From f9cb9af07860658ac61c9a6857931109a586c72f Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Wed, 3 Feb 2021 00:24:49 +0100 Subject: [PATCH] add real uptime counter, for use in lua later --- include/Settings.h | 8 +++++++- src/Init/Config.cpp | 1 + src/main.cpp | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/Settings.h b/include/Settings.h index 2844c1b..cc11aa0 100644 --- a/include/Settings.h +++ b/include/Settings.h @@ -6,6 +6,7 @@ /// Created by Anonymous275 on 7/28/2020 /// #pragma once +#include #include extern std::string ServerName; extern std::string ServerDesc; @@ -25,4 +26,9 @@ extern bool Private; extern int MaxCars; extern bool Debug; extern int Port; -extern int PPS; \ No newline at end of file +extern int PPS; + +extern std::chrono::time_point StartTime; +inline std::chrono::seconds GetUptimeInSeconds() { + return std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - StartTime); +} diff --git a/src/Init/Config.cpp b/src/Init/Config.cpp index 9a24622..227055f 100644 --- a/src/Init/Config.cpp +++ b/src/Init/Config.cpp @@ -21,6 +21,7 @@ bool Private; int MaxCars; bool Debug; int Port; +std::chrono::time_point StartTime; void SetValues(const std::string& Line, int Index) { int state = 0; diff --git a/src/main.cpp b/src/main.cpp index 4223810..f39f1f7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,6 @@ #include "CustomAssert.h" +#include "Settings.h" #include "Startup.h" #include #include @@ -36,6 +37,7 @@ int main(int argc, char* argv[]) { std::thread t1(loop); t1.detach(); #endif + StartTime = std::chrono::high_resolution_clock::now(); ConsoleInit(); InitServer(argc, argv); InitConfig();