From 0c56f71a6191a5156a7c44536ef5ed781a54019f Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 6 Feb 2007 05:48:52 +0000 Subject: [PATCH] cleaned up levels in both the admin plugin and the source code overrides use full flag bits now --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40445 --- configs/admin_levels.cfg | 8 +++++- plugins/admin-flatfile/admin-flatfile.sp | 1 + plugins/admin-flatfile/admin-groups.sp | 4 +++ plugins/admin-flatfile/admin-levels.sp | 30 ++++++++++++++++++++--- plugins/admin-flatfile/admin-overrides.sp | 29 ++++++++++++++-------- plugins/include/admin.inc | 3 ++- 6 files changed, 60 insertions(+), 15 deletions(-) diff --git a/configs/admin_levels.cfg b/configs/admin_levels.cfg index 0ddb0248..81d3dc34 100644 --- a/configs/admin_levels.cfg +++ b/configs/admin_levels.cfg @@ -18,12 +18,18 @@ Levels "slay" "e" "changemap" "f" "cvars" "g" - "configs" "h" + "config" "h" "chat" "i" "vote" "j" "password" "k" "rcon" "l" "cheats" "m" + "custom1" "n" + "custom2" "o" + "custom3" "p" + "custom4" "q" + "custom5" "r" + "custom6" "s" //Custom flags START //Custom flags END diff --git a/plugins/admin-flatfile/admin-flatfile.sp b/plugins/admin-flatfile/admin-flatfile.sp index 261d7ebb..072dc12e 100644 --- a/plugins/admin-flatfile/admin-flatfile.sp +++ b/plugins/admin-flatfile/admin-flatfile.sp @@ -11,6 +11,7 @@ public Plugin:myinfo = }; /** Various globals */ +new bool:g_FlagsSet[26]; /* Maps whether flags are set */ new AdminFlag:g_FlagLetters[26]; /* Maps the flag letters */ new bool:g_LoggedFileName = false; /* Whether or not the file name has been logged */ new g_ErrorCount = 0; diff --git a/plugins/admin-flatfile/admin-groups.sp b/plugins/admin-flatfile/admin-groups.sp index 73cb778d..c129d367 100644 --- a/plugins/admin-flatfile/admin-groups.sp +++ b/plugins/admin-flatfile/admin-groups.sp @@ -80,6 +80,10 @@ public SMCResult:ReadGroups_KeyValue(Handle:smc, { continue; } + if (!g_FlagsSet[value[i] - 'a']) + { + continue; + } flag = g_FlagLetters[value[i] - 'a']; SetAdmGroupAddFlag(g_CurGrp, flag, true); } diff --git a/plugins/admin-flatfile/admin-levels.sp b/plugins/admin-flatfile/admin-levels.sp index 81dc3a16..fa38fa1c 100644 --- a/plugins/admin-flatfile/admin-levels.sp +++ b/plugins/admin-flatfile/admin-levels.sp @@ -9,6 +9,11 @@ static g_LevelState = LEVEL_STATE_NONE; LoadDefaultLetters() { + for (new i='t'; i<'z'; i++) + { + g_FlagsSet[i-'a'] = false; + } + g_FlagLetters['a'-'a'] = Admin_Reservation; g_FlagLetters['b'-'a'] = Admin_Kick; g_FlagLetters['c'-'a'] = Admin_Ban; @@ -19,9 +24,15 @@ LoadDefaultLetters() g_FlagLetters['h'-'a'] = Admin_Config; g_FlagLetters['i'-'a'] = Admin_Chat; g_FlagLetters['j'-'a'] = Admin_Vote; - g_FlagLetters['h'-'a'] = Admin_Password; - g_FlagLetters['i'-'a'] = Admin_RCON; - g_FlagLetters['j'-'a'] = Admin_Cheats; + g_FlagLetters['k'-'a'] = Admin_Password; + g_FlagLetters['l'-'a'] = Admin_RCON; + g_FlagLetters['m'-'a'] = Admin_Cheats; + g_FlagLetters['n'-'a'] = Admin_Custom1; + g_FlagLetters['o'-'a'] = Admin_Custom2; + g_FlagLetters['p'-'a'] = Admin_Custom3; + g_FlagLetters['q'-'a'] = Admin_Custom4; + g_FlagLetters['r'-'a'] = Admin_Custom5; + g_FlagLetters['s'-'a'] = Admin_Custom6; g_FlagLetters['z'-'a'] = Admin_Root; } @@ -103,11 +114,24 @@ public SMCResult:ReadLevels_KeyValue(Handle:smc, const String:key[], const Strin flag = Admin_Cheats; } else if (StrEqual(key, "root")) { flag = Admin_Root; + } else if (StrEqual(key, "custom1")) { + flag = Admin_Custom1; + } else if (StrEqual(key, "custom2")) { + flag = Admin_Custom2; + } else if (StrEqual(key, "custom3")) { + flag = Admin_Custom3; + } else if (StrEqual(key, "custom4")) { + flag = Admin_Custom4; + } else if (StrEqual(key, "custom5")) { + flag = Admin_Custom5; + } else if (StrEqual(key, "custom6")) { + flag = Admin_Custom6; } else { LogLevelError("Unrecognized flag type: %s", key); } g_FlagLetters[chr] = flag; + g_FlagsSet[chr] = true; } return SMCParse_Continue; diff --git a/plugins/admin-flatfile/admin-overrides.sp b/plugins/admin-flatfile/admin-overrides.sp index 6bb54b61..43b93ac9 100644 --- a/plugins/admin-flatfile/admin-overrides.sp +++ b/plugins/admin-flatfile/admin-overrides.sp @@ -50,24 +50,33 @@ public SMCResult:ReadOverrides_KeyValue(Handle:smc, return SMCParse_Continue; } - new AdminFlag:flag; + new AdminFlag:array[AdminFlags_TOTAL]; + new flags_total; - if (strlen(value) > 1) + new len = strlen(value); + for (new i=0; i 'z') + { + LogOverrideError("Invalid flag detected: %c", value[i]); + continue; + } + new val = value[i] - 'a'; + if (!g_FlagsSet[val]) + { + LogOverrideError("Invalid flag detected: %c", value[i]); + continue; + } + array[flags_total++] = g_FlagLetters[val]; } - if (value[0] >= 'a' && value[0] <= 'z') - { - flag = g_FlagLetters[value[0] - 'a']; - } + new flags = FlagArrayToBits(array, flags_total); if (key[0] == '@') { - AddCommandOverride(key[1], Override_CommandGroup, FlagToBit(flag)); + AddCommandOverride(key[1], Override_CommandGroup, flags); } else { - AddCommandOverride(key, Override_Command, FlagToBit(flag)); + AddCommandOverride(key, Override_Command, flags); } return SMCParse_Continue; diff --git a/plugins/include/admin.inc b/plugins/include/admin.inc index 9d3ce6f5..3bfad62a 100644 --- a/plugins/include/admin.inc +++ b/plugins/include/admin.inc @@ -44,9 +44,10 @@ enum AdminFlag Admin_Custom5, /**< Fifth custom flag type */ Admin_Custom6, /**< Sixth custom flag type */ /* --- */ - AdminFlags_TOTAL, }; +#define AdminFlags_TOTAL 21 + /** * These define bitwise values for bitstrings (numbers containing bitwise flags). */