shithub: pokecrystal

Download patch

ref: a91b59ab5dd2468e3f48079d45f90a9625a29fe3
parent: e43c89bc80bb1bb7ff2fc93bb5288f2c0211ea0b
author: mid-kid <esteve.varela@gmail.com>
date: Thu Jul 26 19:26:14 EDT 2018

Remove a documented bug that's not really a bug

I mean, technically, being able to read beyond a data table's size is
bad practice, but there's so many cases of this that it's not worth
mentioning.

For most of these cases, at least, it's safe to assume the index won't
ever get high enough to surpass such a table's length, because it's
either hardcoded or decided by the game without the use of
uncontrollable data. As such, they don't expose any actual bugs.

--- a/docs/bugs_and_glitches.md
+++ b/docs/bugs_and_glitches.md
@@ -55,7 +55,6 @@
 - [`LoadSpriteGFX` does not limit the capacity of `UsedSprites`](#loadspritegfx-does-not-limit-the-capacity-of-usedsprites)
 - [`ChooseWildEncounter` doesn't really validate the wild Pokémon species](#choosewildencounter-doesnt-really-validate-the-wild-pokémon-species)
 - [`TryObjectEvent` arbitrary code execution](#tryobjectevent-arbitrary-code-execution)
-- [`CheckBugContestContestantFlag` can read beyond its data table](#checkbugcontestcontestantflag-can-read-beyond-its-data-table)
 - [`ClearWRAM` only clears WRAM bank 1](#clearwram-only-clears-wram-bank-1)
 
 
@@ -1489,35 +1488,6 @@
 	xor a
 	ret
 ```
-
-
-## `CheckBugContestContestantFlag` can read beyond its data table
-
-In [engine/events/bug_contest/contest_2.asm](/engine/events/bug_contest/contest_2.asm):
-
-```asm
-CheckBugContestContestantFlag:
-; Checks the flag of the Bug Catching Contestant whose index is loaded in a.
-
-; Bug: If a >= NUM_BUG_CONTESTANTS when this is called,
-; it will read beyond the table.
-
-	ld hl, BugCatchingContestantEventFlagTable
-	ld e, a
-	ld d, 0
-	add hl, de
-	add hl, de
-	ld e, [hl]
-	inc hl
-	ld d, [hl]
-	ld b, CHECK_FLAG
-	call EventFlagAction
-	ret
-
-INCLUDE "data/events/bug_contest_flags.asm"
-```
-
-However, `a < NUM_BUG_CONTESTANTS` should always be true, so in practice this is not a problem.
 
 
 ## `ClearWRAM` only clears WRAM bank 1
--- a/engine/events/bug_contest/contest_2.asm
+++ b/engine/events/bug_contest/contest_2.asm
@@ -58,9 +58,6 @@
 CheckBugContestContestantFlag:
 ; Checks the flag of the Bug Catching Contestant whose index is loaded in a.
 
-; Bug: If a >= NUM_BUG_CONTESTANTS when this is called,
-; it will read beyond the table.
-
 	ld hl, BugCatchingContestantEventFlagTable
 	ld e, a
 	ld d, 0