Another refactor to remove references to the world model from LuaStack

This commit is contained in:
2026-02-21 22:00:23 -05:00
parent e9d185acb0
commit afa8c698be
3 changed files with 5 additions and 42 deletions

View File

@@ -94,10 +94,6 @@ lua_State *LuaCoreStack::newstate (lua_Alloc allocf) {
lua_pushstring(L, "tangibles");
lua_newtable(L);
lua_rawset(L, LUA_REGISTRYINDEX);
lua_pushstring(L, "is_authoritative");
lua_pushboolean(L, 1);
lua_rawset(L, LUA_REGISTRYINDEX);
return L;
}
@@ -687,24 +683,6 @@ void LuaCoreStack::setvisited(LuaSlot tab, bool visited) const {
lua_modflagbits(L_, tab.index(), 0x0010, visited ? 0x0010 : 0);
}
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_)) {
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);
}
}
}
static int tailcall_continuation(lua_State *L)
{

View File

@@ -989,17 +989,6 @@ public:
//
void setvisited(LuaSlot tab, bool visited) const;
// Store whether the world is authoritative in the
// registry. This is used to implement guard_nopredict.
//
void set_authoritative(bool auth) const;
// Yield this thread with zero if in a nonauth model, and not a probe.
//
// The function name is just used for generating better error messages.
//
void guard_nopredict(const char *fn);
// This is the largest integer that can be stored in a lua_Number.
// In other words, any 53-bit number can be stored.
//

View File

@@ -131,8 +131,6 @@ World::World(WorldType wt) {
LS.getglobaltable(globtab);
LS.settabletype(globtab, LUA_TT_GLOBALENV);
// Store whether the world is authoritative in the registry.
LS.set_authoritative(wt == WORLD_TYPE_MASTER);
// Create the globaldb in the registry.
LS.rawset(LuaRegistry, "globaldb", LuaNewTable);
@@ -1002,15 +1000,13 @@ void World::guard_blockable(lua_State *L, const char *fn) {
}
void World::guard_nopredict(lua_State *L, const char *fn) {
// Caution: this code must be equivalent to the
// code in LuaCoreStack::guard_nopredict.
if (lthread_thread_id_ == 0) {
return;
}
if (!is_authoritative()) {
if (lthread_thread_id_ == 0) return;
if (lua_isyieldable(L)) {
lua_yield(L, 0);
luaL_error(L, "unexplained nopredict failure in %s", fn);
}
}
}
void World::schedule(int64_t clk, int64_t thid, int64_t plid) {