From 17244b082284a6fa06cc892405abf9ab8faa3a20 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C5=82awomir=20Lach?= <slawek@lach.art.pl>
Date: Tue, 27 Sep 2022 15:09:47 +0200
Subject: [PATCH] =?UTF-8?q?OSDN=20!#45489:=20S=C5=82awomir=20Lach=20<slawe?=
 =?UTF-8?q?k@lach.art.pl>?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Implements support for counter counting how much turn (one after other)
city is in disorder state. It is only code.

diff --git a/common/fc_types.h b/common/fc_types.h
index 837f5f277f..5a7029fef3 100644
--- a/common/fc_types.h
+++ b/common/fc_types.h
@@ -100,6 +100,8 @@ enum output_type_id {
 #define SPECENUM_VALUE1NAME "Owned"
 #define SPECENUM_VALUE2 CB_CITY_CELEBRATION_TURNS
 #define SPECENUM_VALUE2NAME "Celebration"
+#define SPECENUM_VALUE3 CB_CITY_DISORDER_TURNS
+#define SPECENUM_VALUE3NAME "Disorder"
 
 #define SPECENUM_COUNT COUNTER_BEHAVIOUR_LAST
 #include "specenum_gen.h"
diff --git a/server/cityturn.c b/server/cityturn.c
index 94d5be36e5..63c9c18af1 100644
--- a/server/cityturn.c
+++ b/server/cityturn.c
@@ -3387,6 +3387,13 @@ static void update_city_activity(struct city *pcity)
       const char *revomsg;
 
       pcity->anarchy++;
+
+      city_counters_iterate(pcount) {
+        if (pcount->type == CB_CITY_DISORDER_TURNS) {
+          pcity->counter_values[pcount->index]++;
+        }
+      } city_counters_iterate_end;
+
       if (pcity->anarchy == revolution_turns) {
         /* Revolution next turn if not dealt with */
         /* TRANS: preserve leading space; this string will be appended to
@@ -3413,6 +3420,12 @@ static void update_city_activity(struct city *pcity)
                       city_link(pcity));
       }
       pcity->anarchy = 0;
+
+      city_counters_iterate(pcount) {
+        if (pcount->type == CB_CITY_DISORDER_TURNS) {
+          pcity->counter_values[pcount->index] = 0;
+        }
+      } city_counters_iterate_end;
     }
     check_pollution(pcity);
 
-- 
2.38.1

