2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-02-27 05:51:10 +03:00

Added cvar syserror_logfile

Changed in some places rehlds_syserror on Sys_Error for log.
This commit is contained in:
s1lentq 2016-11-08 22:51:56 +07:00
parent 212e9638d6
commit 381a4c0ab2
18 changed files with 81 additions and 42 deletions

View File

@ -33,6 +33,7 @@ Archive's bin directory contains 2 subdirectories, 'bugfixed' and 'pure'
Bugfixed version of rehlds contains an additional cvars:
<ul>
<li>listipcfgfile <filename> // File for permanent ip bans. Default: listip.cfg
<li>syserror_logfile <filename> // File for the system error log. Default: rehlds_error.log
<li>sv_auto_precache_sounds_in_models <1|0> // Automatically precache sounds attached to models. Deault: 0
<li>sv_delayed_spray_upload <1|0> // Upload custom sprays after entering the game instead of when connecting. It increases upload speed. Default: 0
<li>sv_echo_unknown_cmd <1|0> // Echo in the console when trying execute an uncknown command. Default: 0

View File

@ -810,9 +810,11 @@ uint32 MSG_ReadBits(int numbits)
{
uint32 result;
#ifdef REHLDS_FIXES
if (numbits > 32) {
rehlds_syserror("%s: invalid numbits %d\n", __FUNCTION__, numbits);
Sys_Error(__FUNCTION__ ": invalid numbits %d\n", numbits);
}
#endif // REHLDS_FIXES
if (msg_badread)
{
@ -2122,12 +2124,17 @@ unsigned char* EXT_FUNC COM_LoadFile(const char *path, int usehunk, int *pLength
break;
default:
#ifdef REHLDS_FIXES
FS_Close(hFile);
#endif
Sys_Error(__FUNCTION__ ": bad usehunk");
}
if (!buf)
{
#ifdef REHLDS_FIXES
FS_Close(hFile);
#endif
Sys_Error(__FUNCTION__ ": not enough space for %s", path);
}
@ -2197,7 +2204,12 @@ NOXREF unsigned char *COM_LoadFileLimit(char *path, int pos, int cbmax, int *pcb
len = FS_Size(hFile);
if (len < pos)
Sys_Error("COM_LoadFileLimit: invalid seek position for %s", path);
{
#ifdef REHLDS_FIXES
FS_Close(hFile);
#endif
Sys_Error(__FUNCTION__ ": invalid seek position for %s", path);
}
FS_Seek(hFile, pos, FILESYSTEM_SEEK_HEAD);
@ -2215,7 +2227,12 @@ NOXREF unsigned char *COM_LoadFileLimit(char *path, int pos, int cbmax, int *pcb
if (!buf)
{
if (path)
Sys_Error("COM_LoadFileLimit: not enough space for %s", path);
{
#ifdef REHLDS_FIXES
FS_Close(hFile);
#endif
Sys_Error(__FUNCTION__ ": not enough space for %s", path);
}
FS_Close(hFile);
return NULL;

View File

@ -78,8 +78,13 @@ void Draw_CacheWadInitFromFile(FileHandle_t hFile, int len, char *name, int cach
FS_Read(&header, sizeof(wadinfo_t), 1, hFile);
if (*(uint32 *)header.identification != MAKEID('W', 'A', 'D', '3'))
{
#ifdef REHLDS_FIXES
FS_Close(hFile);
#endif
Sys_Error("Wad file %s doesn't have WAD3 id\n", name);
}
wad->lumps = (lumpinfo_s *)Mem_Malloc(len - header.infotableofs);
FS_Seek(hFile, header.infotableofs, FILESYSTEM_SEEK_HEAD);

View File

@ -30,7 +30,7 @@ unsigned int DELTAJIT_GetFieldSize(delta_description_t* desc) {
return 0;
default:
rehlds_syserror("%s: Unknown delta field type %d", __FUNCTION__, desc->fieldType);
Sys_Error(__FUNCTION__ ": Unknown delta field type %d", desc->fieldType);
return 0;
}
}
@ -54,15 +54,13 @@ void DELTAJIT_CreateDescription(delta_t* delta, deltajitdata_t &jitdesc) {
numMemBlocks++;
}
//sanity checks & pre-clean
// sanity checks & pre-clean
if (numMemBlocks > DELTAJIT_MAX_BLOCKS) {
rehlds_syserror("%s: numMemBlocks > DELTAJIT_MAX_BLOCKS (%d > %d)", __FUNCTION__, numMemBlocks, DELTAJIT_MAX_BLOCKS);
return;
Sys_Error(__FUNCTION__ ": numMemBlocks > DELTAJIT_MAX_BLOCKS (%d > %d)", numMemBlocks, DELTAJIT_MAX_BLOCKS);
}
if (delta->fieldCount > DELTAJIT_MAX_FIELDS) {
rehlds_syserror("%s: fieldCount > DELTAJIT_MAX_FIELDS (%d > %d)", __FUNCTION__, delta->fieldCount, DELTAJIT_MAX_FIELDS);
return;
Sys_Error(__FUNCTION__ ": fieldCount > DELTAJIT_MAX_FIELDS (%d > %d)", delta->fieldCount, DELTAJIT_MAX_FIELDS);
}
Q_memset(&jitdesc, 0, sizeof(jitdesc));
@ -678,8 +676,7 @@ CDeltaJit* DELTAJit_LookupDeltaJit(const char* callsite, delta_t *pFields) {
#ifndef REHLDS_FIXES
// only for testing
if (!deltaJit) {
rehlds_syserror("%s: JITted delta encoder not found for delta %p", callsite, pFields);
return NULL;
Sys_Error("%s: JITted delta encoder not found for delta %p", callsite, pFields);
}
#endif // REHLDS_FIXES

View File

@ -105,7 +105,7 @@ NOXREF void Host_EndGame(const char *message, ...)
Q_vsnprintf(string, sizeof(string), message, argptr);
va_end(argptr);
Con_DPrintf("Host_EndGame: %s\n", string);
Con_DPrintf(__FUNCTION__ ": %s\n", string);
oldn = g_pcls.demonum;
@ -116,7 +116,7 @@ NOXREF void Host_EndGame(const char *message, ...)
if (!g_pcls.state)
{
Sys_Error("Host_EndGame: %s\n", string);
Sys_Error(__FUNCTION__ ": %s\n", string);
}
if (oldn != -1)
@ -143,7 +143,7 @@ void __declspec(noreturn) Host_Error(const char *error, ...)
va_start(argptr, error);
if (inerror)
Sys_Error("Host_Error: recursively entered");
Sys_Error(__FUNCTION__ ": recursively entered");
inerror = TRUE;
SCR_EndLoadingPlaque();
@ -153,7 +153,7 @@ void __declspec(noreturn) Host_Error(const char *error, ...)
if (g_psv.active && developer.value != 0.0 )
CL_WriteMessageHistory(0, 0);
Con_Printf("Host_Error: %s\n", string);
Con_Printf(__FUNCTION__ ": %s\n", string);
if (g_psv.active)
Host_ShutdownServer(FALSE);
@ -164,7 +164,7 @@ void __declspec(noreturn) Host_Error(const char *error, ...)
inerror = FALSE;
longjmp(host_abortserver, 1);
}
Sys_Error("Host_Error: %s\n", string);
Sys_Error(__FUNCTION__ ": %s\n", string);
}
/* <35d12> ../engine/host.c:297 */

View File

@ -1370,7 +1370,8 @@ qboolean SaveGameSlot(const char *pSaveName, const char *pSaveComment)
Host_SaveAgeList(pSaveName, 1);
pFile = FS_OpenPathID(name, "wb", "GAMECONFIG");
tag = MAKEID('J','S','A','V');
tag = SAVEGAME_HEADER;
FS_Write(&tag, sizeof(int), 1, pFile);
tag = SAVEGAME_VERSION;
FS_Write(&tag, sizeof(int), 1, pFile);
@ -1451,7 +1452,7 @@ int SaveReadHeader(FileHandle_t pFile, GAME_HEADER *pHeader, int readGlobalState
SAVERESTOREDATA *pSaveData;
FS_Read(&tag, sizeof(int), 1, pFile);
if (tag != MAKEID('J','S','A','V'))
if (tag != SAVEGAME_HEADER)
{
FS_Close(pFile);
return 0;

View File

@ -1502,7 +1502,6 @@ void NET_SendPacket(netsrc_t sock, int length, void *data, const netadr_t& to)
else
{
Sys_Error(__FUNCTION__ ": bad address type");
return;
}
NetadrToSockadr(&to, &addr);

View File

@ -475,6 +475,7 @@ extern cvar_t logsdir;
extern cvar_t bannedcfgfile;
#ifdef REHLDS_FIXES
extern cvar_t listipcfgfile;
extern cvar_t syserror_logfile;
#endif
extern decalname_t sv_decalnames[MAX_BASE_DECALS];

View File

@ -304,6 +304,7 @@ cvar_t sv_auto_precache_sounds_in_models = { "sv_auto_precache_sounds_in_models"
cvar_t sv_delayed_spray_upload = { "sv_delayed_spray_upload", "0", 0, 0.0f, nullptr };
cvar_t sv_rehlds_force_dlmax = { "sv_rehlds_force_dlmax", "0", 0, 0.0f, nullptr };
cvar_t listipcfgfile = { "listipcfgfile", "listip.cfg", 0, 0.0f, nullptr };
cvar_t syserror_logfile = { "syserror_logfile", "rehlds_error.log", 0, 0.0f, nullptr };
cvar_t sv_rehlds_hull_centering = { "sv_rehlds_hull_centering", "0", 0, 0.0f, nullptr };
cvar_t sv_rcon_condebug = { "sv_rcon_condebug", "1", 0, 1.0f, nullptr };
cvar_t sv_rehlds_userinfo_transmitted_fields = { "sv_rehlds_userinfo_transmitted_fields", "", 0, 0.0f, nullptr };
@ -1854,7 +1855,6 @@ int EXT_FUNC SV_CheckProtocol_internal(netadr_t *adr, int nProtocol)
if (adr == NULL)
{
Sys_Error(__FUNCTION__ ": Null address\n");
return FALSE;
}
if (nProtocol == PROTOCOL_VERSION)
@ -7824,6 +7824,7 @@ void SV_Init(void)
Cvar_RegisterVariable(&bannedcfgfile);
#ifdef REHLDS_FIXES
Cvar_RegisterVariable(&listipcfgfile);
Cvar_RegisterVariable(&syserror_logfile);
#endif
Cvar_RegisterVariable(&sv_rcon_minfailures);
Cvar_RegisterVariable(&sv_rcon_maxfailures);

View File

@ -34,7 +34,6 @@ int(*Launcher_MP3subsys_Suspend_Audio)(void);
void(*Launcher_MP3subsys_Resume_Audio)(void);
void(*VID_FlipScreen)(void);
//double curtime;
//double lastcurtime;
//qboolean sc_return_on_enter;
@ -65,7 +64,6 @@ extensiondll_t g_rgextdll[50];
int g_iextdllMac;
modinfo_t gmodinfo;
qboolean gfBackground;
//extern jmp_buf host_abortserver;
//int starttime;
//qboolean Win32AtLeastV4;
//int lowshift;
@ -92,8 +90,6 @@ double g_PerfCounterSlice;
double g_CurrentTime;
double g_StartTime;
int g_WinNTOrHigher;
#endif // _WIN32
@ -474,6 +470,26 @@ void __declspec(noreturn) Sys_Error(const char *error, ...)
Log_Printf("FATAL ERROR (shutting down): %s\n", text);
#ifdef REHLDS_FIXES
if (syserror_logfile.string[0] != '\0')
{
auto pFile = FS_Open(syserror_logfile.string, "a");
if (pFile)
{
tm *today;
time_t ltime;
char szDate[32];
time(&ltime);
today = localtime(&ltime);
strftime(szDate, ARRAYSIZE(szDate) - 1, "L %d/%m/%Y - %H:%M:%S:", today);
FS_FPrintf(pFile, "%s (map \"%s\") %s\n", szDate, &pr_strings[gGlobalVariables.mapname], text);
FS_Close(pFile);
}
}
#endif // REHLDS_FIXES
if (g_bIsDedicatedServer)
{
if (Launcher_ConsolePrintf)

View File

@ -189,6 +189,4 @@
#define EXT_FUNC FORCE_STACK_ALIGN
extern void __declspec(noreturn) rehlds_syserror(const char* fmt, ...);
#endif // _OSCONFIG_H

View File

@ -44,7 +44,7 @@ private:
// this was a root node
unsigned int rootId = GetRoodNodeId(node->key);
if (m_RootNodes[rootId] != node) {
util_syserror("%s: invlid root node", __FUNCTION__);
Sys_Error(__FUNCTION__ ": invalid root node");
return;
}

View File

@ -12,6 +12,7 @@
#endif
#define SAVEFILE_HEADER MAKEID('V','A','L','V') // little-endian "VALV"
#define SAVEGAME_VERSION 0x0071 // Version 0.71
#define SAVEGAME_HEADER MAKEID('J','S','A','V') // little-endian "JSAV"
#define SAVEGAME_VERSION 0x0071 // Version 0.71
#endif // SAVEGAME_VERSION_H

View File

@ -22,7 +22,7 @@ CRehldsFlightRecorder::CRehldsFlightRecorder() {
m_DataRegion = (uint8*) sys_allocmem(DATA_REGION_SIZE);
if (!m_MetaRegion || !m_DataRegion) {
rehlds_syserror("%s: direct allocation failed", __FUNCTION__);
Sys_Error(__FUNCTION__ ": direct allocation failed");
}
//initialize meta region header
@ -36,7 +36,7 @@ CRehldsFlightRecorder::CRehldsFlightRecorder() {
metaPos += sizeof(recorder_state);
if ((metaPos - (char*)m_MetaRegion) > META_REGION_HEADER) {
rehlds_syserror("%s: Meta header overflow", __FUNCTION__);
Sys_Error(__FUNCTION__ ": Meta header overflow");
}
//initialize data region header
@ -48,7 +48,7 @@ CRehldsFlightRecorder::CRehldsFlightRecorder() {
dataPos += sizeof(data_header);
if ((dataPos - (char*)m_pDataHeader) > DATA_REGION_HEADER) {
rehlds_syserror("%s: Data header overflow", __FUNCTION__);
Sys_Error(__FUNCTION__ ": Data header overflow");
}
InitHeadersContent();
@ -93,7 +93,7 @@ void CRehldsFlightRecorder::MoveToStart() {
void CRehldsFlightRecorder::StartMessage(uint16 msg, bool entrance) {
if (msg == 0 || msg > m_pMetaHeader->numMessages) {
rehlds_syserror("%s: Invalid message id %u", __FUNCTION__, msg);
Sys_Error(__FUNCTION__ ": Invalid message id %u", msg);
}
if (entrance) {
@ -101,7 +101,7 @@ void CRehldsFlightRecorder::StartMessage(uint16 msg, bool entrance) {
}
if (m_pRecorderState->curMessage != 0) {
rehlds_syserror("%s: overlapping messages", __FUNCTION__);
Sys_Error(__FUNCTION__ ": overlapping messages");
}
unsigned int sz = DATA_REGION_MAIN_SIZE - m_pRecorderState->wpos;
@ -121,7 +121,7 @@ void CRehldsFlightRecorder::EndMessage(uint16 msg, bool entrance) {
}
if (m_pRecorderState->curMessage != msg) {
rehlds_syserror("%s: invalid message %u", __FUNCTION__, msg);
Sys_Error(__FUNCTION__ ": invalid message %u", msg);
}
unsigned int freeSz = DATA_REGION_MAIN_SIZE - m_pRecorderState->wpos;
@ -131,7 +131,7 @@ void CRehldsFlightRecorder::EndMessage(uint16 msg, bool entrance) {
unsigned int msgSize = m_pRecorderState->wpos - m_pRecorderState->lastMsgBeginPos;
if (msgSize > MSG_MAX_SIZE) {
rehlds_syserror("%s: too big message %u; size%u", __FUNCTION__, msg, msgSize);
Sys_Error(__FUNCTION__ ": too big message %u; size %u", msg, msgSize);
}
*(uint16*)(m_DataRegionPtr + m_pRecorderState->wpos) = msgSize;
m_pRecorderState->wpos += 2;
@ -142,13 +142,13 @@ void CRehldsFlightRecorder::EndMessage(uint16 msg, bool entrance) {
void CRehldsFlightRecorder::CheckSize(unsigned int wantToWriteLen) {
unsigned int msgSize = m_pRecorderState->wpos - m_pRecorderState->lastMsgBeginPos;
if (msgSize + wantToWriteLen > MSG_MAX_SIZE) {
rehlds_syserror("%s: too big message %u; size%u", __FUNCTION__, m_pRecorderState->curMessage, msgSize);
Sys_Error(__FUNCTION__ ": too big message %u; size %u", m_pRecorderState->curMessage, msgSize);
}
}
void CRehldsFlightRecorder::WriteBuffer(const void* data, unsigned int len) {
if (m_pRecorderState->curMessage == 0) {
rehlds_syserror("%s: Could not write, invalid state", __FUNCTION__);
Sys_Error(__FUNCTION__ ": Could not write, invalid state");
}
CheckSize(len);
@ -207,7 +207,7 @@ void CRehldsFlightRecorder::WriteDouble(double v) {
uint16 CRehldsFlightRecorder::RegisterMessage(const char* module, const char *message, unsigned int version, bool inOut) {
if (m_pMetaHeader->numMessages >= MSG_MAX_ID) {
rehlds_syserror("%s: can't register message; limit exceeded", __FUNCTION__);
Sys_Error(__FUNCTION__ ": can't register message; limit exceeded");
}
uint16 msgId = ++m_pMetaHeader->numMessages;

View File

@ -79,7 +79,7 @@ private:
template<typename T>
void WritePrimitive(T v) {
if (m_pRecorderState->curMessage == 0) {
rehlds_syserror("%s: Could not write, invalid state", __FUNCTION__);
Sys_Error(__FUNCTION__ ": Could not write, invalid state");
}
CheckSize(sizeof(T));

View File

@ -40,7 +40,7 @@ public:
IHookChainImpl(void** hooks, origfunc_t orig) : m_Hooks(hooks), m_OriginalFunc(orig)
{
if (orig == NULL)
rehlds_syserror("Non-void HookChain without original function.");
Sys_Error(__FUNCTION__ ": Non-void HookChain without original function.");
}
virtual ~IHookChainImpl() {}

View File

@ -121,3 +121,5 @@ public:
static IReHLDSPlatform* get();
static void set(IReHLDSPlatform* p);
};
extern void __declspec(noreturn) rehlds_syserror(const char* fmt, ...);

View File

@ -285,7 +285,7 @@ IGameClient* GetRehldsApiClient(client_t* cl)
int idx = cl - g_psvs.clients;
if (idx < 0 || idx >= g_psvs.maxclients)
{
rehlds_syserror(__FUNCTION__": Invalid client index %d", idx);
Sys_Error(__FUNCTION__": Invalid client index %d", idx);
}
return g_GameClients[idx];