plugins/admin-flatfile/admin-flatfile.sp
branchrefac-jit
changeset 2168 c24a6fa957db
child 2289 44045ead61cd
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/plugins/admin-flatfile/admin-flatfile.sp	Sun Jul 06 04:49:55 2008 +0000
     1.3 @@ -0,0 +1,96 @@
     1.4 +/**
     1.5 + * vim: set ts=4 :
     1.6 + * =============================================================================
     1.7 + * SourceMod Admin File Reader Plugin
     1.8 + * Manages the standard flat files for admins.  This is the file to compile.
     1.9 + *
    1.10 + * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
    1.11 + * =============================================================================
    1.12 + *
    1.13 + * This program is free software; you can redistribute it and/or modify it under
    1.14 + * the terms of the GNU General Public License, version 3.0, as published by the
    1.15 + * Free Software Foundation.
    1.16 + * 
    1.17 + * This program is distributed in the hope that it will be useful, but WITHOUT
    1.18 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.19 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.20 + * details.
    1.21 + *
    1.22 + * You should have received a copy of the GNU General Public License along with
    1.23 + * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.24 + *
    1.25 + * As a special exception, AlliedModders LLC gives you permission to link the
    1.26 + * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.27 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.28 + * by the Valve Corporation.  You must obey the GNU General Public License in
    1.29 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.30 + * this exception to all derivative works.  AlliedModders LLC defines further
    1.31 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.32 + * or <http://www.sourcemod.net/license.php>.
    1.33 + *
    1.34 + * Version: $Id$
    1.35 + */
    1.36 +
    1.37 +/* We like semicolons */
    1.38 +#pragma semicolon 1
    1.39 +
    1.40 +#include <sourcemod>
    1.41 +
    1.42 +public Plugin:myinfo = 
    1.43 +{
    1.44 +	name = "Admin File Reader",
    1.45 +	author = "AlliedModders LLC",
    1.46 +	description = "Reads admin files",
    1.47 +	version = SOURCEMOD_VERSION,
    1.48 +	url = "http://www.sourcemod.net/"
    1.49 +};
    1.50 +
    1.51 +/** Various parsing globals */
    1.52 +new bool:g_LoggedFileName = false;			/* Whether or not the file name has been logged */
    1.53 +new g_ErrorCount = 0;						/* Current error count */
    1.54 +new g_IgnoreLevel = 0;						/* Nested ignored section count, so users can screw up files safely */
    1.55 +new g_CurrentLine = 0;						/* Current line we're on */
    1.56 +new String:g_Filename[PLATFORM_MAX_PATH];	/* Used for error messages */
    1.57 +
    1.58 +#include "admin-overrides.sp"
    1.59 +#include "admin-groups.sp"
    1.60 +#include "admin-users.sp"
    1.61 +#include "admin-simple.sp"
    1.62 +
    1.63 +public OnRebuildAdminCache(AdminCachePart:part)
    1.64 +{
    1.65 +	if (part == AdminCache_Overrides)
    1.66 +	{
    1.67 +		ReadOverrides();
    1.68 +	} else if (part == AdminCache_Groups) {
    1.69 +		ReadGroups();
    1.70 +	} else if (part == AdminCache_Admins) {
    1.71 +		ReadUsers();
    1.72 +		ReadSimpleUsers();
    1.73 +	}
    1.74 +}
    1.75 +
    1.76 +ParseError(const String:format[], {Handle,String,Float,_}:...)
    1.77 +{
    1.78 +	decl String:buffer[512];
    1.79 +	
    1.80 +	if (!g_LoggedFileName)
    1.81 +	{
    1.82 +		LogError("Error(s) detected parsing %s", g_Filename);
    1.83 +		g_LoggedFileName = true;
    1.84 +	}
    1.85 +	
    1.86 +	VFormat(buffer, sizeof(buffer), format, 2);
    1.87 +	
    1.88 +	LogError(" (line %d) %s", g_CurrentLine, buffer);
    1.89 +	
    1.90 +	g_ErrorCount++;
    1.91 +}
    1.92 +
    1.93 +InitGlobalStates()
    1.94 +{
    1.95 +	g_ErrorCount = 0;
    1.96 +	g_IgnoreLevel = 0;
    1.97 +	g_CurrentLine = 0;
    1.98 +	g_LoggedFileName = false;
    1.99 +}