aboutsummaryrefslogtreecommitdiff
path: root/src/state.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/state.cpp')
-rw-r--r--src/state.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/state.cpp b/src/state.cpp
index e258f9e..90a7c5b 100644
--- a/src/state.cpp
+++ b/src/state.cpp
@@ -218,8 +218,7 @@ static void copy_one_time_settings(Universe* U_, SourceState L1_, DestState L2_)
218void InitializeOnStateCreate(Universe* U_, lua_State* L_) 218void InitializeOnStateCreate(Universe* U_, lua_State* L_)
219{ 219{
220 STACK_CHECK_START_REL(L_, 1); // L_: settings 220 STACK_CHECK_START_REL(L_, 1); // L_: settings
221 lua_getfield(L_, -1, "on_state_create"); // L_: settings on_state_create|nil 221 if (luaG_getfield(L_, -1, "on_state_create") != LuaType::NIL) { // L_: settings on_state_create|nil
222 if (!lua_isnil(L_, -1)) {
223 // store C function pointer in an internal variable 222 // store C function pointer in an internal variable
224 U_->onStateCreateFunc = lua_tocfunction(L_, -1); // L_: settings on_state_create 223 U_->onStateCreateFunc = lua_tocfunction(L_, -1); // L_: settings on_state_create
225 if (U_->onStateCreateFunc != nullptr) { 224 if (U_->onStateCreateFunc != nullptr) {
@@ -289,7 +288,7 @@ void CallOnStateCreate(Universe* U_, lua_State* L_, lua_State* from_, LookupMode
289 } 288 }
290 kConfigRegKey.pushValue(L_); // L_: {} 289 kConfigRegKey.pushValue(L_); // L_: {}
291 STACK_CHECK(L_, 1); 290 STACK_CHECK(L_, 1);
292 lua_getfield(L_, -1, "on_state_create"); // L_: {} on_state_create() 291 std::ignore = luaG_getfield(L_, -1, "on_state_create"); // L_: {} on_state_create()
293 lua_remove(L_, -2); // L_: on_state_create() 292 lua_remove(L_, -2); // L_: on_state_create()
294 } 293 }
295 STACK_CHECK(L_, 1); 294 STACK_CHECK(L_, 1);