Use MaxCount when storing items

Rewritten, HaX can now bypass this limit (still constrained for
overflow)

Closes #314 , thanks @Ninjistix !
This commit is contained in:
Kaphotics
2016-10-09 18:38:04 -07:00
parent e9859a7b03
commit 43c036641d

View File

@@ -178,21 +178,25 @@ private void packBags()
{
string item = dgv.Rows[i].Cells[0].Value.ToString();
int itemindex = Array.IndexOf(itemlist, item);
int itemcnt;
try
{ itemcnt = Convert.ToUInt16(dgv.Rows[i].Cells[1].Value.ToString()); }
catch { itemcnt = 0; }
if (itemcnt == 0)
itemcnt++; // No 0 count of items
else if (itemcnt > 995)
itemcnt = 995; // cap out
else if (itemcnt > 99 && SAV.Generation <= 3)
itemcnt = 99;
if (itemindex == 0) // Compression of Empty Slots
if (itemindex <= 0) // Compression of Empty Slots
continue;
int itemcnt;
int.TryParse(dgv.Rows[i].Cells[1].Value.ToString(), out itemcnt);
if (Main.HaX)
{
// Cap at absolute maximum
if (SAV.Generation <= 2 && itemcnt > byte.MaxValue)
itemcnt = byte.MaxValue;
else if (SAV.Generation >= 3 && itemcnt > ushort.MaxValue)
itemcnt = ushort.MaxValue;
}
else if (itemcnt > t.MaxCount)
itemcnt = t.MaxCount; // Cap at pouch maximum
else if (itemcnt <= 0)
itemcnt = 1;
t.Items[ctr++] = new InventoryItem {Index = itemindex, Count = itemcnt};
}
for (int i = ctr; i < t.Items.Length; i++)