summaryrefslogtreecommitdiff
path: root/src/field/landmark.c
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2017-10-01 19:48:31 -0400
committerPikalaxALT <pikalaxalt@gmail.com>2017-10-01 19:52:40 -0400
commit0685dd4920c64eae6bcfbc9f201854b4da91bfab (patch)
treef759feaf819167d436ab4fde480eca35ba591b04 /src/field/landmark.c
parentd0fbed6ad50c34593002c2b540c4e3e7f4c5cd16 (diff)
parent50dc4f429d4aa68e0365adc71d17e43a0dd7b843 (diff)
Merge branch 'master' into trade
Diffstat (limited to 'src/field/landmark.c')
-rw-r--r--src/field/landmark.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/field/landmark.c b/src/field/landmark.c
new file mode 100644
index 000000000..6a53716bb
--- /dev/null
+++ b/src/field/landmark.c
@@ -0,0 +1,73 @@
+#include "global.h"
+#include "landmark.h"
+#include "event_data.h"
+
+#define MAPSEC_NONE 0x58
+
+struct Landmark
+{
+ u8 *name;
+ u16 flag;
+};
+
+struct LandmarkList
+{
+ u8 mapSection;
+ u8 id;
+ const struct Landmark **landmarks;
+};
+
+extern const struct LandmarkList gLandmarkLists[];
+
+static const struct Landmark **GetLandmarks(u8 mapSection, u8 id);
+
+u8 *GetLandmarkName(u8 mapSection, u8 id, u8 count)
+{
+ const struct Landmark **landmarks = GetLandmarks(mapSection, id);
+
+ if (!landmarks)
+ return NULL;
+
+ while (1)
+ {
+ const struct Landmark *landmark = *landmarks;
+
+ if (landmark->flag == 0xFFFF || FlagGet(landmark->flag) == TRUE)
+ {
+ if (count == 0)
+ break;
+ else
+ count--;
+ }
+
+ landmarks++;
+ if (!*landmarks)
+ return NULL;
+ }
+
+ return (*landmarks)->name;
+}
+
+static const struct Landmark **GetLandmarks(u8 mapSection, u8 id)
+{
+ u16 i = 0;
+
+ for (; gLandmarkLists[i].mapSection != MAPSEC_NONE; i++)
+ {
+ if (gLandmarkLists[i].mapSection > mapSection)
+ return NULL;
+ if (gLandmarkLists[i].mapSection == mapSection)
+ break;
+ }
+
+ if (gLandmarkLists[i].mapSection == MAPSEC_NONE)
+ return NULL;
+
+ for (; gLandmarkLists[i].mapSection == mapSection; i++)
+ {
+ if (gLandmarkLists[i].id == id)
+ return gLandmarkLists[i].landmarks;
+ }
+
+ return NULL;
+}