Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renaming variables and functions related to overworld poison damage and FieldOverworldState #307

Merged
merged 7 commits into from
Nov 23, 2024
24 changes: 12 additions & 12 deletions include/field_map_change.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ void sub_02053494(FieldSystem *fieldSystem);
void FieldSystem_SetLoadNewGameSpawnTask(FieldSystem *fieldSystem);
void FieldSystem_SetLoadSavedGameMapTask(FieldSystem *fieldSystem);
void FieldSystem_StartLoadMapFromErrorTask(FieldSystem *fieldSystem);
void FieldSystem_StartChangeMapTask(FieldTask *param0, const Location *param1);
void FieldTask_ChangeMapByLocation(FieldTask *param0, const Location *param1);
void FieldTask_ChangeMapToLocation(FieldTask *param0, int param1, int param2, int param3, int param4, int param5);
void FieldTask_StartMapChangeFull(FieldTask *param0, int param1, int param2, int param3, int param4, int param5);
void FieldSystem_StartChangeMapTask(FieldTask *taskMan, const Location *param1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: we're kind of all over the place with this in the repo at the moment - I'm seeing task, taskMan, and taskManager. Maybe something we should look into, but doesn't need to be solved with this PR or anything.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's being normalized to task for FieldTask, because there's no "management" aspect to it. There is a light call-stack, but that doesn't totally qualify it as a "manager" to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I change all of them to task then? I can just immediately do it in other files as well, if this is something that you want to normalize across the whole repo

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ones in this PR would be nice, but I wouldn't sweat the whole repo unless you're just enthusiastic to do so. I'd probably do that as a follow-up PR if you did though.

void FieldTask_ChangeMapByLocation(FieldTask *taskMan, const Location *param1);
void FieldTask_ChangeMapToLocation(FieldTask *taskMan, int param1, int param2, int param3, int param4, int param5);
void FieldTask_StartMapChangeFull(FieldTask *taskMan, int param1, int param2, int param3, int param4, int param5);
void FieldTask_StartMapChangeFly(FieldSystem *fieldSystem, int param1, int param2, int param3, int param4, int param5);
void FieldTask_ChangeMapChangeFly(FieldTask *param0, int param1, int param2, int param3, int param4, int param5);
void FieldTask_ChangeMapChangeByDig(FieldTask *param0, const Location *param1, u32 param2);
void FieldTask_ChangeMapChangeFly(FieldTask *taskMan, int param1, int param2, int param3, int param4, int param5);
void FieldTask_ChangeMapChangeByDig(FieldTask *taskMan, const Location *location, u32 param2);
void FieldSystem_StartMapChangeWarpTask(FieldSystem *fieldSystem, int param1, int param2);
void *sub_02053FAC(FieldSystem *fieldSystem);
void FieldTask_SetUndergroundMapChange(FieldSystem *fieldSystem);
BOOL FieldTask_MapChangeToUnderground(FieldTask *param0);
BOOL sub_0205430C(FieldTask *param0);
BOOL FieldTask_MapChangeToUnderground(FieldTask *taskMan);
BOOL sub_0205430C(FieldTask *taskMan);
FieldTaskFunc FieldMapChange_GetMapChangeUndergroundTask(const FieldSystem *fieldSystem);
void sub_020544F0(FieldTask *param0, const Location *param1);
void sub_020544F0(FieldTask *taskMan, const Location *param1);
void sub_020545EC(FieldSystem *fieldSystem);
void sub_02054708(FieldTask *param0);
void sub_02054800(FieldTask *param0, int param1, int param2, int param3, int param4, int param5);
void sub_02054864(FieldTask *param0);
void sub_02054708(FieldTask *taskMan);
void sub_02054800(FieldTask *taskMan, int param1, int param2, int param3, int param4, int param5);
void sub_02054864(FieldTask *taskMan);

#endif // POKEPLATINUM_FIELD_MAP_CHANGE_H
10 changes: 5 additions & 5 deletions include/field_overworld_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ void FieldOverworldState_Init(FieldOverworldState *param0);
Location *FieldOverworldState_GetPlayerLocation(FieldOverworldState *param0);
Location *FieldOverworldState_GetEntranceLocation(FieldOverworldState *param0);
Location *FieldOverworldState_GetPrevLocation(FieldOverworldState *param0);
Location *sub_0203A72C(FieldOverworldState *param0);
Location *FieldOverworldState_GetExitLocation(FieldOverworldState *param0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

polish: The declarations' parameter names should match the definitions' ones. (same with the one in unk_02054884.h)

Location *FieldOverworldState_GetSpecialLocation(FieldOverworldState *param0);
void FieldOverworldState_SetSpecialLocation(FieldOverworldState *param0, Location *param1);
u16 *sub_0203A748(FieldOverworldState *param0);
u16 *FieldOverworldState_GetSpecialBGM(FieldOverworldState *param0);
u16 FieldOverworldState_GetWeather(const FieldOverworldState *param0);
void FieldOverworldState_SetWeather(FieldOverworldState *param0, u16 param1);
u16 FieldOverworldState_GetWarpId(const FieldOverworldState *param0);
Expand All @@ -30,9 +30,9 @@ UnkStruct_020556C4 *sub_0203A76C(FieldOverworldState *param0);
int FieldOverworldState_GetCameraType(const FieldOverworldState *param0);
void FieldOverworldState_SetCameraType(FieldOverworldState *param0, int param1);
PlayerData *FieldOverworldState_GetPlayerData(FieldOverworldState *param0);
u16 *sub_0203A784(FieldOverworldState *param0);
u16 *sub_0203A788(FieldOverworldState *param0);
u16 *sub_0203A78C(FieldOverworldState *param0);
u16 *FieldOverworldState_GetSafariBallCount(FieldOverworldState *param0);
u16 *FieldOverworldState_GetSafariStepCount(FieldOverworldState *param0);
u16 *FieldOverworldState_GetPoisonStepCount(FieldOverworldState *param0);
FieldOverworldState *SaveData_GetFieldOverworldState(SaveData *param0);
FieldOverworldSave *SaveData_GetFieldOverworldSave(SaveData *param0);
void FieldSystem_SaveObjects(FieldSystem *fieldSystem);
Expand Down
4 changes: 2 additions & 2 deletions include/inlines.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ static inline void inline_ov61_0222C3B0_sub(SysTask *param0, void *param1)

static inline void inline_ov47_0225621C_sub(FieldSystem *fieldSystem, int *param1, int *param2)
{
FieldOverworldState *v0 = SaveData_GetFieldOverworldState(fieldSystem->saveData);
Location *location = sub_0203A72C(v0);
FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(fieldSystem->saveData);
Location *location = FieldOverworldState_GetExitLocation(fieldState);

if (MapHeader_IsOnMainMatrix(fieldSystem->location->mapId)) {
*param1 = fieldSystem->location->x;
Expand Down
2 changes: 1 addition & 1 deletion include/overlay005/ov5_021EF4BC.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

UnkStruct_ov5_021EF4F8 *ov5_021EF4BC(u32 param0, HBlankSystem *param1);
void ov5_021EF4F8(UnkStruct_ov5_021EF4F8 *param0);
void ov5_021EF518(UnkStruct_ov5_021EF4F8 *param0);
void Field_DoPoisonEffect(UnkStruct_ov5_021EF4F8 *param0);

#endif // POKEPLATINUM_OV5_021EF4BC_H
2 changes: 1 addition & 1 deletion include/struct_decls/struct_0203A790_decl.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef POKEPLATINUM_STRUCT_0203A790_DECL_H
#define POKEPLATINUM_STRUCT_0203A790_DECL_H

typedef struct UnkStruct_0203A790_t FieldOverworldState;
typedef struct FieldOverworldState FieldOverworldState;

#endif // POKEPLATINUM_STRUCT_0203A790_DECL_H
2 changes: 1 addition & 1 deletion include/unk_02054884.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Pokemon *Party_FindFirstEligibleBattler(const Party *party);
Pokemon *Party_FindFirstHatchedMon(const Party *party);
BOOL Party_HasTwoAliveMons(const Party *party);
void Party_GiveChampionRibbons(Party *party);
int sub_02054B04(Party *param0, u16 param1);
int Pokemon_DoPoisonDamage(Party *param0, u16 param1);
BOOL Pokemon_TrySurvivePoison(Pokemon *mon);

#endif // POKEPLATINUM_UNK_02054884_H
4 changes: 2 additions & 2 deletions include/unk_020553DC.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include "field/field_system_decl.h"

void sub_020553DC(void);
void sub_020553F0(FieldSystem *fieldSystem, u16 param1);
u16 sub_02055404(FieldSystem *fieldSystem);
void Sound_SetSpecialBGM(FieldSystem *fieldSystem, u16 param1);
u16 Sound_GetSpecialBGM(FieldSystem *fieldSystem);
void Sound_ClearSpecialBGM(FieldSystem *fieldSystem);
u16 sub_02055428(FieldSystem *fieldSystem, int param1);
u16 sub_020554A4(FieldSystem *fieldSystem, int param1);
Expand Down
2 changes: 1 addition & 1 deletion src/encounter.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ static BOOL FieldTask_SafariEncounter(FieldTask *task)
FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task);
Encounter *encounter = FieldTask_GetEnv(task);
int *state = FieldTask_GetState(task);
u16 *ballCount = sub_0203A784(SaveData_GetFieldOverworldState(fieldSystem->saveData));
u16 *ballCount = FieldOverworldState_GetSafariBallCount(SaveData_GetFieldOverworldState(fieldSystem->saveData));

switch (*state) {
case 0:
Expand Down
2 changes: 1 addition & 1 deletion src/field_battle_data_transfer.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ void FieldBattleDTO_UpdateFieldSystem(const FieldBattleDTO *dto, FieldSystem *fi
Party *party = Party_GetFromSavedata(fieldSystem->saveData);
Bag *bag = SaveData_GetBag(fieldSystem->saveData);
PokedexData *pokedex = SaveData_Pokedex(fieldSystem->saveData);
u16 *fieldSysSafariBalls = sub_0203A784(SaveData_GetFieldOverworldState(fieldSystem->saveData));
u16 *fieldSysSafariBalls = FieldOverworldState_GetSafariBallCount(SaveData_GetFieldOverworldState(fieldSystem->saveData));

TrainerInfo_Copy(dto->trainerInfo[BATTLER_PLAYER_SLOT_1], trainerInfo);
Party_cpy(dto->parties[BATTLER_PLAYER_SLOT_1], party);
Expand Down
2 changes: 1 addition & 1 deletion src/field_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ static void sub_0203B094(FieldTask *taskMan)
v5 = MessageLoader_GetNewStrbuf(v2, 11);

if (v6 == 0) {
u16 *v7 = sub_0203A784(SaveData_GetFieldOverworldState(fieldSystem->saveData));
u16 *v7 = FieldOverworldState_GetSafariBallCount(SaveData_GetFieldOverworldState(fieldSystem->saveData));

StringTemplate_SetNumber(v3, 0, *v7, 2, 0, 1);
} else {
Expand Down
36 changes: 18 additions & 18 deletions src/field_overworld_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
#include "unk_0203A7D8.h"
#include "unk_020556C4.h"

typedef struct UnkStruct_0203A790_t {
typedef struct FieldOverworldState {
Location player;
Location entrance;
Location previous;
Location special;
Location unk_50;
u16 unk_64;
Location exit;
u16 bgm;
u16 weather;
u16 warpId;
u8 cameraType;
UnkStruct_020556C4 unk_6C;
PlayerData playerData;
u16 unk_94;
u16 unk_96;
u16 unk_98;
u16 unk_9A;
u16 unk_9C;
u16 poisonSteps;
u16 safariSteps;
u16 safariBalls;
u16 padding_9A; // unused
u16 padding_9C; // unused
} FieldOverworldState;

typedef struct UnkStruct_0203A79C_t {
Expand Down Expand Up @@ -79,9 +79,9 @@ Location *FieldOverworldState_GetPrevLocation(FieldOverworldState *fieldState)
return &fieldState->previous;
}

Location *sub_0203A72C(FieldOverworldState *fieldState)
Location *FieldOverworldState_GetExitLocation(FieldOverworldState *fieldState)
{
return &fieldState->unk_50;
return &fieldState->exit;
}

Location *FieldOverworldState_GetSpecialLocation(FieldOverworldState *fieldState)
Expand All @@ -95,9 +95,9 @@ void FieldOverworldState_SetSpecialLocation(FieldOverworldState *fieldState, Loc
return;
}

u16 *sub_0203A748(FieldOverworldState *fieldState)
u16 *FieldOverworldState_GetSpecialBGM(FieldOverworldState *fieldState)
{
return &fieldState->unk_64;
return &fieldState->bgm;
}

u16 FieldOverworldState_GetWeather(const FieldOverworldState *fieldState)
Expand Down Expand Up @@ -140,19 +140,19 @@ PlayerData *FieldOverworldState_GetPlayerData(FieldOverworldState *fieldState)
return &fieldState->playerData;
}

u16 *sub_0203A784(FieldOverworldState *fieldState)
u16 *FieldOverworldState_GetSafariBallCount(FieldOverworldState *fieldState)
{
return &fieldState->unk_98;
return &fieldState->safariBalls;
}

u16 *sub_0203A788(FieldOverworldState *fieldState)
u16 *FieldOverworldState_GetSafariStepCount(FieldOverworldState *fieldState)
{
return &fieldState->unk_96;
return &fieldState->safariSteps;
}

u16 *sub_0203A78C(FieldOverworldState *fieldState)
u16 *FieldOverworldState_GetPoisonStepCount(FieldOverworldState *fieldState)
{
return &fieldState->unk_94;
return &fieldState->poisonSteps;
}

FieldOverworldState *SaveData_GetFieldOverworldState(SaveData *saveData)
Expand Down
16 changes: 8 additions & 8 deletions src/overlay005/field_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ static void Field_CalculateFriendship(FieldSystem *fieldSystem)
static BOOL Field_UpdatePoison(FieldSystem *fieldSystem)
{
Party *party = Party_GetFromSavedata(fieldSystem->saveData);
u16 *poisonSteps = sub_0203A78C(SaveData_GetFieldOverworldState(fieldSystem->saveData));
u16 *poisonSteps = FieldOverworldState_GetPoisonStepCount(SaveData_GetFieldOverworldState(fieldSystem->saveData));

(*poisonSteps)++;
(*poisonSteps) %= 4;
Expand All @@ -905,14 +905,14 @@ static BOOL Field_UpdatePoison(FieldSystem *fieldSystem)
return FALSE;
}

switch (sub_02054B04(party, MapHeader_GetMapLabelTextID(fieldSystem->location->mapId))) {
switch (Pokemon_DoPoisonDamage(party, MapHeader_GetMapLabelTextID(fieldSystem->location->mapId))) {
case 0:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: It would be good to add descriptive constants for these cases (and the corresponding return values in Pokemon_DoPoisonDamage().

return FALSE;
case 1:
ov5_021EF518(fieldSystem->unk_04->unk_20);
Field_DoPoisonEffect(fieldSystem->unk_04->unk_20);
return FALSE;
case 2:
ov5_021EF518(fieldSystem->unk_04->unk_20);
Field_DoPoisonEffect(fieldSystem->unk_04->unk_20);
ScriptManager_Set(fieldSystem, 2003, NULL);
return TRUE;
}
Expand All @@ -926,14 +926,14 @@ static BOOL Field_UpdateSafari(FieldSystem *fieldSystem)
return FALSE;
}

u16 *balls = sub_0203A784(SaveData_GetFieldOverworldState(fieldSystem->saveData));
u16 *balls = FieldOverworldState_GetSafariBallCount(SaveData_GetFieldOverworldState(fieldSystem->saveData));

if (*balls == 0) {
ScriptManager_Set(fieldSystem, 8802, NULL);
return TRUE;
}

u16 *steps = sub_0203A788(SaveData_GetFieldOverworldState(fieldSystem->saveData));
u16 *steps = FieldOverworldState_GetSafariStepCount(SaveData_GetFieldOverworldState(fieldSystem->saveData));
(*steps)++;

if (*steps >= 500) {
Expand Down Expand Up @@ -1024,8 +1024,8 @@ static BOOL Field_MapConnection(const FieldSystem *fieldSystem, int playerX, int

static void Field_SetMapConnection(FieldSystem *fieldSystem, const int playerX, const int playerZ, const int playerDir)
{
FieldOverworldState *v0 = SaveData_GetFieldOverworldState(fieldSystem->saveData);
Location *nextMap = sub_0203A72C(v0);
FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(fieldSystem->saveData);
Location *nextMap = FieldOverworldState_GetExitLocation(fieldState);

(*nextMap) = *(fieldSystem->location);
nextMap->faceDirection = playerDir;
Expand Down
Loading
Loading