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 1 commit 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 deferUnsequencedRunwayReservationForTakeoff(UnsignedInt index, 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;
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;
ObjectID m_objectInSpace;
Bool m_reservedForExit;
Bool m_deferredRunwayReservationForTakeoff;

ParkingPlaceInfo()
{
Expand All @@ -179,6 +181,7 @@ class ParkingPlaceBehavior : public UpdateModule,
m_door = DOOR_NONE_AVAILABLE;
m_objectInSpace = INVALID_ID;
m_reservedForExit = false;
m_deferredRunwayReservationForTakeoff = 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_deferredRunwayReservationForTakeoff = false;
if (pu)
pu->setHoldDoorOpen(it->m_door, false);
}
Expand Down Expand Up @@ -468,18 +469,45 @@ void ParkingPlaceBehavior::transferRunwayReservationToNextInLineForTakeoff(Objec
}
}

//-------------------------------------------------------------------------------------------------
Bool ParkingPlaceBehavior::deferUnsequencedRunwayReservationForTakeoff(UnsignedInt index, Bool forLanding)
{
CONSTEXPR const UnsignedInt INDEX_A = 2, INDEX_B = 3;

if (index == INDEX_A || index == INDEX_B)
{
Bool& deferred = m_spaces[index].m_deferredRunwayReservationForTakeoff;
if (forLanding)
{
deferred = false;
}
else if (!deferred)
{
deferred = 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