Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit dfc186e

Browse files
committed
Fixed phantom screenshake when launching/restarting activities sometimes
1 parent a80a5e5 commit dfc186e

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

Entities/Activity.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ void Activity::Clear() {
316316
if (int screenId = ScreenOfPlayer(player); screenId != -1) {
317317
g_FrameMan.ClearScreenText(screenId);
318318
g_CameraMan.SetScreenOcclusion(Vector(), screenId);
319-
g_CameraMan.SetScreenShake(0.0F, screenId);
320319
}
320+
g_CameraMan.ResetAllScreenShake();
321321

322322
//TODO currently this sets brains to players arbitrarily. We should save information on which brain is for which player in the scene so we can set them properly!
323323
if (m_IsActive[player]) {

Managers/ActivityMan.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,6 @@ namespace RTE {
293293
// Stop all music played by the current activity. It will be re-started by the new Activity.
294294
g_AudioMan.StopMusic();
295295

296-
// Reset screen positions and shake
297-
for (int screen = 0; screen < c_MaxScreenCount; screen++) {
298-
g_CameraMan.SetScreenShake(0, screen);
299-
}
300-
301296
m_ActivityAllowsSaving = false;
302297

303298
m_StartActivity.reset(activity);

Managers/CameraMan.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,16 @@ namespace RTE {
171171
return Vector(static_cast<float>(frameWidth), static_cast<float>(frameHeight));
172172
}
173173

174+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
175+
176+
void CameraMan::ResetAllScreenShake() {
177+
for (int screenId = 0; screenId < g_FrameMan.GetScreenCount(); ++screenId) {
178+
Screen &screen = m_Screens[screenId];
179+
screen.ScreenShakeMagnitude = 0;
180+
screen.ScrollTimer.Reset();
181+
}
182+
}
183+
174184
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
175185

176186
void CameraMan::AddScreenShake(float magnitude, const Vector &position) {

Managers/CameraMan.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ namespace RTE {
200200
#pragma endregion
201201

202202
#pragma region Screen Shake Actions
203+
/// <summary>
204+
/// Resets all screen shake and the screen scroll timers that affect it.
205+
/// </summary>
206+
void ResetAllScreenShake();
207+
203208
/// <summary>
204209
/// Increases the magnitude of screen shake.
205210
/// This is used for spatially located screen-shake, and will automatically determine which screens have shake applied

0 commit comments

Comments
 (0)