diff --git a/luprex/cpp/core/luastack.cpp b/luprex/cpp/core/luastack.cpp index 6169dc91..c30b199f 100644 --- a/luprex/cpp/core/luastack.cpp +++ b/luprex/cpp/core/luastack.cpp @@ -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) { diff --git a/luprex/cpp/core/luastack.hpp b/luprex/cpp/core/luastack.hpp index eb163f19..5b2a6db3 100644 --- a/luprex/cpp/core/luastack.hpp +++ b/luprex/cpp/core/luastack.hpp @@ -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. // diff --git a/luprex/cpp/core/world-core.cpp b/luprex/cpp/core/world-core.cpp index 7ae96a43..1dfe4df6 100644 --- a/luprex/cpp/core/world-core.cpp +++ b/luprex/cpp/core/world-core.cpp @@ -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,14 +1000,12 @@ 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()) { - lua_yield(L, 0); - luaL_error(L, "unexplained nopredict failure in %s", fn); + if (lthread_thread_id_ == 0) return; + if (lua_isyieldable(L)) { + lua_yield(L, 0); + luaL_error(L, "unexplained nopredict failure in %s", fn); + } } }