plugins/admin-flatfile/admin-flatfile.sp
author David Anderson <dvander@alliedmods.net>
Fri Jun 08 01:01:44 2007 +0000 (2007-06-08)
changeset 921 e07dad9724f5
parent 908 cd411e8827c4
child 989 365bacaddd5b
permissions -rw-r--r--
added sm_execcfg
     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 
    24 #include <sourcemod>
    25 #include <textparse>
    26 
    27 /* We like semicolons */
    28 #pragma semicolon 1
    29 
    30 public Plugin:myinfo = 
    31 {
    32 	name = "Admin File Reader",
    33 	author = "AlliedModders LLC",
    34 	description = "Reads admin files",
    35 	version = SOURCEMOD_VERSION,
    36 	url = "http://www.sourcemod.net/"
    37 };
    38 
    39 /** Various parsing globals */
    40 new bool:g_FlagsSet[26];					/* Maps whether flags are set */
    41 new AdminFlag:g_FlagLetters[26];			/* Maps the flag letters */		
    42 new bool:g_LoggedFileName = false;			/* Whether or not the file name has been logged */
    43 new g_ErrorCount = 0;						/* Current error count */
    44 new g_IgnoreLevel = 0;						/* Nested ignored section count, so users can screw up files safely */
    45 new String:g_Filename[PLATFORM_MAX_PATH];	/* Used for error messages */
    46 
    47 #include "admin-levels.sp"
    48 #include "admin-overrides.sp"
    49 #include "admin-groups.sp"
    50 #include "admin-users.sp"
    51 #include "admin-simple.sp"
    52 
    53 public OnRebuildAdminCache(AdminCachePart:part)
    54 {
    55 	RefreshLevels();
    56 	if (part == AdminCache_Overrides)
    57 	{
    58 		ReadOverrides();
    59 	} else if (part == AdminCache_Groups) {
    60 		ReadGroups();
    61 	} else if (part == AdminCache_Admins) {
    62 		ReadUsers();
    63 		ReadSimpleUsers();
    64 	}
    65 }
    66 
    67 ParseError(const String:format[], {Handle,String,Float,_}:...)
    68 {
    69 	decl String:buffer[512];
    70 	
    71 	if (!g_LoggedFileName)
    72 	{
    73 		LogError("Error(s) detected parsing %s", g_Filename);
    74 		g_LoggedFileName = true;
    75 	}
    76 	
    77 	VFormat(buffer, sizeof(buffer), format, 2);
    78 	
    79 	LogError(" (%d) %s", ++g_ErrorCount, buffer);
    80 }
    81 
    82 InitGlobalStates()
    83 {
    84 	g_ErrorCount = 0;
    85 	g_IgnoreLevel = 0;
    86 	g_LoggedFileName = false;
    87 }