From 0f6961c140b4061ec161afe5976279792f973ef0 Mon Sep 17 00:00:00 2001 From: s1lentq Date: Sat, 27 Feb 2016 21:50:45 +0600 Subject: [PATCH] Fix #179 Bug: Sys_InitMemory are not sets '-heapsize' --- rehlds/engine/info.cpp | 2 +- rehlds/engine/sys_dll2.cpp | 29 +++++++++++++---------------- rehlds/engine/sys_dll2.h | 5 +++-- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/rehlds/engine/info.cpp b/rehlds/engine/info.cpp index 02ff265..d9a9fe9 100644 --- a/rehlds/engine/info.cpp +++ b/rehlds/engine/info.cpp @@ -263,7 +263,7 @@ qboolean Info_IsKeyImportant(const char *key) return true; if (!Q_strcmp(key, "topcolor")) return true; - if (!Q_strcmp(key, "botomcolor")) + if (!Q_strcmp(key, "bottomcolor")) return true; if (!Q_strcmp(key, "cl_updaterate")) return true; diff --git a/rehlds/engine/sys_dll2.cpp b/rehlds/engine/sys_dll2.cpp index 7d75405..1ea1ccc 100644 --- a/rehlds/engine/sys_dll2.cpp +++ b/rehlds/engine/sys_dll2.cpp @@ -346,42 +346,39 @@ NOXREF void Sys_ShutdownArgv(void) void Sys_InitMemory(void) { int i; - //bool bDidDefault;//unsued? i = COM_CheckParm("-heapsize"); - if (i && i < Cmd_Argc() - 1) - host_parms.memsize = Q_atoi(Cmd_Argv(i + 1)) * 1024; + if (i && i < com_argc - 1) + host_parms.memsize = Q_atoi(com_argv[i + 1]) * 1024; -#ifdef _WIN32 - MEMORYSTATUS lpBuffer; if (host_parms.memsize < MINIMUM_WIN_MEMORY) { +#ifdef _WIN32 + MEMORYSTATUS lpBuffer; lpBuffer.dwLength = sizeof(MEMORYSTATUS); GlobalMemoryStatus(&lpBuffer); if (lpBuffer.dwTotalPhys) { if (lpBuffer.dwTotalPhys < FIFTEEN_MB) - Sys_Error("Available memory less than 15MB!!! %i", i); + Sys_Error("Available memory less than 15MB!!! %i", host_parms.memsize); host_parms.memsize = (int)(lpBuffer.dwTotalPhys >> 1); - if ((signed int)host_parms.memsize < MINIMUM_WIN_MEMORY) + if (host_parms.memsize < MINIMUM_WIN_MEMORY) host_parms.memsize = MINIMUM_WIN_MEMORY; } else - host_parms.memsize = 0x8000000; + host_parms.memsize = MAXIMUM_WIN_MEMORY; if (g_bIsDedicatedServer) - host_parms.memsize = MAXIMUM_DEDICATED_MEMORY; - } + host_parms.memsize = DEFAULT_MEMORY; #else - if ((signed int)host_parms.memsize <= 0xDFFFFFu) - host_parms.memsize = MAXIMUM_DEDICATED_MEMORY; - + host_parms.memsize = DEFAULT_MEMORY; #endif // _WIN32 + } - if ((signed int)host_parms.memsize > 0x8000000) - host_parms.memsize = 0x8000000; + if (host_parms.memsize > MAXIMUM_DEDICATED_MEMORY) + host_parms.memsize = MAXIMUM_DEDICATED_MEMORY; if (COM_CheckParm("-minmemory")) host_parms.memsize = MINIMUM_WIN_MEMORY; @@ -392,7 +389,7 @@ void Sys_InitMemory(void) #endif // _WIN32 if (!host_parms.membase) - Sys_Error("Unable to allocate %.2f MB\n", (float)(host_parms.memsize) / (1024.0f * 1024.0f)); + Sys_Error("Unable to allocate %.2f MB\n", (float)host_parms.memsize / (1024.0f * 1024.0f)); } /* <906c2> ../engine/sys_dll2.cpp:626 */ diff --git a/rehlds/engine/sys_dll2.h b/rehlds/engine/sys_dll2.h index 3310a94..2049f0b 100644 --- a/rehlds/engine/sys_dll2.h +++ b/rehlds/engine/sys_dll2.h @@ -43,8 +43,9 @@ #define FIFTEEN_MB (15 * 1024 * 1024) #define MINIMUM_WIN_MEMORY 0x0e00000 #define WARNING_MEMORY 0x0200000 -#define MAXIMUM_WIN_MEMORY 0x2800000 // Ask for 40 MB max -#define MAXIMUM_DEDICATED_MEMORY 0x2800000 // Ask for 40 MB max +#define MAXIMUM_WIN_MEMORY 0x8000000 // Ask for 128 MB max +#define MAXIMUM_DEDICATED_MEMORY 0x8000000 // Ask for 128 MB max +#define DEFAULT_MEMORY 0x2800000 #ifdef HOOK_ENGINE #define dedicated_ (*pdedicated)