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

@ -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);