Skip to content

[GEN][ZH] Fixed garrison points not initialized before first use #783

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

roossienb
Copy link

@roossienb roossienb commented Apr 29, 2025

Fixes garrison points not initialized before first use throwing an debug asset

Background

GarrisonContain::loadGarrisonPoints() method is not initially run when the object is created because draw is false in
GarrisonContain::onObjectCreated().

The first time loadGarrisonPoints() is called is when the first unit garissons the object and GarrisonContain::onContaining() is called. At that point the debug assert has already fired.

The issue lies in its parent class method OpenContain::addToContain.

	// ensure our contents are positions correctly.
	redeployOccupants();

	// trigger an onContaining event for the object that just "ate" something
	if( getObject()->getContain() )
	{
		getObject()->getContain()->onContaining( rider, wasSelected );
	}

It first calls redeployOccupants(), which contains the assert, then calls onContaining.

Solution in this PR is to call redeployOccupants() after onContaining.
I've tested it by building, occupying exiting and destroying garrisonable objects to ensure there were no unexpected side effect.

This did however caused a mismatch in the Golden replay (about 10 minutes in).

I have looked at less elegant solutions - e.g. calling loadGarrisonPoints() in redeployOccupants, but that still causes a mismatch.

@roossienb roossienb marked this pull request as ready for review April 29, 2025 19:34
@roossienb roossienb changed the title [GEN][ZH]Fixed garrison points not initialized before first use (#) [GEN][ZH]Fixed garrison points not initialized before first use. Apr 29, 2025
roossienb pushed a commit to roossienb/GeneralsGameCode that referenced this pull request Apr 29, 2025
@roossienb roossienb force-pushed the fix/garrison-points-not-initialized branch from 94d6f1a to 0d506af Compare April 29, 2025 19:35
@roossienb roossienb marked this pull request as draft April 29, 2025 19:53
@roossienb roossienb added Bug Something is not working right GameMismatchWith104 Affects game state towards original 1.04 labels Apr 29, 2025
@Mauller
Copy link

Mauller commented Apr 29, 2025

Looks like this Resolved the problem, but causes a mismatch.
Worth keeping to merge later once we drop compat.

SkyAero — 09:05 PM
main is fine, PR is causing mismatch

@roossienb roossienb changed the title [GEN][ZH]Fixed garrison points not initialized before first use. [GEN][ZH] Fixed garrison points not initialized before first use. Apr 30, 2025
@roossienb roossienb changed the title [GEN][ZH] Fixed garrison points not initialized before first use. [GEN][ZH] Fixed garrison points not initialized before first use Apr 30, 2025
@roossienb roossienb force-pushed the fix/garrison-points-not-initialized branch from 0d506af to b84635c Compare April 30, 2025 11:58
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 GameMismatchWith104 Affects game state towards original 1.04
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Garrison points are not initialised before the first use, throwing a non init assert.
2 participants