plugins/admin-flatfile/admin-flatfile.sp
author David Anderson <dvander@alliedmods.net>
Fri Jul 27 00:28:43 2007 +0000 (2007-07-27)
changeset 1186 5abd46b5b5a6
parent 989 365bacaddd5b
child 1298 9cddbed74581
permissions -rw-r--r--
added ferret's new plugins to the build script
     1 /**
     2  * admin-flatfile.sp
     3  * Manages the standard flat files for admins.  This is the file to compile.
     4  * This file is part of SourceMod, Copyright (C) 2004-2007 AlliedModders LLC
     5  *
     6  * This program is free software; you can redistribute it and/or
     7  * modify it under the terms of the GNU General Public License
     8  * as published by the Free Software Foundation; either version 2
     9  * of the License, or (at your option) any later version.
    10  *
    11  * This program is distributed in the hope that it will be useful,
    12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  * GNU General Public License for more details.
    15  * 
    16  * You should have received a copy of the GNU General Public License
    17  * along with this program; if not, write to the Free Software
    18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    19  *
    20  * Version: $Id$
    21  */
    22 
    23 /* We like semicolons */
    24 #pragma semicolon 1
    25 
    26 #include <sourcemod>
    27 
    28 public Plugin:myinfo = 
    29 {
    30 	name = "Admin File Reader",
    31 	author = "AlliedModders LLC",
    32 	description = "Reads admin files",
    33 	version = SOURCEMOD_VERSION,
    34 	url = "http://www.sourcemod.net/"
    35 };
    36 
    37 /** Various parsing globals */
    38 new bool:g_FlagsSet[26];					/* Maps whether flags are set */
    39 new AdminFlag:g_FlagLetters[26];			/* Maps the flag letters */		
    40 new bool:g_LoggedFileName = false;			/* Whether or not the file name has been logged */
    41 new g_ErrorCount = 0;						/* Current error count */
    42 new g_IgnoreLevel = 0;						/* Nested ignored section count, so users can screw up files safely */
    43 new String:g_Filename[PLATFORM_MAX_PATH];	/* Used for error messages */
    44 
    45 #include "admin-levels.sp"
    46 #include "admin-overrides.sp"
    47 #include "admin-groups.sp"
    48 #include "admin-users.sp"
    49 #include "admin-simple.sp"
    50 
    51 public OnRebuildAdminCache(AdminCachePart:part)
    52 {
    53 	RefreshLevels();
    54 	if (part == AdminCache_Overrides)
    55 	{
    56 		ReadOverrides();
    57 	} else if (part == AdminCache_Groups) {
    58 		ReadGroups();
    59 	} else if (part == AdminCache_Admins) {
    60 		ReadUsers();
    61 		ReadSimpleUsers();
    62 	}
    63 }
    64 
    65 ParseError(const String:format[], {Handle,String,Float,_}:...)
    66 {
    67 	decl String:buffer[512];
    68 	
    69 	if (!g_LoggedFileName)
    70 	{
    71 		LogError("Error(s) detected parsing %s", g_Filename);
    72 		g_LoggedFileName = true;
    73 	}
    74 	
    75 	VFormat(buffer, sizeof(buffer), format, 2);
    76 	
    77 	LogError(" (%d) %s", ++g_ErrorCount, buffer);
    78 }
    79 
    80 InitGlobalStates()
    81 {
    82 	g_ErrorCount = 0;
    83 	g_IgnoreLevel = 0;
    84 	g_LoggedFileName = false;
    85 }