2022-02-19 02:31:16 +01:00
|
|
|
//=====================================================================================//
|
|
|
|
//
|
|
|
|
// Purpose:
|
|
|
|
//
|
|
|
|
//=====================================================================================//
|
|
|
|
|
|
|
|
#include <core/stdafx.h>
|
2023-02-15 20:50:12 +01:00
|
|
|
#include <tier1/strtools.h>
|
2023-10-22 17:00:56 +02:00
|
|
|
#include <localize/localize.h>
|
2022-02-19 02:31:16 +01:00
|
|
|
#include <engine/common.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============================
|
2023-04-02 17:02:04 +02:00
|
|
|
COM_FormatSeconds
|
2022-02-19 02:31:16 +01:00
|
|
|
|
|
|
|
==============================
|
|
|
|
*/
|
2023-02-15 20:50:12 +01:00
|
|
|
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;
|
2023-10-22 17:00:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============================
|
|
|
|
COM_ExplainDisconnection
|
|
|
|
|
|
|
|
==============================
|
|
|
|
*/
|
|
|
|
void COM_ExplainDisconnection(bool bPrint, const char* fmt, ...)
|
|
|
|
{
|
|
|
|
char szBuf[1024];
|
|
|
|
{/////////////////////////////
|
|
|
|
va_list vArgs;
|
|
|
|
va_start(vArgs, fmt);
|
|
|
|
|
|
|
|
vsnprintf(szBuf, sizeof(szBuf), fmt, vArgs);
|
|
|
|
|
|
|
|
szBuf[sizeof(szBuf) - 1] = '\0';
|
|
|
|
va_end(vArgs);
|
|
|
|
}/////////////////////////////
|
|
|
|
|
|
|
|
if (bPrint)
|
|
|
|
{
|
|
|
|
if (szBuf[0] == '#')
|
|
|
|
{
|
|
|
|
wchar_t formatStr[1024];
|
|
|
|
const wchar_t* wpchReason = (*g_ppVGuiLocalize) ? (*g_ppVGuiLocalize)->Find(szBuf) : nullptr;
|
|
|
|
if (wpchReason)
|
|
|
|
{
|
|
|
|
wcsncpy(formatStr, wpchReason, sizeof(formatStr) / sizeof(wchar_t));
|
|
|
|
|
|
|
|
char conStr[256];
|
|
|
|
(*g_ppVGuiLocalize)->ConvertUnicodeToANSI(formatStr, conStr, sizeof(conStr));
|
2024-02-21 01:18:43 +01:00
|
|
|
Error(eDLL_T::CLIENT, NO_ERROR, "%s\n", conStr);
|
2023-10-22 17:00:56 +02:00
|
|
|
}
|
|
|
|
else
|
2024-02-21 01:18:43 +01:00
|
|
|
Error(eDLL_T::CLIENT, NO_ERROR, "%s\n", szBuf);
|
2023-10-22 17:00:56 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-02-21 01:18:43 +01:00
|
|
|
Error(eDLL_T::CLIENT, NO_ERROR, "%s\n", szBuf);
|
2023-10-22 17:00:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
v_COM_ExplainDisconnection(bPrint, szBuf);
|
|
|
|
}
|
|
|
|
|
2023-11-26 13:21:20 +01:00
|
|
|
void VCommon::Detour(const bool bAttach) const
|
2023-10-22 17:00:56 +02:00
|
|
|
{
|
2023-11-26 13:21:20 +01:00
|
|
|
DetourSetup(&v_COM_ExplainDisconnection, COM_ExplainDisconnection, bAttach);
|
2023-10-22 17:00:56 +02:00
|
|
|
}
|