summaryrefslogtreecommitdiffhomepage
path: root/Stars45
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-03-01 23:27:48 +0100
committerAki <please@ignore.pl>2022-03-01 23:27:48 +0100
commit8f65086736ae28e786bb07672fc43b300464494b (patch)
treeb38c86f781482d1d4105088380563342bf9530b0 /Stars45
parentc376af320ebd9d9e435ef3003dd35136dbd71ae8 (diff)
downloadstarshatter-8f65086736ae28e786bb07672fc43b300464494b.zip
starshatter-8f65086736ae28e786bb07672fc43b300464494b.tar.gz
starshatter-8f65086736ae28e786bb07672fc43b300464494b.tar.bz2
Added stub Clock to replace Game built-in
Diffstat (limited to 'Stars45')
-rw-r--r--Stars45/CMakeLists.txt1
-rw-r--r--Stars45/Clock.cpp26
-rw-r--r--Stars45/Clock.h27
3 files changed, 54 insertions, 0 deletions
diff --git a/Stars45/CMakeLists.txt b/Stars45/CMakeLists.txt
index 0376b00..7247082 100644
--- a/Stars45/CMakeLists.txt
+++ b/Stars45/CMakeLists.txt
@@ -31,6 +31,7 @@ add_executable(
CampaignSaveGame.cpp
CampaignSituationReport.cpp
CarrierAI.cpp
+ Clock.cpp
CmdDlg.cpp
CmdForceDlg.cpp
CmdIntelDlg.cpp
diff --git a/Stars45/Clock.cpp b/Stars45/Clock.cpp
new file mode 100644
index 0000000..6e3ec3f
--- /dev/null
+++ b/Stars45/Clock.cpp
@@ -0,0 +1,26 @@
+/* Starshatter: The Open Source Project
+ Copyright (c) 2021-2022, Starshatter: The Open Source Project Contributors
+ Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors
+ Copyright (c) 1997-2006, Destroyer Studios LLC.
+*/
+
+#include "Clock.h"
+
+#include <chrono>
+
+
+Clock::Clock() :
+ m_point {inner_clock::now()},
+ m_compression {1.0}
+{
+}
+
+
+double
+Clock::Step()
+{
+ const auto next = inner_clock::now();
+ const std::chrono::duration<double> delta = next - m_point;
+ m_point = next;
+ return delta.count() * m_compression;
+}
diff --git a/Stars45/Clock.h b/Stars45/Clock.h
new file mode 100644
index 0000000..e82315a
--- /dev/null
+++ b/Stars45/Clock.h
@@ -0,0 +1,27 @@
+/* Starshatter: The Open Source Project
+ Copyright (c) 2021-2022, Starshatter: The Open Source Project Contributors
+ Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors
+ Copyright (c) 1997-2006, Destroyer Studios LLC.
+*/
+
+#ifndef Clock_h
+#define Clock_h
+
+#include <chrono>
+
+
+class Clock
+{
+public:
+ Clock();
+
+ double Step();
+
+protected:
+ using inner_clock = std::chrono::high_resolution_clock;
+ inner_clock::time_point m_point;
+ double m_compression;
+};
+
+
+#endif // Clock_h