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

Conversation

Caball009
Copy link

@Caball009 Caball009 commented Jul 17, 2025

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

  • Replicate in Generals
  • Add code comments

@Caball009 Caball009 added China Affects China faction Enhancement Is new feature or request Minor Severity: Minor < Major < Critical < Blocker USA Affects USA faction Gen Relates to Generals ZH Relates to Zero Hour NoRetail This fix or change is not applicable with Retail game compatibility labels Jul 17, 2025
@Caball009
Copy link
Author

Caball009 commented Jul 31, 2025

@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.

Copy link

@xezon xezon left a 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)
Copy link

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.

Copy link
Author

@Caball009 Caball009 Aug 13, 2025

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;
Copy link

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.

Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
China Affects China faction Enhancement Is new feature or request Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker NoRetail This fix or change is not applicable with Retail game compatibility USA Affects USA faction ZH Relates to Zero Hour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The order in which aircraft take off from airfields is non-deterministic
2 participants