mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 11:37:40 +01:00
Add some capacity constants
This commit is contained in:
parent
7232bfecc2
commit
9a6c2c25d0
@ -491,6 +491,10 @@
|
||||
#define NUM_TECHNICAL_MACHINES 50
|
||||
#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.
|
||||
#define ITEM_HAS_EFFECT(item) ((item) >= ITEM_POTION && (item) <= ITEM_0B2)
|
||||
|
||||
|
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
|
||||
{
|
||||
|
@ -994,9 +994,9 @@ static void Task_BuyHowManyDialogueInit(u8 taskId)
|
||||
|
||||
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
|
||||
{
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "main_menu.h"
|
||||
#include "bg.h"
|
||||
#include "window.h"
|
||||
#include "constants/coins.h"
|
||||
|
||||
// Text
|
||||
extern const u8 gText_YouDontHaveThreeCoins[];
|
||||
@ -974,7 +975,7 @@ static bool8 SlotAction4(struct Task *task)
|
||||
{
|
||||
sub_8104CAC(0);
|
||||
sSlotMachine->state = 5;
|
||||
if (sSlotMachine->coins >= 9999)
|
||||
if (sSlotMachine->coins >= MAX_COINS)
|
||||
sSlotMachine->state = 23;
|
||||
return TRUE;
|
||||
}
|
||||
@ -1186,8 +1187,8 @@ static bool8 SlotAction_CheckMatches(struct Task *task)
|
||||
{
|
||||
sub_8104CAC(3);
|
||||
sSlotMachine->state = 20;
|
||||
if ((sSlotMachine->netCoinLoss += sSlotMachine->bet) > 9999)
|
||||
sSlotMachine->netCoinLoss = 9999;
|
||||
if ((sSlotMachine->netCoinLoss += sSlotMachine->bet) > MAX_COINS)
|
||||
sSlotMachine->netCoinLoss = MAX_COINS;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
@ -1693,7 +1694,7 @@ static bool8 AwardPayoutAction_GivePayoutToPlayer(struct Task *task)
|
||||
if (IsFanfareTaskInactive())
|
||||
PlaySE(SE_PIN);
|
||||
sSlotMachine->payout--;
|
||||
if (sSlotMachine->coins < 9999)
|
||||
if (sSlotMachine->coins < MAX_COINS)
|
||||
sSlotMachine->coins++;
|
||||
task->data[1] = 8;
|
||||
if (gMain.heldKeys & A_BUTTON)
|
||||
@ -1703,8 +1704,8 @@ static bool8 AwardPayoutAction_GivePayoutToPlayer(struct Task *task)
|
||||
{
|
||||
PlaySE(SE_PIN);
|
||||
sSlotMachine->coins += sSlotMachine->payout;
|
||||
if (sSlotMachine->coins > 9999)
|
||||
sSlotMachine->coins = 9999;
|
||||
if (sSlotMachine->coins > MAX_COINS)
|
||||
sSlotMachine->coins = MAX_COINS;
|
||||
sSlotMachine->payout = 0;
|
||||
}
|
||||
if (sSlotMachine->payout == 0)
|
||||
@ -3291,9 +3292,9 @@ static void sub_8104F8C(void)
|
||||
s16 i;
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user