From 9dda60e40c8a0fa5e33261808e7dfcf21d16b927 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Lach?= Date: Thu, 22 Jun 2023 18:15:10 +0200 Subject: [PATCH 2/3] =?UTF-8?q?!OSDN:#47828:S=C5=82awomir=20Lach?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add user counter support diff --git a/common/fc_types.h b/common/fc_types.h index 31d71745d3..b247317c22 100644 --- a/common/fc_types.h +++ b/common/fc_types.h @@ -118,6 +118,8 @@ enum output_type_id { #define SPECENUM_VALUE2NAME "Celebration" #define SPECENUM_VALUE3 CB_CITY_DISORDER_TURNS #define SPECENUM_VALUE3NAME "Disorder" +#define SPECENUM_VALUE4 CB_USER +#define SPECENUM_VALUE4NAME "User" #define SPECENUM_COUNT COUNTER_BEHAVIOUR_LAST #include "specenum_gen.h" diff --git a/common/scriptcore/api_game_counters.c b/common/scriptcore/api_game_counters.c index 30a133bd9e..71f9d0bc7d 100644 --- a/common/scriptcore/api_game_counters.c +++ b/common/scriptcore/api_game_counters.c @@ -16,6 +16,7 @@ #endif /* common */ +#include "city.h" #include "counters.h" #include "name_translation.h" @@ -42,3 +43,17 @@ Counter *api_find_counter(lua_State *L, int counter_id) { return counter_by_id(counter_id); } + +void api_counter_increase(lua_State *L,Counter *c, City *city) +{ + LUASCRIPT_CHECK_ARG_NIL(L, city, 3, City, ); + + city->counter_values[counter_index(c)]++; +} + +void api_counter_zero(lua_State *L,Counter *c, City *city) +{ + LUASCRIPT_CHECK_ARG_NIL(L, city, 3, City, ); + + city->counter_values[counter_index(c)] = 0; +} diff --git a/common/scriptcore/api_game_counters.h b/common/scriptcore/api_game_counters.h index b01adb5eab..33c0dc949f 100644 --- a/common/scriptcore/api_game_counters.h +++ b/common/scriptcore/api_game_counters.h @@ -23,4 +23,6 @@ const char *api_counter_rule_name(lua_State *L, Counter *c); const char *api_counter_name_translation(lua_State *L,Counter *c); Counter *api_find_counter_by_name(lua_State *L, const char *name); Counter *api_find_counter(lua_State *L, int counter_id); +void api_counter_increase(lua_State *L,Counter *c, City *city); +void api_counter_zero(lua_State *L,Counter *c, City *city); #endif diff --git a/common/scriptcore/tolua_game.pkg b/common/scriptcore/tolua_game.pkg index cfd651c0bb..4b8afc2d68 100644 --- a/common/scriptcore/tolua_game.pkg +++ b/common/scriptcore/tolua_game.pkg @@ -172,6 +172,8 @@ module game { module Counter { const char *api_counter_rule_name @ rule_name (lua_State *L,Counter *c); const char *api_counter_name_translation @ name_translation (lua_State *L,Counter *c); + void api_counter_increase @ increase (lua_State *L,Counter *c, City *city); + void api_counter_zero @ zero (lua_State *L,Counter *c, City *city); } /* Module Player. */ -- 2.41.0