summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/code_8040094.c4
-rw-r--r--src/dungeon_ai_items.c2
-rw-r--r--src/dungeon_map_access.c15
-rw-r--r--src/dungeon_movement.c4
-rw-r--r--src/dungeon_range.c3
-rw-r--r--src/dungeon_util.c15
6 files changed, 29 insertions, 14 deletions
diff --git a/src/code_8040094.c b/src/code_8040094.c
index 11429b0..c834602 100644
--- a/src/code_8040094.c
+++ b/src/code_8040094.c
@@ -35,9 +35,9 @@ void HandleLuminousOrbAction(u32 param_1)
gDungeonGlobalData->unk1820B = 1;
- for(YCoord = 0; YCoord <= DUNGEON_MAX_SIZE_Y; YCoord++)
+ for(YCoord = 0; YCoord < DUNGEON_MAX_SIZE_Y; YCoord++)
{
- for(XCoord = 0; XCoord <= DUNGEON_MAX_SIZE_X; XCoord++)
+ for(XCoord = 0; XCoord < DUNGEON_MAX_SIZE_X; XCoord++)
{
mapTile = GetMapEntity(XCoord, YCoord);
mapTile->unk4 = mapTile->unk4 | 1;
diff --git a/src/dungeon_ai_items.c b/src/dungeon_ai_items.c
index 923384d..fc10e85 100644
--- a/src/dungeon_ai_items.c
+++ b/src/dungeon_ai_items.c
@@ -11,6 +11,7 @@
#include "dungeon_capabilities_1.h"
#include "dungeon_entity.h"
#include "dungeon_global_data.h"
+#include "dungeon_map_access.h"
#include "dungeon_pokemon_attributes_1.h"
#include "dungeon_random.h"
#include "dungeon_random_1.h"
@@ -31,7 +32,6 @@ enum ItemTargetFlag
};
extern s32 CalculateFacingDir(struct Position*, struct Position*);
-extern struct MapTile* GetMapTileAtPosition(s16, s16);
extern u32 EvaluateItem(struct DungeonEntity*, struct ItemSlot*, u8);
extern bool8 ToolboxEnabled(struct DungeonEntityData*);
extern void sub_8077274(struct DungeonEntity *, struct DungeonEntity *);
diff --git a/src/dungeon_map_access.c b/src/dungeon_map_access.c
new file mode 100644
index 0000000..43e0e4d
--- /dev/null
+++ b/src/dungeon_map_access.c
@@ -0,0 +1,15 @@
+#include "global.h"
+#include "dungeon_map_access.h"
+
+#include "dungeon_global_data.h"
+
+extern struct MapTile *gUnknown_203B430;
+
+struct MapTile* GetMapTileAtPosition(s32 x, s32 y)
+{
+ if (x >= 0 && y >= 0 && x < DUNGEON_MAX_SIZE_X && y < DUNGEON_MAX_SIZE_Y)
+ {
+ return gDungeonGlobalData->mapEntityPointers[y][x];
+ }
+ return gUnknown_203B430;
+}
diff --git a/src/dungeon_movement.c b/src/dungeon_movement.c
index 275de05..1601cff 100644
--- a/src/dungeon_movement.c
+++ b/src/dungeon_movement.c
@@ -49,7 +49,7 @@ u32 sub_8075818(struct DungeonEntity *entity)
entityData = entity->entityData;
if(EntityExists(entity))
{
- tile = sub_8045128(entity);
+ tile = GetMapEntityForDungeonEntity(entity);
if(HasIQSkill(entity, IQ_SKILL_SUPER_MOBILE))
if(!(tile->tileType & (TILE_TYPE_FLOOR | TILE_TYPE_UNK_1)))
return 1;
@@ -136,7 +136,7 @@ void sub_8075900(struct DungeonEntity *pokemon, u8 r1)
{
if(!gDungeonGlobalData->monsterHouseActive)
{
- if((sub_8045128(pokemon)->tileType & TILE_TYPE_MONSTER_HOUSE))
+ if((GetMapEntityForDungeonEntity(pokemon)->tileType & TILE_TYPE_MONSTER_HOUSE))
{
// It's a monster house!
SendMessage(GetLeaderEntity(), gPtrItsaMonsterHouseMessage);
diff --git a/src/dungeon_range.c b/src/dungeon_range.c
index 86d0f7c..facd71d 100644
--- a/src/dungeon_range.c
+++ b/src/dungeon_range.c
@@ -2,10 +2,9 @@
#include "dungeon_range.h"
#include "dungeon_global_data.h"
+#include "dungeon_map_access.h"
#include "map.h"
-extern struct MapTile* GetMapTileAtPosition(s16, s16);
-
bool8 InSameRoom_2(struct Position *pos1, struct Position *pos2)
{
u8 pos1RoomIndex;
diff --git a/src/dungeon_util.c b/src/dungeon_util.c
index 50b3e08..3594274 100644
--- a/src/dungeon_util.c
+++ b/src/dungeon_util.c
@@ -1,7 +1,8 @@
#include "global.h"
#include "dungeon_util.h"
-extern struct MapTile* GetMapTileAtPosition(s16, s16);
+#include "dungeon_map_access.h"
+
extern struct MapTile* GetMapEntity(s16, s16);
bool8 EntityExists(struct DungeonEntity *entity)
@@ -23,32 +24,32 @@ u8 GetEntityRoomIndex(struct DungeonEntity *entity)
return entity->roomIndex;
}
-struct DungeonEntityData *GetTrapData(struct DungeonEntity *entity)
+struct DungeonEntityData* GetTrapData(struct DungeonEntity *entity)
{
return entity->entityData;
}
-struct ItemSlot *GetItemData(struct DungeonEntity *entity)
+struct ItemSlot* GetItemData(struct DungeonEntity *entity)
{
return (struct ItemSlot *)entity->entityData;
}
-struct DungeonEntityData *sub_804510C(struct DungeonEntity *entity)
+struct DungeonEntityData* sub_804510C(struct DungeonEntity *entity)
{
return entity->entityData;
}
-struct DungeonEntityData *sub_8045110(struct DungeonEntity *entity)
+struct DungeonEntityData* sub_8045110(struct DungeonEntity *entity)
{
return entity->entityData;
}
-struct MapTile *sub_8045114(struct DungeonEntity *entity)
+struct MapTile* GetMapTileForDungeonEntity(struct DungeonEntity *entity)
{
return GetMapTileAtPosition(entity->posWorld.x, entity->posWorld.y);
}
-struct MapTile *sub_8045128(struct DungeonEntity *entity)
+struct MapTile* GetMapEntityForDungeonEntity(struct DungeonEntity *entity)
{
return GetMapEntity(entity->posWorld.x, entity->posWorld.y);
}