summaryrefslogtreecommitdiff
path: root/src/map/clif.cpp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-10-19 22:22:08 -0700
committerBen Longbons <b.r.longbons@gmail.com>2014-10-26 14:21:48 -0700
commit6800761863dd45b6055768febc6ace6a20120dc7 (patch)
tree73b416ca6507d9bb4f950252d55ead8e8cda34b5 /src/map/clif.cpp
parent0edf563dfc14a2b9db33a92f0eced28950bdf1aa (diff)
downloadtmwa-6800761863dd45b6055768febc6ace6a20120dc7.tar.gz
tmwa-6800761863dd45b6055768febc6ace6a20120dc7.tar.bz2
tmwa-6800761863dd45b6055768febc6ace6a20120dc7.tar.xz
tmwa-6800761863dd45b6055768febc6ace6a20120dc7.zip
New ast module for for npc parsing
Will eventually put most/all parsers there.
Diffstat (limited to 'src/map/clif.cpp')
-rw-r--r--src/map/clif.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/map/clif.cpp b/src/map/clif.cpp
index b0cb541..a5b7278 100644
--- a/src/map/clif.cpp
+++ b/src/map/clif.cpp
@@ -5675,4 +5675,38 @@ void do_init_clif(void)
{
make_listen_port(map_port, SessionParsers{.func_parse= clif_parse, .func_delete= clif_delete});
}
+
+bool extract(XString str, DIR *d)
+{
+ unsigned di;
+ if (extract(str, &di) && di < 8)
+ {
+ *d = static_cast<DIR>(di);
+ return true;
+ }
+ const struct
+ {
+ LString str;
+ DIR d;
+ } dirs[] =
+ {
+ {"S"_s, DIR::S},
+ {"SW"_s, DIR::SW},
+ {"W"_s, DIR::W},
+ {"NW"_s, DIR::NW},
+ {"N"_s, DIR::N},
+ {"NE"_s, DIR::NE},
+ {"E"_s, DIR::E},
+ {"SE"_s, DIR::SE},
+ };
+ for (auto& pair : dirs)
+ {
+ if (str == pair.str)
+ {
+ *d = pair.d;
+ return true;
+ }
+ }
+ return false;
+}
} // namespace tmwa