forked from aly/qstbak
313 lines
7.5 KiB
C#
313 lines
7.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using FFXIVClientStructs.FFXIV.Client.Game;
|
|
|
|
namespace LLib.Inventory;
|
|
|
|
public static class InventoryContainers
|
|
{
|
|
public static ReadOnlySpan<InventoryType> Bags => new InventoryType[4]
|
|
{
|
|
InventoryType.Inventory1,
|
|
InventoryType.Inventory2,
|
|
InventoryType.Inventory3,
|
|
InventoryType.Inventory4
|
|
};
|
|
|
|
public static ReadOnlySpan<InventoryType> ArmouryMainHand => new InventoryType[1] { InventoryType.ArmoryMainHand };
|
|
|
|
public static ReadOnlySpan<InventoryType> ArmouryOffHand => new InventoryType[1] { InventoryType.ArmoryOffHand };
|
|
|
|
public static ReadOnlySpan<InventoryType> ArmouryLeftSide => new InventoryType[5]
|
|
{
|
|
InventoryType.ArmoryHead,
|
|
InventoryType.ArmoryBody,
|
|
InventoryType.ArmoryHands,
|
|
InventoryType.ArmoryLegs,
|
|
InventoryType.ArmoryFeets
|
|
};
|
|
|
|
public static ReadOnlySpan<InventoryType> ArmouryRightSide => new InventoryType[4]
|
|
{
|
|
InventoryType.ArmoryEar,
|
|
InventoryType.ArmoryNeck,
|
|
InventoryType.ArmoryWrist,
|
|
InventoryType.ArmoryRings
|
|
};
|
|
|
|
public static ReadOnlySpan<InventoryType> SaddleBag => new InventoryType[2]
|
|
{
|
|
InventoryType.SaddleBag1,
|
|
InventoryType.SaddleBag2
|
|
};
|
|
|
|
public static ReadOnlySpan<InventoryType> PremiumSaddleBag => new InventoryType[2]
|
|
{
|
|
InventoryType.PremiumSaddleBag1,
|
|
InventoryType.PremiumSaddleBag2
|
|
};
|
|
|
|
public unsafe static int CountFreeSlots(ReadOnlySpan<InventoryType> containers)
|
|
{
|
|
InventoryManager* ptr = InventoryManager.Instance();
|
|
int num = ((ptr != null) ? 422803500 : 422803490);
|
|
ReadOnlySpan<InventoryType> readOnlySpan = default(ReadOnlySpan<InventoryType>);
|
|
int num7 = default(int);
|
|
InventoryContainer* inventoryContainer = default(InventoryContainer*);
|
|
int num9 = default(int);
|
|
int num11 = default(int);
|
|
InventoryItem* inventorySlot = default(InventoryItem*);
|
|
while (true)
|
|
{
|
|
int num2 = num;
|
|
int num3 = 422803495;
|
|
int num4 = num2;
|
|
int num5 = num4 + num3;
|
|
int num6 = num4 & num3;
|
|
switch (num5 - (num6 + num6))
|
|
{
|
|
case 1:
|
|
{
|
|
InventoryType inventoryType = readOnlySpan[num7];
|
|
inventoryContainer = ptr->GetInventoryContainer(inventoryType);
|
|
num = ((inventoryContainer == null) ? 422803501 : 422803493);
|
|
break;
|
|
}
|
|
case 11:
|
|
num9 = 0;
|
|
readOnlySpan = containers;
|
|
num7 = 0;
|
|
num = 422803492;
|
|
break;
|
|
case 0:
|
|
num = ((num11 < inventoryContainer->Size) ? 422803491 : 422803501);
|
|
break;
|
|
case 10:
|
|
{
|
|
int num14 = num7;
|
|
num3 = 1;
|
|
num4 = num14;
|
|
num7 = (num4 | num3) + (num4 & num3);
|
|
num = 422803492;
|
|
break;
|
|
}
|
|
case 7:
|
|
{
|
|
int num10 = num11;
|
|
num3 = 1;
|
|
num4 = num10;
|
|
int num12 = num4 ^ num3;
|
|
int num13 = num4 & num3;
|
|
num11 = num12 + (num13 + num13);
|
|
num = 422803495;
|
|
break;
|
|
}
|
|
case 9:
|
|
{
|
|
int num8 = num9;
|
|
num3 = 1;
|
|
num4 = num8;
|
|
num9 = (num4 | num3) + (num4 & num3);
|
|
num = 422803488;
|
|
break;
|
|
}
|
|
case 5:
|
|
return 0;
|
|
case 12:
|
|
return num9;
|
|
case 6:
|
|
num = 422803490;
|
|
break;
|
|
case 8:
|
|
num = ((inventorySlot->ItemId != 0) ? 422803488 : 422803502);
|
|
break;
|
|
case 2:
|
|
num11 = 0;
|
|
num = 422803495;
|
|
break;
|
|
case 4:
|
|
inventorySlot = inventoryContainer->GetInventorySlot(num11);
|
|
num = ((inventorySlot == null) ? 422803502 : 422803503);
|
|
break;
|
|
case 3:
|
|
num = ((num7 < readOnlySpan.Length) ? 422803494 : 422803499);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public unsafe static int CountItems(uint itemId, ReadOnlySpan<InventoryType> containers)
|
|
{
|
|
InventoryManager* ptr = InventoryManager.Instance();
|
|
int num = ((ptr != null) ? 107037197 : 107037193);
|
|
int num11 = default(int);
|
|
InventoryContainer* inventoryContainer = default(InventoryContainer*);
|
|
int num7 = default(int);
|
|
ReadOnlySpan<InventoryType> readOnlySpan = default(ReadOnlySpan<InventoryType>);
|
|
int num5 = default(int);
|
|
InventoryItem* inventorySlot = default(InventoryItem*);
|
|
while (true)
|
|
{
|
|
int num2 = num;
|
|
int num3 = 107037196;
|
|
int num4 = num2;
|
|
switch ((num4 | num3) - (num4 & num3))
|
|
{
|
|
case 9:
|
|
num11 = 0;
|
|
num = 107037196;
|
|
break;
|
|
case 0:
|
|
num = ((num11 < inventoryContainer->Size) ? 107037190 : 107037191);
|
|
break;
|
|
case 1:
|
|
num7 = 0;
|
|
readOnlySpan = containers;
|
|
num5 = 0;
|
|
num = 107037184;
|
|
break;
|
|
case 3:
|
|
num = ((inventorySlot->ItemId != itemId) ? 107037192 : 107037188);
|
|
break;
|
|
case 7:
|
|
num = 107037193;
|
|
break;
|
|
case 8:
|
|
{
|
|
int num6 = num7;
|
|
num3 = inventorySlot->Quantity;
|
|
num4 = num6;
|
|
int num8 = num4 ^ num3;
|
|
int num9 = num4 & num3;
|
|
num7 = num8 + (num9 + num9);
|
|
num = 107037192;
|
|
break;
|
|
}
|
|
case 5:
|
|
return 0;
|
|
case 10:
|
|
inventorySlot = inventoryContainer->GetInventorySlot(num11);
|
|
num = ((inventorySlot == null) ? 107037192 : 107037199);
|
|
break;
|
|
case 4:
|
|
{
|
|
int num12 = num11;
|
|
num3 = 1;
|
|
num4 = num12;
|
|
int num13 = num4 ^ num3;
|
|
int num14 = num4 & num3;
|
|
num11 = num13 + (num14 + num14);
|
|
num = 107037196;
|
|
break;
|
|
}
|
|
case 6:
|
|
{
|
|
InventoryType inventoryType = readOnlySpan[num5];
|
|
inventoryContainer = ptr->GetInventoryContainer(inventoryType);
|
|
num = ((inventoryContainer == null) ? 107037191 : 107037189);
|
|
break;
|
|
}
|
|
case 2:
|
|
return num7;
|
|
case 11:
|
|
{
|
|
int num10 = num5;
|
|
num3 = 1;
|
|
num4 = num10;
|
|
num5 = (num4 | num3) + (num4 & num3);
|
|
num = 107037184;
|
|
break;
|
|
}
|
|
case 12:
|
|
num = ((num5 < readOnlySpan.Length) ? 107037194 : 107037198);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public unsafe static List<InventoryItem> GetHqItems(ReadOnlySpan<InventoryType> containers)
|
|
{
|
|
List<InventoryItem> list = new List<InventoryItem>();
|
|
InventoryManager* ptr = InventoryManager.Instance();
|
|
int num = ((ptr != null) ? (-877452053) : (-877452056));
|
|
InventoryItem* inventorySlot = default(InventoryItem*);
|
|
InventoryContainer* inventoryContainer = default(InventoryContainer*);
|
|
int num5 = default(int);
|
|
ReadOnlySpan<InventoryType> readOnlySpan = default(ReadOnlySpan<InventoryType>);
|
|
int num9 = default(int);
|
|
while (true)
|
|
{
|
|
int num2 = num;
|
|
int num3 = -877452054;
|
|
int num4 = num2;
|
|
switch ((num4 | num3) - (num4 & num3))
|
|
{
|
|
case 5:
|
|
inventorySlot = inventoryContainer->GetInventorySlot(num5);
|
|
num = ((inventorySlot == null) ? (-877452055) : (-877452050));
|
|
break;
|
|
case 2:
|
|
return list;
|
|
case 9:
|
|
num = -877452056;
|
|
break;
|
|
case 0:
|
|
{
|
|
InventoryType inventoryType = readOnlySpan[num9];
|
|
inventoryContainer = ptr->GetInventoryContainer(inventoryType);
|
|
num = ((inventoryContainer == null) ? (-877452051) : (-877452057));
|
|
break;
|
|
}
|
|
case 7:
|
|
{
|
|
int num10 = num9;
|
|
num3 = 1;
|
|
num4 = num10;
|
|
int num11 = num4 ^ num3;
|
|
int num12 = num4 & num3;
|
|
num9 = num11 + (num12 + num12);
|
|
num = -877452064;
|
|
break;
|
|
}
|
|
case 10:
|
|
num = ((num9 < readOnlySpan.Length) ? (-877452054) : (-877452063));
|
|
break;
|
|
case 6:
|
|
num = ((num5 < inventoryContainer->Size) ? (-877452049) : (-877452051));
|
|
break;
|
|
case 12:
|
|
num = (((inventorySlot->Flags & InventoryItem.ItemFlags.HighQuality) == 0) ? (-877452055) : (-877452062));
|
|
break;
|
|
case 8:
|
|
list.Add(*inventorySlot);
|
|
num = -877452055;
|
|
break;
|
|
case 1:
|
|
readOnlySpan = containers;
|
|
num9 = 0;
|
|
num = -877452064;
|
|
break;
|
|
case 4:
|
|
num = ((inventorySlot->ItemId == 0) ? (-877452055) : (-877452058));
|
|
break;
|
|
case 3:
|
|
{
|
|
int num6 = num5;
|
|
num3 = 1;
|
|
num4 = num6;
|
|
int num7 = num4 ^ num3;
|
|
int num8 = num4 & num3;
|
|
num5 = num7 + (num8 + num8);
|
|
num = -877452052;
|
|
break;
|
|
}
|
|
case 11:
|
|
return list;
|
|
case 13:
|
|
num5 = 0;
|
|
num = -877452052;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|