Initial implementation of 'engio' finished
This commit is contained in:
@@ -569,8 +569,8 @@ void World::invoke(const Invocation &inv) {
|
||||
case Invocation::KIND_CHOOSE:
|
||||
invoke_choose(inv.actor(), inv.place(), inv.datapack());
|
||||
break;
|
||||
case Invocation::KIND_PLAYER:
|
||||
invoke_player(inv.actor(), inv.place(), inv.datapack());
|
||||
case Invocation::KIND_ENGIO:
|
||||
invoke_engio(inv.actor(), inv.place(), inv.datapack());
|
||||
break;
|
||||
case Invocation::KIND_LUA:
|
||||
invoke_lua(inv.actor(), inv.place(), inv.datapack());
|
||||
@@ -769,7 +769,7 @@ void World::invoke_choose(int64_t actor_id, int64_t place_id, std::string_view d
|
||||
assert(stack_is_clear());
|
||||
}
|
||||
|
||||
void World::invoke_player(int64_t actor_id, int64_t place_id, std::string_view datapack) {
|
||||
void World::invoke_engio(int64_t actor_id, int64_t place_id, std::string_view datapack) {
|
||||
assert(stack_is_clear());
|
||||
|
||||
// Get the actor and place. Make sure both exist.
|
||||
@@ -793,7 +793,7 @@ void World::invoke_player(int64_t actor_id, int64_t place_id, std::string_view d
|
||||
} catch (const StreamException &ex) {
|
||||
return;
|
||||
}
|
||||
if (sv::is_lua_id(funcname)) {
|
||||
if (!sv::is_lua_id(funcname)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -812,7 +812,7 @@ void World::invoke_player(int64_t actor_id, int64_t place_id, std::string_view d
|
||||
}
|
||||
|
||||
// Get the closure (playerinvoke.funcname).
|
||||
eng::string err = LS.getclass(playercb, "playerinvoke");
|
||||
eng::string err = LS.getclass(playercb, "engio");
|
||||
if ((!err.empty()) || (!LS.istable(playercb))) {
|
||||
return;
|
||||
}
|
||||
@@ -829,7 +829,30 @@ void World::invoke_player(int64_t actor_id, int64_t place_id, std::string_view d
|
||||
lua_pushvalue(L, place.index());
|
||||
|
||||
// Push any additional args from the datapack.
|
||||
// TODO: IMPLEMENT ME.
|
||||
try {
|
||||
while (!datasb.empty()) {
|
||||
SimpleDynamicTag type = datasb.read_simple_dynamic_tag();
|
||||
switch (type) {
|
||||
case SimpleDynamicTag::NUMBER: {
|
||||
lua_pushnumber(L, datasb.read_double());
|
||||
break;
|
||||
}
|
||||
case SimpleDynamicTag::BOOLEAN: {
|
||||
lua_pushboolean(L, datasb.read_bool() ? 1:0);
|
||||
break;
|
||||
}
|
||||
case SimpleDynamicTag::STRING: {
|
||||
std::string_view s = datasb.read_string_view();
|
||||
lua_pushlstring(L, s.data(), s.size());
|
||||
break;
|
||||
}
|
||||
default: return;
|
||||
}
|
||||
nargs++;
|
||||
}
|
||||
} catch (const StreamException &exc) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Transfer all arguments to the new thread.
|
||||
lua_xmove(L, CO, nargs);
|
||||
|
||||
Reference in New Issue
Block a user