From 0a5c91740ed4f3433c44687e6c3c8ab07ec1ce21 Mon Sep 17 00:00:00 2001 From: Isaac Lien Date: Fri, 6 Mar 2026 23:40:06 -0600 Subject: [PATCH 01/12] Provided upper bound --- src/pokemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pokemon.c b/src/pokemon.c index 1cd5dc3e52..f0d20b3e09 100755 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -7927,7 +7927,7 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg) case MON_DATA_PP2: case MON_DATA_PP3: case MON_DATA_PP4: - SET8(substruct1->pp[field - MON_DATA_PP1]); + SET8(substruct1->pp[(field - MON_DATA_PP1) & (MAX_MON_MOVES - 1)]); break; case MON_DATA_HP_EV: SET8(substruct2->hpEV); From c85dab6970528f25af5f32d45ead2932b97b2d9c Mon Sep 17 00:00:00 2001 From: Isaac Lien Date: Fri, 6 Mar 2026 23:42:28 -0600 Subject: [PATCH 02/12] Added qualified calls; move -> std::move --- tools/mapjson/json11.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/mapjson/json11.cpp b/tools/mapjson/json11.cpp index 1b818d09c1..2682e5552c 100755 --- a/tools/mapjson/json11.cpp +++ b/tools/mapjson/json11.cpp @@ -150,7 +150,7 @@ class Value : public JsonValue { // Constructors explicit Value(const T &value) : m_value(value) {} - explicit Value(T &&value) : m_value(move(value)) {} + explicit Value(T &&value) : m_value(std::move(value)) {} // Get type tag Json::Type type() const override { @@ -197,7 +197,7 @@ class JsonString final : public Value { const string &string_value() const override { return m_value; } public: explicit JsonString(const string &value) : Value(value) {} - explicit JsonString(string &&value) : Value(move(value)) {} + explicit JsonString(string &&value) : Value(std::move(value)) {} }; class JsonArray final : public Value { @@ -205,7 +205,7 @@ class JsonArray final : public Value { const Json & operator[](size_t i) const override; public: explicit JsonArray(const Json::array &value) : Value(value) {} - explicit JsonArray(Json::array &&value) : Value(move(value)) {} + explicit JsonArray(Json::array &&value) : Value(std::move(value)) {} }; class JsonObject final : public Value { @@ -213,7 +213,7 @@ class JsonObject final : public Value { const Json & operator[](const string &key) const override; public: explicit JsonObject(const Json::object &value) : Value(value) {} - explicit JsonObject(Json::object &&value) : Value(move(value)) {} + explicit JsonObject(Json::object &&value) : Value(std::move(value)) {} }; class JsonNull final : public Value { @@ -255,12 +255,12 @@ Json::Json(double value) : m_ptr(make_shared(value)) { Json::Json(int value) : m_ptr(make_shared(value)) {} Json::Json(bool value) : m_ptr(value ? statics().t : statics().f) {} Json::Json(const string &value) : m_ptr(make_shared(value)) {} -Json::Json(string &&value) : m_ptr(make_shared(move(value))) {} +Json::Json(string &&value) : m_ptr(make_shared(std::move(value))) {} Json::Json(const char * value) : m_ptr(make_shared(value)) {} Json::Json(const Json::array &values) : m_ptr(make_shared(values)) {} -Json::Json(Json::array &&values) : m_ptr(make_shared(move(values))) {} +Json::Json(Json::array &&values) : m_ptr(make_shared(std::move(values))) {} Json::Json(const Json::object &values) : m_ptr(make_shared(values)) {} -Json::Json(Json::object &&values) : m_ptr(make_shared(move(values))) {} +Json::Json(Json::object &&values) : m_ptr(make_shared(std::move(values))) {} /* * * * * * * * * * * * * * * * * * * * * Accessors @@ -358,7 +358,7 @@ struct JsonParser final { * Mark this parse as failed. */ Json fail(string &&msg) { - return fail(move(msg), Json()); + return fail(std::move(msg), Json()); } template From aff4297db8ef4aabcdb6bee9603123ffd0639c97 Mon Sep 17 00:00:00 2001 From: Isaac Lien Date: Fri, 6 Mar 2026 23:46:33 -0600 Subject: [PATCH 03/12] Added loop index in InitDomeTrainers for clarity, consistency, and remove warning --- src/battle_dome.c | 83 ++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/src/battle_dome.c b/src/battle_dome.c index 41562a980c..798f38f52c 100755 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -2414,7 +2414,8 @@ static void InitDomeTrainers(void) ivs = GetDomeTrainerMonIvs(DOME_TRAINERS[i].trainerId); for (j = 0; j < FRONTIER_PARTY_SIZE; j++) { - CalcDomeMonStats(gFacilityTrainerMons[DOME_MONS[i][j]].species, + species[j] = gFacilityTrainerMons[DOME_MONS[i][j]].species; + CalcDomeMonStats(species[j], monLevel, ivs, gFacilityTrainerMons[DOME_MONS[i][j]].evSpread, gFacilityTrainerMons[DOME_MONS[i][j]].nature, @@ -2427,56 +2428,56 @@ static void InitDomeTrainers(void) rankingScores[i] += statValues[STAT_SPEED]; rankingScores[i] += statValues[STAT_HP]; if ((gSaveBlock1Ptr->tx_Mode_Modern_Types == 0) - && (species == SPECIES_ARBOK - || species == SPECIES_PARASECT - || species == SPECIES_GOLDUCK - || species == SPECIES_KINGLER - || species == SPECIES_MEGANIUM - || species == SPECIES_TYPHLOSION - || species == SPECIES_FERALIGATR - || species == SPECIES_NOCTOWL - || species == SPECIES_SUNFLORA - || species == SPECIES_STANTLER - || species == SPECIES_GROVYLE - || species == SPECIES_SCEPTILE - || species == SPECIES_MASQUERAIN - || species == SPECIES_DELCATTY - || species == SPECIES_GULPIN - || species == SPECIES_SWALOT - || species == SPECIES_LUVDISC - || species == SPECIES_ELECTIVIRE)) + && (species[j] == SPECIES_ARBOK + || species[j] == SPECIES_PARASECT + || species[j] == SPECIES_GOLDUCK + || species[j] == SPECIES_KINGLER + || species[j] == SPECIES_MEGANIUM + || species[j] == SPECIES_TYPHLOSION + || species[j] == SPECIES_FERALIGATR + || species[j] == SPECIES_NOCTOWL + || species[j] == SPECIES_SUNFLORA + || species[j] == SPECIES_STANTLER + || species[j] == SPECIES_GROVYLE + || species[j] == SPECIES_SCEPTILE + || species[j] == SPECIES_MASQUERAIN + || species[j] == SPECIES_DELCATTY + || species[j] == SPECIES_GULPIN + || species[j] == SPECIES_SWALOT + || species[j] == SPECIES_LUVDISC + || species[j] == SPECIES_ELECTIVIRE)) { monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types_old[0]]; monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types_old[1]]; } else if ((gSaveBlock1Ptr->tx_Mode_Fairy_Types == 0) - && (species == SPECIES_JIGGLYPUFF - || species == SPECIES_WIGGLYTUFF - || species == SPECIES_CLEFAIRY - || species == SPECIES_CLEFABLE - || species == SPECIES_MR_MIME - || species == SPECIES_CLEFFA - || species == SPECIES_IGGLYBUFF - || species == SPECIES_TOGEPI - || species == SPECIES_TOGETIC - || species == SPECIES_MARILL - || species == SPECIES_AZUMARILL - || species == SPECIES_SNUBBULL - || species == SPECIES_GRANBULL - || species == SPECIES_RALTS - || species == SPECIES_KIRLIA - || species == SPECIES_GARDEVOIR - || species == SPECIES_AZURILL - || species == SPECIES_MAWILE - || species == SPECIES_MIME_JR - || species == SPECIES_TOGEKISS)) + && (species[j] == SPECIES_JIGGLYPUFF + || species[j] == SPECIES_WIGGLYTUFF + || species[j] == SPECIES_CLEFAIRY + || species[j] == SPECIES_CLEFABLE + || species[j] == SPECIES_MR_MIME + || species[j] == SPECIES_CLEFFA + || species[j] == SPECIES_IGGLYBUFF + || species[j] == SPECIES_TOGEPI + || species[j] == SPECIES_TOGETIC + || species[j] == SPECIES_MARILL + || species[j] == SPECIES_AZUMARILL + || species[j] == SPECIES_SNUBBULL + || species[j] == SPECIES_GRANBULL + || species[j] == SPECIES_RALTS + || species[j] == SPECIES_KIRLIA + || species[j] == SPECIES_GARDEVOIR + || species[j] == SPECIES_AZURILL + || species[j] == SPECIES_MAWILE + || species[j] == SPECIES_MIME_JR + || species[j] == SPECIES_TOGEKISS)) { monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types_old[0]]; monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types_old[1]]; } else if ((gSaveBlock1Ptr->tx_Mode_Fairy_Types == 1) - && (species == SPECIES_SNUBBULL - || species == SPECIES_GRANBULL)) + && (species[j] == SPECIES_SNUBBULL + || species[j] == SPECIES_GRANBULL)) { monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types_new[0]]; monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types_new[1]]; From a756b14ce5d0725cc7a5f70dbf056e11ab42bfa9 Mon Sep 17 00:00:00 2001 From: Isaac Lien Date: Sat, 7 Mar 2026 00:02:51 -0600 Subject: [PATCH 04/12] DECORCAT_COUNT equaled 1, but DecorationCategory in unused code is still referencing is. Adjusted the enums so the _count remove a warning (EWRAM +0.02%) --- include/decoration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/decoration.h b/include/decoration.h index 971d316f4c..ff3a4513bc 100755 --- a/include/decoration.h +++ b/include/decoration.h @@ -42,7 +42,7 @@ enum DecorationCategory enum DecorationCategory_HnS { - DECORCAT_DOLL, + DECORCAT_DOLL = DECORCAT_CUSHION + 1, DECORCAT_COUNT, }; From 1546a34382ac2db6ada10a761e58c4528ced7f1a Mon Sep 17 00:00:00 2001 From: Isaac Lien Date: Sat, 7 Mar 2026 00:04:38 -0600 Subject: [PATCH 05/12] warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] --- src/frontier_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/frontier_util.c b/src/frontier_util.c index 7a5d2a3488..110fadd4ff 100755 --- a/src/frontier_util.c +++ b/src/frontier_util.c @@ -2029,7 +2029,7 @@ static u8 AppendCaughtBannedMonSpeciesName(u16 species, u8 count, s32 numBannedM static void AppendIfValid(u16 species, u16 heldItem, u16 hp, u8 lvlMode, u8 monLevel, u16 *speciesArray, u16 *itemsArray, u8 *count) { s32 i = 0; - u16* gFrontierBannedSpecies; + const u16* gFrontierBannedSpecies; if (gSaveBlock1Ptr->tx_Features_FrontierBans == 0) gFrontierBannedSpecies = gFrontierBannedSpeciesNormal; else if (gSaveBlock1Ptr->tx_Features_FrontierBans == 1) @@ -2129,7 +2129,7 @@ static void CheckPartyIneligibility(void) { s32 i; s32 caughtBannedMons = 0; - u16* gFrontierBannedSpecies; + const u16* gFrontierBannedSpecies; if (gSaveBlock1Ptr->tx_Features_FrontierBans == 0) gFrontierBannedSpecies = gFrontierBannedSpeciesNormal; else if (gSaveBlock1Ptr->tx_Features_FrontierBans == 1) From 201497ffe91b2725fed6410c30fbc73a8f1cc350 Mon Sep 17 00:00:00 2001 From: Isaac Lien Date: Sat, 7 Mar 2026 00:10:08 -0600 Subject: [PATCH 06/12] u8 getting written into a u16 space --- src/item.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/item.c b/src/item.c index 97b7d49d05..e1db41ea6e 100755 --- a/src/item.c +++ b/src/item.c @@ -786,6 +786,8 @@ static bool8 CheckPyramidBagHasSpace(u16 itemId, u16 count) return FALSE; } +#define MAX_PYRAMID_BAG_ITEM_QUANTITY 255 + bool8 AddPyramidBagItem(u16 itemId, u16 count) { u16 i; @@ -801,16 +803,17 @@ bool8 AddPyramidBagItem(u16 itemId, u16 count) 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_QUANTITY) { - newQuantities[i] += count; - if (newQuantities[i] > MAX_BAG_ITEM_CAPACITY) + u16 newVal = newQuantities[i] + count; + if (newVal > MAX_PYRAMID_BAG_ITEM_QUANTITY) { - count = newQuantities[i] - MAX_BAG_ITEM_CAPACITY; - newQuantities[i] = MAX_BAG_ITEM_CAPACITY; + count = newVal - MAX_PYRAMID_BAG_ITEM_QUANTITY; + newQuantities[i] = MAX_PYRAMID_BAG_ITEM_QUANTITY; } else { + newQuantities[i] = newVal; count = 0; } @@ -825,15 +828,16 @@ bool8 AddPyramidBagItem(u16 itemId, u16 count) { if (newItems[i] == ITEM_NONE) { + u16 newVal = count; newItems[i] = itemId; - newQuantities[i] = count; - if (newQuantities[i] > MAX_BAG_ITEM_CAPACITY) + if (newVal > 255) { - count = newQuantities[i] - MAX_BAG_ITEM_CAPACITY; - newQuantities[i] = MAX_BAG_ITEM_CAPACITY; + count = newVal - 255; + newQuantities[i] = 255; } else { + newQuantities[i] = newVal; count = 0; } From a498962b6785d6b247cdc0a4043a5ffeedaf91f6 Mon Sep 17 00:00:00 2001 From: Isaac Lien Date: Sat, 7 Mar 2026 00:10:39 -0600 Subject: [PATCH 07/12] Added includes to remove warnings --- include/rtc_include.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/rtc_include.h b/include/rtc_include.h index 51802ca7e3..d322176ca7 100755 --- a/include/rtc_include.h +++ b/include/rtc_include.h @@ -2,6 +2,9 @@ #ifndef RTC_INCLUDE_H #define RTC_INCLUDE_H +#include "siirtc.h" +#include "rtc.h" + void RtcGetInfoFake(struct SiiRtcInfo *rtc); void RtcCalcTimeDifferenceFake(struct SiiRtcInfo *rtc, struct Time *result, struct Time *t); void RtcAdvanceTime(int hours, int minutes, int seconds); From f89e5982b93299ad40b4c29c8caf04fa46bd61a7 Mon Sep 17 00:00:00 2001 From: Isaac Lien Date: Sat, 7 Mar 2026 00:21:18 -0600 Subject: [PATCH 08/12] Suppressed warnings as everything is safe. The third argument is filled with garbage in *Data2 and argument 3 is never accessed. --- src/pokemon.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pokemon.c b/src/pokemon.c index f0d20b3e09..6de9b1ba77 100755 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -7395,7 +7395,10 @@ u32 GetMonData3(struct Pokemon *mon, s32 field, u8 *data) return ret; } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wattribute-alias=" u32 GetMonData2(struct Pokemon *mon, s32 field) __attribute__((alias("GetMonData3"))); +#pragma GCC diagnostic pop /* GameFreak called GetBoxMonData with either 2 or 3 arguments, for type * safety we have a GetBoxMonData macro (in include/pokemon.h) which @@ -7772,7 +7775,10 @@ u32 GetBoxMonData3(struct BoxPokemon *boxMon, s32 field, u8 *data) return retVal; } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wattribute-alias=" u32 GetBoxMonData2(struct BoxPokemon *boxMon, s32 field) __attribute__((alias("GetBoxMonData3"))); +#pragma GCC diagnostic pop #define SET8(lhs) (lhs) = *data #define SET16(lhs) (lhs) = data[0] + (data[1] << 8) From ea8c0f0beed8fcc5d59870a1ab76a08f4f3f6d26 Mon Sep 17 00:00:00 2001 From: Isaac Lien Date: Sat, 7 Mar 2026 00:21:30 -0600 Subject: [PATCH 09/12] Removed a tab from the end of the file --- data/scripts/mom_savings.inc | 1 - 1 file changed, 1 deletion(-) diff --git a/data/scripts/mom_savings.inc b/data/scripts/mom_savings.inc index 68c68aa95e..1b7dbfcf8d 100644 --- a/data/scripts/mom_savings.inc +++ b/data/scripts/mom_savings.inc @@ -45,4 +45,3 @@ Mom_Text_GiftCall_Decoration: .string "for your room!\p" .string "Check your DECORATIONS when you\n" .string "come home. Take care!$" - \ No newline at end of file From df38e8794b53c8c8bc893d7b9877058eacc7f02d Mon Sep 17 00:00:00 2001 From: Isaac Lien Date: Sat, 7 Mar 2026 00:27:10 -0600 Subject: [PATCH 10/12] fixed byte overflow --- data/maps/MtSilver_MountainSide/map.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/maps/MtSilver_MountainSide/map.json b/data/maps/MtSilver_MountainSide/map.json index a8b33a4e5d..e88730edd0 100644 --- a/data/maps/MtSilver_MountainSide/map.json +++ b/data/maps/MtSilver_MountainSide/map.json @@ -255,7 +255,7 @@ "elevation": 0, "movement_type": "MOVEMENT_TYPE_WALK_UP_AND_DOWN", "movement_range_x": 6, - "movement_range_y": 20, + "movement_range_y": 15, "trainer_type": "TRAINER_TYPE_NONE", "trainer_sight_or_berry_tree_id": "0", "script": "NULL", @@ -268,7 +268,7 @@ "elevation": 0, "movement_type": "MOVEMENT_TYPE_WALK_UP_AND_DOWN", "movement_range_x": 6, - "movement_range_y": 20, + "movement_range_y": 15, "trainer_type": "TRAINER_TYPE_NONE", "trainer_sight_or_berry_tree_id": "0", "script": "NULL", From 791bd2439e4eb2dab2cfabf40ac60b249e2ccde9 Mon Sep 17 00:00:00 2001 From: Isaac Lien Date: Sat, 7 Mar 2026 19:32:46 -0600 Subject: [PATCH 11/12] Revert commit `a756b14ce5d0725cc7a5f70dbf056e11ab42bfa9` --- include/decoration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/decoration.h b/include/decoration.h index ff3a4513bc..971d316f4c 100755 --- a/include/decoration.h +++ b/include/decoration.h @@ -42,7 +42,7 @@ enum DecorationCategory enum DecorationCategory_HnS { - DECORCAT_DOLL = DECORCAT_CUSHION + 1, + DECORCAT_DOLL, DECORCAT_COUNT, }; From b80cb9d1246dba7f69ec36d888ed57305fa8ffc9 Mon Sep 17 00:00:00 2001 From: Isaac Lien Date: Sat, 7 Mar 2026 19:38:49 -0600 Subject: [PATCH 12/12] Different fix than last commit - the count for the decoration categories in HnS is 1, so when trying to add all the category pointers it overflowed. --- src/decoration_inventory.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/decoration_inventory.c b/src/decoration_inventory.c index c84ee69a46..198061b25c 100755 --- a/src/decoration_inventory.c +++ b/src/decoration_inventory.c @@ -12,14 +12,15 @@ EWRAM_DATA struct DecorationInventory gDecorationInventories[DECORCAT_COUNT] = { void SetDecorationInventoriesPointers(void) { - SET_DECOR_INV(DECORCAT_DESK, gSaveBlock1Ptr->decorationDesks); - SET_DECOR_INV(DECORCAT_CHAIR, gSaveBlock1Ptr->decorationChairs); - SET_DECOR_INV(DECORCAT_PLANT, gSaveBlock1Ptr->decorationPlants); - SET_DECOR_INV(DECORCAT_ORNAMENT, gSaveBlock1Ptr->decorationOrnaments); - SET_DECOR_INV(DECORCAT_MAT, gSaveBlock1Ptr->decorationMats); - SET_DECOR_INV(DECORCAT_POSTER, gSaveBlock1Ptr->decorationPosters); + // Not used in HnS, but left in for compatibility with vanilla and potential future use. + // SET_DECOR_INV(DECORCAT_DESK, gSaveBlock1Ptr->decorationDesks); + // SET_DECOR_INV(DECORCAT_CHAIR, gSaveBlock1Ptr->decorationChairs); + // SET_DECOR_INV(DECORCAT_PLANT, gSaveBlock1Ptr->decorationPlants); + // SET_DECOR_INV(DECORCAT_ORNAMENT, gSaveBlock1Ptr->decorationOrnaments); + // SET_DECOR_INV(DECORCAT_MAT, gSaveBlock1Ptr->decorationMats); + // SET_DECOR_INV(DECORCAT_POSTER, gSaveBlock1Ptr->decorationPosters); SET_DECOR_INV(DECORCAT_DOLL, gSaveBlock1Ptr->decorationDolls); - SET_DECOR_INV(DECORCAT_CUSHION, gSaveBlock1Ptr->decorationCushions); + // SET_DECOR_INV(DECORCAT_CUSHION, gSaveBlock1Ptr->decorationCushions); InitDecorationContextItems(); }