summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-03-15 19:34:59 -0700
committerBen Longbons <b.r.longbons@gmail.com>2014-03-16 18:58:48 -0700
commitc812c92d1a1835f0bda783e709481188c8d92225 (patch)
treeb401ede48a088ad1aaed88fe3b997cd26ff7ae08
parentde9ee1b9754af9d954487121947352f32d7ebb7e (diff)
downloadtmwa-c812c92d1a1835f0bda783e709481188c8d92225.tar.gz
tmwa-c812c92d1a1835f0bda783e709481188c8d92225.tar.bz2
tmwa-c812c92d1a1835f0bda783e709481188c8d92225.tar.xz
tmwa-c812c92d1a1835f0bda783e709481188c8d92225.zip
Clean up header organization
-rw-r--r--src/admin/GNUmakefile7
-rw-r--r--src/admin/ladmin.cpp17
-rw-r--r--src/admin/main.cpp2
-rw-r--r--src/char/GNUmakefile7
-rw-r--r--src/char/char.cpp19
-rw-r--r--src/char/char.hpp13
-rw-r--r--src/char/int_party.cpp9
-rw-r--r--src/char/int_party.hpp6
-rw-r--r--src/char/int_storage.cpp9
-rw-r--r--src/char/int_storage.hpp6
-rw-r--r--src/char/inter.cpp13
-rw-r--r--src/char/inter.hpp6
-rw-r--r--src/char/main.cpp2
-rw-r--r--src/common/GNUmakefile7
-rw-r--r--src/compat/alg.cpp3
-rw-r--r--src/compat/alg.hpp21
-rw-r--r--src/compat/attr.hpp13
-rw-r--r--src/compat/cast.cpp3
-rw-r--r--src/compat/cast.hpp54
-rw-r--r--src/compat/fun.hpp11
-rw-r--r--src/compat/iter.cpp3
-rw-r--r--src/compat/iter.hpp (renamed from src/common/iter.hpp)6
-rw-r--r--src/compat/iter_test.cpp (renamed from src/common/iter_test.cpp)0
-rw-r--r--src/compat/memory.cpp3
-rw-r--r--src/compat/memory.hpp27
-rw-r--r--src/compat/nullpo.cpp (renamed from src/common/nullpo.cpp)0
-rw-r--r--src/compat/nullpo.hpp (renamed from src/common/nullpo.hpp)6
-rw-r--r--src/compat/rawmem.cpp3
-rw-r--r--src/compat/rawmem.hpp30
-rw-r--r--src/conf/version.hpp6
-rw-r--r--src/generic/const_array.cpp3
-rw-r--r--src/generic/const_array.hpp (renamed from src/common/const_array.hpp)6
-rw-r--r--src/generic/db.cpp (renamed from src/common/db.cpp)0
-rw-r--r--src/generic/db.hpp (renamed from src/common/db.hpp)6
-rw-r--r--src/generic/enum.cpp3
-rw-r--r--src/generic/enum.hpp (renamed from src/common/utils2.hpp)96
-rw-r--r--src/generic/intern-pool.cpp3
-rw-r--r--src/generic/intern-pool.hpp (renamed from src/common/intern-pool.hpp)6
-rw-r--r--src/generic/intern-pool_test.cpp (renamed from src/common/intern-pool_test.cpp)0
-rw-r--r--src/generic/matrix.cpp3
-rw-r--r--src/generic/matrix.hpp (renamed from src/common/matrix.hpp)12
-rw-r--r--src/generic/md5.cpp (renamed from src/common/md5calc.cpp)128
-rw-r--r--src/generic/md5.hpp (renamed from src/common/md5calc.hpp)28
-rw-r--r--src/generic/md5_test.cpp (renamed from src/common/md5calc_test.cpp)4
-rw-r--r--src/generic/operators.cpp3
-rw-r--r--src/generic/operators.hpp (renamed from src/common/operators.hpp)6
-rw-r--r--src/generic/random.cpp (renamed from src/common/random.cpp)0
-rw-r--r--src/generic/random.hpp (renamed from src/common/random.hpp)6
-rw-r--r--src/generic/random.t.hpp (renamed from src/common/random.t.hpp)6
-rw-r--r--src/generic/random2.hpp (renamed from src/common/random2.hpp)9
-rw-r--r--src/io/cxxstdio.cpp2
-rw-r--r--src/io/cxxstdio.hpp61
-rw-r--r--src/io/fd.cpp1
-rw-r--r--src/io/fd.hpp2
-rw-r--r--src/io/fwd.hpp2
-rw-r--r--src/io/line.hpp2
-rw-r--r--src/io/read.hpp2
-rw-r--r--src/io/tty.cpp2
-rw-r--r--src/io/tty.hpp2
-rw-r--r--src/io/write.hpp2
-rw-r--r--src/login/GNUmakefile7
-rw-r--r--src/login/login.cpp25
-rw-r--r--src/login/main.cpp2
-rw-r--r--src/map/GNUmakefile7
-rw-r--r--src/map/atcommand.cpp24
-rw-r--r--src/map/atcommand.hpp8
-rw-r--r--src/map/battle.cpp9
-rw-r--r--src/map/battle.hpp8
-rw-r--r--src/map/battle.t.hpp8
-rw-r--r--src/map/chrif.cpp10
-rw-r--r--src/map/chrif.hpp12
-rw-r--r--src/map/clif.cpp17
-rw-r--r--src/map/clif.hpp13
-rw-r--r--src/map/clif.t.hpp6
-rw-r--r--src/map/grfio.cpp2
-rw-r--r--src/map/grfio.hpp8
-rw-r--r--src/map/intif.cpp5
-rw-r--r--src/map/intif.hpp8
-rw-r--r--src/map/itemdb.cpp14
-rw-r--r--src/map/itemdb.hpp8
-rw-r--r--src/map/magic-expr-eval.hpp8
-rw-r--r--src/map/magic-expr.cpp6
-rw-r--r--src/map/magic-expr.hpp6
-rw-r--r--src/map/magic-interpreter-aux.hpp6
-rw-r--r--src/map/magic-interpreter-base.cpp2
-rw-r--r--src/map/magic-interpreter-parser.ypp4
-rw-r--r--src/map/magic-interpreter.hpp6
-rw-r--r--src/map/magic-interpreter.t.hpp8
-rw-r--r--src/map/magic-stmt.cpp8
-rw-r--r--src/map/magic.hpp8
-rw-r--r--src/map/main.cpp2
-rw-r--r--src/map/map.cpp21
-rw-r--r--src/map/map.hpp15
-rw-r--r--src/map/map.t.hpp9
-rw-r--r--src/map/mapflag.hpp2
-rw-r--r--src/map/mob.cpp15
-rw-r--r--src/map/mob.hpp13
-rw-r--r--src/map/mob.t.hpp6
-rw-r--r--src/map/npc.cpp15
-rw-r--r--src/map/npc.hpp8
-rw-r--r--src/map/party.cpp10
-rw-r--r--src/map/party.hpp6
-rw-r--r--src/map/path.cpp7
-rw-r--r--src/map/path.hpp6
-rw-r--r--src/map/pc.cpp12
-rw-r--r--src/map/pc.hpp6
-rw-r--r--src/map/pc.t.hpp6
-rw-r--r--src/map/script.cpp21
-rw-r--r--src/map/script.hpp13
-rw-r--r--src/map/script.py3
-rw-r--r--src/map/skill.cpp14
-rw-r--r--src/map/skill.hpp6
-rw-r--r--src/map/skill.t.hpp8
-rw-r--r--src/map/storage.cpp8
-rw-r--r--src/map/storage.hpp8
-rw-r--r--src/map/tmw.cpp4
-rw-r--r--src/map/tmw.hpp11
-rw-r--r--src/map/trade.cpp4
-rw-r--r--src/map/trade.hpp6
-rw-r--r--src/mmo/config_parse.cpp (renamed from src/common/config_parse.cpp)0
-rw-r--r--src/mmo/config_parse.hpp (renamed from src/common/config_parse.hpp)6
-rw-r--r--src/mmo/core.cpp (renamed from src/common/core.cpp)3
-rw-r--r--src/mmo/core.hpp (renamed from src/common/core.hpp)6
-rw-r--r--src/mmo/dumb_ptr.cpp3
-rw-r--r--src/mmo/dumb_ptr.hpp (renamed from src/common/dumb_ptr.hpp)8
-rw-r--r--src/mmo/extract.cpp (renamed from src/common/extract.cpp)0
-rw-r--r--src/mmo/extract.hpp (renamed from src/common/extract.hpp)9
-rw-r--r--src/mmo/extract_test.cpp (renamed from src/common/extract_test.cpp)0
-rw-r--r--src/mmo/human_time_diff.cpp3
-rw-r--r--src/mmo/human_time_diff.hpp (renamed from src/common/human_time_diff.hpp)6
-rw-r--r--src/mmo/human_time_diff_test.cpp (renamed from src/common/human_time_diff_test.cpp)0
-rw-r--r--src/mmo/ip.cpp (renamed from src/common/ip.cpp)0
-rw-r--r--src/mmo/ip.hpp (renamed from src/common/ip.hpp)6
-rw-r--r--src/mmo/ip.py (renamed from src/common/ip.py)0
-rw-r--r--src/mmo/ip_test.cpp (renamed from src/common/ip_test.cpp)0
-rw-r--r--src/mmo/md5more.cpp128
-rw-r--r--src/mmo/md5more.hpp26
-rw-r--r--src/mmo/mmo.cpp3
-rw-r--r--src/mmo/mmo.hpp (renamed from src/common/mmo.hpp)21
-rw-r--r--src/mmo/socket.cpp (renamed from src/common/socket.cpp)0
-rw-r--r--src/mmo/socket.hpp (renamed from src/common/socket.hpp)8
-rw-r--r--src/mmo/timer.cpp (renamed from src/common/timer.cpp)0
-rw-r--r--src/mmo/timer.hpp (renamed from src/common/timer.hpp)6
-rw-r--r--src/mmo/timer.t.hpp (renamed from src/common/timer.t.hpp)6
-rw-r--r--src/mmo/utils.cpp (renamed from src/common/utils.cpp)0
-rw-r--r--src/mmo/utils.hpp (renamed from src/common/utils.hpp)36
-rw-r--r--src/mmo/version.cpp (renamed from src/common/version.cpp)2
-rw-r--r--src/mmo/version.hpp (renamed from src/common/version.hpp)6
-rw-r--r--src/monitor/GNUmakefile7
-rw-r--r--src/monitor/main.cpp4
-rw-r--r--src/sanity.hpp5
-rw-r--r--src/strings/astring.cpp2
-rw-r--r--src/strings/base.hpp2
-rw-r--r--src/strings/fwd.hpp2
-rw-r--r--src/strings/mstring.cpp2
-rw-r--r--src/strings/rstring.cpp2
-rw-r--r--src/strings/sstring.cpp2
-rw-r--r--src/strings/tstring.cpp2
-rw-r--r--src/strings/vstring.cpp2
-rw-r--r--src/strings/vstring.hpp8
-rw-r--r--src/strings/vstring.tcc2
-rw-r--r--src/strings/xstring.cpp2
-rw-r--r--src/strings/zstring.cpp2
163 files changed, 870 insertions, 714 deletions
diff --git a/src/admin/GNUmakefile b/src/admin/GNUmakefile
deleted file mode 100644
index a34b76b..0000000
--- a/src/admin/GNUmakefile
+++ /dev/null
@@ -1,7 +0,0 @@
-.SUFFIXES:
-bin/tmwa-admin:
- ${MAKE} -C ../.. bin/tmwa-admin
-clean:
- rm -r ../../obj/admin/
-%::
- ${MAKE} -C ../.. obj/admin/$@
diff --git a/src/admin/ladmin.cpp b/src/admin/ladmin.cpp
index 38f0c4b..f889b19 100644
--- a/src/admin/ladmin.cpp
+++ b/src/admin/ladmin.cpp
@@ -11,19 +11,20 @@
#include "../strings/xstring.hpp"
#include "../strings/vstring.hpp"
+#include "../generic/md5.hpp"
+
#include "../io/cxxstdio.hpp"
#include "../io/read.hpp"
#include "../io/tty.hpp"
#include "../io/write.hpp"
-#include "../common/config_parse.hpp"
-#include "../common/core.hpp"
-#include "../common/human_time_diff.hpp"
-#include "../common/md5calc.hpp"
-#include "../common/mmo.hpp"
-#include "../common/socket.hpp"
-#include "../common/utils.hpp"
-#include "../common/version.hpp"
+#include "../mmo/config_parse.hpp"
+#include "../mmo/core.hpp"
+#include "../mmo/human_time_diff.hpp"
+#include "../mmo/mmo.hpp"
+#include "../mmo/socket.hpp"
+#include "../mmo/utils.hpp"
+#include "../mmo/version.hpp"
#include "../poison.hpp"
diff --git a/src/admin/main.cpp b/src/admin/main.cpp
index 2900720..bed1539 100644
--- a/src/admin/main.cpp
+++ b/src/admin/main.cpp
@@ -1,2 +1,4 @@
// dummy file to make Make dependencies work
#include "ladmin.hpp"
+
+#include "../poison.hpp"
diff --git a/src/char/GNUmakefile b/src/char/GNUmakefile
deleted file mode 100644
index 48b4c0a..0000000
--- a/src/char/GNUmakefile
+++ /dev/null
@@ -1,7 +0,0 @@
-.SUFFIXES:
-bin/tmwa-char:
- ${MAKE} -C ../.. bin/tmwa-char
-clean:
- rm -r ../../obj/char/
-%::
- ${MAKE} -C ../.. obj/char/$@
diff --git a/src/char/char.cpp b/src/char/char.cpp
index f6fd492..b74df46 100644
--- a/src/char/char.cpp
+++ b/src/char/char.cpp
@@ -17,24 +17,27 @@
#include <bitset>
#include <set>
+#include "../compat/alg.hpp"
+
#include "../strings/mstring.hpp"
#include "../strings/astring.hpp"
#include "../strings/zstring.hpp"
#include "../strings/xstring.hpp"
+#include "../generic/db.hpp"
+
#include "../io/cxxstdio.hpp"
#include "../io/lock.hpp"
#include "../io/read.hpp"
#include "../io/tty.hpp"
-#include "../common/config_parse.hpp"
-#include "../common/core.hpp"
-#include "../common/db.hpp"
-#include "../common/extract.hpp"
-#include "../common/human_time_diff.hpp"
-#include "../common/socket.hpp"
-#include "../common/timer.hpp"
-#include "../common/version.hpp"
+#include "../mmo/config_parse.hpp"
+#include "../mmo/core.hpp"
+#include "../mmo/extract.hpp"
+#include "../mmo/human_time_diff.hpp"
+#include "../mmo/socket.hpp"
+#include "../mmo/timer.hpp"
+#include "../mmo/version.hpp"
#include "inter.hpp"
#include "int_party.hpp"
diff --git a/src/char/char.hpp b/src/char/char.hpp
index 57cacee..6c47c1a 100644
--- a/src/char/char.hpp
+++ b/src/char/char.hpp
@@ -1,11 +1,12 @@
-#ifndef CHAR_HPP
-#define CHAR_HPP
+#ifndef TMWA_CHAR_CHAR_HPP
+#define TMWA_CHAR_CHAR_HPP
# include "../strings/fwd.hpp"
-# include "../common/const_array.hpp"
-# include "../common/ip.hpp"
-# include "../common/mmo.hpp"
+# include "../generic/const_array.hpp"
+
+# include "../mmo/ip.hpp"
+# include "../mmo/mmo.hpp"
class Session;
@@ -32,4 +33,4 @@ void char_log(XString line);
# define CHAR_LOG(fmt, ...) \
char_log(STRPRINTF(fmt, ## __VA_ARGS__))
-#endif // CHAR_HPP
+#endif // TMWA_CHAR_CHAR_HPP
diff --git a/src/char/int_party.cpp b/src/char/int_party.cpp
index 85af96c..c0bedde 100644
--- a/src/char/int_party.cpp
+++ b/src/char/int_party.cpp
@@ -7,14 +7,15 @@
#include "../strings/astring.hpp"
#include "../strings/xstring.hpp"
+#include "../generic/db.hpp"
+
#include "../io/cxxstdio.hpp"
#include "../io/lock.hpp"
#include "../io/read.hpp"
-#include "../common/db.hpp"
-#include "../common/extract.hpp"
-#include "../common/mmo.hpp"
-#include "../common/socket.hpp"
+#include "../mmo/extract.hpp"
+#include "../mmo/mmo.hpp"
+#include "../mmo/socket.hpp"
#include "char.hpp"
#include "inter.hpp"
diff --git a/src/char/int_party.hpp b/src/char/int_party.hpp
index e4dedd1..73020a9 100644
--- a/src/char/int_party.hpp
+++ b/src/char/int_party.hpp
@@ -1,5 +1,5 @@
-#ifndef INT_PARTY_HPP
-#define INT_PARTY_HPP
+#ifndef TMWA_CHAR_INT_PARTY_HPP
+#define TMWA_CHAR_INT_PARTY_HPP
# include "../strings/fwd.hpp"
@@ -14,4 +14,4 @@ void inter_party_leave(int party_id, int account_id);
extern AString party_txt;
-#endif // INT_PARTY_HPP
+#endif // TMWA_CHAR_INT_PARTY_HPP
diff --git a/src/char/int_storage.cpp b/src/char/int_storage.cpp
index 91151ec..0794c8f 100644
--- a/src/char/int_storage.cpp
+++ b/src/char/int_storage.cpp
@@ -9,14 +9,15 @@
#include "../strings/astring.hpp"
#include "../strings/xstring.hpp"
+#include "../generic/db.hpp"
+
#include "../io/cxxstdio.hpp"
#include "../io/lock.hpp"
#include "../io/read.hpp"
-#include "../common/db.hpp"
-#include "../common/extract.hpp"
-#include "../common/mmo.hpp"
-#include "../common/socket.hpp"
+#include "../mmo/extract.hpp"
+#include "../mmo/mmo.hpp"
+#include "../mmo/socket.hpp"
#include "../poison.hpp"
diff --git a/src/char/int_storage.hpp b/src/char/int_storage.hpp
index 7081f30..356d924 100644
--- a/src/char/int_storage.hpp
+++ b/src/char/int_storage.hpp
@@ -1,5 +1,5 @@
-#ifndef INT_STORAGE_HPP
-#define INT_STORAGE_HPP
+#ifndef TMWA_CHAR_INT_STORAGE_HPP
+#define TMWA_CHAR_INT_STORAGE_HPP
# include "../strings/fwd.hpp"
@@ -14,4 +14,4 @@ int inter_storage_parse_frommap(Session *ms);
extern AString storage_txt;
-#endif // INT_STORAGE_HPP
+#endif // TMWA_CHAR_INT_STORAGE_HPP
diff --git a/src/char/inter.cpp b/src/char/inter.cpp
index 4fea6be..c287844 100644
--- a/src/char/inter.cpp
+++ b/src/char/inter.cpp
@@ -11,16 +11,17 @@
#include "../strings/zstring.hpp"
#include "../strings/xstring.hpp"
+#include "../generic/db.hpp"
+
#include "../io/cxxstdio.hpp"
#include "../io/lock.hpp"
#include "../io/read.hpp"
-#include "../common/config_parse.hpp"
-#include "../common/db.hpp"
-#include "../common/extract.hpp"
-#include "../common/socket.hpp"
-#include "../common/timer.hpp"
-#include "../common/utils.hpp"
+#include "../mmo/config_parse.hpp"
+#include "../mmo/extract.hpp"
+#include "../mmo/socket.hpp"
+#include "../mmo/timer.hpp"
+#include "../mmo/utils.hpp"
#include "char.hpp"
#include "int_party.hpp"
diff --git a/src/char/inter.hpp b/src/char/inter.hpp
index b566575..6dd907d 100644
--- a/src/char/inter.hpp
+++ b/src/char/inter.hpp
@@ -1,5 +1,5 @@
-#ifndef INTER_HPP
-#define INTER_HPP
+#ifndef TMWA_CHAR_INTER_HPP
+#define TMWA_CHAR_INTER_HPP
# include "../strings/fwd.hpp"
@@ -14,4 +14,4 @@ int inter_check_length(Session *ms, int length);
extern int party_share_level;
-#endif // INTER_HPP
+#endif // TMWA_CHAR_INTER_HPP
diff --git a/src/char/main.cpp b/src/char/main.cpp
index 9f68e0f..de51ae3 100644
--- a/src/char/main.cpp
+++ b/src/char/main.cpp
@@ -1,2 +1,4 @@
// dummy file to make Make dependencies work
#include "char.hpp"
+
+#include "../poison.hpp"
diff --git a/src/common/GNUmakefile b/src/common/GNUmakefile
deleted file mode 100644
index 917ce0e..0000000
--- a/src/common/GNUmakefile
+++ /dev/null
@@ -1,7 +0,0 @@
-.SUFFIXES:
-common:
- ${MAKE} -C ../.. common
-clean:
- rm -r ../../obj/common/
-%::
- ${MAKE} -C ../.. obj/common/$@
diff --git a/src/compat/alg.cpp b/src/compat/alg.cpp
new file mode 100644
index 0000000..7800e79
--- /dev/null
+++ b/src/compat/alg.cpp
@@ -0,0 +1,3 @@
+#include "alg.hpp"
+
+#include "../poison.hpp"
diff --git a/src/compat/alg.hpp b/src/compat/alg.hpp
new file mode 100644
index 0000000..250c161
--- /dev/null
+++ b/src/compat/alg.hpp
@@ -0,0 +1,21 @@
+#ifndef TMWA_COMPAT_ALG_HPP
+#define TMWA_COMPAT_ALG_HPP
+
+# include "../sanity.hpp"
+
+# include <type_traits>
+
+
+template<class A, class B>
+typename std::common_type<A, B>::type min(A a, B b)
+{
+ return a < b ? a : b;
+}
+
+template<class A, class B>
+typename std::common_type<A, B>::type max(A a, B b)
+{
+ return b < a ? a : b;
+}
+
+#endif // TMWA_COMPAT_ALG_HPP
diff --git a/src/compat/attr.hpp b/src/compat/attr.hpp
new file mode 100644
index 0000000..ca9a7a2
--- /dev/null
+++ b/src/compat/attr.hpp
@@ -0,0 +1,13 @@
+#ifndef TMWA_COMPAT_ATTR_HPP
+#define TMWA_COMPAT_ATTR_HPP
+
+# include "../sanity.hpp"
+
+
+# ifdef __clang__
+# define FALLTHROUGH [[clang::fallthrough]]
+# else
+# define FALLTHROUGH /* fallthrough */
+# endif
+
+#endif // TMWA_COMPAT_ATTR_HPP
diff --git a/src/compat/cast.cpp b/src/compat/cast.cpp
new file mode 100644
index 0000000..015fd27
--- /dev/null
+++ b/src/compat/cast.cpp
@@ -0,0 +1,3 @@
+#include "cast.hpp"
+
+#include "../poison.hpp"
diff --git a/src/compat/cast.hpp b/src/compat/cast.hpp
new file mode 100644
index 0000000..c1b9bab
--- /dev/null
+++ b/src/compat/cast.hpp
@@ -0,0 +1,54 @@
+#ifndef TMWA_COMPAT_CAST_HPP
+#define TMWA_COMPAT_CAST_HPP
+
+# include "../sanity.hpp"
+
+# include <utility>
+# include <type_traits>
+
+
+template<class T>
+const T& const_(T& t)
+{
+ return t;
+}
+
+template<class T, class U>
+T no_cast(U&& u)
+{
+ typedef typename std::remove_reference<T>::type Ti;
+ typedef typename std::remove_reference<U>::type Ui;
+ typedef typename std::remove_cv<Ti>::type Tb;
+ typedef typename std::remove_cv<Ui>::type Ub;
+ static_assert(std::is_same<Tb, Ub>::value, "not no cast");
+ return std::forward<U>(u);
+}
+
+template<class T, class U>
+T base_cast(U&& u)
+{
+ static_assert(std::is_reference<T>::value, "must base cast with references");
+ typedef typename std::remove_reference<T>::type Ti;
+ typedef typename std::remove_reference<U>::type Ui;
+ typedef typename std::remove_cv<Ti>::type Tb;
+ typedef typename std::remove_cv<Ui>::type Ub;
+ static_assert(std::is_base_of<Tb, Ub>::value, "not base cast");
+ return std::forward<U>(u);
+}
+
+// use this when e.g. U is an int of unknown size
+template<class T, class U>
+T maybe_cast(U u)
+{
+ return u;
+}
+
+template<class T, class U>
+typename std::remove_pointer<T>::type *sign_cast(U *u)
+{
+ typedef typename std::remove_pointer<T>::type T_;
+ static_assert(sizeof(T_) == sizeof(U), "sign cast must be same size");
+ return reinterpret_cast<T_ *>(u);
+}
+
+#endif // TMWA_COMPAT_CAST_HPP
diff --git a/src/compat/fun.hpp b/src/compat/fun.hpp
new file mode 100644
index 0000000..536a113
--- /dev/null
+++ b/src/compat/fun.hpp
@@ -0,0 +1,11 @@
+#ifndef TMWA_COMPAT_FUN_HPP
+#define TMWA_COMPAT_FUN_HPP
+
+# include "../sanity.hpp"
+
+# include <functional>
+
+
+namespace ph = std::placeholders;
+
+#endif // TMWA_COMPAT_FUN_HPP
diff --git a/src/compat/iter.cpp b/src/compat/iter.cpp
new file mode 100644
index 0000000..2b1fb0c
--- /dev/null
+++ b/src/compat/iter.cpp
@@ -0,0 +1,3 @@
+#include "iter.hpp"
+
+#include "../poison.hpp"
diff --git a/src/common/iter.hpp b/src/compat/iter.hpp
index 5b39588..7793d90 100644
--- a/src/common/iter.hpp
+++ b/src/compat/iter.hpp
@@ -1,5 +1,5 @@
-#ifndef TMWA_COMMON_ITER_HPP
-#define TMWA_COMMON_ITER_HPP
+#ifndef TMWA_COMPAT_ITER_HPP
+#define TMWA_COMPAT_ITER_HPP
// iter.hpp - tools for dealing with iterators
//
// Copyright © 2012-2014 Ben Longbons <b.r.longbons@gmail.com>
@@ -94,4 +94,4 @@ IteratorPair<ValueIterator<T>> value_range(T b, T e)
return {b, e};
}
-#endif // TMWA_COMMON_ITER_HPP
+#endif // TMWA_COMPAT_ITER_HPP
diff --git a/src/common/iter_test.cpp b/src/compat/iter_test.cpp
index 647ebf9..647ebf9 100644
--- a/src/common/iter_test.cpp
+++ b/src/compat/iter_test.cpp
diff --git a/src/compat/memory.cpp b/src/compat/memory.cpp
new file mode 100644
index 0000000..6a5f526
--- /dev/null
+++ b/src/compat/memory.cpp
@@ -0,0 +1,3 @@
+#include "memory.hpp"
+
+#include "../poison.hpp"
diff --git a/src/compat/memory.hpp b/src/compat/memory.hpp
new file mode 100644
index 0000000..2839640
--- /dev/null
+++ b/src/compat/memory.hpp
@@ -0,0 +1,27 @@
+#ifndef TMWA_COMPAT_MEMORY_HPP
+#define TMWA_COMPAT_MEMORY_HPP
+
+# include "../sanity.hpp"
+
+# include <memory>
+
+
+template<class T>
+struct is_array_of_unknown_bound
+: std::is_same<T, typename std::remove_extent<T>::type[]>
+{};
+
+template<class T, class D=std::default_delete<T>, class... A>
+typename std::enable_if<!is_array_of_unknown_bound<T>::value, std::unique_ptr<T, D>>::type make_unique(A&&... a)
+{
+ return std::unique_ptr<T, D>(new T(std::forward<A>(a)...));
+}
+
+template<class T, class D=std::default_delete<T>>
+typename std::enable_if<is_array_of_unknown_bound<T>::value, std::unique_ptr<T, D>>::type make_unique(size_t sz)
+{
+ typedef typename std::remove_extent<T>::type E;
+ return std::unique_ptr<E[], D>(new E[sz]());
+}
+
+#endif // TMWA_COMPAT_MEMORY_HPP
diff --git a/src/common/nullpo.cpp b/src/compat/nullpo.cpp
index 423ed8c..423ed8c 100644
--- a/src/common/nullpo.cpp
+++ b/src/compat/nullpo.cpp
diff --git a/src/common/nullpo.hpp b/src/compat/nullpo.hpp
index 0eaa1b2..6eca4b6 100644
--- a/src/common/nullpo.hpp
+++ b/src/compat/nullpo.hpp
@@ -1,6 +1,6 @@
/// return wrappers for unexpected NULL pointers
-#ifndef NULLPO_HPP
-#define NULLPO_HPP
+#ifndef TMWA_COMPAT_NULLPO_HPP
+#define TMWA_COMPAT_NULLPO_HPP
/// Uncomment this to live dangerously
/// (really exist to detect mostly-unused variables)
//# define BUG_FREE
@@ -38,4 +38,4 @@ bool nullpo_chk(const char *file, int line, const char *func, T *target)
return nullpo_chk(file, line, func, static_cast<const void *>(target));
}
-#endif // NULLPO_HPP
+#endif // TMWA_COMPAT_NULLPO_HPP
diff --git a/src/compat/rawmem.cpp b/src/compat/rawmem.cpp
new file mode 100644
index 0000000..9e353e8
--- /dev/null
+++ b/src/compat/rawmem.cpp
@@ -0,0 +1,3 @@
+#include "rawmem.hpp"
+
+#include "../poison.hpp"
diff --git a/src/compat/rawmem.hpp b/src/compat/rawmem.hpp
new file mode 100644
index 0000000..ac08964
--- /dev/null
+++ b/src/compat/rawmem.hpp
@@ -0,0 +1,30 @@
+#ifndef TMWA_COMPAT_RAWMEM_HPP
+#define TMWA_COMPAT_RAWMEM_HPP
+
+# include <cstddef>
+# include <cstdint>
+# include <cstring>
+
+inline
+void really_memcpy(uint8_t *dest, const uint8_t *src, size_t n)
+{
+ memcpy(dest, src, n);
+}
+
+inline
+void really_memmove(uint8_t *dest, const uint8_t *src, size_t n)
+{
+ memmove(dest, src, n);
+}
+inline
+bool really_memequal(const uint8_t *a, const uint8_t *b, size_t n)
+{
+ return memcmp(a, b, n) == 0;
+}
+
+inline
+void really_memset0(uint8_t *dest, size_t n)
+{
+ memset(dest, '\0', n);
+}
+#endif // TMWA_COMPAT_RAWMEM_HPP
diff --git a/src/conf/version.hpp b/src/conf/version.hpp
index a4ee931..ab7a3d5 100644
--- a/src/conf/version.hpp
+++ b/src/conf/version.hpp
@@ -1,5 +1,5 @@
-#ifndef CONF_VERSION_HPP
-#define CONF_VERSION_HPP
+#ifndef TMWA_CONF_VERSION_HPP
+#define TMWA_CONF_VERSION_HPP
# include "conf-raw/str-VERSION_FULL.h"
# include "conf-raw/str-VERSION_HASH.h"
@@ -12,4 +12,4 @@
# include "conf-raw/str-VENDOR.h"
# include "conf-raw/int-VENDOR_VERSION.h"
-#endif
+#endif // TMWA_CONF_VERSION_HPP
diff --git a/src/generic/const_array.cpp b/src/generic/const_array.cpp
new file mode 100644
index 0000000..0c09333
--- /dev/null
+++ b/src/generic/const_array.cpp
@@ -0,0 +1,3 @@
+#include "const_array.hpp"
+
+#include "../poison.hpp"
diff --git a/src/common/const_array.hpp b/src/generic/const_array.hpp
index fe15728..1c70f5d 100644
--- a/src/common/const_array.hpp
+++ b/src/generic/const_array.hpp
@@ -1,5 +1,5 @@
-#ifndef CONST_ARRAY_HPP
-#define CONST_ARRAY_HPP
+#ifndef TMWA_GENERIC_CONST_ARRAY_HPP
+#define TMWA_GENERIC_CONST_ARRAY_HPP
// const_array.hpp - just a pointer-to-const and a length
//
// Copyright © 2011-2012 Ben Longbons <b.r.longbons@gmail.com>
@@ -129,4 +129,4 @@ public:
# undef constexpr
# endif
-#endif // CONST_ARRAY_HPP
+#endif // TMWA_GENERIC_CONST_ARRAY_HPP
diff --git a/src/common/db.cpp b/src/generic/db.cpp
index cc58ad8..cc58ad8 100644
--- a/src/common/db.cpp
+++ b/src/generic/db.cpp
diff --git a/src/common/db.hpp b/src/generic/db.hpp
index 0384f1c..314c449 100644
--- a/src/common/db.hpp
+++ b/src/generic/db.hpp
@@ -1,5 +1,5 @@
-#ifndef DB_HPP
-#define DB_HPP
+#ifndef TMWA_GENERIC_DB_HPP
+#define TMWA_GENERIC_DB_HPP
// db.hpp - convenience wrappers over std::map<K, V>
//
// Copyright © 2013 Ben Longbons <b.r.longbons@gmail.com>
@@ -177,4 +177,4 @@ public:
}
};
-#endif // DB_HPP
+#endif // TMWA_GENERIC_DB_HPP
diff --git a/src/generic/enum.cpp b/src/generic/enum.cpp
new file mode 100644
index 0000000..c5ab250
--- /dev/null
+++ b/src/generic/enum.cpp
@@ -0,0 +1,3 @@
+#include "enum.hpp"
+
+#include "../poison.hpp"
diff --git a/src/common/utils2.hpp b/src/generic/enum.hpp
index 9af39e5..6f29981 100644
--- a/src/common/utils2.hpp
+++ b/src/generic/enum.hpp
@@ -1,21 +1,11 @@
-#ifndef UTILS2_HPP
-#define UTILS2_HPP
+#ifndef TMWA_GENERIC_ENUM_HPP
+#define TMWA_GENERIC_ENUM_HPP
# include "../sanity.hpp"
-# include <algorithm>
-# include <functional>
-# include <iterator>
-# include <memory>
# include <type_traits>
-# include "iter.hpp"
-
-# ifdef __clang__
-# define FALLTHROUGH [[clang::fallthrough]]
-# else
-# define FALLTHROUGH /* fallthrough */
-# endif
+# include "../compat/iter.hpp"
template<class T, class E, E max>
struct earray
@@ -69,7 +59,7 @@ class eptr
{
T *_data;
public:
- eptr(decltype(nullptr)=nullptr)
+ eptr(std::nullptr_t=nullptr)
: _data(nullptr)
{}
@@ -177,80 +167,4 @@ IteratorPair<ValueIterator<E, EnumMath<E>>> erange(E b, E e)
return {b, e};
}
-namespace ph = std::placeholders;
-
-template<class A, class B>
-typename std::common_type<A, B>::type min(A a, B b)
-{
- return a < b ? a : b;
-}
-
-template<class A, class B>
-typename std::common_type<A, B>::type max(A a, B b)
-{
- return b < a ? a : b;
-}
-
-template<class T>
-struct is_array_of_unknown_bound
-: std::is_same<T, typename std::remove_extent<T>::type[]>
-{};
-
-template<class T, class D=std::default_delete<T>, class... A>
-typename std::enable_if<!is_array_of_unknown_bound<T>::value, std::unique_ptr<T, D>>::type make_unique(A&&... a)
-{
- return std::unique_ptr<T, D>(new T(std::forward<A>(a)...));
-}
-
-template<class T, class D=std::default_delete<T>>
-typename std::enable_if<is_array_of_unknown_bound<T>::value, std::unique_ptr<T, D>>::type make_unique(size_t sz)
-{
- typedef typename std::remove_extent<T>::type E;
- return std::unique_ptr<E[], D>(new E[sz]());
-}
-
-template<class T>
-const T& const_(T& t)
-{
- return t;
-}
-
-template<class T, class U>
-T no_cast(U&& u)
-{
- typedef typename std::remove_reference<T>::type Ti;
- typedef typename std::remove_reference<U>::type Ui;
- typedef typename std::remove_cv<Ti>::type Tb;
- typedef typename std::remove_cv<Ui>::type Ub;
- static_assert(std::is_same<Tb, Ub>::value, "not no cast");
- return std::forward<U>(u);
-}
-
-template<class T, class U>
-T base_cast(U&& u)
-{
- static_assert(std::is_reference<T>::value, "must base cast with references");
- typedef typename std::remove_reference<T>::type Ti;
- typedef typename std::remove_reference<U>::type Ui;
- typedef typename std::remove_cv<Ti>::type Tb;
- typedef typename std::remove_cv<Ui>::type Ub;
- static_assert(std::is_base_of<Tb, Ub>::value, "not base cast");
- return std::forward<U>(u);
-}
-
-// use this when e.g. U is an int of unknown size
-template<class T, class U>
-T maybe_cast(U u)
-{
- return u;
-}
-
-template<class T, class U>
-typename std::remove_pointer<T>::type *sign_cast(U *u)
-{
- typedef typename std::remove_pointer<T>::type T_;
- static_assert(sizeof(T_) == sizeof(U), "sign cast must be same size");
- return reinterpret_cast<T_ *>(u);
-}
-
-#endif // UTILS2_HPP
+#endif // TMWA_GENERIC_ENUM_HPP
diff --git a/src/generic/intern-pool.cpp b/src/generic/intern-pool.cpp
new file mode 100644
index 0000000..33649f2
--- /dev/null
+++ b/src/generic/intern-pool.cpp
@@ -0,0 +1,3 @@
+#include "intern-pool.hpp"
+
+#include "../poison.hpp"
diff --git a/src/common/intern-pool.hpp b/src/generic/intern-pool.hpp
index e75a359..69f20ef 100644
--- a/src/common/intern-pool.hpp
+++ b/src/generic/intern-pool.hpp
@@ -1,5 +1,5 @@
-#ifndef INTERN_POOL_HPP
-#define INTERN_POOL_HPP
+#ifndef TMWA_GENERIC_INTERN_POOL_HPP
+#define TMWA_GENERIC_INTERN_POOL_HPP
# include <cassert>
@@ -38,4 +38,4 @@ public:
}
};
-#endif //INTERN_POOL_HPP
+#endif // TMWA_GENERIC_INTERN_POOL_HPP
diff --git a/src/common/intern-pool_test.cpp b/src/generic/intern-pool_test.cpp
index bf17b67..bf17b67 100644
--- a/src/common/intern-pool_test.cpp
+++ b/src/generic/intern-pool_test.cpp
diff --git a/src/generic/matrix.cpp b/src/generic/matrix.cpp
new file mode 100644
index 0000000..9ee049e
--- /dev/null
+++ b/src/generic/matrix.cpp
@@ -0,0 +1,3 @@
+#include "matrix.hpp"
+
+#include "../poison.hpp"
diff --git a/src/common/matrix.hpp b/src/generic/matrix.hpp
index 8595191..3530ba7 100644
--- a/src/common/matrix.hpp
+++ b/src/generic/matrix.hpp
@@ -1,5 +1,9 @@
-#ifndef TMWA_COMMON_MATRIX_HPP
-#define TMWA_COMMON_MATRIX_HPP
+#ifndef TMWA_GENERIC_MATRIX_HPP
+#define TMWA_GENERIC_MATRIX_HPP
+
+# include "../sanity.hpp"
+
+# include "../compat/memory.hpp"
template<class T>
class Matrix
@@ -13,7 +17,7 @@ public:
, _ys()
{}
Matrix(size_t x, size_t y)
- : _data(new T[x * y]())
+ : _data(make_unique<T[]>(x * y))
, _xs(x)
, _ys(y)
{}
@@ -47,4 +51,4 @@ public:
}
};
-#endif // TMWA_COMMON_MATRIX_HPP
+#endif // TMWA_GENERIC_MATRIX_HPP
diff --git a/src/common/md5calc.cpp b/src/generic/md5.cpp
index d23f8e3..a626dc5 100644
--- a/src/common/md5calc.cpp
+++ b/src/generic/md5.cpp
@@ -1,15 +1,13 @@
-#include "md5calc.hpp"
+#include "md5.hpp"
#include <cstring>
+#include "../compat/rawmem.hpp"
+
#include "../strings/xstring.hpp"
#include "../strings/vstring.hpp"
-#include "../io/cxxstdio.hpp"
-#include "../io/read.hpp"
-
#include "random.hpp"
-#include "utils.hpp"
#include "../poison.hpp"
@@ -121,9 +119,10 @@ void MD5_init(MD5_state* state)
state->val[3] = 0x10325476;
}
+#define X block.data
+
void MD5_do_block(MD5_state* state, MD5_block block)
{
-#define X block.data
#define a state->val[(16 - i) % 4]
#define b state->val[(17 - i) % 4]
#define c state->val[(18 - i) % 4]
@@ -233,120 +232,3 @@ MD5_state MD5_from_string(XString msg)
}
return state;
}
-
-// TODO - refactor MD5 into a stream, and merge the implementations
-// I once implemented an ostream that does it ...
-MD5_state MD5_from_FILE(io::ReadFile& in)
-{
- uint64_t total_len = 0;
-
- uint8_t buf[0x40];
- uint8_t block_len = 0;
-
- MD5_state state;
- MD5_init(&state);
-
- MD5_block block;
-
- while (true)
- {
- size_t rv = in.get(sign_cast<char *>(buf + block_len), 0x40 - block_len);
- if (!rv)
- break;
- total_len += 8 * rv; // in bits
- block_len += rv;
- if (block_len != 0x40)
- continue;
- for (int i = 0; i < 0x10; i++)
- X[i] = buf[4 * i + 0] | buf[4 * i + 1] << 8 | buf[4 * i + 2] << 16 | buf[4 * i + 3] << 24;
- MD5_do_block(&state, block);
- block_len = 0;
- }
- // no more input, just pad and append the length
- buf[block_len] = 0x80;
- really_memset0(buf + block_len + 1, 0x40 - block_len - 1);
- if (block_len < 0x38)
- {
- for (int i = 0; i < 8; i++)
- buf[0x38 + i] = total_len >> i * 8;
- }
- for (int i = 0; i < 0x10; i++)
- X[i] = buf[4 * i + 0] | buf[4 * i + 1] << 8 | buf[4 * i + 2] << 16 | buf[4 * i + 3] << 24;
- MD5_do_block(&state, block);
- if (0x38 <= block_len)
- {
- really_memset0(buf, 0x38);
- for (int i = 0; i < 8; i++)
- buf[0x38 + i] = total_len >> i * 8;
- for (int i = 0; i < 0x10; i++)
- X[i] = buf[4 * i + 0] | buf[4 * i + 1] << 8 | buf[4 * i + 2] << 16 | buf[4 * i + 3] << 24;
- MD5_do_block(&state, block);
- }
- return state;
-}
-
-
-// Hash a password with a salt.
-// Whoever wrote this FAILS programming
-AccountCrypt MD5_saltcrypt(AccountPass key, SaltString salt)
-{
- char cbuf[64] {};
-
- // hash the key then the salt
- // buf ends up as a 64-char NUL-terminated string
- md5_string tbuf, tbuf2;
- MD5_to_str(MD5_from_string(key), tbuf);
- MD5_to_str(MD5_from_string(salt), tbuf2);
- const auto it = std::copy(tbuf.begin(), tbuf.end(), std::begin(cbuf));
- auto it2 = std::copy(tbuf2.begin(), tbuf2.end(), it);
- assert(it2 == std::end(cbuf));
-
- md5_string tbuf3;
- MD5_to_str(MD5_from_string(XString(std::begin(cbuf), it2, nullptr)), tbuf3);
-
- VString<31> obuf;
-
- // This truncates the string, but we have to keep it like that for compatibility
- SNPRINTF(obuf, 32, "!%s$%s", salt, tbuf3);
- return stringish<AccountCrypt>(obuf);
-}
-
-SaltString make_salt(void)
-{
- char salt[5];
- for (int i = 0; i < 5; i++)
- // 126 would probably actually be okay
- salt[i] = random_::in(48, 125);
- return stringish<SaltString>(XString(salt + 0, salt + 5, nullptr));
-}
-
-bool pass_ok(AccountPass password, AccountCrypt crypted)
-{
- // crypted is like !salt$hash
- auto begin = crypted.begin() + 1;
- auto end = std::find(begin, crypted.end(), '$');
- SaltString salt = stringish<SaltString>(crypted.xislice(begin, end));
-
- return crypted == MD5_saltcrypt(password, salt);
-}
-
-// [M|h]ashes up an IP address and a secret key
-// to return a hopefully unique masked IP.
-IP4Address MD5_ip(IP4Address ip)
-{
- static SaltString secret = make_salt();
-
- // MD5sum a secret + the IP address
- VString<31> ipbuf;
- SNPRINTF(ipbuf, 32, "%s %s", ip, secret);
- md5_binary obuf;
- MD5_to_bin(MD5_from_string(ipbuf), obuf);
-
- // Fold the md5sum to 32 bits, pack the bytes to an in_addr
- return IP4Address({
- static_cast<uint8_t>(obuf[0] ^ obuf[1] ^ obuf[8] ^ obuf[9]),
- static_cast<uint8_t>(obuf[2] ^ obuf[3] ^ obuf[10] ^ obuf[11]),
- static_cast<uint8_t>(obuf[4] ^ obuf[5] ^ obuf[12] ^ obuf[13]),
- static_cast<uint8_t>(obuf[6] ^ obuf[7] ^ obuf[14] ^ obuf[15]),
- });
-}
diff --git a/src/common/md5calc.hpp b/src/generic/md5.hpp
index 45bec84..ba1212a 100644
--- a/src/common/md5calc.hpp
+++ b/src/generic/md5.hpp
@@ -1,5 +1,5 @@
-#ifndef MD5CALC_HPP
-#define MD5CALC_HPP
+#ifndef TMWA_GENERIC_MD5CALC_HPP
+#define TMWA_GENERIC_MD5CALC_HPP
# include "../sanity.hpp"
@@ -14,16 +14,11 @@
# include "../strings/fwd.hpp"
# include "../strings/vstring.hpp"
-# include "../io/fwd.hpp"
-
-# include "ip.hpp"
-# include "mmo.hpp"
-
/// The digest state - becomes the output
struct MD5_state
{
// classically named {A,B,C,D}
- // but use an so we can index
+ // but use an array so we can index
uint32_t val[4];
};
struct MD5_block
@@ -45,20 +40,5 @@ void MD5_to_str(MD5_state state, md5_string& out);
// Convenience
MD5_state MD5_from_string(XString msg);
-MD5_state MD5_from_FILE(io::ReadFile& in);
-
-
-// whoever wrote this fails basic understanding of
-AccountCrypt MD5_saltcrypt(AccountPass key, SaltString salt);
-
-/// return some random characters (statically allocated)
-// Currently, returns a 5-char string
-SaltString make_salt(void);
-
-/// check plaintext password against saved saltcrypt
-bool pass_ok(AccountPass password, AccountCrypt crypted);
-
-/// This returns an IP4Address because it is configurable whether it gets called at all
-IP4Address MD5_ip(IP4Address ip);
-#endif // MD5CALC_HPP
+#endif // TMWA_GENERIC_MD5CALC_HPP
diff --git a/src/common/md5calc_test.cpp b/src/generic/md5_test.cpp
index ab5f242..7086c8c 100644
--- a/src/common/md5calc_test.cpp
+++ b/src/generic/md5_test.cpp
@@ -1,12 +1,10 @@
-#include "md5calc.hpp"
+#include "md5.hpp"
#include <gtest/gtest.h>
#include "../strings/xstring.hpp"
#include "../strings/vstring.hpp"
-#include "utils.hpp"
-
// This should be made part of the main API,
// but is not yet to keep the diff small.
// Edit: hack to fix the new strict comparison.
diff --git a/src/generic/operators.cpp b/src/generic/operators.cpp
new file mode 100644
index 0000000..877aec6
--- /dev/null
+++ b/src/generic/operators.cpp
@@ -0,0 +1,3 @@
+#include "operators.hpp"
+
+#include "../poison.hpp"
diff --git a/src/common/operators.hpp b/src/generic/operators.hpp
index 3d44b81..3d3dccd 100644
--- a/src/common/operators.hpp
+++ b/src/generic/operators.hpp
@@ -1,5 +1,5 @@
-#ifndef OPERATORS_HPP
-#define OPERATORS_HPP
+#ifndef TMWA_GENERIC_OPERATORS_HPP
+#define TMWA_GENERIC_OPERATORS_HPP
namespace _operators
{
@@ -44,4 +44,4 @@ namespace _operators
using _operators::Comparable;
-#endif // OPERATORS_HPP
+#endif // TMWA_GENERIC_OPERATORS_HPP
diff --git a/src/common/random.cpp b/src/generic/random.cpp
index 273dcec..273dcec 100644
--- a/src/common/random.cpp
+++ b/src/generic/random.cpp
diff --git a/src/common/random.hpp b/src/generic/random.hpp
index a694cce..5d7a7af 100644
--- a/src/common/random.hpp
+++ b/src/generic/random.hpp
@@ -1,5 +1,5 @@
-#ifndef RANDOM_HPP
-#define RANDOM_HPP
+#ifndef TMWA_GENERIC_RANDOM_HPP
+#define TMWA_GENERIC_RANDOM_HPP
# include "random.t.hpp"
@@ -66,4 +66,4 @@ namespace random_
}
} // namespace random_
-#endif // RANDOM_HPP
+#endif // TMWA_GENERIC_RANDOM_HPP
diff --git a/src/common/random.t.hpp b/src/generic/random.t.hpp
index 98a6c59..feea2b0 100644
--- a/src/common/random.t.hpp
+++ b/src/generic/random.t.hpp
@@ -1,5 +1,5 @@
-#ifndef RANDOM_T_HPP
-#define RANDOM_T_HPP
+#ifndef TMWA_GENERIC_RANDOM_T_HPP
+#define TMWA_GENERIC_RANDOM_T_HPP
namespace random_
{
@@ -20,4 +20,4 @@ namespace random_
};
} // namespace random_
-#endif // RANDOM_T_HPP
+#endif // TMWA_GENERIC_RANDOM_T_HPP
diff --git a/src/common/random2.hpp b/src/generic/random2.hpp
index 86deddf..4bdc72e 100644
--- a/src/common/random2.hpp
+++ b/src/generic/random2.hpp
@@ -1,11 +1,12 @@
-#ifndef RANDOM2_HPP
-#define RANDOM2_HPP
+#ifndef TMWA_GENERIC_RANDOM2_HPP
+#define TMWA_GENERIC_RANDOM2_HPP
# include "random.hpp"
-# include "utils2.hpp"
# include <algorithm>
+# include "../compat/iter.hpp"
+
namespace random_
{
namespace detail
@@ -71,4 +72,4 @@ namespace random_
}
} // namespace random_
-#endif // RANDOM2_HPP
+#endif // TMWA_GENERIC_RANDOM2_HPP
diff --git a/src/io/cxxstdio.cpp b/src/io/cxxstdio.cpp
index 47617cb..aa603e4 100644
--- a/src/io/cxxstdio.cpp
+++ b/src/io/cxxstdio.cpp
@@ -1 +1,3 @@
#include "cxxstdio.hpp"
+
+#include "../poison.hpp"
diff --git a/src/io/cxxstdio.hpp b/src/io/cxxstdio.hpp
index 753a1fc..0324ebc 100644
--- a/src/io/cxxstdio.hpp
+++ b/src/io/cxxstdio.hpp
@@ -24,9 +24,10 @@
# include <cstdarg>
# include <cstdio>
-// TODO get rid of these header order violations
-# include "../common/const_array.hpp"
-# include "../common/utils2.hpp"
+# include "../compat/cast.hpp"
+
+# include "../generic/const_array.hpp"
+# include "../generic/enum.hpp"
# include "fwd.hpp"
@@ -213,27 +214,25 @@ namespace cxxstdio
}
};
-# define XPRINTF(out, fmt, ...) \
- (/*[&]() -> int*/ \
- { \
- struct format_impl \
- { \
- constexpr static \
- const char *print_format() { return fmt; } \
- }; \
- /*return*/ cxxstdio::PrintFormatter<format_impl>::print(out, ## __VA_ARGS__); \
- }/*()*/)
+# define XPRINTF(out, fmt, ...) \
+ ({ \
+ struct format_impl \
+ { \
+ constexpr static \
+ const char *print_format() { return fmt; } \
+ }; \
+ cxxstdio::PrintFormatter<format_impl>::print(out, ## __VA_ARGS__); \
+ })
-# define XSCANF(out, fmt, ...) \
- (/*[&]() -> int*/ \
- { \
- struct format_impl \
- { \
- constexpr static \
- const char *scan_format() { return fmt; } \
- }; \
- /*return*/ cxxstdio::ScanFormatter<format_impl>::scan(out, ## __VA_ARGS__); \
- }/*()*/)
+# define XSCANF(out, fmt, ...) \
+ ({ \
+ struct format_impl \
+ { \
+ constexpr static \
+ const char *scan_format() { return fmt; } \
+ }; \
+ cxxstdio::ScanFormatter<format_impl>::scan(out, ## __VA_ARGS__); \
+ })
# define FPRINTF(file, fmt, ...) XPRINTF(/*no_cast<FILE *>*/(file), fmt, ## __VA_ARGS__)
# define FSCANF(file, fmt, ...) XSCANF(no_cast<FILE *>(file), fmt, ## __VA_ARGS__)
@@ -241,23 +240,21 @@ namespace cxxstdio
# define SPRINTF(str, fmt, ...) XPRINTF(base_cast<AString&>(str), fmt, ## __VA_ARGS__)
# define SNPRINTF(str, n, fmt, ...) XPRINTF(base_cast<VString<n-1>&>(str), fmt, ## __VA_ARGS__)
# define SCANF(fmt, ...) FSCANF(stdin, fmt, ## __VA_ARGS__)
-# define SSCANF(str, fmt, ...) XSCANF(/*ZString or compatible*/str, fmt, ## __VA_ARGS__)
+# define SSCANF(str, fmt, ...) XSCANF(maybe_cast<ZString>(str), fmt, ## __VA_ARGS__)
# define STRPRINTF(fmt, ...) \
- (/*[&]() -> AString*/ \
- { \
+ ({ \
AString _out_impl; \
SPRINTF(_out_impl, fmt, ## __VA_ARGS__); \
- /*return*/ _out_impl; \
- }/*()*/)
+ _out_impl; \
+ })
# define STRNPRINTF(n, fmt, ...) \
- (/*[&]() -> VString<n - 1>*/ \
- { \
+ ({ \
VString<n - 1> _out_impl; \
SNPRINTF(_out_impl, n, fmt, ## __VA_ARGS__); \
- /*return*/ _out_impl; \
- }/*()*/)
+ _out_impl; \
+ })
} // namespace cxxstdio
diff --git a/src/io/fd.cpp b/src/io/fd.cpp
index 87d3967..4fc33e9 100644
--- a/src/io/fd.cpp
+++ b/src/io/fd.cpp
@@ -23,6 +23,7 @@
#include "../strings/zstring.hpp"
+#include "../poison.hpp"
namespace io
{
diff --git a/src/io/fd.hpp b/src/io/fd.hpp
index ca703d6..7afb40f 100644
--- a/src/io/fd.hpp
+++ b/src/io/fd.hpp
@@ -165,4 +165,4 @@ namespace io
};
} // namespace io
-#endif //TMWA_IO_FD_HPP
+#endif // TMWA_IO_FD_HPP
diff --git a/src/io/fwd.hpp b/src/io/fwd.hpp
index 52e6d6d..1e5fa82 100644
--- a/src/io/fwd.hpp
+++ b/src/io/fwd.hpp
@@ -29,4 +29,4 @@ namespace io
class AppendFile;
} // namespace io
-#endif //TMWA_IO_FWD_HPP
+#endif // TMWA_IO_FWD_HPP
diff --git a/src/io/line.hpp b/src/io/line.hpp
index bdff1bb..321cdf7 100644
--- a/src/io/line.hpp
+++ b/src/io/line.hpp
@@ -94,4 +94,4 @@ namespace io
};
} // namespace io
-#endif //TMWA_IO_LINE_HPP
+#endif // TMWA_IO_LINE_HPP
diff --git a/src/io/read.hpp b/src/io/read.hpp
index 2355e46..f99fb56 100644
--- a/src/io/read.hpp
+++ b/src/io/read.hpp
@@ -50,4 +50,4 @@ namespace io
};
} // namespace io
-#endif //TMWA_IO_READ_HPP
+#endif // TMWA_IO_READ_HPP
diff --git a/src/io/tty.cpp b/src/io/tty.cpp
index d2e084e..e71ee44 100644
--- a/src/io/tty.cpp
+++ b/src/io/tty.cpp
@@ -18,4 +18,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
+#include "../poison.hpp"
+
/* Nothing to see here, move along */
diff --git a/src/io/tty.hpp b/src/io/tty.hpp
index 86616f1..97487b8 100644
--- a/src/io/tty.hpp
+++ b/src/io/tty.hpp
@@ -35,4 +35,4 @@
# define SGR_RESET "\e[0m"
-#endif //TMWA_IO_TTY_HPP
+#endif // TMWA_IO_TTY_HPP
diff --git a/src/io/write.hpp b/src/io/write.hpp
index 0a238c0..870ebb5 100644
--- a/src/io/write.hpp
+++ b/src/io/write.hpp
@@ -66,4 +66,4 @@ namespace io
int do_vprint(WriteFile& out, const char *fmt, va_list ap);
} // namespace io
-#endif //TMWA_IO_WRITE_HPP
+#endif // TMWA_IO_WRITE_HPP
diff --git a/src/login/GNUmakefile b/src/login/GNUmakefile
deleted file mode 100644
index eb983e8..0000000
--- a/src/login/GNUmakefile
+++ /dev/null
@@ -1,7 +0,0 @@
-.SUFFIXES:
-bin/tmwa-login:
- ${MAKE} -C ../.. bin/tmwa-login
-clean:
- rm -r ../../obj/login/
-%::
- ${MAKE} -C ../.. obj/login/$@
diff --git a/src/login/login.cpp b/src/login/login.cpp
index b21b028..c9b285f 100644
--- a/src/login/login.cpp
+++ b/src/login/login.cpp
@@ -22,23 +22,24 @@
#include "../strings/xstring.hpp"
#include "../strings/vstring.hpp"
+#include "../generic/db.hpp"
+#include "../generic/random.hpp"
+
#include "../io/cxxstdio.hpp"
#include "../io/lock.hpp"
#include "../io/read.hpp"
#include "../io/tty.hpp"
-#include "../common/config_parse.hpp"
-#include "../common/core.hpp"
-#include "../common/db.hpp"
-#include "../common/extract.hpp"
-#include "../common/human_time_diff.hpp"
-#include "../common/md5calc.hpp"
-#include "../common/mmo.hpp"
-#include "../common/random.hpp"
-#include "../common/socket.hpp"
-#include "../common/timer.hpp"
-#include "../common/version.hpp"
-#include "../common/utils.hpp"
+#include "../mmo/config_parse.hpp"
+#include "../mmo/core.hpp"
+#include "../mmo/extract.hpp"
+#include "../mmo/human_time_diff.hpp"
+#include "../mmo/md5more.hpp"
+#include "../mmo/mmo.hpp"
+#include "../mmo/socket.hpp"
+#include "../mmo/timer.hpp"
+#include "../mmo/version.hpp"
+#include "../mmo/utils.hpp"
#include "../poison.hpp"
diff --git a/src/login/main.cpp b/src/login/main.cpp
index 2ef17a0..470bcd1 100644
--- a/src/login/main.cpp
+++ b/src/login/main.cpp
@@ -1,2 +1,4 @@
// dummy file to make Make dependencies work
#include "login.hpp"
+
+#include "../poison.hpp"
diff --git a/src/map/GNUmakefile b/src/map/GNUmakefile
deleted file mode 100644
index 22f6daa..0000000
--- a/src/map/GNUmakefile
+++ /dev/null
@@ -1,7 +0,0 @@
-.SUFFIXES:
-bin/tmwa-map:
- ${MAKE} -C ../.. bin/tmwa-map
-clean:
- rm -r ../../obj/map/
-%::
- ${MAKE} -C ../.. obj/map/$@
diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp
index 39e81a9..29bf0b1 100644
--- a/src/map/atcommand.cpp
+++ b/src/map/atcommand.cpp
@@ -4,27 +4,29 @@
#include <cstring>
#include <ctime>
+#include "../compat/nullpo.hpp"
+#include "../compat/fun.hpp"
+
#include "../strings/mstring.hpp"
#include "../strings/astring.hpp"
#include "../strings/zstring.hpp"
#include "../strings/xstring.hpp"
#include "../strings/vstring.hpp"
+#include "../generic/random.hpp"
+
#include "../io/cxxstdio.hpp"
#include "../io/read.hpp"
#include "../io/write.hpp"
-#include "../common/config_parse.hpp"
-#include "../common/core.hpp"
-#include "../common/extract.hpp"
-#include "../common/human_time_diff.hpp"
-#include "../common/mmo.hpp"
-#include "../common/nullpo.hpp"
-#include "../common/random.hpp"
-#include "../common/socket.hpp"
-#include "../common/timer.hpp"
-#include "../common/utils2.hpp"
-#include "../common/version.hpp"
+#include "../mmo/config_parse.hpp"
+#include "../mmo/core.hpp"
+#include "../mmo/extract.hpp"
+#include "../mmo/human_time_diff.hpp"
+#include "../mmo/mmo.hpp"
+#include "../mmo/socket.hpp"
+#include "../mmo/timer.hpp"
+#include "../mmo/version.hpp"
#include "battle.hpp"
#include "chrif.hpp"
diff --git a/src/map/atcommand.hpp b/src/map/atcommand.hpp
index c825976..16d1efc 100644
--- a/src/map/atcommand.hpp
+++ b/src/map/atcommand.hpp
@@ -1,9 +1,9 @@
-#ifndef ATCOMMAND_HPP
-#define ATCOMMAND_HPP
+#ifndef TMWA_MAP_ATCOMMAND_HPP
+#define TMWA_MAP_ATCOMMAND_HPP
# include "../strings/fwd.hpp"
-# include "../common/const_array.hpp"
+# include "../generic/const_array.hpp"
# include "map.hpp"
@@ -19,4 +19,4 @@ extern AString gm_log;
void atcommand_config_write(ZString cfgName);
-#endif // ATCOMMAND_HPP
+#endif // TMWA_MAP_ATCOMMAND_HPP
diff --git a/src/map/battle.cpp b/src/map/battle.cpp
index 59e798d..7e563b8 100644
--- a/src/map/battle.cpp
+++ b/src/map/battle.cpp
@@ -2,15 +2,18 @@
#include <cstring>
+#include "../compat/alg.hpp"
+#include "../compat/nullpo.hpp"
+
#include "../strings/astring.hpp"
#include "../strings/zstring.hpp"
+#include "../generic/random.hpp"
+
#include "../io/cxxstdio.hpp"
#include "../io/read.hpp"
-#include "../common/config_parse.hpp"
-#include "../common/nullpo.hpp"
-#include "../common/random.hpp"
+#include "../mmo/config_parse.hpp"
#include "clif.hpp"
#include "itemdb.hpp"
diff --git a/src/map/battle.hpp b/src/map/battle.hpp
index 243d7fb..fd452e8 100644
--- a/src/map/battle.hpp
+++ b/src/map/battle.hpp
@@ -1,11 +1,11 @@
-#ifndef BATTLE_HPP
-#define BATTLE_HPP
+#ifndef TMWA_MAP_BATTLE_HPP
+#define TMWA_MAP_BATTLE_HPP
# include "battle.t.hpp"
# include "../strings/fwd.hpp"
-# include "../common/timer.t.hpp"
+# include "../mmo/timer.t.hpp"
# include "magic-interpreter.t.hpp"
# include "map.t.hpp"
@@ -204,4 +204,4 @@ extern struct Battle_Config
bool battle_config_read(ZString cfgName);
void battle_config_check();
-#endif // BATTLE_HPP
+#endif // TMWA_MAP_BATTLE_HPP
diff --git a/src/map/battle.t.hpp b/src/map/battle.t.hpp
index 1242c85..76ff571 100644
--- a/src/map/battle.t.hpp
+++ b/src/map/battle.t.hpp
@@ -1,7 +1,7 @@
-#ifndef BATTLE_T_HPP
-#define BATTLE_T_HPP
+#ifndef TMWA_MAP_BATTLE_T_HPP
+#define TMWA_MAP_BATTLE_T_HPP
-# include "../common/utils2.hpp"
+# include "../generic/enum.hpp"
namespace e
{
@@ -226,4 +226,4 @@ enum class DamageType : uint8_t
FLEE2 = 0x0b,
};
-#endif // BATTLE_T_HPP
+#endif // TMWA_MAP_BATTLE_T_HPP
diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp
index 48cff81..ea74ca4 100644
--- a/src/map/chrif.cpp
+++ b/src/map/chrif.cpp
@@ -4,15 +4,17 @@
#include <cstring>
+#include "../compat/fun.hpp"
+#include "../compat/nullpo.hpp"
+
#include "../strings/astring.hpp"
#include "../strings/zstring.hpp"
#include "../io/cxxstdio.hpp"
-#include "../common/nullpo.hpp"
-#include "../common/socket.hpp"
-#include "../common/timer.hpp"
-#include "../common/utils.hpp"
+#include "../mmo/socket.hpp"
+#include "../mmo/timer.hpp"
+#include "../mmo/utils.hpp"
#include "battle.hpp"
#include "clif.hpp"
diff --git a/src/map/chrif.hpp b/src/map/chrif.hpp
index 734f1ac..2dfda43 100644
--- a/src/map/chrif.hpp
+++ b/src/map/chrif.hpp
@@ -1,11 +1,11 @@
-#ifndef CHRIF_HPP
-#define CHRIF_HPP
+#ifndef TMWA_MAP_CHRIF_HPP
+#define TMWA_MAP_CHRIF_HPP
# include "../strings/fwd.hpp"
-# include "../common/dumb_ptr.hpp"
-# include "../common/human_time_diff.hpp"
-# include "../common/ip.hpp"
+# include "../mmo/dumb_ptr.hpp"
+# include "../mmo/human_time_diff.hpp"
+# include "../mmo/ip.hpp"
# include "map.hpp"
@@ -39,4 +39,4 @@ void do_init_chrif(void);
// only used by intif.cpp
extern Session *char_session;
-#endif // CHRIF_HPP
+#endif // TMWA_MAP_CHRIF_HPP
diff --git a/src/map/clif.cpp b/src/map/clif.cpp
index 37646bf..3ec41ae 100644
--- a/src/map/clif.cpp
+++ b/src/map/clif.cpp
@@ -6,19 +6,24 @@
#include <cstring>
#include <ctime>
+#include "../compat/alg.hpp"
+#include "../compat/attr.hpp"
+#include "../compat/fun.hpp"
+#include "../compat/nullpo.hpp"
+
#include "../strings/astring.hpp"
#include "../strings/zstring.hpp"
#include "../strings/xstring.hpp"
+#include "../generic/random.hpp"
+
#include "../io/cxxstdio.hpp"
#include "../io/write.hpp"
-#include "../common/md5calc.hpp"
-#include "../common/random.hpp"
-#include "../common/nullpo.hpp"
-#include "../common/socket.hpp"
-#include "../common/timer.hpp"
-#include "../common/version.hpp"
+#include "../mmo/md5more.hpp"
+#include "../mmo/socket.hpp"
+#include "../mmo/timer.hpp"
+#include "../mmo/version.hpp"
#include "atcommand.hpp"
#include "battle.hpp"
diff --git a/src/map/clif.hpp b/src/map/clif.hpp
index e84adf3..c346f7d 100644
--- a/src/map/clif.hpp
+++ b/src/map/clif.hpp
@@ -1,5 +1,5 @@
-#ifndef CLIF_HPP
-#define CLIF_HPP
+#ifndef TMWA_MAP_CLIF_HPP
+#define TMWA_MAP_CLIF_HPP
# include "clif.t.hpp"
@@ -7,9 +7,10 @@
# include "../strings/fwd.hpp"
-# include "../common/const_array.hpp"
-# include "../common/ip.hpp"
-# include "../common/timer.t.hpp"
+# include "../generic/const_array.hpp"
+
+# include "../mmo/ip.hpp"
+# include "../mmo/timer.t.hpp"
# include "battle.t.hpp"
# include "map.hpp"
@@ -163,4 +164,4 @@ int clif_foreachclient(std::function<void(dumb_ptr<map_session_data>)>);
void do_init_clif(void);
-#endif // CLIF_HPP
+#endif // TMWA_MAP_CLIF_HPP
diff --git a/src/map/clif.t.hpp b/src/map/clif.t.hpp
index 96b8a9c..a52b33a 100644
--- a/src/map/clif.t.hpp
+++ b/src/map/clif.t.hpp
@@ -1,5 +1,5 @@
-#ifndef CLIF_T_HPP
-#define CLIF_T_HPP
+#ifndef TMWA_MAP_CLIF_T_HPP
+#define TMWA_MAP_CLIF_T_HPP
# include <cstdint>
@@ -18,4 +18,4 @@ enum class BeingRemoveWhy : uint8_t
NEGATIVE1 = 0xff,
};
-#endif // CLIF_T_HPP
+#endif // TMWA_MAP_CLIF_T_HPP
diff --git a/src/map/grfio.cpp b/src/map/grfio.cpp
index d89fe21..bf55cf7 100644
--- a/src/map/grfio.cpp
+++ b/src/map/grfio.cpp
@@ -19,7 +19,7 @@
#include "../io/cxxstdio.hpp"
#include "../io/read.hpp"
-#include "../common/extract.hpp"
+#include "../mmo/extract.hpp"
#include "../poison.hpp"
diff --git a/src/map/grfio.hpp b/src/map/grfio.hpp
index 3fde76a..e0758fe 100644
--- a/src/map/grfio.hpp
+++ b/src/map/grfio.hpp
@@ -1,11 +1,11 @@
-#ifndef GRFIO_HPP
-#define GRFIO_HPP
+#ifndef TMWA_MAP_GRFIO_HPP
+#define TMWA_MAP_GRFIO_HPP
# include <cstdint>
# include <vector>
-# include "../common/mmo.hpp"
+# include "../mmo/mmo.hpp"
bool load_resnametable(ZString filename);
@@ -14,4 +14,4 @@ bool load_resnametable(ZString filename);
/// Currently there is exactly one .wlk per .gat, but multiples are fine.
std::vector<uint8_t> grfio_reads(MapName resourcename);
-#endif // GRFIO_HPP
+#endif // TMWA_MAP_GRFIO_HPP
diff --git a/src/map/intif.cpp b/src/map/intif.cpp
index 5c6c46a..7f7be73 100644
--- a/src/map/intif.cpp
+++ b/src/map/intif.cpp
@@ -3,14 +3,15 @@
#include <cstdlib>
#include <cstring>
+#include "../compat/nullpo.hpp"
+
#include "../strings/astring.hpp"
#include "../strings/zstring.hpp"
#include "../strings/xstring.hpp"
#include "../io/cxxstdio.hpp"
-#include "../common/nullpo.hpp"
-#include "../common/socket.hpp"
+#include "../mmo/socket.hpp"
#include "battle.hpp"
#include "chrif.hpp"
diff --git a/src/map/intif.hpp b/src/map/intif.hpp
index 0fe7182..ac2740c 100644
--- a/src/map/intif.hpp
+++ b/src/map/intif.hpp
@@ -1,9 +1,9 @@
-#ifndef INTIF_HPP
-#define INTIF_HPP
+#ifndef TMWA_MAP_INTIF_HPP
+#define TMWA_MAP_INTIF_HPP
# include "../strings/fwd.hpp"
-# include "../common/const_array.hpp"
+# include "../generic/const_array.hpp"
# include "map.hpp"
@@ -30,4 +30,4 @@ void intif_party_changemap(dumb_ptr<map_session_data> sd, int online);
void intif_party_message(int party_id, int account_id, XString mes);
void intif_party_checkconflict(int party_id, int account_id, CharName nick);
-#endif // INTIF_HPP
+#endif // TMWA_MAP_INTIF_HPP
diff --git a/src/map/itemdb.cpp b/src/map/itemdb.cpp
index 330bd8b..528c81f 100644
--- a/src/map/itemdb.cpp
+++ b/src/map/itemdb.cpp
@@ -3,19 +3,21 @@
#include <cstdlib>
#include <cstring>
+#include "../compat/nullpo.hpp"
+
#include "../strings/astring.hpp"
#include "../strings/zstring.hpp"
#include "../strings/xstring.hpp"
+#include "../generic/db.hpp"
+#include "../generic/random.hpp"
+
#include "../io/cxxstdio.hpp"
#include "../io/read.hpp"
-#include "../common/config_parse.hpp"
-#include "../common/db.hpp"
-#include "../common/extract.hpp"
-#include "../common/nullpo.hpp"
-#include "../common/random.hpp"
-#include "../common/socket.hpp"
+#include "../mmo/config_parse.hpp"
+#include "../mmo/extract.hpp"
+#include "../mmo/socket.hpp"
#include "../poison.hpp"
diff --git a/src/map/itemdb.hpp b/src/map/itemdb.hpp
index f026f95..4c07303 100644
--- a/src/map/itemdb.hpp
+++ b/src/map/itemdb.hpp
@@ -1,7 +1,7 @@
-#ifndef ITEMDB_HPP
-#define ITEMDB_HPP
+#ifndef TMWA_MAP_ITEMDB_HPP
+#define TMWA_MAP_ITEMDB_HPP
-# include "../common/mmo.hpp"
+# include "../mmo/mmo.hpp"
# include "map.t.hpp"
# include "script.hpp"
@@ -77,4 +77,4 @@ void itemdb_reload(void);
void do_final_itemdb(void);
bool itemdb_readdb(ZString filename);
-#endif // ITEMDB_HPP
+#endif // TMWA_MAP_ITEMDB_HPP
diff --git a/src/map/magic-expr-eval.hpp b/src/map/magic-expr-eval.hpp
index 1569be8..0783dc8 100644
--- a/src/map/magic-expr-eval.hpp
+++ b/src/map/magic-expr-eval.hpp
@@ -1,10 +1,8 @@
-#ifndef MAGIC_EXPR_EVAL_HPP
-#define MAGIC_EXPR_EVAL_HPP
+#ifndef TMWA_MAP_MAGIC_EXPR_EVAL_HPP
+#define TMWA_MAP_MAGIC_EXPR_EVAL_HPP
# include "../strings/zstring.hpp"
-# include "../common/utils2.hpp"
-
# include "magic-interpreter.hpp"
/* Helper definitions for dealing with functions and operations */
@@ -42,4 +40,4 @@ void magic_area_rect(map_local **m, int *x, int *y, int *width, int *height,
# define ARG_MAY_BE_AREA(x) (ARG_TYPE(x) == TYPE::AREA || ARG_TYPE(x) == TYPE::LOCATION)
-#endif // MAGIC_EXPR_EVAL_HPP
+#endif // TMWA_MAP_MAGIC_EXPR_EVAL_HPP
diff --git a/src/map/magic-expr.cpp b/src/map/magic-expr.cpp
index 1f9ef82..279ba56 100644
--- a/src/map/magic-expr.cpp
+++ b/src/map/magic-expr.cpp
@@ -5,14 +5,16 @@
#include <cassert>
#include <cmath>
+#include "../compat/alg.hpp"
+
#include "../strings/mstring.hpp"
#include "../strings/astring.hpp"
#include "../strings/zstring.hpp"
#include "../strings/vstring.hpp"
-#include "../io/cxxstdio.hpp"
+#include "../generic/random.hpp"
-#include "../common/random.hpp"
+#include "../io/cxxstdio.hpp"
#include "battle.hpp"
#include "npc.hpp"
diff --git a/src/map/magic-expr.hpp b/src/map/magic-expr.hpp
index 0fdc435..79fdc3f 100644
--- a/src/map/magic-expr.hpp
+++ b/src/map/magic-expr.hpp
@@ -1,5 +1,5 @@
-#ifndef MAGIC_EXPR_HPP
-#define MAGIC_EXPR_HPP
+#ifndef TMWA_MAP_MAGIC_EXPR_HPP
+#define TMWA_MAP_MAGIC_EXPR_HPP
# include "magic-interpreter.hpp"
@@ -84,4 +84,4 @@ int magic_find_item(const_array<val_t> args, int index, struct item *item, int *
int magic_location_in_area(map_local *m, int x, int y, dumb_ptr<area_t> area);
-#endif // MAGIC_EXPR_HPP
+#endif // TMWA_MAP_MAGIC_EXPR_HPP
diff --git a/src/map/magic-interpreter-aux.hpp b/src/map/magic-interpreter-aux.hpp
index 070c771..6f5ad79 100644
--- a/src/map/magic-interpreter-aux.hpp
+++ b/src/map/magic-interpreter-aux.hpp
@@ -1,5 +1,5 @@
-#ifndef MAGIC_INTERPRETER_AUX_HPP
-#define MAGIC_INTERPRETER_AUX_HPP
+#ifndef TMWA_MAP_MAGIC_INTERPRETER_AUX_HPP
+#define TMWA_MAP_MAGIC_INTERPRETER_AUX_HPP
# include "magic-interpreter.t.hpp"
@@ -9,4 +9,4 @@ bool CHECK_TYPE(T *v, TYPE t)
return v->ty == t;
}
-#endif // MAGIC_INTERPRETER_AUX_HPP
+#endif // TMWA_MAP_MAGIC_INTERPRETER_AUX_HPP
diff --git a/src/map/magic-interpreter-base.cpp b/src/map/magic-interpreter-base.cpp
index f1878a0..40f186b 100644
--- a/src/map/magic-interpreter-base.cpp
+++ b/src/map/magic-interpreter-base.cpp
@@ -8,7 +8,7 @@
#include "../io/cxxstdio.hpp"
-#include "../common/timer.hpp"
+#include "../mmo/timer.hpp"
#include "magic-expr.hpp"
diff --git a/src/map/magic-interpreter-parser.ypp b/src/map/magic-interpreter-parser.ypp
index 3ec1bdd..ef8b159 100644
--- a/src/map/magic-interpreter-parser.ypp
+++ b/src/map/magic-interpreter-parser.ypp
@@ -17,9 +17,9 @@ AString current_magic_filename;
#include "../strings/astring.hpp"
#include "../strings/zstring.hpp"
-#include "../io/cxxstdio.hpp"
+#include "../generic/const_array.hpp"
-#include "../common/const_array.hpp"
+#include "../io/cxxstdio.hpp"
#include "itemdb.hpp"
#include "magic-expr.hpp"
diff --git a/src/map/magic-interpreter.hpp b/src/map/magic-interpreter.hpp
index 7e42499..6864844 100644
--- a/src/map/magic-interpreter.hpp
+++ b/src/map/magic-interpreter.hpp
@@ -1,5 +1,5 @@
-#ifndef MAGIC_INTERPRETER_HPP
-#define MAGIC_INTERPRETER_HPP
+#ifndef TMWA_MAP_MAGIC_INTERPRETER_HPP
+#define TMWA_MAP_MAGIC_INTERPRETER_HPP
# include "magic-interpreter.t.hpp"
@@ -450,4 +450,4 @@ bool magic_init0();
bool magic_init1(ZString filename);
void spell_update_location(dumb_ptr<invocation> invocation);
-#endif // MAGIC_INTERPRETER_HPP
+#endif // TMWA_MAP_MAGIC_INTERPRETER_HPP
diff --git a/src/map/magic-interpreter.t.hpp b/src/map/magic-interpreter.t.hpp
index fb7bb6d..e8d7e06 100644
--- a/src/map/magic-interpreter.t.hpp
+++ b/src/map/magic-interpreter.t.hpp
@@ -1,7 +1,7 @@
-#ifndef MAGIC_INTERPRETER_T_HPP
-#define MAGIC_INTERPRETER_T_HPP
+#ifndef TMWA_MAP_MAGIC_INTERPRETER_T_HPP
+#define TMWA_MAP_MAGIC_INTERPRETER_T_HPP
-# include "../common/utils2.hpp"
+# include "../generic/enum.hpp"
enum class SPELLARG : uint8_t
{
@@ -156,4 +156,4 @@ ENUM_BITWISE_OPERATORS(INVOCATION_FLAG)
}
using e::INVOCATION_FLAG;
-#endif // MAGIC_INTERPRETER_T_HPP
+#endif // TMWA_MAP_MAGIC_INTERPRETER_T_HPP
diff --git a/src/map/magic-stmt.cpp b/src/map/magic-stmt.cpp
index a71f43c..4063a68 100644
--- a/src/map/magic-stmt.cpp
+++ b/src/map/magic-stmt.cpp
@@ -2,12 +2,16 @@
#include <cassert>
+#include "../compat/attr.hpp"
+#include "../compat/fun.hpp"
+
#include "../strings/zstring.hpp"
+#include "../generic/random2.hpp"
+
#include "../io/cxxstdio.hpp"
-#include "../common/random2.hpp"
-#include "../common/timer.hpp"
+#include "../mmo/timer.hpp"
#include "magic-expr.hpp"
#include "magic-expr-eval.hpp"
diff --git a/src/map/magic.hpp b/src/map/magic.hpp
index 1fabd6f..1562469 100644
--- a/src/map/magic.hpp
+++ b/src/map/magic.hpp
@@ -1,9 +1,9 @@
-#ifndef MAGIC_HPP
-#define MAGIC_HPP
+#ifndef TMWA_MAP_MAGIC_HPP
+#define TMWA_MAP_MAGIC_HPP
# include "../strings/fwd.hpp"
-# include "../common/dumb_ptr.hpp"
+# include "../mmo/dumb_ptr.hpp"
# include "map.hpp"
# include "skill.t.hpp"
@@ -80,4 +80,4 @@ int spell_attack(int caster, int target);
void spell_free_invocation(dumb_ptr<invocation> invocation);
-#endif // MAGIC_HPP
+#endif // TMWA_MAP_MAGIC_HPP
diff --git a/src/map/main.cpp b/src/map/main.cpp
index c930630..f0e3517 100644
--- a/src/map/main.cpp
+++ b/src/map/main.cpp
@@ -1,2 +1,4 @@
// dummy file to make Make dependencies work
#include "map.hpp"
+
+#include "../poison.hpp"
diff --git a/src/map/map.cpp b/src/map/map.cpp
index 132afac..d9dd9cc 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -10,25 +10,28 @@
#include <cstdlib>
#include <cstring>
+#include "../compat/nullpo.hpp"
+#include "../compat/fun.hpp"
+
#include "../strings/astring.hpp"
#include "../strings/zstring.hpp"
#include "../strings/xstring.hpp"
#include "../strings/vstring.hpp"
+#include "../generic/db.hpp"
+#include "../generic/random2.hpp"
+
#include "../io/cxxstdio.hpp"
#include "../io/read.hpp"
#include "../io/tty.hpp"
#include "../io/write.hpp"
-#include "../common/config_parse.hpp"
-#include "../common/core.hpp"
-#include "../common/db.hpp"
-#include "../common/extract.hpp"
-#include "../common/random2.hpp"
-#include "../common/nullpo.hpp"
-#include "../common/socket.hpp"
-#include "../common/timer.hpp"
-#include "../common/version.hpp"
+#include "../mmo/config_parse.hpp"
+#include "../mmo/core.hpp"
+#include "../mmo/extract.hpp"
+#include "../mmo/socket.hpp"
+#include "../mmo/timer.hpp"
+#include "../mmo/version.hpp"
#include "atcommand.hpp"
#include "battle.hpp"
diff --git a/src/map/map.hpp b/src/map/map.hpp
index 1964a3c..d476dbc 100644
--- a/src/map/map.hpp
+++ b/src/map/map.hpp
@@ -1,5 +1,5 @@
-#ifndef MAP_HPP
-#define MAP_HPP
+#ifndef TMWA_MAP_MAP_HPP
+#define TMWA_MAP_MAP_HPP
# include "map.t.hpp"
@@ -13,12 +13,13 @@
# include "../strings/astring.hpp"
# include "../strings/vstring.hpp"
+# include "../generic/db.hpp"
+# include "../generic/matrix.hpp"
+
# include "../io/cxxstdio.hpp"
-# include "../common/db.hpp"
-# include "../common/matrix.hpp"
-# include "../common/socket.hpp"
-# include "../common/timer.t.hpp"
+# include "../mmo/socket.hpp"
+# include "../mmo/timer.t.hpp"
# include "battle.t.hpp"
# include "magic-interpreter.t.hpp"
@@ -714,4 +715,4 @@ inline dumb_ptr<npc_data_shop> npc_data::is_shop() { return npc_subtype == NpcSu
inline dumb_ptr<npc_data_warp> npc_data::is_warp() { return npc_subtype == NpcSubtype::WARP ? as_warp() : nullptr ; }
inline dumb_ptr<npc_data_message> npc_data::is_message() { return npc_subtype == NpcSubtype::MESSAGE ? as_message() : nullptr ; }
-#endif // MAP_HPP
+#endif // TMWA_MAP_MAP_HPP
diff --git a/src/map/map.t.hpp b/src/map/map.t.hpp
index f4d916a..4a41ea8 100644
--- a/src/map/map.t.hpp
+++ b/src/map/map.t.hpp
@@ -1,10 +1,9 @@
-#ifndef MAP_T_HPP
-#define MAP_T_HPP
+#ifndef TMWA_MAP_MAP_T_HPP
+#define TMWA_MAP_MAP_T_HPP
# include "../strings/vstring.hpp"
-# include "../common/mmo.hpp"
-# include "../common/utils2.hpp"
+# include "../mmo/mmo.hpp"
namespace e
{
@@ -562,4 +561,4 @@ struct NpcName : VString<23> {};
struct ScriptLabel : VString<23> {};
struct ItemName : VString<23> {};
-#endif // MAP_T_HPP
+#endif // TMWA_MAP_MAP_T_HPP
diff --git a/src/map/mapflag.hpp b/src/map/mapflag.hpp
index bf8229f..f3819ff 100644
--- a/src/map/mapflag.hpp
+++ b/src/map/mapflag.hpp
@@ -21,7 +21,7 @@
# include "../sanity.hpp"
-# include "../common/extract.hpp" // TODO remove this (requires specializing the *other* half)
+# include "../mmo/extract.hpp" // TODO remove this (requires specializing the *other* half)
# include "../strings/xstring.hpp"
diff --git a/src/map/mob.cpp b/src/map/mob.cpp
index 5a414be..61dcfb6 100644
--- a/src/map/mob.cpp
+++ b/src/map/mob.cpp
@@ -8,18 +8,21 @@
#include <algorithm>
+#include "../compat/fun.hpp"
+#include "../compat/nullpo.hpp"
+
#include "../strings/astring.hpp"
#include "../strings/xstring.hpp"
+#include "../generic/random.hpp"
+
#include "../io/cxxstdio.hpp"
#include "../io/read.hpp"
-#include "../common/config_parse.hpp"
-#include "../common/extract.hpp"
-#include "../common/nullpo.hpp"
-#include "../common/random.hpp"
-#include "../common/socket.hpp"
-#include "../common/timer.hpp"
+#include "../mmo/config_parse.hpp"
+#include "../mmo/extract.hpp"
+#include "../mmo/socket.hpp"
+#include "../mmo/timer.hpp"
#include "battle.hpp"
#include "clif.hpp"
diff --git a/src/map/mob.hpp b/src/map/mob.hpp
index bc8350a..305cd16 100644
--- a/src/map/mob.hpp
+++ b/src/map/mob.hpp
@@ -1,11 +1,12 @@
-#ifndef MOB_HPP
-#define MOB_HPP
+#ifndef TMWA_MAP_MOB_HPP
+#define TMWA_MAP_MOB_HPP
# include "mob.t.hpp"
-# include "../common/mmo.hpp"
-# include "../common/timer.t.hpp"
-# include "../common/random.t.hpp"
+# include "../generic/random.t.hpp"
+
+# include "../mmo/mmo.hpp"
+# include "../mmo/timer.t.hpp"
# include "clif.t.hpp"
# include "map.hpp"
@@ -108,4 +109,4 @@ int mob_summonslave(dumb_ptr<mob_data> md2, int *value, int amount, int flag);
void mob_reload(void);
-#endif // MOB_HPP
+#endif // TMWA_MAP_MOB_HPP
diff --git a/src/map/mob.t.hpp b/src/map/mob.t.hpp
index 54c326d..c8b1e7a 100644
--- a/src/map/mob.t.hpp
+++ b/src/map/mob.t.hpp
@@ -1,5 +1,5 @@
-#ifndef MOB_T_HPP
-#define MOB_T_HPP
+#ifndef TMWA_MAP_MOB_T_HPP
+#define TMWA_MAP_MOB_T_HPP
# include <cstdint>
@@ -38,4 +38,4 @@ enum class MobSkillState : uint8_t
MSS_CHASE,
};
-#endif // MOB_T_HPP
+#endif // TMWA_MAP_MOB_T_HPP
diff --git a/src/map/npc.cpp b/src/map/npc.cpp
index 8ecd7a3..1e164a5 100644
--- a/src/map/npc.cpp
+++ b/src/map/npc.cpp
@@ -7,20 +7,23 @@
#include <list>
+#include "../compat/fun.hpp"
+#include "../compat/nullpo.hpp"
+
#include "../strings/mstring.hpp"
#include "../strings/astring.hpp"
#include "../strings/zstring.hpp"
#include "../strings/xstring.hpp"
+#include "../generic/db.hpp"
+
#include "../io/cxxstdio.hpp"
#include "../io/read.hpp"
-#include "../common/config_parse.hpp"
-#include "../common/db.hpp"
-#include "../common/extract.hpp"
-#include "../common/nullpo.hpp"
-#include "../common/socket.hpp"
-#include "../common/timer.hpp"
+#include "../mmo/config_parse.hpp"
+#include "../mmo/extract.hpp"
+#include "../mmo/socket.hpp"
+#include "../mmo/timer.hpp"
#include "battle.hpp"
#include "clif.hpp"
diff --git a/src/map/npc.hpp b/src/map/npc.hpp
index 4d4cef1..93f2030 100644
--- a/src/map/npc.hpp
+++ b/src/map/npc.hpp
@@ -1,12 +1,12 @@
-#ifndef NPC_HPP
-#define NPC_HPP
+#ifndef TMWA_MAP_NPC_HPP
+#define TMWA_MAP_NPC_HPP
# include <cstddef>
# include <cstdint>
# include "../strings/fwd.hpp"
-# include "../common/timer.t.hpp"
+# include "../mmo/timer.t.hpp"
# include "map.hpp"
@@ -70,4 +70,4 @@ interval_t npc_gettimerevent_tick(dumb_ptr<npc_data_script> nd);
void npc_settimerevent_tick(dumb_ptr<npc_data_script> nd, interval_t newtimer);
int npc_delete(dumb_ptr<npc_data> nd);
-#endif // NPC_HPP
+#endif // TMWA_MAP_NPC_HPP
diff --git a/src/map/party.cpp b/src/map/party.cpp
index f7b8396..eadf392 100644
--- a/src/map/party.cpp
+++ b/src/map/party.cpp
@@ -2,14 +2,16 @@
#include <cstring>
+#include "../compat/nullpo.hpp"
+
#include "../strings/xstring.hpp"
+#include "../generic/db.hpp"
+
#include "../io/cxxstdio.hpp"
-#include "../common/db.hpp"
-#include "../common/nullpo.hpp"
-#include "../common/socket.hpp"
-#include "../common/timer.hpp"
+#include "../mmo/socket.hpp"
+#include "../mmo/timer.hpp"
#include "battle.hpp"
#include "clif.hpp"
diff --git a/src/map/party.hpp b/src/map/party.hpp
index 91dab1b..c2d4e9d 100644
--- a/src/map/party.hpp
+++ b/src/map/party.hpp
@@ -1,5 +1,5 @@
-#ifndef PARTY_HPP
-#define PARTY_HPP
+#ifndef TMWA_MAP_PARTY_HPP
+#define TMWA_MAP_PARTY_HPP
# include <functional>
@@ -48,4 +48,4 @@ int party_exp_share(struct party *p, map_local *map, int base_exp, int job_exp);
void party_foreachsamemap(std::function<void(dumb_ptr<block_list>)> func,
dumb_ptr<map_session_data> sd, int type);
-#endif // PARTY_HPP
+#endif // TMWA_MAP_PARTY_HPP
diff --git a/src/map/path.cpp b/src/map/path.cpp
index d66640e..a237fa8 100644
--- a/src/map/path.cpp
+++ b/src/map/path.cpp
@@ -2,10 +2,11 @@
#include <cassert>
-#include "../io/cxxstdio.hpp"
+#include "../compat/nullpo.hpp"
+
+#include "../generic/random.hpp"
-#include "../common/random.hpp"
-#include "../common/nullpo.hpp"
+#include "../io/cxxstdio.hpp"
#include "battle.hpp"
diff --git a/src/map/path.hpp b/src/map/path.hpp
index 4b5b3d8..69316e9 100644
--- a/src/map/path.hpp
+++ b/src/map/path.hpp
@@ -1,8 +1,8 @@
-#ifndef PATH_HPP
-#define PATH_HPP
+#ifndef TMWA_MAP_PATH_HPP
+#define TMWA_MAP_PATH_HPP
# include "map.hpp"
int path_search(struct walkpath_data *, map_local *, int, int, int, int, int);
-#endif // PATH_HPP
+#endif // TMWA_MAP_PATH_HPP
diff --git a/src/map/pc.cpp b/src/map/pc.cpp
index 86280ed..e3dd67a 100644
--- a/src/map/pc.cpp
+++ b/src/map/pc.cpp
@@ -4,17 +4,21 @@
#include <cstdlib>
#include <cstring>
+#include "../compat/alg.hpp"
+#include "../compat/fun.hpp"
+#include "../compat/nullpo.hpp"
+
#include "../strings/rstring.hpp"
#include "../strings/astring.hpp"
#include "../strings/zstring.hpp"
+#include "../generic/random.hpp"
+
#include "../io/cxxstdio.hpp"
#include "../io/read.hpp"
-#include "../common/nullpo.hpp"
-#include "../common/random.hpp"
-#include "../common/socket.hpp"
-#include "../common/timer.hpp"
+#include "../mmo/socket.hpp"
+#include "../mmo/timer.hpp"
#include "atcommand.hpp"
#include "battle.hpp"
diff --git a/src/map/pc.hpp b/src/map/pc.hpp
index df612d8..0226019 100644
--- a/src/map/pc.hpp
+++ b/src/map/pc.hpp
@@ -1,5 +1,5 @@
-#ifndef PC_HPP
-#define PC_HPP
+#ifndef TMWA_MAP_PC_HPP
+#define TMWA_MAP_PC_HPP
# include "pc.t.hpp"
@@ -155,4 +155,4 @@ void pc_show_motd(dumb_ptr<map_session_data> sd);
void do_init_pc(void);
-#endif // PC_HPP
+#endif // TMWA_MAP_PC_HPP
diff --git a/src/map/pc.t.hpp b/src/map/pc.t.hpp
index 95a76a7..29c3515 100644
--- a/src/map/pc.t.hpp
+++ b/src/map/pc.t.hpp
@@ -1,5 +1,5 @@
-#ifndef PC_T_HPP
-#define PC_T_HPP
+#ifndef TMWA_MAP_PC_T_HPP
+#define TMWA_MAP_PC_T_HPP
# include <cstdint>
@@ -41,4 +41,4 @@ enum class PickupFail : uint8_t
DROP_STEAL = 6,
};
-#endif // PC_T_HPP
+#endif // TMWA_MAP_PC_T_HPP
diff --git a/src/map/script.cpp b/src/map/script.cpp
index e3db7c7..fe42e44 100644
--- a/src/map/script.cpp
+++ b/src/map/script.cpp
@@ -7,25 +7,28 @@
#include <cstring>
#include <ctime>
+#include "../compat/fun.hpp"
+
#include "../strings/mstring.hpp"
#include "../strings/rstring.hpp"
#include "../strings/astring.hpp"
#include "../strings/zstring.hpp"
#include "../strings/xstring.hpp"
+#include "../generic/db.hpp"
+#include "../generic/intern-pool.hpp"
+#include "../generic/random.hpp"
+
#include "../io/cxxstdio.hpp"
#include "../io/lock.hpp"
#include "../io/read.hpp"
-#include "../common/config_parse.hpp"
-#include "../common/core.hpp"
-#include "../common/db.hpp"
-#include "../common/extract.hpp"
-#include "../common/intern-pool.hpp"
-#include "../common/random.hpp"
-#include "../common/socket.hpp"
-#include "../common/utils.hpp"
-#include "../common/timer.hpp"
+#include "../mmo/config_parse.hpp"
+#include "../mmo/core.hpp"
+#include "../mmo/extract.hpp"
+#include "../mmo/socket.hpp"
+#include "../mmo/utils.hpp"
+#include "../mmo/timer.hpp"
#include "atcommand.hpp"
#include "battle.hpp"
diff --git a/src/map/script.hpp b/src/map/script.hpp
index 91ee6a5..6cf40b0 100644
--- a/src/map/script.hpp
+++ b/src/map/script.hpp
@@ -1,5 +1,5 @@
-#ifndef SCRIPT_HPP
-#define SCRIPT_HPP
+#ifndef TMWA_MAP_SCRIPT_HPP
+#define TMWA_MAP_SCRIPT_HPP
# include <cstdint>
# include <cstring> // for inlined get_str - TODO remove
@@ -10,9 +10,10 @@
# include "../strings/astring.hpp"
# include "../strings/zstring.hpp"
-# include "../common/db.hpp"
-# include "../common/dumb_ptr.hpp"
-# include "../common/utils.hpp"
+# include "../generic/db.hpp"
+
+# include "../mmo/dumb_ptr.hpp"
+# include "../mmo/utils.hpp"
# include "map.t.hpp"
@@ -175,4 +176,4 @@ void set_script_var_s(dumb_ptr<map_session_data> sd, VarName var, int e, XString
int get_script_var_i(dumb_ptr<map_session_data> sd, VarName var, int e);
ZString get_script_var_s(dumb_ptr<map_session_data> sd, VarName var, int e);
-#endif // SCRIPT_HPP
+#endif // TMWA_MAP_SCRIPT_HPP
diff --git a/src/map/script.py b/src/map/script.py
index ba0198c..068307a 100644
--- a/src/map/script.py
+++ b/src/map/script.py
@@ -54,3 +54,6 @@ class script_data(object):
yield 'str', v['str']
else:
yield 'numi', v['numi']
+
+ def to_string(self):
+ return None
diff --git a/src/map/skill.cpp b/src/map/skill.cpp
index 077bf66..72d7f7a 100644
--- a/src/map/skill.cpp
+++ b/src/map/skill.cpp
@@ -5,18 +5,22 @@
#include <cstring>
#include <ctime>
+#include "../compat/attr.hpp"
+#include "../compat/fun.hpp"
+#include "../compat/nullpo.hpp"
+
#include "../strings/mstring.hpp"
#include "../strings/rstring.hpp"
#include "../strings/xstring.hpp"
+#include "../generic/random.hpp"
+
#include "../io/cxxstdio.hpp"
#include "../io/read.hpp"
-#include "../common/extract.hpp"
-#include "../common/nullpo.hpp"
-#include "../common/random.hpp"
-#include "../common/socket.hpp"
-#include "../common/timer.hpp"
+#include "../mmo/extract.hpp"
+#include "../mmo/socket.hpp"
+#include "../mmo/timer.hpp"
#include "battle.hpp"
#include "clif.hpp"
diff --git a/src/map/skill.hpp b/src/map/skill.hpp
index e8f36ab..b612268 100644
--- a/src/map/skill.hpp
+++ b/src/map/skill.hpp
@@ -1,5 +1,5 @@
-#ifndef SKILL_HPP
-#define SKILL_HPP
+#ifndef TMWA_MAP_SKILL_HPP
+#define TMWA_MAP_SKILL_HPP
# include "skill.t.hpp"
# include "skill-pools.hpp"
@@ -143,4 +143,4 @@ int skill_power_bl(dumb_ptr<block_list> bl, SkillID skill);
// [Fate] Remember that a certain skill ID belongs to a pool skill
void skill_pool_register(SkillID id);
-#endif // SKILL_HPP
+#endif // TMWA_MAP_SKILL_HPP
diff --git a/src/map/skill.t.hpp b/src/map/skill.t.hpp
index 1470d61..aedbb11 100644
--- a/src/map/skill.t.hpp
+++ b/src/map/skill.t.hpp
@@ -1,9 +1,9 @@
-#ifndef SKILL_T_HPP
-#define SKILL_T_HPP
+#ifndef TMWA_MAP_SKILL_T_HPP
+#define TMWA_MAP_SKILL_T_HPP
# include <cstdint>
-# include "../common/utils2.hpp"
+# include "../generic/enum.hpp"
// TODO remove most of these as their corresponding SkillIDs get deleted.
enum class StatusChange : uint16_t
@@ -110,4 +110,4 @@ ENUM_BITWISE_OPERATORS(SkillFlags)
}
using e::SkillFlags;
-#endif // SKILL_T_HPP
+#endif // TMWA_MAP_SKILL_T_HPP
diff --git a/src/map/storage.cpp b/src/map/storage.cpp
index b753c0d..89357b9 100644
--- a/src/map/storage.cpp
+++ b/src/map/storage.cpp
@@ -1,13 +1,13 @@
+#include "storage.hpp"
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see COPYING in the main folder
-#include "storage.hpp"
-
#include <cstdlib>
#include <cstring>
-#include "../common/db.hpp"
-#include "../common/nullpo.hpp"
+#include "../compat/nullpo.hpp"
+
+#include "../generic/db.hpp"
#include "chrif.hpp"
#include "clif.hpp"
diff --git a/src/map/storage.hpp b/src/map/storage.hpp
index 76be7d6..0e6d111 100644
--- a/src/map/storage.hpp
+++ b/src/map/storage.hpp
@@ -1,9 +1,9 @@
+#ifndef TMWA_MAP_STORAGE_HPP
+#define TMWA_MAP_STORAGE_HPP
+
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see COPYING in the main folder
-#ifndef STORAGE_HPP
-#define STORAGE_HPP
-
# include "map.hpp"
int storage_storageopen(dumb_ptr<map_session_data> sd);
@@ -17,4 +17,4 @@ int storage_storage_quit(dumb_ptr<map_session_data> sd);
int storage_storage_save(int account_id, int final);
int storage_storage_saved(int account_id);
-#endif // STORAGE_HPP
+#endif // TMWA_MAP_STORAGE_HPP
diff --git a/src/map/tmw.cpp b/src/map/tmw.cpp
index 16276fa..1c18bd5 100644
--- a/src/map/tmw.cpp
+++ b/src/map/tmw.cpp
@@ -3,14 +3,14 @@
#include <cctype>
#include <cstring>
+#include "../compat/nullpo.hpp"
+
#include "../strings/astring.hpp"
#include "../strings/zstring.hpp"
#include "../strings/xstring.hpp"
#include "../io/cxxstdio.hpp"
-#include "../common/nullpo.hpp"
-
#include "atcommand.hpp"
#include "battle.hpp"
#include "chrif.hpp"
diff --git a/src/map/tmw.hpp b/src/map/tmw.hpp
index e90143d..65e71fb 100644
--- a/src/map/tmw.hpp
+++ b/src/map/tmw.hpp
@@ -1,14 +1,15 @@
-#ifndef TMW_HPP
-#define TMW_HPP
+#ifndef TMWA_MAP_TMW_HPP
+#define TMWA_MAP_TMW_HPP
# include "../strings/fwd.hpp"
-# include "../common/const_array.hpp"
-# include "../common/dumb_ptr.hpp"
+# include "../generic/const_array.hpp"
+
+# include "../mmo/dumb_ptr.hpp"
# include "map.hpp"
int tmw_CheckChatSpam(dumb_ptr<map_session_data> sd, XString message);
void tmw_GmHackMsg(ZString line);
-#endif // TMW_HPP
+#endif // TMWA_MAP_TMW_HPP
diff --git a/src/map/trade.cpp b/src/map/trade.cpp
index 9626191..e9c5fd4 100644
--- a/src/map/trade.cpp
+++ b/src/map/trade.cpp
@@ -1,8 +1,8 @@
#include "trade.hpp"
-#include "../io/cxxstdio.hpp"
+#include "../compat/nullpo.hpp"
-#include "../common/nullpo.hpp"
+#include "../io/cxxstdio.hpp"
#include "battle.hpp"
#include "clif.hpp"
diff --git a/src/map/trade.hpp b/src/map/trade.hpp
index e50d608..1fb30f4 100644
--- a/src/map/trade.hpp
+++ b/src/map/trade.hpp
@@ -1,5 +1,5 @@
-#ifndef TRADE_HPP
-#define TRADE_HPP
+#ifndef TMWA_MAP_TRADE_HPP
+#define TMWA_MAP_TRADE_HPP
# include "map.hpp"
@@ -11,4 +11,4 @@ void trade_tradecancel(dumb_ptr<map_session_data> sd);
void trade_tradecommit(dumb_ptr<map_session_data> sd);
void trade_verifyzeny(dumb_ptr<map_session_data> sd);
-#endif // TRADE_HPP
+#endif // TMWA_MAP_TRADE_HPP
diff --git a/src/common/config_parse.cpp b/src/mmo/config_parse.cpp
index d677d8e..d677d8e 100644
--- a/src/common/config_parse.cpp
+++ b/src/mmo/config_parse.cpp
diff --git a/src/common/config_parse.hpp b/src/mmo/config_parse.hpp
index 6a55174..dd1b79e 100644
--- a/src/common/config_parse.hpp
+++ b/src/mmo/config_parse.hpp
@@ -1,5 +1,5 @@
-#ifndef TMWA_COMMON_CONFIG_PARSE_HPP
-#define TMWA_COMMON_CONFIG_PARSE_HPP
+#ifndef TMWA_MMO_CONFIG_PARSE_HPP
+#define TMWA_MMO_CONFIG_PARSE_HPP
// config_parse.hpp - Framework for per-server config parsers.
//
// Copyright © 2014 Ben Longbons <b.r.longbons@gmail.com>
@@ -33,4 +33,4 @@ bool config_split(XString line, XString *key, XString *value);
/// Then it defers to the inferior parser for a line it does not understand.
bool load_config_file(ZString filename, ConfigItemParser slave);
-#endif // TMWA_COMMON_CONFIG_PARSE_HPP
+#endif // TMWA_MMO_CONFIG_PARSE_HPP
diff --git a/src/common/core.cpp b/src/mmo/core.cpp
index d57e970..1a9a52e 100644
--- a/src/common/core.cpp
+++ b/src/mmo/core.cpp
@@ -10,9 +10,10 @@
#include "../strings/zstring.hpp"
+#include "../generic/random.hpp"
+
#include "../io/cxxstdio.hpp"
-#include "random.hpp"
#include "socket.hpp"
#include "timer.hpp"
diff --git a/src/common/core.hpp b/src/mmo/core.hpp
index 8141e9c..1788ece 100644
--- a/src/common/core.hpp
+++ b/src/mmo/core.hpp
@@ -1,5 +1,5 @@
-#ifndef CORE_HPP
-#define CORE_HPP
+#ifndef TMWA_MMO_CORE_HPP
+#define TMWA_MMO_CORE_HPP
# include "../sanity.hpp"
@@ -19,4 +19,4 @@ extern int do_init(int, ZString *);
/// or when if we manage to exit() gracefully.
extern void term_func(void);
-#endif // CORE_HPP
+#endif // TMWA_MMO_CORE_HPP
diff --git a/src/mmo/dumb_ptr.cpp b/src/mmo/dumb_ptr.cpp
new file mode 100644
index 0000000..5f73d27
--- /dev/null
+++ b/src/mmo/dumb_ptr.cpp
@@ -0,0 +1,3 @@
+#include "dumb_ptr.hpp"
+
+#include "../poison.hpp"
diff --git a/src/common/dumb_ptr.hpp b/src/mmo/dumb_ptr.hpp
index bf97f22..98c6308 100644
--- a/src/common/dumb_ptr.hpp
+++ b/src/mmo/dumb_ptr.hpp
@@ -1,5 +1,5 @@
-#ifndef TMWA_COMMON_DUMB_PTR_HPP
-#define TMWA_COMMON_DUMB_PTR_HPP
+#ifndef TMWA_MMO_DUMB_PTR_HPP
+#define TMWA_MMO_DUMB_PTR_HPP
// ptr.hpp - temporary new/delete wrappers
//
// Copyright © 2013 Ben Longbons <b.r.longbons@gmail.com>
@@ -29,7 +29,7 @@
# include "../strings/zstring.hpp"
# include "../strings/xstring.hpp"
-# include "const_array.hpp"
+# include "../generic/const_array.hpp"
// unmanaged new/delete-able pointer
// should be replaced by std::unique_ptr<T>
@@ -273,4 +273,4 @@ const char *convert_for_printf(dumb_string ds)
return ds.c_str();
}
-#endif // TMWA_COMMON_DUMB_PTR_HPP
+#endif // TMWA_MMO_DUMB_PTR_HPP
diff --git a/src/common/extract.cpp b/src/mmo/extract.cpp
index 378986d..378986d 100644
--- a/src/common/extract.cpp
+++ b/src/mmo/extract.cpp
diff --git a/src/common/extract.hpp b/src/mmo/extract.hpp
index 31cf111..0ea9eb9 100644
--- a/src/common/extract.hpp
+++ b/src/mmo/extract.hpp
@@ -1,5 +1,5 @@
-#ifndef EXTRACT_HPP
-#define EXTRACT_HPP
+#ifndef TMWA_MMO_EXTRACT_HPP
+#define TMWA_MMO_EXTRACT_HPP
// extract.hpp - a simple, hierarchical, tokenizer
//
// Copyright © 2012-2013 Ben Longbons <b.r.longbons@gmail.com>
@@ -25,7 +25,8 @@
# include "../strings/xstring.hpp"
-# include "const_array.hpp"
+# include "../generic/const_array.hpp"
+
# include "mmo.hpp"
# include "utils.hpp"
@@ -220,4 +221,4 @@ bool extract(XString str, CharName *out)
return false;
}
-#endif // EXTRACT_HPP
+#endif // TMWA_MMO_EXTRACT_HPP
diff --git a/src/common/extract_test.cpp b/src/mmo/extract_test.cpp
index 3d0610e..3d0610e 100644
--- a/src/common/extract_test.cpp
+++ b/src/mmo/extract_test.cpp
diff --git a/src/mmo/human_time_diff.cpp b/src/mmo/human_time_diff.cpp
new file mode 100644
index 0000000..93a6d52
--- /dev/null
+++ b/src/mmo/human_time_diff.cpp
@@ -0,0 +1,3 @@
+#include "human_time_diff.hpp"
+
+#include "../poison.hpp"
diff --git a/src/common/human_time_diff.hpp b/src/mmo/human_time_diff.hpp
index b8040b8..689b8d9 100644
--- a/src/common/human_time_diff.hpp
+++ b/src/mmo/human_time_diff.hpp
@@ -1,5 +1,5 @@
-#ifndef TMWA_COMMON_HUMAN_TIME_DIFF_HPP
-#define TMWA_COMMON_HUMAN_TIME_DIFF_HPP
+#ifndef TMWA_MMO_HUMAN_TIME_DIFF_HPP
+#define TMWA_MMO_HUMAN_TIME_DIFF_HPP
// human_time_diff.hpp - broken deltas
//
// Copyright © 2013 Ben Longbons <b.r.longbons@gmail.com>
@@ -83,4 +83,4 @@ bool extract(XString str, HumanTimeDiff *iv)
return true;
}
-#endif // TMWA_COMMON_HUMAN_TIME_DIFF_HPP
+#endif // TMWA_MMO_HUMAN_TIME_DIFF_HPP
diff --git a/src/common/human_time_diff_test.cpp b/src/mmo/human_time_diff_test.cpp
index d3ddad1..d3ddad1 100644
--- a/src/common/human_time_diff_test.cpp
+++ b/src/mmo/human_time_diff_test.cpp
diff --git a/src/common/ip.cpp b/src/mmo/ip.cpp
index 146734a..146734a 100644
--- a/src/common/ip.cpp
+++ b/src/mmo/ip.cpp
diff --git a/src/common/ip.hpp b/src/mmo/ip.hpp
index d6e6f04..a425710 100644
--- a/src/common/ip.hpp
+++ b/src/mmo/ip.hpp
@@ -1,5 +1,5 @@
-#ifndef TMWA_COMMON_IP_HPP
-#define TMWA_COMMON_IP_HPP
+#ifndef TMWA_MMO_IP_HPP
+#define TMWA_MMO_IP_HPP
// ip.hpp - classes to deal with IP addresses.
//
// Copyright © 2013 Ben Longbons <b.r.longbons@gmail.com>
@@ -161,4 +161,4 @@ bool extract(XString str, IP4Address *iv);
bool extract(XString str, IP4Mask *iv);
-#endif // TMWA_COMMON_IP_HPP
+#endif // TMWA_MMO_IP_HPP
diff --git a/src/common/ip.py b/src/mmo/ip.py
index e6a8183..e6a8183 100644
--- a/src/common/ip.py
+++ b/src/mmo/ip.py
diff --git a/src/common/ip_test.cpp b/src/mmo/ip_test.cpp
index 7ef1047..7ef1047 100644
--- a/src/common/ip_test.cpp
+++ b/src/mmo/ip_test.cpp
diff --git a/src/mmo/md5more.cpp b/src/mmo/md5more.cpp
new file mode 100644
index 0000000..51ff5c4
--- /dev/null
+++ b/src/mmo/md5more.cpp
@@ -0,0 +1,128 @@
+#include "md5more.hpp"
+
+#include "../compat/rawmem.hpp"
+
+#include "../generic/random.hpp"
+
+#include "../io/cxxstdio.hpp"
+
+#include "../poison.hpp"
+
+#define X block.data
+
+// TODO - refactor MD5 into a stream, and merge the implementations
+// I once implemented an ostream that does it ...
+MD5_state MD5_from_FILE(io::ReadFile& in)
+{
+ uint64_t total_len = 0;
+
+ uint8_t buf[0x40];
+ uint8_t block_len = 0;
+
+ MD5_state state;
+ MD5_init(&state);
+
+ MD5_block block;
+
+ while (true)
+ {
+ size_t rv = in.get(sign_cast<char *>(buf + block_len), 0x40 - block_len);
+ if (!rv)
+ break;
+ total_len += 8 * rv; // in bits
+ block_len += rv;
+ if (block_len != 0x40)
+ continue;
+ for (int i = 0; i < 0x10; i++)
+ X[i] = buf[4 * i + 0] | buf[4 * i + 1] << 8 | buf[4 * i + 2] << 16 | buf[4 * i + 3] << 24;
+ MD5_do_block(&state, block);
+ block_len = 0;
+ }
+ // no more input, just pad and append the length
+ buf[block_len] = 0x80;
+ really_memset0(buf + block_len + 1, 0x40 - block_len - 1);
+ if (block_len < 0x38)
+ {
+ for (int i = 0; i < 8; i++)
+ buf[0x38 + i] = total_len >> i * 8;
+ }
+ for (int i = 0; i < 0x10; i++)
+ X[i] = buf[4 * i + 0] | buf[4 * i + 1] << 8 | buf[4 * i + 2] << 16 | buf[4 * i + 3] << 24;
+ MD5_do_block(&state, block);
+ if (0x38 <= block_len)
+ {
+ really_memset0(buf, 0x38);
+ for (int i = 0; i < 8; i++)
+ buf[0x38 + i] = total_len >> i * 8;
+ for (int i = 0; i < 0x10; i++)
+ X[i] = buf[4 * i + 0] | buf[4 * i + 1] << 8 | buf[4 * i + 2] << 16 | buf[4 * i + 3] << 24;
+ MD5_do_block(&state, block);
+ }
+ return state;
+}
+
+
+// Hash a password with a salt.
+// Whoever wrote this FAILS programming
+AccountCrypt MD5_saltcrypt(AccountPass key, SaltString salt)
+{
+ char cbuf[64] {};
+
+ // hash the key then the salt
+ // buf ends up as a 64-char NUL-terminated string
+ md5_string tbuf, tbuf2;
+ MD5_to_str(MD5_from_string(key), tbuf);
+ MD5_to_str(MD5_from_string(salt), tbuf2);
+ const auto it = std::copy(tbuf.begin(), tbuf.end(), std::begin(cbuf));
+ auto it2 = std::copy(tbuf2.begin(), tbuf2.end(), it);
+ assert(it2 == std::end(cbuf));
+
+ md5_string tbuf3;
+ MD5_to_str(MD5_from_string(XString(std::begin(cbuf), it2, nullptr)), tbuf3);
+
+ VString<31> obuf;
+
+ // This truncates the string, but we have to keep it like that for compatibility
+ SNPRINTF(obuf, 32, "!%s$%s", salt, tbuf3);
+ return stringish<AccountCrypt>(obuf);
+}
+
+SaltString make_salt(void)
+{
+ char salt[5];
+ for (int i = 0; i < 5; i++)
+ // 126 would probably actually be okay
+ salt[i] = random_::in(48, 125);
+ return stringish<SaltString>(XString(salt + 0, salt + 5, nullptr));
+}
+
+bool pass_ok(AccountPass password, AccountCrypt crypted)
+{
+ // crypted is like !salt$hash
+ auto begin = crypted.begin() + 1;
+ auto end = std::find(begin, crypted.end(), '$');
+ SaltString salt = stringish<SaltString>(crypted.xislice(begin, end));
+
+ return crypted == MD5_saltcrypt(password, salt);
+}
+
+// [M|h]ashes up an IP address and a secret key
+// to return a hopefully unique masked IP.
+IP4Address MD5_ip(IP4Address ip)
+{
+ static SaltString secret = make_salt();
+
+ // MD5sum a secret + the IP address
+ VString<31> ipbuf;
+ SNPRINTF(ipbuf, 32, "%s %s", ip, secret);
+ md5_binary obuf;
+ MD5_to_bin(MD5_from_string(ipbuf), obuf);
+
+ // Fold the md5sum to 32 bits, pack the bytes to an in_addr
+ return IP4Address({
+ static_cast<uint8_t>(obuf[0] ^ obuf[1] ^ obuf[8] ^ obuf[9]),
+ static_cast<uint8_t>(obuf[2] ^ obuf[3] ^ obuf[10] ^ obuf[11]),
+ static_cast<uint8_t>(obuf[4] ^ obuf[5] ^ obuf[12] ^ obuf[13]),
+ static_cast<uint8_t>(obuf[6] ^ obuf[7] ^ obuf[14] ^ obuf[15]),
+ });
+}
diff --git a/src/mmo/md5more.hpp b/src/mmo/md5more.hpp
new file mode 100644
index 0000000..0c50cca
--- /dev/null
+++ b/src/mmo/md5more.hpp
@@ -0,0 +1,26 @@
+#ifndef TMWA_MMO_MD5MORE_HPP
+#define TMWA_MMO_MD5MORE_HPP
+
+# include "../generic/md5.hpp"
+
+# include "../io/read.hpp"
+
+# include "ip.hpp"
+# include "mmo.hpp"
+
+MD5_state MD5_from_FILE(io::ReadFile& in);
+
+// whoever wrote this fails basic understanding of
+AccountCrypt MD5_saltcrypt(AccountPass key, SaltString salt);
+
+/// return some random characters
+// Currently, returns a 5-char string
+SaltString make_salt(void);
+
+/// check plaintext password against saved saltcrypt
+bool pass_ok(AccountPass password, AccountCrypt crypted);
+
+/// This returns an IP4Address because it is configurable whether it gets called at all
+IP4Address MD5_ip(IP4Address ip);
+
+#endif // TMWA_MMO_MD5MORE_HPP
diff --git a/src/mmo/mmo.cpp b/src/mmo/mmo.cpp
new file mode 100644
index 0000000..e9893ee
--- /dev/null
+++ b/src/mmo/mmo.cpp
@@ -0,0 +1,3 @@
+#include "mmo.hpp"
+
+#include "../poison.hpp"
diff --git a/src/common/mmo.hpp b/src/mmo/mmo.hpp
index bb30682..6b3cd53 100644
--- a/src/common/mmo.hpp
+++ b/src/mmo/mmo.hpp
@@ -1,13 +1,16 @@
/// Global structures and defines
-#ifndef MMO_HPP
-#define MMO_HPP
+#ifndef TMWA_MMO_MMO_HPP
+#define TMWA_MMO_MMO_HPP
# include "../sanity.hpp"
+# include "../compat/memory.hpp"
+
# include "../strings/vstring.hpp"
+# include "../generic/enum.hpp"
+
# include "timer.t.hpp"
-# include "utils2.hpp"
// affects CharName
# define NAME_IGNORING_CASE 1
@@ -47,13 +50,7 @@ struct AccountEmail : VString<39> {};
struct ServerName : VString<19> {};
struct PartyName : VString<23> {};
struct VarName : VString<31> {};
-template<class T>
-T stringish(VString<sizeof(T) - 1> iv)
-{
- T rv;
- static_cast<VString<sizeof(T) - 1>&>(rv) = iv;
- return rv;
-}
+
# define DEFAULT_EMAIL stringish<AccountEmail>("a@a.com")
// It is decreed: a mapname shall not contain an extension
@@ -351,7 +348,7 @@ struct storage
struct item storage_[MAX_STORAGE];
};
-struct map_session_data;
+//struct map_session_data;
struct GM_Account
{
@@ -377,4 +374,4 @@ struct party
struct party_member member[MAX_PARTY];
};
-#endif // MMO_HPP
+#endif // TMWA_MMO_MMO_HPP
diff --git a/src/common/socket.cpp b/src/mmo/socket.cpp
index 73e32a4..73e32a4 100644
--- a/src/common/socket.cpp
+++ b/src/mmo/socket.cpp
diff --git a/src/common/socket.hpp b/src/mmo/socket.hpp
index e0847ac..a77f512 100644
--- a/src/common/socket.hpp
+++ b/src/mmo/socket.hpp
@@ -1,5 +1,5 @@
-#ifndef SOCKET_HPP
-#define SOCKET_HPP
+#ifndef TMWA_MMO_SOCKET_HPP
+#define TMWA_MMO_SOCKET_HPP
# include "../sanity.hpp"
@@ -9,6 +9,8 @@
# include <array>
+# include "../compat/rawmem.hpp"
+
# include "../strings/astring.hpp"
# include "../strings/vstring.hpp"
# include "../strings/xstring.hpp"
@@ -368,4 +370,4 @@ void RFIFO_WFIFO_CLONE(Session *rs, Session *ws, size_t len)
static_cast<const uint8_t *>(RFIFOP(rs, 0)), len);
}
-#endif // SOCKET_HPP
+#endif // TMWA_MMO_SOCKET_HPP
diff --git a/src/common/timer.cpp b/src/mmo/timer.cpp
index b5a2a5e..b5a2a5e 100644
--- a/src/common/timer.cpp
+++ b/src/mmo/timer.cpp
diff --git a/src/common/timer.hpp b/src/mmo/timer.hpp
index 7e187a3..01b8623 100644
--- a/src/common/timer.hpp
+++ b/src/mmo/timer.hpp
@@ -1,5 +1,5 @@
-#ifndef TIMER_HPP
-#define TIMER_HPP
+#ifndef TMWA_MMO_TIMER_HPP
+#define TMWA_MMO_TIMER_HPP
# include "timer.t.hpp"
@@ -27,4 +27,4 @@ tick_t file_modified(ZString name);
/// Check if there are any events at all scheduled.
bool has_timers();
-#endif // TIMER_HPP
+#endif // TMWA_MMO_TIMER_HPP
diff --git a/src/common/timer.t.hpp b/src/mmo/timer.t.hpp
index 1e3a87a..dcc88f8 100644
--- a/src/common/timer.t.hpp
+++ b/src/mmo/timer.t.hpp
@@ -1,5 +1,5 @@
-#ifndef TIMER_T_HPP
-#define TIMER_T_HPP
+#ifndef TMWA_MMO_TIMER_T_HPP
+#define TMWA_MMO_TIMER_T_HPP
# include <chrono>
# include <functional>
@@ -65,4 +65,4 @@ public:
bool operator !() { return !td; }
};
-#endif // TIMER_T_HPP
+#endif // TMWA_MMO_TIMER_T_HPP
diff --git a/src/common/utils.cpp b/src/mmo/utils.cpp
index 0dbf145..0dbf145 100644
--- a/src/common/utils.cpp
+++ b/src/mmo/utils.cpp
diff --git a/src/common/utils.hpp b/src/mmo/utils.hpp
index 161cbd4..5e9de26 100644
--- a/src/common/utils.hpp
+++ b/src/mmo/utils.hpp
@@ -1,21 +1,19 @@
-#ifndef UTILS_HPP
-#define UTILS_HPP
+#ifndef TMWA_MMO_UTILS_HPP
+#define TMWA_MMO_UTILS_HPP
# include "../sanity.hpp"
# include <cstdio>
-# include <cstring>
# include <type_traits>
# include "../strings/fwd.hpp"
# include "../strings/vstring.hpp"
-# include "../io/fwd.hpp"
+# include "../generic/const_array.hpp"
+# include "../generic/operators.hpp"
-# include "const_array.hpp"
-# include "operators.hpp"
-# include "utils2.hpp"
+# include "../io/fwd.hpp"
template<class T>
struct is_trivially_copyable
@@ -29,28 +27,6 @@ struct is_trivially_copyable
bool e_mail_check(XString email);
int config_switch (ZString str);
-inline
-void really_memcpy(uint8_t *dest, const uint8_t *src, size_t n)
-{
- memcpy(dest, src, n);
-}
-
-inline
-void really_memmove(uint8_t *dest, const uint8_t *src, size_t n)
-{
- memmove(dest, src, n);
-}
-inline
-bool really_memequal(const uint8_t *a, const uint8_t *b, size_t n)
-{
- return memcmp(a, b, n) == 0;
-}
-
-inline
-void really_memset0(uint8_t *dest, size_t n)
-{
- memset(dest, '\0', n);
-}
template<class T>
void really_memzero_this(T *v)
{
@@ -137,4 +113,4 @@ static_assert(sizeof(TIMESTAMP_DUMMY) == sizeof(timestamp_seconds_buffer),
&t \
)
-#endif //UTILS_HPP
+#endif // TMWA_MMO_UTILS_HPP
diff --git a/src/common/version.cpp b/src/mmo/version.cpp
index 811ffdf..dd18fe1 100644
--- a/src/common/version.cpp
+++ b/src/mmo/version.cpp
@@ -6,6 +6,8 @@
#include "extract.hpp"
+#include "../poison.hpp"
+
Version CURRENT_VERSION =
{
VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH,
diff --git a/src/common/version.hpp b/src/mmo/version.hpp
index a2c4e05..420cbf9 100644
--- a/src/common/version.hpp
+++ b/src/mmo/version.hpp
@@ -1,5 +1,5 @@
-#ifndef TMWA_COMMON_VERSION_HPP
-#define TMWA_COMMON_VERSION_HPP
+#ifndef TMWA_MMO_VERSION_HPP
+#define TMWA_MMO_VERSION_HPP
# include <cstdint>
@@ -66,4 +66,4 @@ bool operator >= (Version l, Version r)
return !(l < r);
}
-#endif // TMWA_COMMON_VERSION_HPP
+#endif // TMWA_MMO_VERSION_HPP
diff --git a/src/monitor/GNUmakefile b/src/monitor/GNUmakefile
deleted file mode 100644
index 42efa8b..0000000
--- a/src/monitor/GNUmakefile
+++ /dev/null
@@ -1,7 +0,0 @@
-.SUFFIXES:
-bin/tmwa-monitor:
- ${MAKE} -C ../.. bin/tmwa-monitor
-clean:
- rm -r ../../obj/monitor/
-%::
- ${MAKE} -C ../.. obj/monitor/$@
diff --git a/src/monitor/main.cpp b/src/monitor/main.cpp
index e59be71..d2d22c4 100644
--- a/src/monitor/main.cpp
+++ b/src/monitor/main.cpp
@@ -23,8 +23,8 @@
#include "../io/fd.hpp"
#include "../io/read.hpp"
-#include "../common/config_parse.hpp"
-#include "../common/utils.hpp"
+#include "../mmo/config_parse.hpp"
+#include "../mmo/utils.hpp"
#include "../poison.hpp"
diff --git a/src/sanity.hpp b/src/sanity.hpp
index d4a8738..b048c36 100644
--- a/src/sanity.hpp
+++ b/src/sanity.hpp
@@ -10,11 +10,6 @@
# error "Your compiler is absolutely ancient. You have no chance ..."
# endif // __GNUC__ < 4
-/// Convert type assumptions to use the standard types here
-# include <cstdint>
-/// size_t, NULL
-# include <cstddef>
-
# if __GNUC__ == 4
// clang identifies as GCC 4.2, but is mostly okay.
// Until a bug-free release of it happens, though, I won't recommend it.
diff --git a/src/strings/astring.cpp b/src/strings/astring.cpp
index f7cfa2e..f1e9030 100644
--- a/src/strings/astring.cpp
+++ b/src/strings/astring.cpp
@@ -25,6 +25,8 @@
#include "xstring.hpp"
#include "vstring.hpp"
+//#include "../poison.hpp"
+
namespace strings
{
static_assert(sizeof(AString) == 256, "AString");
diff --git a/src/strings/base.hpp b/src/strings/base.hpp
index c081f70..cd8d46f 100644
--- a/src/strings/base.hpp
+++ b/src/strings/base.hpp
@@ -22,6 +22,8 @@
# include "fwd.hpp"
# include "pair.hpp"
+# include <cstddef>
+
# include <iterator>
// It is a common mistake to assume that one string class for everything.
diff --git a/src/strings/fwd.hpp b/src/strings/fwd.hpp
index f2b4037..4c58e03 100644
--- a/src/strings/fwd.hpp
+++ b/src/strings/fwd.hpp
@@ -21,6 +21,8 @@
# include "../sanity.hpp"
+# include <cstdint>
+
// It is a common mistake to assume that one string class for everything.
// Because C++ and TMWA have a C legacy, there are a few more here
// than would probably be necessary in an ideal language.
diff --git a/src/strings/mstring.cpp b/src/strings/mstring.cpp
index 0d496a5..2a1ca62 100644
--- a/src/strings/mstring.cpp
+++ b/src/strings/mstring.cpp
@@ -20,6 +20,8 @@
#include "xstring.hpp"
+#include "../poison.hpp"
+
namespace strings
{
MString::iterator MString::begin()
diff --git a/src/strings/rstring.cpp b/src/strings/rstring.cpp
index eb9d88a..c0e231e 100644
--- a/src/strings/rstring.cpp
+++ b/src/strings/rstring.cpp
@@ -25,6 +25,8 @@
#include "xstring.hpp"
#include "vstring.hpp"
+//#include "../poison.hpp"
+
namespace strings
{
static_assert(sizeof(RString) == sizeof(const char *), "RString");
diff --git a/src/strings/sstring.cpp b/src/strings/sstring.cpp
index fee98f9..76f0994 100644
--- a/src/strings/sstring.cpp
+++ b/src/strings/sstring.cpp
@@ -22,6 +22,8 @@
#include "zstring.hpp"
#include "xstring.hpp"
+#include "../poison.hpp"
+
namespace strings
{
SString::SString()
diff --git a/src/strings/tstring.cpp b/src/strings/tstring.cpp
index 8be7112..5f463ca 100644
--- a/src/strings/tstring.cpp
+++ b/src/strings/tstring.cpp
@@ -22,6 +22,8 @@
#include "zstring.hpp"
#include "xstring.hpp"
+#include "../poison.hpp"
+
namespace strings
{
TString::TString()
diff --git a/src/strings/vstring.cpp b/src/strings/vstring.cpp
index 6a0416a..0ef8f3d 100644
--- a/src/strings/vstring.cpp
+++ b/src/strings/vstring.cpp
@@ -18,6 +18,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
+#include "../poison.hpp"
+
namespace strings
{
} // namespace strings
diff --git a/src/strings/vstring.hpp b/src/strings/vstring.hpp
index 183e782..c467b64 100644
--- a/src/strings/vstring.hpp
+++ b/src/strings/vstring.hpp
@@ -65,6 +65,14 @@ namespace strings
int do_vprint(VString<len>& out, const char *fmt, va_list ap);
} // namespace strings
+template<class T>
+T stringish(VString<sizeof(T) - 1> iv)
+{
+ T rv;
+ static_cast<VString<sizeof(T) - 1>&>(rv) = iv;
+ return rv;
+}
+
# include "vstring.tcc"
#endif // TMWA_STRINGS_VSTRING_HPP
diff --git a/src/strings/vstring.tcc b/src/strings/vstring.tcc
index 69729d4..1aa163d 100644
--- a/src/strings/vstring.tcc
+++ b/src/strings/vstring.tcc
@@ -19,7 +19,7 @@
#include <cassert>
-#include "../common/utils2.hpp"
+#include "../compat/cast.hpp"
#include "rstring.hpp"
#include "astring.hpp"
diff --git a/src/strings/xstring.cpp b/src/strings/xstring.cpp
index 8a604c7..0808104 100644
--- a/src/strings/xstring.cpp
+++ b/src/strings/xstring.cpp
@@ -18,6 +18,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
+#include "../poison.hpp"
+
namespace strings
{
XString::XString()
diff --git a/src/strings/zstring.cpp b/src/strings/zstring.cpp
index bfc0c96..e2a763f 100644
--- a/src/strings/zstring.cpp
+++ b/src/strings/zstring.cpp
@@ -20,6 +20,8 @@
#include "xstring.hpp"
+#include "../poison.hpp"
+
namespace strings
{
ZString::ZString()