From 5d752bbe49f5d559932fdfbb2247fb72199e0c2a Mon Sep 17 00:00:00 2001 From: SBird Date: Wed, 3 Jun 2020 14:26:22 +0200 Subject: [PATCH] shop: document some constants s.t. object events don't break --- include/shop.h | 2 +- src/shop.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/shop.h b/include/shop.h index 164d6f3c27..c338103b4a 100644 --- a/include/shop.h +++ b/include/shop.h @@ -41,7 +41,7 @@ struct ShopData /*0x200B*/ u8 scrollIndicatorsTaskId; /*0x200C*/ u8 iconSlot; /*0x200D*/ u8 itemSpriteIds[2]; - /*0x2010*/ s16 viewportObjects[16][5]; + /*0x2010*/ s16 viewportObjects[OBJECT_EVENTS_COUNT][5]; }; void CreatePokemartMenu(const u16 *); diff --git a/src/shop.c b/src/shop.c index a4d1939cb1..849beeabc3 100755 --- a/src/shop.c +++ b/src/shop.c @@ -796,15 +796,15 @@ static void BuyMenuCollectObjectEventData(void) u8 r8 = 0; GetXYCoordsOneStepInFrontOfPlayer(&facingX, &facingY); - for (y = 0; y < 16; y++) - gShopDataPtr->viewportObjects[y][OBJ_EVENT_ID] = 16; + for (y = 0; y < OBJECT_EVENTS_COUNT; y++) + gShopDataPtr->viewportObjects[y][OBJ_EVENT_ID] = OBJECT_EVENTS_COUNT; for (y = 0; y < 5; y++) { for (x = 0; x < 7; x++) { u8 objEventId = GetObjectEventIdByXY(facingX - 4 + x, facingY - 2 + y); - if (objEventId != 16) + if (objEventId != OBJECT_EVENTS_COUNT) { gShopDataPtr->viewportObjects[r8][OBJ_EVENT_ID] = objEventId; gShopDataPtr->viewportObjects[r8][X_COORD] = x; @@ -839,9 +839,9 @@ static void BuyMenuDrawObjectEvents(void) u8 spriteId; const struct ObjectEventGraphicsInfo *graphicsInfo; - for (i = 0; i < 16; i++) // max objects? + for (i = 0; i < OBJECT_EVENTS_COUNT; i++) // max objects? { - if (gShopDataPtr->viewportObjects[i][OBJ_EVENT_ID] == 16) + if (gShopDataPtr->viewportObjects[i][OBJ_EVENT_ID] == OBJECT_EVENTS_COUNT) continue; graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[gShopDataPtr->viewportObjects[i][OBJ_EVENT_ID]].graphicsId);