Skip to content

Commit a3452c2

Browse files
committed
Fix index out of bounds in ProcessAllRaids
Add bounds validation to ensure allRaids and allEncounters are accessed safely. The RaidCrawler library can return different counts for raids vs encounters, causing IndexOutOfRangeException crashes.
1 parent af089ef commit a3452c2

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

SysBot.Pokemon/SV/BotRaid/RotatingRaidBotSV.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4573,7 +4573,7 @@ private async Task ProcessAllRaids(CancellationToken token)
45734573
bool newEventSpeciesFound = false;
45744574
var (distGroupIDs, mightGroupIDs) = GetPossibleGroups(Container);
45754575

4576-
int raidsToCheck = Math.Min(5, allRaids.Count);
4576+
int raidsToCheck = Math.Min(5, Math.Min(allRaids.Count, allEncounters.Count));
45774577

45784578
if (!IsKitakami && !IsBlueberry)
45794579
{
@@ -4597,7 +4597,8 @@ private async Task ProcessAllRaids(CancellationToken token)
45974597
}
45984598
}
45994599

4600-
for (int i = 0; i < allRaids.Count; i++)
4600+
int maxRaidIndex = Math.Min(allRaids.Count, allEncounters.Count);
4601+
for (int i = 0; i < maxRaidIndex; i++)
46014602
{
46024603
if (newEventSpeciesFound)
46034604
{

0 commit comments

Comments
 (0)