Skip to content

Commit

Permalink
Change: Yet to fix changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
J0anJosep committed Sep 19, 2021
1 parent b6f1c35 commit 9ae64a9
Show file tree
Hide file tree
Showing 9 changed files with 341 additions and 235 deletions.
68 changes: 34 additions & 34 deletions src/air_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,69 +160,69 @@ static inline bool GetCatchmentAirportType(TileIndex t)
}

/**
* Set the terminal type of an airport tile.
* Set the apron type of an airport tile.
* @param t Tile to modify.
* @param type Type of terminal.
* @pre IsTerminal
* @param type Type of apron.
* @pre IsApron
*/
static inline void SetTerminalType(TileIndex t, TerminalType type)
static inline void SetApronType(TileIndex t, ApronType type)
{
assert(IsValidTile(t));
assert(IsTileType(t, MP_STATION));
assert(IsAirport(t));

assert(IsTerminal(t));
assert(IsApron(t));

assert(type < HTT_TERMINAL_END);
assert(type < APRON_END);

SB(_m[t].m5, 4, 2, type);
}

/**
* Is a given tile a plane terminal?
* Is a given tile a plane apron?
* @param t Tile to get the type of.
* @return True if it is a plane terminal.
* @pre IsTerminal
* @return True if it is a plane apron.
* @pre IsApron
*/
static inline bool IsPlaneTerminal(TileIndex t)
static inline bool IsPlaneApron(TileIndex t)
{
assert(IsValidTile(t));
assert(IsTileType(t, MP_STATION));
assert(IsAirport(t));
assert(IsTerminal(t));
assert(IsApron(t));

return GetTerminalType(t) == HTT_TERMINAL;
return GetApronType(t) == APRON_APRON;
}

/**
* Is this tile a basic plane terminal?
* Is this tile a basic plane apron?
* @param t the tile to get the information from.
* @return true if and only if the tile is a plane terminal.
* @return true if and only if the tile is a plane apron.
*/
static inline bool IsPlaneTerminalTile(TileIndex t)
static inline bool IsPlaneApronTile(TileIndex t)
{
return IsTileType(t, MP_STATION) &&
IsAirport(t) &&
IsTerminal(t) &&
IsPlaneTerminal(t);
IsApron(t) &&
IsPlaneApron(t);
}

/**
* Is a given tile a heliport or a built-in heliport?
* @param t Tile to get the type of.
* @return True if it is a heliport.
* @pre IsTerminal
* @pre IsApron
*/
static inline bool IsHeliport(TileIndex t)
{
assert(IsValidTile(t));
assert(IsTileType(t, MP_STATION));
assert(IsAirport(t));
assert(IsTerminal(t));
assert(IsApron(t));

TerminalType type = GetTerminalType(t);
ApronType type = GetApronType(t);

return type == HTT_HELIPORT || type == HTT_BUILTIN_HELIPORT;
return type == APRON_HELIPORT || type == APRON_BUILTIN_HELIPORT;
}

/**
Expand All @@ -236,24 +236,24 @@ static inline bool IsHeliportTile(TileIndex t)

return IsTileType(t, MP_STATION) &&
IsAirport(t) &&
IsTerminal(t) &&
IsApron(t) &&
IsHeliport(t);
}

/**
* Is a given tile a helipad?
* @param t Tile to get the type of.
* @return True if it is a helipad.
* @pre IsTerminal
* @pre IsApron
*/
static inline bool IsHelipad(TileIndex t)
{
assert(IsValidTile(t));
assert(IsTileType(t, MP_STATION));
assert(IsAirport(t));
assert(IsTerminal(t));
assert(IsApron(t));

return GetTerminalType(t) == HTT_HELIPAD;
return GetApronType(t) == APRON_HELIPAD;
}

/**
Expand All @@ -265,7 +265,7 @@ static inline bool IsHelipadTile(TileIndex t)
{
return IsTileType(t, MP_STATION) &&
IsAirport(t) &&
IsTerminal(t) &&
IsApron(t) &&
IsHelipad(t);
}

Expand All @@ -278,12 +278,12 @@ static inline int32 GetLandingHeight(TileIndex t)
{
assert(IsTileType(t, MP_STATION) && IsAirport(t));

if (!IsTerminal(t)) return 0;
if (!IsApron(t)) return 0;

switch (GetTerminalType(t)) {
case HTT_HELIPORT:
switch (GetApronType(t)) {
case APRON_HELIPORT:
return 60;
case HTT_BUILTIN_HELIPORT:
case APRON_BUILTIN_HELIPORT:
return 54;
default:
return 0;
Expand All @@ -307,25 +307,25 @@ static inline bool HasAirportCatchment(TileIndex t)
* Set the rotation of an airport tile (see SetHangarDirection).
* @param t Tile to modify.
* @param dir Rotation.
* @pre IsAirportTile && (IsInfrastructure || IsTerminal)
* @pre IsAirportTile && (IsInfrastructure || IsApron)
*/
static inline void SetAirportTileRotation(TileIndex t, DiagDirection dir)
{
assert(IsAirportTile(t));
assert(IsTerminal(t) || IsInfrastructure(t));
assert(IsApron(t) || IsInfrastructure(t));
SB(_me[t].m8, 14, 2, dir);
}

/**
* Get the hangar direction.
* @param t Tile to check.
* @return The exit direction of the hangar.
* @pre IsAirportTile && (IsInfrastructure || IsTerminal)
* @pre IsAirportTile && (IsInfrastructure || IsApron)
*/
static inline DiagDirection GetAirportTileRotation(TileIndex t)
{
assert(IsAirportTile(t));
assert(IsTerminal(t) || IsInfrastructure(t));
assert(IsApron(t) || IsInfrastructure(t));
return (DiagDirection)GB(_me[t].m8, 14, 2);

}
Expand Down
46 changes: 23 additions & 23 deletions src/aircraft_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ static void HelicopterTickHandler(Aircraft *v)
if (u->vehstatus & VS_HIDDEN) return;

/* if true, helicopter rotors do not rotate. This should only be the case if a helicopter is
* loading/unloading at a terminal or stopped */
* loading/unloading at an apron or stopped */
if (v->current_order.IsType(OT_LOADING) || (v->vehstatus & VS_STOPPED)) {
if (u->cur_speed != 0) {
u->cur_speed++;
Expand Down Expand Up @@ -1054,7 +1054,7 @@ static void MaybeCrashAirplane(Aircraft *v)
}

/**
* Aircraft arrives at a terminal. If it is the first aircraft, throw a party.
* Aircraft arrives at an apron. If it is the first aircraft, throw a party.
* Start loading cargo.
* @param v Aircraft that arrived.
*/
Expand All @@ -1064,7 +1064,7 @@ static void AircraftEntersTerminal(Aircraft *v)

v->last_station_visited = v->targetairport;

v->state = (AircraftState)(AS_TERMINAL + GetTerminalType(v->tile));
v->state = (AircraftState)(AS_TERMINAL + GetApronType(v->tile));

/* Check if station was ever visited before */
Station *st = Station::Get(v->targetairport);
Expand All @@ -1083,7 +1083,7 @@ static void AircraftEntersTerminal(Aircraft *v)
}

if (_settings_game.order.serviceathelipad && v->subtype == AIR_HELICOPTER &&
(IsHelipad(v->tile) || IsTerminal(v->tile))) {
(IsHelipad(v->tile) || IsApron(v->tile))) {
/* an excerpt of ServiceAircraft, without the invisibility stuff */
v->date_of_last_service = _date;
v->breakdowns_since_last_service = 0;
Expand Down Expand Up @@ -1226,7 +1226,7 @@ TileIndex GetClosestLandingTile(Aircraft *v)

if (free_landing_tile != INVALID_TILE) return free_landing_tile;

for (auto &it : st->airport.terminals) {
for (auto &it : st->airport.aprons) {
if (DistanceSquare(it, v->tile) < best_dist) {
landing_tile = it;
best_dist = DistanceSquare(it, v->tile);
Expand Down Expand Up @@ -1368,15 +1368,15 @@ void AssignLandingTile(Aircraft *v, TileIndex tile)
{
if (IsValidTile(tile)) {
v->next_state = AS_LANDING;
if (IsTerminal(tile)) {
if (IsApron(tile)) {
assert(v->IsHelicopter());
switch (GetTerminalType(tile)) {
case HTT_TERMINAL:
case HTT_HELIPAD:
case HTT_HELIPORT:
switch (GetApronType(tile)) {
case APRON_APRON:
case APRON_HELIPAD:
case APRON_HELIPORT:
v->next_state = AS_HELICOPTER_LANDING;
break;
case HTT_BUILTIN_HELIPORT:
case APRON_BUILTIN_HELIPORT:
/* Oil rig heliport is not the actual station tile. */
tile += ToTileIndexDiff({2, 0});
v->next_state = AS_HELICOPTER_LANDING;
Expand Down Expand Up @@ -1430,7 +1430,7 @@ void UpdateTargetState(Aircraft *v)
break;

case OT_NOTHING:
/* On an aiprort, go to hangar if possible, otherwise a terminal, otherwise do nothing. */
/* On an aiprort, go to hangar if possible, otherwise an apron, otherwise do nothing. */
/* If flying, find closest airport and go there. */
/* If not possible, ??? */
if (cur_station != INVALID_STATION) {
Expand Down Expand Up @@ -1469,7 +1469,7 @@ void UpdateTargetState(Aircraft *v)
/* On an airport... */
assert(IsTileType(v->tile, MP_STATION) && IsAirportTile(v->tile));
if (v->IsHelicopter()) {
if (IsTerminal(v->tile) && (IsHelipad(v->tile) ||
if (IsApron(v->tile) && (IsHelipad(v->tile) ||
IsHeliport(v->tile) || IsBuiltInHeliport(v->tile))) {
v->state = AS_HELICOPTER_TAKEOFF;
v->next_state = AS_FLYING;
Expand Down Expand Up @@ -1497,7 +1497,7 @@ void UpdateTargetState(Aircraft *v)
switch (v->next_state) {
case AS_TERMINAL:
assert(IsTileType(v->tile, MP_STATION) && IsAirportTile(v->tile));
if (!IsPlaneTerminalTile(v->tile)) {
if (!IsPlaneApronTile(v->tile)) {
if (v->state != AS_HANGAR) {
v->state = AS_IDLE;
}
Expand All @@ -1509,7 +1509,7 @@ void UpdateTargetState(Aircraft *v)
break;
case AS_HELIPAD:
assert(IsTileType(v->tile, MP_STATION) && IsAirportTile(v->tile));
if (!IsTerminal(v->tile)) {
if (!IsApron(v->tile)) {
if (v->state != AS_HANGAR) {
v->state = AS_IDLE;
}
Expand Down Expand Up @@ -1884,7 +1884,7 @@ bool AircraftArrivesAtPartialDestination(Aircraft *v)
AssignLandingTile(v, GetClosestLandingTile(v));
} else {
if (v->IsHelicopter()) {
if (IsTerminal(v->tile)) {
if (IsApron(v->tile)) {
v->state = AS_HELICOPTER_TAKEOFF;
v->next_state = AS_HELICOPTER_TAKEOFF;
} else {
Expand All @@ -1902,7 +1902,7 @@ bool AircraftArrivesAtPartialDestination(Aircraft *v)
v->next_state = AS_IDLE;
} else if (IsRunwayStart(v->next_tile)) {
v->next_state = AS_LANDING;
} else if (IsAirportTile(v->next_tile) && IsTerminal(v->next_tile)) {
} else if (IsAirportTile(v->next_tile) && IsApron(v->next_tile)) {
v->next_state = AS_HELICOPTER_LANDING;
} else {
NOT_REACHED();
Expand Down Expand Up @@ -2232,7 +2232,7 @@ static bool AircraftController(Aircraft *v, bool mode)
case OT_GOTO_STATION:
if (IsAirportTile(v->tile) &&
CheckDestination(v) &&
IsTerminal(v->tile) && v->targetairport == GetStationIndex(v->tile)) {
IsApron(v->tile) && v->targetairport == GetStationIndex(v->tile)) {
assert(HasAirportTrackReserved(v->tile));
assert(CountBits(GetReservedAirportTracks(v->tile)) == 1);
assert(IsDiagonalTrackdir(v->trackdir));
Expand Down Expand Up @@ -2292,14 +2292,14 @@ static bool AircraftController(Aircraft *v, bool mode)
MaybeCrashAirplane(v);
/* Find altitude of landing position. */
int z = GetTileMaxPixelZ(v->tile) + 1;
switch (GetTerminalType(v->tile)) {
case HTT_TERMINAL:
case HTT_HELIPAD:
switch (GetApronType(v->tile)) {
case APRON_APRON:
case APRON_HELIPAD:
break;
case HTT_HELIPORT:
case APRON_HELIPORT:
z += 60;
break;
case HTT_BUILTIN_HELIPORT:
case APRON_BUILTIN_HELIPORT:
z += 54;
break;
default: NOT_REACHED();
Expand Down

0 comments on commit 9ae64a9

Please sign in to comment.