From 73237e884b84484e157d1705aea06d3072bcb9ab Mon Sep 17 00:00:00 2001 From: Chuvi Date: Thu, 5 Jan 2017 01:08:21 +0300 Subject: [PATCH] Convert g_bIs#GameName# to enum. (#300) * Convert g_bIs#GameName# to enum. --- rehlds/engine/server.h | 23 ++++++++++++++++++++++- rehlds/engine/sv_main.cpp | 39 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/rehlds/engine/server.h b/rehlds/engine/server.h index 801dcf3..37d3eba 100644 --- a/rehlds/engine/server.h +++ b/rehlds/engine/server.h @@ -545,7 +545,28 @@ extern cvar_t sv_rcon_minfailuretime; extern cvar_t sv_rcon_banpenalty; extern cvar_t scr_downloading; +#ifdef REHLDS_FIXES +enum GameType_e +{ + GT_Unitialized, + GT_CZero, + GT_CZeroRitual, + GT_TerrorStrike, + GT_TFC, + GT_HL1, + GT_CStrike +}; +extern GameType_e g_eGameType; +//A crutch to prevent rewriting tons of code. +#define g_bIsCZero (g_eGameType==GT_CZero) +#define g_bIsCZeroRitual (g_eGameType==GT_CZeroRitual) +#define g_bIsTerrorStrike (g_eGameType==GT_TerrorStrike) +#define g_bIsTFC (g_eGameType==GT_TFC) +#define g_bIsHL1 (g_eGameType==GT_HL1) +#define g_bIsCStrike (g_eGameType==GT_CStrike) + +#else extern int g_bCS_CZ_Flags_Initialized; extern int g_bIsCZero; extern int g_bIsCZeroRitual; @@ -553,7 +574,7 @@ extern int g_bIsTerrorStrike; extern int g_bIsTFC; extern int g_bIsHL1; extern int g_bIsCStrike; - +#endif extern int fatbytes; extern int giNextUserMsg; extern int hashstrings_collisions; diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index df43173..0dd0ada 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -99,7 +99,10 @@ char outputbuf[MAX_ROUTEABLE_PACKET]; redirect_t sv_redirected; netadr_t sv_redirectto; -// TODO: make one global var with mods enum. +// DONE: make one global var with mods enum. +#ifdef REHLDS_FIXES +GameType_e g_eGameType = GT_Unitialized; +#else int g_bCS_CZ_Flags_Initialized; int g_bIsCZero; int g_bIsCZeroRitual; @@ -107,7 +110,7 @@ int g_bIsTerrorStrike; int g_bIsTFC; int g_bIsHL1; int g_bIsCStrike; - +#endif qboolean allow_cheats; /* @@ -5561,34 +5564,64 @@ NOXREF void SV_ReconnectAllClients(void) void SetCStrikeFlags(void) { - if (!g_bCS_CZ_Flags_Initialized) // TODO: Convert these to enum +#ifdef REHLDS_FIXES + if(g_eGameType==GT_Unitialized) +#else + if (!g_bCS_CZ_Flags_Initialized) // DONE: Convert these to enum +#endif { if (!Q_stricmp(com_gamedir, "valve")) { +#ifdef REHLDS_FIXES + g_eGameType = GT_HL1; +#else g_bIsHL1 = 1; +#endif } else if (!Q_stricmp(com_gamedir, "cstrike") || !Q_stricmp(com_gamedir, "cstrike_beta")) { +#ifdef REHLDS_FIXES + g_eGameType = GT_CStrike; +#else g_bIsCStrike = 1; +#endif } else if (!Q_stricmp(com_gamedir, "czero")) { +#ifdef REHLDS_FIXES + g_eGameType = GT_CZero; +#else g_bIsCZero = 1; +#endif } else if (!Q_stricmp(com_gamedir, "czeror")) { +#ifdef REHLDS_FIXES + g_eGameType = GT_CZeroRitual; +#else g_bIsCZeroRitual = 1; +#endif } else if (!Q_stricmp(com_gamedir, "terror")) { +#ifdef REHLDS_FIXES + g_eGameType = GT_TerrorStrike; +#else g_bIsTerrorStrike = 1; +#endif } else if (!Q_stricmp(com_gamedir, "tfc")) { +#ifdef REHLDS_FIXES + g_eGameType = GT_TFC; +#else g_bIsTFC = 1; +#endif } +#ifndef REHLDS_FIXES g_bCS_CZ_Flags_Initialized = 1; +#endif } }