From aa963603eda35904587ed17006895290d90a269c Mon Sep 17 00:00:00 2001 From: HttrckCldHKS Date: Sat, 18 Oct 2014 10:09:11 -0700 Subject: [PATCH 1/9] Adding New Game Modifications Due Colored Menus Adding New Game Modifications Due Colored Menus. --- amxmodx/meta_api.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/amxmodx/meta_api.cpp b/amxmodx/meta_api.cpp index 5393c884..cb973183 100755 --- a/amxmodx/meta_api.cpp +++ b/amxmodx/meta_api.cpp @@ -143,6 +143,21 @@ int FF_InconsistentFile = -1; int FF_ClientAuthorized = -1; int FF_ChangeLevel = -1; +static const bool ColoredMenus(String & ModName) +{ + static const char * pModNames[] = { "cstrike", "czero", "dmc", "dod", "tfc", "valve" }; + static const size_t ModsCount = sizeof(pModNames) / sizeof(const char *); + static int Iterator = 0u; + + for (Iterator = 0u; Iterator < ModsCount; ++Iterator) + { + if (ModName.compare(pModNames[Iterator]) == 0u) + return true; // this game modification currently supports colored menus + } + + return false; // no colored menus are supported for this game modification +} + void ParseAndOrAdd(CStack & files, const char *name) { if (strncmp(name, "plugins-", 8) == 0) @@ -1440,10 +1455,7 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m g_mod_name.assign(a); - if (g_mod_name.compare("cstrike") == 0 || g_mod_name.compare("czero") == 0 || g_mod_name.compare("dod") == 0) - g_coloredmenus = true; - else - g_coloredmenus = false; + g_coloredmenus = ColoredMenus(g_mod_name); // whether or not to use colored menus // ###### Print short GPL print_srvconsole("\n AMX Mod X version %s Copyright (c) 2004-2014 AMX Mod X Development Team \n" From e08e140c3c69ae0d2d8049336831b1f7c32efcc9 Mon Sep 17 00:00:00 2001 From: HttrckCldHKS Date: Sat, 18 Oct 2014 10:10:09 -0700 Subject: [PATCH 2/9] Fixed Switch Statement Fixed Switch Statement. --- dlls/geoip/geoip_util.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/dlls/geoip/geoip_util.cpp b/dlls/geoip/geoip_util.cpp index 67b1b84f..aecdb864 100644 --- a/dlls/geoip/geoip_util.cpp +++ b/dlls/geoip/geoip_util.cpp @@ -155,13 +155,16 @@ int getContinentId(const char *code) { case 'A': { - switch (code[1]) - { - case 'F': index = CONTINENT_AFRICA; break; - case 'N': index = CONTINENT_ANTARCTICA; break; - case 'S': index = CONTINENT_ASIA; break; - } + switch (code[1]) + { + case 'F': index = CONTINENT_AFRICA; break; + case 'N': index = CONTINENT_ANTARCTICA; break; + case 'S': index = CONTINENT_ASIA; break; + } + + break; } + case 'E': index = CONTINENT_EUROPE; break; case 'O': index = CONTINENT_OCEANIA; break; case 'N': index = CONTINENT_NORTH_AMERICA; break; From 3615e717ca7e1047481f5ebcd1c372f17ed40295 Mon Sep 17 00:00:00 2001 From: HttrckCldHKS Date: Sat, 18 Oct 2014 10:10:58 -0700 Subject: [PATCH 3/9] Adding New Game Modifications Due Colored Menus Adding New Game Modifications Due Colored Menus. --- plugins/include/amxmisc.inc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/plugins/include/amxmisc.inc b/plugins/include/amxmisc.inc index ccd7a511..0d97062a 100755 --- a/plugins/include/amxmisc.inc +++ b/plugins/include/amxmisc.inc @@ -420,12 +420,22 @@ stock show_activity_key(const KeyWithoutName[], const KeyWithName[], const ___Ad } } -stock colored_menus() +stock colored_menus() { - new mod_name[32]; - get_modname(mod_name,31); + static const ModNames[][] = { "cstrike", "czero", "dmc", "dod", "tfc", "valve" }; + static const ModsCount = sizeof(ModNames); - return ( equal(mod_name,"cstrike") || equal(mod_name,"czero") || equal(mod_name,"dod") ); + static ModName[32], Iterator = 0; + + get_modname(ModName, 31); + + for (Iterator = 0; Iterator < ModsCount; Iterator++) + { + if (equal(ModName, ModNames[Iterator])) + return 1; + } + + return 0; } stock cstrike_running() From 59a1b018edf0bd22c584feeefa48807feb96524e Mon Sep 17 00:00:00 2001 From: HttrckCldHKS Date: Sat, 18 Oct 2014 10:34:03 -0700 Subject: [PATCH 4/9] Improving Code --- amxmodx/meta_api.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/amxmodx/meta_api.cpp b/amxmodx/meta_api.cpp index cb973183..78ef34d6 100755 --- a/amxmodx/meta_api.cpp +++ b/amxmodx/meta_api.cpp @@ -143,13 +143,11 @@ int FF_InconsistentFile = -1; int FF_ClientAuthorized = -1; int FF_ChangeLevel = -1; -static const bool ColoredMenus(String & ModName) +bool ColoredMenus(String & ModName) { - static const char * pModNames[] = { "cstrike", "czero", "dmc", "dod", "tfc", "valve" }; - static const size_t ModsCount = sizeof(pModNames) / sizeof(const char *); - static int Iterator = 0u; + const char * pModNames[] = { "cstrike", "czero", "dmc", "dod", "tfc", "valve" }; - for (Iterator = 0u; Iterator < ModsCount; ++Iterator) + for (int Iterator = 0u; Iterator < sizeof(pModNames) / sizeof(const char *); ++Iterator) { if (ModName.compare(pModNames[Iterator]) == 0u) return true; // this game modification currently supports colored menus From 5d2b738ec1a916ba7d7862946d157fc5d1ed8a63 Mon Sep 17 00:00:00 2001 From: HttrckCldHKS Date: Sat, 18 Oct 2014 10:36:07 -0700 Subject: [PATCH 5/9] Improving Code --- plugins/include/amxmisc.inc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/plugins/include/amxmisc.inc b/plugins/include/amxmisc.inc index 0d97062a..9f91c6bb 100755 --- a/plugins/include/amxmisc.inc +++ b/plugins/include/amxmisc.inc @@ -422,14 +422,12 @@ stock show_activity_key(const KeyWithoutName[], const KeyWithName[], const ___Ad stock colored_menus() { - static const ModNames[][] = { "cstrike", "czero", "dmc", "dod", "tfc", "valve" }; - static const ModsCount = sizeof(ModNames); + new const ModNames[][] = { "cstrike", "czero", "dmc", "dod", "tfc", "valve" }; + new ModName[32]; - static ModName[32], Iterator = 0; + get_modname(ModName, charsmax(ModName)); - get_modname(ModName, 31); - - for (Iterator = 0; Iterator < ModsCount; Iterator++) + for (new Iterator = 0; Iterator < sizeof(ModNames); Iterator++) { if (equal(ModName, ModNames[Iterator])) return 1; From 82cbc94f2752567c1e07435dc0ebb6df5d43f5ce Mon Sep 17 00:00:00 2001 From: HttrckCldHKS Date: Sat, 18 Oct 2014 10:58:26 -0700 Subject: [PATCH 6/9] Improving Code --- amxmodx/meta_api.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/amxmodx/meta_api.cpp b/amxmodx/meta_api.cpp index 78ef34d6..1253b5d2 100755 --- a/amxmodx/meta_api.cpp +++ b/amxmodx/meta_api.cpp @@ -145,9 +145,10 @@ int FF_ChangeLevel = -1; bool ColoredMenus(String & ModName) { - const char * pModNames[] = { "cstrike", "czero", "dmc", "dod", "tfc", "valve" }; + static const char * pModNames[] = { "cstrike", "czero", "dmc", "dod", "tfc", "valve" }; + static const size_t ModsCount = sizeof(pModNames) / sizeof(const char *); - for (int Iterator = 0u; Iterator < sizeof(pModNames) / sizeof(const char *); ++Iterator) + for (int Iterator = 0u; Iterator < ModsCount; ++Iterator) { if (ModName.compare(pModNames[Iterator]) == 0u) return true; // this game modification currently supports colored menus From 7ced590cbc41654a783559b6d9ccc9a72196795f Mon Sep 17 00:00:00 2001 From: HttrckCldHKS Date: Sat, 18 Oct 2014 11:04:10 -0700 Subject: [PATCH 7/9] Improving Code --- plugins/include/amxmisc.inc | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/plugins/include/amxmisc.inc b/plugins/include/amxmisc.inc index 9f91c6bb..99e7aa8d 100755 --- a/plugins/include/amxmisc.inc +++ b/plugins/include/amxmisc.inc @@ -422,18 +422,29 @@ stock show_activity_key(const KeyWithoutName[], const KeyWithName[], const ___Ad stock colored_menus() { - new const ModNames[][] = { "cstrike", "czero", "dmc", "dod", "tfc", "valve" }; - new ModName[32]; + static const ModNames[][] = { "cstrike", "czero", "dmc", "dod", "tfc", "valve" }; + static ColoredMenus = -1; - get_modname(ModName, charsmax(ModName)); - - for (new Iterator = 0; Iterator < sizeof(ModNames); Iterator++) + if (ColoredMenus == -1) { - if (equal(ModName, ModNames[Iterator])) - return 1; + new ModName[32]; + get_modname(ModName, charsmax(ModName)); + + for (new Iterator = 0; Iterator < sizeof(ModNames); Iterator++) + { + if (equal(ModName, ModNames[Iterator])) + { + ColoredMenus = 1; + + break; + } + } + + if (ColoredMenus == -1) + ColoredMenus = 0; } - return 0; + return ColoredMenus; } stock cstrike_running() From d1c0b8fea617357795bd3f0f870fe96ab54d5c47 Mon Sep 17 00:00:00 2001 From: HttrckCldHKS Date: Sat, 18 Oct 2014 11:09:49 -0700 Subject: [PATCH 8/9] Improving Code --- amxmodx/meta_api.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/amxmodx/meta_api.cpp b/amxmodx/meta_api.cpp index 1253b5d2..8ae5611a 100755 --- a/amxmodx/meta_api.cpp +++ b/amxmodx/meta_api.cpp @@ -145,8 +145,8 @@ int FF_ChangeLevel = -1; bool ColoredMenus(String & ModName) { - static const char * pModNames[] = { "cstrike", "czero", "dmc", "dod", "tfc", "valve" }; - static const size_t ModsCount = sizeof(pModNames) / sizeof(const char *); + const char * pModNames[] = { "cstrike", "czero", "dmc", "dod", "tfc", "valve" }; + const size_t ModsCount = sizeof(pModNames) / sizeof(const char *); for (int Iterator = 0u; Iterator < ModsCount; ++Iterator) { From 3953db97cd48fcdc9cc6d2bd3c5df8a1fe373ae6 Mon Sep 17 00:00:00 2001 From: HttrckCldHKS Date: Sat, 18 Oct 2014 11:11:10 -0700 Subject: [PATCH 9/9] Improving Code --- plugins/include/amxmisc.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/include/amxmisc.inc b/plugins/include/amxmisc.inc index 99e7aa8d..a4314f2f 100755 --- a/plugins/include/amxmisc.inc +++ b/plugins/include/amxmisc.inc @@ -422,12 +422,13 @@ stock show_activity_key(const KeyWithoutName[], const KeyWithName[], const ___Ad stock colored_menus() { - static const ModNames[][] = { "cstrike", "czero", "dmc", "dod", "tfc", "valve" }; static ColoredMenus = -1; if (ColoredMenus == -1) { + new const ModNames[][] = { "cstrike", "czero", "dmc", "dod", "tfc", "valve" }; new ModName[32]; + get_modname(ModName, charsmax(ModName)); for (new Iterator = 0; Iterator < sizeof(ModNames); Iterator++)