New log features, class attribute and minior changes. See details.

Made new log CVAR for overriding filters on error log types: zr_log_error_override. If this is on, errors are always logged, independent of flags and filters. Now all non-error logging can be completely disabled without complex flags or filtering.
Made new class attribute ("has_napalm", ClassGetHasNapalm) that specifies if the class have or can trhow napalm grenades. Implemented usage in napalm module.
Added team id validation in class attributes.
Improved formatting of log messages in cvars module.
Known issue: Commands in config for adding modules to log filter are executed too late. Otherwise the module filter works fine.
This commit is contained in:
richard 2009-06-14 19:10:30 +02:00
parent 0a72dc2100
commit 4b66f688ab
11 changed files with 102 additions and 28 deletions

View File

@ -69,6 +69,7 @@
"fov" "90"
// Effects
"has_napalm" "0"
"napalm_time" "10.0"
// Player behaviour
@ -110,6 +111,7 @@
"fov" "90"
// Effects
"has_napalm" "0"
"napalm_time" "5.0"
// Player behaviour
@ -151,6 +153,7 @@
"fov" "90"
// Effects
"has_napalm" "0"
"napalm_time" "15.0"
// Player behaviour
@ -192,6 +195,7 @@
"fov" "90"
// Effects
"has_napalm" "0"
"napalm_time" "20.0"
// Player behaviour
@ -239,6 +243,7 @@
"fov" "90"
// Effects
"has_napalm" "1"
"napalm_time" "0.0"
// Player behaviour
@ -280,6 +285,7 @@
"fov" "90"
// Effects
"has_napalm" "0"
"napalm_time" "0.0"
// Player behaviour
@ -321,6 +327,7 @@
"fov" "90"
// Effects
"has_napalm" "1"
"napalm_time" "0.0"
// Player behaviour

View File

@ -112,9 +112,9 @@ public bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max)
public OnPluginStart()
{
// Forward event to modules.
LogInit(); // Doesn't depend on CVARs.
TranslationInit();
CvarsInit();
LogInit();
ToolsInit();
CommandsInit();
WeaponsInit();

View File

@ -192,7 +192,7 @@ ConfigOnCommandsCreate()
}
/**
* Load plugin configs.
* Load plugin configs. Executes map configs.
*/
ConfigLoad()
{

View File

@ -44,6 +44,7 @@ enum CvarsList
Handle:CVAR_LOG_FLAGS,
Handle:CVAR_LOG_MODULE_FILTER,
Handle:CVAR_LOG_IGNORE_CONSOLE,
Handle:CVAR_LOG_ERROR_OVERRIDE,
Handle:CVAR_LOG_PRINT_ADMINS,
Handle:CVAR_LOG_PRINT_CHAT,
Handle:CVAR_CONFIG_PATH_MODELS,
@ -207,6 +208,7 @@ CvarsCreate()
g_hCvarsList[CVAR_LOG_FLAGS] = CreateConVar("zr_log_flags", "3", "A bit field that specify what event types to log. See logging section (3.3) in manual for details.");
g_hCvarsList[CVAR_LOG_MODULE_FILTER] = CreateConVar("zr_log_module_filter", "0", "Enable module filtering. Only log events from listed modules will be logged.");
g_hCvarsList[CVAR_LOG_IGNORE_CONSOLE] = CreateConVar("zr_log_ignore_console", "1", "Don't log events triggered by console commands that are executed by the console itself, like commands in configs. Enable this command to avoid spamming logs with events like weapon restrictions.");
g_hCvarsList[CVAR_LOG_ERROR_OVERRIDE] = CreateConVar("zr_log_error_override", "1", "Always log error messages. Overrides module filter and logging flags.");
g_hCvarsList[CVAR_LOG_PRINT_ADMINS] = CreateConVar("zr_log_print_admins", "0", "Print log events to admin chat in addition to the log file.");
g_hCvarsList[CVAR_LOG_PRINT_CHAT] = CreateConVar("zr_log_print_chat", "0", "Print log events to public chat in addition to the log file.");
@ -518,7 +520,7 @@ public CvarsHookLocked(Handle:cvar, const String:oldvalue[], const String:newval
SetConVarInt(g_hAutoTeamBalance, CVARS_AUTOTEAMBALANCE_LOCKED);
// If log flag check fails, then don't log.
LogEvent(false, LogType_Normal, LOG_CORE_EVENTS, LogModule_Cvars, "Cvar Locked", "Cvar \"mp_autoteambalance\" was reverted back to \"CVARS_AUTOTEAMBALANCE_LOCKED\".");
LogEvent(false, LogType_Normal, LOG_CORE_EVENTS, LogModule_Cvars, "Cvar Locked", "Cvar \"mp_autoteambalance\" was reverted back to %d.", CVARS_AUTOTEAMBALANCE_LOCKED);
}
// If cvar is mp_limitteams, then continue.
else if (cvar == g_hLimitTeams)
@ -533,7 +535,7 @@ public CvarsHookLocked(Handle:cvar, const String:oldvalue[], const String:newval
SetConVarInt(g_hLimitTeams, CVARS_LIMITTEAMS_LOCKED);
// If log flag check fails, then don't log.
LogEvent(false, LogType_Normal, LOG_CORE_EVENTS, LogModule_Cvars, "Cvar Locked", "Cvar \"mp_limitteams\" was reverted back to \"CVARS_LIMITTEAMS_LOCKED\".");
LogEvent(false, LogType_Normal, LOG_CORE_EVENTS, LogModule_Cvars, "Cvar Locked", "Cvar \"mp_limitteams\" was reverted back to %d.", CVARS_LIMITTEAMS_LOCKED);
}
}

View File

@ -230,7 +230,7 @@ public Action:EventPlayerHurt(Handle:event, const String:name[], bool:dontBroadc
InfectOnClientHurt(index, attacker, weapon);
SEffectsOnClientHurt(index);
KnockbackOnClientHurt(index, attacker, weapon, hitgroup, dmg_health);
NapalmOnClientHurt(index, weapon);
NapalmOnClientHurt(index, attacker, weapon);
ZHPOnClientHurt(index);
}
@ -300,9 +300,10 @@ public Action:EventPlayerJump(Handle:event, const String:name[], bool:dontBroadc
public Action:EventWeaponFire(Handle:event, const String:name[], bool:dontBroadcast)
{
// Get all required event info.
new index = GetClientOfUserId(GetEventInt(event, "userid"));
decl String:weapon[32];
GetEventString(event, "weapon", weapon, sizeof(weapon));
// Forward event to modules.
NapalmOnWeaponFire(weapon);
NapalmOnWeaponFire(index, weapon);
}

View File

@ -258,8 +258,8 @@ bool:LogCheckModuleFilter(LogModules:module)
*/
LogEvent(bool:isConsole = false, LogTypes:logType = LogType_Normal, eventType = LOG_CORE_EVENTS, LogModules:module, const String:description[], const String:text[], any:...)
{
// Only do filter and flag checks if the log type isn't a fatal error.
if (logType != LogType_Fatal)
// Check filter overrides. Always log fatal errors, and check error override setting on error log types.
if ((logType != LogType_Fatal && logType != LogType_Error) || (logType == LogType_Error && !GetConVarBool(g_hCvarsList[CVAR_LOG_ERROR_OVERRIDE])))
{
// Check if logging is disabled.
if (!GetConVarBool(g_hCvarsList[CVAR_LOG]))
@ -333,6 +333,7 @@ LogEvent(bool:isConsole = false, LogTypes:logType = LogType_Normal, eventType =
// Check if printing log events to public chat is enabled.
if (GetConVarBool(g_hCvarsList[CVAR_LOG_PRINT_CHAT]))
{
// Print text to public chat.
TranslationPrintToChatAll(false, false, "Literal text", logbuffer);
}
}

View File

@ -34,9 +34,10 @@
* Client has been hurt.
*
* @param client The client index.
* @param attacker The attacker index.
* @param weapon The weapon name.
*/
NapalmOnClientHurt(client, const String:weapon[])
NapalmOnClientHurt(client, attacker, const String:weapon[])
{
// If player isn't a zombie, then stop.
if (!InfectIsClientInfected(client))
@ -51,6 +52,12 @@ NapalmOnClientHurt(client, const String:weapon[])
return;
}
// If the attacker can't throw napalm grenades, then stop.
if (ClassGetHasNapalm(attacker))
{
return;
}
// If weapon is a grenade, then ignite player.
if (StrEqual(weapon, "hegrenade", false))
{
@ -76,9 +83,10 @@ NapalmOnClientDeath(client)
/**
* Weapon has been fired.
*
* @param weapon The weapon name.
* @param client The client index.
* @param weapon The weapon name.
*/
NapalmOnWeaponFire(const String:weapon[])
NapalmOnWeaponFire(client, const String:weapon[])
{
// If grenade fire is disabled, then stop.
new bool:napalmignite = GetConVarBool(g_hCvarsList[CVAR_NAPALM_IGNITE]);
@ -87,11 +95,11 @@ NapalmOnWeaponFire(const String:weapon[])
return;
}
// If human class can't throw napalm grenades, then stop. (TODO)
/*if ()
// If human class can't throw napalm grenades, then stop.
if (!ClassGetHasNapalm(client))
{
return;
}*/
}
// If weapon isn't a grenade, then stop.
if (!StrEqual(weapon, "hegrenade", false))

View File

@ -461,6 +461,38 @@ stock ClassGetFOV(index, cachetype = ZR_CLASS_CACHE_PLAYER)
* ------------------------------------
*/
/**
* Gets the napalm setting from the specified class.
*
* @param index Index of the class in a class cache or a client index,
* depending on the cache type specified.
* @param cachetype Optional. Specifies what class cache to read from. Options:
* ZR_CLASS_CACHE_ORIGINAL - Unchanced class data.
* ZR_CLASS_CACHE_MODIFIED - Changed/newest class data.
* ZR_CLASS_CACHE_PLAYER (default) - Player cache. If this one
* is used, index will be used as a client index.
* @return True if the class has napalm grenades, false otherwise.
*/
stock bool:ClassGetHasNapalm(index, cachetype = ZR_CLASS_CACHE_PLAYER)
{
switch (cachetype)
{
case ZR_CLASS_CACHE_ORIGINAL:
{
return ClassData[index][class_has_napalm];
}
case ZR_CLASS_CACHE_MODIFIED:
{
return ClassDataCache[index][class_has_napalm];
}
case ZR_CLASS_CACHE_PLAYER:
{
return ClassPlayerCache[index][class_has_napalm];
}
}
return false;
}
/**
* Gets the napalm grenades time from the specified class.
*

View File

@ -396,6 +396,11 @@ stock bool:ClassModifyBoolean(classindex, attributeflag, bool:value)
ClassDataCache[classindex][class_no_fall_damage] = bool:value;
return true;
}
case ZR_CLASS_FLAG_HAS_NAPALM:
{
ClassDataCache[classindex][class_has_napalm] = bool:value;
return true;
}
}
// Invalid flag or multiple flags combined.

View File

@ -106,6 +106,12 @@ stock ClassValidateAttributes(classindex)
new flags;
// Team.
if (ClassData[classindex][class_team] < ZR_CLASS_TEAM_MIN || ClassData[classindex][class_team] > ZR_CLASS_TEAM_MAX)
{
flags += ZR_CLASS_FLAG_TEAM;
}
// Name.
if (strlen(ClassData[classindex][class_name]) < ZR_CLASS_NAME_MIN)
{
@ -116,7 +122,7 @@ stock ClassValidateAttributes(classindex)
decl String:name[64];
strcopy(name, sizeof(name), ClassData[classindex][class_name]);
// Check for reserved name keyworks.
// Check for reserved name keyworks. These aren't allowed as names.
if (StrEqual(name, "all", false) ||
StrEqual(name, "humans", false) ||
StrEqual(name, "zombies", false) ||

View File

@ -121,6 +121,7 @@
#define ZR_CLASS_DEFAULT_OVERLAY_PATH "overlays/zr/zvision"
#define ZR_CLASS_DEFAULT_NVGS true
#define ZR_CLASS_DEFAULT_FOV 90
#define ZR_CLASS_DEFAULT_HAS_NAPALM 1
#define ZR_CLASS_DEFAULT_NAPALM_TIME 10.0
#define ZR_CLASS_DEFAULT_IMMUNITY_MODE ZR_CLASS_IMMUNITY_DISABLED
#define ZR_CLASS_DEFAULT_IMMUNITY_AMOUNT 0.0
@ -141,6 +142,8 @@
/**
* @section Attribute limit values. Used when validating.
*/
#define ZR_CLASS_TEAM_MIN 0
#define ZR_CLASS_TEAM_MAX 2
#define ZR_CLASS_NAME_MIN 1
#define ZR_CLASS_DESCRIPTION_MIN 1
/** Model path is checked for existance. */
@ -192,19 +195,20 @@
#define ZR_CLASS_FLAG_OVERLAY_PATH (1<<9)
#define ZR_CLASS_FLAG_NVGS (1<<10)
#define ZR_CLASS_FLAG_FOV (1<<11)
#define ZR_CLASS_FLAG_NAPALM_TIME (1<<12)
#define ZR_CLASS_FLAG_IMMUNITY_MODE (1<<13)
#define ZR_CLASS_FLAG_IMMUNITY_AMOUNT (1<<14)
#define ZR_CLASS_FLAG_NO_FALL_DAMAGE (1<<15)
#define ZR_CLASS_FLAG_HEALTH (1<<16)
#define ZR_CLASS_FLAG_HEALTH_REGEN_INTERVAL (1<<17)
#define ZR_CLASS_FLAG_HEALTH_REGEN_AMOUNT (1<<18)
#define ZR_CLASS_FLAG_HEALTH_INFECT_GAIN (1<<19)
#define ZR_CLASS_FLAG_KILL_BONUS (1<<20)
#define ZR_CLASS_FLAG_SPEED (1<<21)
#define ZR_CLASS_FLAG_KNOCKBACK (1<<22)
#define ZR_CLASS_FLAG_JUMP_HEIGHT (1<<23)
#define ZR_CLASS_FLAG_JUMP_DISTANCE (1<<24)
#define ZR_CLASS_FLAG_HAS_NAPALM (1<<12)
#define ZR_CLASS_FLAG_NAPALM_TIME (1<<13)
#define ZR_CLASS_FLAG_IMMUNITY_MODE (1<<14)
#define ZR_CLASS_FLAG_IMMUNITY_AMOUNT (1<<15)
#define ZR_CLASS_FLAG_NO_FALL_DAMAGE (1<<16)
#define ZR_CLASS_FLAG_HEALTH (1<<17)
#define ZR_CLASS_FLAG_HEALTH_REGEN_INTERVAL (1<<18)
#define ZR_CLASS_FLAG_HEALTH_REGEN_AMOUNT (1<<19)
#define ZR_CLASS_FLAG_HEALTH_INFECT_GAIN (1<<20)
#define ZR_CLASS_FLAG_KILL_BONUS (1<<21)
#define ZR_CLASS_FLAG_SPEED (1<<22)
#define ZR_CLASS_FLAG_KNOCKBACK (1<<23)
#define ZR_CLASS_FLAG_JUMP_HEIGHT (1<<24)
#define ZR_CLASS_FLAG_JUMP_DISTANCE (1<<25)
/**
* @endsection
*/
@ -234,6 +238,7 @@ enum ClassAttributes
class_fov,
/* Effects */
bool:class_has_napalm,
Float:class_napalm_time,
/* Player behaviour */
@ -420,6 +425,7 @@ ClassLoad()
/* Effects */
ClassData[ClassCount][class_has_napalm] = bool:KvGetNum(kvClassData, "have_napalm", ZR_CLASS_DEFAULT_HAS_NAPALM);
ClassData[ClassCount][class_napalm_time] = KvGetFloat(kvClassData, "napalm_time", ZR_CLASS_DEFAULT_NAPALM_TIME);
@ -528,6 +534,7 @@ bool:ClassReloadDataCache()
ClassDataCache[classindex][class_fov] = ClassData[classindex][class_fov];
/* Effects */
ClassDataCache[classindex][class_has_napalm] = ClassData[classindex][class_has_napalm];
ClassDataCache[classindex][class_napalm_time] = ClassData[classindex][class_napalm_time];
/* Player behaviour */
@ -591,6 +598,7 @@ bool:ClassReloadPlayerCache(client, classindex, cachetype = ZR_CLASS_CACHE_MODIF
ClassPlayerCache[client][class_fov] = ClassData[classindex][class_fov];
/* Effects */
ClassPlayerCache[client][class_has_napalm] = ClassData[classindex][class_has_napalm];
ClassPlayerCache[client][class_napalm_time] = ClassData[classindex][class_napalm_time];
/* Player behaviour */
@ -628,6 +636,7 @@ bool:ClassReloadPlayerCache(client, classindex, cachetype = ZR_CLASS_CACHE_MODIF
ClassPlayerCache[client][class_fov] = ClassDataCache[classindex][class_fov];
/* Effects */
ClassPlayerCache[client][class_has_napalm] = ClassDataCache[classindex][class_has_napalm];
ClassPlayerCache[client][class_napalm_time] = ClassDataCache[classindex][class_napalm_time];
/* Player behaviour */
@ -794,6 +803,9 @@ ClassDumpData(index, cachetype, String:buffer[], maxlen)
Format(attribute, sizeof(attribute), "fov: \"%d\"\n", ClassGetFOV(index, cachetype));
cellcount += StrCat(buffer, maxlen, attribute);
Format(attribute, sizeof(attribute), "has_napalm: \"%d\"\n", ClassGetHasNapalm(index, cachetype));
cellcount += StrCat(buffer, maxlen, attribute);
Format(attribute, sizeof(attribute), "napalm_time: \"%f\"\n", ClassGetNapalmTime(index, cachetype));
cellcount += StrCat(buffer, maxlen, attribute);