-
Notifications
You must be signed in to change notification settings - Fork 89
[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
base: main
Are you sure you want to change the base?
[GEN][ZH] Make aircraft takeoff order deterministic #1297
Conversation
GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ParkingPlaceBehavior.h
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/ParkingPlaceBehavior.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ParkingPlaceBehavior.h
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/ParkingPlaceBehavior.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/ParkingPlaceBehavior.cpp
Outdated
Show resolved
Hide resolved
@xezon I made a small adjustment to the code to make it a bit more flexible. Airfields with equal counts of spaces and runways are excluded. Index checks are now tied to the runway count so that it can now handle this 3 runway / 6 space airfield: https://www.moddb.com/mods/operation-firestorm/images/usa-airforce-generals-airfield If there are airfields with say 2 runways and more than 4 spaces (i.e. more than double the runway count), the fix in this PR will not work 100%. I'm not sure how to fix that yet or if such airfields even exist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this and it works in principle but there is one bug.
A bit of documentation for the new logic would be good.
@@ -468,18 +469,43 @@ void ParkingPlaceBehavior::transferRunwayReservationToNextInLineForTakeoff(Objec | |||
} | |||
} | |||
|
|||
//------------------------------------------------------------------------------------------------- | |||
Bool ParkingPlaceBehavior::deferUnsequencedRunwayReservationForTakeoff(UnsignedInt spaceIndex, Bool forLanding) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there perhaps a better name for this function? It reads confusing to me.
How about "postponeRunwayReservation" ?
Also don't need to mention "ForTakeoff" in the function because there is an argument "Bool forLanding" which either implies takeoff or contradicts it.
Can also add a description for this function to help understand what it does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed function name to "postponeRunwayReservation" as well as the member variable.
I added a short comment to the function.
Bool& deferred = m_spaces[spaceIndex].m_deferredRunwayReservationForTakeoff; | ||
if (forLanding) | ||
{ | ||
deferred = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not work correctly when planes take off and are asked to land on another airfield. Then Runway 2 and 3 will have deferred=true
and new planes built will be able to take off immediately from runway 2 and 3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I hadn't thought that through.
The flag is now reset when a space is released, so this bug should be fixed.
…l009/GeneralsGameCode into fix_airfield_takeoff_order
The order in which aircraft take off from airfields is non-deterministic, which can cause delays between pairs of aircraft taking off. This PR defers an airfield runway reservation request once, if that request came from a 'lower priority' space.
TODO