|
@@ -1541,13 +1541,13 @@ static void UpdateVarsAfterSwap(Vehicle
|
|
|
v->cur_image = v->GetImage(v->direction);
|
|
|
BeginVehicleMove(v);
|
|
|
VehiclePositionChanged(v);
|
|
|
EndVehicleMove(v);
|
|
|
}
|
|
|
|
|
|
static void SetLastSpeed(Vehicle* v, int spd)
|
|
|
static inline void SetLastSpeed(Vehicle* v, int spd)
|
|
|
{
|
|
|
int old = v->u.rail.last_speed;
|
|
|
if (spd != old) {
|
|
|
v->u.rail.last_speed = spd;
|
|
|
if (_patches.vehicle_speed || (old == 0) != (spd == 0))
|
|
|
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
|
|
@@ -2768,21 +2768,21 @@ static byte AfterSetTrainPos(Vehicle *v,
|
|
|
static const Direction _new_vehicle_direction_table[11] = {
|
|
|
DIR_N , DIR_NW, DIR_W , INVALID_DIR,
|
|
|
DIR_NE, DIR_N , DIR_SW, INVALID_DIR,
|
|
|
DIR_E , DIR_SE, DIR_S
|
|
|
};
|
|
|
|
|
|
static Direction GetNewVehicleDirectionByTile(TileIndex new_tile, TileIndex old_tile)
|
|
|
static inline Direction GetNewVehicleDirectionByTile(TileIndex new_tile, TileIndex old_tile)
|
|
|
{
|
|
|
uint offs = (TileY(new_tile) - TileY(old_tile) + 1) * 4 +
|
|
|
TileX(new_tile) - TileX(old_tile) + 1;
|
|
|
assert(offs < 11);
|
|
|
return _new_vehicle_direction_table[offs];
|
|
|
}
|
|
|
|
|
|
static int GetDirectionToVehicle(const Vehicle *v, int x, int y)
|
|
|
static inline int GetDirectionToVehicle(const Vehicle *v, int x, int y)
|
|
|
{
|
|
|
byte offs;
|
|
|
|
|
|
x -= v->x_pos;
|
|
|
if (x >= 0) {
|
|
|
offs = (x > 2) ? 0 : 1;
|
|
@@ -2799,13 +2799,13 @@ static int GetDirectionToVehicle(const V
|
|
|
|
|
|
assert(offs < 11);
|
|
|
return _new_vehicle_direction_table[offs];
|
|
|
}
|
|
|
|
|
|
/* Check if the vehicle is compatible with the specified tile */
|
|
|
static bool CheckCompatibleRail(const Vehicle *v, TileIndex tile)
|
|
|
static inline bool CheckCompatibleRail(const Vehicle *v, TileIndex tile)
|
|
|
{
|
|
|
return
|
|
|
IsTileOwner(tile, v->owner) && (
|
|
|
!IsFrontEngine(v) ||
|
|
|
HasBit(v->u.rail.compatible_railtypes, GetRailType(tile))
|
|
|
);
|
|
@@ -2823,25 +2823,25 @@ static const RailtypeSlowdownParams _rai
|
|
|
{256 / 4, 256 / 2, 256 / 4, 2}, ///< electrified
|
|
|
{256 / 4, 256 / 2, 256 / 4, 2}, ///< monorail
|
|
|
{0, 256 / 2, 256 / 4, 2}, ///< maglev
|
|
|
};
|
|
|
|
|
|
/** Modify the speed of the vehicle due to a turn */
|
|
|
static void AffectSpeedByDirChange(Vehicle* v, Direction new_dir)
|
|
|
static inline void AffectSpeedByDirChange(Vehicle* v, Direction new_dir)
|
|
|
{
|
|
|
if (_patches.realistic_acceleration) return;
|
|
|
|
|
|
DirDiff diff = DirDifference(v->direction, new_dir);
|
|
|
if (diff == DIRDIFF_SAME) return;
|
|
|
|
|
|
const RailtypeSlowdownParams *rsp = &_railtype_slowdown[v->u.rail.railtype];
|
|
|
v->cur_speed -= (diff == DIRDIFF_45RIGHT || diff == DIRDIFF_45LEFT ? rsp->small_turn : rsp->large_turn) * v->cur_speed >> 8;
|
|
|
}
|
|
|
|
|
|
/** Modify the speed of the vehicle due to a change in altitude */
|
|
|
static void AffectSpeedByZChange(Vehicle *v, byte old_z)
|
|
|
static inline void AffectSpeedByZChange(Vehicle *v, byte old_z)
|
|
|
{
|
|
|
if (old_z == v->z_pos || _patches.realistic_acceleration) return;
|
|
|
|
|
|
const RailtypeSlowdownParams *rsp = &_railtype_slowdown[v->u.rail.railtype];
|
|
|
|
|
|
if (old_z < v->z_pos) {
|