From dbae33f006641565cf19a83bed0613dddacead85 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Tue, 26 Jul 2022 14:12:55 +0300 Subject: [PATCH 50/50] AI: Fix assert failure when transport boarding is not enabled See osdn #45239 Signed-off-by: Marko Lindqvist --- ai/default/aiferry.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ai/default/aiferry.c b/ai/default/aiferry.c index 2ba63e68dc..39232b4cbc 100644 --- a/ai/default/aiferry.c +++ b/ai/default/aiferry.c @@ -771,6 +771,7 @@ bool aiferry_gobyboat(struct ai_type *ait, struct player *pplayer, int boatid; struct unit *ferryboat = NULL; int cap = with_bodyguard ? 2 : 1; + bool board_success = FALSE; UNIT_LOG(LOGLEVEL_GOBYBOAT, punit, "will have to go to (%d,%d) by boat", TILE_XY(dest_tile)); @@ -841,10 +842,22 @@ bool aiferry_gobyboat(struct ai_type *ait, struct player *pplayer, if (unit_perform_action(pplayer, punit->id, ferryboat->id, 0, "", paction->id, ACT_REQ_PLAYER)) { + board_success = TRUE; break; } } } action_by_result_iterate_end; + + if (!board_success) { + /* No action enabler active. + * TODO: Try to predict this failure so that the units wouldn't + * waste turns to travel to the rendezvous point. */ + UNIT_LOG(LOGLEVEL_GOBYBOAT, punit, "boarding boat[%d](%d,%d) not enabled", + ferryboat->id, TILE_XY(unit_tile(ferryboat))); + + return FALSE; + } + fc_assert(unit_transported(punit)); } -- 2.35.1