Skip to content

fix(particlesys): Decouple creation of particle systems from game logic#1

Draft
stephanmeesters wants to merge 1 commit into
fix/createparticlesystem-nullcheck-fffrom
fix/decouple-particle-creation-gamelogic-ff
Draft

fix(particlesys): Decouple creation of particle systems from game logic#1
stephanmeesters wants to merge 1 commit into
fix/createparticlesystem-nullcheck-fffrom
fix/decouple-particle-creation-gamelogic-ff

Conversation

@stephanmeesters
Copy link
Copy Markdown
Owner

Based on branch by Caball.

Tested that it passes the gold replay while using ParticleSystemManagerDummy which sets all particle templates to null.

The logic was written to also keep behavior the same in the case that a particle system does not exist because of a data change like in mods. Added to this should be TheParticleSystemManager->isDummy(), which is not available yet, this can be added in TheSuperHackers#2709.

@Caball009
Copy link
Copy Markdown

Caball009 commented May 18, 2026

FWIW, I'm not sure if it's desirable, but you could use GameLogicRandomValueUnchanged,

Details

Without retail compatibility GameLogicRandomValueUnchanged is kind of a hybrid in that in it provides a logical random value but doesn't change the logical seeds themselves. That way you can have synchronized random values as long as the preceding and following CRC values are the same for all clients, and the act of getting the random values doesn't modify the CRC values.

if(sys) // todo: add || TheParticleSystemManager->isDummy()
{
Coord3D offs = { 0,0,0 };
target->getGeometryInfo().makeGameLogicRandomOffsetWithinFootprint(offs);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Or just unroll the relevant calls to GameLogicRandomValue here?

// TheSuperHackers @fix stephanmeesters 18/05/2026 Fix issue where the creation of a certain particle system
// would influence game logic CRC due to the incorrect usage of game logic RNG. This code block is required to
// forward the game logic RNG and keep things consistent.
if(tmp) // todo: add || TheParticleSystemManager->isDummy()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I dont think || TheParticleSystemManager->isDummy() would be correct. It would mean a null template would pass. I suspect this means we need to preserve templates in the dummy manager, at least for RETAIL_COMPATIBLE_CRC.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

|| TheParticleSystemManager->isDummy() here assumes that the template exists in the original data (which for the three cases in this PR it does), which isn't great to assume that I suppose, it does pass the replay test.

* The position is local to to the object */
//-------------------------------------------------------------------------------------------------
static Coord3D getLocalEffectPos( const FXLocInfo *locInfo, Drawable *draw )
static Coord3D getLocalEffectPos( const FXLocInfo *locInfo, Drawable *draw, Bool useGameLogicRandom = TRUE)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can we do this more elegantly? I do not have better idea but it is a bit sad to have this as argument.

}

//=============================================================================
void GeometryInfo::makeGameClientRandomOffsetOnPerimeter(Coord3D& pt) const
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You can avoid making a duplicate function by passing a function pointer for GameClientRandomValueReal or GameLogicRandomValueReal. Same for the other function.

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.

3 participants