2007-02-07 03:17:19 +01:00
|
|
|
/**
|
|
|
|
* admin-flatfile.sp
|
|
|
|
* Manages the standard flat files for admins. This is the file to compile.
|
|
|
|
* This file is part of SourceMod, Copyright (C) 2004-2007 AlliedModders LLC
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2007-01-29 20:36:02 +01:00
|
|
|
#include <sourcemod>
|
|
|
|
#include <textparse>
|
|
|
|
|
2007-03-16 23:15:03 +01:00
|
|
|
/* We like semicolons */
|
|
|
|
#pragma semicolon 1
|
|
|
|
|
2007-01-29 20:36:02 +01:00
|
|
|
public Plugin:myinfo =
|
|
|
|
{
|
2007-02-09 05:41:03 +01:00
|
|
|
name = "Admin File Reader",
|
2007-01-29 20:36:02 +01:00
|
|
|
author = "AlliedModders LLC",
|
|
|
|
description = "Reads admin files",
|
|
|
|
version = "1.0.0.0",
|
|
|
|
url = "http://www.sourcemod.net/"
|
|
|
|
};
|
|
|
|
|
2007-02-07 00:30:50 +01:00
|
|
|
/** Various parsing globals */
|
2007-02-06 06:48:52 +01:00
|
|
|
new bool:g_FlagsSet[26]; /* Maps whether flags are set */
|
2007-01-29 20:36:02 +01:00
|
|
|
new AdminFlag:g_FlagLetters[26]; /* Maps the flag letters */
|
|
|
|
new bool:g_LoggedFileName = false; /* Whether or not the file name has been logged */
|
2007-02-07 00:30:50 +01:00
|
|
|
new g_ErrorCount = 0; /* Current error count */
|
|
|
|
new g_IgnoreLevel = 0; /* Nested ignored section count, so users can screw up files safely */
|
|
|
|
new String:g_Filename[PLATFORM_MAX_PATH]; /* Used for error messages */
|
2007-01-29 20:36:02 +01:00
|
|
|
|
2007-01-30 01:38:15 +01:00
|
|
|
#include "admin-levels.sp"
|
|
|
|
#include "admin-overrides.sp"
|
2007-01-30 07:43:34 +01:00
|
|
|
#include "admin-groups.sp"
|
2007-02-07 03:17:19 +01:00
|
|
|
#include "admin-users.sp"
|
2007-03-16 23:15:03 +01:00
|
|
|
#include "admin-simple.sp"
|
2007-01-30 01:38:15 +01:00
|
|
|
|
2007-02-06 06:13:24 +01:00
|
|
|
public OnRebuildAdminCache(AdminCachePart:part)
|
2007-01-29 20:36:02 +01:00
|
|
|
{
|
|
|
|
RefreshLevels();
|
2007-02-06 06:13:24 +01:00
|
|
|
if (part == AdminCache_Overrides)
|
2007-01-30 00:54:04 +01:00
|
|
|
{
|
|
|
|
ReadOverrides();
|
2007-02-07 03:17:19 +01:00
|
|
|
} else if (part == AdminCache_Groups) {
|
2007-01-30 07:43:34 +01:00
|
|
|
ReadGroups();
|
2007-02-07 03:17:19 +01:00
|
|
|
} else if (part == AdminCache_Admins) {
|
|
|
|
ReadUsers();
|
2007-03-16 23:15:03 +01:00
|
|
|
ReadSimpleUsers();
|
2007-01-30 07:43:34 +01:00
|
|
|
}
|
2007-01-29 20:36:02 +01:00
|
|
|
}
|
2007-02-07 00:30:50 +01:00
|
|
|
|
|
|
|
ParseError(const String:format[], {Handle,String,Float,_}:...)
|
|
|
|
{
|
|
|
|
decl String:buffer[512];
|
|
|
|
|
|
|
|
if (!g_LoggedFileName)
|
|
|
|
{
|
2007-02-07 00:39:25 +01:00
|
|
|
LogError("Error(s) detected parsing %s", g_Filename);
|
2007-02-07 00:30:50 +01:00
|
|
|
g_LoggedFileName = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
VFormat(buffer, sizeof(buffer), format, 2);
|
|
|
|
|
|
|
|
LogError(" (%d) %s", ++g_ErrorCount, buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
InitGlobalStates()
|
|
|
|
{
|
|
|
|
g_ErrorCount = 0;
|
|
|
|
g_IgnoreLevel = 0;
|
|
|
|
g_LoggedFileName = false;
|
|
|
|
}
|