Add some capacity constants

This commit is contained in:
GriffinR
2020-01-26 04:02:15 -05:00
committed by huderlem
parent 7232bfecc2
commit 9a6c2c25d0
4 changed files with 31 additions and 26 deletions
+4
View File
@@ -491,6 +491,10 @@
#define NUM_TECHNICAL_MACHINES 50 #define NUM_TECHNICAL_MACHINES 50
#define NUM_HIDDEN_MACHINES 8 #define NUM_HIDDEN_MACHINES 8
#define MAX_BAG_ITEM_CAPACITY 99
#define MAX_PC_ITEM_CAPACITY 999
#define MAX_BERRY_CAPACITY 999
// Check if the item is one that can be used on a Pokemon. // Check if the item is one that can be used on a Pokemon.
#define ITEM_HAS_EFFECT(item) ((item) >= ITEM_POTION && (item) <= ITEM_0B2) #define ITEM_HAS_EFFECT(item) ((item) >= ITEM_POTION && (item) <= ITEM_0B2)
+16 -16
View File
@@ -202,9 +202,9 @@ bool8 CheckBagHasSpace(u16 itemId, u16 count)
pocket = ItemId_GetPocket(itemId) - 1; pocket = ItemId_GetPocket(itemId) - 1;
if (pocket != BERRIES_POCKET) if (pocket != BERRIES_POCKET)
slotCapacity = 99; slotCapacity = MAX_BAG_ITEM_CAPACITY;
else else
slotCapacity = 999; slotCapacity = MAX_BERRY_CAPACITY;
// Check space in any existing item slots that already contain this item // Check space in any existing item slots that already contain this item
for (i = 0; i < gBagPockets[pocket].capacity; i++) 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)); memcpy(newItems, itemPocket->itemSlots, itemPocket->capacity * sizeof(struct ItemSlot));
if (pocket != BERRIES_POCKET) if (pocket != BERRIES_POCKET)
slotCapacity = 99; slotCapacity = MAX_BAG_ITEM_CAPACITY;
else else
slotCapacity = 999; slotCapacity = MAX_BERRY_CAPACITY;
for (i = 0; i < itemPocket->capacity; i++) for (i = 0; i < itemPocket->capacity; i++)
{ {
@@ -667,15 +667,15 @@ bool8 AddPCItem(u16 itemId, u16 count)
if (newItems[i].itemId == itemId) if (newItems[i].itemId == itemId)
{ {
ownedCount = GetPCItemQuantity(&newItems[i].quantity); ownedCount = GetPCItemQuantity(&newItems[i].quantity);
if (ownedCount + count <= 999) if (ownedCount + count <= MAX_PC_ITEM_CAPACITY)
{ {
SetPCItemQuantity(&newItems[i].quantity, ownedCount + count); SetPCItemQuantity(&newItems[i].quantity, ownedCount + count);
memcpy(gSaveBlock1Ptr->pcItems, newItems, sizeof(gSaveBlock1Ptr->pcItems)); memcpy(gSaveBlock1Ptr->pcItems, newItems, sizeof(gSaveBlock1Ptr->pcItems));
Free(newItems); Free(newItems);
return TRUE; return TRUE;
} }
count += ownedCount - 999; count += ownedCount - MAX_PC_ITEM_CAPACITY;
SetPCItemQuantity(&newItems[i].quantity, 999); SetPCItemQuantity(&newItems[i].quantity, MAX_PC_ITEM_CAPACITY);
if (count == 0) if (count == 0)
{ {
memcpy(gSaveBlock1Ptr->pcItems, newItems, sizeof(gSaveBlock1Ptr->pcItems)); 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 (items[i] == itemId || items[i] == ITEM_NONE)
{ {
if (quantities[i] + count <= 99) if (quantities[i] + count <= MAX_BAG_ITEM_CAPACITY)
return TRUE; return TRUE;
count = (quantities[i] + count) - 99; count = (quantities[i] + count) - MAX_BAG_ITEM_CAPACITY;
if (count == 0) if (count == 0)
return TRUE; return TRUE;
} }
@@ -910,13 +910,13 @@ bool8 AddPyramidBagItem(u16 itemId, u16 count)
for (i = 0; i < PYRAMID_BAG_ITEMS_COUNT; i++) 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; newQuantities[i] += count;
if (newQuantities[i] > 99) if (newQuantities[i] > MAX_BAG_ITEM_CAPACITY)
{ {
count = newQuantities[i] - 99; count = newQuantities[i] - MAX_BAG_ITEM_CAPACITY;
newQuantities[i] = 99; newQuantities[i] = MAX_BAG_ITEM_CAPACITY;
} }
else else
{ {
@@ -936,10 +936,10 @@ bool8 AddPyramidBagItem(u16 itemId, u16 count)
{ {
newItems[i] = itemId; newItems[i] = itemId;
newQuantities[i] = count; newQuantities[i] = count;
if (newQuantities[i] > 99) if (newQuantities[i] > MAX_BAG_ITEM_CAPACITY)
{ {
count = newQuantities[i] - 99; count = newQuantities[i] - MAX_BAG_ITEM_CAPACITY;
newQuantities[i] = 99; newQuantities[i] = MAX_BAG_ITEM_CAPACITY;
} }
else else
{ {
+2 -2
View File
@@ -994,9 +994,9 @@ static void Task_BuyHowManyDialogueInit(u8 taskId)
maxQuantity = GetMoney(&gSaveBlock1Ptr->money) / gShopDataPtr->totalCost; maxQuantity = GetMoney(&gSaveBlock1Ptr->money) / gShopDataPtr->totalCost;
if (maxQuantity > 99) if (maxQuantity > MAX_BAG_ITEM_CAPACITY)
{ {
gShopDataPtr->maxQuantity = 99; gShopDataPtr->maxQuantity = MAX_BAG_ITEM_CAPACITY;
} }
else else
{ {
+9 -8
View File
@@ -24,6 +24,7 @@
#include "main_menu.h" #include "main_menu.h"
#include "bg.h" #include "bg.h"
#include "window.h" #include "window.h"
#include "constants/coins.h"
// Text // Text
extern const u8 gText_YouDontHaveThreeCoins[]; extern const u8 gText_YouDontHaveThreeCoins[];
@@ -974,7 +975,7 @@ static bool8 SlotAction4(struct Task *task)
{ {
sub_8104CAC(0); sub_8104CAC(0);
sSlotMachine->state = 5; sSlotMachine->state = 5;
if (sSlotMachine->coins >= 9999) if (sSlotMachine->coins >= MAX_COINS)
sSlotMachine->state = 23; sSlotMachine->state = 23;
return TRUE; return TRUE;
} }
@@ -1186,8 +1187,8 @@ static bool8 SlotAction_CheckMatches(struct Task *task)
{ {
sub_8104CAC(3); sub_8104CAC(3);
sSlotMachine->state = 20; sSlotMachine->state = 20;
if ((sSlotMachine->netCoinLoss += sSlotMachine->bet) > 9999) if ((sSlotMachine->netCoinLoss += sSlotMachine->bet) > MAX_COINS)
sSlotMachine->netCoinLoss = 9999; sSlotMachine->netCoinLoss = MAX_COINS;
} }
return FALSE; return FALSE;
} }
@@ -1693,7 +1694,7 @@ static bool8 AwardPayoutAction_GivePayoutToPlayer(struct Task *task)
if (IsFanfareTaskInactive()) if (IsFanfareTaskInactive())
PlaySE(SE_PIN); PlaySE(SE_PIN);
sSlotMachine->payout--; sSlotMachine->payout--;
if (sSlotMachine->coins < 9999) if (sSlotMachine->coins < MAX_COINS)
sSlotMachine->coins++; sSlotMachine->coins++;
task->data[1] = 8; task->data[1] = 8;
if (gMain.heldKeys & A_BUTTON) if (gMain.heldKeys & A_BUTTON)
@@ -1703,8 +1704,8 @@ static bool8 AwardPayoutAction_GivePayoutToPlayer(struct Task *task)
{ {
PlaySE(SE_PIN); PlaySE(SE_PIN);
sSlotMachine->coins += sSlotMachine->payout; sSlotMachine->coins += sSlotMachine->payout;
if (sSlotMachine->coins > 9999) if (sSlotMachine->coins > MAX_COINS)
sSlotMachine->coins = 9999; sSlotMachine->coins = MAX_COINS;
sSlotMachine->payout = 0; sSlotMachine->payout = 0;
} }
if (sSlotMachine->payout == 0) if (sSlotMachine->payout == 0)
@@ -3291,9 +3292,9 @@ static void sub_8104F8C(void)
s16 i; s16 i;
s16 x; s16 x;
for (x = 203, i = 1; i < 10000; i *= 10, x -= 7) for (x = 203, i = 1; i <= MAX_COINS; i *= 10, x -= 7)
sub_8104FF4(x, 23, 0, i); sub_8104FF4(x, 23, 0, i);
for (x = 235, i = 1; i < 10000; i *= 10, x -= 7) for (x = 235, i = 1; i <= MAX_COINS; i *= 10, x -= 7)
sub_8104FF4(x, 23, 1, i); sub_8104FF4(x, 23, 1, i);
} }