mirror of https://github.com/OpenTTD/OpenTTD
Fix #12301: Update ship current order destination tile when relocating buoys
Moving buoys caused current_order to be detected as unchanged, making pathfinders to compute a path to an outdated v->dest_tile. Properly update v->dest_tile before reaching pathfinders.pull/12303/head
parent
4edde7d6de
commit
bf792c9a90
|
@ -2189,9 +2189,23 @@ bool ProcessOrders(Vehicle *v)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If it is unchanged, keep it. */
|
/* If it is unchanged, keep it. */
|
||||||
if (order->Equals(v->current_order) && (v->type == VEH_AIRCRAFT || v->dest_tile != 0) &&
|
if (order->Equals(v->current_order) && (v->type == VEH_AIRCRAFT || v->dest_tile != 0)) {
|
||||||
(v->type != VEH_SHIP || !order->IsType(OT_GOTO_STATION) || Station::Get(order->GetDestination())->ship_station.tile != INVALID_TILE)) {
|
if (v->type != VEH_SHIP) {
|
||||||
return false;
|
return false;
|
||||||
|
} else {
|
||||||
|
switch (order->GetType()) {
|
||||||
|
case OT_GOTO_STATION:
|
||||||
|
if (Station::Get(order->GetDestination())->ship_station.tile != INVALID_TILE) return false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OT_GOTO_WAYPOINT:
|
||||||
|
if (Waypoint::Get(order->GetDestination())->xy == v->dest_tile) return false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Otherwise set it, and determine the destination tile. */
|
/* Otherwise set it, and determine the destination tile. */
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "window_func.h"
|
#include "window_func.h"
|
||||||
#include "timer/timer_game_calendar.h"
|
#include "timer/timer_game_calendar.h"
|
||||||
#include "vehicle_func.h"
|
#include "vehicle_func.h"
|
||||||
|
#include "ship.h"
|
||||||
#include "string_func.h"
|
#include "string_func.h"
|
||||||
#include "company_func.h"
|
#include "company_func.h"
|
||||||
#include "newgrf_station.h"
|
#include "newgrf_station.h"
|
||||||
|
@ -487,8 +488,14 @@ CommandCost CmdBuildBuoy(DoCommandFlag flags, TileIndex tile)
|
||||||
if (wp == nullptr) {
|
if (wp == nullptr) {
|
||||||
wp = new Waypoint(tile);
|
wp = new Waypoint(tile);
|
||||||
} else {
|
} else {
|
||||||
/* Move existing (recently deleted) buoy to the new location */
|
if (wp->xy != tile) {
|
||||||
wp->xy = tile;
|
/* Move existing (recently deleted) buoy to the new location. */
|
||||||
|
wp->xy = tile;
|
||||||
|
for (Ship *v : Ship::Iterate()) {
|
||||||
|
if (!v->current_order.IsType(OT_GOTO_WAYPOINT) || v->current_order.GetDestination() != wp->index) continue;
|
||||||
|
v->SetDestTile(wp->xy);
|
||||||
|
}
|
||||||
|
}
|
||||||
InvalidateWindowData(WC_WAYPOINT_VIEW, wp->index);
|
InvalidateWindowData(WC_WAYPOINT_VIEW, wp->index);
|
||||||
}
|
}
|
||||||
wp->rect.BeforeAddTile(tile, StationRect::ADD_TRY);
|
wp->rect.BeforeAddTile(tile, StationRect::ADD_TRY);
|
||||||
|
|
Loading…
Reference in New Issue