Codefix: some coding style improvements
This commit is contained in:
@@ -988,7 +988,7 @@ static bool AircraftController(Aircraft *v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get distance from destination pos to current pos. */
|
/* Get distance from destination pos to current pos. */
|
||||||
uint dist = abs(x + amd.x - v->x_pos) + abs(y + amd.y - v->y_pos);
|
uint dist = abs(x + amd.x - v->x_pos) + abs(y + amd.y - v->y_pos);
|
||||||
|
|
||||||
/* Need exact position? */
|
/* Need exact position? */
|
||||||
if (!amd.flags.Test(AirportMovingDataFlag::ExactPosition) && dist <= (amd.flags.Test(AirportMovingDataFlag::SlowTurn) ? 8U : 4U)) return true;
|
if (!amd.flags.Test(AirportMovingDataFlag::ExactPosition) && dist <= (amd.flags.Test(AirportMovingDataFlag::SlowTurn) ? 8U : 4U)) return true;
|
||||||
@@ -1021,10 +1021,21 @@ static bool AircraftController(Aircraft *v)
|
|||||||
uint speed_limit = SPEED_LIMIT_TAXI;
|
uint speed_limit = SPEED_LIMIT_TAXI;
|
||||||
bool hard_limit = true;
|
bool hard_limit = true;
|
||||||
|
|
||||||
if (amd.flags.Test(AirportMovingDataFlag::NoSpeedClamp)) speed_limit = SPEED_LIMIT_NONE;
|
if (amd.flags.Test(AirportMovingDataFlag::NoSpeedClamp)) {
|
||||||
if (amd.flags.Test(AirportMovingDataFlag::Hold)) { speed_limit = SPEED_LIMIT_HOLD; hard_limit = false; }
|
speed_limit = SPEED_LIMIT_NONE;
|
||||||
if (amd.flags.Test(AirportMovingDataFlag::Land)) { speed_limit = SPEED_LIMIT_APPROACH; hard_limit = false; }
|
}
|
||||||
if (amd.flags.Test(AirportMovingDataFlag::Brake)) { speed_limit = SPEED_LIMIT_TAXI; hard_limit = false; }
|
if (amd.flags.Test(AirportMovingDataFlag::Hold)) {
|
||||||
|
speed_limit = SPEED_LIMIT_HOLD;
|
||||||
|
hard_limit = false;
|
||||||
|
}
|
||||||
|
if (amd.flags.Test(AirportMovingDataFlag::Land)) {
|
||||||
|
speed_limit = SPEED_LIMIT_APPROACH;
|
||||||
|
hard_limit = false;
|
||||||
|
}
|
||||||
|
if (amd.flags.Test(AirportMovingDataFlag::Brake)) {
|
||||||
|
speed_limit = SPEED_LIMIT_TAXI;
|
||||||
|
hard_limit = false;
|
||||||
|
}
|
||||||
|
|
||||||
int count = UpdateAircraftSpeed(v, speed_limit, hard_limit);
|
int count = UpdateAircraftSpeed(v, speed_limit, hard_limit);
|
||||||
if (count == 0) return false;
|
if (count == 0) return false;
|
||||||
@@ -1181,7 +1192,7 @@ static bool HandleCrashedAircraft(Aircraft *v)
|
|||||||
Station *st = GetTargetAirportIfValid(v);
|
Station *st = GetTargetAirportIfValid(v);
|
||||||
|
|
||||||
/* make aircraft crash down to the ground */
|
/* make aircraft crash down to the ground */
|
||||||
if (v->crashed_counter < 500 && st == nullptr && ((v->crashed_counter % 3) == 0) ) {
|
if (v->crashed_counter < 500 && st == nullptr && ((v->crashed_counter % 3) == 0)) {
|
||||||
int z = GetSlopePixelZ(Clamp(v->x_pos, 0, Map::MaxX() * TILE_SIZE), Clamp(v->y_pos, 0, Map::MaxY() * TILE_SIZE));
|
int z = GetSlopePixelZ(Clamp(v->x_pos, 0, Map::MaxX() * TILE_SIZE), Clamp(v->y_pos, 0, Map::MaxY() * TILE_SIZE));
|
||||||
v->z_pos -= 1;
|
v->z_pos -= 1;
|
||||||
if (v->z_pos <= z) {
|
if (v->z_pos <= z) {
|
||||||
@@ -1814,7 +1825,7 @@ static bool AirportMove(Aircraft *v, const AirportFTAClass *apc)
|
|||||||
{
|
{
|
||||||
/* error handling */
|
/* error handling */
|
||||||
if (v->pos >= apc->nofelements) {
|
if (v->pos >= apc->nofelements) {
|
||||||
Debug(misc, 0, "[Ap] position {} is not valid for current airport. Max position is {}", v->pos, apc->nofelements-1);
|
Debug(misc, 0, "[Ap] position {} is not valid for current airport. Max position is {}", v->pos, apc->nofelements - 1);
|
||||||
assert(v->pos < apc->nofelements);
|
assert(v->pos < apc->nofelements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2229,6 +2229,25 @@ static void DrawTrackBitsOverlay(TileInfo *ti, TrackBits track, const RailTypeIn
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns which of the 5 junction-'Rail underlays' to use for the given track bits.
|
||||||
|
* See https://newgrf-specs.tt-wiki.net/wiki/Action3/Railtypes for the cases.
|
||||||
|
* @pre The track bits describe a junction, so at least two bits are set.
|
||||||
|
* @param track The track bits to consider.
|
||||||
|
* @return The offset in the five junction ground sprites.
|
||||||
|
*/
|
||||||
|
static int GetJunctionGroundSpriteOffset(TrackBits track)
|
||||||
|
{
|
||||||
|
/* If none of the tracks end up in the NE corner, return the ground sprite
|
||||||
|
* where the NE of the tile is not covered. Repeat for the other directions.
|
||||||
|
* What remains are junctions where all directions are covered. */
|
||||||
|
if ((track & TRACK_BIT_3WAY_NE) == 0) return 0;
|
||||||
|
if ((track & TRACK_BIT_3WAY_SW) == 0) return 1;
|
||||||
|
if ((track & TRACK_BIT_3WAY_NW) == 0) return 2;
|
||||||
|
if ((track & TRACK_BIT_3WAY_SE) == 0) return 3;
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw ground sprite and track bits
|
* Draw ground sprite and track bits
|
||||||
* @param ti TileInfo
|
* @param ti TileInfo
|
||||||
@@ -2304,11 +2323,7 @@ static void DrawTrackBits(TileInfo *ti, TrackBits track)
|
|||||||
/* junction, select only ground sprite, handle track sprite later */
|
/* junction, select only ground sprite, handle track sprite later */
|
||||||
default:
|
default:
|
||||||
junction = true;
|
junction = true;
|
||||||
if ((track & TRACK_BIT_3WAY_NE) == 0) { image = rti->base_sprites.ground; break; }
|
image = rti->base_sprites.ground + GetJunctionGroundSpriteOffset(track);
|
||||||
if ((track & TRACK_BIT_3WAY_SW) == 0) { image = rti->base_sprites.ground + 1; break; }
|
|
||||||
if ((track & TRACK_BIT_3WAY_NW) == 0) { image = rti->base_sprites.ground + 2; break; }
|
|
||||||
if ((track & TRACK_BIT_3WAY_SE) == 0) { image = rti->base_sprites.ground + 3; break; }
|
|
||||||
image = rti->base_sprites.ground + 4;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user