Refactor to remove dependency of DrivenEngine on World

This commit is contained in:
2026-02-24 22:36:01 -05:00
parent 8889a36ba3
commit a7027873ab
10 changed files with 194 additions and 92 deletions

View File

@@ -52,15 +52,14 @@
#include "util.hpp"
#include "streambuffer.hpp"
#include "enginewrapper.hpp"
#include "planemap.hpp"
#include "invocation.hpp"
class DrivenEngine;
class World;
using UniqueDrivenEngine = std::unique_ptr<DrivenEngine>;
using DrivenEngineMaker = UniqueDrivenEngine (*)();
using DrivenEngineMaker = UniqueDrivenEngine (*)(EngineWrapper *);
using DrivenEngineInitializer = void (*)();
class Channel : public eng::opnew {
public:
// Get the buffers associated with this channel.
@@ -222,6 +221,12 @@ public:
//
//////////////////////////////////////////////////////////////
// Reset the wrapper's world-related function pointers back to
// defaults that return empty results. Call this before destroying
// a World that was previously exposed via World::setup_wrapper.
//
static void unexpose_world_to_driver(EngineWrapper *w);
// Constructor.
//
// Most initialization is achieved by 'drv_xxx' functions, so
@@ -260,8 +265,6 @@ public:
bool drv_get_rescan_lua_source() const;
bool drv_get_stop_driver() const;
int64_t drv_get_actor_id() const;
void drv_get_tangibles_near(int64_t tanid, double rx, double ry, double rz, uint32_t *count, int64_t **ids);
void drv_get_animation_queues(uint32_t count, const int64_t *ids, uint32_t *lengths, const char **strings);
void drv_clear_new_outgoing();
void drv_sent_outgoing(uint32_t chid, uint32_t nbytes);
@@ -280,15 +283,6 @@ private:
Channel *get_chid(int chid) const;
protected:
// The DrivenEngine can optionally contain
// a world model. This is initialized to
// nullptr, but classes that derive from
// DrivenEngine can store a world model here.
// If they do, then functions like get_near
// will reference this model.
//
std::unique_ptr<World> world_;
// When the Driver calls get_actor_id,
// we return this value. This is initialized
// to zero, but classes that derive from
@@ -302,8 +296,6 @@ private:
eng::vector<SharedChannel> accepted_channels_;
eng::vector<uint32_t> new_outgoing_;
eng::vector<uint32_t> listen_ports_;
util::IdVector scan_result_;
std::vector<util::SharedStdString> anim_queues_;
StreamBuffer call_function_retpk_;
bool rescan_lua_source_ = false;
double clock_ = 0.0;
@@ -324,8 +316,8 @@ struct DrivenEngineReg {
};
#define DrivenEngineDefine(name, cname) \
UniqueDrivenEngine dengmake_##cname() { \
return UniqueDrivenEngine(new cname); \
UniqueDrivenEngine dengmake_##cname(EngineWrapper *w) { \
return UniqueDrivenEngine(new cname(w)); \
} \
DrivenEngineReg dengreg_##cname(name, dengmake_##cname);