Skip to content

Commit

Permalink
fix feather queuing
Browse files Browse the repository at this point in the history
  • Loading branch information
NostraThomas99 committed Dec 1, 2024
1 parent eadfa69 commit e0bf2c3
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions RebornToolbox/Features/ChocoboRacing/ChocoboRacing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ private unsafe void OnUpdate(IFramework framework)
return;
}

var selectedDutyName = addon->AtkValues[18].GetValueAsString();
var selectedDutyName = addon->AtkValues[18].GetValueAsString()
.Replace("\u0002\u001a\u0002\u0002\u0003", string.Empty)
.Replace("\u0002\u001a\u0002\u0001\u0003", string.Empty);
if (selectedDutyName.Contains(GetSelectedDutyName(), StringComparison.InvariantCultureIgnoreCase))
{
Callback.Fire((AtkUnitBase*)addon, true, 12, 0);
Expand All @@ -145,28 +147,20 @@ private string GetSelectedDutyName()
var row = ContentRoulettes.First(c => c.RowId == routeId);
return row.Name.ToString();
}

// Credit: https://github.com/ffxivcode/AutoDuty/blob/26a61eefdba148bc5f46694f915f402315e9f128/AutoDuty/Helpers/QueueHelper.cs#L247
private uint HeadersCount(uint before, List<AtkComponentTreeListItem> list)
private static uint HeadersCount(int before, List<AtkComponentTreeListItem> list)
{
uint count = 0;
for (int i = 0; i < before; i++)
{
if (list[i].UIntValues[0] == 4 || list[i].UIntValues[0] == 2)
count++;
}

return count;
return (uint)list.Take(before).Count(item => item.UIntValues[0] == 0 || item.UIntValues[0] == 1);
}

// Credit: https://github.com/ffxivcode/AutoDuty/blob/26a61eefdba148bc5f46694f915f402315e9f128/AutoDuty/Helpers/QueueHelper.cs#L258
private unsafe void SelectDuty(AddonContentsFinder* addonContentsFinder)
{
if (addonContentsFinder == null) return;

var vectorDutyListItems = addonContentsFinder->DutyList->Items;
List<AtkComponentTreeListItem> listAtkComponentTreeListItems = [];
vectorDutyListItems.ForEach(pointAtkComponentTreeListItem => listAtkComponentTreeListItems.Add(*(pointAtkComponentTreeListItem.Value)));
Callback.Fire((AtkUnitBase*)addonContentsFinder, true, 3, HeadersCount((uint)addonContentsFinder->DutyList->SelectedItemIndex, listAtkComponentTreeListItems) + 1); // - (HeadersCount(addonContentsFinder->DutyList->SelectedItemIndex, listAtkComponentTreeListItems) + 1));
var dutyItems = addonContentsFinder->DutyList->Items;
var itemList = dutyItems.Select(itemPtr => *(itemPtr.Value)).ToList();
int selectedIndex = addonContentsFinder->DutyList->SelectedItemIndex;
uint headersBeforeSelected = HeadersCount(selectedIndex, itemList);
uint callbackIndex = headersBeforeSelected + 1;
Callback.Fire((AtkUnitBase*)addonContentsFinder, true, 3, callbackIndex);
}

}

0 comments on commit e0bf2c3

Please sign in to comment.