update logger

This commit is contained in:
GenZmeY 2022-07-19 13:28:43 +03:00
parent a390cffbb8
commit de44bfe00f
11 changed files with 111 additions and 58 deletions

View File

@ -1,40 +1,46 @@
class KFGI_Access extends Object
within KFGameInfo;
public function Array<class<KFPawn_Monster> > GetAIClassList()
public function Array<class<KFPawn_Monster> > GetAIClassList(E_LogLevel LogLevel)
{
local Array<class<KFPawn_Monster> > RV;
local class<KFPawn_Monster> KFPMC;
`Log_Trace();
foreach AIClassList(KFPMC)
RV.AddItem(KFPMC);
return RV;
}
public function Array<class<KFPawn_Monster> > GetNonSpawnAIClassList()
public function Array<class<KFPawn_Monster> > GetNonSpawnAIClassList(E_LogLevel LogLevel)
{
local Array<class<KFPawn_Monster> > RV;
local class<KFPawn_Monster> KFPMC;
`Log_Trace();
foreach NonSpawnAIClassList(KFPMC)
RV.AddItem(KFPMC);
return RV;
}
public function Array<class<KFPawn_Monster> > GetAIBossClassList()
public function Array<class<KFPawn_Monster> > GetAIBossClassList(E_LogLevel LogLevel)
{
local Array<class<KFPawn_Monster> > RV;
local class<KFPawn_Monster> KFPMC;
`Log_Trace();
foreach AIBossClassList(KFPMC)
RV.AddItem(KFPMC);
return RV;
}
public function bool IsCustomZed(class<KFPawn_Monster> KFPM)
public function bool IsCustomZed(class<KFPawn_Monster> KFPM, E_LogLevel LogLevel)
{
if (AIClassList.Find(KFPM) != INDEX_NONE) return false;
if (NonSpawnAIClassList.Find(KFPM) != INDEX_NONE) return false;
@ -42,10 +48,12 @@ public function bool IsCustomZed(class<KFPawn_Monster> KFPM)
return true;
}
public function bool IsOriginalAI(class<KFPawn_Monster> KFPM, optional out EAIType AIType)
public function bool IsOriginalAI(class<KFPawn_Monster> KFPM, optional out EAIType AIType, optional E_LogLevel LogLevel = LL_None)
{
local int Type;
`Log_Trace();
Type = AIClassList.Find(KFPM);
if (Type != INDEX_NONE)
{
@ -56,10 +64,12 @@ public function bool IsOriginalAI(class<KFPawn_Monster> KFPM, optional out EAITy
return false;
}
public function bool IsOriginalAIBoss(class<KFPawn_Monster> KFPM, optional out EBossAIType AIType)
public function bool IsOriginalAIBoss(class<KFPawn_Monster> KFPM, optional out EBossAIType AIType, optional E_LogLevel LogLevel = LL_None)
{
local int Type;
`Log_Trace();
Type = AIBossClassList.Find(KFPM);
if (Type != INDEX_NONE)
{
@ -70,16 +80,20 @@ public function bool IsOriginalAIBoss(class<KFPawn_Monster> KFPM, optional out E
return false;
}
public function class<KFPawn_Monster> AITypePawn(EAIType AIType)
public function class<KFPawn_Monster> AITypePawn(EAIType AIType, E_LogLevel LogLevel)
{
`Log_Trace();
if (AIType < AIClassList.Length)
return AIClassList[AIType];
else
return None;
}
public function class<KFPawn_Monster> BossAITypePawn(EBossAIType AIType)
public function class<KFPawn_Monster> BossAITypePawn(EBossAIType AIType, E_LogLevel LogLevel)
{
`Log_Trace();
if (AIType < AIBossClassList.Length)
return AIBossClassList[AIType];
else

View File

@ -13,12 +13,14 @@ var public config float SingleSpawnLimitCycleMultiplier;
var public config int AliveSpawnLimit;
var public config bool bSmoothSpawn;
public static function InitConfig(int Version, int LatestVersion)
public static function InitConfig(int Version, int LatestVersion, E_LogLevel LogLevel)
{
`Log_TraceStatic();
switch (Version)
{
case `NO_CONFIG:
ApplyDefault();
ApplyDefault(LogLevel);
case 3:
default.bSmoothSpawn = false;
@ -32,8 +34,10 @@ public static function InitConfig(int Version, int LatestVersion)
}
}
private static function ApplyDefault()
private static function ApplyDefault(E_LogLevel LogLevel)
{
`Log_TraceStatic();
default.bCyclicalSpawn = true;
default.bShadowSpawn = true;
default.bSmoothSpawn = true;
@ -50,6 +54,8 @@ public static function bool Load(E_LogLevel LogLevel)
{
local bool Errors;
`Log_TraceStatic();
if (default.ZedTotalMultiplier <= 0.f)
{
`Log_Error("ZedTotalMultiplier" @ "(" $ default.ZedTotalMultiplier $ ")" @ "must be greater than 0.0");

View File

@ -5,13 +5,15 @@ class SpawnAtPlayerStart extends Object
var private config Array<String> ZedClass;
var public config Array<String> Map;
public static function InitConfig(int Version, int LatestVersion)
public static function InitConfig(int Version, int LatestVersion, E_LogLevel LogLevel)
{
`Log_TraceStatic();
switch (Version)
{
case `NO_CONFIG:
case 2:
ApplyDefault();
ApplyDefault(LogLevel);
default: break;
}
@ -22,8 +24,10 @@ public static function InitConfig(int Version, int LatestVersion)
}
}
private static function ApplyDefault()
private static function ApplyDefault(E_LogLevel LogLevel)
{
`Log_TraceStatic();
default.ZedClass.Length = 0;
default.ZedClass.AddItem("HL2Monsters.Combine_Strider");
default.ZedClass.AddItem("HL2Monsters.Combine_Gunship");
@ -41,6 +45,8 @@ public static function Array<class<KFPawn_Monster> > Load(E_LogLevel LogLevel)
local String ZedClassTmp;
local int Line;
`Log_TraceStatic();
`Log_Info("Load zeds to spawn at player start:");
foreach default.ZedClass(ZedClassTmp, Line)
{

View File

@ -15,12 +15,14 @@ struct S_SpawnEntryCfg
var public config bool bStopRegularSpawn;
var private config Array<S_SpawnEntryCfg> Spawn;
public static function InitConfig(int Version, int LatestVersion, KFGI_Access KFGIA)
public static function InitConfig(int Version, int LatestVersion, KFGI_Access KFGIA, E_LogLevel LogLevel)
{
`Log_TraceStatic();
switch (Version)
{
case `NO_CONFIG:
ApplyDefault(KFGIA);
ApplyDefault(KFGIA, LogLevel);
default: break;
}
@ -31,12 +33,14 @@ public static function InitConfig(int Version, int LatestVersion, KFGI_Access KF
}
}
private static function ApplyDefault(KFGI_Access KFGIA)
private static function ApplyDefault(KFGI_Access KFGIA, E_LogLevel LogLevel)
{
local S_SpawnEntryCfg SpawnEntry;
local Array<class<KFPawn_Monster> > KFPM_Bosses;
local class<KFPawn_Monster> KFPMC;
`Log_TraceStatic();
default.Spawn.Length = 0;
default.bStopRegularSpawn = true;
@ -46,7 +50,7 @@ private static function ApplyDefault(KFGI_Access KFGIA)
SpawnEntry.SingleSpawnLimit = 1;
SpawnEntry.Delay = 30;
SpawnEntry.Probability = 100;
KFPM_Bosses = KFGIA.GetAIBossClassList();
KFPM_Bosses = KFGIA.GetAIBossClassList(LogLevel);
foreach KFPM_Bosses(KFPMC)
{
SpawnEntry.BossClass = "KFGameContent." $ String(KFPMC);
@ -62,6 +66,8 @@ public static function Array<S_SpawnEntry> Load(E_LogLevel LogLevel)
local int Line;
local bool Errors;
`Log_TraceStatic();
`Log_Info("Load boss waves spawn list:");
foreach default.Spawn(SpawnEntryCfg, Line)
{

View File

@ -20,12 +20,14 @@ delegate int SpawnListSort(S_SpawnEntryCfg A, S_SpawnEntryCfg B)
return A.Wave > B.Wave ? -1 : 0;
}
public static function InitConfig(int Version, int LatestVersion, KFGI_Access KFGIA)
public static function InitConfig(int Version, int LatestVersion, KFGI_Access KFGIA, E_LogLevel LogLevel)
{
`Log_TraceStatic();
switch (Version)
{
case `NO_CONFIG:
ApplyDefault(KFGIA);
ApplyDefault(KFGIA, LogLevel);
default: break;
}
@ -36,12 +38,14 @@ public static function InitConfig(int Version, int LatestVersion, KFGI_Access KF
}
}
private static function ApplyDefault(KFGI_Access KFGIA)
private static function ApplyDefault(KFGI_Access KFGIA, E_LogLevel LogLevel)
{
local S_SpawnEntryCfg SpawnEntry;
local Array<class<KFPawn_Monster> > KFPM_Zeds;
local class<KFPawn_Monster> KFPMC;
`Log_TraceStatic();
default.Spawn.Length = 0;
SpawnEntry.Wave = 0;
@ -51,7 +55,7 @@ private static function ApplyDefault(KFGI_Access KFGIA)
SpawnEntry.Delay = 60;
SpawnEntry.Probability = 100;
KFPM_Zeds = KFGIA.GetAIClassList();
KFPM_Zeds = KFGIA.GetAIClassList(LogLevel);
foreach KFPM_Zeds(KFPMC)
{
++SpawnEntry.Wave;
@ -68,6 +72,8 @@ public static function Array<S_SpawnEntry> Load(E_LogLevel LogLevel)
local int Line;
local bool Errors;
`Log_TraceStatic();
`Log_Info("Load spawn list:");
foreach default.Spawn(SpawnEntryCfg, Line)
{

View File

@ -16,12 +16,14 @@ struct S_SpawnEntryCfg
var public config bool bStopRegularSpawn;
var private config Array<S_SpawnEntryCfg> Spawn;
public static function InitConfig(int Version, int LatestVersion)
public static function InitConfig(int Version, int LatestVersion, E_LogLevel LogLevel)
{
`Log_TraceStatic();
switch (Version)
{
case `NO_CONFIG:
ApplyDefault();
ApplyDefault(LogLevel);
default: break;
}
@ -32,11 +34,13 @@ public static function InitConfig(int Version, int LatestVersion)
}
}
private static function ApplyDefault()
private static function ApplyDefault(E_LogLevel LogLevel)
{
local S_SpawnEntryCfg SpawnEntry;
local EAIType AIType;
`Log_TraceStatic();
default.bStopRegularSpawn = true;
default.Spawn.Length = 0;
SpawnEntry.ZedClass = "SomePackage.SomeClass";
@ -60,6 +64,8 @@ public static function Array<S_SpawnEntry> Load(KFGameInfo_Endless KFGIE, E_LogL
local int Line;
local bool Errors;
`Log_TraceStatic();
if (KFGIE == None)
{
`Log_Info("Not Endless mode, skip loading special waves");

View File

@ -73,7 +73,7 @@ public simulated function bool SafeDestroy()
public event PreBeginPlay()
{
`Log_Trace(`Location);
`Log_Trace();
if (WorldInfo.NetMode == NM_Client)
{
@ -87,7 +87,7 @@ public event PreBeginPlay()
public event PostBeginPlay()
{
`Log_Trace(`Location);
`Log_Trace();
if (bPendingDelete || bDeleteMe) return;
@ -104,11 +104,11 @@ private function InitConfig()
SaveConfig();
}
CfgSpawn.static.InitConfig(Version, LatestVersion);
CfgSpawnAtPlayerStart.static.InitConfig(Version, LatestVersion);
CfgSpawnListRW.static.InitConfig(Version, LatestVersion, KFGIA);
CfgSpawnListBW.static.InitConfig(Version, LatestVersion, KFGIA);
CfgSpawnListSW.static.InitConfig(Version, LatestVersion);
CfgSpawn.static.InitConfig(Version, LatestVersion, LogLevel);
CfgSpawnAtPlayerStart.static.InitConfig(Version, LatestVersion, LogLevel);
CfgSpawnListRW.static.InitConfig(Version, LatestVersion, KFGIA, LogLevel);
CfgSpawnListBW.static.InitConfig(Version, LatestVersion, KFGIA, LogLevel);
CfgSpawnListSW.static.InitConfig(Version, LatestVersion, LogLevel);
switch (Version)
{
@ -148,7 +148,7 @@ private function Init()
local S_SpawnEntry SE;
local String CurrentMap;
`Log_Trace(`Location);
`Log_Trace();
KFGIS = KFGameInfo_Survival(WorldInfo.Game);
if (KFGIS == None)
@ -220,6 +220,8 @@ private function PreloadContent()
{
local class<KFPawn_Monster> PawnClass;
`Log_Trace();
ExtractCustomZedsFromSpawnList(SpawnListRW, CustomZeds);
ExtractCustomZedsFromSpawnList(SpawnListBW, CustomZeds);
ExtractCustomZedsFromSpawnList(SpawnListSW, CustomZeds);
@ -235,10 +237,12 @@ private function ExtractCustomZedsFromSpawnList(Array<S_SpawnEntry> SpawnList, o
{
local S_SpawnEntry SE;
`Log_Trace();
foreach SpawnList(SE)
{
if (Out.Find(SE.ZedClass) == INDEX_NONE
&& KFGIA.IsCustomZed(SE.ZedClass))
&& KFGIA.IsCustomZed(SE.ZedClass, LogLevel))
{
Out.AddItem(SE.ZedClass);
}
@ -251,7 +255,7 @@ private function SpawnTimer()
local int Index;
local float Threshold;
`Log_Trace(`Location);
`Log_Trace();
if (KFGIS.WaveNum != 0 && CurrentWave < KFGIS.WaveNum)
{
@ -323,7 +327,7 @@ private function SetupWave()
local S_SpawnEntry SE;
local EAIType SWType;
`Log_Trace(`Location);
`Log_Trace();
if (CfgSpawn.default.bCyclicalSpawn && KFGIS.WaveNum > 1 && KFGIS.WaveNum == CycleWaveShift + CycleWaveSize * CurrentCycle)
{
@ -350,7 +354,7 @@ private function SetupWave()
if (KFGIS.MyKFGRI.IsBossWave())
{
CurrentBossClass = KFGIA.BossAITypePawn(EBossAIType(KFGIS.MyKFGRI.BossIndex));
CurrentBossClass = KFGIA.BossAITypePawn(EBossAIType(KFGIS.MyKFGRI.BossIndex), LogLevel);
if (CurrentBossClass == None)
{
`Log_Error("Can't determine boss class. Boss index:" @ KFGIS.MyKFGRI.BossIndex);
@ -432,7 +436,7 @@ private function AdjustSpawnList(out Array<S_SpawnEntry> List)
local float PawnTotalF, PawnLimitF;
local int ZedNameMaxLength;
`Log_Trace(`Location);
`Log_Trace();
Cycle = float(CurrentCycle);
Players = float(PlayerCount());
@ -487,7 +491,7 @@ private function SpawnTimerLogger(bool Stop, optional String Comment)
{
local String Message;
`Log_Trace(`Location);
`Log_Trace();
if (Stop)
Message = "Stop spawn";
@ -511,7 +515,7 @@ private function SpawnEntry(out Array<S_SpawnEntry> SpawnList, int Index)
local String Action, Comment, NextSpawn;
local bool SpawnAtPlayerStart;
`Log_Trace(`Location);
`Log_Trace();
SE = SpawnList[Index];
@ -628,7 +632,7 @@ private function int PlayerCount()
local int HumanPlayers;
local KFOnlineGameSettings KFGameSettings;
`Log_Trace(`Location);
`Log_Trace();
if (KFGIS.PlayfabInter != None && KFGIS.PlayfabInter.GetGameSettings() != None)
{
@ -653,7 +657,7 @@ private function Vector PlayerStartLocation()
{
local PlayerController PC;
`Log_Trace(`Location);
`Log_Trace();
foreach WorldInfo.AllControllers(class'PlayerController', PC)
return KFGIS.FindPlayerStart(PC, 0).Location;
@ -672,7 +676,7 @@ private function int SpawnZed(class<KFPawn_Monster> ZedClass, int PawnCount, opt
local int Failed, Spawned;
local int Index;
`Log_Trace(`Location);
`Log_Trace();
PlayerStart = PlayerStartLocation();
if (SpawnAtPlayerStart)
@ -750,14 +754,14 @@ private function int SpawnZed(class<KFPawn_Monster> ZedClass, int PawnCount, opt
public function NotifyLogin(Controller C)
{
`Log_Trace(`Location);
`Log_Trace();
CreateRepLink(C);
}
public function NotifyLogout(Controller C)
{
`Log_Trace(`Location);
`Log_Trace();
DestroyRepLink(C);
}
@ -766,7 +770,7 @@ public function bool CreateRepLink(Controller C)
{
local ZedSpawnerRepLink RepLink;
`Log_Trace(`Location);
`Log_Trace();
if (C == None) return false;
@ -789,7 +793,7 @@ public function bool DestroyRepLink(Controller C)
{
local ZedSpawnerRepLink RepLink;
`Log_Trace(`Location);
`Log_Trace();
if (C == None) return false;

View File

@ -18,7 +18,7 @@ public simulated function bool SafeDestroy()
public reliable client function ClientSync(class<KFPawn_Monster> CustomZed)
{
`Log_Trace(`Location);
`Log_Trace();
`Log_Debug("Received:" @ CustomZed);
CustomZeds.AddItem(CustomZed);
@ -29,7 +29,7 @@ public reliable client function SyncFinished()
{
local class<KFPawn_Monster> CustomZed;
`Log_Trace(`Location);
`Log_Trace();
foreach CustomZeds(CustomZed)
{
@ -42,7 +42,7 @@ public reliable client function SyncFinished()
public reliable server function ServerSync()
{
`Log_Trace(`Location);
`Log_Trace();
if (bPendingDelete || bDeleteMe) return;

View File

@ -4,6 +4,7 @@ class _Logger extends Object
enum E_LogLevel
{
LL_WrongLevel,
LL_None,
LL_Fatal,
LL_Error,
LL_Warning,

View File

@ -1,6 +1,8 @@
// Logger
`define Log_Tag 'ZedSpawner'
`define LocationStatic "`{ClassName}::" $ GetFuncName()
`define Log_Base(msg, cond) `log(`msg `if(`cond), `cond`{endif}, `Log_Tag)
`define Log_Fatal(msg) `log("FATAL:" @ `msg, (LogLevel >= LL_Fatal), `Log_Tag)
@ -8,4 +10,6 @@
`define Log_Warn(msg) `log("WARN:" @ `msg, (LogLevel >= LL_Warning), `Log_Tag)
`define Log_Info(msg) `log("INFO:" @ `msg, (LogLevel >= LL_Info), `Log_Tag)
`define Log_Debug(msg) `log("DEBUG:" @ `msg, (LogLevel >= LL_Debug), `Log_Tag)
`define Log_Trace(msg) `log("TRACE:" @ `msg, (LogLevel >= LL_Trace), `Log_Tag)
`define Log_Trace(msg) `log("TRACE:" @ `Location `if(`msg) @ `msg`{endif}, (LogLevel >= LL_Trace), `Log_Tag)
`define Log_TraceStatic(msg) `log("TRACE:" @ `LocationStatic `if(`msg) @ `msg`{endif}, (LogLevel >= LL_Trace), `Log_Tag)