From a533828c6e6909c101ef8e2849504b3dc6b21875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Lach?= Date: Sun, 17 Apr 2022 10:34:09 +0200 Subject: [PATCH 1/3] =?UTF-8?q?OSDN!41121=20S=C5=82awomir=20Lach=20=20-=20Type=20system=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change enum related C-code types into freeciv specenum --- common/counters.c | 5 +++-- common/counters.h | 13 ++++++++----- server/citytools.c | 2 +- server/srv_main.c | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/common/counters.c b/common/counters.c index 728a113d23..aa3f647c15 100644 --- a/common/counters.c +++ b/common/counters.c @@ -25,7 +25,7 @@ static struct counter counters[MAX_COUNTERS] = { - { (struct name_translation) NAME_INIT, COUNTER_OWNED, CTGT_CITY, 5, 0 } + { (struct name_translation) NAME_INIT, CB_CITY_OWNED_TURNS, CTGT_CITY, 5, 0 } }; static struct counter *counters_city[MAX_COUNTERS]; @@ -44,7 +44,7 @@ void counters_init(void) for (i = 0; i < MAX_COUNTERS; i++) { - if (counters[i].type == COUNTER_OWNED) { + if (counters[i].type == CB_CITY_OWNED_TURNS) { /* City counter type */ counters_city[number_city_counters] = &counters[i]; counters[i].index = number_city_counters; @@ -54,6 +54,7 @@ void counters_init(void) } } + /************************************************************************//** Free resources allocated by counters system ****************************************************************************/ diff --git a/common/counters.h b/common/counters.h index f29924a585..1848e9e9d2 100644 --- a/common/counters.h +++ b/common/counters.h @@ -20,17 +20,21 @@ extern "C" { /* common */ #include "name_translation.h" -enum counter_type { COUNTER_OWNED = 0, COUNTER_COUNT }; +#define SPECENUM_NAME counter_behaviour +#define SPECENUM_VALUE1 CB_CITY_OWNED_TURNS +#define SPECENUM_VALUE1NAME "Owned" + +#define SPECENUM_COUNT COUNTER_BEHAVIOUR_LAST +#include "specenum_gen.h" enum counter_target { CTGT_CITY }; -/* Space for one counter of each type */ -#define MAX_COUNTERS COUNTER_COUNT +#define MAX_COUNTERS COUNTER_BEHAVIOUR_LAST struct counter { struct name_translation name; - enum counter_type type; + enum counter_behaviour type; enum counter_target target; int checkpoint; int def; /* default value for each entity of given type @@ -55,7 +59,6 @@ int counter_index(struct counter *pcount); struct counter *counter_by_index(int index, enum counter_target target); int counters_get_city_counters_count(void); - #define city_counters_iterate(pcount) { \ int _i_##pcount; \ struct counter *pcount; \ diff --git a/server/citytools.c b/server/citytools.c index ada6227b22..3349f4f250 100644 --- a/server/citytools.c +++ b/server/citytools.c @@ -1219,7 +1219,7 @@ bool transfer_city(struct player *ptaker, struct city *pcity, /* Reset turns owner counters */ if (city_remains) { city_counters_iterate(pcount) { - if (pcount->type == COUNTER_OWNED) { + if (pcount->type == CB_CITY_OWNED_TURNS) { pcity->counter_values[pcount->index] = 0; } } city_counters_iterate_end; diff --git a/server/srv_main.c b/server/srv_main.c index 8eb0fcfcb2..682caf5b45 100644 --- a/server/srv_main.c +++ b/server/srv_main.c @@ -1520,7 +1520,7 @@ static void end_turn(void) players_iterate(pplayer) { city_list_iterate(pplayer->cities, pcity) { city_counters_iterate(pcount) { - if (pcount->type == COUNTER_OWNED) { + if (pcount->type == CB_CITY_OWNED_TURNS) { pcity->counter_values[pcount->index]++; } } city_counters_iterate_end; -- 2.36.0