Skip to content

[GEN][ZH] Make aircraft takeoff order deterministic #1297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class ParkingPlaceBehavior : public UpdateModule,
virtual Bool reserveSpace(ObjectID id, Real parkingOffset, PPInfo* info);
virtual void releaseSpace(ObjectID id);
virtual Bool reserveRunway(ObjectID id, Bool forLanding);
Bool postponeRunwayReservation(UnsignedInt spaceIndex, Bool forLanding);
virtual void releaseRunway(ObjectID id);
virtual void calcPPInfo( ObjectID id, PPInfo *info );
virtual Int getRunwayCount() const { return m_runways.size(); }
Expand All @@ -158,15 +159,16 @@ class ParkingPlaceBehavior : public UpdateModule,

struct ParkingPlaceInfo
{
Coord3D m_hangarStart;
Real m_hangarStartOrient;
Coord3D m_location;
Coord3D m_prep;
Real m_orientation;
Int m_runway;
ExitDoorType m_door;
ObjectID m_objectInSpace;
Bool m_reservedForExit;
Coord3D m_hangarStart;
Real m_hangarStartOrient;
Coord3D m_location;
Coord3D m_prep;
Real m_orientation;
Int m_runway;
ExitDoorType m_door;
ObjectID m_objectInSpace;
Bool m_reservedForExit;
Bool m_postponedRunwayReservationForTakeoff;

ParkingPlaceInfo()
{
Expand All @@ -179,6 +181,7 @@ class ParkingPlaceBehavior : public UpdateModule,
m_door = DOOR_NONE_AVAILABLE;
m_objectInSpace = INVALID_ID;
m_reservedForExit = false;
m_postponedRunwayReservationForTakeoff = false;
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ void ParkingPlaceBehavior::purgeDead()
{
it->m_objectInSpace = INVALID_ID;
it->m_reservedForExit = false;
it->m_postponedRunwayReservationForTakeoff = false;
if (pu)
pu->setHoldDoorOpen(it->m_door, false);
}
Expand Down Expand Up @@ -430,6 +431,7 @@ void ParkingPlaceBehavior::releaseSpace(ObjectID id)
{
it->m_objectInSpace = INVALID_ID;
it->m_reservedForExit = false;
it->m_postponedRunwayReservationForTakeoff = false;
if (pu)
pu->setHoldDoorOpen(it->m_door, false);
}
Expand Down Expand Up @@ -468,18 +470,46 @@ void ParkingPlaceBehavior::transferRunwayReservationToNextInLineForTakeoff(Objec
}
}

//-------------------------------------------------------------------------------------------------
Bool ParkingPlaceBehavior::postponeRunwayReservation(UnsignedInt spaceIndex, Bool forLanding)
{
// TheSuperHackers @tweak Block the first attempt to reserve a runway for 'upper' space indices.
// This allows 'lower' space indices to reserve a runway first to ensure deterministic takeoff ordering.

if (m_spaces.size() > m_runways.size() && spaceIndex >= m_runways.size())
{
Bool& postponed = m_spaces[spaceIndex].m_postponedRunwayReservationForTakeoff;
if (forLanding)
{
postponed = false;
}
else if (!postponed)
{
postponed = true;
return true;
}
}

return false;
}

//-------------------------------------------------------------------------------------------------
Bool ParkingPlaceBehavior::reserveRunway(ObjectID id, Bool forLanding)
{
buildInfo();
purgeDead();

Int runway = -1;
for (std::vector<ParkingPlaceInfo>::iterator it = m_spaces.begin(); it != m_spaces.end(); ++it)
for (UnsignedInt i = 0; i < m_spaces.size(); ++i)
{
if (it->m_objectInSpace == id)
if (m_spaces[i].m_objectInSpace == id)
{
runway = it->m_runway;
#if !RETAIL_COMPATIBLE_CRC
if (deferUnsequencedRunwayReservationForTakeoff(i, forLanding))
return false;
#endif

runway = m_spaces[i].m_runway;
break;
}
}
Expand Down
Loading