Move queued invocations down into lpxserver/lpxclient
This commit is contained in:
@@ -165,12 +165,6 @@ void DrivenEngine::set_console_prompt(const eng::string &prompt) {
|
||||
console_prompt_ = prompt;
|
||||
}
|
||||
|
||||
eng::vector<UniqueInvocation> DrivenEngine::get_queued_invocations() {
|
||||
eng::vector<UniqueInvocation> result = std::move(queued_invocations_);
|
||||
queued_invocations_.clear();
|
||||
return result;
|
||||
}
|
||||
|
||||
void DrivenEngine::rescan_lua_source() {
|
||||
rescan_lua_source_ = true;
|
||||
}
|
||||
@@ -483,8 +477,9 @@ void DrivenEngine::drv_update(double clock) {
|
||||
|
||||
void DrivenEngine::drv_call_function(InvocationKind kind, int64_t place, uint32_t datapklen, const char *datapk) {
|
||||
Invocation *inv = new Invocation(kind, visible_actor_id_, place, std::string_view(datapk, datapklen));
|
||||
queued_invocations_.emplace_back(inv);
|
||||
// This next line is a hack, because the DrivenEngine is not supposed to care about 'kind'.
|
||||
if (kind == InvocationKind::LUA_SOURCE) rescan_lua_source_ = false;
|
||||
event_call_function(kind, place, std::string_view(datapklen, datapk));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -147,6 +147,12 @@ public:
|
||||
//
|
||||
virtual void event_init(std::string_view srcpk, int argc, char *argv[]) = 0;
|
||||
|
||||
// The call-function callback. This is invoked whenever drv_call_function
|
||||
// is called. This is the main entry point for "general" access into the
|
||||
// DrivenEngine.
|
||||
//
|
||||
virtual void event_call_function(InvocationKind kind, int64_t place, std::string_view datapk) {};
|
||||
|
||||
// The update callback. You may override this in a subclass.
|
||||
// This will be called whenever anything changes.
|
||||
//
|
||||
@@ -210,16 +216,11 @@ public:
|
||||
// Set the prompt for the console.
|
||||
//
|
||||
void set_console_prompt(const eng::string &prompt);
|
||||
|
||||
// Fetches the invocation queue.
|
||||
//
|
||||
// This also clears the stored queue.
|
||||
//
|
||||
eng::vector<UniqueInvocation> get_queued_invocations();
|
||||
|
||||
// Rescan the lua source directory. The lua source directory is read once,
|
||||
// automatically, at engine creation time. If you want to read it again,
|
||||
// you must trigger a rescan. The rescan is not instantaneous.
|
||||
// Set the flag to rescan the lua source directory. The lua source
|
||||
// directory is read once, automatically, at engine creation time.
|
||||
// If you want to read it again, you must trigger a rescan.
|
||||
// The rescan is not instantaneous.
|
||||
//
|
||||
// DRIVER: this merely sets a flag, which the driver will notice later,
|
||||
// causing the driver to update the lua source.
|
||||
@@ -315,7 +316,6 @@ private:
|
||||
int64_t visible_actor_id_;
|
||||
util::IdVector scan_result_;
|
||||
std::vector<util::SharedStdString> anim_queues_;
|
||||
eng::vector<UniqueInvocation> queued_invocations_;
|
||||
bool rescan_lua_source_;
|
||||
double clock_;
|
||||
bool stop_driver_;
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
SharedChannel channel_;
|
||||
LuaConsole console_;
|
||||
PrintChanneler print_channeler_;
|
||||
eng::vector<UniqueInvocation> delayed_invocations_;
|
||||
|
||||
public:
|
||||
void set_initial_state_connect(const eng::string &hostspec) {
|
||||
@@ -245,12 +246,16 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void event_call_function(InvocationKind kind, int64_t place, std::string_view datapk) {
|
||||
delayed_invocations_.emplace_back(kind, place, datapk);
|
||||
}
|
||||
|
||||
virtual void event_update() {
|
||||
// Send invocations. We execute these using predictive execution.
|
||||
eng::vector<UniqueInvocation> invocations = get_queued_invocations();
|
||||
for (const UniqueInvocation &inv : invocations) {
|
||||
for (const UniqueInvocation &inv : delayed_invocations_) {
|
||||
send_invocation(*inv);
|
||||
}
|
||||
delayed_invocations_.clear();
|
||||
|
||||
// Check for keyboard input on stdin.
|
||||
while (true) {
|
||||
|
||||
@@ -192,16 +192,20 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void event_call_function(InvocationKind kind, int64_t place, std::string_view datapk) {
|
||||
delayed_invocations_.emplace_back(kind, place, datapk);
|
||||
}
|
||||
|
||||
virtual void event_update() override {
|
||||
// Get the clock.
|
||||
double clock = get_clock();
|
||||
|
||||
// Execute any queued invocations.
|
||||
// We just feed these directly into the master model.
|
||||
eng::vector<UniqueInvocation> invocations = get_queued_invocations();
|
||||
for (const UniqueInvocation &inv : invocations) {
|
||||
for (const UniqueInvocation &inv : delayed_invocations_) {
|
||||
master_->invoke(*inv);
|
||||
}
|
||||
delayed_invocations_.clear();
|
||||
|
||||
// Check for keyboard input on stdin.
|
||||
while (true) {
|
||||
|
||||
Reference in New Issue
Block a user