Skip to content

bugfix: Prevent fallen Angry Mob members respawning at the Barracks after loading a save#2314

Open
Stubbjax wants to merge 1 commit intoTheSuperHackers:mainfrom
Stubbjax:fix-unsaved-angry-mob-respawn-data
Open

bugfix: Prevent fallen Angry Mob members respawning at the Barracks after loading a save#2314
Stubbjax wants to merge 1 commit intoTheSuperHackers:mainfrom
Stubbjax:fix-unsaved-angry-mob-respawn-data

Conversation

@Stubbjax
Copy link

This change fixes an issue where fallen Angry Mob members respawn at the Barracks after loading a save.

Angry Mob members spawn from the Barracks if m_initialBurstCountdown is greater than 0. As m_initialBurstCountdown is not saved in the retail game, it is always reset to its default/retail value of 5 when loading a saved game. This results in up to 5 Angry Mob members respawning from the Barracks and attempting to run across the map to join the nexus, where they often die again in the process due to being too far away.

Before

Fallen Angry Mob members respawn at the Barracks

BAD_SPAWN.mp4

After

Fallen Angry Mob members respawn at the nexus

GOOD_SPAWN.mp4

@Stubbjax Stubbjax self-assigned this Feb 16, 2026
@Stubbjax Stubbjax added Bug Something is not working right, typically is user facing GLA Affects GLA faction Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour NoRetail This fix or change is not applicable with Retail game compatibility labels Feb 16, 2026
@greptile-apps
Copy link

greptile-apps bot commented Feb 16, 2026

Greptile Summary

This PR fixes a bug where fallen Angry Mob members incorrectly respawned at the Barracks after loading a saved game, rather than at the nexus where they should spawn. The fix adds serialization for the m_initialBurstCountdown field in the SpawnBehavior::xfer() method, which tracks how many initial burst spawns should exit from the barracks.

Key changes:

  • Added m_initialBurstCountdown to the save/load logic with version 3
  • Used RETAIL_COMPATIBLE_XFER_SAVE preprocessor guard to maintain backward compatibility with retail saves
  • Applied the fix to both Generals and GeneralsMD codebases

Technical details:
The m_initialBurstCountdown variable is initialized from md->m_initialBurst (typically 5) and decremented each time a spawn exits via the barracks. Without serialization, loading a save would reset this value to 5, causing up to 5 dead Angry Mob members to respawn at the barracks and run across the map to the nexus. By persisting this value, the game correctly tracks which spawns have already exited the barracks.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The fix correctly adds serialization for a single field that was missing from save/load logic, following the established pattern used throughout the codebase. The use of RETAIL_COMPATIBLE_XFER_SAVE guards ensures backward compatibility. The change is minimal, well-documented, and directly addresses the root cause of the bug.
  • No files require special attention

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/SpawnBehavior.cpp Added serialization for m_initialBurstCountdown with version 3, using RETAIL_COMPATIBLE_XFER_SAVE guard to maintain save compatibility
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/SpawnBehavior.cpp Added serialization for m_initialBurstCountdown with version 3, using RETAIL_COMPATIBLE_XFER_SAVE guard to maintain save compatibility

Last reviewed commit: 23304a3

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +1011 to +1012
if (version >= 3)
xfer->xferUnsignedInt(&m_initialBurstCountdown);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent brace style with surrounding code (line 1007-1009 uses braces)

Suggested change
if (version >= 3)
xfer->xferUnsignedInt(&m_initialBurstCountdown);
if (version >= 3) {
xfer->xferUnsignedInt(&m_initialBurstCountdown);
}

Context Used: Rule from dashboard - Always place if/else/for/while statement bodies on separate lines from the condition to allow precis... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/SpawnBehavior.cpp
Line: 1011:1012

Comment:
Inconsistent brace style with surrounding code (line 1007-1009 uses braces)

```suggestion
	if (version >= 3) {
		xfer->xferUnsignedInt(&m_initialBurstCountdown);
	}
```

**Context Used:** Rule from `dashboard` - Always place if/else/for/while statement bodies on separate lines from the condition to allow precis... ([source](https://app.greptile.com/review/custom-context?memory=16b9b669-b823-49be-ba5b-2bd30ff3ba6d))

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +1096 to +1097
if (version >= 3)
xfer->xferUnsignedInt(&m_initialBurstCountdown);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent brace style with surrounding code (line 1092-1094 uses braces)

Suggested change
if (version >= 3)
xfer->xferUnsignedInt(&m_initialBurstCountdown);
if (version >= 3) {
xfer->xferUnsignedInt(&m_initialBurstCountdown);
}

Context Used: Rule from dashboard - Always place if/else/for/while statement bodies on separate lines from the condition to allow precis... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/SpawnBehavior.cpp
Line: 1096:1097

Comment:
Inconsistent brace style with surrounding code (line 1092-1094 uses braces)

```suggestion
	if (version >= 3) {
		xfer->xferUnsignedInt(&m_initialBurstCountdown);
	}
```

**Context Used:** Rule from `dashboard` - Always place if/else/for/while statement bodies on separate lines from the condition to allow precis... ([source](https://app.greptile.com/review/custom-context?memory=16b9b669-b823-49be-ba5b-2bd30ff3ba6d))

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

@Skyaero42
Copy link

Question: Are they supposed to respawn at all?

@Stubbjax
Copy link
Author

Question: Are they supposed to respawn at all?

Yes; see SpawnReplaceDelay and ExitDelay fields in the data. See m_spawnReplaceDelayData and m_replacementTimes in the logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something is not working right, typically is user facing Gen Relates to Generals GLA Affects GLA faction Minor Severity: Minor < Major < Critical < Blocker NoRetail This fix or change is not applicable with Retail game compatibility ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants