mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-27 13:53:52 +01:00
Clean up shop.c
This commit is contained in:
parent
6127c6f32e
commit
9773b436d2
261
src/shop.c
261
src/shop.c
@ -40,11 +40,14 @@
|
|||||||
#include "constants/songs.h"
|
#include "constants/songs.h"
|
||||||
#include "constants/tv.h"
|
#include "constants/tv.h"
|
||||||
|
|
||||||
EWRAM_DATA struct MartInfo gMartInfo = {0};
|
#define TAG_SCROLL_ARROW 2100
|
||||||
EWRAM_DATA struct ShopData *gShopDataPtr = NULL;
|
#define TAG_ITEM_ICON_BASE 2110
|
||||||
EWRAM_DATA struct ListMenuItem *gUnknown_02039F74 = NULL;
|
|
||||||
EWRAM_DATA u8 (*gUnknown_02039F78)[16] = {0};
|
static EWRAM_DATA struct MartInfo sMartInfo = {0};
|
||||||
EWRAM_DATA u8 gMartPurchaseHistoryId = 0;
|
static EWRAM_DATA struct ShopData *sShopData = NULL;
|
||||||
|
static EWRAM_DATA struct ListMenuItem *sListMenuItems = NULL;
|
||||||
|
static EWRAM_DATA u8 (*sItemNames)[16] = {0};
|
||||||
|
static EWRAM_DATA u8 sPurchaseHistoryId = 0;
|
||||||
EWRAM_DATA struct ItemSlot gMartPurchaseHistory[3] = {0};
|
EWRAM_DATA struct ItemSlot gMartPurchaseHistory[3] = {0};
|
||||||
|
|
||||||
static void Task_ShopMenu(u8 taskId);
|
static void Task_ShopMenu(u8 taskId);
|
||||||
@ -276,15 +279,15 @@ static u8 CreateShopMenu(u8 martType)
|
|||||||
int numMenuItems;
|
int numMenuItems;
|
||||||
|
|
||||||
ScriptContext2_Enable();
|
ScriptContext2_Enable();
|
||||||
gMartInfo.martType = martType;
|
sMartInfo.martType = martType;
|
||||||
|
|
||||||
if (martType == MART_TYPE_NORMAL)
|
if (martType == MART_TYPE_NORMAL)
|
||||||
{
|
{
|
||||||
struct WindowTemplate winTemplate;
|
struct WindowTemplate winTemplate;
|
||||||
winTemplate = sShopMenuWindowTemplates[0];
|
winTemplate = sShopMenuWindowTemplates[0];
|
||||||
winTemplate.width = GetMaxWidthInMenuTable(sShopMenuActions_BuySellQuit, ARRAY_COUNT(sShopMenuActions_BuySellQuit));
|
winTemplate.width = GetMaxWidthInMenuTable(sShopMenuActions_BuySellQuit, ARRAY_COUNT(sShopMenuActions_BuySellQuit));
|
||||||
gMartInfo.windowId = AddWindow(&winTemplate);
|
sMartInfo.windowId = AddWindow(&winTemplate);
|
||||||
gMartInfo.menuActions = sShopMenuActions_BuySellQuit;
|
sMartInfo.menuActions = sShopMenuActions_BuySellQuit;
|
||||||
numMenuItems = ARRAY_COUNT(sShopMenuActions_BuySellQuit);
|
numMenuItems = ARRAY_COUNT(sShopMenuActions_BuySellQuit);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -292,35 +295,35 @@ static u8 CreateShopMenu(u8 martType)
|
|||||||
struct WindowTemplate winTemplate;
|
struct WindowTemplate winTemplate;
|
||||||
winTemplate = sShopMenuWindowTemplates[1];
|
winTemplate = sShopMenuWindowTemplates[1];
|
||||||
winTemplate.width = GetMaxWidthInMenuTable(sShopMenuActions_BuyQuit, ARRAY_COUNT(sShopMenuActions_BuyQuit));
|
winTemplate.width = GetMaxWidthInMenuTable(sShopMenuActions_BuyQuit, ARRAY_COUNT(sShopMenuActions_BuyQuit));
|
||||||
gMartInfo.windowId = AddWindow(&winTemplate);
|
sMartInfo.windowId = AddWindow(&winTemplate);
|
||||||
gMartInfo.menuActions = sShopMenuActions_BuyQuit;
|
sMartInfo.menuActions = sShopMenuActions_BuyQuit;
|
||||||
numMenuItems = ARRAY_COUNT(sShopMenuActions_BuyQuit);
|
numMenuItems = ARRAY_COUNT(sShopMenuActions_BuyQuit);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetStandardWindowBorderStyle(gMartInfo.windowId, 0);
|
SetStandardWindowBorderStyle(sMartInfo.windowId, 0);
|
||||||
PrintMenuTable(gMartInfo.windowId, numMenuItems, gMartInfo.menuActions);
|
PrintMenuTable(sMartInfo.windowId, numMenuItems, sMartInfo.menuActions);
|
||||||
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(gMartInfo.windowId, numMenuItems, 0);
|
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sMartInfo.windowId, numMenuItems, 0);
|
||||||
PutWindowTilemap(gMartInfo.windowId);
|
PutWindowTilemap(sMartInfo.windowId);
|
||||||
CopyWindowToVram(gMartInfo.windowId, 1);
|
CopyWindowToVram(sMartInfo.windowId, 1);
|
||||||
|
|
||||||
return CreateTask(Task_ShopMenu, 8);
|
return CreateTask(Task_ShopMenu, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetShopMenuCallback(void (* callback)(void))
|
static void SetShopMenuCallback(void (* callback)(void))
|
||||||
{
|
{
|
||||||
gMartInfo.callback = callback;
|
sMartInfo.callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetShopItemsForSale(const u16 *items)
|
static void SetShopItemsForSale(const u16 *items)
|
||||||
{
|
{
|
||||||
u16 i = 0;
|
u16 i = 0;
|
||||||
|
|
||||||
gMartInfo.itemList = items;
|
sMartInfo.itemList = items;
|
||||||
gMartInfo.itemCount = 0;
|
sMartInfo.itemCount = 0;
|
||||||
|
|
||||||
while (gMartInfo.itemList[i])
|
while (sMartInfo.itemList[i])
|
||||||
{
|
{
|
||||||
gMartInfo.itemCount++;
|
sMartInfo.itemCount++;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -337,7 +340,7 @@ static void Task_ShopMenu(u8 taskId)
|
|||||||
Task_HandleShopMenuQuit(taskId);
|
Task_HandleShopMenuQuit(taskId);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
gMartInfo.menuActions[inputCode].func.void_u8(taskId);
|
sMartInfo.menuActions[inputCode].func.void_u8(taskId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -368,14 +371,14 @@ void CB2_ExitSellMenu(void)
|
|||||||
|
|
||||||
static void Task_HandleShopMenuQuit(u8 taskId)
|
static void Task_HandleShopMenuQuit(u8 taskId)
|
||||||
{
|
{
|
||||||
ClearStdWindowAndFrameToTransparent(gMartInfo.windowId, 2);
|
ClearStdWindowAndFrameToTransparent(sMartInfo.windowId, 2);
|
||||||
RemoveWindow(gMartInfo.windowId);
|
RemoveWindow(sMartInfo.windowId);
|
||||||
SaveRecordedItemPurchasesForTVShow();
|
SaveRecordedItemPurchasesForTVShow();
|
||||||
ScriptContext2_Disable();
|
ScriptContext2_Disable();
|
||||||
DestroyTask(taskId);
|
DestroyTask(taskId);
|
||||||
|
|
||||||
if (gMartInfo.callback)
|
if (sMartInfo.callback)
|
||||||
gMartInfo.callback();
|
sMartInfo.callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Task_GoToBuyOrSellMenu(u8 taskId)
|
static void Task_GoToBuyOrSellMenu(u8 taskId)
|
||||||
@ -398,7 +401,7 @@ static void Task_ReturnToShopMenu(u8 taskId)
|
|||||||
{
|
{
|
||||||
if (IsWeatherNotFadingIn() == TRUE)
|
if (IsWeatherNotFadingIn() == TRUE)
|
||||||
{
|
{
|
||||||
if (gMartInfo.martType == MART_TYPE_DECOR2)
|
if (sMartInfo.martType == MART_TYPE_DECOR2)
|
||||||
DisplayItemMessageOnField(taskId, gText_CanIHelpWithAnythingElse, ShowShopMenuAfterExitingBuyOrSellMenu);
|
DisplayItemMessageOnField(taskId, gText_CanIHelpWithAnythingElse, ShowShopMenuAfterExitingBuyOrSellMenu);
|
||||||
else
|
else
|
||||||
DisplayItemMessageOnField(taskId, gText_AnythingElseICanHelp, ShowShopMenuAfterExitingBuyOrSellMenu);
|
DisplayItemMessageOnField(taskId, gText_AnythingElseICanHelp, ShowShopMenuAfterExitingBuyOrSellMenu);
|
||||||
@ -407,7 +410,7 @@ static void Task_ReturnToShopMenu(u8 taskId)
|
|||||||
|
|
||||||
static void ShowShopMenuAfterExitingBuyOrSellMenu(u8 taskId)
|
static void ShowShopMenuAfterExitingBuyOrSellMenu(u8 taskId)
|
||||||
{
|
{
|
||||||
CreateShopMenu(gMartInfo.martType);
|
CreateShopMenu(sMartInfo.martType);
|
||||||
DestroyTask(taskId);
|
DestroyTask(taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,10 +450,10 @@ static void CB2_InitBuyMenu(void)
|
|||||||
ResetSpriteData();
|
ResetSpriteData();
|
||||||
ResetTasks();
|
ResetTasks();
|
||||||
ClearScheduledBgCopiesToVram();
|
ClearScheduledBgCopiesToVram();
|
||||||
gShopDataPtr = AllocZeroed(sizeof(struct ShopData));
|
sShopData = AllocZeroed(sizeof(struct ShopData));
|
||||||
gShopDataPtr->scrollIndicatorsTaskId = TASK_NONE;
|
sShopData->scrollIndicatorsTaskId = TASK_NONE;
|
||||||
gShopDataPtr->itemSpriteIds[0] = SPRITE_NONE;
|
sShopData->itemSpriteIds[0] = SPRITE_NONE;
|
||||||
gShopDataPtr->itemSpriteIds[1] = SPRITE_NONE;
|
sShopData->itemSpriteIds[1] = SPRITE_NONE;
|
||||||
BuyMenuBuildListMenuTemplate();
|
BuyMenuBuildListMenuTemplate();
|
||||||
BuyMenuInitBgs();
|
BuyMenuInitBgs();
|
||||||
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20);
|
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20);
|
||||||
@ -480,9 +483,9 @@ static void CB2_InitBuyMenu(void)
|
|||||||
|
|
||||||
static void BuyMenuFreeMemory(void)
|
static void BuyMenuFreeMemory(void)
|
||||||
{
|
{
|
||||||
Free(gShopDataPtr);
|
Free(sShopData);
|
||||||
Free(gUnknown_02039F74);
|
Free(sListMenuItems);
|
||||||
Free(gUnknown_02039F78);
|
Free(sItemNames);
|
||||||
FreeAllWindowBuffers();
|
FreeAllWindowBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,29 +493,29 @@ static void BuyMenuBuildListMenuTemplate(void)
|
|||||||
{
|
{
|
||||||
u16 i;
|
u16 i;
|
||||||
|
|
||||||
gUnknown_02039F74 = Alloc((gMartInfo.itemCount + 1) * sizeof(*gUnknown_02039F74));
|
sListMenuItems = Alloc((sMartInfo.itemCount + 1) * sizeof(*sListMenuItems));
|
||||||
gUnknown_02039F78 = Alloc((gMartInfo.itemCount + 1) * sizeof(*gUnknown_02039F78));
|
sItemNames = Alloc((sMartInfo.itemCount + 1) * sizeof(*sItemNames));
|
||||||
for (i = 0; i < gMartInfo.itemCount; i++)
|
for (i = 0; i < sMartInfo.itemCount; i++)
|
||||||
BuyMenuSetListEntry(&gUnknown_02039F74[i], gMartInfo.itemList[i], gUnknown_02039F78[i]);
|
BuyMenuSetListEntry(&sListMenuItems[i], sMartInfo.itemList[i], sItemNames[i]);
|
||||||
|
|
||||||
StringCopy(gUnknown_02039F78[i], gText_Cancel2);
|
StringCopy(sItemNames[i], gText_Cancel2);
|
||||||
gUnknown_02039F74[i].name = gUnknown_02039F78[i];
|
sListMenuItems[i].name = sItemNames[i];
|
||||||
gUnknown_02039F74[i].id = -2;
|
sListMenuItems[i].id = LIST_CANCEL;
|
||||||
|
|
||||||
gMultiuseListMenuTemplate = sShopBuyMenuListTemplate;
|
gMultiuseListMenuTemplate = sShopBuyMenuListTemplate;
|
||||||
gMultiuseListMenuTemplate.items = gUnknown_02039F74;
|
gMultiuseListMenuTemplate.items = sListMenuItems;
|
||||||
gMultiuseListMenuTemplate.totalItems = gMartInfo.itemCount + 1;
|
gMultiuseListMenuTemplate.totalItems = sMartInfo.itemCount + 1;
|
||||||
if (gMultiuseListMenuTemplate.totalItems > 8)
|
if (gMultiuseListMenuTemplate.totalItems > 8)
|
||||||
gMultiuseListMenuTemplate.maxShowed = 8;
|
gMultiuseListMenuTemplate.maxShowed = 8;
|
||||||
else
|
else
|
||||||
gMultiuseListMenuTemplate.maxShowed = gMultiuseListMenuTemplate.totalItems;
|
gMultiuseListMenuTemplate.maxShowed = gMultiuseListMenuTemplate.totalItems;
|
||||||
|
|
||||||
gShopDataPtr->itemsShowed = gMultiuseListMenuTemplate.maxShowed;
|
sShopData->itemsShowed = gMultiuseListMenuTemplate.maxShowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BuyMenuSetListEntry(struct ListMenuItem *menuItem, u16 item, u8 *name)
|
static void BuyMenuSetListEntry(struct ListMenuItem *menuItem, u16 item, u8 *name)
|
||||||
{
|
{
|
||||||
if (gMartInfo.martType == MART_TYPE_NORMAL)
|
if (sMartInfo.martType == MART_TYPE_NORMAL)
|
||||||
CopyItemName(item, name);
|
CopyItemName(item, name);
|
||||||
else
|
else
|
||||||
StringCopy(name, gDecorations[item].name);
|
StringCopy(name, gDecorations[item].name);
|
||||||
@ -527,16 +530,16 @@ static void BuyMenuPrintItemDescriptionAndShowItemIcon(s32 item, bool8 onInit, s
|
|||||||
if (onInit != TRUE)
|
if (onInit != TRUE)
|
||||||
PlaySE(SE_SELECT);
|
PlaySE(SE_SELECT);
|
||||||
|
|
||||||
if (item != -2)
|
if (item != LIST_CANCEL)
|
||||||
BuyMenuAddItemIcon(item, gShopDataPtr->iconSlot);
|
BuyMenuAddItemIcon(item, sShopData->iconSlot);
|
||||||
else
|
else
|
||||||
BuyMenuAddItemIcon(-1, gShopDataPtr->iconSlot);
|
BuyMenuAddItemIcon(-1, sShopData->iconSlot);
|
||||||
|
|
||||||
BuyMenuRemoveItemIcon(item, gShopDataPtr->iconSlot ^ 1);
|
BuyMenuRemoveItemIcon(item, sShopData->iconSlot ^ 1);
|
||||||
gShopDataPtr->iconSlot ^= 1;
|
sShopData->iconSlot ^= 1;
|
||||||
if (item != -2)
|
if (item != LIST_CANCEL)
|
||||||
{
|
{
|
||||||
if (gMartInfo.martType == MART_TYPE_NORMAL)
|
if (sMartInfo.martType == MART_TYPE_NORMAL)
|
||||||
description = ItemId_GetDescription(item);
|
description = ItemId_GetDescription(item);
|
||||||
else
|
else
|
||||||
description = gDecorations[item].description;
|
description = gDecorations[item].description;
|
||||||
@ -554,9 +557,9 @@ static void BuyMenuPrintPriceInList(u8 windowId, s32 item, u8 y)
|
|||||||
{
|
{
|
||||||
u8 x;
|
u8 x;
|
||||||
|
|
||||||
if (item != -2)
|
if (item != LIST_CANCEL)
|
||||||
{
|
{
|
||||||
if (gMartInfo.martType == MART_TYPE_NORMAL)
|
if (sMartInfo.martType == MART_TYPE_NORMAL)
|
||||||
{
|
{
|
||||||
ConvertIntToDecimalStringN(
|
ConvertIntToDecimalStringN(
|
||||||
gStringVar1,
|
gStringVar1,
|
||||||
@ -581,26 +584,26 @@ static void BuyMenuPrintPriceInList(u8 windowId, s32 item, u8 y)
|
|||||||
|
|
||||||
static void BuyMenuAddScrollIndicatorArrows(void)
|
static void BuyMenuAddScrollIndicatorArrows(void)
|
||||||
{
|
{
|
||||||
if (gShopDataPtr->scrollIndicatorsTaskId == TASK_NONE && gMartInfo.itemCount + 1 > 8)
|
if (sShopData->scrollIndicatorsTaskId == TASK_NONE && sMartInfo.itemCount + 1 > 8)
|
||||||
{
|
{
|
||||||
gShopDataPtr->scrollIndicatorsTaskId = AddScrollIndicatorArrowPairParameterized(
|
sShopData->scrollIndicatorsTaskId = AddScrollIndicatorArrowPairParameterized(
|
||||||
SCROLL_ARROW_UP,
|
SCROLL_ARROW_UP,
|
||||||
0xAC,
|
172,
|
||||||
0xC,
|
12,
|
||||||
0x94,
|
148,
|
||||||
gMartInfo.itemCount - 7,
|
sMartInfo.itemCount - 7,
|
||||||
2100,
|
TAG_SCROLL_ARROW,
|
||||||
2100,
|
TAG_SCROLL_ARROW,
|
||||||
&gShopDataPtr->scrollOffset);
|
&sShopData->scrollOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BuyMenuRemoveScrollIndicatorArrows(void)
|
static void BuyMenuRemoveScrollIndicatorArrows(void)
|
||||||
{
|
{
|
||||||
if (gShopDataPtr->scrollIndicatorsTaskId != TASK_NONE)
|
if (sShopData->scrollIndicatorsTaskId != TASK_NONE)
|
||||||
{
|
{
|
||||||
RemoveScrollIndicatorArrowPair(gShopDataPtr->scrollIndicatorsTaskId);
|
RemoveScrollIndicatorArrowPair(sShopData->scrollIndicatorsTaskId);
|
||||||
gShopDataPtr->scrollIndicatorsTaskId = TASK_NONE;
|
sShopData->scrollIndicatorsTaskId = TASK_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,13 +616,13 @@ static void BuyMenuPrintCursor(u8 scrollIndicatorsTaskId, u8 colorSet)
|
|||||||
static void BuyMenuAddItemIcon(u16 item, u8 iconSlot)
|
static void BuyMenuAddItemIcon(u16 item, u8 iconSlot)
|
||||||
{
|
{
|
||||||
u8 spriteId;
|
u8 spriteId;
|
||||||
u8 *spriteIdPtr = &gShopDataPtr->itemSpriteIds[iconSlot];
|
u8 *spriteIdPtr = &sShopData->itemSpriteIds[iconSlot];
|
||||||
if (*spriteIdPtr != SPRITE_NONE)
|
if (*spriteIdPtr != SPRITE_NONE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (gMartInfo.martType == MART_TYPE_NORMAL || item == 0xFFFF)
|
if (sMartInfo.martType == MART_TYPE_NORMAL || item == 0xFFFF)
|
||||||
{
|
{
|
||||||
spriteId = AddItemIconSprite(iconSlot + 2110, iconSlot + 2110, item);
|
spriteId = AddItemIconSprite(iconSlot + TAG_ITEM_ICON_BASE, iconSlot + TAG_ITEM_ICON_BASE, item);
|
||||||
if (spriteId != MAX_SPRITES)
|
if (spriteId != MAX_SPRITES)
|
||||||
{
|
{
|
||||||
*spriteIdPtr = spriteId;
|
*spriteIdPtr = spriteId;
|
||||||
@ -629,7 +632,7 @@ static void BuyMenuAddItemIcon(u16 item, u8 iconSlot)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
spriteId = AddDecorationIconObject(item, 20, 84, 1, iconSlot + 2110, iconSlot + 2110);
|
spriteId = AddDecorationIconObject(item, 20, 84, 1, iconSlot + TAG_ITEM_ICON_BASE, iconSlot + TAG_ITEM_ICON_BASE);
|
||||||
if (spriteId != MAX_SPRITES)
|
if (spriteId != MAX_SPRITES)
|
||||||
*spriteIdPtr = spriteId;
|
*spriteIdPtr = spriteId;
|
||||||
}
|
}
|
||||||
@ -637,12 +640,12 @@ static void BuyMenuAddItemIcon(u16 item, u8 iconSlot)
|
|||||||
|
|
||||||
static void BuyMenuRemoveItemIcon(u16 item, u8 iconSlot)
|
static void BuyMenuRemoveItemIcon(u16 item, u8 iconSlot)
|
||||||
{
|
{
|
||||||
u8 *spriteIdPtr = &gShopDataPtr->itemSpriteIds[iconSlot];
|
u8 *spriteIdPtr = &sShopData->itemSpriteIds[iconSlot];
|
||||||
if (*spriteIdPtr == SPRITE_NONE)
|
if (*spriteIdPtr == SPRITE_NONE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FreeSpriteTilesByTag(iconSlot + 2110);
|
FreeSpriteTilesByTag(iconSlot + TAG_ITEM_ICON_BASE);
|
||||||
FreeSpritePaletteByTag(iconSlot + 2110);
|
FreeSpritePaletteByTag(iconSlot + TAG_ITEM_ICON_BASE);
|
||||||
DestroySprite(&gSprites[*spriteIdPtr]);
|
DestroySprite(&gSprites[*spriteIdPtr]);
|
||||||
*spriteIdPtr = SPRITE_NONE;
|
*spriteIdPtr = SPRITE_NONE;
|
||||||
}
|
}
|
||||||
@ -651,9 +654,9 @@ static void BuyMenuInitBgs(void)
|
|||||||
{
|
{
|
||||||
ResetBgsAndClearDma3BusyFlags(0);
|
ResetBgsAndClearDma3BusyFlags(0);
|
||||||
InitBgsFromTemplates(0, sShopBuyMenuBgTemplates, ARRAY_COUNT(sShopBuyMenuBgTemplates));
|
InitBgsFromTemplates(0, sShopBuyMenuBgTemplates, ARRAY_COUNT(sShopBuyMenuBgTemplates));
|
||||||
SetBgTilemapBuffer(1, gShopDataPtr->tilemapBuffers[1]);
|
SetBgTilemapBuffer(1, sShopData->tilemapBuffers[1]);
|
||||||
SetBgTilemapBuffer(2, gShopDataPtr->tilemapBuffers[3]);
|
SetBgTilemapBuffer(2, sShopData->tilemapBuffers[3]);
|
||||||
SetBgTilemapBuffer(3, gShopDataPtr->tilemapBuffers[2]);
|
SetBgTilemapBuffer(3, sShopData->tilemapBuffers[2]);
|
||||||
SetGpuReg(REG_OFFSET_BG0HOFS, 0);
|
SetGpuReg(REG_OFFSET_BG0HOFS, 0);
|
||||||
SetGpuReg(REG_OFFSET_BG0VOFS, 0);
|
SetGpuReg(REG_OFFSET_BG0VOFS, 0);
|
||||||
SetGpuReg(REG_OFFSET_BG1HOFS, 0);
|
SetGpuReg(REG_OFFSET_BG1HOFS, 0);
|
||||||
@ -673,7 +676,7 @@ static void BuyMenuInitBgs(void)
|
|||||||
static void BuyMenuDecompressBgGraphics(void)
|
static void BuyMenuDecompressBgGraphics(void)
|
||||||
{
|
{
|
||||||
DecompressAndCopyTileDataToVram(1, gBuyMenuFrame_Gfx, 0x3A0, 0x3E3, 0);
|
DecompressAndCopyTileDataToVram(1, gBuyMenuFrame_Gfx, 0x3A0, 0x3E3, 0);
|
||||||
LZDecompressWram(gBuyMenuFrame_Tilemap, gShopDataPtr->tilemapBuffers[0]);
|
LZDecompressWram(gBuyMenuFrame_Tilemap, sShopData->tilemapBuffers[0]);
|
||||||
LoadCompressedPalette(gMenuMoneyPal, 0xC0, 0x20);
|
LoadCompressedPalette(gMenuMoneyPal, 0xC0, 0x20);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -763,16 +766,16 @@ static void BuyMenuDrawMapMetatile(s16 x, s16 y, const u16 *src, u8 metatileLaye
|
|||||||
switch (metatileLayerType)
|
switch (metatileLayerType)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[3], offset1, offset2, src);
|
BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[3], offset1, offset2, src);
|
||||||
BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[1], offset1, offset2, src + 4);
|
BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[1], offset1, offset2, src + 4);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[2], offset1, offset2, src);
|
BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[2], offset1, offset2, src);
|
||||||
BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[3], offset1, offset2, src + 4);
|
BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[3], offset1, offset2, src + 4);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[2], offset1, offset2, src);
|
BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[2], offset1, offset2, src);
|
||||||
BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[1], offset1, offset2, src + 4);
|
BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[1], offset1, offset2, src + 4);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -796,7 +799,7 @@ static void BuyMenuCollectObjectEventData(void)
|
|||||||
|
|
||||||
GetXYCoordsOneStepInFrontOfPlayer(&facingX, &facingY);
|
GetXYCoordsOneStepInFrontOfPlayer(&facingX, &facingY);
|
||||||
for (y = 0; y < OBJECT_EVENTS_COUNT; y++)
|
for (y = 0; y < OBJECT_EVENTS_COUNT; y++)
|
||||||
gShopDataPtr->viewportObjects[y][OBJ_EVENT_ID] = OBJECT_EVENTS_COUNT;
|
sShopData->viewportObjects[y][OBJ_EVENT_ID] = OBJECT_EVENTS_COUNT;
|
||||||
for (y = 0; y < 5; y++)
|
for (y = 0; y < 5; y++)
|
||||||
{
|
{
|
||||||
for (x = 0; x < 7; x++)
|
for (x = 0; x < 7; x++)
|
||||||
@ -805,25 +808,25 @@ static void BuyMenuCollectObjectEventData(void)
|
|||||||
|
|
||||||
if (objEventId != OBJECT_EVENTS_COUNT)
|
if (objEventId != OBJECT_EVENTS_COUNT)
|
||||||
{
|
{
|
||||||
gShopDataPtr->viewportObjects[r8][OBJ_EVENT_ID] = objEventId;
|
sShopData->viewportObjects[r8][OBJ_EVENT_ID] = objEventId;
|
||||||
gShopDataPtr->viewportObjects[r8][X_COORD] = x;
|
sShopData->viewportObjects[r8][X_COORD] = x;
|
||||||
gShopDataPtr->viewportObjects[r8][Y_COORD] = y;
|
sShopData->viewportObjects[r8][Y_COORD] = y;
|
||||||
gShopDataPtr->viewportObjects[r8][LAYER_TYPE] = MapGridGetMetatileLayerTypeAt(facingX - 4 + x, facingY - 2 + y);
|
sShopData->viewportObjects[r8][LAYER_TYPE] = MapGridGetMetatileLayerTypeAt(facingX - 4 + x, facingY - 2 + y);
|
||||||
|
|
||||||
switch (gObjectEvents[objEventId].facingDirection)
|
switch (gObjectEvents[objEventId].facingDirection)
|
||||||
{
|
{
|
||||||
case DIR_SOUTH:
|
case DIR_SOUTH:
|
||||||
gShopDataPtr->viewportObjects[r8][ANIM_NUM] = 0;
|
sShopData->viewportObjects[r8][ANIM_NUM] = 0;
|
||||||
break;
|
break;
|
||||||
case DIR_NORTH:
|
case DIR_NORTH:
|
||||||
gShopDataPtr->viewportObjects[r8][ANIM_NUM] = 1;
|
sShopData->viewportObjects[r8][ANIM_NUM] = 1;
|
||||||
break;
|
break;
|
||||||
case DIR_WEST:
|
case DIR_WEST:
|
||||||
gShopDataPtr->viewportObjects[r8][ANIM_NUM] = 2;
|
sShopData->viewportObjects[r8][ANIM_NUM] = 2;
|
||||||
break;
|
break;
|
||||||
case DIR_EAST:
|
case DIR_EAST:
|
||||||
default:
|
default:
|
||||||
gShopDataPtr->viewportObjects[r8][ANIM_NUM] = 3;
|
sShopData->viewportObjects[r8][ANIM_NUM] = 3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
r8++;
|
r8++;
|
||||||
@ -840,25 +843,25 @@ static void BuyMenuDrawObjectEvents(void)
|
|||||||
|
|
||||||
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
||||||
{
|
{
|
||||||
if (gShopDataPtr->viewportObjects[i][OBJ_EVENT_ID] == OBJECT_EVENTS_COUNT)
|
if (sShopData->viewportObjects[i][OBJ_EVENT_ID] == OBJECT_EVENTS_COUNT)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[gShopDataPtr->viewportObjects[i][OBJ_EVENT_ID]].graphicsId);
|
graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[sShopData->viewportObjects[i][OBJ_EVENT_ID]].graphicsId);
|
||||||
|
|
||||||
spriteId = AddPseudoObjectEvent(
|
spriteId = AddPseudoObjectEvent(
|
||||||
gObjectEvents[gShopDataPtr->viewportObjects[i][OBJ_EVENT_ID]].graphicsId,
|
gObjectEvents[sShopData->viewportObjects[i][OBJ_EVENT_ID]].graphicsId,
|
||||||
SpriteCallbackDummy,
|
SpriteCallbackDummy,
|
||||||
(u16)gShopDataPtr->viewportObjects[i][X_COORD] * 16 + 8,
|
(u16)sShopData->viewportObjects[i][X_COORD] * 16 + 8,
|
||||||
(u16)gShopDataPtr->viewportObjects[i][Y_COORD] * 16 + 48 - graphicsInfo->height / 2,
|
(u16)sShopData->viewportObjects[i][Y_COORD] * 16 + 48 - graphicsInfo->height / 2,
|
||||||
2);
|
2);
|
||||||
|
|
||||||
if (BuyMenuCheckIfObjectEventOverlapsMenuBg(gShopDataPtr->viewportObjects[i]) == TRUE)
|
if (BuyMenuCheckIfObjectEventOverlapsMenuBg(sShopData->viewportObjects[i]) == TRUE)
|
||||||
{
|
{
|
||||||
gSprites[spriteId].subspriteTableNum = 4;
|
gSprites[spriteId].subspriteTableNum = 4;
|
||||||
gSprites[spriteId].subspriteMode = SUBSPRITES_ON;
|
gSprites[spriteId].subspriteMode = SUBSPRITES_ON;
|
||||||
}
|
}
|
||||||
|
|
||||||
StartSpriteAnim(&gSprites[spriteId], gShopDataPtr->viewportObjects[i][ANIM_NUM]);
|
StartSpriteAnim(&gSprites[spriteId], sShopData->viewportObjects[i][ANIM_NUM]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -877,8 +880,8 @@ static bool8 BuyMenuCheckIfObjectEventOverlapsMenuBg(s16 *object)
|
|||||||
static void BuyMenuCopyMenuBgToBg1TilemapBuffer(void)
|
static void BuyMenuCopyMenuBgToBg1TilemapBuffer(void)
|
||||||
{
|
{
|
||||||
s16 i;
|
s16 i;
|
||||||
u16 *dest = gShopDataPtr->tilemapBuffers[1];
|
u16 *dest = sShopData->tilemapBuffers[1];
|
||||||
const u16 *src = gShopDataPtr->tilemapBuffers[0];
|
const u16 *src = sShopData->tilemapBuffers[0];
|
||||||
|
|
||||||
for (i = 0; i < 1024; i++)
|
for (i = 0; i < 1024; i++)
|
||||||
{
|
{
|
||||||
@ -891,7 +894,7 @@ static void BuyMenuCopyMenuBgToBg1TilemapBuffer(void)
|
|||||||
|
|
||||||
static bool8 BuyMenuCheckForOverlapWithMenuBg(int x, int y)
|
static bool8 BuyMenuCheckForOverlapWithMenuBg(int x, int y)
|
||||||
{
|
{
|
||||||
const u16 *metatile = gShopDataPtr->tilemapBuffers[0];
|
const u16 *metatile = sShopData->tilemapBuffers[0];
|
||||||
int offset1 = x * 2;
|
int offset1 = x * 2;
|
||||||
int offset2 = y * 64;
|
int offset2 = y * 64;
|
||||||
|
|
||||||
@ -913,7 +916,7 @@ static void Task_BuyMenu(u8 taskId)
|
|||||||
if (!gPaletteFade.active)
|
if (!gPaletteFade.active)
|
||||||
{
|
{
|
||||||
s32 itemId = ListMenu_ProcessInput(tListTaskId);
|
s32 itemId = ListMenu_ProcessInput(tListTaskId);
|
||||||
ListMenuGetScrollAndRow(tListTaskId, &gShopDataPtr->scrollOffset, &gShopDataPtr->selectedRow);
|
ListMenuGetScrollAndRow(tListTaskId, &sShopData->scrollOffset, &sShopData->selectedRow);
|
||||||
|
|
||||||
switch (itemId)
|
switch (itemId)
|
||||||
{
|
{
|
||||||
@ -930,22 +933,22 @@ static void Task_BuyMenu(u8 taskId)
|
|||||||
BuyMenuRemoveScrollIndicatorArrows();
|
BuyMenuRemoveScrollIndicatorArrows();
|
||||||
BuyMenuPrintCursor(tListTaskId, 2);
|
BuyMenuPrintCursor(tListTaskId, 2);
|
||||||
|
|
||||||
if (gMartInfo.martType == MART_TYPE_NORMAL)
|
if (sMartInfo.martType == MART_TYPE_NORMAL)
|
||||||
{
|
{
|
||||||
gShopDataPtr->totalCost = (ItemId_GetPrice(itemId) >> GetPriceReduction(POKENEWS_SLATEPORT));
|
sShopData->totalCost = (ItemId_GetPrice(itemId) >> GetPriceReduction(POKENEWS_SLATEPORT));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gShopDataPtr->totalCost = gDecorations[itemId].price;
|
sShopData->totalCost = gDecorations[itemId].price;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsEnoughMoney(&gSaveBlock1Ptr->money, gShopDataPtr->totalCost))
|
if (!IsEnoughMoney(&gSaveBlock1Ptr->money, sShopData->totalCost))
|
||||||
{
|
{
|
||||||
BuyMenuDisplayMessage(taskId, gText_YouDontHaveMoney, BuyMenuReturnToItemList);
|
BuyMenuDisplayMessage(taskId, gText_YouDontHaveMoney, BuyMenuReturnToItemList);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (gMartInfo.martType == MART_TYPE_NORMAL)
|
if (sMartInfo.martType == MART_TYPE_NORMAL)
|
||||||
{
|
{
|
||||||
CopyItemName(itemId, gStringVar1);
|
CopyItemName(itemId, gStringVar1);
|
||||||
if (ItemId_GetPocket(itemId) == POCKET_TM_HM)
|
if (ItemId_GetPocket(itemId) == POCKET_TM_HM)
|
||||||
@ -961,9 +964,9 @@ static void Task_BuyMenu(u8 taskId)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringCopy(gStringVar1, gDecorations[itemId].name);
|
StringCopy(gStringVar1, gDecorations[itemId].name);
|
||||||
ConvertIntToDecimalStringN(gStringVar2, gShopDataPtr->totalCost, STR_CONV_MODE_LEFT_ALIGN, 6);
|
ConvertIntToDecimalStringN(gStringVar2, sShopData->totalCost, STR_CONV_MODE_LEFT_ALIGN, 6);
|
||||||
|
|
||||||
if (gMartInfo.martType == MART_TYPE_DECOR)
|
if (sMartInfo.martType == MART_TYPE_DECOR)
|
||||||
StringExpandPlaceholders(gStringVar4, gText_Var1IsItThatllBeVar2);
|
StringExpandPlaceholders(gStringVar4, gText_Var1IsItThatllBeVar2);
|
||||||
else // MART_TYPE_DECOR2
|
else // MART_TYPE_DECOR2
|
||||||
StringExpandPlaceholders(gStringVar4, gText_YouWantedVar1ThatllBeVar2);
|
StringExpandPlaceholders(gStringVar4, gText_YouWantedVar1ThatllBeVar2);
|
||||||
@ -992,15 +995,15 @@ static void Task_BuyHowManyDialogueInit(u8 taskId)
|
|||||||
BuyMenuPrintItemQuantityAndPrice(taskId);
|
BuyMenuPrintItemQuantityAndPrice(taskId);
|
||||||
ScheduleBgCopyTilemapToVram(0);
|
ScheduleBgCopyTilemapToVram(0);
|
||||||
|
|
||||||
maxQuantity = GetMoney(&gSaveBlock1Ptr->money) / gShopDataPtr->totalCost;
|
maxQuantity = GetMoney(&gSaveBlock1Ptr->money) / sShopData->totalCost;
|
||||||
|
|
||||||
if (maxQuantity > MAX_BAG_ITEM_CAPACITY)
|
if (maxQuantity > MAX_BAG_ITEM_CAPACITY)
|
||||||
{
|
{
|
||||||
gShopDataPtr->maxQuantity = MAX_BAG_ITEM_CAPACITY;
|
sShopData->maxQuantity = MAX_BAG_ITEM_CAPACITY;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gShopDataPtr->maxQuantity = maxQuantity;
|
sShopData->maxQuantity = maxQuantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
gTasks[taskId].func = Task_BuyHowManyDialogueHandleInput;
|
gTasks[taskId].func = Task_BuyHowManyDialogueHandleInput;
|
||||||
@ -1010,9 +1013,9 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId)
|
|||||||
{
|
{
|
||||||
s16 *data = gTasks[taskId].data;
|
s16 *data = gTasks[taskId].data;
|
||||||
|
|
||||||
if (AdjustQuantityAccordingToDPadInput(&tItemCount, gShopDataPtr->maxQuantity) == TRUE)
|
if (AdjustQuantityAccordingToDPadInput(&tItemCount, sShopData->maxQuantity) == TRUE)
|
||||||
{
|
{
|
||||||
gShopDataPtr->totalCost = (ItemId_GetPrice(tItemId) >> GetPriceReduction(POKENEWS_SLATEPORT)) * tItemCount;
|
sShopData->totalCost = (ItemId_GetPrice(tItemId) >> GetPriceReduction(POKENEWS_SLATEPORT)) * tItemCount;
|
||||||
BuyMenuPrintItemQuantityAndPrice(taskId);
|
BuyMenuPrintItemQuantityAndPrice(taskId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1027,7 +1030,7 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId)
|
|||||||
PutWindowTilemap(1);
|
PutWindowTilemap(1);
|
||||||
CopyItemName(tItemId, gStringVar1);
|
CopyItemName(tItemId, gStringVar1);
|
||||||
ConvertIntToDecimalStringN(gStringVar2, tItemCount, STR_CONV_MODE_LEFT_ALIGN, BAG_ITEM_CAPACITY_DIGITS);
|
ConvertIntToDecimalStringN(gStringVar2, tItemCount, STR_CONV_MODE_LEFT_ALIGN, BAG_ITEM_CAPACITY_DIGITS);
|
||||||
ConvertIntToDecimalStringN(gStringVar3, gShopDataPtr->totalCost, STR_CONV_MODE_LEFT_ALIGN, 6);
|
ConvertIntToDecimalStringN(gStringVar3, sShopData->totalCost, STR_CONV_MODE_LEFT_ALIGN, 6);
|
||||||
BuyMenuDisplayMessage(taskId, gText_Var1AndYouWantedVar2, BuyMenuConfirmPurchase);
|
BuyMenuDisplayMessage(taskId, gText_Var1AndYouWantedVar2, BuyMenuConfirmPurchase);
|
||||||
}
|
}
|
||||||
else if (JOY_NEW(B_BUTTON))
|
else if (JOY_NEW(B_BUTTON))
|
||||||
@ -1053,7 +1056,7 @@ static void BuyMenuTryMakePurchase(u8 taskId)
|
|||||||
|
|
||||||
PutWindowTilemap(1);
|
PutWindowTilemap(1);
|
||||||
|
|
||||||
if (gMartInfo.martType == MART_TYPE_NORMAL)
|
if (sMartInfo.martType == MART_TYPE_NORMAL)
|
||||||
{
|
{
|
||||||
if (AddBagItem(tItemId, tItemCount) == TRUE)
|
if (AddBagItem(tItemId, tItemCount) == TRUE)
|
||||||
{
|
{
|
||||||
@ -1069,7 +1072,7 @@ static void BuyMenuTryMakePurchase(u8 taskId)
|
|||||||
{
|
{
|
||||||
if (DecorationAdd(tItemId))
|
if (DecorationAdd(tItemId))
|
||||||
{
|
{
|
||||||
if (gMartInfo.martType == MART_TYPE_DECOR)
|
if (sMartInfo.martType == MART_TYPE_DECOR)
|
||||||
BuyMenuDisplayMessage(taskId, gText_ThankYouIllSendItHome, BuyMenuSubtractMoney);
|
BuyMenuDisplayMessage(taskId, gText_ThankYouIllSendItHome, BuyMenuSubtractMoney);
|
||||||
else // MART_TYPE_DECOR2
|
else // MART_TYPE_DECOR2
|
||||||
BuyMenuDisplayMessage(taskId, gText_ThanksIllSendItHome, BuyMenuSubtractMoney);
|
BuyMenuDisplayMessage(taskId, gText_ThanksIllSendItHome, BuyMenuSubtractMoney);
|
||||||
@ -1084,11 +1087,11 @@ static void BuyMenuTryMakePurchase(u8 taskId)
|
|||||||
static void BuyMenuSubtractMoney(u8 taskId)
|
static void BuyMenuSubtractMoney(u8 taskId)
|
||||||
{
|
{
|
||||||
IncrementGameStat(GAME_STAT_SHOPPED);
|
IncrementGameStat(GAME_STAT_SHOPPED);
|
||||||
RemoveMoney(&gSaveBlock1Ptr->money, gShopDataPtr->totalCost);
|
RemoveMoney(&gSaveBlock1Ptr->money, sShopData->totalCost);
|
||||||
PlaySE(SE_SHOP);
|
PlaySE(SE_SHOP);
|
||||||
PrintMoneyAmountInMoneyBox(0, GetMoney(&gSaveBlock1Ptr->money), 0);
|
PrintMoneyAmountInMoneyBox(0, GetMoney(&gSaveBlock1Ptr->money), 0);
|
||||||
|
|
||||||
if (gMartInfo.martType == MART_TYPE_NORMAL)
|
if (sMartInfo.martType == MART_TYPE_NORMAL)
|
||||||
{
|
{
|
||||||
gTasks[taskId].func = Task_ReturnToItemListAfterItemPurchase;
|
gTasks[taskId].func = Task_ReturnToItemListAfterItemPurchase;
|
||||||
}
|
}
|
||||||
@ -1143,7 +1146,7 @@ static void BuyMenuPrintItemQuantityAndPrice(u8 taskId)
|
|||||||
s16 *data = gTasks[taskId].data;
|
s16 *data = gTasks[taskId].data;
|
||||||
|
|
||||||
FillWindowPixelBuffer(4, PIXEL_FILL(1));
|
FillWindowPixelBuffer(4, PIXEL_FILL(1));
|
||||||
PrintMoneyAmount(4, 38, 1, gShopDataPtr->totalCost, TEXT_SPEED_FF);
|
PrintMoneyAmount(4, 38, 1, sShopData->totalCost, TEXT_SPEED_FF);
|
||||||
ConvertIntToDecimalStringN(gStringVar1, tItemCount, STR_CONV_MODE_LEADING_ZEROS, BAG_ITEM_CAPACITY_DIGITS);
|
ConvertIntToDecimalStringN(gStringVar1, tItemCount, STR_CONV_MODE_LEADING_ZEROS, BAG_ITEM_CAPACITY_DIGITS);
|
||||||
StringExpandPlaceholders(gStringVar4, gText_xVar1);
|
StringExpandPlaceholders(gStringVar4, gText_xVar1);
|
||||||
BuyMenuPrint(4, gStringVar4, 0, 1, 0, 0);
|
BuyMenuPrint(4, gStringVar4, 0, 1, 0, 0);
|
||||||
@ -1169,7 +1172,7 @@ static void Task_ExitBuyMenu(u8 taskId)
|
|||||||
|
|
||||||
static void ClearItemPurchases(void)
|
static void ClearItemPurchases(void)
|
||||||
{
|
{
|
||||||
gMartPurchaseHistoryId = 0;
|
sPurchaseHistoryId = 0;
|
||||||
memset(gMartPurchaseHistory, 0, sizeof(gMartPurchaseHistory));
|
memset(gMartPurchaseHistory, 0, sizeof(gMartPurchaseHistory));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1179,27 +1182,23 @@ static void RecordItemPurchase(u8 taskId)
|
|||||||
|
|
||||||
u16 i;
|
u16 i;
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < ARRAY_COUNT(gMartPurchaseHistory); i++)
|
||||||
{
|
{
|
||||||
if (gMartPurchaseHistory[i].itemId == tItemId && gMartPurchaseHistory[i].quantity != 0)
|
if (gMartPurchaseHistory[i].itemId == tItemId && gMartPurchaseHistory[i].quantity != 0)
|
||||||
{
|
{
|
||||||
if (gMartPurchaseHistory[i].quantity + tItemCount > 255)
|
if (gMartPurchaseHistory[i].quantity + tItemCount > 255)
|
||||||
{
|
|
||||||
gMartPurchaseHistory[i].quantity = 255;
|
gMartPurchaseHistory[i].quantity = 255;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
gMartPurchaseHistory[i].quantity += tItemCount;
|
gMartPurchaseHistory[i].quantity += tItemCount;
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gMartPurchaseHistoryId < 3)
|
if (sPurchaseHistoryId < ARRAY_COUNT(gMartPurchaseHistory))
|
||||||
{
|
{
|
||||||
gMartPurchaseHistory[gMartPurchaseHistoryId].itemId = tItemId;
|
gMartPurchaseHistory[sPurchaseHistoryId].itemId = tItemId;
|
||||||
gMartPurchaseHistory[gMartPurchaseHistoryId].quantity = tItemCount;
|
gMartPurchaseHistory[sPurchaseHistoryId].quantity = tItemCount;
|
||||||
gMartPurchaseHistoryId++;
|
sPurchaseHistoryId++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user