From 973f7859452ad240a6b88cbdd0b21f2ca43abc13 Mon Sep 17 00:00:00 2001 From: Dino Date: Sat, 12 Sep 2026 21:31:30 -0400 Subject: [PATCH] city_add_unit(): make new citizens do something useful RM #1618 --- server/unithand.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/server/unithand.c b/server/unithand.c index 1561cf998b..31c3339fd3 100644 --- a/server/unithand.c +++ b/server/unithand.c @@ -4235,7 +4235,6 @@ static bool city_add_unit(struct player *pplayer, struct unit *punit, { int amount = unit_pop_value(punit); const struct unit_type *act_utype; - Specialist_type_id spec_id = DEFAULT_SPECIALIST; int new_food; int savings_pct = city_growth_granary_savings(pcity); @@ -4253,23 +4252,22 @@ static bool city_add_unit(struct player *pplayer, struct unit *punit, /* Preserve old food stock, unless granary effect gives us more. */ pcity->food_stock = MAX(pcity->food_stock, new_food); + citizens_update(pcity, unit_nationality(punit)); + if (is_super_specialist(act_utype->spec_type)) { Specialist_type_id sspec = specialist_index(act_utype->spec_type); fc_assert_ret_val(pcity->specialists[sspec] < MAX_CITY_SIZE, FALSE); pcity->specialists[sspec]++; + /* Refresh the city data. */ + city_refresh(pcity); } else { fc_assert_ret_val(amount > 0, FALSE); - /* Hardly much needed but let it be */ - spec_id = specialist_index(act_utype->spec_type); + /* Make the new people something, otherwise city fails the checks */ + pcity->specialists[DEFAULT_SPECIALIST] += amount; + /* Make the new people do something useful */ + auto_arrange_workers(pcity); /* this calls city_refresh(pcity) */ } - /* Make the new people something, otherwise city fails the checks */ - fc_assert_ret_val(MAX_CITY_SIZE - pcity->specialists[spec_id] >= amount, - FALSE); - pcity->specialists[spec_id] += amount; - citizens_update(pcity, unit_nationality(punit)); - /* Refresh the city data. */ - city_refresh(pcity); /* Notify the unit owner that the unit successfully joined the city. */ notify_player(pplayer, city_tile(pcity), E_CITY_BUILD, ftc_server, -- 2.31.0