Rename drv_invoke to drv_call_function

This commit is contained in:
2024-09-03 21:56:53 -04:00
parent bf3e963949
commit 3ed9a7ee2d
4 changed files with 27 additions and 32 deletions

View File

@@ -220,8 +220,8 @@ enum DrvAction {
PLAY_RECV_INCOMING, PLAY_RECV_INCOMING,
PLAY_NOTIFY_CLOSE, PLAY_NOTIFY_CLOSE,
PLAY_NOTIFY_ACCEPT, PLAY_NOTIFY_ACCEPT,
PLAY_CALL_EVENT_UPDATE, PLAY_UPDATE,
PLAY_INVOKE, PLAY_CALL_FUNCTION,
PLAY_RELEASE, PLAY_RELEASE,
}; };
@@ -233,8 +233,8 @@ inline static const char *action_string(DrvAction act) {
case PLAY_RECV_INCOMING: return "PLAY_RECV_INCOMING"; case PLAY_RECV_INCOMING: return "PLAY_RECV_INCOMING";
case PLAY_NOTIFY_CLOSE: return "PLAY_NOTIFY_CLOSE"; case PLAY_NOTIFY_CLOSE: return "PLAY_NOTIFY_CLOSE";
case PLAY_NOTIFY_ACCEPT: return "PLAY_NOTIFY_ACCEPT"; case PLAY_NOTIFY_ACCEPT: return "PLAY_NOTIFY_ACCEPT";
case PLAY_CALL_EVENT_UPDATE: return "PLAY_CALL_EVENT_UPDATE"; case PLAY_UPDATE: return "PLAY_UPDATE";
case PLAY_INVOKE: return "PLAY_INVOKE_LUA_CALL"; case PLAY_CALL_FUNCTION: return "PLAY_CALL_FUNCTION";
case PLAY_RELEASE: return "PLAY_RELEASE"; case PLAY_RELEASE: return "PLAY_RELEASE";
default: return "unknown"; default: return "unknown";
} }
@@ -476,12 +476,12 @@ uint32_t DrivenEngine::drv_notify_accept(uint32_t port) {
return chid; return chid;
} }
void DrivenEngine::drv_call_event_update(double clock) { void DrivenEngine::drv_update(double clock) {
clock_ = clock; clock_ = clock;
event_update(); event_update();
} }
void DrivenEngine::drv_invoke(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); queued_invocations_.emplace_back(inv);
if (kind == InvocationKind::LUA_SOURCE) rescan_lua_source_ = false; if (kind == InvocationKind::LUA_SOURCE) rescan_lua_source_ = false;
@@ -787,52 +787,52 @@ static void replay_notify_accept(EngineWrapper *w) {
//////////////////////// ////////////////////////
static void play_invoke_event_update(EngineWrapper *w, double clock) { static void play_update(EngineWrapper *w, double clock) {
assert(w->rlog == nullptr); assert(w->rlog == nullptr);
if (w->wlog != nullptr) { if (w->wlog != nullptr) {
w->wlog->write_cmd_hash(PLAY_CALL_EVENT_UPDATE, eng::memhash()); w->wlog->write_cmd_hash(PLAY_UPDATE, eng::memhash());
w->wlog->write_double(clock); w->wlog->write_double(clock);
w->wlog->flush(); w->wlog->flush();
} }
w->engine->drv_call_event_update(clock); w->engine->drv_update(clock);
} }
static void replay_invoke_event_update(EngineWrapper *w) { static void replay_update(EngineWrapper *w) {
double clock = w->rlog->read_double(); double clock = w->rlog->read_double();
if (!w->rlog->good()) { if (!w->rlog->good()) {
return reset_wrapper(w, "replay log corrupt in replay_event_update"); return reset_wrapper(w, "replay log corrupt in replay_event_update");
} }
w->engine->drv_call_event_update(clock); w->engine->drv_update(clock);
} }
//////////////////////// ////////////////////////
void play_invoke(EngineWrapper *w, InvocationKind kind, int64_t place, uint32_t datapklen, const char *datapk) { void play_call_function(EngineWrapper *w, InvocationKind kind, int64_t place, uint32_t datapklen, const char *datapk) {
assert(w->rlog == nullptr); assert(w->rlog == nullptr);
if (w->wlog != nullptr) { if (w->wlog != nullptr) {
w->wlog->write_cmd_hash(PLAY_INVOKE, eng::memhash()); w->wlog->write_cmd_hash(PLAY_CALL_FUNCTION, eng::memhash());
w->wlog->write_uint8(int64_t(kind)); w->wlog->write_uint8(int64_t(kind));
w->wlog->write_int64(place); w->wlog->write_int64(place);
w->wlog->write_string(std::string_view(datapk, datapklen)); w->wlog->write_string(std::string_view(datapk, datapklen));
w->wlog->flush(); w->wlog->flush();
} }
w->engine->drv_invoke(kind, place, datapklen, datapk); w->engine->drv_call_function(kind, place, datapklen, datapk);
} }
void replay_invoke(EngineWrapper *w) { void replay_call_function(EngineWrapper *w) {
InvocationKind kind = InvocationKind(w->rlog->read_uint8()); InvocationKind kind = InvocationKind(w->rlog->read_uint8());
int64_t place = w->rlog->read_int64(); int64_t place = w->rlog->read_int64();
std::string srcpack = w->rlog->read_string(); std::string srcpack = w->rlog->read_string();
if (!w->rlog->good()) { if (!w->rlog->good()) {
return reset_wrapper(w, "replay log corrupt in replay_invoke_lua_call"); return reset_wrapper(w, "replay log corrupt in replay_call_function_lua_call");
} }
w->engine->drv_invoke(kind, place, srcpack.size(), srcpack.c_str()); w->engine->drv_call_function(kind, place, srcpack.size(), srcpack.c_str());
} }
@@ -902,8 +902,8 @@ static void replaycore_step(EngineWrapper *w) {
case PLAY_RECV_INCOMING: replay_recv_incoming(w); return; case PLAY_RECV_INCOMING: replay_recv_incoming(w); return;
case PLAY_NOTIFY_CLOSE: replay_notify_close(w); return; case PLAY_NOTIFY_CLOSE: replay_notify_close(w); return;
case PLAY_NOTIFY_ACCEPT: replay_notify_accept(w); return; case PLAY_NOTIFY_ACCEPT: replay_notify_accept(w); return;
case PLAY_CALL_EVENT_UPDATE: replay_invoke_event_update(w); return; case PLAY_UPDATE: replay_update(w); return;
case PLAY_INVOKE: replay_invoke(w); return; case PLAY_CALL_FUNCTION: replay_call_function(w); return;
case PLAY_RELEASE: release(w); return; case PLAY_RELEASE: release(w); return;
default: return reset_wrapper(w, "Replay log corrupt in command dispatcher"); default: return reset_wrapper(w, "Replay log corrupt in command dispatcher");
} }
@@ -963,8 +963,8 @@ static void init_engine_wrapper_helper(EngineWrapper *w) {
w->play_recv_incoming = play_recv_incoming; w->play_recv_incoming = play_recv_incoming;
w->play_notify_close = play_notify_close; w->play_notify_close = play_notify_close;
w->play_notify_accept = play_notify_accept; w->play_notify_accept = play_notify_accept;
w->play_invoke_event_update = play_invoke_event_update; w->play_update = play_update;
w->play_invoke = play_invoke; w->play_call_function = play_call_function;
w->replay_initialize = replaycore_initialize; w->replay_initialize = replaycore_initialize;
w->replay_step = replaycore_step; w->replay_step = replaycore_step;

View File

@@ -152,11 +152,6 @@ public:
// //
virtual void event_update() = 0; virtual void event_update() = 0;
// // The probe callback. You may override this in a subclass.
// // This will be called whenever the driver wants to probe the state of the world.
// //
// virtual void event_probe(InvocationKind kind, int64_t place, std::string_view datapack, StreamBuffer *retvals) = 0;
// Specify the set of listening ports. // Specify the set of listening ports.
// This can only be used during the init routine. // This can only be used during the init routine.
// //
@@ -297,8 +292,8 @@ public:
void drv_recv_incoming(uint32_t chid, uint32_t nbytes, const char *bytes); void drv_recv_incoming(uint32_t chid, uint32_t nbytes, const char *bytes);
void drv_notify_close(uint32_t chid, uint32_t len, const char *data); void drv_notify_close(uint32_t chid, uint32_t len, const char *data);
uint32_t drv_notify_accept(uint32_t port); uint32_t drv_notify_accept(uint32_t port);
void drv_call_event_update(double clock); void drv_update(double clock);
void drv_invoke(InvocationKind kind, int64_t place, uint32_t datapklen, const char *datapk); void drv_call_function(InvocationKind kind, int64_t place, uint32_t datapklen, const char *datapk);
private: private:
// Find a currently-unused channel ID. Channel IDs // Find a currently-unused channel ID. Channel IDs

View File

@@ -204,14 +204,14 @@ struct EngineWrapper {
// and it should roughly be equal to the number of seconds since // and it should roughly be equal to the number of seconds since
// the program started. // the program started.
// //
void (*play_invoke_event_update)(EngineWrapper *w, double clock); void (*play_update)(EngineWrapper *w, double clock);
// Send an invoke. // Send an invoke.
// //
// This is the main pathway for blueprints, or the unreal C++ code, // This is the main pathway for blueprints, or the unreal C++ code,
// to change the state of the world. // to change the state of the world.
// //
void (*play_invoke)(EngineWrapper *w, InvocationKind kind, int64_t place, uint32_t datapklen, const char *datapk); void (*play_call_function)(EngineWrapper *w, InvocationKind kind, int64_t place, uint32_t datapklen, const char *datapk);
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////

View File

@@ -193,7 +193,7 @@ class Driver {
std::string err = drvutil::package_lua_source(".", &oss); std::string err = drvutil::package_lua_source(".", &oss);
if_error_print_and_exit(err); if_error_print_and_exit(err);
std::string_view ossv = oss.view(); std::string_view ossv = oss.view();
engw.play_invoke(&engw, InvocationKind::LUA_SOURCE, 0, ossv.size(), ossv.data()); engw.play_call_function(&engw, InvocationKind::LUA_SOURCE, 0, ossv.size(), ossv.data());
} }
} }
@@ -667,7 +667,7 @@ class Driver {
handle_socket_input_output(); handle_socket_input_output();
handle_console_input(); handle_console_input();
handle_console_output(); handle_console_output();
engw.play_invoke_event_update(&engw, drvutil::get_monotonic_clock()); engw.play_update(&engw, drvutil::get_monotonic_clock());
} }
// Cleanup // Cleanup