mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use const instead of magic number for ship order distance. Allow slightly further distance when following orders.
parent
b98887c4a0
commit
7af53d7588
|
@ -23,6 +23,7 @@
|
||||||
#include "core/random_func.hpp"
|
#include "core/random_func.hpp"
|
||||||
#include "aircraft.h"
|
#include "aircraft.h"
|
||||||
#include "roadveh.h"
|
#include "roadveh.h"
|
||||||
|
#include "ship.h"
|
||||||
#include "station_base.h"
|
#include "station_base.h"
|
||||||
#include "waypoint_base.h"
|
#include "waypoint_base.h"
|
||||||
#include "company_base.h"
|
#include "company_base.h"
|
||||||
|
@ -929,7 +930,7 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||||
dist = GetOrderDistance(prev, &new_order, v);
|
dist = GetOrderDistance(prev, &new_order, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dist >= 130) {
|
if (dist >= SHIP_MAX_ORDER_DISTANCE) {
|
||||||
return_cmd_error(STR_ERROR_TOO_FAR_FROM_PREVIOUS_DESTINATION);
|
return_cmd_error(STR_ERROR_TOO_FAR_FROM_PREVIOUS_DESTINATION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,8 @@ struct Ship FINAL : public SpecializedVehicle<Ship, VEH_SHIP> {
|
||||||
void UpdateCache();
|
void UpdateCache();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const uint SHIP_MAX_ORDER_DISTANCE = 130;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterate over all ships.
|
* Iterate over all ships.
|
||||||
* @param var The variable used for iteration.
|
* @param var The variable used for iteration.
|
||||||
|
|
|
@ -459,7 +459,7 @@ static Track ChooseShipTrack(Ship *v, TileIndex tile, DiagDirection enterdir, Tr
|
||||||
bool path_found = true;
|
bool path_found = true;
|
||||||
Track track;
|
Track track;
|
||||||
|
|
||||||
if (v->dest_tile == 0 || DistanceManhattan(tile, v->dest_tile) > 130) {
|
if (v->dest_tile == 0 || DistanceManhattan(tile, v->dest_tile) > SHIP_MAX_ORDER_DISTANCE + 5) {
|
||||||
/* No destination or destination too far, don't invoke pathfinder. */
|
/* No destination or destination too far, don't invoke pathfinder. */
|
||||||
static const TrackBits direction_to_trackbits[DIR_END] = {
|
static const TrackBits direction_to_trackbits[DIR_END] = {
|
||||||
TRACK_BIT_LEFT | TRACK_BIT_RIGHT, // DIR_N
|
TRACK_BIT_LEFT | TRACK_BIT_RIGHT, // DIR_N
|
||||||
|
|
Loading…
Reference in New Issue