From 19be28cc2e397dd1077041b8154810521e841edb Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Tue, 3 Feb 2015 10:26:28 -0500 Subject: [PATCH 1/3] Rename g_FlagSet to g_FlagCharSet to avoid some confusion. --- core/logic/AdminCache.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/logic/AdminCache.cpp b/core/logic/AdminCache.cpp index fc21673e..0a51146f 100644 --- a/core/logic/AdminCache.cpp +++ b/core/logic/AdminCache.cpp @@ -48,7 +48,7 @@ AdminCache g_Admins; char g_ReverseFlags[26]; AdminFlag g_FlagLetters[26]; -bool g_FlagSet[26]; +bool g_FlagCharSet[26]; /* Default flags */ AdminFlag g_DefaultFlags[26] = @@ -72,9 +72,9 @@ public: memcpy(g_FlagLetters, g_DefaultFlags, sizeof(AdminFlag) * 26); for (unsigned int i=0; i<20; i++) { - g_FlagSet[i] = true; + g_FlagCharSet[i] = true; } - g_FlagSet[25] = true; + g_FlagCharSet[25] = true; } } private: @@ -104,7 +104,7 @@ private: { m_LevelState = LEVEL_STATE_NONE; m_IgnoreLevel = 0; - memset(g_FlagSet, 0, sizeof(g_FlagSet)); + memset(g_FlagCharSet, 0, sizeof(g_FlagCharSet)); } SMCResult ReadSMC_NewSection(const SMCStates *states, const char *name) { @@ -164,7 +164,7 @@ private: return SMCResult_Continue; } - g_FlagSet[c] = true; + g_FlagCharSet[c] = true; return SMCResult_Continue; } @@ -1585,7 +1585,7 @@ bool AdminCache::FindFlag(char c, AdminFlag *pAdmFlag) { if (c < 'a' || c > 'z' - || !g_FlagSet[(unsigned)c - (unsigned)'a']) + || !g_FlagCharSet[(unsigned)c - (unsigned)'a']) { return false; } @@ -1600,7 +1600,7 @@ bool AdminCache::FindFlag(char c, AdminFlag *pAdmFlag) bool AdminCache::FindFlagChar(AdminFlag flag, char *c) { - if (!g_FlagSet[flag]) + if (!g_FlagCharSet[flag]) { return false; } From 84a59c6fb700cf95481cd0932438b511c16a242e Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Tue, 3 Feb 2015 10:27:32 -0500 Subject: [PATCH 2/3] Fix g_ReverseFlags array size. --- core/logic/AdminCache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/logic/AdminCache.cpp b/core/logic/AdminCache.cpp index 0a51146f..5b77907a 100644 --- a/core/logic/AdminCache.cpp +++ b/core/logic/AdminCache.cpp @@ -46,7 +46,7 @@ #define LEVEL_STATE_FLAGS 2 AdminCache g_Admins; -char g_ReverseFlags[26]; +char g_ReverseFlags[AdminFlags_TOTAL]; AdminFlag g_FlagLetters[26]; bool g_FlagCharSet[26]; From e88039d4e026f4185e789b7b60a08ca3cc02a918 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Tue, 3 Feb 2015 10:32:34 -0500 Subject: [PATCH 3/3] Fix FindFlagChar not finding char for AdminFlag_Custom6. --- core/logic/AdminCache.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/core/logic/AdminCache.cpp b/core/logic/AdminCache.cpp index 5b77907a..0b997082 100644 --- a/core/logic/AdminCache.cpp +++ b/core/logic/AdminCache.cpp @@ -1600,17 +1600,13 @@ bool AdminCache::FindFlag(char c, AdminFlag *pAdmFlag) bool AdminCache::FindFlagChar(AdminFlag flag, char *c) { - if (!g_FlagCharSet[flag]) - { - return false; - } - + char flagchar = g_ReverseFlags[flag]; if (c) { - *c = g_ReverseFlags[flag]; + *c = flagchar; } - return true; + return flagchar != '?'; } FlagBits AdminCache::ReadFlagString(const char *flags, const char **end)