plugins/admin-flatfile/admin-flatfile.sp
author Nicholas Hastings <skamonkey@gmail.com>
Sat Mar 22 17:06:37 2014 -0400 (2014-03-22)
changeset 4295 9b2a4619d94b
parent 2289 44045ead61cd
permissions -rw-r--r--
Fix compile error in DisplayAskConnectBox stock (bug 5984).
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod Admin File Reader Plugin
     5  * Manages the standard flat files for admins.  This is the file to compile.
     6  *
     7  * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
     8  * =============================================================================
     9  *
    10  * This program is free software; you can redistribute it and/or modify it under
    11  * the terms of the GNU General Public License, version 3.0, as published by the
    12  * Free Software Foundation.
    13  * 
    14  * This program is distributed in the hope that it will be useful, but WITHOUT
    15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    16  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    17  * details.
    18  *
    19  * You should have received a copy of the GNU General Public License along with
    20  * this program.  If not, see <http://www.gnu.org/licenses/>.
    21  *
    22  * As a special exception, AlliedModders LLC gives you permission to link the
    23  * code of this program (as well as its derivative works) to "Half-Life 2," the
    24  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    25  * by the Valve Corporation.  You must obey the GNU General Public License in
    26  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    27  * this exception to all derivative works.  AlliedModders LLC defines further
    28  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    29  * or <http://www.sourcemod.net/license.php>.
    30  *
    31  * Version: $Id$
    32  */
    33 
    34 /* We like semicolons */
    35 #pragma semicolon 1
    36 
    37 #include <sourcemod>
    38 
    39 public Plugin:myinfo = 
    40 {
    41 	name = "Admin File Reader",
    42 	author = "AlliedModders LLC",
    43 	description = "Reads admin files",
    44 	version = SOURCEMOD_VERSION,
    45 	url = "http://www.sourcemod.net/"
    46 };
    47 
    48 /** Various parsing globals */
    49 new bool:g_LoggedFileName = false;			/* Whether or not the file name has been logged */
    50 new g_ErrorCount = 0;						/* Current error count */
    51 new g_IgnoreLevel = 0;						/* Nested ignored section count, so users can screw up files safely */
    52 new g_CurrentLine = 0;						/* Current line we're on */
    53 new String:g_Filename[PLATFORM_MAX_PATH];	/* Used for error messages */
    54 
    55 #include "admin-overrides.sp"
    56 #include "admin-groups.sp"
    57 #include "admin-users.sp"
    58 #include "admin-simple.sp"
    59 
    60 public OnRebuildAdminCache(AdminCachePart:part)
    61 {
    62 	if (part == AdminCache_Overrides)
    63 	{
    64 		ReadOverrides();
    65 	} else if (part == AdminCache_Groups) {
    66 		ReadGroups();
    67 	} else if (part == AdminCache_Admins) {
    68 		ReadUsers();
    69 		ReadSimpleUsers();
    70 	}
    71 }
    72 
    73 ParseError(const String:format[], {Handle,String,Float,_}:...)
    74 {
    75 	decl String:buffer[512];
    76 	
    77 	if (!g_LoggedFileName)
    78 	{
    79 		LogError("Error(s) detected parsing %s", g_Filename);
    80 		g_LoggedFileName = true;
    81 	}
    82 	
    83 	VFormat(buffer, sizeof(buffer), format, 2);
    84 	
    85 	LogError(" (line %d) %s", g_CurrentLine, buffer);
    86 	
    87 	g_ErrorCount++;
    88 }
    89 
    90 InitGlobalStates()
    91 {
    92 	g_ErrorCount = 0;
    93 	g_IgnoreLevel = 0;
    94 	g_CurrentLine = 0;
    95 	g_LoggedFileName = false;
    96 }