From edd53af9960b217a51deac79e7f9de7dcb409d9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Lach?= Date: Mon, 16 May 2022 15:31:46 +0200 Subject: [PATCH 1/2] - Repair BUG with specenum counting - Remove counter routines added diff --git a/common/counters.c b/common/counters.c index 3ad331e482..fe8097f317 100644 --- a/common/counters.c +++ b/common/counters.c @@ -107,6 +107,25 @@ struct counter *counter_by_rule_name(const char *name) return NULL; } + +/************************************************************************//** + Removes given counter. Can not be called + when game is processing. +****************************************************************************/ +void counter_remove(struct counter *pcount) +{ + switch (pcount->target) { + + case CTGT_CITY: + counters_city[pcount->index] = counters_city[number_city_counters - 1]; + counters_city[pcount->index]->index = pcount->index; + --number_city_counters; + } + // TODO: Must provide global counters counter + *pcount = counters[number_city_counters]; +} + + /************************************************************************//** Search for counter by translated name (return matched counter if found or NULL) diff --git a/common/counters.h b/common/counters.h index 394c1e1e83..6464ffa8ea 100644 --- a/common/counters.h +++ b/common/counters.h @@ -21,8 +21,8 @@ extern "C" { #include "name_translation.h" #define SPECENUM_NAME counter_behaviour -#define SPECENUM_VALUE1 CB_CITY_OWNED_TURNS -#define SPECENUM_VALUE1NAME "Owned" +#define SPECENUM_VALUE0 CB_CITY_OWNED_TURNS +#define SPECENUM_VALUE0NAME "Owned" #define SPECENUM_COUNT COUNTER_BEHAVIOUR_LAST #include "specenum_gen.h" @@ -58,6 +58,7 @@ struct counter *counter_by_translated_name(const char *name); int counter_index(struct counter *pcount); struct counter *counter_by_index(int index, enum counter_target target); int counters_get_city_counters_count(void); +void counter_remove(struct counter *pcount); void attach_city_counter(struct counter *counter); #define city_counters_iterate(pcount) { \ -- 2.36.1