From 48134739c9b1a7d06465efbf7cf8eb887497fc73 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Tue, 25 Apr 2023 19:49:12 +0300 Subject: [PATCH 30/30] Fix overzealous 'pcity->surplus[O_SHIELD] >= 0' assert The surplus can be negative as long as there's enough shields left from the previous turn to pay. See osdn #47938 Signed-off-by: Marko Lindqvist --- server/cityturn.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/cityturn.c b/server/cityturn.c index 773a6ef54b..1459b218b3 100644 --- a/server/cityturn.c +++ b/server/cityturn.c @@ -2409,15 +2409,18 @@ static bool city_build_building(struct player *pplayer, struct city *pcity) int saved_id = pcity->id; if (city_production_has_flag(pcity, IF_GOLD)) { - fc_assert(pcity->surplus[O_SHIELD] >= 0); + fc_assert(pcity->before_change_shields >= 0); + /* pcity->before_change_shields already contains the surplus from * this turn. */ pplayer->economic.gold += pcity->before_change_shields; pcity->before_change_shields = 0; pcity->shield_stock = 0; choose_build_target(pplayer, pcity); + return TRUE; } + upgrade_building_prod(pcity); /* The final (after upgrade) build target */ -- 2.39.2