From 56b9000291251e9fc4b7463a7cf41839eba27d71 Mon Sep 17 00:00:00 2001 From: Gustavo Ramos Rehermann Date: Fri, 22 Dec 2023 21:56:21 -0300 Subject: [PATCH] Fix HatedBy linked list tail --- Classes/MushMatchInfo.uc | 21 ++++++++++++--------- Classes/MushMatchPRL.uc | 8 ++++++-- Classes/PlayerReplicationList.uc | 2 +- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Classes/MushMatchInfo.uc b/Classes/MushMatchInfo.uc index 1e98539..04ff45e 100644 --- a/Classes/MushMatchInfo.uc +++ b/Classes/MushMatchInfo.uc @@ -87,12 +87,14 @@ simulated function PreSelected() { function bool RemovePRL(PlayerReplicationinfo PRI) { local bool success; - local PlayerReplicationList newRoot; + local PlayerReplicationList newRoot, newTail; if (PRL != None) { newRoot = PRL; - success = PRL.RemovePlayer(PRI, newRoot, PRLTail); - PRL = MushMatchPRL(newRoot);) + newTail = PRLTail; + success = PRL.RemovePlayer(PRI, newRoot, newTail); + PRL = MushMatchPRL(newRoot); + PRLTail = MushMatchPRL(newTail); } if (!success) { @@ -104,6 +106,8 @@ function bool RemovePRL(PlayerReplicationinfo PRI) { function MushMatchPRL RegisterPRL(PlayerReplicationinfo PRI) { local MushMatchPRL NewPRL; + local PlayerReplicationList NewPRLTail; + NewPRLTail = PRLTail; if (PRL == None) { PRL = Spawn(class'MushMatchPRL', PRI); @@ -113,15 +117,14 @@ function MushMatchPRL RegisterPRL(PlayerReplicationinfo PRI) { } else if (!bCheckDuplicatePRLs || PRL.FindPlayer(PRI) == None) { - NewPRL = MushMatchPRL(PRL.AppendPlayer(PRI, PRLTail, class'MushMatchPRL'); - } - - else if (bCheckDuplicatePRLs) { - Warn("Attempted to register duplicate PRL for"@PRI.PlayerName); - return None; + NewPRL = MushMatchPRL(PRLTail.AppendPlayer(PRI, NewPRLTail, class'MushMatchPRL')); + PRLTail = MushMatchPRL(NewPRLTail); } else { + if (bCheckDuplicatePRLs) { + Warn("Attempted to register duplicate PRL for"@PRI.PlayerName); + } return None; } diff --git a/Classes/MushMatchPRL.uc b/Classes/MushMatchPRL.uc index 4036aaf..fe5c5ac 100644 --- a/Classes/MushMatchPRL.uc +++ b/Classes/MushMatchPRL.uc @@ -8,7 +8,7 @@ var bool bDead, bSpectator; var int InitialTeam; var float ImmuneLevel; var float ImmuneMomentum, ImmuneThrust, ImmuneResistance; -var PlayerReplicationList HatedBy; +var PlayerReplicationList HatedBy, HatedByTail; var class HatePRLType; // Replicated settings @@ -243,11 +243,15 @@ simulated event AddHate(PlayerReplicationInfo Other) simulated event bool RemoveHate(PlayerReplicationInfo Other) { + local PlayerReplicationList newTail; + if ( HatedBy == None ) return false; else { - return HatedBy.RemovePlayer(Other, HatedBy, HatedByTail); + newTail = HatedByTail; + return HatedBy.RemovePlayer(Other, HatedBy, newTail); + HatedByTail = newTail; } } diff --git a/Classes/PlayerReplicationList.uc b/Classes/PlayerReplicationList.uc index 7c51e8e..4a2fbe5 100644 --- a/Classes/PlayerReplicationList.uc +++ b/Classes/PlayerReplicationList.uc @@ -26,7 +26,7 @@ simulated function PlayerReplicationList AppendPlayer(PlayerReplicationInfo othe prl.Next = Spawn(PRLType, other); prl.Next.Root = Root; - newTail = prl.Next; + if (newTail != None) newTail = prl.Next; return prl.Next; }