diff options
-rw-r--r-- | data/maps/PewterCity_Gym/text.inc | 3 | ||||
-rw-r--r-- | src/battle_main.c | 2 | ||||
-rw-r--r-- | src/malloc.c | 4 | ||||
-rw-r--r-- | src/party_menu.c | 2 | ||||
-rw-r--r-- | src/wild_encounter.c | 4 |
5 files changed, 9 insertions, 6 deletions
diff --git a/data/maps/PewterCity_Gym/text.inc b/data/maps/PewterCity_Gym/text.inc index b6a1d87ee..4ba144beb 100644 --- a/data/maps/PewterCity_Gym/text.inc +++ b/data/maps/PewterCity_Gym/text.inc @@ -14,6 +14,9 @@ PewterCity_Gym_Text_BrockIntro:: @ 8190CD4 .string "Fine, then!\n" .string "Show me your best!{PLAY_BGM}{MUS_ENCOUNTER_GYM_LEADER}$" +@ NOTE: This defeat text actually causes a buffer overflow. It's too long for the gDisplayedStringBattle +@ buffer that it's put into, and it stomps all over the gBattleTextBuffs after, as well as the otherwise +@ unused array after that, gUnknown_2022AE8. Perhaps that's the reason why said array exists. PewterCity_Gym_Text_BrockDefeat:: @ 8190E4F .string "I took you for granted, and so\n" .string "I lost.\p" diff --git a/src/battle_main.c b/src/battle_main.c index 021a0ca81..53757d13c 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -125,7 +125,7 @@ EWRAM_DATA u8 gDisplayedStringBattle[300] = {0}; EWRAM_DATA u8 gBattleTextBuff1[TEXT_BUFF_ARRAY_COUNT] = {0}; EWRAM_DATA u8 gBattleTextBuff2[TEXT_BUFF_ARRAY_COUNT] = {0}; EWRAM_DATA u8 gBattleTextBuff3[TEXT_BUFF_ARRAY_COUNT] = {0}; -static EWRAM_DATA u32 gUnknown_2022AE8[25] = {0}; +static EWRAM_DATA u32 gUnknown_2022AE8[25] = {0}; // Note: This shouldn't be removed without adjusting the size of gDisplayedStringBattle. EWRAM_DATA u32 gBattleTypeFlags = 0; EWRAM_DATA u8 gBattleTerrain = 0; EWRAM_DATA u32 gUnknown_2022B54 = 0; diff --git a/src/malloc.c b/src/malloc.c index 590d45c05..260c41d0d 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -192,12 +192,12 @@ void InitHeap(void *heapStart, u32 heapSize) void *Alloc(u32 size) { - AllocInternal(sHeapStart, size); + return AllocInternal(sHeapStart, size); } void *AllocZeroed(u32 size) { - AllocZeroedInternal(sHeapStart, size); + return AllocZeroedInternal(sHeapStart, size); } void Free(void *pointer) diff --git a/src/party_menu.c b/src/party_menu.c index e08c427c8..aa7ffc702 100644 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -839,7 +839,7 @@ static bool8 DisplayPartyPokemonDataForMoveTutorOrEvolutionItem(u8 slot) if (gPartyMenu.action == PARTY_ACTION_MOVE_TUTOR) { gSpecialVar_Result = FALSE; - if (gSpecialVar_0x8005 > 14) + if (gSpecialVar_0x8005 >= TUTOR_MOVE_COUNT) return FALSE; DisplayPartyPokemonDataToTeachMove(slot, 0, gSpecialVar_0x8005); } diff --git a/src/wild_encounter.c b/src/wild_encounter.c index 5c3e59fde..90501e583 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -87,7 +87,7 @@ static u8 ChooseWildMonIndex_Land(void) return 8; else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_8 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_9) return 9; - else if (rand == ENCOUNTER_CHANCE_LAND_MONS_SLOT_9) + else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_9 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_10) return 10; else return 11; @@ -147,7 +147,7 @@ static u8 ChooseWildMonIndex_Fishing(u8 rod) wildMonIndex = 7; if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_7 && rand < ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_8) wildMonIndex = 8; - if (rand == ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_8) + if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_8 && rand < ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_9) wildMonIndex = 9; break; } |