Added support for post map configs (with workaround for SourceMod bug 3803). Log cleanup. Minior fixes.

Removed log check in fatal errors. Those must always log.
Stored LogCheckFlag result in a boolean where log is executed more than once.
Fixed invalid translation string used in menu title.
Fixed index out of bounds in zspawn when a client disconnects.
This commit is contained in:
richard
2009-05-09 17:45:19 +02:00
parent e9c611b476
commit 969aa19b85
9 changed files with 120 additions and 32 deletions

View File

@ -41,6 +41,9 @@
*/
#define CONFIG_OPTION_MAX_LENGTH 32
/**
* Actions to use when working on key/values.
*/
enum ConfigKeyvalueAction
{
Create, /** Create a key. */
@ -48,6 +51,9 @@ enum ConfigKeyvalueAction
Set, /** Modify setting of a key. */
Get, /** Get setting of a key. */
}
/**
* @endsection
*/
/**
* @section Global data handle initializations.
@ -57,6 +63,7 @@ new Handle:kvClassData = INVALID_HANDLE;
new Handle:kvWeapons = INVALID_HANDLE;
new Handle:kvWeaponGroups = INVALID_HANDLE;
new Handle:kvHitgroups = INVALID_HANDLE;
/**
* Load plugin configs.
*/
@ -88,6 +95,48 @@ ConfigLoad()
}
}
/**
* Executed when modules are done loading. After all init calls in
* OnConfigsExecuted.
*
* Executes post map configs if they exist.
*/
ConfigOnModulesLoaded()
{
decl String:mapname[256];
decl String:mapconfig[PLATFORM_MAX_PATH];
decl String:path[PLATFORM_MAX_PATH];
new bool:cfgexists;
// Get map name and format into config path.
GetCurrentMap(mapname, sizeof(mapname));
Format(mapconfig, sizeof(mapconfig), "sourcemod/zombiereloaded/%s.post.cfg", mapname);
// Prepend cfg to path.
Format(path, sizeof(path), "cfg/%s", mapconfig);
// Workaround for bug 3083 in SourceMod compiler. Having FileExist directly
// in the if in this function makes it crash. Storing the result in a
// boolean first works.
// Check if the file exist.
cfgexists = FileExists(path);
if (!cfgexists)
{
// File doesn't exist, then stop.
return;
}
// Execute config file.
ServerCommand("exec %s", mapconfig);
// Log action.
if (LogCheckFlag(LOG_CORE_EVENTS))
{
LogMessageFormatted(-1, "", "", "Executed post map config file: %s.", LOG_FORMAT_TYPE_SIMPLE, mapconfig);
}
}
/**
* Load config file.
*
@ -106,6 +155,7 @@ bool:ConfigGetFilePath(CvarsList:cvar, String:path[])
return FileExists(path);
}
/**
* Creates, deletes, sets, or gets any key/setting of any ZR config keyvalue file in memory.
* Only use when interacting with a command or manipulating single keys/values,