FIX: Endless look in vehicle route drawing if conditional orders form a cycle (in the simplest form, a conditional order skipping to itself)
(cherry picked from commit 680ddba875208b09160908ad03064b542193df4e) See: #39
This commit is contained in:

committed by
Jonathan G Rennison

parent
864d94d2c5
commit
d154debb5e
@@ -1693,8 +1693,13 @@ static inline TileIndex GetLastValidOrderLocation(const Vehicle *veh)
|
|||||||
|
|
||||||
static inline Order *GetFinalOrder(const Vehicle *veh, Order *order)
|
static inline Order *GetFinalOrder(const Vehicle *veh, Order *order)
|
||||||
{
|
{
|
||||||
while (order->IsType(OT_CONDITIONAL))
|
auto original_order = order;
|
||||||
|
|
||||||
|
while (order->IsType(OT_CONDITIONAL)) {
|
||||||
order = veh->GetOrder(order->GetConditionSkipToOrder());
|
order = veh->GetOrder(order->GetConditionSkipToOrder());
|
||||||
|
|
||||||
|
if (original_order == order) return nullptr;
|
||||||
|
}
|
||||||
return order;
|
return order;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1709,6 +1714,7 @@ static bool ViewportMapPrepareVehicleRoute(const Vehicle * const veh)
|
|||||||
Order *order;
|
Order *order;
|
||||||
FOR_VEHICLE_ORDERS(veh, order) {
|
FOR_VEHICLE_ORDERS(veh, order) {
|
||||||
Order *final_order = GetFinalOrder(veh, order);
|
Order *final_order = GetFinalOrder(veh, order);
|
||||||
|
if (final_order == nullptr) continue;
|
||||||
const TileIndex to_tile = final_order->GetLocation(veh, veh->type == VEH_AIRCRAFT);
|
const TileIndex to_tile = final_order->GetLocation(veh, veh->type == VEH_AIRCRAFT);
|
||||||
if (to_tile == INVALID_TILE) continue;
|
if (to_tile == INVALID_TILE) continue;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user