From 861995c88ef312beb4bc1b7920d612bd52590303 Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 8 Mar 2022 23:31:50 +0100 Subject: Removed legacy functions that acted as wrappers for time compression --- Stars45/DebriefDlg.cpp | 2 +- Stars45/Game.cpp | 10 ---------- Stars45/Game.h | 2 -- Stars45/Mfd.cpp | 4 ++-- Stars45/QuitView.cpp | 4 ++-- Stars45/Ship.cpp | 2 +- Stars45/Sky.cpp | 2 +- Stars45/StarServer.cpp | 2 +- Stars45/Starshatter.cpp | 44 +++++++++++++++++++++----------------------- 9 files changed, 29 insertions(+), 43 deletions(-) (limited to 'Stars45') diff --git a/Stars45/DebriefDlg.cpp b/Stars45/DebriefDlg.cpp index 7765ca1..bc1ec23 100644 --- a/Stars45/DebriefDlg.cpp +++ b/Stars45/DebriefDlg.cpp @@ -98,7 +98,7 @@ void DebriefDlg::Show() { FormWindow::Show(); - Game::GetInstance()->SetTimeCompression(1); + Game::GetInstance()->GetClock()->SetTimeCompression(1.0); mission = 0; campaign = Campaign::GetCampaign(); diff --git a/Stars45/Game.cpp b/Stars45/Game.cpp index 5dfd828..e2364de 100644 --- a/Stars45/Game.cpp +++ b/Stars45/Game.cpp @@ -1226,16 +1226,6 @@ Game::GetClock() return &clock; } -DWORD Game::TimeCompression() -{ - return clock.TimeCompression(); -} - -void Game::SetTimeCompression(DWORD comp) -{ - if (comp > 0 && comp <= 100) - clock.SetTimeCompression(static_cast(comp)); -} DWORD Game::Frame() { diff --git a/Stars45/Game.h b/Stars45/Game.h index 7ecb198..e51ae02 100644 --- a/Stars45/Game.h +++ b/Stars45/Game.h @@ -77,8 +77,6 @@ public: void SetMaxTexSize(int n); Clock* GetClock(); - DWORD TimeCompression(); - void SetTimeCompression(DWORD comp); DWORD Frame(); double FrameRate(); diff --git a/Stars45/Mfd.cpp b/Stars45/Mfd.cpp index 37aece0..58a5a4d 100644 --- a/Stars45/Mfd.cpp +++ b/Stars45/Mfd.cpp @@ -1118,8 +1118,8 @@ MFD::DrawGameMFD() seconds = (clock / 1000) % 60; } - if (Game::GetInstance()->TimeCompression() > 1) - sprintf_s(txt, "%02d:%02d:%02d x%d", hours, minutes, seconds, Game::GetInstance()->TimeCompression()); //-V576 + if (static_cast(Game::GetInstance()->GetClock()->TimeCompression()) != 1) + sprintf_s(txt, "%02d:%02d:%02d x%.1f", hours, minutes, seconds, Game::GetInstance()->GetClock()->TimeCompression()); //-V576 else sprintf_s(txt, "%02d:%02d:%02d", hours, minutes, seconds); diff --git a/Stars45/QuitView.cpp b/Stars45/QuitView.cpp index 7cf6fe4..bc0b348 100644 --- a/Stars45/QuitView.cpp +++ b/Stars45/QuitView.cpp @@ -163,7 +163,7 @@ QuitView::ExecFrame() // exit and accept: if (action == 1) { CloseMenu(); - Game::GetInstance()->SetTimeCompression(1); + Game::GetInstance()->GetClock()->SetTimeCompression(1.0); Starshatter* stars = Starshatter::GetInstance(); stars->SetGameMode(Starshatter::PLAN_MODE); @@ -172,7 +172,7 @@ QuitView::ExecFrame() // quit and discard results: else if (action == 2) { CloseMenu(); - Game::GetInstance()->SetTimeCompression(1); + Game::GetInstance()->GetClock()->SetTimeCompression(1.0); Starshatter* stars = Starshatter::GetInstance(); Campaign* campaign = Campaign::GetCampaign(); diff --git a/Stars45/Ship.cpp b/Stars45/Ship.cpp index 3ac957e..12b9b7c 100644 --- a/Stars45/Ship.cpp +++ b/Stars45/Ship.cpp @@ -3585,7 +3585,7 @@ Ship::TimeSkip() { if (CanTimeSkip()) { // go back to regular time before performing the skip: - Game::GetInstance()->SetTimeCompression(1); + Game::GetInstance()->GetClock()->SetTimeCompression(1.0); transition_time = 7.5f; transition_type = TRANSITION_TIME_SKIP; diff --git a/Stars45/Sky.cpp b/Stars45/Sky.cpp index eb22cc3..8f475f6 100644 --- a/Stars45/Sky.cpp +++ b/Stars45/Sky.cpp @@ -132,7 +132,7 @@ Dust::Reset(const Point& ref) void Dust::ExecFrame(double factor, const Point& ref) { - if (Game::GetInstance()->TimeCompression() > 4) { + if (Game::GetInstance()->GetClock()->TimeCompression() > 4.0) { Hide(); return; } diff --git a/Stars45/StarServer.cpp b/Stars45/StarServer.cpp index 25d4dd9..418d607 100644 --- a/Stars45/StarServer.cpp +++ b/Stars45/StarServer.cpp @@ -220,7 +220,7 @@ StarServer::SetGameMode(int m) // stand alone server should wait for players to connect // before unpausing the simulation... - SetTimeCompression(1); + clock.SetTimeCompression(1.0); Pause(true); } diff --git a/Stars45/Starshatter.cpp b/Stars45/Starshatter.cpp index 6c48e32..19cbb64 100644 --- a/Stars45/Starshatter.cpp +++ b/Stars45/Starshatter.cpp @@ -638,7 +638,7 @@ Starshatter::SetGameMode(int m) HUDView::ClearMessages(); RadioView::ClearMessages(); - SetTimeCompression(1); + clock.SetTimeCompression(1.0); Pause(false); Print(" Stardate: %.1f\n", StarSystem::GetBaseTime()); @@ -1254,22 +1254,18 @@ Starshatter::DoCmpnScreenFrame() else if (KeyDown(KEY_TIME_COMPRESS)) { time_til_change = 1; - - switch (TimeCompression()) { - case 1: SetTimeCompression(2); break; - case 2: SetTimeCompression(4); break; - case 4: SetTimeCompression(8); break; - } + double compression = clock.TimeCompression() * 2; + if (compression > 8.0) + compression = 8.0; + clock.SetTimeCompression(compression); } else if (KeyDown(KEY_TIME_EXPAND)) { time_til_change = 1; - - switch (TimeCompression()) { - case 8: SetTimeCompression( 4); break; - case 4: SetTimeCompression( 2); break; - default: SetTimeCompression( 1); break; - } + double compression = clock.TimeCompression() / 2; + if (compression < 0.5) + compression = 0.5; + clock.SetTimeCompression(compression); } } } @@ -1658,11 +1654,12 @@ Starshatter::DoGameKeys() else if (KeyDown(KEY_TIME_COMPRESS)) { time_til_change = 0.5; if (NetGame::IsNetGame()) - SetTimeCompression(1); - else - switch (TimeCompression()) { - case 1: SetTimeCompression(2); break; - default: SetTimeCompression(4); break; + clock.SetTimeCompression(1.0); + else { + double compression = clock.TimeCompression() * 2; + if (compression > 4.0) + compression = 4.0; + clock.SetTimeCompression(compression); } } @@ -1670,11 +1667,12 @@ Starshatter::DoGameKeys() time_til_change = 0.5; if (NetGame::IsNetGame()) - SetTimeCompression(1); - else - switch (TimeCompression()) { - case 4: SetTimeCompression( 2); break; - default: SetTimeCompression( 1); break; + clock.SetTimeCompression(1.0); + else { + double compression = clock.TimeCompression() / 2; + if (compression < 0.5) + compression = 0.5; + clock.SetTimeCompression(compression); } } -- cgit v1.1