mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-10 08:00:05 +00:00
(svn r8802) -Fix
-Fix: When inserting an order for a ship while checking the distance between the new order and the order it is inserted after adhere the order types to determine the correct type of destination (i.e. station or depot) Also do a better job in determining the preceding order NOTE: 0.5 candidate
This commit is contained in:
parent
352273a5b3
commit
a69c6086e2
@ -167,6 +167,16 @@ static void DeleteOrderWarnings(const Vehicle* v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static TileIndex GetOrderLocation(const Order& o)
|
||||||
|
{
|
||||||
|
switch (o.type) {
|
||||||
|
default: NOT_REACHED();
|
||||||
|
case OT_GOTO_STATION: return GetStation(o.dest)->xy;
|
||||||
|
case OT_GOTO_DEPOT: return GetDepot(o.dest)->xy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Add an order to the orderlist of a vehicle.
|
/** Add an order to the orderlist of a vehicle.
|
||||||
* @param tile unused
|
* @param tile unused
|
||||||
* @param p1 various bitstuffed elements
|
* @param p1 various bitstuffed elements
|
||||||
@ -343,18 +353,29 @@ int32 CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||||||
* handle any more then this.. */
|
* handle any more then this.. */
|
||||||
if (v->num_orders >= MAX_BACKUP_ORDER_COUNT) return_cmd_error(STR_8832_TOO_MANY_ORDERS);
|
if (v->num_orders >= MAX_BACKUP_ORDER_COUNT) return_cmd_error(STR_8832_TOO_MANY_ORDERS);
|
||||||
|
|
||||||
/* For ships, make sure that the station is not too far away from the
|
if (v->type == VEH_Ship &&
|
||||||
* previous destination, for human players with new pathfinding disabled */
|
IsHumanPlayer(v->owner) &&
|
||||||
if (v->type == VEH_Ship && IsHumanPlayer(v->owner) &&
|
!_patches.new_pathfinding_all) {
|
||||||
sel_ord != 0 && GetVehicleOrder(v, sel_ord - 1)->type == OT_GOTO_STATION
|
// Make sure the new destination is not too far away from the previous
|
||||||
&& !_patches.new_pathfinding_all) {
|
const Order *prev = NULL;
|
||||||
|
uint n = 0;
|
||||||
|
|
||||||
int dist = DistanceManhattan(
|
/* Find the last goto station or depot order before the insert location.
|
||||||
GetStation(GetVehicleOrder(v, sel_ord - 1)->dest)->xy,
|
* If the order is to be inserted at the beginning of the order list this
|
||||||
GetStation(new_order.dest)->xy // XXX type != OT_GOTO_STATION?
|
* finds the last order in the list. */
|
||||||
);
|
for (const Order *o = v->orders; o != NULL; o = o->next) {
|
||||||
if (dist >= 130)
|
if (o->type == OT_GOTO_STATION || o->type == OT_GOTO_DEPOT) prev = o;
|
||||||
return_cmd_error(STR_0210_TOO_FAR_FROM_PREVIOUS_DESTINATIO);
|
if (++n == sel_ord && prev != NULL) break;
|
||||||
|
}
|
||||||
|
if (prev != NULL) {
|
||||||
|
uint dist = DistanceManhattan(
|
||||||
|
GetOrderLocation(*prev),
|
||||||
|
GetOrderLocation(new_order)
|
||||||
|
);
|
||||||
|
if (dist >= 130) {
|
||||||
|
return_cmd_error(STR_0210_TOO_FAR_FROM_PREVIOUS_DESTINATIO);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
|
Loading…
Reference in New Issue
Block a user