Get rid of invoke_engio

This commit is contained in:
2024-08-29 17:45:05 -04:00
parent 368581463e
commit d4f46eef45
7 changed files with 7 additions and 103 deletions

View File

@@ -551,9 +551,6 @@ void World::run_unittests() {
void World::invoke(const Invocation &inv) {
switch (inv.kind()) {
case Invocation::KIND_ENGIO:
invoke_engio(inv.actor(), inv.place(), inv.datapack());
break;
case Invocation::KIND_LUA_CALL:
invoke_lua_call(inv.actor(), inv.place(), inv.datapack());
break;
@@ -742,50 +739,6 @@ void push_simple_dynamic(lua_State *L, StreamBuffer *sb) {
}
}
void World::invoke_engio(int64_t actor_id, int64_t place_id, std::string_view datapack) {
assert(stack_is_clear());
// Use a streambuffer to parse the datapack.
StreamBuffer datasb(datapack);
// Extract the function name from the datapack.
eng::string funcname;
try {
funcname = datasb.read_string_limit(100);
} catch (const StreamException &ex) {
return;
}
if (!sv::is_lua_id(funcname)) {
return;
}
{
lua_State *L = state();
LuaVar engio, func;
LuaExtStack LS(L, engio, func);
// Get the closure (engio.funcname).
eng::string err = LS.getclass(engio, "engio");
if ((!err.empty()) || (!LS.istable(engio))) {
return;
}
LS.rawget(func, engio, funcname);
// Spawn a thread, pushing extra arguments from the datapack.
int nargs = 0;
try {
while (!datasb.empty()) {
push_simple_dynamic(L, &datasb);
nargs++;
}
} catch (const StreamException &exc) {
return;
}
spawn(LS, actor_id, place_id, func, true, nargs, false);
}
run_scheduled_threads();
assert(stack_is_clear());
}
void World::invoke_lua_call(int64_t actor_id, int64_t place_id, std::string_view datapack) {
assert(stack_is_clear());