From ec280ed7af5bef524aa0a80d6b22b993a6b49838 Mon Sep 17 00:00:00 2001 From: Sveinung Kvilhaugsvik Date: Sun, 27 Jun 2021 11:28:26 +0200 Subject: [PATCH] Map unit move orders to (dis/)embark actions. Making the embark actions rare_pop_up made the pop up never come up as the rare_pop_up logic interprets embark as a legal regular move that blocks a rare pop up. Reported by Lexxie See osdn #42581 This also makes paths through ships work again. Reported by ihnatus See osdn #41824 --- server/unithand.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/server/unithand.c b/server/unithand.c index ec13c16616..476f7e8c78 100644 --- a/server/unithand.c +++ b/server/unithand.c @@ -5208,6 +5208,7 @@ bool unit_move_handling(struct unit *punit, struct tile *pdesttile, bool move_do_not_act) { struct player *pplayer = unit_owner(punit); + struct unit *ptrans; /*** Phase 1: Attempted action interpretation checks ***/ @@ -5296,6 +5297,54 @@ bool unit_move_handling(struct unit *punit, struct tile *pdesttile, return unit_perform_action(pplayer, punit->id, tile_index(pdesttile), NO_TARGET, "", ACTION_UNIT_MOVE3, ACT_REQ_PLAYER); + } else if (!can_unit_survive_at_tile(&(wld.map), punit, pdesttile) + && ((ptrans = transporter_for_unit_at(punit, pdesttile))) + && is_action_enabled_unit_on_unit(ACTION_TRANSPORT_EMBARK, + punit, ptrans)) { + /* "Transport Embark". */ + return unit_perform_action(pplayer, punit->id, ptrans->id, + NO_TARGET, "", ACTION_TRANSPORT_EMBARK, + ACT_REQ_PLAYER); + } else if (!can_unit_survive_at_tile(&(wld.map), punit, pdesttile) + && ((ptrans = transporter_for_unit_at(punit, pdesttile))) + && is_action_enabled_unit_on_unit(ACTION_TRANSPORT_EMBARK2, + punit, ptrans)) { + /* "Transport Embark 2". */ + return unit_perform_action(pplayer, punit->id, ptrans->id, + NO_TARGET, "", ACTION_TRANSPORT_EMBARK2, + ACT_REQ_PLAYER); + } else if (!can_unit_survive_at_tile(&(wld.map), punit, pdesttile) + && ((ptrans = transporter_for_unit_at(punit, pdesttile))) + && is_action_enabled_unit_on_unit(ACTION_TRANSPORT_EMBARK3, + punit, ptrans)) { + /* "Transport Embark 3". */ + return unit_perform_action(pplayer, punit->id, ptrans->id, + NO_TARGET, "", ACTION_TRANSPORT_EMBARK3, + ACT_REQ_PLAYER); + } else if (is_action_enabled_unit_on_tile(ACTION_TRANSPORT_DISEMBARK1, + punit, pdesttile, NULL)) { + /* "Transport Disembark". */ + return unit_perform_action(pplayer, punit->id, tile_index(pdesttile), + NO_TARGET, "", ACTION_TRANSPORT_DISEMBARK1, + ACT_REQ_PLAYER); + } else if (is_action_enabled_unit_on_tile(ACTION_TRANSPORT_DISEMBARK2, + punit, pdesttile, NULL)) { + /* "Transport Disembark 2". */ + return unit_perform_action(pplayer, punit->id, tile_index(pdesttile), + NO_TARGET, "", ACTION_TRANSPORT_DISEMBARK2, + ACT_REQ_PLAYER); + } else if (is_action_enabled_unit_on_tile(ACTION_TRANSPORT_DISEMBARK3, + punit, pdesttile, NULL)) { + /* "Transport Disembark 3". */ + return unit_perform_action(pplayer, punit->id, tile_index(pdesttile), + NO_TARGET, "", ACTION_TRANSPORT_DISEMBARK3, + ACT_REQ_PLAYER); + } else if (is_action_enabled_unit_on_tile(ACTION_TRANSPORT_DISEMBARK4, + punit, pdesttile, NULL)) { + /* "Transport Disembark 4". */ + return unit_perform_action(pplayer, punit->id, tile_index(pdesttile), + NO_TARGET, "", ACTION_TRANSPORT_DISEMBARK4, + ACT_REQ_PLAYER); } else { /* TODO: Extend the action not enabled explanation system to cover all * existing reasons and switch to using it. See hrm Feature #920229 */ -- 2.30.2