diff --git a/server/unittools.cpp b/server/unittools.cpp index 16c501049c..deed7f6448 100644 --- a/server/unittools.cpp +++ b/server/unittools.cpp @@ -1228,6 +1228,28 @@ void bounce_unit(struct unit *punit, bool verbose) } square_iterate_end; + if (count == 0) { + /* If no place unit can survive try the same with tiles the unit can just + * exist inspite of losing health or fuel*/ + square_iterate(&(wld.map), punit_tile, DIST, ptile) + { + if (count >= ARRAY_SIZE(tiles)) { + break; + } + + if (ptile == punit_tile) { + continue; + } + + if (can_unit_exist_at_tile(&(wld.map), punit, ptile) + && !is_non_allied_city_tile(ptile, pplayer) + && !is_non_allied_unit_tile(ptile, pplayer)) { + tiles[count++] = ptile; + } + } + square_iterate_end; + } + if (count > 0) { struct tile *ptile = tiles[fc_rand(count)];