From 45ead4d0bf00aea9c94f8606d2c49736309621b3 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 28 Sep 2019 17:31:14 +0300 Subject: Refactoring --- src/core/CutsceneMgr.cpp | 80 ++++++++++++++++++++++++------------------------ src/core/CutsceneMgr.h | 2 +- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/core/CutsceneMgr.cpp b/src/core/CutsceneMgr.cpp index 40ae0d2e..b3737c4d 100644 --- a/src/core/CutsceneMgr.cpp +++ b/src/core/CutsceneMgr.cpp @@ -329,41 +329,41 @@ CCutsceneMgr::CreateCutsceneObject(int modelId) void CCutsceneMgr::DeleteCutsceneData(void) { - if (ms_loaded) { - ms_cutsceneProcessing = false; - ms_useLodMultiplier = false; + if (!ms_loaded) return; - for (--ms_numCutsceneObjs; ms_numCutsceneObjs >= 0; ms_numCutsceneObjs--) { - CWorld::Remove(ms_pCutsceneObjects[ms_numCutsceneObjs]); - ms_pCutsceneObjects[ms_numCutsceneObjs]->DeleteRwObject(); - if (ms_pCutsceneObjects[ms_numCutsceneObjs]) - delete ms_pCutsceneObjects[ms_numCutsceneObjs]; - } - ms_numCutsceneObjs = 0; + ms_cutsceneProcessing = false; + ms_useLodMultiplier = false; - if (ms_animLoaded) - CAnimManager::RemoveLastAnimFile(); + for (--ms_numCutsceneObjs; ms_numCutsceneObjs >= 0; ms_numCutsceneObjs--) { + CWorld::Remove(ms_pCutsceneObjects[ms_numCutsceneObjs]); + ms_pCutsceneObjects[ms_numCutsceneObjs]->DeleteRwObject(); + if (ms_pCutsceneObjects[ms_numCutsceneObjs]) + delete ms_pCutsceneObjects[ms_numCutsceneObjs]; + } + ms_numCutsceneObjs = 0; - ms_animLoaded = false; - TheCamera.RestoreWithJumpCut(); - TheCamera.SetWideScreenOff(); - ms_running = false; - ms_loaded = false; + if (ms_animLoaded) + CAnimManager::RemoveLastAnimFile(); - FindPlayerPed()->bIsVisible = true; - CPad::GetPad(0)->DisablePlayerControls &= ~PLAYERCONTROL_DISABLED_80; - CWorld::Players[CWorld::PlayerInFocus].MakePlayerSafe(false); + ms_animLoaded = false; + TheCamera.RestoreWithJumpCut(); + TheCamera.SetWideScreenOff(); + ms_running = false; + ms_loaded = false; - if (strcmpi(ms_cutsceneName, "end")) { - DMAudio.StopCutSceneMusic(); - if (strcmpi(ms_cutsceneName, "bet")) - DMAudio.ChangeMusicMode(1); - } - CTimer::Stop(); - //TheCamera.GetScreenFadeStatus() == 2; // what for?? - CGame::DrasticTidyUpMemory(); - CTimer::Update(); + FindPlayerPed()->bIsVisible = true; + CPad::GetPad(0)->DisablePlayerControls &= ~PLAYERCONTROL_DISABLED_80; + CWorld::Players[CWorld::PlayerInFocus].MakePlayerSafe(false); + + if (strcmpi(ms_cutsceneName, "end")) { + DMAudio.StopCutSceneMusic(); + if (strcmpi(ms_cutsceneName, "bet")) + DMAudio.ChangeMusicMode(1); } + CTimer::Stop(); + //TheCamera.GetScreenFadeStatus() == 2; // what for?? + CGame::DrasticTidyUpMemory(); + CTimer::Update(); } void @@ -395,20 +395,20 @@ CCutsceneMgr::Update(void) break; } - if (ms_running) { - ms_cutsceneTimer += CTimer::GetTimeStepNonClipped() * 0.02; - if (strcmpi(ms_cutsceneName, "end") && TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_FLYBY && ms_cutsceneLoadStatus == CUTSCENE_LOADING_0) { - if (CPad::GetPad(0)->GetCrossJustDown() - || (CGame::playingIntro && CPad::GetPad(0)->GetStartJustDown()) - || CPad::GetPad(0)->GetLeftMouseJustDown() - || CPad::GetPad(0)->GetPadEnterJustDown() || CPad::GetPad(0)->GetEnterJustDown() // NOTE: In original code it's a single CPad method - || CPad::GetPad(0)->GetCharJustDown(VK_SPACE)) - FinishCutscene(); - } + if (!ms_running) return; + + ms_cutsceneTimer += CTimer::GetTimeStepNonClipped() * 0.02; + if (strcmpi(ms_cutsceneName, "end") && TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_FLYBY && ms_cutsceneLoadStatus == CUTSCENE_LOADING_0) { + if (CPad::GetPad(0)->GetCrossJustDown() + || (CGame::playingIntro && CPad::GetPad(0)->GetStartJustDown()) + || CPad::GetPad(0)->GetLeftMouseJustDown() + || CPad::GetPad(0)->GetPadEnterJustDown() || CPad::GetPad(0)->GetEnterJustDown() // NOTE: In original code it's a single CPad method + || CPad::GetPad(0)->GetCharJustDown(VK_SPACE)) + FinishCutscene(); } } -bool CCutsceneMgr::HasCutsceneFinished() { return TheCamera.GetPositionAlongSpline() == 1.0; } +bool CCutsceneMgr::HasCutsceneFinished(void) { return TheCamera.GetPositionAlongSpline() == 1.0; } STARTPATCHES InjectHook(0x4045D0, &CCutsceneMgr::Initialise, PATCH_JUMP); diff --git a/src/core/CutsceneMgr.h b/src/core/CutsceneMgr.h index 4f62d7c8..69ce58a6 100644 --- a/src/core/CutsceneMgr.h +++ b/src/core/CutsceneMgr.h @@ -27,7 +27,7 @@ public: static bool IsRunning(void) { return ms_running; } static bool IsCutsceneProcessing(void) { return ms_cutsceneProcessing; } static CCutsceneObject* GetCutsceneObject(int id) { return ms_pCutsceneObjects[id]; } - static int GetCutsceneTimeInMilleseconds() { return 1000.0f * ms_cutsceneTimer; } + static int GetCutsceneTimeInMilleseconds(void) { return 1000.0f * ms_cutsceneTimer; } static char *GetCutsceneName(void) { return ms_cutsceneName; } static bool HasCutsceneFinished(void); -- cgit v1.2.3