Skip to content

Commit

Permalink
Fix event raid reading with multiple deliver group ids
Browse files Browse the repository at this point in the history
Co-Authored-By: Archit Date <architdate@gmail.com>
  • Loading branch information
LegoFigure11 and architdate committed Aug 12, 2023
1 parent 9b53309 commit e10ea08
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions RaidCrawler.Core/Extensions/RaidExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public static (int delivery, int encounter) ReadAllRaids(this RaidContainer cont
List<Raid> newRaids = new();
List<ITeraRaid> newTera = new();
List<List<(int, int, int)>> newRewards = new();
int eventct = 0;
for (int i = 0; i < count; i++)
{
var raid = new Raid(data.AsSpan(i * Raid.SIZE, Raid.SIZE));
Expand All @@ -99,7 +100,7 @@ public static (int delivery, int encounter) ReadAllRaids(this RaidContainer cont
var raid_delivery_group_id = -1;
try
{
raid_delivery_group_id = raid.GetDeliveryGroupID(container.DeliveryRaidPriority, possible_groups);
raid_delivery_group_id = raid.GetDeliveryGroupID(container.DeliveryRaidPriority, possible_groups, eventct);
}
catch (Exception ex)
{
Expand All @@ -120,6 +121,8 @@ public static (int delivery, int encounter) ReadAllRaids(this RaidContainer cont
continue;
}

if (raid.IsEvent) eventct++;

newRaids.Add(raid);
newTera.Add(encounter);
newRewards.Add(encounter.GetRewards(container, raid, boost));
Expand Down Expand Up @@ -195,20 +198,33 @@ public static int GetStarCount(this Raid _, uint difficulty, int progress, bool
};
}

public static int GetDeliveryGroupID(this Raid raid, DeliveryGroupID ids, List<int> possible_groups)
public static int GetDeliveryGroupID(this Raid raid, DeliveryGroupID ids, List<int> possible_groups, int eventct)
{
if (!raid.IsEvent)
return -1;

// WW/IL re-run has DeliveryGroupID = 3, having a Might7 alongside it conflicts.
bool group3 = possible_groups.Contains(3) && raid.Flags != 3;
bool special = possible_groups.Contains(3) && raid.Flags != 3;
var groups = ids.GroupID;
for (int i = 0; i < groups.Table_Length; i++)
if (special)
{
for (int i = 0; i < groups.Table_Length; i++)
{
var ct = groups.Table(i) + (special ? 2 : raid.Flags != 3 ? 1 : 0);
var result = possible_groups.Find(x => x == ct);
if (result > 0)
return ct;
}
}
else
{
var ct = groups.Table(i) + (group3 ? 2 : raid.Flags != 3 ? 1 : 0);
var result = possible_groups.Find(x => x == ct);
if (result > 0)
return ct;
for (int j = 0; j < groups.Table_Length; j++)
{
var ct = groups.Table(j);
if (!possible_groups.Contains(j + 1)) continue;
if (eventct < ct) return j + 1;
eventct -= ct;
}
}
throw new Exception("Found event out of priority range.");
}
Expand Down

0 comments on commit e10ea08

Please sign in to comment.