Finally fix the long-standing lore library bug FOR REAL.

This commit is contained in:
Mari the Deer 2021-01-03 14:14:02 +01:00
commit 72527003e3
3 changed files with 19 additions and 31 deletions

View file

@ -1,2 +1,2 @@
[default]
SWWM_MODVER="\chSWWM \czGZ\c- \cw0.9.11b-pre r729 \cu(Sun 3 Jan 01:51:49 CET 2021)";
SWWM_MODVER="\chSWWM \czGZ\c- \cw0.9.11b-pre r729 \cu(Sun 3 Jan 14:14:02 CET 2021)";

View file

@ -938,34 +938,6 @@ Class SWWMHandler : EventHandler
l.ChangeStatNum(Thinker.STAT_STATIC);
l.myplayer = p;
}
// horrendous piece of shit bandaid fix because gzdoom gets on my fucking nerves with its inconsistency bullshit
let ti = ThinkerIterator.Create("SWWMLoreLibrary",Thinker.STAT_STATIC);
SWWMLoreLibrary l2;
bool bmesg = false;
while ( l2 = SWWMLoreLibrary(ti.Next()) )
{
if ( (l2 == l) || (l2.myplayer != p) ) continue;
if ( !bmesg )
{
Console.Printf("If these messages appear, something broke and should be reported.");
bmesg = true;
}
// merge excess libraries (if it ever happens)
Console.Printf("Merging existing lore library with %d entries.",l2.ent.Size());
for ( int i=0; i<l2.ent.Size(); i++ )
{
bool dontadd = false;
for ( int j=0; j<l.ent.Size(); j++ )
{
if ( l.ent[j].tag != l2.ent[i].tag ) continue;
l.ent[j].read |= l2.ent[i].read;
dontadd = true;
}
if ( dontadd ) continue;
l.ent.Push(l2.ent[i]);
}
l2.Destroy();
}
// pre-add some entries to start with
l.DirectAdd("Demolitionist");
l.DirectAdd("KnowledgeBase");
@ -989,6 +961,11 @@ Class SWWMHandler : EventHandler
l.DirectAdd("TheOrder");
l.DirectAdd("TheFront");
}
// starting weapons (if owned)
if ( p.mo.FindInventory('DeepImpact') )
l.DirectAdd("DeepImpact");
if ( p.mo.FindInventory('ExplodiumGun') )
l.DirectAdd("ExplodiumGun");
SWWMStats s = SWWMStats.Find(p);
if ( !s )
{
@ -1027,7 +1004,14 @@ Class SWWMHandler : EventHandler
override void PlayerRespawned( PlayerEvent e )
{
PlayerEntered(e);
// reset some vars
multilevel[e.playernumber] = 0;
spreecount[e.playernumber] = 0;
tookdamage[e.playernumber] = false;
lastkill[e.playernumber] = int.min;
// reset combat tracker
if ( !swwm_notrack )
SWWMCombatTracker.Spawn(players[e.playernumber].mo);
}
override void WorldThingRevived( WorldEvent e )

View file

@ -8,6 +8,7 @@ Class Demolitionist : PlayerPawn
bool dashsnd;
bool sendtoground;
bool key_reentrant;
bool bLoreGrossHackFuckThisEngine;
int lastdamage;
transient int lastdamagetic;
@ -358,7 +359,9 @@ Class Demolitionist : PlayerPawn
}
override void GiveDefaultInventory()
{
bLoreGrossHackFuckThisEngine = true; // prevent default inventory from adding lore entries (fixes lore library disappearing when loading saves WHILE DEAD)
Super.GiveDefaultInventory();
bLoreGrossHackFuckThisEngine = false;
// preloaded gun
let eg = ExplodiumGun(FindInventory("ExplodiumGun"));
if ( !eg ) return;
@ -1861,7 +1864,8 @@ Class Demolitionist : PlayerPawn
Super.AddInventory(item);
if ( !player ) return;
// add lore if any
SWWMLoreLibrary.Add(player,item.GetClassName());
if ( !bLoreGrossHackFuckThisEngine )
SWWMLoreLibrary.Add(player,item.GetClassName());
if ( (item is 'Weapon') && !(item is 'SWWMGesture') && !(item is 'SWWMItemGesture') && mystats && !mystats.GotWeapon(Weapon(item).GetClass()) && CheckLocalView() )
SWWMHandler.AddOneliner("getweapon",2);
if ( (item is 'Key') && !key_reentrant && !deathmatch )