Refactor: remove references to class World from util and luastack. These are low-level modules that should not reference class World.

This commit is contained in:
2026-02-21 21:42:53 -05:00
parent 7e7f9bf147
commit e9d185acb0
5 changed files with 21 additions and 43 deletions

View File

@@ -94,8 +94,8 @@ lua_State *LuaCoreStack::newstate (lua_Alloc allocf) {
lua_pushstring(L, "tangibles");
lua_newtable(L);
lua_rawset(L, LUA_REGISTRYINDEX);
lua_pushstring(L, "worldtype");
lua_pushnumber(L, WORLD_TYPE_MASTER);
lua_pushstring(L, "is_authoritative");
lua_pushboolean(L, 1);
lua_rawset(L, LUA_REGISTRYINDEX);
return L;
@@ -687,24 +687,19 @@ void LuaCoreStack::setvisited(LuaSlot tab, bool visited) const {
lua_modflagbits(L_, tab.index(), 0x0010, visited ? 0x0010 : 0);
}
WorldType LuaCoreStack::get_world_type() const {
lua_pushstring(L_, "worldtype");
lua_rawget(L_, LUA_REGISTRYINDEX);
lua_Integer n = lua_tointeger(L_, -1);
lua_pop(L_, 1);
assert(n != 0);
return (WorldType)n;
}
void LuaCoreStack::set_world_type(WorldType t) const {
lua_pushstring(L_, "worldtype");
lua_pushnumber(L_, (int)t);
void LuaCoreStack::set_authoritative(bool auth) const {
lua_pushstring(L_, "is_authoritative");
lua_pushboolean(L_, auth ? 1 : 0);
lua_rawset(L_, LUA_REGISTRYINDEX);
}
void LuaCoreStack::guard_nopredict(const char *fn) {
if (lua_isyieldable(L_)) {
if (!is_authoritative()) {
lua_pushstring(L_, "is_authoritative");
lua_rawget(L_, LUA_REGISTRYINDEX);
bool auth = lua_toboolean(L_, -1);
lua_pop(L_, 1);
if (!auth) {
lua_yield(L_, 0);
luaL_error(L_, "unexplained nopredict failure in %s", fn);
}