Service caching.
This commit is contained in:
parent
afd9c9ebf0
commit
1969eff7d9
4 changed files with 26 additions and 27 deletions
|
|
@ -1,3 +1,3 @@
|
|||
[default]
|
||||
SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r179 \cu(Fri 15 Jul 08:05:08 CEST 2022)\c-";
|
||||
SWWM_SHORTVER="\cw1.3pre r179 \cu(2022-07-15 08:05:08)\c-";
|
||||
SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r180 \cu(Fri 15 Jul 09:32:16 CEST 2022)\c-";
|
||||
SWWM_SHORTVER="\cw1.3pre r180 \cu(2022-07-15 09:32:16)\c-";
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ Class SWWMHandler : EventHandler
|
|||
int iwantdie;
|
||||
int indoomvacation;
|
||||
int inultdoom2;
|
||||
bool funtagsv;
|
||||
Array<Service> funtagsv, mergemonstersv;
|
||||
|
||||
// for checkreplacement
|
||||
bool hasdrlamonsters;
|
||||
|
|
@ -91,9 +91,14 @@ Class SWWMHandler : EventHandler
|
|||
bludtypes.Push(list[i]);
|
||||
}
|
||||
}
|
||||
// check if fun tag services actually exist (can reduce overhead severely on map load if they don't, due to combat tracker tag lookups)
|
||||
if ( ServiceIterator.Find("FunTagService").Next() )
|
||||
funtagsv = true;
|
||||
// cache various services into the handler on register
|
||||
// this dramatically reduces overhead by not having to use an iterator every time they're needed
|
||||
// especially noticeable for fun tags, as they're looked up for every monster on map load
|
||||
let si = ServiceIterator.Find("FunTagService");
|
||||
Service sv;
|
||||
while ( sv = si.Next() ) funtagsv.Push(sv);
|
||||
si = ServiceIterator.Find("MergeMonsterService");
|
||||
while ( sv = si.Next() ) mergemonstersv.Push(sv);
|
||||
// start profiling
|
||||
if ( swwm_profstart <= 0 ) return;
|
||||
bprofiletics = profiletics = swwm_profstart;
|
||||
|
|
|
|||
|
|
@ -144,6 +144,8 @@ Class SWWMStats : SWWMStaticThinker
|
|||
int silveregg;
|
||||
bool oldcheat;
|
||||
bool gotyorick;
|
||||
// caching
|
||||
SWWMHandler hnd;
|
||||
|
||||
bool GotWeapon( Class<Weapon> which )
|
||||
{
|
||||
|
|
@ -248,7 +250,8 @@ Class SWWMStats : SWWMStaticThinker
|
|||
{
|
||||
if ( victim )
|
||||
{
|
||||
Class<Actor> mvictim = SWWMUtility.MergeMonster(victim.GetClass());
|
||||
if ( !hnd ) hnd = SWWMHandler(EventHandler.Find("SWWMHandler"));
|
||||
Class<Actor> mvictim = SWWMUtility.MergeMonster(hnd,victim.GetClass());
|
||||
bool found = false;
|
||||
for ( int i=0; i<mstats.Size(); i++ )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -874,19 +874,13 @@ Class SWWMUtility
|
|||
static play String GetFunTag( SWWMHandler hnd, Actor a, String defstr = "" )
|
||||
{
|
||||
// look up fun tag services if available
|
||||
if ( hnd.funtagsv )
|
||||
for ( int i=0; i<hnd.funtagsv.Size(); i++ )
|
||||
{
|
||||
let si = ServiceIterator.Find("FunTagService");
|
||||
Service sv;
|
||||
String res;
|
||||
while ( sv = si.Next() )
|
||||
{
|
||||
res = sv.GetString("GetFunTag",objectArg:a);
|
||||
if ( res == "" ) continue;
|
||||
si.Destroy();
|
||||
return res;
|
||||
}
|
||||
si.Destroy();
|
||||
let sv = hnd.funtagsv[i];
|
||||
if ( !sv ) continue;
|
||||
String res = sv.GetString("GetFunTag",objectArg:a);
|
||||
if ( res == "" ) continue;
|
||||
return res;
|
||||
}
|
||||
int ntags = 1;
|
||||
String basetag = "";
|
||||
|
|
@ -1437,21 +1431,18 @@ Class SWWMUtility
|
|||
// e.g.: "stealth" monsters and their non-stealth counterparts,
|
||||
// or "HereticImp" and "HereticImpLeader", which have the same exact tag,
|
||||
// and would result in an odd "duplication" of monster names
|
||||
static play Class<Actor> MergeMonster( Class<Actor> a )
|
||||
static play Class<Actor> MergeMonster( SWWMHandler hnd, Class<Actor> a )
|
||||
{
|
||||
// see if any services can resolve this first
|
||||
let si = ServiceIterator.Find("MergeMonsterService");
|
||||
Service sv;
|
||||
String res;
|
||||
while ( sv = si.Next() )
|
||||
for ( int i=0; i<hnd.mergemonstersv.Size(); i++ )
|
||||
{
|
||||
res = sv.GetString("MergeMonster",stringArg:a.GetClassName());
|
||||
let sv = hnd.mergemonstersv[i];
|
||||
if ( !sv ) continue;
|
||||
String res = sv.GetString("MergeMonster",stringArg:a.GetClassName());
|
||||
if ( res == "" ) continue;
|
||||
si.Destroy();
|
||||
Class<Actor> rescls = res;
|
||||
return rescls;
|
||||
}
|
||||
si.Destroy();
|
||||
// stealth monsters, the worst thing ever invented
|
||||
if ( a == 'StealthArachnotron' ) return 'Arachnotron';
|
||||
if ( a == 'StealthArchvile' ) return 'Archvile';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue