plugins/admin-flatfile/admin-flatfile.sp
author Scott Ehlert <ds@alliedmods.net>
Wed Aug 15 06:19:30 2007 +0000 (2007-08-15)
changeset 1330 ab94316bb52b
parent 1298 9cddbed74581
child 1432 d5001413aba7
permissions -rw-r--r--
Updated license headers on virtually all files with extremely minor changes in the name of some sort of strange consistency.
All plugin and include file headers also have been changed to say about GPL3 instead of GPL2.

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