From 4ca16e57fe579e0e9140b63454ab93efc5bbc5df Mon Sep 17 00:00:00 2001 From: Sveinung Kvilhaugsvik Date: Mon, 31 May 2021 08:14:08 +0200 Subject: [PATCH 06/10] unit_perform_action(): sub target must be there. Check that the sub target is there after server side sub target assignment. See osdn #42437 --- server/unithand.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/server/unithand.c b/server/unithand.c index a003b71fec..84523c9c90 100644 --- a/server/unithand.c +++ b/server/unithand.c @@ -3208,6 +3208,31 @@ bool unit_perform_action(struct player *pplayer, sub_tgt_impr = improvement_by_number(sub_tgt_id); + /* Sub targets should now be assigned */ + switch (paction->sub_target_kind) { + case ASTK_NONE: + /* No sub target. */ + break; + case ASTK_BUILDING: + if (sub_tgt_impr == NULL) { + /* Missing sub target */ + return FALSE; + } + break; + case ASTK_TECH: + /* Not handled here yet */ + break; + case ASTK_EXTRA: + case ASTK_EXTRA_NOT_THERE: + if (target_extra == NULL) { + /* Missing sub target */ + return FALSE; + } + break; + case ASTK_COUNT: + break; + } + if (action_get_activity(paction) != ACTIVITY_LAST && unit_activity_needs_target_from_client( action_get_activity(paction)) -- 2.30.2