Skip to content

Commit

Permalink
Fix HatedBy linked list tail
Browse files Browse the repository at this point in the history
  • Loading branch information
wallabra committed Dec 23, 2023
1 parent e762670 commit 56b9000
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
21 changes: 12 additions & 9 deletions Classes/MushMatchInfo.uc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand All @@ -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;
}

Expand Down
8 changes: 6 additions & 2 deletions Classes/MushMatchPRL.uc
Original file line number Diff line number Diff line change
Expand Up @@ -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<PlayerReplicationList> HatePRLType;

// Replicated settings
Expand Down Expand Up @@ -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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Classes/PlayerReplicationList.uc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 56b9000

Please sign in to comment.