@@ -1533,7 +1533,7 @@ int runGame(Gametype gametype, int level) {
15331533 unsigned int currentStartTime = SDL_GetTicks ();
15341534 unsigned int originalStartTime = replayInfo.startInfo .ticks ;
15351535 replayTimeOffset = currentStartTime - originalStartTime;
1536-
1536+
15371537 // Adjust startInfo ticks to current time
15381538 replayInfo.startInfo .ticks = currentStartTime;
15391539 theGame.NewGame (replayInfo.startInfo );
@@ -1960,32 +1960,31 @@ int runGame(Gametype gametype, int level) {
19601960
19611961 // set bNearDeath to false theGame*.Update() will change to true as needed
19621962 bNearDeath = theGame.IsNearDeath () || theGame2.IsNearDeath ();
1963-
1963+
19641964 // Process replay actions if in replay mode
19651965 if (isReplayMode) {
19661966 unsigned int currentTick = SDL_GetTicks ();
1967+ // Process all actions from the replay queue up to the current time
1968+ // We MUST use recorded UPDATE tick values to maintain deterministic state
19671969 while (replayActionIndex < replayQueue.size ()) {
19681970 const BlockGameAction& replayAction = replayQueue[replayActionIndex];
1969- // Process all actions up to the current tick
1970- if (replayAction.action == BlockGameAction::Action::UPDATE) {
1971- if (replayAction.tick > currentTick) {
1972- break ; // Wait for the right time
1973- }
1974- theGame.DoAction (replayAction);
1975- replayActionIndex++;
1976- break ; // Only process one UPDATE per frame
1977- } else {
1978- // Non-UPDATE actions can be processed immediately
1979- theGame.DoAction (replayAction);
1980- replayActionIndex++;
1971+
1972+ // Check if it's time to process this action
1973+ if (replayAction.tick > currentTick) {
1974+ break ; // Wait for the right time
19811975 }
1976+
1977+ // Process the action with its original recorded tick value
1978+ theGame.DoAction (replayAction);
1979+ replayActionIndex++;
19821980 }
1983- } else {
1981+ }
1982+ else {
19841983 // Updates the objects (only when not in replay mode)
19851984 a.action = BlockGameAction::Action::UPDATE;
19861985 theGame.DoAction (a);
19871986 }
1988-
1987+
19891988 // Always update player 2
19901989 a.action = BlockGameAction::Action::UPDATE;
19911990 theGame2.DoAction (a);
0 commit comments