mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 01:53:45 +01:00
Clean up some getServer() unsafety
This commit is contained in:
parent
e39e47b21f
commit
58eccc7a2a
@ -541,8 +541,8 @@ Server* ScriptApiBase::getServer()
|
|||||||
{
|
{
|
||||||
// Since the gamedef is the server it's still possible to retrieve it in
|
// Since the gamedef is the server it's still possible to retrieve it in
|
||||||
// e.g. the async environment, but this isn't meant to happen.
|
// e.g. the async environment, but this isn't meant to happen.
|
||||||
// TODO: still needs work
|
if (getType() != ScriptingType::Server)
|
||||||
//assert(getType() == ScriptingType::Server);
|
return nullptr;
|
||||||
return dynamic_cast<Server *>(m_gamedef);
|
return dynamic_cast<Server *>(m_gamedef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,10 +56,15 @@ EmergeScripting::EmergeScripting(EmergeThread *parent):
|
|||||||
|
|
||||||
InitializeModApi(L, top);
|
InitializeModApi(L, top);
|
||||||
|
|
||||||
auto *data = ModApiBase::getServer(L)->m_lua_globals_data.get();
|
// pull the globals data from the server
|
||||||
assert(data);
|
{
|
||||||
script_unpack(L, data);
|
auto *server = dynamic_cast<Server*>(ModApiBase::getGameDef(L));
|
||||||
lua_setfield(L, top, "transferred_globals");
|
assert(server);
|
||||||
|
auto *data = server->m_lua_globals_data.get();
|
||||||
|
assert(data);
|
||||||
|
script_unpack(L, data);
|
||||||
|
lua_setfield(L, top, "transferred_globals");
|
||||||
|
}
|
||||||
|
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
||||||
|
@ -192,8 +192,10 @@ void ServerScripting::InitializeAsync(lua_State *L, int top)
|
|||||||
LuaVoxelManip::Register(L);
|
LuaVoxelManip::Register(L);
|
||||||
LuaSettings::Register(L);
|
LuaSettings::Register(L);
|
||||||
|
|
||||||
// globals data
|
// pull the globals data from the server
|
||||||
auto *data = ModApiBase::getServer(L)->m_lua_globals_data.get();
|
auto *server = dynamic_cast<Server*>(ModApiBase::getGameDef(L));
|
||||||
|
assert(server);
|
||||||
|
auto *data = server->m_lua_globals_data.get();
|
||||||
assert(data);
|
assert(data);
|
||||||
script_unpack(L, data);
|
script_unpack(L, data);
|
||||||
lua_setfield(L, top, "transferred_globals");
|
lua_setfield(L, top, "transferred_globals");
|
||||||
|
Loading…
Reference in New Issue
Block a user