-
Notifications
You must be signed in to change notification settings - Fork 87
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
cleanup map_object.c #306
base: master
Are you sure you want to change the base?
cleanup map_object.c #306
Conversation
marking as ready cause this PR is getting too big and overwhelming, expect a part 2 sometime in the future |
@@ -28,7 +28,7 @@ | |||
.public GF3dGfxRawResObj_GetTex4x4Key | |||
.public GF3dGfxRawResObj_GetPlttKey | |||
.public sub_02026E18 | |||
.public MapObject_GetFieldSysPtr | |||
.public MapObject_GetFieldSystemPtr |
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.
can drop Ptr
@@ -34,7 +34,7 @@ u16* GetVarPointer(FieldSystem* fieldSystem, u16 varId); | |||
u16 FieldSystem_VarGet(FieldSystem* fieldSystem, u16 varId); | |||
BOOL FieldSystem_VarSet(FieldSystem* fieldSystem, u16 varId, u16 value); | |||
u16 FieldSystem_VarGetObjectEventGraphicsId(FieldSystem* fieldSystem, u16 objId); | |||
BOOL FieldSystem_FlagGet(FieldSystem *fieldSystem, u16 flagId); | |||
BOOL FieldSystem_FlagCheck(FieldSystem *fieldSystem, u16 flagId); |
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.
verb should come before? I remember having a discussion about this but that might've just been for the battle commands
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.
out of scope (will fix it when I get to fieldmap)
u32 unk0; | ||
u32 unk4; | ||
u32 flags; | ||
u32 flags2; |
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.
any ay to distinguish between flags and flags2?
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.
honestly I forgot I even renamed these in this ptr, I'll check when I have more time lmao
GF_ASSERT(obj != NULL); | ||
|
||
MapObject_SetID(obj, obj_apricorn); | ||
MapObject_SetType(obj, 0); | ||
MapObject_SetFlagID(obj, 0); | ||
MapObject_SetXRange(obj, -1); | ||
MapObject_SetYRange(obj, -1); | ||
MapObject_SetFlagsBits(obj, MAPOBJECTFLAG_UNK13 | MAPOBJECTFLAG_UNK10); | ||
MapObject_ClearFlagsBits(obj, MAPOBJECTFLAG_UNK8 | MAPOBJECTFLAG_UNK7); | ||
MapObject_SetFlagsBits(obj, (MapObjectFlagBits)(MAPOBJECTFLAG_UNK13 | MAPOBJECTFLAG_UNK10)); |
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.
is it really worth having the enum if you have to keep casting it? #define could work just as well
void MapObject_Delete(LocalMapObject *object) { | ||
u32 flagId = MapObject_GetFlagID(object); | ||
FieldSystem *fieldSystem = MapObject_GetFieldSystemPtr(object); | ||
FieldSystem_FlagSet(fieldSystem, (u16)flagId); |
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.
does this match if you change the function signature to (FieldSystem *, u16) or change flagId to a u16?
|
||
static void sub_0205E934(LocalMapObject *object) { | ||
MapObject_SetFlagsBits(object, (MapObjectFlagBits)(MAPOBJECTFLAG_UNK2 | MAPOBJECTFLAG_ACTIVE)); | ||
MapObject_ClearFlagsBits(object, (MapObjectFlagBits)(MAPOBJECTFLAG_IGNORE_HEIGHTS | MAPOBJECTFLAG_UNK22 | |
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.
not sure how much I like the stacking compared to before
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.
This should not be an enum type.
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 does kinda make sense to be an enum type, it's just flags enums are annoying, I wonder if there's a way to get the compiler to work properly with this, would be good
@@ -37,7 +37,7 @@ | |||
#include "unk_020552A4.h" | |||
#include "unk_02034354.h" | |||
#include "unk_02066EDC.h" | |||
#include "field_map_object.h" | |||
#include "map_object.h" |
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.
This is included twice
@@ -117,6 +115,7 @@ typedef struct UnkLMOCallbackStruct2 { | |||
} UnkLMOCallbackStruct2; | |||
|
|||
typedef enum MapObjectFlagBits { | |||
MAPOBJECTFLAG_INACTIVE = 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.
MAPOBJECTFLAG_INACTIVE = 0, | |
MAPOBJECTFLAG_NONE = 0, |
u32 object_gfx_id = MapObject_GetGfxID(object); | ||
if (object_gfx_id != gfx_id) { |
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.
oop
UnkLMOCallbackStruct2* unk = (gfx_id == 0x2000) ? (UnkLMOCallbackStruct2*)&ov01_0220724C : sub_0205FB38(gfx_id); | ||
static void sub_0205ED18(LocalMapObject *object) { | ||
u32 spriteId = MapObject_GetSpriteID(object); | ||
UnkLMOCallbackStruct2 *unk = (spriteId == SPRITE_CAMERA_FOCUS) ? (UnkLMOCallbackStruct2 *)&ov01_0220724C : sub_0205FB38(spriteId); |
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.
This should probably be a const pointer
@@ -1,7 +1,7 @@ | |||
#ifndef POKEHEARTGOLD_FOLLOW_MON_H | |||
#define POKEHEARTGOLD_FOLLOW_MON_H | |||
|
|||
#include "field_map_object.h" | |||
#include "map_object.h" |
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 original filename is adapted from gen 3, and imo equivalent routines should have equivalent (or close enough) names to facilitate transition from gen 3 to gen 4.
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.
field does have a special meaning in gen 4 (the field overlay) which ofc is not present in gen 3, I believe this is sufficient to differentiate it
plus I genuinely don't look at gen 3 when decomping/cleaning up, the structures, consoles, and general differences are enough to make gen 3 at best misleading, at worst completely breaking for the process
void sub_0205E104(MapObjectManager* manager, u32 a1, u32 a2, u32 num_object_events, ObjectEvent* object_events) { | ||
u32 count = MapObjectManager_GetCount(manager); | ||
LocalMapObject* objects = MapObjectManager_GetObjects(manager); | ||
extern void ov01_021F9FB0(MapObjectManager *manager, void *); |
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.
Put this in a header
|
||
static void sub_0205E934(LocalMapObject *object) { | ||
MapObject_SetFlagsBits(object, (MapObjectFlagBits)(MAPOBJECTFLAG_UNK2 | MAPOBJECTFLAG_ACTIVE)); | ||
MapObject_ClearFlagsBits(object, (MapObjectFlagBits)(MAPOBJECTFLAG_IGNORE_HEIGHTS | MAPOBJECTFLAG_UNK22 | |
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.
This should not be an enum type.
void sub_0205EF6C(LocalMapObject* object) { | ||
// No-op | ||
static void MapObject_NoOp(LocalMapObject *object) { | ||
// NoOp |
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.
Why change this comment?
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.
consistency, noop is NoOp elsewhere in code, and the comment should be the same as the name of the func
basically there's little to no purpose to it other than the look nice
No description provided.