From 14df301b7f9a2f5457f1346577e7ff7ce7590e43 Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Mon, 16 Sep 2024 23:20:50 -0400 Subject: [PATCH] Wrap all LATTR_[GS]ETTER macros in anonymous namespaces Without this, seemingly random link errors occur when either file is modified. --- src/scripting/game_lua_kernel.cpp | 10 ++++++++++ src/scripting/lua_kernel_base.cpp | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/scripting/game_lua_kernel.cpp b/src/scripting/game_lua_kernel.cpp index 5ceda504110..6797e6ecbbe 100644 --- a/src/scripting/game_lua_kernel.cpp +++ b/src/scripting/game_lua_kernel.cpp @@ -992,6 +992,7 @@ int game_lua_kernel::impl_schedule_dir(lua_State *L) { return scheduleReg.dir(L); } +namespace { SCHEDULE_GETTER("time_of_day", std::string) { if(sched.area_index >= 0) { return sched.tod_man().get_area_time_of_day(sched.area_index).id; @@ -1084,6 +1085,7 @@ SCHEDULE_SETTER("hexes", std::set) { } sched.tod_man().replace_area_locations(sched.area_index, value); } +} /** * Gets details about a terrain. @@ -1354,6 +1356,7 @@ GAME_CONFIG_SETTER(#name, decltype(game_config::name), game_lua_kernel) { \ game_config::name = value; \ } +namespace { GAME_CONFIG_GETTER("do_healing", bool, game_lua_kernel) { game_config_glk_tag k2{k.ref}; return k2.pc().gamestate().do_healing_; @@ -1395,6 +1398,7 @@ GAME_CONFIG_SIMPLE_SETTER(rest_heal_amount); GAME_CONFIG_SIMPLE_SETTER(recall_cost); GAME_CONFIG_SIMPLE_SETTER(kill_experience); GAME_CONFIG_SIMPLE_SETTER(combat_experience); +} namespace { static config find_addon(const std::string& type, const std::string& id) @@ -1607,6 +1611,7 @@ template<> struct lua_object_traits { } }; +namespace { SCENARIO_GETTER("turns", int) { return k.tod_man().number_of_turns(); } @@ -1770,6 +1775,7 @@ SCENARIO_GETTER("era", utils::optional) { if(!k.cls().is_multiplayer()) return utils::nullopt; return find_addon("era", k.cls().era_id); } +} /** * Gets some scenario data (__index metamethod). @@ -1846,6 +1852,7 @@ template<> struct lua_object_traits { } }; +namespace { CURRENT_GETTER("side", int) { return k.pc().current_side(); } @@ -1904,6 +1911,7 @@ CURRENT_GETTER("event_context", config) { } return cfg; } +} /** * Gets some data about current point of game (__index metamethod). @@ -5137,12 +5145,14 @@ template<> struct lua_object_traits { } }; +namespace { CALLBACK_GETTER("on_event", void); CALLBACK_GETTER("on_load", void); CALLBACK_GETTER("on_save", config); CALLBACK_GETTER("on_mouse_action", void); CALLBACK_GETTER("on_mouse_button", bool); CALLBACK_GETTER("on_mouse_move", void); +} static int impl_game_events_dir(lua_State* L) { return callbacksReg.dir(L); diff --git a/src/scripting/lua_kernel_base.cpp b/src/scripting/lua_kernel_base.cpp index 1000c2d0d87..e0d64787dd5 100644 --- a/src/scripting/lua_kernel_base.cpp +++ b/src/scripting/lua_kernel_base.cpp @@ -1285,6 +1285,7 @@ GAME_CONFIG_GETTER(#name, decltype(game_config::name), lua_kernel_base) { \ return game_config::name; \ } +namespace { GAME_CONFIG_SIMPLE_GETTER(base_income); GAME_CONFIG_SIMPLE_GETTER(village_income); GAME_CONFIG_SIMPLE_GETTER(village_support); @@ -1336,6 +1337,7 @@ GAME_CONFIG_GETTER("blue_white_scale_text", lua_index_raw, lua_kernel_base) { push_color_palette(L, game_config::blue_white_scale_text); return lua_index_raw(L); } +} /** * Gets some game_config data (__index metamethod).