This commit is contained in:
Brandon Johnson
2026-01-31 14:55:12 -05:00
parent 1bf9ecd4a2
commit 0fd70b13e1
2 changed files with 26 additions and 0 deletions

View File

@@ -342,6 +342,7 @@ export class Game {
public autoRecordInputs: boolean;
public inputStartTick: number;
public replayInputStartTick: number | null;
public replayAutoFastForward: boolean;
constructor({
hud,
@@ -440,6 +441,7 @@ export class Game {
this.autoRecordInputs = true;
this.inputStartTick = 0;
this.replayInputStartTick = null;
this.replayAutoFastForward = false;
}
setGameSource(source: GameSource) {
@@ -464,10 +466,12 @@ export class Game {
if (enabled) {
this.inputRecord = null;
this.replayInputStartTick = 0;
this.replayAutoFastForward = true;
} else {
this.inputFeed = null;
this.inputFeedIndex = 0;
this.replayInputStartTick = null;
this.replayAutoFastForward = false;
}
}
@@ -1308,6 +1312,16 @@ export class Game {
}
this.resetBallForStage({ withIntro: true });
if (this.replayInputStartTick !== null) {
const startTick = Math.max(0, this.replayInputStartTick);
this.introTotalFrames = startTick;
this.introTimerFrames = startTick;
if (this.ball) {
this.cameraController?.initForStage(this.ball, this.ball.startRotY, this.stageRuntime);
}
this.replayAutoFastForward = true;
this.setFixedTickMode(true, 1);
}
void this.audio?.playMusicForStage(stageId, this.gameSource);
this.statusText = '';
@@ -2023,6 +2037,12 @@ export class Game {
this.simPerf.tickCount += 1;
}
this.simTick += 1;
if (this.replayAutoFastForward && this.replayInputStartTick !== null) {
if (this.simTick >= this.replayInputStartTick) {
this.replayAutoFastForward = false;
this.setFixedTickMode(false, 1);
}
}
}
}
if (this.simPerf.enabled && this.simPerf.tickCount >= this.simPerf.logEvery) {

View File

@@ -895,6 +895,11 @@ async function startReplay(replay: ReplayData) {
hudStatus.textContent = '';
}
game.setReplayMode(true, true);
activeGameSource = replay.gameSource;
if (gameSourceSelect) {
gameSourceSelect.value = replay.gameSource;
}
updateGameSourceFields();
game.setGameSource(replay.gameSource);
game.stageBasePath = getStageBasePath(replay.gameSource);
currentSmb2LikeMode = null;
@@ -913,6 +918,7 @@ async function startReplay(replay: ReplayData) {
while (game.simTick < game.replayInputStartTick) {
game.update(game.fixedStep);
}
game.replayAutoFastForward = false;
game.setFixedTickMode(false, 1);
setReplayStatus(`Replay loaded (stage ${replay.stageId})`);
}