Skip to content

Commit a83b79f

Browse files
committed
Replicated in Generals.
1 parent 855461e commit a83b79f

File tree

2 files changed

+45
-12
lines changed

2 files changed

+45
-12
lines changed

Generals/Code/GameEngine/Include/GameLogic/Module/ParkingPlaceBehavior.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ class ParkingPlaceBehavior : public UpdateModule,
130130
Bool reserveSpace(ObjectID id, Real parkingOffset, PPInfo* info);
131131
void releaseSpace(ObjectID id);
132132
Bool reserveRunway(ObjectID id, Bool forLanding);
133+
Bool postponeRunwayReservation(UnsignedInt spaceIndex, Bool forLanding);
133134
void releaseRunway(ObjectID id);
134135
Int getRunwayCount() const { return m_runways.size(); }
135136
ObjectID getRunwayReservation(Int r);
@@ -143,15 +144,16 @@ class ParkingPlaceBehavior : public UpdateModule,
143144

144145
struct ParkingPlaceInfo
145146
{
146-
Coord3D m_hangarStart;
147-
Real m_hangarStartOrient;
148-
Coord3D m_location;
149-
Coord3D m_prep;
150-
Real m_orientation;
151-
Int m_runway;
152-
ExitDoorType m_door;
153-
ObjectID m_objectInSpace;
154-
Bool m_reservedForExit;
147+
Coord3D m_hangarStart;
148+
Real m_hangarStartOrient;
149+
Coord3D m_location;
150+
Coord3D m_prep;
151+
Real m_orientation;
152+
Int m_runway;
153+
ExitDoorType m_door;
154+
ObjectID m_objectInSpace;
155+
Bool m_reservedForExit;
156+
Bool m_postponedRunwayReservationForTakeoff;
155157

156158
ParkingPlaceInfo()
157159
{
@@ -164,6 +166,7 @@ class ParkingPlaceBehavior : public UpdateModule,
164166
m_door = DOOR_NONE_AVAILABLE;
165167
m_objectInSpace = INVALID_ID;
166168
m_reservedForExit = false;
169+
m_postponedRunwayReservationForTakeoff = false;
167170
}
168171
};
169172

Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/ParkingPlaceBehavior.cpp

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ void ParkingPlaceBehavior::purgeDead()
159159
{
160160
it->m_objectInSpace = INVALID_ID;
161161
it->m_reservedForExit = false;
162+
it->m_postponedRunwayReservationForTakeoff = false;
162163
if (pu)
163164
pu->setHoldDoorOpen(it->m_door, false);
164165
}
@@ -379,6 +380,7 @@ void ParkingPlaceBehavior::releaseSpace(ObjectID id)
379380
{
380381
it->m_objectInSpace = INVALID_ID;
381382
it->m_reservedForExit = false;
383+
it->m_postponedRunwayReservationForTakeoff = false;
382384
if (pu)
383385
pu->setHoldDoorOpen(it->m_door, false);
384386
}
@@ -409,18 +411,46 @@ void ParkingPlaceBehavior::transferRunwayReservationToNextInLineForTakeoff(Objec
409411
}
410412
}
411413

414+
//-------------------------------------------------------------------------------------------------
415+
Bool ParkingPlaceBehavior::postponeRunwayReservation(UnsignedInt spaceIndex, Bool forLanding)
416+
{
417+
// TheSuperHackers @tweak Block the first attempt to reserve a runway for 'upper' space indices.
418+
// This allows 'lower' space indices to reserve a runway first to ensure deterministic takeoff ordering.
419+
420+
if (m_spaces.size() > m_runways.size() && spaceIndex >= m_runways.size())
421+
{
422+
Bool& postponed = m_spaces[spaceIndex].m_postponedRunwayReservationForTakeoff;
423+
if (forLanding)
424+
{
425+
postponed = false;
426+
}
427+
else if (!postponed)
428+
{
429+
postponed = true;
430+
return true;
431+
}
432+
}
433+
434+
return false;
435+
}
436+
412437
//-------------------------------------------------------------------------------------------------
413438
Bool ParkingPlaceBehavior::reserveRunway(ObjectID id, Bool forLanding)
414439
{
415440
buildInfo();
416441
purgeDead();
417442

418443
Int runway = -1;
419-
for (std::vector<ParkingPlaceInfo>::iterator it = m_spaces.begin(); it != m_spaces.end(); ++it)
444+
for (UnsignedInt i = 0; i < m_spaces.size(); ++i)
420445
{
421-
if (it->m_objectInSpace == id)
446+
if (m_spaces[i].m_objectInSpace == id)
422447
{
423-
runway = it->m_runway;
448+
#if !RETAIL_COMPATIBLE_CRC
449+
if (postponeRunwayReservation(i, forLanding))
450+
return false;
451+
#endif
452+
453+
runway = m_spaces[i].m_runway;
424454
break;
425455
}
426456
}

0 commit comments

Comments
 (0)