diff options
author | ProjectRevoTPP <projectrevotpp@hotmail.com> | 2017-02-11 00:38:59 -0500 |
---|---|---|
committer | YamaArashi <YamaArashi@users.noreply.github.com> | 2017-02-10 21:38:59 -0800 |
commit | f21587ea9eb1190ac2136d72deb7929c1e1169eb (patch) | |
tree | bf39287a8b3906a6e2b47197e323047272b3d5a4 /src/berry.c | |
parent | c78e787f934f03bfffcf93ac69d92271d7d8036d (diff) |
misc labels and memcpy/set cleanups (#232)
* some labels and enumerate player speeds
* clear up speed enums
* GetPlayerSpeed
* oops
* start decompiling mauville_old_man.c
* formatting
* decompile more of mauville_old_man.c
* someone fix this please
* formatting
* make ROM build again
* formatting again
* make ROM match again
* label, document, reorganize, and clean up battle_ai.c
* move stuff to battle.h and get rid of battle_2000000
* various changes
* labeling
* minor labels and formatting
* contest ai labels and misc stuff
Diffstat (limited to 'src/berry.c')
-rw-r--r-- | src/berry.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/berry.c b/src/berry.c index 7932fafea..2f8f6a799 100644 --- a/src/berry.c +++ b/src/berry.c @@ -7,6 +7,8 @@ #include "rng.h" #include "text.h" +#define BERRY_NAME_LENGTH 6 + #define FIRST_BERRY ITEM_CHERI_BERRY #define LAST_BERRY ITEM_ENIGMA_BERRY @@ -917,7 +919,7 @@ void ClearBerryTrees(void) struct SaveBlock1 *saveBlock1 = &gSaveBlock1; struct BerryTree berryTree = gBlankBerryTree; - for (i = 0; i < 128; i++) + for (i = 0; i < (u8)ARRAY_COUNT(saveBlock1->berryTrees); i++) // casting to u8 fixes a mismatched signed compare. what saveBlock1->berryTrees[i] = berryTree; } @@ -955,7 +957,7 @@ void BerryTreeTimeUpdate(int time) int i; struct BerryTree *tree; - for (i = 0; i < 128; i++) + for (i = 0; i < (u8)ARRAY_COUNT(gSaveBlock1.berryTrees); i++) { tree = &gSaveBlock1.berryTrees[i]; @@ -1044,8 +1046,8 @@ u16 BerryTypeToItemId(u16 berry) void GetBerryNameByBerryType(u8 berry, u8 *string) { - memcpy(string, GetBerryInfo(berry)->name, 6); - string[6] = EOS; + memcpy(string, GetBerryInfo(berry)->name, BERRY_NAME_LENGTH); + string[BERRY_NAME_LENGTH] = EOS; } void ResetBerryTreeSparkleFlag(u8 id) @@ -1185,7 +1187,7 @@ void ResetBerryTreeSparkleFlags(void) top = cam_top + 3; right = cam_left + 14; bottom = top + 8; - for (i = 0; i < 16; i++) + for (i = 0; i < (u8)ARRAY_COUNT(gSaveBlock1.mapObjects); i++) { if (gMapObjects[i].active && gMapObjects[i].animPattern == 12) { |