fix(particlesys): Decouple creation of particle systems from game logic#2739
Conversation
|
|
||
| // get the what is the position we're going to played the effect at | ||
| pos = getLocalEffectPos( &modData->m_particleSystem[ newState ][ i ].locInfo, draw ); | ||
| pos = getLocalEffectPos( &modData->m_particleSystem[ newState ][ i ].locInfo, draw, TRUE ); |
There was a problem hiding this comment.
I tried to make this more elegant, by accepting generally structs from FXDamageFXListInfo, FXDamageOCLInfo or FXDamageParticleSystemInfo and deciding based on that whether to use game logic or client logic RNG, but we can't touch the structs really without causing mismatching.
| for (UnsignedInt e = 0 ; e < emitterCount; ++e) | ||
| { | ||
| Coord3D offs = { 0,0,0 }; | ||
| curVictim->getGeometryInfo().makeGameLogicRandomOffsetWithinFootprint(offs); |
There was a problem hiding this comment.
Best to keep these as-is as not much was gained by unrolling
| if(sys) | ||
| { | ||
| Coord3D offs = { 0,0,0 }; | ||
| target->getGeometryInfo().makeGameLogicRandomOffsetWithinFootprint(offs); |
|
| Filename | Overview |
|---|---|
| GeneralsMD/Code/GameEngine/Include/Common/Geometry.h | Old makeRandomOffsetWithinFootprint declaration removed and replaced with two clearly-named public variants; already uses #pragma once. |
| GeneralsMD/Code/GameEngine/Source/Common/System/Geometry.cpp | Static helper refactored to accept a function-pointer for RNG, with two thin forwarding wrappers; logic identical to original for both geometry types. |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/GenerateMinefieldBehavior.cpp | Trivial rename from makeRandomOffsetWithinFootprint to makeGameLogicRandomOffsetWithinFootprint; semantics unchanged. |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Damage/TransitionDamageFX.cpp | getLocalEffectPos gains useGameClientRandom param; particle-system path now uses client RNG; RETAIL block correctly gates game-logic RNG forwarding on if(pSystem) matching the original guard. |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/EMPUpdate.cpp | All three game-logic RNG calls (offset, z-height, initial delay) correctly moved to client RNG; RETAIL block inside if(sys) advances logic RNG the same number of times as the original. |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpecialAbilityUpdate.cpp | Single offset call correctly switched to client RNG; RETAIL block inside if(sys) mirrors original logic-RNG advancement. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Particle System Creation Site] --> B{pSystemT / tmp exists?}
B -- No --> Z[Skip — no RNG advanced]
B -- Yes --> C[createParticleSystem]
C --> D{sys != null?}
D -- No --> Z2[Skip — no RNG advanced]
D -- Yes --> E[makeGameClientRandomOffsetWithinFootprint\nGameClientRandomValue calls\nVisual positioning only]
E --> F{RETAIL_COMPATIBLE_CRC?}
F -- No --> G[Done]
F -- Yes --> H[makeGameLogicRandomOffsetWithinFootprint\nGameLogicRandomValue calls\nDiscard results — advance RNG state only]
H --> G
subgraph GenerateMinefieldBehavior
M[makeGameLogicRandomOffsetWithinFootprint\nGame logic RNG — affects simulation]
end
Reviews (5): Last reviewed commit: "Simplify ahead of 2740" | Re-trigger Greptile
|
This should be tested against a large number of replays. |
bd19747 to
968de38
Compare
968de38 to
8e84331
Compare
|
While this change is technically ok, the implementation details are a bit complicated. I created an alternative fix with #2742 to address it. |
Very nice |
Based on branch by Caball.
Todo