https://github.com/libsdl-org/Maelstrom/commit/b51ae566448da60488e4a1397cefb148c28efeb7
From b51ae566448da60488e4a1397cefb148c28efeb7 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 20 Nov 2011 22:16:10 -0500
Subject: [PATCH] When showing a replay, show it by default from the
perspective of the person who recorded it.
---
game/game.cpp | 6 +++++-
game/replay.cpp | 11 +++++++----
game/replay.h | 3 +++
3 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/game/game.cpp b/game/game.cpp
index 71aea891..d139db41 100644
--- a/game/game.cpp
+++ b/game/game.cpp
@@ -68,7 +68,11 @@ static bool SetupPlayers(void)
return false;
/* Set up the controls for the game */
- gDisplayed = -1;
+ if (gReplay.IsPlaying()) {
+ gDisplayed = gReplay.GetDisplayPlayer();
+ } else {
+ gDisplayed = -1;
+ }
for (int i = 0; i < MAX_PLAYERS; ++i) {
if (gGameInfo.IsValidPlayer(i)) {
if (gGameInfo.IsLocalPlayer(i)) {
diff --git a/game/replay.cpp b/game/replay.cpp
index 7a10023e..f0a88738 100644
--- a/game/replay.cpp
+++ b/game/replay.cpp
@@ -316,16 +316,19 @@ Replay::HandleNewGame()
m_game.PrepareForReplay();
m_data.Reset();
m_pausedInput.Reset();
+
+ // We'll be recording new info here.
+ m_frameCount = 0;
+ m_finalPlayer = 0;
+ m_finalWave = 0;
+ SDL_zero(m_finalScore);
+
} else if (m_mode == REPLAY_PLAYBACK) {
gGameInfo.CopyFrom(m_game);
gGameInfo.PrepareForReplay();
m_data.Seek(0);
}
m_seed = m_game.seed;
- m_frameCount = 0;
- m_finalPlayer = 0;
- m_finalWave = 0;
- SDL_zero(m_finalScore);
}
bool
diff --git a/game/replay.h b/game/replay.h
index b3a8d8e2..6a2457e1 100644
--- a/game/replay.h
+++ b/game/replay.h
@@ -56,6 +56,9 @@ class Replay
bool IsRecording() {
return m_mode == REPLAY_RECORDING;
}
+ int GetDisplayPlayer() {
+ return m_finalPlayer;
+ }
bool Load(const char *file, bool headerOnly = false);
bool Save(const char *file);