Raised the limit of max items per stack to 999 (#3923)

* Expanded the amount of max items per stack from 99 to 999

* Set Battle Pyramid Bag stack limit back to 99
This commit exists for archival purposes.
People who may want to set the limit of item stacks in the Battle Pyramid's bag to 999 can refer to its code diff.

* Reintroduced the Battle Pyramid changes through a MAX_PYRAMID_BAG_ITEM_CAPACITY constant

* Gave 3 digit support to the Battle Pyramid's bag

* Rewrote the comment for MAX_PYRAMID_BAG_ITEM_CAPACITY

* Made DebugAction_Give_Item_SelectQuantity use MAX_ITEM_DIGITS

* Ditched BERRY_CAPACITY_DIGITS and BAG_ITEM_CAPACITY_DIGITS

* Removed MAX_BERRY_CAPACITY
No point in keeping it if we're making all item stacks cap at 999.

* Applied review corrections

* Removed pointless local var in DebugAction_Give_Item_SelectQuantity

* Defined a MAX_PYRAMID_ITEM_DIGITS

* Cleaned up some of the functions in which MAX_ITEM_DIGITS is used

Summary:
-Removed pointless local variables in CheckBagHasSpace, AddBagItem, PrintItemQuantity and PrintItemSoldAmount.
-Removed pointless brackets in an if statement of CheckBagHasSpace.
-Initialized the pocket local variable of CheckBagHasSpace from the get go to save a few lines too.

---------

Co-authored-by: Eduardo Quezada D'Ottone <eduardo602002@gmail.com>
This commit is contained in:
LOuroboros 2024-01-14 16:32:38 -03:00 committed by GitHub
parent 0b149f6b6a
commit 80ffaa5e2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 91 additions and 76 deletions

View file

@ -1022,13 +1022,12 @@
#define NUM_TECHNICAL_MACHINES 100
#define NUM_HIDDEN_MACHINES 8
#define MAX_BAG_ITEM_CAPACITY 99
#define MAX_PC_ITEM_CAPACITY 999
#define MAX_BERRY_CAPACITY 999
#define MAX_BAG_ITEM_CAPACITY 999
#define MAX_PC_ITEM_CAPACITY 999
#define MAX_PYRAMID_BAG_ITEM_CAPACITY 99 // Values higher than 255 require free SaveBlock2 space.
#define BAG_ITEM_CAPACITY_DIGITS 2
#define BERRY_CAPACITY_DIGITS 3
#define MAX_ITEM_DIGITS BERRY_CAPACITY_DIGITS
#define MAX_ITEM_DIGITS ((MAX_BAG_ITEM_CAPACITY > 99) ? 3 : 2)
#define MAX_PYRAMID_ITEM_DIGITS ((MAX_PYRAMID_BAG_ITEM_CAPACITY > 99) ? 3 : 2)
// Secondary IDs for rods
#define OLD_ROD 0

View file

@ -16,6 +16,7 @@
#include "constants/pokemon.h"
#include "constants/easy_chat.h"
#include "constants/trainer_hill.h"
#include "constants/items.h"
// Prevent cross-jump optimization.
#define BLOCK_CROSS_JUMP asm("");
@ -225,7 +226,11 @@ struct BerryPickingResults
struct PyramidBag
{
u16 itemId[FRONTIER_LVL_MODE_COUNT][PYRAMID_BAG_ITEMS_COUNT];
#if MAX_PYRAMID_BAG_ITEM_CAPACITY > 255
u16 quantity[FRONTIER_LVL_MODE_COUNT][PYRAMID_BAG_ITEMS_COUNT];
#else
u8 quantity[FRONTIER_LVL_MODE_COUNT][PYRAMID_BAG_ITEMS_COUNT];
#endif
};
struct BerryCrush

View file

@ -622,7 +622,7 @@ static void CopyBagItemName(u8 *dst, u16 itemId)
{
if (ItemId_GetPocket(itemId) == POCKET_BERRIES)
{
ConvertIntToDecimalStringN(gStringVar1, ITEM_TO_BERRY(itemId), STR_CONV_MODE_LEADING_ZEROS, 2);
ConvertIntToDecimalStringN(gStringVar1, ITEM_TO_BERRY(itemId), STR_CONV_MODE_LEADING_ZEROS, MAX_PYRAMID_ITEM_DIGITS);
CopyItemName(itemId, gStringVar2);
StringExpandPlaceholders(dst, gText_NumberItem_TMBerry);
}
@ -670,7 +670,7 @@ static void PrintItemQuantity(u8 windowId, u32 itemIndex, u8 y)
ConvertIntToDecimalStringN(gStringVar1,
gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode][itemIndex],
STR_CONV_MODE_RIGHT_ALIGN,
2);
MAX_PYRAMID_ITEM_DIGITS);
StringExpandPlaceholders(gStringVar4, gText_xVar1);
xAlign = GetStringRightAlignXOffset(FONT_NARROW, gStringVar4, 119);
PyramidBagPrint_Quantity(windowId, gStringVar4, xAlign, y, 0, 0, TEXT_SKIP_DRAW, COLORID_DARK_GRAY);
@ -727,7 +727,11 @@ static void SwapItems(u8 id1, u8 id2)
{
u16 temp;
u16 *itemIds = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode];
#if MAX_PYRAMID_BAG_ITEM_CAPACITY > 255
u16 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];
#else
u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];
#endif
SWAP(itemIds[id1], itemIds[id2], temp);
SWAP(quantities[id1], quantities[id2], temp);
@ -736,7 +740,11 @@ static void SwapItems(u8 id1, u8 id2)
static void MovePyramidBagItemSlotInList(u8 from, u8 to)
{
u16 *itemIds = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode];
#if MAX_PYRAMID_BAG_ITEM_CAPACITY > 255
u16 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];
#else
u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];
#endif
if (from != to)
{
@ -770,7 +778,11 @@ static void CompactItems(void)
{
u8 i, j;
u16 *itemIds = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode];
#if MAX_PYRAMID_BAG_ITEM_CAPACITY > 255
u16 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];
#else
u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];
#endif
for (i = 0; i < PYRAMID_BAG_ITEMS_COUNT; i++)
{
@ -1148,7 +1160,7 @@ static void AskConfirmToss(u8 taskId)
s16 *data = gTasks[taskId].data;
CopyItemName(gSpecialVar_ItemId, gStringVar1);
ConvertIntToDecimalStringN(gStringVar2, tNumToToss, STR_CONV_MODE_LEFT_ALIGN, 2);
ConvertIntToDecimalStringN(gStringVar2, tNumToToss, STR_CONV_MODE_LEFT_ALIGN, MAX_PYRAMID_ITEM_DIGITS);
StringExpandPlaceholders(gStringVar4, gText_ConfirmTossItems);
FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0));
PyramidBagPrint(WIN_INFO, gStringVar4, 3, 0, 0, 1, 0, COLORID_DARK_GRAY);
@ -1167,7 +1179,7 @@ static void DontTossItem(u8 taskId)
static void ShowNumToToss(void)
{
s32 x;
ConvertIntToDecimalStringN(gStringVar1, 1, STR_CONV_MODE_LEADING_ZEROS, 2);
ConvertIntToDecimalStringN(gStringVar1, 1, STR_CONV_MODE_LEADING_ZEROS, MAX_PYRAMID_ITEM_DIGITS);
StringExpandPlaceholders(gStringVar4, gText_xVar1);
DrawTossNumberWindow(WIN_TOSS_NUM);
x = GetStringCenterAlignXOffset(FONT_NORMAL, gStringVar4, 0x28);
@ -1177,7 +1189,7 @@ static void ShowNumToToss(void)
static void UpdateNumToToss(s16 num)
{
s32 x;
ConvertIntToDecimalStringN(gStringVar1, num, STR_CONV_MODE_LEADING_ZEROS, 2);
ConvertIntToDecimalStringN(gStringVar1, num, STR_CONV_MODE_LEADING_ZEROS, MAX_PYRAMID_ITEM_DIGITS);
StringExpandPlaceholders(gStringVar4, gText_xVar1);
x = GetStringCenterAlignXOffset(FONT_NORMAL, gStringVar4, 0x28);
AddTextPrinterParameterized(WIN_TOSS_NUM, FONT_NORMAL, gStringVar4, x, 2, 0, NULL);
@ -1216,7 +1228,7 @@ static void TossItem(u8 taskId)
s16 *data = gTasks[taskId].data;
CopyItemName(gSpecialVar_ItemId, gStringVar1);
ConvertIntToDecimalStringN(gStringVar2, tNumToToss, STR_CONV_MODE_LEFT_ALIGN, 2);
ConvertIntToDecimalStringN(gStringVar2, tNumToToss, STR_CONV_MODE_LEFT_ALIGN, MAX_PYRAMID_ITEM_DIGITS);
StringExpandPlaceholders(gStringVar4, gText_ThrewAwayVar2Var1s);
FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0));
PyramidBagPrint(WIN_INFO, gStringVar4, 3, 0, 0, 1, 0, COLORID_DARK_GRAY);
@ -1412,7 +1424,11 @@ void TryStoreHeldItemsInPyramidBag(void)
u8 i;
struct Pokemon *party = gPlayerParty;
u16 *newItems = Alloc(PYRAMID_BAG_ITEMS_COUNT * sizeof(*newItems));
#if MAX_PYRAMID_BAG_ITEM_CAPACITY > 255
u16 *newQuantities = Alloc(PYRAMID_BAG_ITEMS_COUNT * sizeof(*newQuantities));
#else
u8 *newQuantities = Alloc(PYRAMID_BAG_ITEMS_COUNT * sizeof(*newQuantities));
#endif
u16 heldItem;
memcpy(newItems, gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode], PYRAMID_BAG_ITEMS_COUNT * sizeof(*newItems));

View file

@ -3012,10 +3012,9 @@ static void DebugAction_Give_Item_SelectQuantity(u8 taskId)
if (JOY_NEW(DPAD_UP))
{
u32 maxCapacity = (ItemId_GetPocket(itemId) - 1 == BERRIES_POCKET) ? MAX_BERRY_CAPACITY : MAX_BAG_ITEM_CAPACITY;
gTasks[taskId].tInput += sPowersOfTen[gTasks[taskId].tDigit];
if (gTasks[taskId].tInput > maxCapacity)
gTasks[taskId].tInput = maxCapacity;
if (gTasks[taskId].tInput > MAX_BAG_ITEM_CAPACITY)
gTasks[taskId].tInput = MAX_BAG_ITEM_CAPACITY;
}
if (JOY_NEW(DPAD_DOWN))
{
@ -3030,7 +3029,7 @@ static void DebugAction_Give_Item_SelectQuantity(u8 taskId)
}
if (JOY_NEW(DPAD_RIGHT))
{
if (gTasks[taskId].tDigit < 2)
if (gTasks[taskId].tDigit < MAX_ITEM_DIGITS)
gTasks[taskId].tDigit += 1;
}
@ -4182,8 +4181,8 @@ static void DebugAction_PCBag_Fill_PocketBerries(u8 taskId)
for (itemId = FIRST_BERRY_INDEX; itemId < LAST_BERRY_INDEX; itemId++)
{
if (CheckBagHasSpace(itemId, MAX_BERRY_CAPACITY))
AddBagItem(itemId, MAX_BERRY_CAPACITY);
if (CheckBagHasSpace(itemId, MAX_BAG_ITEM_CAPACITY))
AddBagItem(itemId, MAX_BAG_ITEM_CAPACITY);
}
}

View file

@ -177,23 +177,14 @@ bool8 HasAtLeastOneBerry(void)
bool8 CheckBagHasSpace(u16 itemId, u16 count)
{
u8 i;
u8 pocket;
u16 slotCapacity;
u8 pocket = ItemId_GetPocket(itemId) - 1;
u16 ownedCount;
if (ItemId_GetPocket(itemId) == POCKET_NONE)
return FALSE;
if (InBattlePyramid() || FlagGet(FLAG_STORING_ITEMS_IN_PYRAMID_BAG) == TRUE)
{
return CheckPyramidBagHasSpace(itemId, count);
}
pocket = ItemId_GetPocket(itemId) - 1;
if (pocket != BERRIES_POCKET)
slotCapacity = MAX_BAG_ITEM_CAPACITY;
else
slotCapacity = MAX_BERRY_CAPACITY;
// Check space in any existing item slots that already contain this item
for (i = 0; i < gBagPockets[pocket].capacity; i++)
@ -201,11 +192,11 @@ bool8 CheckBagHasSpace(u16 itemId, u16 count)
if (gBagPockets[pocket].itemSlots[i].itemId == itemId)
{
ownedCount = GetBagItemQuantity(&gBagPockets[pocket].itemSlots[i].quantity);
if (ownedCount + count <= slotCapacity)
if (ownedCount + count <= MAX_BAG_ITEM_CAPACITY)
return TRUE;
if (pocket == TMHM_POCKET || pocket == BERRIES_POCKET)
return FALSE;
count -= (slotCapacity - ownedCount);
count -= (MAX_BAG_ITEM_CAPACITY - ownedCount);
if (count == 0)
break; //should be return TRUE, but that doesn't match
}
@ -218,11 +209,11 @@ bool8 CheckBagHasSpace(u16 itemId, u16 count)
{
if (gBagPockets[pocket].itemSlots[i].itemId == 0)
{
if (count > slotCapacity)
if (count > MAX_BAG_ITEM_CAPACITY)
{
if (pocket == TMHM_POCKET || pocket == BERRIES_POCKET)
return FALSE;
count -= slotCapacity;
count -= MAX_BAG_ITEM_CAPACITY;
}
else
{
@ -254,7 +245,6 @@ bool8 AddBagItem(u16 itemId, u16 count)
{
struct BagPocket *itemPocket;
struct ItemSlot *newItems;
u16 slotCapacity;
u16 ownedCount;
u8 pocket = ItemId_GetPocket(itemId) - 1;
@ -262,18 +252,13 @@ bool8 AddBagItem(u16 itemId, u16 count)
newItems = AllocZeroed(itemPocket->capacity * sizeof(struct ItemSlot));
memcpy(newItems, itemPocket->itemSlots, itemPocket->capacity * sizeof(struct ItemSlot));
if (pocket != BERRIES_POCKET)
slotCapacity = MAX_BAG_ITEM_CAPACITY;
else
slotCapacity = MAX_BERRY_CAPACITY;
for (i = 0; i < itemPocket->capacity; i++)
{
if (newItems[i].itemId == itemId)
{
ownedCount = GetBagItemQuantity(&newItems[i].quantity);
// check if won't exceed max slot capacity
if (ownedCount + count <= slotCapacity)
if (ownedCount + count <= MAX_BAG_ITEM_CAPACITY)
{
// successfully added to already existing item's count
SetBagItemQuantity(&newItems[i].quantity, ownedCount + count);
@ -291,8 +276,8 @@ bool8 AddBagItem(u16 itemId, u16 count)
}
else
{
count -= slotCapacity - ownedCount;
SetBagItemQuantity(&newItems[i].quantity, slotCapacity);
count -= MAX_BAG_ITEM_CAPACITY - ownedCount;
SetBagItemQuantity(&newItems[i].quantity, MAX_BAG_ITEM_CAPACITY);
// don't create another instance of the item if it's at max slot capacity and count is equal to 0
if (count == 0)
{
@ -312,7 +297,7 @@ bool8 AddBagItem(u16 itemId, u16 count)
if (newItems[i].itemId == ITEM_NONE)
{
newItems[i].itemId = itemId;
if (count > slotCapacity)
if (count > MAX_BAG_ITEM_CAPACITY)
{
// try creating a new slot with max capacity if duplicates are possible
if (pocket == TMHM_POCKET || pocket == BERRIES_POCKET)
@ -320,8 +305,8 @@ bool8 AddBagItem(u16 itemId, u16 count)
Free(newItems);
return FALSE;
}
count -= slotCapacity;
SetBagItemQuantity(&newItems[i].quantity, slotCapacity);
count -= MAX_BAG_ITEM_CAPACITY;
SetBagItemQuantity(&newItems[i].quantity, MAX_BAG_ITEM_CAPACITY);
}
else
{
@ -690,7 +675,11 @@ static bool8 CheckPyramidBagHasItem(u16 itemId, u16 count)
{
u8 i;
u16 *items = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode];
#if MAX_PYRAMID_BAG_ITEM_CAPACITY > 255
u16 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];
#else
u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];
#endif
for (i = 0; i < PYRAMID_BAG_ITEMS_COUNT; i++)
{
@ -712,16 +701,20 @@ static bool8 CheckPyramidBagHasSpace(u16 itemId, u16 count)
{
u8 i;
u16 *items = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode];
#if MAX_PYRAMID_BAG_ITEM_CAPACITY > 255
u16 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];
#else
u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];
#endif
for (i = 0; i < PYRAMID_BAG_ITEMS_COUNT; i++)
{
if (items[i] == itemId || items[i] == ITEM_NONE)
{
if (quantities[i] + count <= MAX_BAG_ITEM_CAPACITY)
if (quantities[i] + count <= MAX_PYRAMID_BAG_ITEM_CAPACITY)
return TRUE;
count = (quantities[i] + count) - MAX_BAG_ITEM_CAPACITY;
count = (quantities[i] + count) - MAX_PYRAMID_BAG_ITEM_CAPACITY;
if (count == 0)
return TRUE;
}
@ -735,23 +728,28 @@ bool8 AddPyramidBagItem(u16 itemId, u16 count)
u16 i;
u16 *items = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode];
u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];
u16 *newItems = Alloc(PYRAMID_BAG_ITEMS_COUNT * sizeof(*newItems));
#if MAX_PYRAMID_BAG_ITEM_CAPACITY > 255
u16 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];
u16 *newQuantities = Alloc(PYRAMID_BAG_ITEMS_COUNT * sizeof(*newQuantities));
#else
u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];
u8 *newQuantities = Alloc(PYRAMID_BAG_ITEMS_COUNT * sizeof(*newQuantities));
#endif
memcpy(newItems, items, PYRAMID_BAG_ITEMS_COUNT * sizeof(*newItems));
memcpy(newQuantities, quantities, PYRAMID_BAG_ITEMS_COUNT * sizeof(*newQuantities));
for (i = 0; i < PYRAMID_BAG_ITEMS_COUNT; i++)
{
if (newItems[i] == itemId && newQuantities[i] < MAX_BAG_ITEM_CAPACITY)
if (newItems[i] == itemId && newQuantities[i] < MAX_PYRAMID_BAG_ITEM_CAPACITY)
{
newQuantities[i] += count;
if (newQuantities[i] > MAX_BAG_ITEM_CAPACITY)
if (newQuantities[i] > MAX_PYRAMID_BAG_ITEM_CAPACITY)
{
count = newQuantities[i] - MAX_BAG_ITEM_CAPACITY;
newQuantities[i] = MAX_BAG_ITEM_CAPACITY;
count = newQuantities[i] - MAX_PYRAMID_BAG_ITEM_CAPACITY;
newQuantities[i] = MAX_PYRAMID_BAG_ITEM_CAPACITY;
}
else
{
@ -771,10 +769,10 @@ bool8 AddPyramidBagItem(u16 itemId, u16 count)
{
newItems[i] = itemId;
newQuantities[i] = count;
if (newQuantities[i] > MAX_BAG_ITEM_CAPACITY)
if (newQuantities[i] > MAX_PYRAMID_BAG_ITEM_CAPACITY)
{
count = newQuantities[i] - MAX_BAG_ITEM_CAPACITY;
newQuantities[i] = MAX_BAG_ITEM_CAPACITY;
count = newQuantities[i] - MAX_PYRAMID_BAG_ITEM_CAPACITY;
newQuantities[i] = MAX_PYRAMID_BAG_ITEM_CAPACITY;
}
else
{
@ -808,7 +806,11 @@ bool8 RemovePyramidBagItem(u16 itemId, u16 count)
u16 i;
u16 *items = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode];
#if MAX_PYRAMID_BAG_ITEM_CAPACITY > 255
u16 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];
#else
u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];
#endif
i = gPyramidBagMenuState.cursorPosition + gPyramidBagMenuState.scrollPosition;
if (items[i] == itemId && quantities[i] >= count)
@ -821,7 +823,11 @@ bool8 RemovePyramidBagItem(u16 itemId, u16 count)
else
{
u16 *newItems = Alloc(PYRAMID_BAG_ITEMS_COUNT * sizeof(*newItems));
#if MAX_PYRAMID_BAG_ITEM_CAPACITY > 255
u16 *newQuantities = Alloc(PYRAMID_BAG_ITEMS_COUNT * sizeof(*newQuantities));
#else
u8 *newQuantities = Alloc(PYRAMID_BAG_ITEMS_COUNT * sizeof(*newQuantities));
#endif
memcpy(newItems, items, PYRAMID_BAG_ITEMS_COUNT * sizeof(*newItems));
memcpy(newQuantities, quantities, PYRAMID_BAG_ITEMS_COUNT * sizeof(*newQuantities));

View file

@ -977,18 +977,10 @@ static void BagMenu_ItemPrintCallback(u8 windowId, u32 itemIndex, u8 y)
if (itemId >= ITEM_HM01 && itemId <= ITEM_HM08)
BlitBitmapToWindow(windowId, gBagMenuHMIcon_Gfx, 8, y - 1, 16, 16);
if (gBagPosition.pocket == BERRIES_POCKET)
{
// Print berry quantity
ConvertIntToDecimalStringN(gStringVar1, itemQuantity, STR_CONV_MODE_RIGHT_ALIGN, BERRY_CAPACITY_DIGITS);
StringExpandPlaceholders(gStringVar4, gText_xVar1);
offset = GetStringRightAlignXOffset(FONT_NARROW, gStringVar4, 119);
BagMenu_Print(windowId, FONT_NARROW, gStringVar4, offset, y, 0, 0, TEXT_SKIP_DRAW, COLORID_NORMAL);
}
else if (gBagPosition.pocket != KEYITEMS_POCKET && ItemId_GetImportance(itemId) == FALSE)
if (gBagPosition.pocket != KEYITEMS_POCKET && ItemId_GetImportance(itemId) == FALSE)
{
// Print item quantity
ConvertIntToDecimalStringN(gStringVar1, itemQuantity, STR_CONV_MODE_RIGHT_ALIGN, BAG_ITEM_CAPACITY_DIGITS);
ConvertIntToDecimalStringN(gStringVar1, itemQuantity, STR_CONV_MODE_RIGHT_ALIGN, MAX_ITEM_DIGITS);
StringExpandPlaceholders(gStringVar4, gText_xVar1);
offset = GetStringRightAlignXOffset(FONT_NARROW, gStringVar4, 119);
BagMenu_Print(windowId, FONT_NARROW, gStringVar4, offset, y, 0, 0, TEXT_SKIP_DRAW, COLORID_NORMAL);
@ -1218,8 +1210,7 @@ static void AddItemQuantityWindow(u8 windowType)
static void PrintItemQuantity(u8 windowId, s16 quantity)
{
u8 numDigits = (gBagPosition.pocket == BERRIES_POCKET) ? BERRY_CAPACITY_DIGITS : BAG_ITEM_CAPACITY_DIGITS;
ConvertIntToDecimalStringN(gStringVar1, quantity, STR_CONV_MODE_LEADING_ZEROS, numDigits);
ConvertIntToDecimalStringN(gStringVar1, quantity, STR_CONV_MODE_LEADING_ZEROS, MAX_ITEM_DIGITS);
StringExpandPlaceholders(gStringVar4, gText_xVar1);
AddTextPrinterParameterized(windowId, FONT_NORMAL, gStringVar4, GetStringCenterAlignXOffset(FONT_NORMAL, gStringVar4, 0x28), 2, 0, 0);
}
@ -1227,8 +1218,7 @@ static void PrintItemQuantity(u8 windowId, s16 quantity)
// Prints the quantity of items to be sold and the amount that would be earned
static void PrintItemSoldAmount(int windowId, int numSold, int moneyEarned)
{
u8 numDigits = (gBagPosition.pocket == BERRIES_POCKET) ? BERRY_CAPACITY_DIGITS : BAG_ITEM_CAPACITY_DIGITS;
ConvertIntToDecimalStringN(gStringVar1, numSold, STR_CONV_MODE_LEADING_ZEROS, numDigits);
ConvertIntToDecimalStringN(gStringVar1, numSold, STR_CONV_MODE_LEADING_ZEROS, MAX_ITEM_DIGITS);
StringExpandPlaceholders(gStringVar4, gText_xVar1);
AddTextPrinterParameterized(windowId, FONT_NORMAL, gStringVar4, 0, 1, TEXT_SKIP_DRAW, 0);
PrintMoneyAmount(windowId, 38, 1, moneyEarned, 0);

View file

@ -493,7 +493,7 @@ bool8 ScrCmd_additem(struct ScriptContext *ctx)
u16 itemId = VarGet(ScriptReadHalfword(ctx));
u32 quantity = VarGet(ScriptReadHalfword(ctx));
gSpecialVar_Result = AddBagItem(itemId, (u8)quantity);
gSpecialVar_Result = AddBagItem(itemId, quantity);
return FALSE;
}
@ -502,7 +502,7 @@ bool8 ScrCmd_removeitem(struct ScriptContext *ctx)
u16 itemId = VarGet(ScriptReadHalfword(ctx));
u32 quantity = VarGet(ScriptReadHalfword(ctx));
gSpecialVar_Result = RemoveBagItem(itemId, (u8)quantity);
gSpecialVar_Result = RemoveBagItem(itemId, quantity);
return FALSE;
}
@ -511,7 +511,7 @@ bool8 ScrCmd_checkitemspace(struct ScriptContext *ctx)
u16 itemId = VarGet(ScriptReadHalfword(ctx));
u32 quantity = VarGet(ScriptReadHalfword(ctx));
gSpecialVar_Result = CheckBagHasSpace(itemId, (u8)quantity);
gSpecialVar_Result = CheckBagHasSpace(itemId, quantity);
return FALSE;
}
@ -520,7 +520,7 @@ bool8 ScrCmd_checkitem(struct ScriptContext *ctx)
u16 itemId = VarGet(ScriptReadHalfword(ctx));
u32 quantity = VarGet(ScriptReadHalfword(ctx));
gSpecialVar_Result = CheckBagHasItem(itemId, (u8)quantity);
gSpecialVar_Result = CheckBagHasItem(itemId, quantity);
return FALSE;
}

View file

@ -97,7 +97,7 @@ struct ShopData
u16 itemsShowed;
u16 selectedRow;
u16 scrollOffset;
u8 maxQuantity;
u16 maxQuantity;
u8 scrollIndicatorsTaskId;
u8 iconSlot;
u8 itemSpriteIds[2];
@ -1085,7 +1085,7 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId)
ClearWindowTilemap(WIN_QUANTITY_IN_BAG);
PutWindowTilemap(WIN_ITEM_LIST);
CopyItemName(tItemId, gStringVar1);
ConvertIntToDecimalStringN(gStringVar2, tItemCount, STR_CONV_MODE_LEFT_ALIGN, BAG_ITEM_CAPACITY_DIGITS);
ConvertIntToDecimalStringN(gStringVar2, tItemCount, STR_CONV_MODE_LEFT_ALIGN, MAX_ITEM_DIGITS);
ConvertIntToDecimalStringN(gStringVar3, sShopData->totalCost, STR_CONV_MODE_LEFT_ALIGN, 6);
BuyMenuDisplayMessage(taskId, gText_Var1AndYouWantedVar2, BuyMenuConfirmPurchase);
}
@ -1198,7 +1198,7 @@ static void BuyMenuPrintItemQuantityAndPrice(u8 taskId)
FillWindowPixelBuffer(WIN_QUANTITY_PRICE, PIXEL_FILL(1));
PrintMoneyAmount(WIN_QUANTITY_PRICE, 38, 1, sShopData->totalCost, TEXT_SKIP_DRAW);
ConvertIntToDecimalStringN(gStringVar1, tItemCount, STR_CONV_MODE_LEADING_ZEROS, BAG_ITEM_CAPACITY_DIGITS);
ConvertIntToDecimalStringN(gStringVar1, tItemCount, STR_CONV_MODE_LEADING_ZEROS, MAX_ITEM_DIGITS);
StringExpandPlaceholders(gStringVar4, gText_xVar1);
BuyMenuPrint(WIN_QUANTITY_PRICE, gStringVar4, 0, 1, 0, COLORID_NORMAL);
}