From 0df055bcc6fc09fd67ae7c0a802e7d2280ae404b Mon Sep 17 00:00:00 2001 From: Kermalis <29823718+Kermalis@users.noreply.github.com> Date: Sun, 10 Nov 2024 22:51:33 -0500 Subject: [PATCH] Replace EntTrapInfo with Trap --- include/code_80450F8.h | 2 +- include/dungeon_util.h | 15 ++++++++++----- include/structs/axdata.h | 2 +- include/structs/dungeon_entity.h | 12 ------------ include/structs/str_dungeon.h | 3 ++- include/structs/str_traps.h | 5 +++-- src/code_803E724.c | 12 ++++++------ src/code_80450F8.c | 15 +++++++++------ src/code_806E8B0.c | 1 + src/code_8072B78.c | 4 ++-- src/code_80861A8.c | 1 + src/dungeon_util.c | 8 ++++---- src/status_checks.c | 2 +- 13 files changed, 41 insertions(+), 41 deletions(-) diff --git a/include/code_80450F8.h b/include/code_80450F8.h index abf7c7d92..82374dd0c 100644 --- a/include/code_80450F8.h +++ b/include/code_80450F8.h @@ -3,7 +3,7 @@ #include "structs/dungeon_entity.h" -Entity *sub_8045684(u8 a, Position *pos, u8 c); +Entity *sub_8045684(u8 trapID, Position *pos, u8 c); Entity *sub_8045708(Position *pos); void sub_80457DC(Entity* ent); diff --git a/include/dungeon_util.h b/include/dungeon_util.h index b28f72e31..e2b1d27e2 100644 --- a/include/dungeon_util.h +++ b/include/dungeon_util.h @@ -11,13 +11,18 @@ extern const Position gAdjacentTileOffsets[NUM_DIRECTIONS]; bool8 EntityExists(Entity *pokemon); u32 GetEntityType(Entity *entity); u8 GetEntityRoom(Entity *entity); -Trap *GetTrapData(Entity *entity); -Trap* GetTrapData_1(Entity *entity); -Item *GetItemData(Entity *entity); struct Tile *GetTileAtEntitySafe(Entity *entity); -Item *GetItemData_1(Entity *entity); void sub_804535C(Entity *entity, Position32 *pos); void SetEntityPixelPos(Entity *entity, s32 x, s32 y); void IncreaseEntityPixelPos(Entity *entity, s32 x, s32 y); -#endif +static inline EntityInfo *GetEntInfo(Entity *entity) +{ + return entity->axObj.info.monster; +} +Item *GetItemData(Entity *entity); +Item *GetItemData_1(Entity *entity); +Trap *GetTrapData(Entity *entity); +Trap* GetTrapData_1(Entity *entity); + +#endif // GUARD_DUNGEON_UTIL_H \ No newline at end of file diff --git a/include/structs/axdata.h b/include/structs/axdata.h index cbc027b1f..a08151b7b 100644 --- a/include/structs/axdata.h +++ b/include/structs/axdata.h @@ -88,7 +88,7 @@ struct axObject { struct Item* item; struct EntityInfo* monster; - struct EntTrapInfo* trap; + struct Trap* trap; } info; }; diff --git a/include/structs/dungeon_entity.h b/include/structs/dungeon_entity.h index 579c6e3f9..0bf034ef3 100644 --- a/include/structs/dungeon_entity.h +++ b/include/structs/dungeon_entity.h @@ -352,13 +352,6 @@ typedef struct EntityInfo u8 unk204; } EntityInfo; -// size: 0x4 -typedef struct EntTrapInfo -{ - /* 0x0 */ u8 unk0; - /* 0x0 */ u8 unk1; -} EntTrapInfo; - // size: 0x74 | Used for Pokémon, items, and traps. typedef struct Entity { @@ -477,9 +470,4 @@ static inline void SetExpMultplier(EntityInfo *info) SetRegularExpMultiplier(info); } -static inline EntityInfo *GetEntInfo(Entity *ent) -{ - return ent->axObj.info.monster; -} - #endif diff --git a/include/structs/str_dungeon.h b/include/structs/str_dungeon.h index 66642c31b..5f20fad1b 100644 --- a/include/structs/str_dungeon.h +++ b/include/structs/str_dungeon.h @@ -7,6 +7,7 @@ #include "structs/map.h" #include "structs/rgb.h" #include "structs/str_position.h" +#include "structs/str_traps.h" #include "sprite.h" #define DUNGEON_MAX_SIZE_X 56 @@ -356,7 +357,7 @@ typedef struct Dungeon /* 0x3800 */ s16 deoxysForm; Item unk3804[DUNGEON_MAX_ITEMS]; /* 0x3904 */ s16 unk3904; - EntTrapInfo unk3908[DUNGEON_MAX_TRAPS]; + Trap unk3908[DUNGEON_MAX_TRAPS]; /* 0x3A08 */ bool8 unk3A08; /* 0x3A09 */ bool8 unk3A09; /* 0x3A0A */ bool8 unk3A0A; diff --git a/include/structs/str_traps.h b/include/structs/str_traps.h index 1c3d4f9e4..8727333da 100644 --- a/include/structs/str_traps.h +++ b/include/structs/str_traps.h @@ -3,10 +3,11 @@ #include "constants/trap.h" -typedef struct Trap +// size: 0x4 +typedef struct Trap { /* 0x0 */ u8 id; /* 0x1 */ u8 unk1; } Trap; -#endif // GUARD_STR_TRAPS_H +#endif // GUARD_STR_TRAPS_H \ No newline at end of file diff --git a/src/code_803E724.c b/src/code_803E724.c index 7c9233200..f33a118a8 100644 --- a/src/code_803E724.c +++ b/src/code_803E724.c @@ -849,9 +849,9 @@ void sub_803F27C(bool8 a0) strPtr->blinded = 0; strPtr->hallucinating = 0; strPtr->unk1820F = 0; - strPtr->unk1820D = 0; + strPtr->unk1820D = FALSE; strPtr->unk18211 = 0; - strPtr->unk1820E = 0; + strPtr->unk1820E = FALSE; strPtr->unk1820B = 0; strPtr->unk1820C = 0; } @@ -979,8 +979,8 @@ void sub_803F580(u8 a0) strPtr->cameraPixelPos.y = (cameraTarget->pixelPos.y / 256) - 96; if (HasHeldItem(cameraTarget, ITEM_X_RAY_SPECS) && info->isTeamLeader) { - strPtr->unk1820D = 1; - strPtr->unk1820E = 1; + strPtr->unk1820D = TRUE; + strPtr->unk1820E = TRUE; } else { strPtr->unk1820D = info->powerEars; @@ -1112,8 +1112,8 @@ void sub_803F878(s32 a0, s32 a1) strPtr->cameraPixelPos.y = (a1 / 256) - 96; strPtr->cameraPos.x = a0 / 6144; strPtr->cameraPos.y = a1 / 6144; - strPtr->unk1820D = 0; - strPtr->unk1820E = 0; + strPtr->unk1820D = FALSE; + strPtr->unk1820E = FALSE; strPtr->unk18211 = 0; strPtr->unk18216 = 0; diff --git a/src/code_80450F8.c b/src/code_80450F8.c index 243bb1e9f..6e1b42eb3 100644 --- a/src/code_80450F8.c +++ b/src/code_80450F8.c @@ -391,7 +391,7 @@ Entity *sub_804550C(s16 a) ); } -Entity *sub_8045684(u8 a, Position *pos, u8 c) +Entity *sub_8045684(u8 trapID, Position *pos, u8 c) { Entity *entity; s32 i; @@ -401,7 +401,7 @@ Entity *sub_8045684(u8 a, Position *pos, u8 c) if (!EntityExists(entity)) { entity->type = ENTITY_TRAP; entity->axObj.info.trap = &gDungeon->unk3908[i]; - entity->axObj.info.trap->unk0 = a; + entity->axObj.info.trap->id = trapID; entity->axObj.info.trap->unk1 = c; entity->unk1C = 0; @@ -457,19 +457,19 @@ bool8 sub_8045804(Entity *ent) { UnkDungeonGlobal_unk181E8_sub* saveTyping; Entity* camTarget; - EntityInfo *entInfo; + EntityInfo *monInfo; switch (GetEntityType(ent)) { case ENTITY_MONSTER: { if (ent->isVisible) { saveTyping = &gDungeon->unk181e8; camTarget = saveTyping->cameraTarget; - entInfo = GetEntInfo(ent); + monInfo = GetEntInfo(ent); - if (!entInfo->isNotTeamMember) + if (!monInfo->isNotTeamMember) return TRUE; - if (!saveTyping->unk1820F && entInfo->transformStatus.transformStatus == STATUS_INVISIBLE) + if (!saveTyping->unk1820F && monInfo->transformStatus.transformStatus == STATUS_INVISIBLE) return FALSE; if (saveTyping->unk1820B || saveTyping->unk1820D) @@ -480,6 +480,9 @@ bool8 sub_8045804(Entity *ent) } return FALSE; } + /*case ENTITY_TRAP: + case ENTITY_ITEM: + case ENTITY_UNK_4:*/ default: { return TRUE; } diff --git a/src/code_806E8B0.c b/src/code_806E8B0.c index 8da4a347b..c1862ccea 100644 --- a/src/code_806E8B0.c +++ b/src/code_806E8B0.c @@ -21,6 +21,7 @@ #include "code_8045A00.h" #include "dungeon_items.h" #include "structs/str_damage.h" +#include "dungeon_util.h" void sub_8042940(Entity *r0); void sub_80428B0(Entity *r0); diff --git a/src/code_8072B78.c b/src/code_8072B78.c index 12a3b08da..d3b1eddb1 100644 --- a/src/code_8072B78.c +++ b/src/code_8072B78.c @@ -2,9 +2,10 @@ #include "code_805D8C8.h" #include "code_806CD90.h" #include "dungeon_map_access.h" +#include "dungeon_message.h" #include "dungeon_movement.h" #include "dungeon_random.h" -#include "dungeon_message.h" +#include "dungeon_util.h" #include "moves.h" #include "pokemon_mid.h" #include "pokemon_mid.h" @@ -13,7 +14,6 @@ #include "structs/map.h" #include "structs/str_pokemon.h" -extern Position gAdjacentTileOffsets[]; extern u8 *gUnknown_80FE2EC[]; struct unkStruct_806B7F8 diff --git a/src/code_80861A8.c b/src/code_80861A8.c index df08b8531..e53b058e0 100644 --- a/src/code_80861A8.c +++ b/src/code_80861A8.c @@ -5,6 +5,7 @@ #include "code_803E668.h" #include "code_806CD90.h" #include "dungeon_music.h" +#include "dungeon_util.h" extern const unkStruct_2039DB0 gUnknown_8107380; diff --git a/src/dungeon_util.c b/src/dungeon_util.c index 56885cb0b..4db47a0a0 100644 --- a/src/dungeon_util.c +++ b/src/dungeon_util.c @@ -47,22 +47,22 @@ u8 GetEntityRoom(Entity *entity) Trap* GetTrapData(Entity *entity) { - return (Trap *) GetEntInfo(entity); + return entity->axObj.info.trap; } Item* GetItemData(Entity *entity) { - return (Item *) GetEntInfo(entity); + return entity->axObj.info.item; } Trap* GetTrapData_1(Entity *entity) { - return (Trap *) GetEntInfo(entity); + return entity->axObj.info.trap; } Item* GetItemData_1(Entity *entity) { - return (Item*) GetEntInfo(entity); + return entity->axObj.info.item; } Tile *GetTileAtEntity(Entity *entity) diff --git a/src/status_checks.c b/src/status_checks.c index e7643e2f6..14d05b60c 100644 --- a/src/status_checks.c +++ b/src/status_checks.c @@ -1,6 +1,6 @@ #include "global.h" #include "status_checks.h" - +#include "dungeon_util.h" #include "charge_move.h" #include "code_8045A00.h" #include "dungeon_message.h"