Use fewer pointers refactor: get rid of visible_world_ in drivenengine. The world is now fully owned by the drivenengine.

This commit is contained in:
2026-02-21 19:27:42 -05:00
parent 48b7bf37da
commit 00ef81bf0d
4 changed files with 47 additions and 63 deletions

View File

@@ -211,14 +211,6 @@ public:
//
void set_have_prints(bool b) { have_prints_ = b; }
// Set the world pointer and the actor ID.
//
// This allows the graphics engine to query the DrivenEngine
// about the state of the world and the player. It is legal to set these
// to zero, in which case queries will return null results.
//
void set_visible_world_and_actor(World *w, int64_t actor);
// Stop the driver. The engine should call this when it's done
// and there's nothing left to do.
//
@@ -287,21 +279,36 @@ private:
// Get the channel associated with the specified channel ID.
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
// DrivenEngine can store an actor_id here.
//
int64_t actor_id_ = 0;
private:
SharedChannel channels_[DRV_MAX_CHAN];
int next_unused_chid_;
int next_unused_chid_ = 1;
eng::vector<SharedChannel> accepted_channels_;
eng::vector<uint32_t> new_outgoing_;
eng::vector<uint32_t> listen_ports_;
World *visible_world_;
int64_t visible_actor_id_;
util::IdVector scan_result_;
std::vector<util::SharedStdString> anim_queues_;
StreamBuffer call_function_retpk_;
bool rescan_lua_source_;
double clock_;
bool have_prints_;
bool stop_driver_;
bool rescan_lua_source_ = false;
double clock_ = 0.0;
bool have_prints_ = false;
bool stop_driver_ = false;
friend class Channel;
};