aboutsummaryrefslogtreecommitdiff
path: root/src/openvic/GameAdvancementHook.cpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-05-22 17:54:15 +0200
committer GitHub <noreply@github.com>2023-05-22 17:54:15 +0200
commit08ec6fe5fbf52d814d88c235aac84bb95ad4e322 (patch)
tree136a221eb5e7c895c8219778b3d206f2ed9e8e7f /src/openvic/GameAdvancementHook.cpp
parent15e960f93ced8c94a6a45ebb2b44d0705ff7f8f6 (diff)
parent7874702f30d5855319faf197b10aed31f07f5e27 (diff)
Merge pull request #5 from OpenVicProject/bmp
BMP palette parser + code style cleanup
Diffstat (limited to 'src/openvic/GameAdvancementHook.cpp')
-rw-r--r--src/openvic/GameAdvancementHook.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/openvic/GameAdvancementHook.cpp b/src/openvic/GameAdvancementHook.cpp
index 0fcdd03..ac16158 100644
--- a/src/openvic/GameAdvancementHook.cpp
+++ b/src/openvic/GameAdvancementHook.cpp
@@ -3,15 +3,19 @@
using namespace OpenVic;
const std::vector<std::chrono::milliseconds> GameAdvancementHook::GAME_SPEEDS = {
- std::chrono::milliseconds{ 4000 },
- std::chrono::milliseconds{ 3000 },
- std::chrono::milliseconds{ 2000 },
- std::chrono::milliseconds{ 1000 },
- std::chrono::milliseconds{ 100 },
- std::chrono::milliseconds{ 1 } };
+ std::chrono::milliseconds { 4000 },
+ std::chrono::milliseconds { 3000 },
+ std::chrono::milliseconds { 2000 },
+ std::chrono::milliseconds { 1000 },
+ std::chrono::milliseconds { 100 },
+ std::chrono::milliseconds { 1 }
+};
-GameAdvancementHook::GameAdvancementHook(AdvancementFunction tickFunction, RefreshFunction updateFunction, bool startPaused, speed_t startingSpeed)
- : triggerFunction{ tickFunction }, refreshFunction{ updateFunction }, isPaused{ startPaused } {
+GameAdvancementHook::GameAdvancementHook(AdvancementFunction tickFunction,
+ RefreshFunction updateFunction, bool startPaused, speed_t startingSpeed)
+ : triggerFunction { tickFunction },
+ refreshFunction { updateFunction },
+ isPaused { startPaused } {
lastPolledTime = std::chrono::high_resolution_clock::now();
setSimulationSpeed(startingSpeed);
}
@@ -57,7 +61,7 @@ GameAdvancementHook& GameAdvancementHook::operator--() {
void GameAdvancementHook::conditionallyAdvanceGame() {
if (!isPaused) {
- std::chrono::time_point<std::chrono::high_resolution_clock> currentTime = std::chrono::high_resolution_clock::now();
+ time_point_t currentTime = std::chrono::high_resolution_clock::now();
if (std::chrono::duration_cast<std::chrono::milliseconds>(currentTime - lastPolledTime) >= GAME_SPEEDS[currentSpeed]) {
lastPolledTime = currentTime;
if (triggerFunction) triggerFunction();