From 979575659b2ca74d29fc32774deef4242c61fab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Lach?= Date: Sat, 17 Feb 2024 18:26:24 +0100 Subject: [PATCH 1/2] =?UTF-8?q?!OSDN:47829:S=C5=82awomir=20Lach=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement city's counter value getter for lua scripts. diff --git a/server/scripting/api_server_counters.c b/server/scripting/api_server_counters.c index dc546780ca..d0311c85c4 100644 --- a/server/scripting/api_server_counters.c +++ b/server/scripting/api_server_counters.c @@ -65,3 +65,13 @@ void api_counter_zero(lua_State *L, Counter *c, City *city) city_counters_refresh(city); } + +/**********************************************************************//** + Obtain city's counter value +**************************************************************************/ +int api_counter_city_get(lua_State *L, Counter *c, City *city) +{ + LUASCRIPT_CHECK_ARG_NIL(L, city, 3, City, -1); + + return city->counter_values[counter_index(c)]; +} diff --git a/server/scripting/api_server_counters.h b/server/scripting/api_server_counters.h index d4500ae02a..29e651ed23 100644 --- a/server/scripting/api_server_counters.h +++ b/server/scripting/api_server_counters.h @@ -21,4 +21,5 @@ struct lua_State; void api_counter_increase(lua_State *L, Counter *c, City *city); void api_counter_zero(lua_State *L, Counter *c, City *city); +int api_counter_city_get(lua_State *L, Counter *c, City *city); #endif /* FCAPI_GAME_COUNTERS_H */ diff --git a/server/scripting/tolua_server.pkg b/server/scripting/tolua_server.pkg index bc0d69fc16..cb5a94a3e8 100644 --- a/server/scripting/tolua_server.pkg +++ b/server/scripting/tolua_server.pkg @@ -60,6 +60,7 @@ module server { module Counter { void api_counter_increase @ increase (lua_State *L, Counter *c, City *city); void api_counter_zero @ zero (lua_State *L, Counter *c, City *city); + int api_counter_city_get @ get (lua_State *L, Counter *c, City *city); } /* Notify module. */ -- 2.43.1