summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/clif.cpp34
-rw-r--r--src/map/clif.hpp2
2 files changed, 36 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
diff --git a/src/map/clif.hpp b/src/map/clif.hpp
index 12ed633..9873592 100644
--- a/src/map/clif.hpp
+++ b/src/map/clif.hpp
@@ -189,4 +189,6 @@ int clif_GM_kick(dumb_ptr<map_session_data> sd, dumb_ptr<map_session_data> tsd,
int clif_foreachclient(std::function<void(dumb_ptr<map_session_data>)>);
void do_init_clif(void);
+
+bool extract(XString, DIR *);
} // namespace tmwa