Add some capacity constants
This commit is contained in:
32
src/item.c
32
src/item.c
@@ -202,9 +202,9 @@ bool8 CheckBagHasSpace(u16 itemId, u16 count)
|
||||
|
||||
pocket = ItemId_GetPocket(itemId) - 1;
|
||||
if (pocket != BERRIES_POCKET)
|
||||
slotCapacity = 99;
|
||||
slotCapacity = MAX_BAG_ITEM_CAPACITY;
|
||||
else
|
||||
slotCapacity = 999;
|
||||
slotCapacity = MAX_BERRY_CAPACITY;
|
||||
|
||||
// Check space in any existing item slots that already contain this item
|
||||
for (i = 0; i < gBagPockets[pocket].capacity; i++)
|
||||
@@ -422,9 +422,9 @@ bool8 AddBagItem(u16 itemId, u16 count)
|
||||
memcpy(newItems, itemPocket->itemSlots, itemPocket->capacity * sizeof(struct ItemSlot));
|
||||
|
||||
if (pocket != BERRIES_POCKET)
|
||||
slotCapacity = 99;
|
||||
slotCapacity = MAX_BAG_ITEM_CAPACITY;
|
||||
else
|
||||
slotCapacity = 999;
|
||||
slotCapacity = MAX_BERRY_CAPACITY;
|
||||
|
||||
for (i = 0; i < itemPocket->capacity; i++)
|
||||
{
|
||||
@@ -667,15 +667,15 @@ bool8 AddPCItem(u16 itemId, u16 count)
|
||||
if (newItems[i].itemId == itemId)
|
||||
{
|
||||
ownedCount = GetPCItemQuantity(&newItems[i].quantity);
|
||||
if (ownedCount + count <= 999)
|
||||
if (ownedCount + count <= MAX_PC_ITEM_CAPACITY)
|
||||
{
|
||||
SetPCItemQuantity(&newItems[i].quantity, ownedCount + count);
|
||||
memcpy(gSaveBlock1Ptr->pcItems, newItems, sizeof(gSaveBlock1Ptr->pcItems));
|
||||
Free(newItems);
|
||||
return TRUE;
|
||||
}
|
||||
count += ownedCount - 999;
|
||||
SetPCItemQuantity(&newItems[i].quantity, 999);
|
||||
count += ownedCount - MAX_PC_ITEM_CAPACITY;
|
||||
SetPCItemQuantity(&newItems[i].quantity, MAX_PC_ITEM_CAPACITY);
|
||||
if (count == 0)
|
||||
{
|
||||
memcpy(gSaveBlock1Ptr->pcItems, newItems, sizeof(gSaveBlock1Ptr->pcItems));
|
||||
@@ -883,10 +883,10 @@ static bool8 CheckPyramidBagHasSpace(u16 itemId, u16 count)
|
||||
{
|
||||
if (items[i] == itemId || items[i] == ITEM_NONE)
|
||||
{
|
||||
if (quantities[i] + count <= 99)
|
||||
if (quantities[i] + count <= MAX_BAG_ITEM_CAPACITY)
|
||||
return TRUE;
|
||||
|
||||
count = (quantities[i] + count) - 99;
|
||||
count = (quantities[i] + count) - MAX_BAG_ITEM_CAPACITY;
|
||||
if (count == 0)
|
||||
return TRUE;
|
||||
}
|
||||
@@ -910,13 +910,13 @@ bool8 AddPyramidBagItem(u16 itemId, u16 count)
|
||||
|
||||
for (i = 0; i < PYRAMID_BAG_ITEMS_COUNT; i++)
|
||||
{
|
||||
if (newItems[i] == itemId && newQuantities[i] < 99)
|
||||
if (newItems[i] == itemId && newQuantities[i] < MAX_BAG_ITEM_CAPACITY)
|
||||
{
|
||||
newQuantities[i] += count;
|
||||
if (newQuantities[i] > 99)
|
||||
if (newQuantities[i] > MAX_BAG_ITEM_CAPACITY)
|
||||
{
|
||||
count = newQuantities[i] - 99;
|
||||
newQuantities[i] = 99;
|
||||
count = newQuantities[i] - MAX_BAG_ITEM_CAPACITY;
|
||||
newQuantities[i] = MAX_BAG_ITEM_CAPACITY;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -936,10 +936,10 @@ bool8 AddPyramidBagItem(u16 itemId, u16 count)
|
||||
{
|
||||
newItems[i] = itemId;
|
||||
newQuantities[i] = count;
|
||||
if (newQuantities[i] > 99)
|
||||
if (newQuantities[i] > MAX_BAG_ITEM_CAPACITY)
|
||||
{
|
||||
count = newQuantities[i] - 99;
|
||||
newQuantities[i] = 99;
|
||||
count = newQuantities[i] - MAX_BAG_ITEM_CAPACITY;
|
||||
newQuantities[i] = MAX_BAG_ITEM_CAPACITY;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user