Began adding cvar descriptions, recoded logging module, fixed zmenu display bug, removed include line for anticamp until recoded.

This commit is contained in:
Greyscale
2009-05-14 09:32:01 +02:00
parent ef5dd66890
commit 055e89d64a
29 changed files with 588 additions and 811 deletions

View File

@ -92,10 +92,20 @@ public Action:Command_ClassDump(client, argc)
// Dump the specified cache.
ReplyToCommand(client, "DUMPING CACHE: \"%s\" (%d classes total)\n========================================\n", type, ClassCount);
ClassDumpData(index, cachetype, buffer, sizeof(buffer));
ZR_ReplyToCommandLong(client, buffer);
// Print all data to client.
decl String:partbuffer[1024];
new pos;
new cellswritten = 1; // Initialize for the loop.
while (cellswritten)
{
cellswritten = strcopy(partbuffer, sizeof(partbuffer), buffer[pos]);
ReplyToCommand(client, partbuffer);
pos += cellswritten;
}
return Plugin_Handled;
}
/**

View File

@ -94,12 +94,12 @@ ClassOnClientSpawn(client)
// Mark zombie class as selected.
ClassSelected[client][ZR_CLASS_TEAM_ZOMBIES] = randomzombie;
ClassGetName(randomzombie, classname, sizeof(classname), ZR_CLASS_TEAM_ZOMBIES);
ZR_PrintToChat(client, "Classes random assignment", classname);
TranslationPrintToChat(client, "Classes random assignment", classname);
// Mark human class as selected.
ClassSelected[client][ZR_CLASS_TEAM_HUMANS] = randomhuman;
ClassGetName(randomhuman, classname, sizeof(classname), ZR_CLASS_TEAM_HUMANS);
ZR_PrintToChat(client, "Classes random assignment", classname);
TranslationPrintToChat(client, "Classes random assignment", classname);
// Update player cache with the human class data, and apply it.
ClassReloadPlayerCache(client, randomhuman);

View File

@ -81,7 +81,7 @@ ClassOverlayOnClientSpawn(client)
decl String:togglecmds[CLASSOVERLAY_TOGGLE_MAX_CMDS * CLASSOVERLAY_TOGGLE_MAX_LENGTH];
GetConVarString(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLECMDS], togglecmds, sizeof(togglecmds));
ZR_HudHint(client, "Classes overlay toggle", togglecmds);
TranslationPrintHUDText(client, "Classes overlay toggle", togglecmds);
}
}
@ -103,7 +103,7 @@ ClassOverlayOnClientInfected(client)
decl String:togglecmds[CLASSOVERLAY_TOGGLE_MAX_CMDS * CLASSOVERLAY_TOGGLE_MAX_LENGTH];
GetConVarString(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLECMDS], togglecmds, sizeof(togglecmds));
ZR_PrintCenterText(client, "Classes overlay toggle", togglecmds);
TranslationPrintCenterText(client, "Classes overlay toggle", togglecmds);
}
}

View File

@ -674,9 +674,6 @@ 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)
{
@ -740,20 +737,13 @@ ClassGetDefaultSpawnClass(teamid, cachetype = ZR_CLASS_CACHE_MODIFIED)
// in the specified team, and log a warning.
classindex = ClassGetFirstClass(teamid, _, cachetype);
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);
}
LogPrintToLog(LOG_FORMAT_TYPE_NORMAL, "Classes", "Default Spawn Class", "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);
// Validate the new index.
if (ClassValidateIndex(classindex))
{
// Log a warning.
if (enablelog)
{
LogMessageFormatted(-1, "Classes", "DefaultSpawnClass", "Warning: The default class name \"%s\" does not exist or matches the team ID.", _, classname);
}
LogPrintToLog(LOG_FORMAT_TYPE_NORMAL, "Classes", "Default Spawn Class", "Warning: The default class name \"%s\" does not exist or matches the team ID.", classname);
return classindex;
}
else

View File

@ -322,9 +322,6 @@ new ClassPlayerNextAdminClass[MAXPLAYERS + 1];
*/
ClassLoad()
{
// Initialize log boolean.
new bool:enablelog = LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_CLASSES);
// Make sure kvClassData is ready to use.
if (kvClassData != INVALID_HANDLE)
{
@ -339,16 +336,12 @@ ClassLoad()
// If file doesn't exist, then log and stop.
if (!exists)
{
LogMessageFormatted(-1, "Classes", "Load", "Fatal error: Missing playerclasses config file \"%s\"", LOG_FORMAT_TYPE_FATALERROR, pathclasses);
LogPrintToLog(LOG_FORMAT_TYPE_FATALERROR, "Classes", "Config Validation", "Fatal Error: Missing playerclasses config file \"%s\"", pathclasses);
return;
}
// Log what class file that is loaded.
if (enablelog)
{
LogMessageFormatted(-1, "Classes", "Load", "Loading classes from file \"%s\".", LOG_FORMAT_TYPE_SIMPLE, pathclasses);
}
LogPrintToLog(LOG_FORMAT_TYPE_NORMAL, "Classes", "Config Validation", "Loading classes from file \"%s\".", pathclasses);
// Put file data into memory.
FileToKeyValues(kvClassData, pathclasses);
@ -357,7 +350,7 @@ ClassLoad()
KvRewind(kvClassData);
if (!KvGotoFirstSubKey(kvClassData))
{
LogMessageFormatted(-1, "Classes", "Load", "Fatal error: Can't find any classes in \"%s\"", LOG_FORMAT_TYPE_FATALERROR, pathclasses);
LogPrintToLog(LOG_FORMAT_TYPE_FATALERROR, "Classes", "Config Validation", "Fatal Error: Can't find any classes in \"%s\"", pathclasses);
}
decl String:name[64];
@ -375,10 +368,7 @@ ClassLoad()
if (ClassCount > ZR_CLASS_MAX)
{
// Maximum classes reached. Write a warning and exit the loop.
if (enablelog)
{
LogMessageFormatted(-1, "Classes", "Load", "Warning: Maximum classes reached (%d). Skipping other classes.", _, ZR_CLASS_MAX + 1);
}
LogPrintToLog(LOG_FORMAT_TYPE_NORMAL, "Classes", "Config Validation", "Warning: Maximum classes reached (%d). Skipping other classes.", ZR_CLASS_MAX + 1);
break;
}
@ -439,10 +429,7 @@ ClassLoad()
// There's one or more invalid class attributes. Disable the class
// and log an error message.
ClassData[ClassCount][class_enabled] = false;
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);
}
LogPrintToLog(LOG_FORMAT_TYPE_ERROR, "Classes", "Config Validation", "Warning: Invalid class at index %d, disabled class. Class error flags: %d.", ClassCount, ClassErrorFlags);
failedcount++;
}
@ -454,13 +441,13 @@ ClassLoad()
// Validate team requirements.
if (!ClassValidateTeamRequirements())
{
LogMessageFormatted(-1, "Classes", "Config Validation", "Fatal error: The class configuration doesn't match the team requirements.", LOG_FORMAT_TYPE_FATALERROR);
LogPrintToLog(LOG_FORMAT_TYPE_FATALERROR, "Classes", "Config Validation", "Fatal Error: The class configuration doesn't match the team requirements.");
}
// Validate team default requirements.
if (!ClassValidateTeamDefaults())
{
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);
LogPrintToLog(LOG_FORMAT_TYPE_FATALERROR, "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.");
}
// Cache class data.
@ -470,10 +457,7 @@ ClassLoad()
ClassValidated = true;
// Log summary.
if (enablelog)
{
LogMessageFormatted(-1, "Classes", "Config Validation", "Total: %d | Successful: %d | Unsuccessful: %d", _, ClassCount, ClassCount - failedcount, failedcount);
}
LogPrintToLog(LOG_FORMAT_TYPE_NORMAL, "Classes", "Config Validation", "Total: %d | Successful: %d | Unsuccessful: %d", ClassCount, ClassCount - failedcount, failedcount);
}
@ -657,10 +641,7 @@ ClassClientSetDefaultIndexes(client = -1)
{
// Invalid class index. Fall back to default class in class config and
// log a warning.
if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_CLASSES))
{
LogMessageFormatted(-1, "Classes", "SetDefaultIndexes", "Warning: Failed to get default zombie class, falling back to default class in class config. Check spelling in \"zr_classes_default_zombie\".", LOG_FORMAT_TYPE_ERROR);
}
LogPrintToLog(LOG_FORMAT_TYPE_ERROR, "Classes", "Set Default Indexes", "Warning: Failed to get default zombie class, falling back to default class in class config. Check spelling in \"zr_classes_default_zombie\".");
// Use default class.
zombieindex = ClassGetDefaultClass(ZR_CLASS_TEAM_ZOMBIES);
@ -671,10 +652,7 @@ ClassClientSetDefaultIndexes(client = -1)
{
// Invalid class index. Fall back to default class in class config and
// log a warning.
if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_CLASSES))
{
LogMessageFormatted(-1, "Classes", "SetDefaultIndexes", "Warning: Failed to get default human class, falling back to default class in class config. Check spelling in \"zr_classes_default_human\".", LOG_FORMAT_TYPE_ERROR);
}
LogPrintToLog(LOG_FORMAT_TYPE_ERROR, "Classes", "Set Default Indexes", "Warning: Failed to get default human class, falling back to default class in class config. Check spelling in \"zr_classes_default_human\".");
// Use default class.
humanindex = ClassGetDefaultClass(ZR_CLASS_TEAM_HUMANS);