From 0b723d732bbccef5726e9ea70abfa50232c0384e Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 7 May 2022 00:39:21 +0300 Subject: [PATCH 21/21] Handle finishing terrain transform activities like other activities Former handling of activities transforming the terrain caused trouble with how activities of the units in the same tile were turned illegal. Reported by alain_bkr See osdn #44519 Signed-off-by: Marko Lindqvist --- server/unittools.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/server/unittools.c b/server/unittools.c index 7206a8653f..f65977f9b2 100644 --- a/server/unittools.c +++ b/server/unittools.c @@ -980,23 +980,19 @@ static void update_unit_activity(struct unit *punit) } if (unit_activity_done) { + struct extra_type *act_tgt = punit->activity_target; + update_tile_knowledge(ptile); - if (ACTIVITY_IRRIGATE == activity - || ACTIVITY_MINE == activity - || ACTIVITY_TRANSFORM == activity) { - /* FIXME: As we might probably do the activity again, because of the - * terrain change cycles, we need to treat these cases separatly. - * Probably ACTIVITY_TRANSFORM should be associated to its terrain - * target, whereas ACTIVITY_IRRIGATE and ACTIVITY_MINE should only - * used for extras. */ + if (ACTIVITY_TRANSFORM == activity + || ((ACTIVITY_IRRIGATE == activity + || ACTIVITY_MINE == activity) + && act_tgt == NULL)) { unit_list_iterate(ptile->units, punit2) { if (punit2->activity == activity) { - unit_activities_cancel(punit2); + set_unit_activity(punit2, ACTIVITY_IDLE); } } unit_list_iterate_end; } else { - struct extra_type *act_tgt = punit->activity_target; - unit_list_iterate(ptile->units, punit2) { if (punit2->activity == activity && punit2->activity_target == act_tgt) { @@ -1006,10 +1002,10 @@ static void update_unit_activity(struct unit *punit) set_unit_activity(punit2, ACTIVITY_IDLE); } } unit_list_iterate_end; - - unit_activities_cancel_all_illegal_tile(ptile); } + unit_activities_cancel_all_illegal_tile(ptile); + for (i = 0; tile_changing_actions[i] != ACTIVITY_LAST; i++) { if (tile_changing_actions[i] == activity) { /* Some units nearby may not be able to continue their action, -- 2.35.1