Tier0: move GetUnixTimeStamp() to utility code

This commit is contained in:
Kawe Mazidjatari 2024-04-03 02:06:10 +02:00
parent d1498240eb
commit 1e8dd63e4c
3 changed files with 11 additions and 8 deletions

View File

@ -332,14 +332,6 @@ static bool LiveAPI_CheckSwitchType(HSQUIRRELVM const v, const SQObjectPtr& obj)
#define LIVEAPI_UNSUPPORTED_TYPE_ERROR(v, gotType, eventMsg) {v_SQVM_RaiseError(v, "Value type \"%s\" is not supported for message \"%s\".\n", IdType2Name(gotType), eventMsg->GetTypeName().c_str()); return false; }
#define LIVEAPI_CHECK_RECURSION_DEPTH(v, currDepth) { if (currDepth > LIVEAPI_MAX_ITEM_DEPTH) { v_SQVM_RaiseError(v, "Exceeded nesting depth limit of \"%i\".", LIVEAPI_MAX_ITEM_DEPTH); return false; }}
uint64_t GetUnixTimeStamp() // TODO: move elsewhere
{
__time64_t time;
_time64(&time);
return time;
}
/*

View File

@ -122,6 +122,7 @@ int CompareIPv6(const IN6_ADDR& ipA, const IN6_ADDR& ipB);
/////////////////////////////////////////////////////////////////////////////
// Time
uint64_t GetUnixTimeStamp();
std::chrono::nanoseconds IntervalToDuration(const float flInterval);
/////////////////////////////////////////////////////////////////////////////

View File

@ -1148,6 +1148,16 @@ int CompareIPv6(const IN6_ADDR& ipA, const IN6_ADDR& ipB)
return 0;
}
///////////////////////////////////////////////////////////////////////////////
// For obtaining the current timestamp.
uint64_t GetUnixTimeStamp()
{
__time64_t time;
_time64(&time);
return time;
}
///////////////////////////////////////////////////////////////////////////////
// For obtaining a duration from a certain interval.
std::chrono::nanoseconds IntervalToDuration(const float flInterval)