summaryrefslogtreecommitdiff
path: root/src/fieldmap.c
diff options
context:
space:
mode:
authorscnorton <scnorton@biociphers.org>2019-01-07 15:48:36 -0500
committerscnorton <scnorton@biociphers.org>2019-01-07 15:48:36 -0500
commit34cf3662fc0343d77fe36b1a3083605110764c9a (patch)
tree317722e88eaba51dbae0a611cff0ecb8d646ad3a /src/fieldmap.c
parente1bd043bf3049b8a91b718ca1e4416711f0b8646 (diff)
GetMapBorderIdAt
Diffstat (limited to 'src/fieldmap.c')
-rw-r--r--src/fieldmap.c56
1 files changed, 47 insertions, 9 deletions
diff --git a/src/fieldmap.c b/src/fieldmap.c
index 4193ece97..06385ff35 100644
--- a/src/fieldmap.c
+++ b/src/fieldmap.c
@@ -395,15 +395,7 @@ union Block
block; \
})
-#define MapGridGetTileAt(x, y) ({ \
- u16 block; \
- if (x >= 0 && x < VMap.Xsize \
- && y >= 0 && y < VMap.Ysize) \
- block = VMap.map[x + VMap.Xsize * y]; \
- else \
- block = MapGridGetBorderTileAt2(x, y); \
- block; \
-})
+#define MapGridGetTileAt(x, y) ((x >= 0 && x < VMap.Xsize && y >= 0 && y < VMap.Ysize) ? VMap.map[x + VMap.Xsize * y] : MapGridGetBorderTileAt2(x, y))
u8 MapGridGetZCoordAt(s32 x, s32 y)
{
@@ -641,3 +633,49 @@ void sub_8059250(u8 a1)
}
ClearSavedMapView();
}
+
+s32 GetMapBorderIdAt(s32 x, s32 y)
+{
+ if (MapGridGetTileAt(x, y) == 0x3FF)
+ {
+ return -1;
+ }
+
+ if (x >= VMap.Xsize - 8)
+ {
+ if (!gMapConnectionFlags.east)
+ {
+ return -1;
+ }
+ return CONNECTION_EAST;
+ }
+
+ if (x < 7)
+ {
+ if (!gMapConnectionFlags.west)
+ {
+ return -1;
+ }
+ return CONNECTION_WEST;
+ }
+
+ if (y >= VMap.Ysize - 7)
+ {
+ if (!gMapConnectionFlags.south)
+ {
+ return -1;
+ }
+ return CONNECTION_SOUTH;
+ }
+
+ if (y < 7)
+ {
+ if (!gMapConnectionFlags.north)
+ {
+ return -1;
+ }
+ return CONNECTION_NORTH;
+ }
+
+ return 0;
+}