From da66824be54e611a77023dc2deaf3276d879b01c Mon Sep 17 00:00:00 2001 From: Sveinung Kvilhaugsvik Date: Sun, 30 May 2021 22:11:32 +0200 Subject: [PATCH 05/10] Only allow buildings as building targets. Reported by Lexxie See osdn #42436 --- server/unithand.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/unithand.c b/server/unithand.c index c7b1128fab..a003b71fec 100644 --- a/server/unithand.c +++ b/server/unithand.c @@ -3126,6 +3126,7 @@ bool unit_perform_action(struct player *pplayer, struct unit *actor_unit = player_unit_by_number(pplayer, actor_id); struct tile *target_tile = NULL; struct extra_type *target_extra; + struct impr_type *sub_tgt_impr; struct unit *punit = NULL; struct city *pcity = NULL; @@ -3205,6 +3206,8 @@ bool unit_perform_action(struct player *pplayer, target_extra = NULL; } + sub_tgt_impr = improvement_by_number(sub_tgt_id); + if (action_get_activity(paction) != ACTIVITY_LAST && unit_activity_needs_target_from_client( action_get_activity(paction)) @@ -3465,7 +3468,8 @@ bool unit_perform_action(struct player *pplayer, /* Difference is caused by data in the action structure. */ ACTION_STARTED_UNIT_CITY(action_type, actor_unit, pcity, diplomat_sabotage(pplayer, actor_unit, pcity, - sub_tgt_id, paction)); + sub_tgt_impr->item_number, + paction)); break; case ACTRES_SPY_SABOTAGE_CITY_PRODUCTION: /* Difference is caused by data in the action structure. */ @@ -3586,7 +3590,7 @@ bool unit_perform_action(struct player *pplayer, do_unit_strike_city_building(pplayer, actor_unit, pcity, - sub_tgt_id, + sub_tgt_impr->item_number, paction)); break; case ACTRES_STRIKE_PRODUCTION: -- 2.30.2