From cac63533798622325b090e32a41d60aab57d018a Mon Sep 17 00:00:00 2001 From: Gustavo Ramos Rehermann Date: Sat, 2 Dec 2023 20:23:57 -0300 Subject: [PATCH] Stop using expensive foreach Pawn + PRL.FindPlayer loops --- Classes/MushMatch.uc | 40 ++++++++++++++-------------------------- buildconfig.sh | 2 +- 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/Classes/MushMatch.uc b/Classes/MushMatch.uc index 6235243..aa51649 100644 --- a/Classes/MushMatch.uc +++ b/Classes/MushMatch.uc @@ -463,19 +463,12 @@ function GetAliveTeams(out int humans, out int mush) { return; } - for (p = Level.PawnList; p != none; p = p.nextPawn) { - if (p.bIsPlayer && p.PlayerReplicationInfo != none) { - PRL = MushMatchInfo(GameReplicationInfo).FindPRL(p.PlayerReplicationInfo); - - if (PRL != None && !PRL.bDead) { - if (PRL.bMush) { - mush += 1; - } - - else { - humans += 1; - } - } + for (PRL = MushMatchInfo(GameReplicationInfo).PRL; PRL != None; PRL = MushMatchPRL(PRL.next)) { + if (!PRL.bDead) { + if (PRL.bMush) + mush += 1; + else + humans += 1; } } } @@ -961,12 +954,11 @@ function int MushCount() local Pawn p; local MushMatchPRL PRL; - for (p = Level.PawnList; p != none; p = p.NextPawn) { - if (!p.bIsPlayer) continue; - - PRL = FindPawnPRL(p); + for (PRL = MushMatchInfo(GameReplicationInfo).PRL; PRL != None; PRL = MushMatchPRL(PRL.next)) { + p = Pawn(PRL.Owner.Owner); - if (PRL == None) continue; + if (!p.bIsPlayer) continue; + if (PRL.bDead) continue; if (!PRL.bMush) continue; i++; @@ -985,14 +977,10 @@ function Selected() sp.MushSelected(); } - for ( p = Level.PawnList; p != none; p = p.NextPawn ) { - if ( p.bIsPlayer && p.PlayerReplicationInfo != none ) - { - p.Health = Max(p.Health, p.Class.Default.Health); - - PRL = MushMatchInfo(GameReplicationInfo).FindPRL(p.PlayerReplicationInfo); - PRL.SetInitialTeam(); - } + for (PRL = MushMatchInfo(GameReplicationInfo).PRL; PRL != None; PRL = MushMatchPRL(PRL.next)) { + p = Pawn(PRL.Owner.Owner); + p.Health = Max(p.Health, p.Class.Default.Health); + PRL.SetInitialTeam(); } BroadcastLocalizedMessage(MushSelectedMessageType); diff --git a/buildconfig.sh b/buildconfig.sh index f2cbbc0..5728a4a 100644 --- a/buildconfig.sh +++ b/buildconfig.sh @@ -6,7 +6,7 @@ export name="Mush Match" export package=MushMatch export version=1.3.4 -export build=20231207 +export build=20231211 export debug=1 export makeint=1 export incl_readme=1