From a688195c47dcc055b1f74784cf43f3fd4de0e6d3 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 13 Nov 2021 10:09:31 +0200 Subject: [PATCH 26/26] Make shield_stock given in editor to stick over production change Changing the production back and forth was causing the stock to get to the value it had before editing, not to the value it had after the editing (but before it was changed the first time) Reported by ihnatus See osdn #42685 Signed-off-by: Marko Lindqvist --- server/edithand.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/edithand.c b/server/edithand.c index 20e4e2d93d..20d605bdaf 100644 --- a/server/edithand.c +++ b/server/edithand.c @@ -843,6 +843,7 @@ void handle_edit_city(struct connection *pc, /* Handle shield stock change. */ if (packet->shield_stock != pcity->shield_stock) { int max = USHRT_MAX; /* Limited to uint16 by city info packet. */ + if (!(0 <= packet->shield_stock && packet->shield_stock <= max)) { notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor, _("Invalid city shield stock amount %d for city %s " @@ -850,6 +851,8 @@ void handle_edit_city(struct connection *pc, packet->shield_stock, city_link(pcity), 0, max); } else { pcity->shield_stock = packet->shield_stock; + /* Make sure the shields stay if changing production back and forth */ + pcity->before_change_shields = packet->shield_stock; changed = TRUE; } } -- 2.33.0