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;
|
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() {
|
void DrivenEngine::rescan_lua_source() {
|
||||||
rescan_lua_source_ = true;
|
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) {
|
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));
|
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;
|
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;
|
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.
|
// The update callback. You may override this in a subclass.
|
||||||
// This will be called whenever anything changes.
|
// This will be called whenever anything changes.
|
||||||
//
|
//
|
||||||
@@ -211,15 +217,10 @@ public:
|
|||||||
//
|
//
|
||||||
void set_console_prompt(const eng::string &prompt);
|
void set_console_prompt(const eng::string &prompt);
|
||||||
|
|
||||||
// Fetches the invocation queue.
|
// Set the flag to rescan the lua source directory. The lua source
|
||||||
//
|
// directory is read once, automatically, at engine creation time.
|
||||||
// This also clears the stored queue.
|
// If you want to read it again, you must trigger a rescan.
|
||||||
//
|
// The rescan is not instantaneous.
|
||||||
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.
|
|
||||||
//
|
//
|
||||||
// DRIVER: this merely sets a flag, which the driver will notice later,
|
// DRIVER: this merely sets a flag, which the driver will notice later,
|
||||||
// causing the driver to update the lua source.
|
// causing the driver to update the lua source.
|
||||||
@@ -315,7 +316,6 @@ private:
|
|||||||
int64_t visible_actor_id_;
|
int64_t visible_actor_id_;
|
||||||
util::IdVector scan_result_;
|
util::IdVector scan_result_;
|
||||||
std::vector<util::SharedStdString> anim_queues_;
|
std::vector<util::SharedStdString> anim_queues_;
|
||||||
eng::vector<UniqueInvocation> queued_invocations_;
|
|
||||||
bool rescan_lua_source_;
|
bool rescan_lua_source_;
|
||||||
double clock_;
|
double clock_;
|
||||||
bool stop_driver_;
|
bool stop_driver_;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public:
|
|||||||
SharedChannel channel_;
|
SharedChannel channel_;
|
||||||
LuaConsole console_;
|
LuaConsole console_;
|
||||||
PrintChanneler print_channeler_;
|
PrintChanneler print_channeler_;
|
||||||
|
eng::vector<UniqueInvocation> delayed_invocations_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void set_initial_state_connect(const eng::string &hostspec) {
|
void set_initial_state_connect(const eng::string &hostspec) {
|
||||||
@@ -245,12 +246,16 @@ public:
|
|||||||
return true;
|
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() {
|
virtual void event_update() {
|
||||||
// Send invocations. We execute these using predictive execution.
|
// Send invocations. We execute these using predictive execution.
|
||||||
eng::vector<UniqueInvocation> invocations = get_queued_invocations();
|
for (const UniqueInvocation &inv : delayed_invocations_) {
|
||||||
for (const UniqueInvocation &inv : invocations) {
|
|
||||||
send_invocation(*inv);
|
send_invocation(*inv);
|
||||||
}
|
}
|
||||||
|
delayed_invocations_.clear();
|
||||||
|
|
||||||
// Check for keyboard input on stdin.
|
// Check for keyboard input on stdin.
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|||||||
@@ -192,16 +192,20 @@ public:
|
|||||||
return true;
|
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 {
|
virtual void event_update() override {
|
||||||
// Get the clock.
|
// Get the clock.
|
||||||
double clock = get_clock();
|
double clock = get_clock();
|
||||||
|
|
||||||
// Execute any queued invocations.
|
// Execute any queued invocations.
|
||||||
// We just feed these directly into the master model.
|
// We just feed these directly into the master model.
|
||||||
eng::vector<UniqueInvocation> invocations = get_queued_invocations();
|
for (const UniqueInvocation &inv : delayed_invocations_) {
|
||||||
for (const UniqueInvocation &inv : invocations) {
|
|
||||||
master_->invoke(*inv);
|
master_->invoke(*inv);
|
||||||
}
|
}
|
||||||
|
delayed_invocations_.clear();
|
||||||
|
|
||||||
// Check for keyboard input on stdin.
|
// Check for keyboard input on stdin.
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|||||||
Reference in New Issue
Block a user