forked from mirror/openmw-tes3mp
Merge pull request #516 from TES3MP/0.7.0-alpha
[Server] Add GetMillisecondsSinceServerStart() server function
This commit is contained in:
commit
cb5e24e6c5
2 changed files with 47 additions and 31 deletions
|
@ -11,6 +11,7 @@
|
||||||
#include <Script/Script.hpp>
|
#include <Script/Script.hpp>
|
||||||
|
|
||||||
static std::string tempFilename;
|
static std::string tempFilename;
|
||||||
|
static std::chrono::high_resolution_clock::time_point startupTime = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
void ServerFunctions::LogMessage(unsigned short level, const char *message) noexcept
|
void ServerFunctions::LogMessage(unsigned short level, const char *message) noexcept
|
||||||
{
|
{
|
||||||
|
@ -74,6 +75,13 @@ const char* ServerFunctions::GetDataPath() noexcept
|
||||||
return Script::GetModDir();
|
return Script::GetModDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int ServerFunctions::GetMillisecondsSinceServerStart() noexcept
|
||||||
|
{
|
||||||
|
std::chrono::high_resolution_clock::time_point currentTime = std::chrono::high_resolution_clock::now();
|
||||||
|
std::chrono::milliseconds milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(currentTime - startupTime);
|
||||||
|
return milliseconds.count();
|
||||||
|
}
|
||||||
|
|
||||||
const char *ServerFunctions::GetOperatingSystemType() noexcept
|
const char *ServerFunctions::GetOperatingSystemType() noexcept
|
||||||
{
|
{
|
||||||
return Utils::getOperatingSystemType().c_str();
|
return Utils::getOperatingSystemType().c_str();
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
{"DoesFilePathExist", ServerFunctions::DoesFilePathExist},\
|
{"DoesFilePathExist", ServerFunctions::DoesFilePathExist},\
|
||||||
{"GetCaseInsensitiveFilename", ServerFunctions::GetCaseInsensitiveFilename},\
|
{"GetCaseInsensitiveFilename", ServerFunctions::GetCaseInsensitiveFilename},\
|
||||||
{"GetDataPath", ServerFunctions::GetDataPath},\
|
{"GetDataPath", ServerFunctions::GetDataPath},\
|
||||||
|
{"GetMillisecondsSinceServerStart", ServerFunctions::GetMillisecondsSinceServerStart},\
|
||||||
{"GetOperatingSystemType", ServerFunctions::GetOperatingSystemType},\
|
{"GetOperatingSystemType", ServerFunctions::GetOperatingSystemType},\
|
||||||
{"GetArchitectureType", ServerFunctions::GetArchitectureType},\
|
{"GetArchitectureType", ServerFunctions::GetArchitectureType},\
|
||||||
{"GetServerVersion", ServerFunctions::GetServerVersion},\
|
{"GetServerVersion", ServerFunctions::GetServerVersion},\
|
||||||
|
@ -130,6 +131,13 @@ public:
|
||||||
*/
|
*/
|
||||||
static const char *GetDataPath() noexcept;
|
static const char *GetDataPath() noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Get the milliseconds elapsed since the server was started.
|
||||||
|
*
|
||||||
|
* \return The time since the server's startup in milliseconds.
|
||||||
|
*/
|
||||||
|
static unsigned int GetMillisecondsSinceServerStart() noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Get the type of the operating system used by the server.
|
* \brief Get the type of the operating system used by the server.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue