Implement 'COM_FormatSeconds'

This commit is contained in:
Kawe Mazidjatari 2023-02-15 20:50:12 +01:00
parent 06698bea33
commit eaf1e3632e
2 changed files with 32 additions and 0 deletions

View File

@ -5,6 +5,7 @@
//=====================================================================================//
#include <core/stdafx.h>
#include <tier1/strtools.h>
#include <engine/common.h>
/*
@ -18,3 +19,33 @@ void* HCOM_ExplainDisconnection(void* unused, const char* fmt, ...)
// !TODO: rebuild.
return nullptr;
}
const char* COM_FormatSeconds(int seconds)
{
static char string[64];
int hours = 0;
int minutes = seconds / 60;
if (minutes > 0)
{
seconds -= (minutes * 60);
hours = minutes / 60;
if (hours > 0)
{
minutes -= (hours * 60);
}
}
if (hours > 0)
{
Q_snprintf(string, sizeof(string), "%2i:%02i:%02i", hours, minutes, seconds);
}
else
{
Q_snprintf(string, sizeof(string), "%02i:%02i", minutes, seconds);
}
return string;
}

View File

@ -7,6 +7,7 @@ inline auto COM_InitFilesystem = p_COM_InitFilesystem.RCast<void* (*)(const char
inline CMemory p_COM_ExplainDisconnection;
inline auto COM_ExplainDisconnection = p_COM_ExplainDisconnection.RCast<void* (*)(uint64_t level, const char* fmt, ...)>();
const char* COM_FormatSeconds(int seconds);
///////////////////////////////////////////////////////////////////////////////
class VCommon : public IDetour
{