[freeciv-dev] Patch for Issue #885093

  • From: graf wasili <graf.wasili@xxxxxxxxxx>
  • To: Freeciv dev <freeciv-dev@xxxxxxxxxxxxx>
  • Date: Sun, 25 Oct 2020 08:44:25 +0100

Attached a patch for the master branch. If there are no objections, I'll check if it works for 2.6 and 3.0 and make patches for them if needed.

Changes:
Don't yet update tile output sprites when celebration ends next turn
(because bonuses will still apply on end of this turn).

Comment:
In fill_city_overlays_sprite_array() tile output sprites are made
by calling city_tile_output_now(). This function uses the return
value of city_celebrating() which returns true if and only if
the city is celebrating and conditions are met for the city
to continue celebrating next turn. Instead base_city_celebrating()
should be used in this case.

I went for the easy fix by directly calling city_tile_output()
with base_city_celebrating(). I still think city_tile_output_now()
is somewhat of a misnomer but it's used for evaluating tile output
by quite some ai code, where it makes some sense (e.g. do not
choose worker action based on tile output that changes next turn).From 65043a7e81026ba314d36da4dade3a2dbff96d90 Mon Sep 17 00:00:00 2001
From: graf wasili <graf.wasili@xxxxxxxxxx>
Date: Sun, 25 Oct 2020 08:22:11 +0100
Subject: [PATCH] Issue 885093: Properly reflect tile output on end of turn if
 celebration ends next turn

---
 client/tilespec.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/client/tilespec.c b/client/tilespec.c
index 0fe5443862..58e4501c9e 100644
--- a/client/tilespec.c
+++ b/client/tilespec.c
@@ -4797,10 +4797,15 @@ static int fill_city_overlays_sprite_array(const struct 
tileset *t,
       }
     } else if (NULL != pwork && pwork == pcity
                && (citymode || gui_options.draw_city_output)) {
+
       /* Add on the tile output sprites. */
-      int food = city_tile_output_now(pcity, ptile, O_FOOD);
-      int shields = city_tile_output_now(pcity, ptile, O_SHIELD);
-      int trade = city_tile_output_now(pcity, ptile, O_TRADE);
+      int food = city_tile_output(pcity, ptile,
+                                  base_city_celebrating(pcity), O_FOOD);
+      int shields = city_tile_output(pcity, ptile,
+                                     base_city_celebrating(pcity), O_SHIELD);
+      int trade = city_tile_output(pcity, ptile,
+                                   base_city_celebrating(pcity), O_TRADE);
+
       const int ox = t->type == TS_ISOMETRIC ? t->normal_tile_width / 3 : 0;
       const int oy = t->type == TS_ISOMETRIC ? -t->normal_tile_height / 3 : 0;
 
-- 
2.25.1

Other related posts:

  • » [freeciv-dev] Patch for Issue #885093 - graf wasili