From bd8019da9f01308ef57f957b8614e127bed137f8 Mon Sep 17 00:00:00 2001 From: In-line Date: Mon, 20 Feb 2017 19:08:07 +0400 Subject: [PATCH] Add MAX_CVARLIST_FILES define --- rehlds/engine/cvar.cpp | 8 ++++++++ rehlds/engine/cvar.h | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/rehlds/engine/cvar.cpp b/rehlds/engine/cvar.cpp index d72ccc2..1275532 100644 --- a/rehlds/engine/cvar.cpp +++ b/rehlds/engine/cvar.cpp @@ -586,7 +586,11 @@ void Cmd_CvarList_f(void) { // Open log int i; +#ifdef REHLDS_FIXES + for (i = 0; i < MAX_CVARLIST_FILES; i++) +#else for (i = 0; i < 100; i++) +#endif { Q_snprintf(szTemp, ARRAYSIZE(szTemp) - 1, "cvarlist%02d.txt", i); szTemp[ARRAYSIZE(szTemp) - 1] = 0; @@ -599,7 +603,11 @@ void Cmd_CvarList_f(void) FS_Close(fp); } +#ifdef REHLDS_FIXES + if (i == MAX_CVARLIST_FILES) +#else if (i >= 100) +#endif { Con_Printf("Can't cvarlist! Too many existing cvarlist output files in the gamedir!\n"); return; diff --git a/rehlds/engine/cvar.h b/rehlds/engine/cvar.h index e80feea..c7c0268 100644 --- a/rehlds/engine/cvar.h +++ b/rehlds/engine/cvar.h @@ -34,6 +34,15 @@ #define MAX_CVAR_VALUE 1024 +#ifdef REHLDS_FIXES + +#define MAX_CVARLIST_FILES 100 +#if (MAX_CVARLIST_FILES < 0 || MAX_CVARLIST_FILES > 100) // Code in Cmd_CvarList_f handles only value between 0-99 +#error "MAX_CVARLIST_FILES value is out of bound" +#endif + +#endif + #ifdef HOOK_ENGINE #define cvar_vars (*pcvar_vars) #endif // HOOK_ENGINE