Skip to content

Some improvement to the game loop#935

Merged
stavrosfa merged 1 commit into
C7-Game:Developmentfrom
stavrosfa:enhancement/game-loop-improvements
May 19, 2026
Merged

Some improvement to the game loop#935
stavrosfa merged 1 commit into
C7-Game:Developmentfrom
stavrosfa:enhancement/game-loop-improvements

Conversation

@stavrosfa
Copy link
Copy Markdown
Contributor

@stavrosfa stavrosfa commented May 15, 2026

This PR addresses the issue, where upon launching the game, if the player had finished their turn, the AI would immediatly take control, and the game would either get stuck in a loop, or have a black screen.

The main issue was occuring because after loading the game (game data & map), a call to advance the turn was made.

If the human player had finished their turn, either by choise, or by (game) design, that meant the loop was moving on to the next player in the list, effectively skipping the human player.
Now that was working well when in regular play mode, but when loading in directly where the human player has finished their turn, the issue becomes clear.

So, now, no matter what, when loading a new/saved/scenario game, the human player will go first. Even if they have no units left, the have to end the turn manually with the usual methods.

Some other things:

  • Some of the Game class code was re-ordered, to try and make it more readable, and logically grouped where I thought it would be useful.

  • Removed the PreGame entry from the GameState enum as it wasn't really used anywhere, and also interfered with fixing the main bug of this PR

  • I added the skipFirstTurn player flag when loading up a .biq scenario (eample usage: 9 WWII in the Pacific.biq)

  • I disabled being able to click anything while the AI are playing their turns.

  • Some class clean-up, renaming and removing unused imports, etc

  • Hide all the buttons when they are created to avoid showing them all at once, they already are getting shown/hidden properly when a unit is selected.

  • Added isSettler flag to the UnitPrototype class, so that we don't have to check the string name of the prototype

I hope I didn't miss anything, let me know if you have questions or comments

@ajhalme
Copy link
Copy Markdown
Contributor

ajhalme commented May 16, 2026

LGTM. Appears to fix the attack-on-load crash game save I shared recently. 👍

@stavrosfa
Copy link
Copy Markdown
Contributor Author

Adding the save for the crash game you mentioned for future reference.

Another good example that this PR is working is the 9 WWII in the Pacific.biq scenario when picking anyone except Japan, and since they skip their first turn, all units are disabled (which should trigger the original error in some way, and Japan should start moving, and also incrementing the turn to Jan 1942), but the turn starts with the human player and the game waits for the button or Spacebar/Enter to be pressed.

on_load_animation_bug_2.json.zip

@stavrosfa stavrosfa merged commit c2e56fa into C7-Game:Development May 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants