summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCameron Hall <camthesaxman@users.noreply.github.com>2016-11-06 23:02:20 -0600
committerYamaArashi <YamaArashi@users.noreply.github.com>2016-11-06 21:02:20 -0800
commit7b1e836e9b48fd54a227931942d231f1c0823626 (patch)
tree7a987a7be6724b10704ac106d522ba6366671b07 /src
parent7f5332c12025c36c90c647184a5a4b1a3433d200 (diff)
cleanup (#93)
* cleanup * cleanup
Diffstat (limited to 'src')
-rw-r--r--src/battle_setup.c152
-rw-r--r--src/berry.c251
-rw-r--r--src/heal_location.c36
-rw-r--r--src/landmark.c49
-rw-r--r--src/scrcmd.c6
5 files changed, 194 insertions, 300 deletions
diff --git a/src/battle_setup.c b/src/battle_setup.c
index 27cef8441..869f713ca 100644
--- a/src/battle_setup.c
+++ b/src/battle_setup.c
@@ -246,6 +246,7 @@ void task_add_01_battle_start_with_music_and_stats(void)
sav12_xor_increment(9);
}
+//Initiates battle where Wally catches Ralts
void sub_8081AFC(void)
{
CreateMaleMon(&gEnemyParty[0], SPECIES_RALTS, 5);
@@ -384,10 +385,11 @@ s8 sub_8081D3C(void)
if (MetatileBehavior_IsBridge(tileBehavior) == TRUE)
return 4;
}
- if (!(gSaveBlock1.location.mapGroup == 0 && gSaveBlock1.location.mapNum == 28) && GetSav1Weather() != 8)
- return 9;
- else
+ if (gSaveBlock1.location.mapGroup == 0 && gSaveBlock1.location.mapNum == 28)
+ return 2;
+ if (GetSav1Weather() == 8)
return 2;
+ return 9;
}
s8 sub_8081E90(void)
@@ -404,7 +406,7 @@ s8 sub_8081E90(void)
if (flashUsed)
return 2;
- if (!(MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior)))
+ if (!MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior))
{
switch (gMapHeader.light)
{
@@ -421,26 +423,21 @@ s8 sub_8081E90(void)
u16 GetSumOfPartyMonLevel(u8 numMons)
{
- u32 monData;
u8 sum = 0;
int i;
for (i = 0; i < 6; i++)
{
- monData = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2);
- if (monData != 412 && monData)
+ u32 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2);
+
+ if (species != 412 && species != 0 && GetMonData(&gPlayerParty[i], MON_DATA_HP) != 0)
{
- if (GetMonData(&gPlayerParty[i], MON_DATA_HP))
- {
- sum += GetMonData(&gPlayerParty[i], MON_DATA_LEVEL);
-
- numMons--;
- if (numMons == 0)
- break;
- }
+ sum += GetMonData(&gPlayerParty[i], MON_DATA_LEVEL);
+ numMons--;
+ if (numMons == 0)
+ break;
}
}
-
return sum;
}
@@ -623,14 +620,11 @@ bool32 battle_exit_is_player_defeat(u32 a1)
case 6:
return FALSE;
}
-
return FALSE;
}
-u8 **sub_80822BC(void)
+void sub_80822BC(void)
{
- u32 *pointer;
-
gTrainerBattleMode = 0;
gTrainerBattleOpponent = 0;
gTrainerMapObjectLocalId = 0;
@@ -640,7 +634,6 @@ u8 **sub_80822BC(void)
gTrainerCannotBattleSpeech = 0;
gTrainerBattleScriptReturnAddress = 0;
gTrainerBattleEndScript = 0;
- return &gTrainerBattleEndScript;
}
void TrainerBattleLoadArgs(struct TrainerBattleSpec *specs, u8 *data)
@@ -843,22 +836,18 @@ void sub_80826D8(void)
u8 *sub_80826E8(void)
{
- u8 *result = gTrainerBattleScriptReturnAddress;
-
- if (!gTrainerBattleScriptReturnAddress)
+ if (gTrainerBattleScriptReturnAddress)
+ return gTrainerBattleScriptReturnAddress;
+ else
return gUnknown_081C6C02;
-
- return result;
}
u8 *sub_8082700(void)
{
- u8 *result = gTrainerBattleEndScript;
-
- if (!gTrainerBattleEndScript)
+ if (gTrainerBattleEndScript)
+ return gTrainerBattleEndScript;
+ else
return gUnknown_081C6C02;
-
- return result;
}
void sub_8082718()
@@ -916,22 +905,22 @@ void PlayTrainerEncounterMusic(void)
default:
music = BGM_AYASII;
}
-
PlayNewMapMusic(music);
}
}
-u8 *ReturnEmptyStringIfNull(u8 *result)
+//Returns an empty string if a null pointer was passed, otherwise returns str
+u8 *SanitizeString(u8 *str)
{
- if (result)
- return result;
+ if (str)
+ return str;
else
return gOtherText_CancelWithTerminator;
}
u8 *sub_808281C(void)
{
- return ReturnEmptyStringIfNull(gTrainerIntroSpeech);
+ return SanitizeString(gTrainerIntroSpeech);
}
u8 *sub_8082830(void)
@@ -943,18 +932,18 @@ u8 *sub_8082830(void)
else
str = gTrainerDefeatSpeech;
- StringExpandPlaceholders(gStringVar4, ReturnEmptyStringIfNull(str));
+ StringExpandPlaceholders(gStringVar4, SanitizeString(str));
return gStringVar4;
}
u8 *unref_sub_808286C(void)
{
- return ReturnEmptyStringIfNull(gTrainerVictorySpeech);
+ return SanitizeString(gTrainerVictorySpeech);
}
u8 *sub_8082880(void)
{
- return ReturnEmptyStringIfNull(gTrainerCannotBattleSpeech);
+ return SanitizeString(gTrainerCannotBattleSpeech);
}
s32 sub_8082894(struct TrainerEyeTrainer *trainers, u16 trainerNum)
@@ -966,67 +955,60 @@ s32 sub_8082894(struct TrainerEyeTrainer *trainers, u16 trainerNum)
if (trainers[i].trainerNums[0] == trainerNum)
return i;
}
-
return -1;
}
s32 sub_80828B8(struct TrainerEyeTrainer *trainers, u16 trainerNum)
{
- s32 i;
-
- for (i = 0; i < NUM_TRAINER_EYE_TRAINERS; i++)
- {
- s32 j;
+ s32 i;
+ s32 j;
- for (j = 0; j < 5 && trainers[i].trainerNums[j] != 0; j++)
- {
- if (trainers[i].trainerNums[j] == trainerNum)
- return i;
- }
- }
- return -1;
+ for (i = 0; i < NUM_TRAINER_EYE_TRAINERS; i++)
+ {
+ for (j = 0; j < 5 && trainers[i].trainerNums[j] != 0; j++)
+ {
+ if (trainers[i].trainerNums[j] == trainerNum)
+ return i;
+ }
+ }
+ return -1;
}
bool32 sub_80828FC(struct TrainerEyeTrainer *trainers, u16 mapGroup, u16 mapNum)
{
- int i;
- bool32 ret = FALSE;
-
- for (i = 0; i < NUM_TRAINER_EYE_TRAINERS; i++)
- {
- if (trainers[i].mapGroup == mapGroup && trainers[i].mapNum == mapNum)
- {
- if (gSaveBlock1.trainerRematches[i] != 0)
- {
- ret = TRUE;
- continue;
- }
- if (trainer_flag_check(trainers[i].trainerNums[0]) == TRUE && (Random() % 100) <= 30)
- {
- int j = 1;
-
- while (j < 5 && trainers[i].trainerNums[j] != 0 && trainer_flag_check(trainers[i].trainerNums[j]))
- j++;
- gSaveBlock1.trainerRematches[i] = j;
-
- ret = TRUE;
- }
- }
- }
+ int i;
+ bool32 ret = FALSE;
+ for (i = 0; i < NUM_TRAINER_EYE_TRAINERS; i++)
+ {
+ if (trainers[i].mapGroup == mapGroup && trainers[i].mapNum == mapNum)
+ {
+ if (gSaveBlock1.trainerRematches[i] != 0)
+ ret = TRUE;
+ else if (trainer_flag_check(trainers[i].trainerNums[0]) == TRUE && (Random() % 100) <= 30)
+ {
+ int j = 1;
+
+ while (j < 5 && trainers[i].trainerNums[j] != 0 && trainer_flag_check(trainers[i].trainerNums[j]))
+ j++;
+ gSaveBlock1.trainerRematches[i] = j;
+ ret = TRUE;
+ }
+ }
+ }
return ret;
}
s32 sub_80829A8(struct TrainerEyeTrainer *trainers, u16 mapGroup, u16 mapNum)
{
- s32 i;
+ s32 i;
- for (i = 0; i < NUM_TRAINER_EYE_TRAINERS; i++)
- {
- if (trainers[i].mapGroup == mapGroup && trainers[i].mapNum == mapNum && gSaveBlock1.trainerRematches[i])
- return 1;
- }
- return 0;
+ for (i = 0; i < NUM_TRAINER_EYE_TRAINERS; i++)
+ {
+ if (trainers[i].mapGroup == mapGroup && trainers[i].mapNum == mapNum && gSaveBlock1.trainerRematches[i])
+ return 1;
+ }
+ return 0;
}
s32 sub_80829E8(struct TrainerEyeTrainer *trainers, u16 mapGroup, u16 mapNum)
@@ -1069,9 +1051,7 @@ u16 sub_8082A90(struct TrainerEyeTrainer *trainers, u16 trainerNum)
if (trainerEyeIndex == -1)
return 0;
-
trainer = &trainers[trainerEyeIndex];
-
for (i = 1; i < 5; i++)
{
if (!trainer->trainerNums[i])
@@ -1079,7 +1059,6 @@ u16 sub_8082A90(struct TrainerEyeTrainer *trainers, u16 trainerNum)
if (!trainer_flag_check(trainer->trainerNums[i]))
return trainer->trainerNums[i];
}
-
return trainer->trainerNums[4];
}
@@ -1115,7 +1094,6 @@ bool32 sub_8082B44(void)
return TRUE;
}
}
-
return FALSE;
}
diff --git a/src/berry.c b/src/berry.c
index 79e716480..e00015477 100644
--- a/src/berry.c
+++ b/src/berry.c
@@ -1,4 +1,5 @@
#include "global.h"
+#include "text.h"
#define FIRST_BERRY 0x85 // ITEM_CHERI_BERRY
#define LAST_BERRY 0xaf // ITEM_ENIGMA_BERRY
@@ -35,15 +36,11 @@ void unref_sub_80B4884(void)
// setEnigmaBerry
void sub_80B48A8(u8 *src)
{
- u8 *dest;
- struct SaveBlock1 *saveBlock;
unsigned int i;
- dest = (u8*)&gSaveBlock1.enigmaBerry;
- saveBlock = &gSaveBlock1;
+ u8 *dest = (u8*)&gSaveBlock1.enigmaBerry;
+
for (i = 0; i < sizeof(gSaveBlock1.enigmaBerry); i++)
- {
dest[i] = src[i];
- }
gSaveBlock1.enigmaBerry.berry.description1 = gSaveBlock1.enigmaBerry.description1;
gSaveBlock1.enigmaBerry.berry.description2 = gSaveBlock1.enigmaBerry.description2;
}
@@ -75,29 +72,27 @@ u32 sub_80B48F8(struct EnigmaBerry *enigmaBerry)
return checksum;
}
-int sub_80B4940(void)
+bool32 sub_80B4940(void)
{
if (!gSaveBlock1.enigmaBerry.berry.stageDuration)
- return 0;
+ return FALSE;
if (!gSaveBlock1.enigmaBerry.berry.maxYield)
- return 0;
+ return FALSE;
if (sub_80B48F8(&gSaveBlock1.enigmaBerry) != gSaveBlock1.enigmaBerry.checksum)
- return 0;
- return 1;
+ return FALSE;
+ return TRUE;
}
struct Berry *GetBerryInfo(u8 berry)
{
- if ((u8)berry == 0x2b)
- {
- if (sub_80B4940())
- return &gSaveBlock1.enigmaBerry.berry;
- }
- if ((u8)(berry - 1) > 0x2a)
+ if (berry == 0x2B && sub_80B4940())
+ return &gSaveBlock1.enigmaBerry.berry;
+ else
{
- berry = 1;
+ if (berry == 0 || berry > 0x2B)
+ berry = 1;
+ return &gBerries[berry - 1];
}
- return &gBerries[berry - 1];
}
struct BerryTree *GetBerryTreeInfo(u8 id)
@@ -105,42 +100,45 @@ struct BerryTree *GetBerryTreeInfo(u8 id)
return &gSaveBlock1.berryTrees[id];
}
-int FieldObjectInteractionWaterBerryTree(void)
+bool32 FieldObjectInteractionWaterBerryTree(void)
{
struct BerryTree *tree = GetBerryTreeInfo(FieldObjectGetBerryTreeId(gSelectedMapObject));
+
switch (tree->stage)
{
case 1:
- tree->watered1 = 1;
+ tree->watered1 = TRUE;
break;
case 2:
- tree->watered2 = 1;
+ tree->watered2 = TRUE;
break;
case 3:
- tree->watered3 = 1;
+ tree->watered3 = TRUE;
break;
case 4:
- tree->watered4 = 1;
+ tree->watered4 = TRUE;
break;
default:
- return 0;
+ return FALSE;
}
- return 1;
+ return TRUE;
}
-int IsPlayerFacingPlantedBerryTree(void)
+bool32 IsPlayerFacingPlantedBerryTree(void)
{
- if (GetFieldObjectScriptPointerForComparison() == &BerryTreeScript)
- if (GetStageByBerryTreeId(FieldObjectGetBerryTreeId(gSelectedMapObject)) == 0)
- return 1;
- return 0;
+ if (GetFieldObjectScriptPointerForComparison() == &BerryTreeScript
+ && GetStageByBerryTreeId(FieldObjectGetBerryTreeId(gSelectedMapObject)) == 0)
+ return TRUE;
+ else
+ return FALSE;
}
u8 WaterBerryTree(void)
{
if (GetFieldObjectScriptPointerForComparison() != &BerryTreeScript)
return 0;
- return FieldObjectInteractionWaterBerryTree();
+ else
+ return FieldObjectInteractionWaterBerryTree();
}
void sub_80B4A90(void)
@@ -148,20 +146,19 @@ void sub_80B4A90(void)
int i;
struct SaveBlock1 *saveBlock1 = &gSaveBlock1;
struct BerryTree berryTree = gUnknown_083CD780;
- for (i = 127; i >= 0; i--)
- {
+
+ for (i = 0; i < 128; i++)
saveBlock1->berryTrees[i] = berryTree;
- }
}
-int BerryTreeGrow(struct BerryTree *tree)
+bool32 BerryTreeGrow(struct BerryTree *tree)
{
if (tree->growthSparkle)
- return 0;
+ return FALSE;
switch (tree->stage)
{
case 0:
- return 0;
+ return FALSE;
case 4:
tree->berryYield = CalcBerryYield(tree);
case 1:
@@ -180,75 +177,51 @@ int BerryTreeGrow(struct BerryTree *tree)
*tree = gUnknown_083CD780;
break;
}
- return 1;
+ return TRUE;
}
void BerryTreeTimeUpdate(int time)
{
int i;
struct BerryTree *tree;
- int time2;
- for (i = 0; i <= 0x7f; i++)
+
+ for (i = 0; i < 128; i++)
{
tree = &gSaveBlock1.berryTrees[i];
- if (tree->berry == 0)
- continue;
- if (tree->stage == 0)
- continue;
- if (tree->growthSparkle)
- continue;
-
- if (time >= GetStageDurationByBerryType(tree->berry) * 71)
+ if (tree->berry && tree->stage && !tree->growthSparkle)
{
- *tree = gUnknown_083CD780;
- continue;
- }
-
- time2 = time;
- if (!time2)
- continue;
-
- if (tree->secondsUntilNextStage > time2)
- {
- tree->secondsUntilNextStage -= time2;
- time2 = tree->secondsUntilNextStage;
- continue;
- }
-
- while (1)
- {
- time2 -= tree->secondsUntilNextStage;
- tree->secondsUntilNextStage = GetStageDurationByBerryType(tree->berry);
- if (BerryTreeGrow(tree))
+ if (time >= GetStageDurationByBerryType(tree->berry) * 71)
{
- if (tree->stage == 5)
- {
- tree->secondsUntilNextStage *= 4;
- }
- if (!time2)
- {
- break;
- }
+ *tree = gUnknown_083CD780;
}
else
{
- break;
- }
- if (tree->secondsUntilNextStage > time2)
- {
- tree->secondsUntilNextStage -= time2;
- time2 = tree->secondsUntilNextStage;
- break;
+ int time2 = time;
+
+ while (time2 != 0)
+ {
+ if (tree->secondsUntilNextStage > time2)
+ {
+ tree->secondsUntilNextStage -= time2;
+ break;
+ }
+ time2 -= tree->secondsUntilNextStage;
+ tree->secondsUntilNextStage = GetStageDurationByBerryType(tree->berry);
+ if (!BerryTreeGrow(tree))
+ break;
+ if (tree->stage == 5)
+ tree->secondsUntilNextStage *= 4;
+ }
}
}
}
}
-void PlantBerryTree(u8 id, u8 berry, u8 stage, u8 sparkle)
+void PlantBerryTree(u8 id, u8 berry, u8 stage, bool8 sparkle)
{
- struct BerryTree *tree;
- tree = GetBerryTreeInfo(id);
+ struct BerryTree *tree = GetBerryTreeInfo(id);
+
*tree = gUnknown_083CD780;
tree->berry = berry;
tree->secondsUntilNextStage = GetStageDurationByBerryType(berry);
@@ -258,9 +231,9 @@ void PlantBerryTree(u8 id, u8 berry, u8 stage, u8 sparkle)
tree->berryYield = CalcBerryYield(tree);
tree->secondsUntilNextStage *= 4;
}
- if (sparkle == 0)
+ if (!sparkle)
{
- tree->growthSparkle = 1;
+ tree->growthSparkle = TRUE;
}
}
@@ -282,39 +255,38 @@ u8 GetStageByBerryTreeId(u8 id)
u8 ItemIdToBerryType(u16 item)
{
u16 berry = item - FIRST_BERRY;
+
if (berry > LAST_BERRY - FIRST_BERRY)
return 1;
- return item - FIRST_BERRY + 1;
+ else
+ return item - FIRST_BERRY + 1;
}
u16 BerryTypeToItemId(u16 berry)
{
- u16 item = berry;
- item -= 1;
+ u16 item = berry - 1;
+
if (item > LAST_BERRY - FIRST_BERRY)
return FIRST_BERRY;
- item = berry;
- return item + FIRST_BERRY - 1;
+ else
+ return berry + FIRST_BERRY - 1;
}
void GetBerryNameByBerryType(u8 berry, u8 *string)
{
- struct Berry *info;
- info = GetBerryInfo(berry);
- memcpy(string, info->name, 6);
- string[6] = 0xff;
+ memcpy(string, GetBerryInfo(berry)->name, 6);
+ string[6] = EOS;
}
void ResetBerryTreeSparkleFlag(u8 id)
{
- struct BerryTree *tree;
- tree = GetBerryTreeInfo(id);
- tree->growthSparkle = 0;
+ GetBerryTreeInfo(id)->growthSparkle = 0;
}
u8 BerryTreeGetNumStagesWatered(struct BerryTree *tree)
{
u8 count = 0;
+
if (tree->watered1)
count++;
if (tree->watered2)
@@ -331,33 +303,26 @@ u8 GetNumStagesWateredByBerryTreeId(u8 id)
return BerryTreeGetNumStagesWatered(GetBerryTreeInfo(id));
}
-u8 CalcBerryYieldInternal(u16 a1, u16 a2, u8 a3)
-{
- u32 v6;
- u32 v1;
- u32 v5;
- u32 v4;
- u16 random;
- u32 ret;
- v6 = a2;
- if (a3 == 0)
- return v6;
- v1 = a1 - v6;
- v5 = v1 * (a3 - 1);
- v4 = v1 * a3;
- random = Random();
- v4 -= v5;
- v4 += 1;
- v5 += random % v4;
- if ((v5 & 3) <= 1)
- {
- ret = v5 / 4;
- return ret + v6;
- }
+u8 CalcBerryYieldInternal(u16 max, u16 min, u8 water)
+{
+ u32 randMin;
+ u32 randMax;
+ u32 rand;
+ u32 extraYield;
+
+ if (water == 0)
+ return min;
else
{
- ret = v5 / 4 + 1;
- return ret + v6;
+ randMin = (max - min) * (water - 1);
+ randMax = (max - min) * (water);
+ rand = randMin + Random() % (randMax - randMin + 1);
+
+ if ((rand & 3) > 1)
+ extraYield = rand / 4 + 1;
+ else
+ extraYield = rand / 4;
+ return extraYield + min;
}
}
@@ -366,6 +331,7 @@ u8 CalcBerryYield(struct BerryTree *tree)
struct Berry *berry = GetBerryInfo(tree->berry);
u8 min = berry->minYield;
u8 max = berry->maxYield;
+
return CalcBerryYieldInternal(max, min, BerryTreeGetNumStagesWatered(tree));
}
@@ -386,20 +352,19 @@ void FieldObjectInteractionGetBerryTreeData(void)
u8 unk;
u8 group;
u8 num;
+
id = FieldObjectGetBerryTreeId(gSelectedMapObject);
berry = GetBerryTypeByBerryTreeId(id);
ResetBerryTreeSparkleFlag(id);
unk = gScriptLastTalked;
num = gSaveBlock1.location.mapNum;
group = gSaveBlock1.location.mapGroup;
-
if (sub_8060234(unk, num, group))
- gSpecialVar_0x8004 = 0xff;
+ gSpecialVar_0x8004 = 0xFF;
else
- gSpecialVar_0x8004 = (u8)GetStageByBerryTreeId(id);
-
- gSpecialVar_0x8005 = (u8)GetNumStagesWateredByBerryTreeId(id);
- gSpecialVar_0x8006 = (u8)GetBerryCountByBerryTreeId(id);
+ gSpecialVar_0x8004 = GetStageByBerryTreeId(id);
+ gSpecialVar_0x8005 = GetNumStagesWateredByBerryTreeId(id);
+ gSpecialVar_0x8006 = GetBerryCountByBerryTreeId(id);
GetBerryNameByBerryType(berry, gStringVar1);
}
@@ -411,30 +376,23 @@ void sub_80B4EE4(void)
void FieldObjectInteractionPlantBerryTree(void)
{
u8 berry = ItemIdToBerryType(gScriptItemId);
- PlantBerryTree(FieldObjectGetBerryTreeId(gSelectedMapObject), berry, 1, 1);
+
+ PlantBerryTree(FieldObjectGetBerryTreeId(gSelectedMapObject), berry, 1, TRUE);
FieldObjectInteractionGetBerryTreeData();
}
void FieldObjectInteractionPickBerryTree(void)
{
- u8 id;
- u8 berry;
- id = FieldObjectGetBerryTreeId(gSelectedMapObject);
- berry = GetBerryTypeByBerryTreeId(id);
+ u8 id = FieldObjectGetBerryTreeId(gSelectedMapObject);
+ u8 berry = GetBerryTypeByBerryTreeId(id);
+
gSpecialVar_0x8004 = AddBagItem(BerryTypeToItemId(berry), GetBerryCountByBerryTreeId(id));
}
void FieldObjectInteractionRemoveBerryTree(void)
{
- u8 id;
- u8 unk;
- u8 group, num;
- id = FieldObjectGetBerryTreeId(gSelectedMapObject);
- RemoveBerryTree(id);
- unk = gScriptLastTalked;
- num = gSaveBlock1.location.mapNum;
- group = gSaveBlock1.location.mapGroup;
- sub_8060288(unk, num, group);
+ RemoveBerryTree(FieldObjectGetBerryTreeId(gSelectedMapObject));
+ sub_8060288(gScriptLastTalked, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup);
}
u8 PlayerHasBerries(void)
@@ -457,7 +415,6 @@ void ResetBerryTreeSparkleFlags(void)
top = cam_top + 3;
right = cam_left + 14;
bottom = top + 8;
-
for (i = 0; i < 16; i++)
{
if (gMapObjects[i].active && gMapObjects[i].animPattern == 12)
diff --git a/src/heal_location.c b/src/heal_location.c
index 15c4c7105..da2e466a9 100644
--- a/src/heal_location.c
+++ b/src/heal_location.c
@@ -12,58 +12,34 @@ struct HealLocation
extern const struct HealLocation gHealLocations[];
-u32 GetHealLocationIndexByMap(u16 some_group, u16 some_map)
+u32 GetHealLocationIndexByMap(u16 mapGroup, u16 mapNum)
{
- u32 i = 0;
+ u32 i;
- const struct HealLocation *temp = gHealLocations;
-
- for (; i<NUM_HEAL_LOCATIONS; i++)
+ for (i = 0; i < NUM_HEAL_LOCATIONS; i++)
{
- if (temp->group != some_group)
- {
- temp++;
- }
- else if (temp->map != some_map)
- {
- temp++;
- }
- else
- {
+ if(gHealLocations[i].group == mapGroup && gHealLocations[i].map == mapNum)
return i + 1;
- }
}
-
return 0;
}
-const struct HealLocation *GetHealLocationByMap(u16 some_group,
- u16 some_map)
+const struct HealLocation *GetHealLocationByMap(u16 mapGroup, u16 mapNum)
{
- u32 index = GetHealLocationIndexByMap(some_group, some_map);
+ u32 index = GetHealLocationIndexByMap(mapGroup, mapNum);
if (index == 0)
- {
return NULL;
- }
else
- {
return &gHealLocations[index - 1];
- }
}
const struct HealLocation *GetHealLocation(u32 index)
{
if (index == 0)
- {
return NULL;
- }
else if (index > NUM_HEAL_LOCATIONS)
- {
return NULL;
- }
else
- {
return &gHealLocations[index - 1];
- }
}
diff --git a/src/landmark.c b/src/landmark.c
index a343cecac..0ccadfa61 100644
--- a/src/landmark.c
+++ b/src/landmark.c
@@ -1,4 +1,7 @@
#include "global.h"
+#include "flag.h"
+
+#define MAPSEC_NONE 0x58
struct Landmark
{
@@ -8,21 +11,21 @@ struct Landmark
struct LandmarkList
{
- u8 field_0;
+ u8 mapSection;
u8 field_1;
u16 field_2;
- struct Landmark **landmark_list;
+ struct Landmark **landmarks;
};
extern const struct LandmarkList gLandmarkLists[];
-const struct Landmark **GetLandmarkList(u8 arg_0, u8 arg_1);
+static const struct Landmark **GetLandmarks(u8 arg_0, u8 arg_1);
u8 *GetLandmarkName(u8 arg_0, u8 arg_1, u8 count)
{
register struct Landmark **landmark_list asm("r4")
- = GetLandmarkList(arg_0, arg_1);
+ = GetLandmarks(arg_0, arg_1);
if (landmark_list == NULL)
{
@@ -84,44 +87,24 @@ u8 *GetLandmarkName(u8 arg_0, u8 arg_1, u8 count)
}
-
-const struct Landmark **GetLandmarkList(u8 arg_0, u8 arg_1)
+static const struct Landmark **GetLandmarks(u8 arg_0, u8 arg_1)
{
- u16 i;
-
- i = 0;
-
- if (gLandmarkLists[0].field_0 == 0x58)
- {
- return NULL;
- }
-
+ u16 i = 0;
- for (; gLandmarkLists[i].field_0 != 0x58; i++)
+ for (; gLandmarkLists[i].mapSection != MAPSEC_NONE; i++)
{
- if (gLandmarkLists[i].field_0 > arg_0)
- {
+ if (gLandmarkLists[i].mapSection > arg_0)
return NULL;
- }
- if (gLandmarkLists[i].field_0 == arg_0)
- {
+ if (gLandmarkLists[i].mapSection == arg_0)
break;
- }
}
-
- if (gLandmarkLists[i].field_0 == 0x58)
- {
+ if (gLandmarkLists[i].mapSection == MAPSEC_NONE)
return NULL;
- }
- for (; gLandmarkLists[i].field_0 == arg_0; i++)
+ for (; gLandmarkLists[i].mapSection == arg_0; i++)
{
if (gLandmarkLists[i].field_1 == arg_1)
- {
- return gLandmarkLists[i].landmark_list;
- }
+ return gLandmarkLists[i].landmarks;
}
-
- return 0;
+ return NULL;
}
-
diff --git a/src/scrcmd.c b/src/scrcmd.c
index 2a3e4f32e..aa6fdd5ed 100644
--- a/src/scrcmd.c
+++ b/src/scrcmd.c
@@ -112,7 +112,7 @@ extern void CreatePokemartMenu(void *);
extern void CreateDecorationShop1Menu(void *);
extern void CreateDecorationShop2Menu(void *);
extern void PlaySlotMachine(u8, void *);
-extern void PlantBerryTree(u8, u8, u8, u8);
+extern void PlantBerryTree(u8, u8, u8, bool8);
extern bool8 GetPriceReduction(u8);
extern void sub_80F99CC(void);
extern void sub_80C48C8(void);
@@ -1756,9 +1756,9 @@ bool8 ScrCmd_event_8a(struct ScriptContext *ctx)
u8 v3 = ScriptReadByte(ctx);
u8 v4 = ScriptReadByte(ctx);
if (!v3)
- PlantBerryTree(v2, 0, v4, 0);
+ PlantBerryTree(v2, 0, v4, FALSE);
else
- PlantBerryTree(v2, v3, v4, 0);
+ PlantBerryTree(v2, v3, v4, FALSE);
return FALSE;
}