From 7d9b7066ab11c67a92bae7995ca8ad18ab1c39d9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C5=82awomir=20Lach?= <slawek@lach.art.pl>
Date: Tue, 6 Dec 2022 13:59:20 +0100
Subject: [PATCH] =?UTF-8?q?!OSDN:=20#TICKET:=2045488=20-=20S=C5=82awomir?=
 =?UTF-8?q?=20Lach=20<slawek@lach.art.pl>?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Ruleset author could now count how many turns city's celebrating by
using special counter.

diff --git a/common/fc_types.h b/common/fc_types.h
index 38de637c6c..0acf6a7c85 100644
--- a/common/fc_types.h
+++ b/common/fc_types.h
@@ -110,6 +110,8 @@ enum output_type_id {
 #define SPECENUM_NAME counter_behaviour
 #define SPECENUM_VALUE1 CB_CITY_OWNED_TURNS
 #define SPECENUM_VALUE1NAME "Owned"
+#define SPECENUM_VALUE2 CB_CITY_OWNED_TURNS
+#define SPECENUM_VALUE2NAME "Celebration"
 
 #define SPECENUM_COUNT COUNTER_BEHAVIOUR_LAST
 #include "specenum_gen.h"
diff --git a/server/citytools.c b/server/citytools.c
index fff72c22d8..43f5b5690e 100644
--- a/server/citytools.c
+++ b/server/citytools.c
@@ -2234,6 +2234,7 @@ void broadcast_city_info(struct city *pcity)
     if (!send_city_suppressed || pplayer != powner) {
       if (can_player_see_city_internals(pplayer, pcity)) {
         update_dumb_city(pplayer, pcity);
+
         lsend_packet_city_info(pplayer->connections, &packet, FALSE);
         lsend_packet_city_nationalities(pplayer->connections, &nat_packet, FALSE);
         lsend_packet_city_rally_point(pplayer->connections, &rally_packet, FALSE);
@@ -2336,6 +2337,11 @@ void send_city_info(struct player *dest, struct city *pcity)
     send_city_info_at_tile(dest, dest->connections, pcity, pcity->tile);
   }
 
+  /* Sending counters */
+  city_counters_iterate(pcount) {
+    city_counter_refresh(pcity, pcount->index);
+  } city_counters_iterate_end;
+
   if (game.info.team_pooled_research
       && player_list_size(team_members(powner->team)) > 1) {
     /* We want to send the new total bulbs production of the team. */
diff --git a/server/cityturn.c b/server/cityturn.c
index 57df7a36a1..6cb18b1cb1 100644
--- a/server/cityturn.c
+++ b/server/cityturn.c
@@ -3345,6 +3345,14 @@ static void update_city_activity(struct city *pcity)
 
     if (city_celebrating(pcity) || is_celebrating) {
       pcity->rapture++;
+
+      /* Update city's celebrating counters */
+      city_counters_iterate(pcount) {
+        if (pcount->type == CB_CITY_CELEBRATION_TURNS) {
+          pcity->counter_values[pcount->index]++;
+        }
+      } city_counters_iterate_end;
+
       if (pcity->rapture == 1) {
         notify_player(pplayer, city_tile(pcity), E_CITY_LOVE, ftc_server,
                       _("Celebrations in your honor in %s."),
@@ -3356,6 +3364,13 @@ static void update_city_activity(struct city *pcity)
                       _("Celebrations canceled in %s."),
                       city_link(pcity));
       }
+
+      /* Update city's celebrating counters */
+      city_counters_iterate(pcount) {
+        if (pcount->type == CB_CITY_CELEBRATION_TURNS) {
+          pcity->counter_values[pcount->index] = 0;
+        }
+      } city_counters_iterate_end;
       pcity->rapture = 0;
     }
     pcity->was_happy = is_happy;
-- 
2.38.1

