-
Notifications
You must be signed in to change notification settings - Fork 80
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few thoughts on names, and a variety of small style stuff we're working on cleaning up. For the style matters, I only commented on the first occurrence of each that I noticed. Thanks for another contribution :)
include/field_map_change.h
Outdated
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
include/field_overworld_state.h
Outdated
@@ -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); |
There was a problem hiding this comment.
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
)
src/overlay005/field_control.c
Outdated
@@ -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: |
There was a problem hiding this comment.
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()
.
u32 v1; | ||
int v2, v3; | ||
FieldOverworldState *v4; | ||
u32 mapId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
polish: We're working on cleaning up C89-style declarations to be more concise and declared when needed, as long as it matches. For example:
- u32 mapId;
...
- mapId = fieldSystem->location->mapId;
+ u32 mapId = fieldSystem->location->mapId;
I think these should match.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately that doesn't seem to match
src/overlay005/fieldmap.c
Outdated
@@ -426,10 +426,10 @@ static BOOL FieldMap_ChangeZone(FieldSystem *fieldSystem) | |||
} | |||
|
|||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
polish: We're also working on cleaning up unnecessary scope blocks like these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there's still a couple pesky extra scope blocks in this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be taken care of now
src/unk_02054884.c
Outdated
if (Pokemon_CanBattle(v4)) { | ||
if (Pokemon_GetValue(v4, MON_DATA_STATUS_CONDITION, NULL) & (MON_CONDITION_TOXIC | MON_CONDITION_POISON)) { | ||
u32 v5 = Pokemon_GetValue(v4, MON_DATA_CURRENT_HP, NULL); | ||
if (Pokemon_CanBattle(mon)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: I think you can collapse these two if
statements into one with a conjunction and it'll still match.
src/unk_020553DC.c
Outdated
@@ -119,23 +119,23 @@ void sub_020553DC() | |||
return; | |||
} | |||
|
|||
void sub_020553F0(FieldSystem *fieldSystem, u16 param1) | |||
void Sound_SetSpecialBGM(FieldSystem *fieldSystem, u16 param1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: I think param1
here is a SDAT ID. For all the invocations of this function that pass a constant, you should be able to find a matching constant in the SDAT consts file. I would recommend just ctrl+Fing for the number in the generated file build/consts/sdat.h
.
src/unk_020553DC.c
Outdated
{ | ||
u16 *v0 = sub_0203A748(SaveData_GetFieldOverworldState(fieldSystem->saveData)); | ||
u16 *v0 = FieldOverworldState_GetSpecialBGM(SaveData_GetFieldOverworldState(fieldSystem->saveData)); | ||
|
||
*v0 = param1; | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
polish: This return
can be removed.
src/unk_02054884.c
Outdated
BOOL result; | ||
TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(param1); | ||
Party *party = Party_GetFromSavedata(param1); | ||
Pokemon *mon = Pokemon_New(32); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
polish: The 32
here is a heap ID - HEAP_ID_FIELD_TASK
.
src/unk_02054884.c
Outdated
@@ -31,55 +31,55 @@ BOOL Pokemon_CanBattle(Pokemon *mon) | |||
|
|||
BOOL sub_020548B0(int param0, SaveData *param1, u16 param2, u8 param3, u16 param4, int param5, int param6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought: I wonder if this and the function below are documented enough to name at this point. Looks like this particular one is only invoked in the script command ScrCmd_096
, which DSPRE has named GivePokemon
. The one below still has a bit more mystique in how it's invoked, so maybe just this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100% agree that we should aim to name scripting commands as we finish documenting functions which they invoke.
…sary return; and scoping, more renaming)
Thanks for all the feedback, I've processed most it in the new commit (and also got carried away again with some new additions, whoops), let me know if there's anything else (or new) to improve. |
…rom this PR with `task`
First commit: Renaming
sub_02054B04
toPokemon_DoPoisonDamage
and renamng all the variables in that function and related functions.Second and third commit: Renaming various functions and variables in
field_overworld_state.c
and related files.Fourth commit: Renaming variables in
unk_02054884.c
.There's one function name in
field_overworld_state.c
and some inunk_02054884.c
which I wasn't sure what to name, so I left those as they are. Also, let me know if this PR was too all over the place, I just started from somewhere and then one renamed variable lead me to other variables to be renamed.