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:
@ -660,6 +660,9 @@ ClassGetDefaultSpawnClass(teamid, cachetype = ZR_CLASS_CACHE_MODIFIED)
|
||||
decl String:classname[64];
|
||||
new classindex;
|
||||
|
||||
// Initialize log boolean.
|
||||
new bool:enablelog = LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_CLASSES);
|
||||
|
||||
// Get the default class name from the correct CVAR depending on teamid.
|
||||
switch (teamid)
|
||||
{
|
||||
@ -723,7 +726,7 @@ ClassGetDefaultSpawnClass(teamid, cachetype = ZR_CLASS_CACHE_MODIFIED)
|
||||
// in the specified team, and log a warning.
|
||||
classindex = ClassGetFirstClass(teamid, _, cachetype);
|
||||
|
||||
if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_CLASSES))
|
||||
if (enablelog)
|
||||
{
|
||||
LogMessageFormatted(-1, "Classes", "DefaultSpawnClass", "Warning: Failed to set \"%s\" as default spawn class for team %d. The class doesn't exist or the team IDs doesn't match. Falling back to the first class in the team.", _, classname, teamid);
|
||||
}
|
||||
@ -732,7 +735,7 @@ ClassGetDefaultSpawnClass(teamid, cachetype = ZR_CLASS_CACHE_MODIFIED)
|
||||
if (ClassValidateIndex(classindex))
|
||||
{
|
||||
// Log a warning.
|
||||
if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_CLASSES))
|
||||
if (enablelog)
|
||||
{
|
||||
LogMessageFormatted(-1, "Classes", "DefaultSpawnClass", "Warning: The default class name \"%s\" does not exist or matches the team ID.", _, classname);
|
||||
}
|
||||
|
@ -300,6 +300,9 @@ new ClassPlayerNextAdminClass[MAXPLAYERS + 1];
|
||||
*/
|
||||
ClassLoad()
|
||||
{
|
||||
// Initialize log boolean.
|
||||
new bool:enablelog = LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_WEAPONS);
|
||||
|
||||
// Make sure kvClassData is ready to use.
|
||||
if (kvClassData != INVALID_HANDLE)
|
||||
{
|
||||
@ -311,14 +314,16 @@ ClassLoad()
|
||||
decl String:pathclasses[PLATFORM_MAX_PATH];
|
||||
new bool:exists = ConfigGetFilePath(CVAR_CONFIG_PATH_PLAYERCLASSES, pathclasses);
|
||||
|
||||
// Log what class file that is loaded.
|
||||
if (enablelog)
|
||||
{
|
||||
LogMessageFormatted(-1, "Classes", "Load", "Loading classes from file \"%s\".", LOG_FORMAT_TYPE_SIMPLE, pathclasses);
|
||||
}
|
||||
|
||||
// If file doesn't exist, then log and stop.
|
||||
if (!exists)
|
||||
{
|
||||
// Log failure.
|
||||
if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_WEAPONS))
|
||||
{
|
||||
LogMessageFormatted(-1, "Classes", "Config Validation", "Missing playerclasses config file: %s", LOG_FORMAT_TYPE_FATALERROR, pathclasses);
|
||||
}
|
||||
LogMessageFormatted(-1, "Classes", "Load", "Fatal error: Missing playerclasses config file \"%s\"", LOG_FORMAT_TYPE_FATALERROR, pathclasses);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -330,7 +335,7 @@ ClassLoad()
|
||||
KvRewind(kvClassData);
|
||||
if (!KvGotoFirstSubKey(kvClassData))
|
||||
{
|
||||
LogMessageFormatted(-1, "Classes", "Config Validation", "Can't find any classes in %s", LOG_FORMAT_TYPE_FATALERROR, pathclasses);
|
||||
LogMessageFormatted(-1, "Classes", "Load", "Fatal error: Can't find any classes in \"%s\"", LOG_FORMAT_TYPE_FATALERROR, pathclasses);
|
||||
}
|
||||
|
||||
decl String:name[64];
|
||||
@ -339,6 +344,7 @@ ClassLoad()
|
||||
decl String:overlay_path[PLATFORM_MAX_PATH];
|
||||
|
||||
ClassCount = 0;
|
||||
new failedcount;
|
||||
new ClassErrorFlags;
|
||||
|
||||
// Loop through all classes and store attributes in the ClassData array.
|
||||
@ -347,7 +353,7 @@ ClassLoad()
|
||||
if (ClassCount > ZR_CLASS_MAX)
|
||||
{
|
||||
// Maximum classes reached. Write a warning and exit the loop.
|
||||
if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_CLASSES))
|
||||
if (enablelog)
|
||||
{
|
||||
LogMessageFormatted(-1, "Classes", "Load", "Warning: Maximum classes reached (%d). Skipping other classes.", _, ZR_CLASS_MAX + 1);
|
||||
}
|
||||
@ -411,10 +417,12 @@ ClassLoad()
|
||||
// There's one or more invalid class attributes. Disable the class
|
||||
// and log an error message.
|
||||
ClassData[ClassCount][class_enabled] = false;
|
||||
if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_CLASSES))
|
||||
if (enablelog)
|
||||
{
|
||||
LogMessageFormatted(-1, "Classes", "Config Validation", "Warning: Invalid class at index %d, disabled class. Class error flags: %d.", LOG_FORMAT_TYPE_ERROR, ClassCount, ClassErrorFlags);
|
||||
}
|
||||
|
||||
failedcount++;
|
||||
}
|
||||
|
||||
// Update the counter.
|
||||
@ -424,17 +432,23 @@ ClassLoad()
|
||||
// Validate team requirements.
|
||||
if (!ClassValidateTeamRequirements())
|
||||
{
|
||||
LogMessageFormatted(-1, "Classes", "Config Validation", "The class configuration doesn't match the team requirements.", LOG_FORMAT_TYPE_FATALERROR);
|
||||
LogMessageFormatted(-1, "Classes", "Config Validation", "Fatal error: The class configuration doesn't match the team requirements.", LOG_FORMAT_TYPE_FATALERROR);
|
||||
}
|
||||
|
||||
// Validate team default requirements.
|
||||
if (!ClassValidateTeamDefaults())
|
||||
{
|
||||
LogMessageFormatted(-1, "Classes", "Config Validation", "Couldn't find a default class for one or more teams. At least one class per team must be marked as default.", LOG_FORMAT_TYPE_FATALERROR);
|
||||
LogMessageFormatted(-1, "Classes", "Config Validation", "Fatal error: Couldn't find a default class for one or more teams. At least one class per team must be marked as default.", LOG_FORMAT_TYPE_FATALERROR);
|
||||
}
|
||||
|
||||
// Cache class data.
|
||||
ClassReloadDataCache();
|
||||
|
||||
// Log summary.
|
||||
if (enablelog)
|
||||
{
|
||||
LogMessageFormatted(-1, "Classes", "Config Validation", "Total: %d | Successful: %d | Unsuccessful: %d", _, ClassCount, ClassCount - failedcount, failedcount);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user