Refactor SWWMHandler profiling routines.

This commit is contained in:
Mari the Deer 2022-02-25 16:51:20 +01:00
commit f6b891c9fe
7 changed files with 104 additions and 74 deletions

View file

@ -270,18 +270,18 @@ extend Class SWWMHandler
override void CheckReplacee( ReplacedEvent e )
{
if ( profiling ) curms = MSTime();
if ( profiling ) ProfileTick();
if ( e.Replacement is 'DSparilHax' )
e.Replacee = 'Sorcerer2';
// drla stuff, needed so boss deaths work
if ( !hasdrlamonsters )
{
if ( profiling ) checkreplacee_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_CHECKREPLACEE);
return;
}
let rep = GetDRLAReplacee(e.Replacement);
if ( rep ) e.Replacee = rep;
if ( profiling ) checkreplacee_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_CHECKREPLACEE);
}
private Class<Actor> GetDRLAReplacement( Class<Actor> a )
@ -549,11 +549,11 @@ extend Class SWWMHandler
override void CheckReplacement( ReplaceEvent e )
{
if ( profiling ) curms = MSTime();
if ( profiling ) ProfileTick();
// respect final replacements
if ( e.IsFinal )
{
if ( profiling ) checkreplacement_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_CHECKREPLACEMENT);
return;
}
// DRLA Monsters stuff
@ -564,7 +564,7 @@ extend Class SWWMHandler
{
e.Replacement = rep;
e.IsFinal = true;
if ( profiling ) checkreplacement_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_CHECKREPLACEMENT);
return;
}
}
@ -576,7 +576,7 @@ extend Class SWWMHandler
{
if ( SWWMUtility.CheckDehackery(e.Replacee) )
{
if ( profiling ) checkreplacement_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_CHECKREPLACEMENT);
return;
}
e.Replacement = 'SWWMHangingKeen';
@ -585,7 +585,7 @@ extend Class SWWMHandler
{
if ( SWWMUtility.CheckDehackery(e.Replacee) )
{
if ( profiling ) checkreplacement_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_CHECKREPLACEMENT);
return;
}
e.Replacement = 'SWWMBossBrain';
@ -594,7 +594,7 @@ extend Class SWWMHandler
{
if ( !equinoxhack && (level.GetChecksum() ~== "3805A661D5C4523AFF7BF86991071043") )
{
if ( profiling ) checkreplacement_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_CHECKREPLACEMENT);
return; // don't replace red key in Equinox MAP13
}
e.Replacement = 'SWWMRedCard';
@ -706,12 +706,12 @@ extend Class SWWMHandler
else if ( e.Replacee is 'ArtiTeleport' ) e.Replacement = 'SafetyTether';
else
{
if ( profiling ) checkreplacement_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_CHECKREPLACEMENT);
return;
}
// this last part is kind of ugly, but it works
// guarantees that OUR replacements are all final
e.IsFinal = true;
if ( profiling ) checkreplacement_ms += MSTime()-curms;
if ( profiling ) ProfileTock(PT_CHECKREPLACEMENT);
}
}