Added a load-block for incorrect mods to TF2 and cstrike extensions.
3 * =============================================================================
4 * SourceMod Admin File Reader Plugin
5 * Reads overrides from the admin_levels.cfg file. Do not compile
8 * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
9 * =============================================================================
11 * This program is free software; you can redistribute it and/or modify it under
12 * the terms of the GNU General Public License, version 3.0, as published by the
13 * Free Software Foundation.
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
20 * You should have received a copy of the GNU General Public License along with
21 * this program. If not, see <http://www.gnu.org/licenses/>.
23 * As a special exception, AlliedModders LLC gives you permission to link the
24 * code of this program (as well as its derivative works) to "Half-Life 2," the
25 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
26 * by the Valve Corporation. You must obey the GNU General Public License in
27 * all respects for all other code used. Additionally, AlliedModders LLC grants
28 * this exception to all derivative works. AlliedModders LLC defines further
29 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
30 * or <http://www.sourcemod.net/license.php>.
35 #define OVERRIDE_STATE_NONE 0
36 #define OVERRIDE_STATE_LEVELS 1
37 #define OVERRIDE_STATE_OVERRIDES 2
39 static Handle:g_hOldOverrideParser = INVALID_HANDLE;
40 static Handle:g_hNewOverrideParser = INVALID_HANDLE;
41 static g_OverrideState = OVERRIDE_STATE_NONE;
43 public SMCResult:ReadOldOverrides_NewSection(Handle:smc, const String:name[], bool:opt_quotes)
48 return SMCParse_Continue;
51 if (g_OverrideState == OVERRIDE_STATE_NONE)
53 if (StrEqual(name, "Levels"))
55 g_OverrideState = OVERRIDE_STATE_LEVELS;
59 } else if (g_OverrideState == OVERRIDE_STATE_LEVELS) {
60 if (StrEqual(name, "Overrides"))
62 g_OverrideState = OVERRIDE_STATE_OVERRIDES;
70 return SMCParse_Continue;
73 public SMCResult:ReadNewOverrides_NewSection(Handle:smc, const String:name[], bool:opt_quotes)
78 return SMCParse_Continue;
81 if (g_OverrideState == OVERRIDE_STATE_NONE)
83 if (StrEqual(name, "Overrides"))
85 g_OverrideState = OVERRIDE_STATE_OVERRIDES;
93 return SMCParse_Continue;
96 public SMCResult:ReadOverrides_KeyValue(Handle:smc,
102 if (g_OverrideState != OVERRIDE_STATE_OVERRIDES
105 return SMCParse_Continue;
108 new flags = ReadFlagString(value);
112 AddCommandOverride(key[1], Override_CommandGroup, flags);
114 AddCommandOverride(key, Override_Command, flags);
117 return SMCParse_Continue;
120 public SMCResult:ReadOldOverrides_EndSection(Handle:smc)
122 /* If we're ignoring, skip out */
126 return SMCParse_Continue;
129 if (g_OverrideState == OVERRIDE_STATE_LEVELS)
131 g_OverrideState = OVERRIDE_STATE_NONE;
132 } else if (g_OverrideState == OVERRIDE_STATE_OVERRIDES) {
133 /* We're totally done parsing */
134 g_OverrideState = OVERRIDE_STATE_LEVELS;
135 return SMCParse_Halt;
138 return SMCParse_Continue;
141 public SMCResult:ReadNewOverrides_EndSection(Handle:smc)
143 /* If we're ignoring, skip out */
147 return SMCParse_Continue;
150 if (g_OverrideState == OVERRIDE_STATE_OVERRIDES)
152 g_OverrideState = OVERRIDE_STATE_NONE;
155 return SMCParse_Continue;
158 public SMCResult:ReadOverrides_CurrentLine(Handle:smc, const String:line[], lineno)
160 g_CurrentLine = lineno;
162 return SMCParse_Continue;
165 static InitializeOverrideParsers()
167 if (g_hOldOverrideParser == INVALID_HANDLE)
169 g_hOldOverrideParser = SMC_CreateParser();
170 SMC_SetReaders(g_hOldOverrideParser,
171 ReadOldOverrides_NewSection,
172 ReadOverrides_KeyValue,
173 ReadOldOverrides_EndSection);
174 SMC_SetRawLine(g_hOldOverrideParser, ReadOverrides_CurrentLine);
176 if (g_hNewOverrideParser == INVALID_HANDLE)
178 g_hNewOverrideParser = SMC_CreateParser();
179 SMC_SetReaders(g_hNewOverrideParser,
180 ReadNewOverrides_NewSection,
181 ReadOverrides_KeyValue,
182 ReadNewOverrides_EndSection);
183 SMC_SetRawLine(g_hNewOverrideParser, ReadOverrides_CurrentLine);
187 InternalReadOverrides(Handle:parser, const String:file[])
189 BuildPath(Path_SM, g_Filename, sizeof(g_Filename), file);
193 g_OverrideState = OVERRIDE_STATE_NONE;
195 new SMCError:err = SMC_ParseFile(parser, g_Filename);
196 if (err != SMCError_Okay)
198 decl String:buffer[64];
199 if (SMC_GetErrorString(err, buffer, sizeof(buffer)))
201 ParseError("%s", buffer);
203 ParseError("Fatal parse error");
210 InitializeOverrideParsers();
211 InternalReadOverrides(g_hOldOverrideParser, "configs/admin_levels.cfg");
212 InternalReadOverrides(g_hNewOverrideParser, "configs/admin_overrides.cfg");