summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-10-25 15:24:26 -0700
committerBen Longbons <b.r.longbons@gmail.com>2014-10-26 14:21:48 -0700
commit86395f53634b3ef1ce76a7f1e5edfdb61f8ffd80 (patch)
tree2710c62fe71d5e0d2e228fba9c951a040c4dcddf
parent6800761863dd45b6055768febc6ace6a20120dc7 (diff)
downloadtmwa-86395f53634b3ef1ce76a7f1e5edfdb61f8ffd80.tar.gz
tmwa-86395f53634b3ef1ce76a7f1e5edfdb61f8ffd80.tar.bz2
tmwa-86395f53634b3ef1ce76a7f1e5edfdb61f8ffd80.tar.xz
tmwa-86395f53634b3ef1ce76a7f1e5edfdb61f8ffd80.zip
Fix header ranking
-rw-r--r--Makefile.in24
-rw-r--r--src/admin/fwd.hpp9
-rw-r--r--src/admin/ladmin.cpp12
-rw-r--r--src/admin/main.cpp2
-rw-r--r--src/ast/fwd.hpp6
-rw-r--r--src/ast/npc.cpp7
-rw-r--r--src/ast/npc.hpp5
-rw-r--r--src/char/char.cpp15
-rw-r--r--src/char/char.hpp4
-rw-r--r--src/char/fwd.hpp11
-rw-r--r--src/char/int_party.cpp10
-rw-r--r--src/char/int_party.hpp6
-rw-r--r--src/char/int_storage.cpp12
-rw-r--r--src/char/int_storage.hpp8
-rw-r--r--src/char/inter.cpp9
-rw-r--r--src/char/inter.hpp4
-rw-r--r--src/char/main.cpp2
-rw-r--r--src/compat/fwd.hpp5
-rw-r--r--src/compat/operators.hpp (renamed from src/generic/operators.hpp)0
-rw-r--r--src/compat/rawmem.hpp21
-rw-r--r--src/compat/time_t.hpp84
-rw-r--r--src/generic/fwd.hpp4
-rw-r--r--src/generic/md5.hpp1
-rw-r--r--src/high/core.cpp (renamed from src/mmo/core.cpp)4
-rw-r--r--src/high/core.hpp (renamed from src/mmo/core.hpp)2
-rw-r--r--src/high/extract_mmo.cpp95
-rw-r--r--src/high/extract_mmo.hpp32
-rw-r--r--src/high/fwd.hpp39
-rw-r--r--src/high/md5more.cpp (renamed from src/mmo/md5more.cpp)2
-rw-r--r--src/high/md5more.hpp (renamed from src/mmo/md5more.hpp)4
-rw-r--r--src/high/mmo.hpp (renamed from src/mmo/mmo.hpp)0
-rw-r--r--src/high/utils.cpp (renamed from src/mmo/utils.cpp)39
-rw-r--r--src/high/utils.hpp29
-rw-r--r--src/ints/fwd.hpp2
-rw-r--r--src/io/dir.hpp2
-rw-r--r--src/io/extract.cpp (renamed from src/mmo/extract.cpp)64
-rw-r--r--src/io/extract.hpp (renamed from src/mmo/extract.hpp)12
-rw-r--r--src/io/extract_test.cpp (renamed from src/mmo/extract_test.cpp)6
-rw-r--r--src/io/fd.hpp2
-rw-r--r--src/io/fwd.hpp6
-rw-r--r--src/io/read.cpp2
-rw-r--r--src/io/read.hpp2
-rw-r--r--src/io/write.hpp2
-rw-r--r--src/login/fwd.hpp11
-rw-r--r--src/login/login.cpp15
-rw-r--r--src/login/login.hpp2
-rw-r--r--src/login/main.cpp2
-rw-r--r--src/map/atcommand.cpp13
-rw-r--r--src/map/atcommand.hpp8
-rw-r--r--src/map/battle.cpp4
-rw-r--r--src/map/battle.hpp8
-rw-r--r--src/map/chrif.cpp7
-rw-r--r--src/map/chrif.hpp8
-rw-r--r--src/map/clif.cpp45
-rw-r--r--src/map/clif.hpp13
-rw-r--r--src/map/fwd.hpp20
-rw-r--r--src/map/grfio.cpp5
-rw-r--r--src/map/grfio.hpp4
-rw-r--r--src/map/intif.cpp5
-rw-r--r--src/map/intif.hpp10
-rw-r--r--src/map/itemdb.cpp2
-rw-r--r--src/map/itemdb.hpp2
-rw-r--r--src/map/magic-expr.cpp3
-rw-r--r--src/map/magic-expr.hpp6
-rw-r--r--src/map/magic-interpreter-base.cpp3
-rw-r--r--src/map/magic-interpreter-base.hpp6
-rw-r--r--src/map/magic-interpreter.hpp6
-rw-r--r--src/map/magic-stmt.cpp3
-rw-r--r--src/map/magic-stmt.hpp6
-rw-r--r--src/map/magic.hpp6
-rw-r--r--src/map/main.cpp2
-rw-r--r--src/map/map.cpp14
-rw-r--r--src/map/map.hpp36
-rw-r--r--src/map/map.t.hpp7
-rw-r--r--src/map/mapflag.cpp2
-rw-r--r--src/map/mapflag.hpp2
-rw-r--r--src/map/mob.cpp4
-rw-r--r--src/map/mob.hpp5
-rw-r--r--src/map/npc-internal.hpp2
-rw-r--r--src/map/npc-parse.cpp3
-rw-r--r--src/map/npc-parse.hpp8
-rw-r--r--src/map/npc.cpp4
-rw-r--r--src/map/npc.hpp6
-rw-r--r--src/map/party.cpp2
-rw-r--r--src/map/party.hpp8
-rw-r--r--src/map/path.cpp2
-rw-r--r--src/map/path.hpp2
-rw-r--r--src/map/pc.cpp6
-rw-r--r--src/map/pc.hpp8
-rw-r--r--src/map/script-call.cpp3
-rw-r--r--src/map/script-call.hpp6
-rw-r--r--src/map/script-fun.cpp5
-rw-r--r--src/map/script-parse-internal.hpp2
-rw-r--r--src/map/script-parse.cpp3
-rw-r--r--src/map/script-parse.hpp4
-rw-r--r--src/map/script-startup-internal.hpp4
-rw-r--r--src/map/script-startup.cpp3
-rw-r--r--src/map/script-startup.hpp2
-rw-r--r--src/map/skill-pools.cpp3
-rw-r--r--src/map/skill.cpp4
-rw-r--r--src/map/skill.hpp4
-rw-r--r--src/map/storage.cpp2
-rw-r--r--src/map/storage.hpp8
-rw-r--r--src/map/tmw.cpp1
-rw-r--r--src/map/tmw.hpp4
-rw-r--r--src/map/trade.hpp4
-rw-r--r--src/mmo/clif.t.hpp (renamed from src/map/clif.t.hpp)4
-rw-r--r--src/mmo/config_parse.hpp2
-rw-r--r--src/mmo/cxxstdio_enums.hpp (renamed from src/io/cxxstdio_enums.hpp)0
-rw-r--r--src/mmo/extract_enums.cpp59
-rw-r--r--src/mmo/extract_enums.hpp6
-rw-r--r--src/mmo/fwd.hpp32
-rw-r--r--src/mmo/human_time_diff.cpp68
-rw-r--r--src/mmo/human_time_diff.hpp45
-rw-r--r--src/mmo/ids.cpp42
-rw-r--r--src/mmo/ids.hpp17
-rw-r--r--src/mmo/login.t.hpp (renamed from src/login/login.t.hpp)0
-rw-r--r--src/mmo/skill.t.hpp (renamed from src/map/skill.t.hpp)0
-rw-r--r--src/mmo/strs.hpp33
-rw-r--r--src/mmo/utils.hpp167
-rw-r--r--src/mmo/version.cpp2
-rw-r--r--src/mmo/version.hpp2
-rw-r--r--src/monitor/main.cpp3
-rw-r--r--src/net/fwd.hpp9
-rw-r--r--src/net/ip.cpp3
-rw-r--r--src/net/ip.hpp2
-rw-r--r--src/net/socket.cpp16
-rw-r--r--src/net/socket.hpp19
-rw-r--r--src/net/timer.hpp3
-rw-r--r--src/net/timestamp-utils.cpp72
-rw-r--r--src/net/timestamp-utils.hpp54
-rw-r--r--src/proto-base/fwd.hpp5
-rw-r--r--src/range/fwd.hpp2
-rw-r--r--src/sexpr/fwd.hpp5
-rw-r--r--src/sexpr/lexer.hpp1
-rw-r--r--src/sexpr/parser.hpp2
-rw-r--r--src/strings/astring.py2
-rw-r--r--src/strings/fwd.hpp2
-rw-r--r--src/strings/rstring.py2
-rw-r--r--src/tests/fwd.hpp4
-rw-r--r--src/wire/fwd.hpp34
-rw-r--r--src/wire/packets.cpp (renamed from src/net/packets.cpp)0
-rw-r--r--src/wire/packets.hpp (renamed from src/net/packets.hpp)7
-rwxr-xr-xtools/protocol.py63
144 files changed, 1031 insertions, 773 deletions
diff --git a/Makefile.in b/Makefile.in
index 9fd289c..9be1ad9 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -197,6 +197,8 @@ PIES := $(filter-out src/main-gdb-%.py,${PIES})
SOURCES := ${REAL_SOURCES}
HEADERS := ${REAL_HEADERS}
CHECK_HEADERS := $(patsubst src/%.hpp,stamp/%.hpp.check,$(filter %.hpp,${REAL_HEADERS}))
+CHECK_RANK_FWDS := $(patsubst src/%,stamp/%.rank,${REAL_HEADERS} $(filter-out %_test.cpp,${REAL_SOURCES}))
+CHECK_FWDS := $(patsubst src/%/fwd.hpp,stamp/%.fwdcheck,$(filter %/fwd.hpp,${REAL_HEADERS}))
PATTERN_ROOTS := $(patsubst src/%.cpp,%,${SOURCES})
PATTERN_PIES := $(patsubst src/%.py,%,${PIES})
PATTERN_MAINS := $(patsubst %/main,%,$(filter %/main,${PATTERN_ROOTS}))
@@ -501,18 +503,40 @@ endif
test: test-direct
test-direct: $(patsubst bin/tests/%,stamp/run-%.stamp,${TEST_BINARIES})
+
test: test-gtest
test-gtest: $(patsubst bin/tests/%,stamp/run-%.stamp,${GTEST_BINARIES})
+
test: test-dtest
test-dtest: $(patsubst bin/tests/%,stamp/run-%.stamp,${DTEST_BINARIES})
+
stamp/run-%.stamp: bin/tests/%
$(MKDIR_FIRST)
ln -sf ../lib bin/lib
${TESTER} $< ${TEST_ARGS}
touch $@
+
test: test-headers
test-headers: ${CHECK_HEADERS}
+test: test-rank-fwd
+test-rank-fwd: ${CHECK_RANK_FWDS}
+stamp/%.rank: src/%
+ $(MKDIR_FIRST)
+ includes=$$(grep '#include.*".*/.*"' $< | sed 's/^[^"]*"//;s/"[^"]*$$//;s:/[^/]*$$::' | sort -u | fgrep -vx -e '..' -e 'conf-raw' -e '../conf'); \
+ for inc in $$includes; do if ! test -f ${<D}/fwd.hpp; then continue; fi; echo fgrep -q $${inc}/fwd.hpp ${<D}/fwd.hpp; fgrep -q $${inc}/fwd.hpp ${<D}/fwd.hpp || { echo ${<D}/fwd.hpp:''23: error: No $${inc}/fwd.hpp; exit 1; }; done
+ touch $@
+
+test: test-check-fwd
+test-check-fwd: ${CHECK_FWDS}
+stamp/%.fwdcheck: src/%/fwd.hpp
+ $(MKDIR_FIRST)
+ types=$$(grep -o '\(enum \|class \| struct \|union \)\+[A-Za-z_0-9]\+;$$' $< | sed 's/\(;\|enum \|class \|struct \|union \)//g'); \
+ for t in $$types; do echo grep -q $$t $(filter-out %/fwd.hpp,$(wildcard ${<D}/*.hpp)); grep -qw '\(enum \|class \|struct \|union \)'$$t $(filter-out %/fwd.hpp,$(wildcard ${<D}/*.hpp)) || { grep -Hnw $$t';$$' $<; exit 1; }; done
+ includes=$$(grep -o '#include.*".*/fwd\.hpp"' $< | sed 's:^[^"]*"::;s:/[^/]*"$$:/:'); \
+ for inc in $$includes; do echo fgrep -q $$inc $(filter-out %/fwd.hpp,$(wildcard ${<D}/*.hpp ${<D}/*.tcc ${<D}/*.cpp)); fgrep -q $$inc $(filter-out %/fwd.hpp,$(wildcard ${<D}/*.hpp ${<D}/*.tcc ${<D}/*.cpp)) || { grep -Hn $$inc $<; exit 1; }; done
+ touch $@
+
install := install
install_exe := ${install}
install_dir := ${install} -d
diff --git a/src/admin/fwd.hpp b/src/admin/fwd.hpp
index 46674c8..a964d5f 100644
--- a/src/admin/fwd.hpp
+++ b/src/admin/fwd.hpp
@@ -20,6 +20,15 @@
#include "../sanity.hpp"
+#include "../strings/fwd.hpp" // rank 1
+#include "../io/fwd.hpp" // rank 4
+#include "../net/fwd.hpp" // rank 5
+#include "../mmo/fwd.hpp" // rank 6
+#include "../proto2/fwd.hpp" // rank 8
+#include "../high/fwd.hpp" // rank 9
+#include "../wire/fwd.hpp" // rank 9
+// admin/fwd.hpp is rank ∞ because it is an executable
+
namespace tmwa
{
diff --git a/src/admin/ladmin.cpp b/src/admin/ladmin.cpp
index 9dae089..e3557dd 100644
--- a/src/admin/ladmin.cpp
+++ b/src/admin/ladmin.cpp
@@ -35,23 +35,27 @@
#include "../strings/vstring.hpp"
#include "../io/cxxstdio.hpp"
+#include "../io/extract.hpp"
#include "../io/read.hpp"
#include "../io/tty.hpp"
#include "../io/write.hpp"
#include "../net/ip.hpp"
-#include "../net/packets.hpp"
+#include "../net/timestamp-utils.hpp"
#include "../proto2/any-user.hpp"
#include "../proto2/login-admin.hpp"
#include "../mmo/config_parse.hpp"
-#include "../mmo/core.hpp"
#include "../mmo/human_time_diff.hpp"
-#include "../mmo/mmo.hpp"
-#include "../mmo/utils.hpp"
+#include "../high/mmo.hpp"
#include "../mmo/version.hpp"
+#include "../high/core.hpp"
+#include "../high/utils.hpp"
+
+#include "../wire/packets.hpp"
+
#include "../poison.hpp"
diff --git a/src/admin/main.cpp b/src/admin/main.cpp
index 1849d80..babf195 100644
--- a/src/admin/main.cpp
+++ b/src/admin/main.cpp
@@ -17,7 +17,7 @@
// 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 "../mmo/core.hpp"
+#include "../high/core.hpp"
#include "ladmin.hpp"
diff --git a/src/ast/fwd.hpp b/src/ast/fwd.hpp
index 77328c9..4ab4490 100644
--- a/src/ast/fwd.hpp
+++ b/src/ast/fwd.hpp
@@ -20,6 +20,12 @@
#include "../sanity.hpp"
+#include "../compat/fwd.hpp" // rank 2
+#include "../io/fwd.hpp" // rank 4
+#include "../net/fwd.hpp" // rank 5
+#include "../mmo/fwd.hpp" // rank 6
+#include "../high/fwd.hpp" // rank 9
+// ast/fwd.hpp is rank 10
namespace tmwa
{
diff --git a/src/ast/npc.cpp b/src/ast/npc.cpp
index 362943c..ca518d8 100644
--- a/src/ast/npc.cpp
+++ b/src/ast/npc.cpp
@@ -18,11 +18,14 @@
// 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 "../compat/memory.hpp"
+
#include "../io/cxxstdio.hpp"
+#include "../io/extract.hpp"
-#include "../mmo/extract.hpp"
+#include "../mmo/extract_enums.hpp"
-#include "../map/clif.hpp"
+#include "../high/extract_mmo.hpp"
#include "../poison.hpp"
diff --git a/src/ast/npc.hpp b/src/ast/npc.hpp
index e39a704..648b40b 100644
--- a/src/ast/npc.hpp
+++ b/src/ast/npc.hpp
@@ -20,12 +20,15 @@
#include "fwd.hpp"
+#include <memory>
+
#include "../compat/result.hpp"
+#include "../mmo/clif.t.hpp"
#include "../mmo/ids.hpp"
#include "../mmo/strs.hpp"
-#include "../map/map.hpp"
+#include "../net/timer.t.hpp"
#include "script.hpp"
diff --git a/src/char/char.cpp b/src/char/char.cpp
index 98a2178..0b166c2 100644
--- a/src/char/char.cpp
+++ b/src/char/char.cpp
@@ -49,13 +49,12 @@
#include "../generic/array.hpp"
#include "../io/cxxstdio.hpp"
-#include "../io/cxxstdio_enums.hpp"
+#include "../io/extract.hpp"
#include "../io/lock.hpp"
#include "../io/read.hpp"
#include "../io/tty.hpp"
#include "../io/write.hpp"
-#include "../net/packets.hpp"
#include "../net/socket.hpp"
#include "../net/timer.hpp"
@@ -66,14 +65,18 @@
#include "../proto2/char-user.hpp"
#include "../mmo/config_parse.hpp"
-#include "../mmo/core.hpp"
-#include "../mmo/extract.hpp"
+#include "../mmo/cxxstdio_enums.hpp"
#include "../mmo/extract_enums.hpp"
#include "../mmo/human_time_diff.hpp"
-#include "../mmo/mmo.hpp"
-#include "../mmo/utils.hpp"
#include "../mmo/version.hpp"
+#include "../high/core.hpp"
+#include "../high/extract_mmo.hpp"
+#include "../high/mmo.hpp"
+#include "../high/utils.hpp"
+
+#include "../wire/packets.hpp"
+
#include "inter.hpp"
#include "int_party.hpp"
#include "int_storage.hpp"
diff --git a/src/char/char.hpp b/src/char/char.hpp
index a9c786f..47d94d8 100644
--- a/src/char/char.hpp
+++ b/src/char/char.hpp
@@ -22,13 +22,11 @@
#include "fwd.hpp"
-#include "../strings/fwd.hpp"
-
#include "../generic/array.hpp"
#include "../net/ip.hpp"
-#include "../mmo/mmo.hpp"
+#include "../high/mmo.hpp"
namespace tmwa
diff --git a/src/char/fwd.hpp b/src/char/fwd.hpp
index 31cd1ba..ff2bf22 100644
--- a/src/char/fwd.hpp
+++ b/src/char/fwd.hpp
@@ -20,6 +20,17 @@
#include "../sanity.hpp"
+#include "../ints/fwd.hpp" // rank 1
+#include "../strings/fwd.hpp" // rank 1
+#include "../generic/fwd.hpp" // rank 3
+#include "../io/fwd.hpp" // rank 4
+#include "../net/fwd.hpp" // rank 5
+#include "../mmo/fwd.hpp" // rank 6
+#include "../proto2/fwd.hpp" // rank 8
+#include "../high/fwd.hpp" // rank 9
+#include "../wire/fwd.hpp" // rank 9
+// char/fwd.hpp is rank ∞ because it is an executable
+
namespace tmwa
{
diff --git a/src/char/int_party.cpp b/src/char/int_party.cpp
index 0ce827e..9a9dbd9 100644
--- a/src/char/int_party.cpp
+++ b/src/char/int_party.cpp
@@ -29,17 +29,19 @@
#include "../generic/db.hpp"
#include "../io/cxxstdio.hpp"
+#include "../io/extract.hpp"
#include "../io/lock.hpp"
#include "../io/read.hpp"
#include "../io/write.hpp"
-#include "../net/packets.hpp"
-
#include "../proto2/char-map.hpp"
-#include "../mmo/extract.hpp"
#include "../mmo/ids.hpp"
-#include "../mmo/mmo.hpp"
+
+#include "../high/extract_mmo.hpp"
+#include "../high/mmo.hpp"
+
+#include "../wire/packets.hpp"
#include "char.hpp"
#include "inter.hpp"
diff --git a/src/char/int_party.hpp b/src/char/int_party.hpp
index f33fc0d..79b3bd4 100644
--- a/src/char/int_party.hpp
+++ b/src/char/int_party.hpp
@@ -22,12 +22,6 @@
#include "fwd.hpp"
-#include "../strings/fwd.hpp"
-
-#include "../net/fwd.hpp"
-
-#include "../mmo/fwd.hpp"
-
namespace tmwa
{
diff --git a/src/char/int_storage.cpp b/src/char/int_storage.cpp
index a2b0bc7..c02f037 100644
--- a/src/char/int_storage.cpp
+++ b/src/char/int_storage.cpp
@@ -28,17 +28,19 @@
#include "../generic/db.hpp"
#include "../io/cxxstdio.hpp"
-#include "../io/cxxstdio_enums.hpp"
+#include "../io/extract.hpp"
#include "../io/lock.hpp"
#include "../io/read.hpp"
#include "../io/write.hpp"
-#include "../net/packets.hpp"
-
#include "../proto2/char-map.hpp"
-#include "../mmo/extract.hpp"
-#include "../mmo/mmo.hpp"
+#include "../mmo/cxxstdio_enums.hpp"
+
+#include "../high/extract_mmo.hpp"
+#include "../high/mmo.hpp"
+
+#include "../wire/packets.hpp"
#include "../poison.hpp"
diff --git a/src/char/int_storage.hpp b/src/char/int_storage.hpp
index 0a80027..c03ebff 100644
--- a/src/char/int_storage.hpp
+++ b/src/char/int_storage.hpp
@@ -22,14 +22,6 @@
#include "fwd.hpp"
-#include "../compat/fwd.hpp"
-
-#include "../strings/fwd.hpp"
-
-#include "../net/fwd.hpp"
-
-#include "../mmo/fwd.hpp"
-
namespace tmwa
{
diff --git a/src/char/inter.cpp b/src/char/inter.cpp
index 2efcc83..03d027a 100644
--- a/src/char/inter.cpp
+++ b/src/char/inter.cpp
@@ -34,16 +34,17 @@
#include "../generic/db.hpp"
#include "../io/cxxstdio.hpp"
+#include "../io/extract.hpp"
#include "../io/lock.hpp"
#include "../io/read.hpp"
#include "../io/write.hpp"
-#include "../net/packets.hpp"
-
#include "../proto2/char-map.hpp"
-#include "../mmo/extract.hpp"
-#include "../mmo/mmo.hpp"
+#include "../high/extract_mmo.hpp"
+#include "../high/mmo.hpp"
+
+#include "../wire/packets.hpp"
#include "char.hpp"
#include "int_party.hpp"
diff --git a/src/char/inter.hpp b/src/char/inter.hpp
index 19900f9..31d80b1 100644
--- a/src/char/inter.hpp
+++ b/src/char/inter.hpp
@@ -22,10 +22,6 @@
#include "fwd.hpp"
-#include "../strings/fwd.hpp"
-
-#include "../net/fwd.hpp"
-
namespace tmwa
{
diff --git a/src/char/main.cpp b/src/char/main.cpp
index 3648a74..7d6fee3 100644
--- a/src/char/main.cpp
+++ b/src/char/main.cpp
@@ -17,7 +17,7 @@
// 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 "../mmo/core.hpp"
+#include "../high/core.hpp"
#include "char.hpp"
diff --git a/src/compat/fwd.hpp b/src/compat/fwd.hpp
index c16e196..3fa0dd2 100644
--- a/src/compat/fwd.hpp
+++ b/src/compat/fwd.hpp
@@ -20,6 +20,10 @@
#include "../sanity.hpp"
+#include "../ints/fwd.hpp" // rank 1
+#include "../strings/fwd.hpp" // rank 1
+// compat/fwd.hpp is rank 2
+
namespace tmwa
{
@@ -33,5 +37,6 @@ namespace tmwa
template<class T>
class Borrowed;
+ struct TimeT;
// meh, add more when I feel like it
} // namespace tmwa
diff --git a/src/generic/operators.hpp b/src/compat/operators.hpp
index bb05765..bb05765 100644
--- a/src/generic/operators.hpp
+++ b/src/compat/operators.hpp
diff --git a/src/compat/rawmem.hpp b/src/compat/rawmem.hpp
index c271a56..66af204 100644
--- a/src/compat/rawmem.hpp
+++ b/src/compat/rawmem.hpp
@@ -22,6 +22,8 @@
#include <cstdint>
#include <cstring>
+#include <type_traits>
+
#include "fwd.hpp"
@@ -49,4 +51,23 @@ void really_memset0(uint8_t *dest, size_t n)
{
memset(dest, '\0', n);
}
+
+template<class T>
+struct is_trivially_copyable
+: std::integral_constant<bool,
+ // come back when GCC actually implements the public traits properly
+ __has_trivial_copy(T)
+ && __has_trivial_assign(T)
+ && __has_trivial_destructor(T)>
+{};
+
+template<class T>
+void really_memzero_this(T *v)
+{
+ static_assert(is_trivially_copyable<T>::value, "only for mostly-pod types");
+ static_assert(std::is_class<T>::value || std::is_union<T>::value, "Only for user-defined structures (for now)");
+ memset(v, '\0', sizeof(*v));
+}
+template<class T, size_t n>
+void really_memzero_this(T (&)[n]) = delete;
} // namespace tmwa
diff --git a/src/compat/time_t.hpp b/src/compat/time_t.hpp
index 9e7cf25..e9c97c4 100644
--- a/src/compat/time_t.hpp
+++ b/src/compat/time_t.hpp
@@ -20,10 +20,90 @@
#include "fwd.hpp"
-// TODO fix this ordering violation by promoting TimeT here
-#include "../mmo/utils.hpp"
+#include <ctime>
+
+#include "../ints/little.hpp"
+
+#include "operators.hpp"
namespace tmwa
{
+// Exists in place of time_t, to give it a predictable printf-format.
+// (on x86 and amd64, time_t == long, but not on x32)
+static_assert(sizeof(long long) >= sizeof(time_t), "long long >= time_t");
+struct TimeT : Comparable
+{
+ long long value;
+
+ // conversion
+ TimeT(time_t t=0) : value(t) {}
+ TimeT(struct tm t) : value(timegm(&t)) {}
+ operator time_t() const { return value; }
+ operator struct tm() const { time_t v = value; return *gmtime(&v); }
+
+ explicit operator bool() const { return value; }
+ bool operator !() const { return !value; }
+
+ // prevent surprises
+ template<class T>
+ TimeT(T) = delete;
+ template<class T>
+ operator T() const = delete;
+
+ static
+ TimeT now()
+ {
+ // poisoned, but this is still in header-land
+ return time(nullptr);
+ }
+
+ bool error() const
+ {
+ return value == -1;
+ }
+ bool okay() const
+ {
+ return !error();
+ }
+};
+
+inline
+long long convert_for_printf(TimeT t)
+{
+ return t.value;
+}
+
+// 2038 problem
+inline __attribute__((warn_unused_result))
+bool native_to_network(Little32 *net, TimeT nat)
+{
+ time_t tmp = nat;
+ return native_to_network(net, static_cast<uint32_t>(tmp));
+}
+
+inline __attribute__((warn_unused_result))
+bool network_to_native(TimeT *nat, Little32 net)
+{
+ uint32_t tmp;
+ bool rv = network_to_native(&tmp, net);
+ *nat = static_cast<time_t>(tmp);
+ return rv;
+}
+
+inline __attribute__((warn_unused_result))
+bool native_to_network(Little64 *net, TimeT nat)
+{
+ time_t tmp = nat;
+ return native_to_network(net, static_cast<uint64_t>(tmp));
+}
+
+inline __attribute__((warn_unused_result))
+bool network_to_native(TimeT *nat, Little64 net)
+{
+ uint64_t tmp;
+ bool rv = network_to_native(&tmp, net);
+ *nat = static_cast<time_t>(tmp);
+ return rv;
+}
} // namespace tmwa
diff --git a/src/generic/fwd.hpp b/src/generic/fwd.hpp
index 9c389b1..2517d62 100644
--- a/src/generic/fwd.hpp
+++ b/src/generic/fwd.hpp
@@ -20,6 +20,10 @@
#include "../sanity.hpp"
+#include "../strings/fwd.hpp" // rank 1
+#include "../compat/fwd.hpp" // rank 2
+// generic/fwd.hpp is rank 3
+
namespace tmwa
{
diff --git a/src/generic/md5.hpp b/src/generic/md5.hpp
index 50bc987..2f07789 100644
--- a/src/generic/md5.hpp
+++ b/src/generic/md5.hpp
@@ -24,7 +24,6 @@
#include <array>
-#include "../strings/fwd.hpp"
#include "../strings/vstring.hpp"
diff --git a/src/mmo/core.cpp b/src/high/core.cpp
index ff12f17..a45db18 100644
--- a/src/mmo/core.cpp
+++ b/src/high/core.cpp
@@ -153,8 +153,8 @@ int tmwa_main(int argc, char **argv)
// may wait too long in sendrecv
tick_t now = milli_clock::now();
interval_t next = do_timer(now);
- do_sendrecv(next);
- do_parsepacket();
+ runflag &= do_sendrecv(next);
+ runflag &= do_parsepacket();
}
return 0;
diff --git a/src/mmo/core.hpp b/src/high/core.hpp
index 259dd90..0ded246 100644
--- a/src/mmo/core.hpp
+++ b/src/high/core.hpp
@@ -24,8 +24,6 @@
#include "../range/slice.hpp"
-#include "../strings/fwd.hpp"
-
namespace tmwa
{
diff --git a/src/high/extract_mmo.cpp b/src/high/extract_mmo.cpp
new file mode 100644
index 0000000..a674656
--- /dev/null
+++ b/src/high/extract_mmo.cpp
@@ -0,0 +1,95 @@
+#include "extract_mmo.hpp"
+// extract_mmo.cpp - a simple, hierarchical, tokenizer
+//
+// Copyright © 2013 Ben Longbons <b.r.longbons@gmail.com>
+//
+// This file is part of The Mana World (Athena server)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// 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 <algorithm>
+
+#include "../io/extract.hpp"
+
+#include "../mmo/extract_enums.hpp"
+
+#include "mmo.hpp"
+
+#include "../poison.hpp"
+
+
+// TODO also pass an io::LineSpan around.
+namespace tmwa
+{
+bool extract(XString str, GlobalReg *var)
+{
+ return extract(str,
+ record<','>(&var->str, &var->value));
+}
+
+bool extract(XString str, Item *it)
+{
+ XString ignored;
+ XString corruption_hack_amount;
+ bool rv = extract(str,
+ record<',', 11>(
+ &ignored,
+ &it->nameid,
+ &corruption_hack_amount,
+ &it->equip,
+ &ignored,
+ &ignored,
+ &ignored,
+ &ignored,
+ &ignored,
+ &ignored,
+ &ignored,
+ &ignored));
+ if (rv)
+ {
+ if (corruption_hack_amount == "-1"_s)
+ it->amount = 0;
+ else
+ rv = extract(corruption_hack_amount, &it->amount);
+ }
+ return rv;
+}
+
+bool extract(XString str, MapName *m)
+{
+ XString::iterator it = std::find(str.begin(), str.end(), '.');
+ str = str.xislice_h(it);
+ VString<15> tmp;
+ bool rv = extract(str, &tmp);
+ *m = tmp;
+ return rv;
+}
+
+bool extract(XString str, CharName *out)
+{
+ VString<23> tmp;
+ if (extract(str, &tmp))
+ {
+ *out = CharName(tmp);
+ return true;
+ }
+ return false;
+}
+
+bool extract(XString str, NpcEvent *ev)
+{
+ XString mid;
+ return extract(str, record<':'>(&ev->npc, &mid, &ev->label)) && !mid;
+}
+} // namespace tmwa
diff --git a/src/high/extract_mmo.hpp b/src/high/extract_mmo.hpp
new file mode 100644
index 0000000..0c18090
--- /dev/null
+++ b/src/high/extract_mmo.hpp
@@ -0,0 +1,32 @@
+#pragma once
+// extract_mmo.hpp - a simple, hierarchical, tokenizer
+//
+// Copyright © 2012-2013 Ben Longbons <b.r.longbons@gmail.com>
+//
+// This file is part of The Mana World (Athena server)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// 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 "fwd.hpp"
+
+
+namespace tmwa
+{
+bool extract(XString str, GlobalReg *var);
+bool extract(XString str, Item *it);
+bool extract(XString str, MapName *m);
+bool extract(XString str, CharName *out);
+
+bool extract(XString str, NpcEvent *ev);
+} // namespace tmwa
diff --git a/src/high/fwd.hpp b/src/high/fwd.hpp
new file mode 100644
index 0000000..1a46b4b
--- /dev/null
+++ b/src/high/fwd.hpp
@@ -0,0 +1,39 @@
+#pragma once
+// high/fwd.hpp - list of type names for mmo lib
+//
+// Copyright © 2014 Ben Longbons <b.r.longbons@gmail.com>
+//
+// This file is part of The Mana World (Athena server)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// 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 "../sanity.hpp"
+
+#include "../range/fwd.hpp" // rank 1
+#include "../strings/fwd.hpp" // rank 1
+#include "../compat/fwd.hpp" // rank 2
+#include "../generic/fwd.hpp" // rank 3
+#include "../io/fwd.hpp" // rank 4
+#include "../net/fwd.hpp" // rank 5
+#include "../mmo/fwd.hpp" // rank 6
+#include "../proto2/fwd.hpp" // rank 8
+// high/fwd.hpp is rank 9
+
+
+namespace tmwa
+{
+class CharPair;
+class PartyPair;
+// meh, add more when I feel like it
+} // namespace tmwa
diff --git a/src/mmo/md5more.cpp b/src/high/md5more.cpp
index 4e5d2da..05149ac 100644
--- a/src/mmo/md5more.cpp
+++ b/src/high/md5more.cpp
@@ -31,7 +31,7 @@
#include "../net/ip.hpp"
-#include "../mmo/mmo.hpp"
+#include "mmo.hpp"
#include "../poison.hpp"
diff --git a/src/mmo/md5more.hpp b/src/high/md5more.hpp
index 7d50713..33ebe24 100644
--- a/src/mmo/md5more.hpp
+++ b/src/high/md5more.hpp
@@ -24,10 +24,6 @@
#include "../generic/md5.hpp"
-#include "../io/fwd.hpp"
-
-#include "../net/fwd.hpp"
-
namespace tmwa
{
diff --git a/src/mmo/mmo.hpp b/src/high/mmo.hpp
index b5bcac8..b5bcac8 100644
--- a/src/mmo/mmo.hpp
+++ b/src/high/mmo.hpp
diff --git a/src/mmo/utils.cpp b/src/high/utils.cpp
index f8aff2e..9b89c31 100644
--- a/src/mmo/utils.cpp
+++ b/src/high/utils.cpp
@@ -28,9 +28,7 @@
#include "../strings/xstring.hpp"
#include "../io/cxxstdio.hpp"
-#include "../io/write.hpp"
-
-#include "extract.hpp"
+#include "../io/extract.hpp"
#include "../poison.hpp"
@@ -85,39 +83,4 @@ int config_switch(ZString str)
FPRINTF(stderr, "Fatal: bad option value %s"_fmt, str);
abort();
}
-
-static_assert(sizeof(timestamp_seconds_buffer) == 20, "seconds buffer");
-static_assert(sizeof(timestamp_milliseconds_buffer) == 24, "millis buffer");
-
-void stamp_time(timestamp_seconds_buffer& out, const TimeT *t)
-{
- struct tm when = t ? *t : TimeT::now();
- char buf[20];
- strftime(buf, 20, "%Y-%m-%d %H:%M:%S", &when);
- out = stringish<timestamp_seconds_buffer>(VString<19>(strings::really_construct_from_a_pointer, buf));
-}
-void stamp_time(timestamp_milliseconds_buffer& out)
-{
- struct timeval tv;
- gettimeofday(&tv, nullptr);
- struct tm when = TimeT(tv.tv_sec);
- char buf[24];
- strftime(buf, 20, "%Y-%m-%d %H:%M:%S", &when);
- sprintf(buf + 19, ".%03d", static_cast<int>(tv.tv_usec / 1000));
- out = stringish<timestamp_milliseconds_buffer>(VString<23>(strings::really_construct_from_a_pointer, buf));
-}
-
-void log_with_timestamp(io::WriteFile& out, XString line)
-{
- if (!line)
- {
- out.put('\n');
- return;
- }
- timestamp_milliseconds_buffer tmpstr;
- stamp_time(tmpstr);
- out.really_put(tmpstr.data(), tmpstr.size());
- out.really_put(": ", 2);
- out.put_line(line);
-}
} // namespace tmwa
diff --git a/src/high/utils.hpp b/src/high/utils.hpp
new file mode 100644
index 0000000..c815e03
--- /dev/null
+++ b/src/high/utils.hpp
@@ -0,0 +1,29 @@
+#pragma once
+// utils.hpp - Useful stuff that hasn't been categorized.
+//
+// Copyright © ????-2004 Athena Dev Teams
+// Copyright © 2004-2011 The Mana World Development Team
+// Copyright © 2011-2014 Ben Longbons <b.r.longbons@gmail.com>
+//
+// This file is part of The Mana World (Athena server)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// 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 "fwd.hpp"
+
+namespace tmwa
+{
+bool e_mail_check(XString email);
+int config_switch(ZString str);
+} // namespace tmwa
diff --git a/src/ints/fwd.hpp b/src/ints/fwd.hpp
index a08e546..536eba1 100644
--- a/src/ints/fwd.hpp
+++ b/src/ints/fwd.hpp
@@ -20,6 +20,8 @@
#include "../sanity.hpp"
+// ints/fwd.hpp is rank 1
+
namespace tmwa
{
diff --git a/src/io/dir.hpp b/src/io/dir.hpp
index 071f309..f6fedbf 100644
--- a/src/io/dir.hpp
+++ b/src/io/dir.hpp
@@ -20,8 +20,6 @@
#include "fwd.hpp"
-#include "../strings/fwd.hpp"
-
#include "fd.hpp"
diff --git a/src/mmo/extract.cpp b/src/io/extract.cpp
index 9123237..55d3980 100644
--- a/src/mmo/extract.cpp
+++ b/src/io/extract.cpp
@@ -1,7 +1,7 @@
#include "extract.hpp"
// extract.cpp - a simple, hierarchical, tokenizer
//
-// Copyright © 2013 Ben Longbons <b.r.longbons@gmail.com>
+// Copyright © 2013-2014 Ben Longbons <b.r.longbons@gmail.com>
//
// This file is part of The Mana World (Athena server)
//
@@ -24,15 +24,10 @@
#include "../strings/xstring.hpp"
#include "../strings/vstring.hpp"
-#include "extract_enums.hpp"
-#include "mmo.hpp"
-
#include "../poison.hpp"
-// TODO move this whole file to io/ or something.
-// It needs to be lower in the include hierarchy so it can be implemented
-// for library types. Also it should pass an io::LineSpan around.
+// TODO also pass an io::LineSpan around.
namespace tmwa
{
bool extract(XString str, XString *rv)
@@ -53,61 +48,6 @@ bool extract(XString str, AString *rv)
return true;
}
-bool extract(XString str, GlobalReg *var)
-{
- return extract(str,
- record<','>(&var->str, &var->value));
-}
-
-bool extract(XString str, Item *it)
-{
- XString ignored;
- XString corruption_hack_amount;
- bool rv = extract(str,
- record<',', 11>(
- &ignored,
- &it->nameid,
- &corruption_hack_amount,
- &it->equip,
- &ignored,
- &ignored,
- &ignored,
- &ignored,
- &ignored,
- &ignored,
- &ignored,
- &ignored));
- if (rv)
- {
- if (corruption_hack_amount == "-1"_s)
- it->amount = 0;
- else
- rv = extract(corruption_hack_amount, &it->amount);
- }
- return rv;
-}
-
-bool extract(XString str, MapName *m)
-{
- XString::iterator it = std::find(str.begin(), str.end(), '.');
- str = str.xislice_h(it);
- VString<15> tmp;
- bool rv = extract(str, &tmp);
- *m = tmp;
- return rv;
-}
-
-bool extract(XString str, CharName *out)
-{
- VString<23> tmp;
- if (extract(str, &tmp))
- {
- *out = CharName(tmp);
- return true;
- }
- return false;
-}
-
bool extract(XString str, std::chrono::nanoseconds *ns)
{
std::chrono::nanoseconds::rep rep;
diff --git a/src/mmo/extract.hpp b/src/io/extract.hpp
index 152d1b7..174243e 100644
--- a/src/mmo/extract.hpp
+++ b/src/io/extract.hpp
@@ -31,9 +31,9 @@
#include "../strings/xstring.hpp"
-#include "../generic/enum.hpp"
+#include "../compat/time_t.hpp"
-#include "utils.hpp"
+#include "../generic/enum.hpp"
namespace tmwa
@@ -210,14 +210,6 @@ bool extract(XString str, VRecord<split, T> rec)
&& extract(str.xislice_t(s + 1), rec);
}
-bool extract(XString str, GlobalReg *var);
-
-bool extract(XString str, Item *it);
-
-bool extract(XString str, MapName *m);
-
-bool extract(XString str, CharName *out);
-
template<class T>
bool do_extract(XString str, T t)
{
diff --git a/src/mmo/extract_test.cpp b/src/io/extract_test.cpp
index 9c203ac..ee4cb08 100644
--- a/src/mmo/extract_test.cpp
+++ b/src/io/extract_test.cpp
@@ -22,7 +22,11 @@
#include "../strings/xstring.hpp"
-#include "mmo.hpp"
+#include "../net/timer.t.hpp"
+
+#include "../mmo/strs.hpp"
+
+#include "../high/extract_mmo.hpp"
#include "../poison.hpp"
diff --git a/src/io/fd.hpp b/src/io/fd.hpp
index d04d5bf..03a8b44 100644
--- a/src/io/fd.hpp
+++ b/src/io/fd.hpp
@@ -23,8 +23,6 @@
#include <sys/select.h>
#include <sys/socket.h>
-#include "../strings/fwd.hpp"
-
#include "../diagnostics.hpp"
diff --git a/src/io/fwd.hpp b/src/io/fwd.hpp
index deeb08c..99268f4 100644
--- a/src/io/fwd.hpp
+++ b/src/io/fwd.hpp
@@ -20,6 +20,12 @@
#include "../sanity.hpp"
+#include "../ints/fwd.hpp" // rank 1
+#include "../strings/fwd.hpp" // rank 1
+#include "../compat/fwd.hpp" // rank 2
+#include "../generic/fwd.hpp" // rank 3
+// io/fwd.hpp is rank 4
+
namespace tmwa
{
diff --git a/src/io/read.cpp b/src/io/read.cpp
index f3ed293..30620a1 100644
--- a/src/io/read.cpp
+++ b/src/io/read.cpp
@@ -25,7 +25,7 @@
#include "../strings/zstring.hpp"
#include "../strings/literal.hpp"
-#include "../io/cxxstdio.hpp"
+#include "cxxstdio.hpp"
#include "../poison.hpp"
diff --git a/src/io/read.hpp b/src/io/read.hpp
index 1ec26ca..c1c4882 100644
--- a/src/io/read.hpp
+++ b/src/io/read.hpp
@@ -20,8 +20,6 @@
#include "fwd.hpp"
-#include "../strings/fwd.hpp"
-
#include "dir.hpp"
#include "fd.hpp"
diff --git a/src/io/write.hpp b/src/io/write.hpp
index 1ab05f3..d7d3699 100644
--- a/src/io/write.hpp
+++ b/src/io/write.hpp
@@ -22,8 +22,6 @@
#include <cstdarg>
-#include "../strings/fwd.hpp"
-
#include "dir.hpp"
#include "fd.hpp"
diff --git a/src/login/fwd.hpp b/src/login/fwd.hpp
index 94fe3c0..8a2027b 100644
--- a/src/login/fwd.hpp
+++ b/src/login/fwd.hpp
@@ -20,6 +20,17 @@
#include "../sanity.hpp"
+#include "../ints/fwd.hpp" // rank 1
+#include "../strings/fwd.hpp" // rank 1
+#include "../generic/fwd.hpp" // rank 3
+#include "../io/fwd.hpp" // rank 4
+#include "../net/fwd.hpp" // rank 5
+#include "../mmo/fwd.hpp" // rank 6
+#include "../proto2/fwd.hpp" // rank 8
+#include "../high/fwd.hpp" // rank 9
+#include "../wire/fwd.hpp" // rank 9
+// login/fwd.hpp is rank ∞ because it is an executable
+
namespace tmwa
{
diff --git a/src/login/login.cpp b/src/login/login.cpp
index a84c96a..fa528ba 100644
--- a/src/login/login.cpp
+++ b/src/login/login.cpp
@@ -45,23 +45,18 @@
#include "../generic/random.hpp"
#include "../io/cxxstdio.hpp"
+#include "../io/extract.hpp"
#include "../io/lock.hpp"
#include "../io/read.hpp"
#include "../io/tty.hpp"
#include "../io/write.hpp"
-#include "../net/packets.hpp"
#include "../net/socket.hpp"
#include "../net/timer.hpp"
#include "../mmo/config_parse.hpp"
-#include "../mmo/core.hpp"
-#include "../mmo/extract.hpp"
#include "../mmo/human_time_diff.hpp"
#include "../mmo/ids.hpp"
-#include "../mmo/md5more.hpp"
-#include "../mmo/mmo.hpp"
-#include "../mmo/utils.hpp"
#include "../mmo/version.hpp"
#include "../proto2/any-user.hpp"
@@ -69,6 +64,14 @@
#include "../proto2/login-char.hpp"
#include "../proto2/login-user.hpp"
+#include "../high/core.hpp"
+#include "../high/extract_mmo.hpp"
+#include "../high/md5more.hpp"
+#include "../high/mmo.hpp"
+#include "../high/utils.hpp"
+
+#include "../wire/packets.hpp"
+
#include "../poison.hpp"
diff --git a/src/login/login.hpp b/src/login/login.hpp
index 5900440..88dd4ec 100644
--- a/src/login/login.hpp
+++ b/src/login/login.hpp
@@ -18,8 +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 "login.t.hpp"
-
#include "fwd.hpp"
diff --git a/src/login/main.cpp b/src/login/main.cpp
index 48a471a..4495bda 100644
--- a/src/login/main.cpp
+++ b/src/login/main.cpp
@@ -17,7 +17,7 @@
// 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 "../mmo/core.hpp"
+#include "../high/core.hpp"
#include "login.hpp"
diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp
index bf64473..d3e215f 100644
--- a/src/map/atcommand.cpp
+++ b/src/map/atcommand.cpp
@@ -37,23 +37,26 @@
#include "../generic/random.hpp"
#include "../io/cxxstdio.hpp"
-#include "../io/cxxstdio_enums.hpp"
+#include "../io/extract.hpp"
#include "../io/read.hpp"
#include "../io/write.hpp"
#include "../net/socket.hpp"
#include "../net/timer.hpp"
+#include "../net/timestamp-utils.hpp"
#include "../mmo/config_parse.hpp"
-#include "../mmo/core.hpp"
-#include "../mmo/extract.hpp"
+#include "../mmo/cxxstdio_enums.hpp"
#include "../mmo/extract_enums.hpp"
#include "../mmo/human_time_diff.hpp"
#include "../mmo/ids.hpp"
-#include "../mmo/mmo.hpp"
-#include "../mmo/utils.hpp"
#include "../mmo/version.hpp"
+#include "../high/core.hpp"
+#include "../high/extract_mmo.hpp"
+#include "../high/mmo.hpp"
+#include "../high/utils.hpp"
+
#include "battle.hpp"
#include "chrif.hpp"
#include "clif.hpp"
diff --git a/src/map/atcommand.hpp b/src/map/atcommand.hpp
index 4bf5277..745039d 100644
--- a/src/map/atcommand.hpp
+++ b/src/map/atcommand.hpp
@@ -22,14 +22,6 @@
#include "fwd.hpp"
-#include "../strings/fwd.hpp"
-
-#include "../generic/fwd.hpp"
-
-#include "../net/fwd.hpp"
-
-#include "../mmo/fwd.hpp"
-
namespace tmwa
{
diff --git a/src/map/battle.cpp b/src/map/battle.cpp
index ce10c5c..63dc957 100644
--- a/src/map/battle.cpp
+++ b/src/map/battle.cpp
@@ -32,10 +32,12 @@
#include "../generic/random.hpp"
#include "../io/cxxstdio.hpp"
-#include "../io/cxxstdio_enums.hpp"
#include "../io/read.hpp"
#include "../mmo/config_parse.hpp"
+#include "../mmo/cxxstdio_enums.hpp"
+
+#include "../high/utils.hpp"
#include "clif.hpp"
#include "itemdb.hpp"
diff --git a/src/map/battle.hpp b/src/map/battle.hpp
index 5f47b70..4a69b8e 100644
--- a/src/map/battle.hpp
+++ b/src/map/battle.hpp
@@ -24,15 +24,11 @@
#include "fwd.hpp"
-#include "../strings/fwd.hpp"
-
-#include "../generic/fwd.hpp"
-
#include "../net/timer.t.hpp"
-#include "clif.t.hpp"
+#include "../mmo/clif.t.hpp"
#include "map.t.hpp"
-#include "skill.t.hpp"
+#include "../mmo/skill.t.hpp"
namespace tmwa
diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp
index 090cccf..09c238c 100644
--- a/src/map/chrif.cpp
+++ b/src/map/chrif.cpp
@@ -29,15 +29,16 @@
#include "../io/cxxstdio.hpp"
#include "../net/ip.hpp"
-#include "../net/packets.hpp"
#include "../net/socket.hpp"
#include "../net/timer.hpp"
+#include "../net/timestamp-utils.hpp"
#include "../proto2/char-map.hpp"
#include "../mmo/human_time_diff.hpp"
-#include "../mmo/mmo.hpp"
-#include "../mmo/utils.hpp"
+#include "../high/mmo.hpp"
+
+#include "../wire/packets.hpp"
#include "battle.hpp"
#include "clif.hpp"
diff --git a/src/map/chrif.hpp b/src/map/chrif.hpp
index 4711bc5..4bd00aa 100644
--- a/src/map/chrif.hpp
+++ b/src/map/chrif.hpp
@@ -22,14 +22,6 @@
#include "fwd.hpp"
-#include "../strings/fwd.hpp"
-
-#include "../generic/fwd.hpp"
-
-#include "../net/fwd.hpp"
-
-#include "../mmo/fwd.hpp"
-
namespace tmwa
{
diff --git a/src/map/clif.cpp b/src/map/clif.cpp
index a5b7278..430d928 100644
--- a/src/map/clif.cpp
+++ b/src/map/clif.cpp
@@ -36,22 +36,25 @@
#include "../strings/xstring.hpp"
#include "../io/cxxstdio.hpp"
-#include "../io/cxxstdio_enums.hpp"
+#include "../io/extract.hpp"
#include "../io/write.hpp"
#include "../net/ip.hpp"
-#include "../net/packets.hpp"
#include "../net/socket.hpp"
#include "../net/timer.hpp"
+#include "../net/timestamp-utils.hpp"
#include "../proto2/any-user.hpp"
#include "../proto2/char-map.hpp"
#include "../proto2/map-user.hpp"
-#include "../mmo/md5more.hpp"
-#include "../mmo/utils.hpp"
+#include "../mmo/cxxstdio_enums.hpp"
#include "../mmo/version.hpp"
+#include "../high/md5more.hpp"
+
+#include "../wire/packets.hpp"
+
#include "atcommand.hpp"
#include "battle.hpp"
#include "chrif.hpp"
@@ -5675,38 +5678,4 @@ void do_init_clif(void)
{
make_listen_port(map_port, SessionParsers{.func_parse= clif_parse, .func_delete= clif_delete});
}
-
-bool extract(XString str, DIR *d)
-{
- unsigned di;
- if (extract(str, &di) && di < 8)
- {
- *d = static_cast<DIR>(di);
- return true;
- }
- const struct
- {
- LString str;
- DIR d;
- } dirs[] =
- {
- {"S"_s, DIR::S},
- {"SW"_s, DIR::SW},
- {"W"_s, DIR::W},
- {"NW"_s, DIR::NW},
- {"N"_s, DIR::N},
- {"NE"_s, DIR::NE},
- {"E"_s, DIR::E},
- {"SE"_s, DIR::SE},
- };
- for (auto& pair : dirs)
- {
- if (str == pair.str)
- {
- *d = pair.d;
- return true;
- }
- }
- return false;
-}
} // namespace tmwa
diff --git a/src/map/clif.hpp b/src/map/clif.hpp
index 9873592..24f4b80 100644
--- a/src/map/clif.hpp
+++ b/src/map/clif.hpp
@@ -20,25 +20,20 @@
// 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 "clif.t.hpp"
+#include "../mmo/clif.t.hpp"
#include "fwd.hpp"
#include <functional>
-#include "../strings/fwd.hpp"
-
-#include "../generic/fwd.hpp"
+#include "../high/mmo.hpp"
#include "../net/timer.t.hpp"
-#include "../mmo/fwd.hpp"
-#include "../mmo/mmo.hpp"
-
#include "battle.t.hpp"
#include "map.t.hpp"
#include "pc.t.hpp"
-#include "skill.t.hpp"
+#include "../mmo/skill.t.hpp"
namespace tmwa
@@ -189,6 +184,4 @@ int clif_GM_kick(dumb_ptr<map_session_data> sd, dumb_ptr<map_session_data> tsd,
int clif_foreachclient(std::function<void(dumb_ptr<map_session_data>)>);
void do_init_clif(void);
-
-bool extract(XString, DIR *);
} // namespace tmwa
diff --git a/src/map/fwd.hpp b/src/map/fwd.hpp
index 578b08a..f998b77 100644
--- a/src/map/fwd.hpp
+++ b/src/map/fwd.hpp
@@ -22,11 +22,24 @@
#include <cstdint>
+#include "../ints/fwd.hpp" // rank 1
+#include "../range/fwd.hpp" // rank 1
+#include "../strings/fwd.hpp" // rank 1
+#include "../compat/fwd.hpp" // rank 2
+#include "../generic/fwd.hpp" // rank 3
+#include "../io/fwd.hpp" // rank 4
+#include "../net/fwd.hpp" // rank 5
+#include "../sexpr/fwd.hpp" // rank 5
+#include "../mmo/fwd.hpp" // rank 6
+#include "../proto2/fwd.hpp" // rank 8
+#include "../high/fwd.hpp" // rank 9
+#include "../wire/fwd.hpp" // rank 9
+// map/fwd.hpp is rank ∞ because it is an executable
+
namespace tmwa
{
// meh, add more when I feel like it
-class BlockId;
struct block_list;
struct map_session_data;
struct npc_data;
@@ -38,11 +51,6 @@ class npc_data_script;
class npc_data_shop;
class npc_data_warp;
class npc_data_message;
-struct NpcEvent;
-struct MobName;
-struct NpcName;
-struct ScriptLabel;
-struct ItemName;
struct item_data;
diff --git a/src/map/grfio.cpp b/src/map/grfio.cpp
index 4a1656b..8821374 100644
--- a/src/map/grfio.cpp
+++ b/src/map/grfio.cpp
@@ -33,10 +33,11 @@
#include "../strings/zstring.hpp"
#include "../io/cxxstdio.hpp"
+#include "../io/extract.hpp"
#include "../io/read.hpp"
-#include "../mmo/extract.hpp"
-#include "../mmo/mmo.hpp"
+#include "../high/extract_mmo.hpp"
+#include "../high/mmo.hpp"
#include "../poison.hpp"
diff --git a/src/map/grfio.hpp b/src/map/grfio.hpp
index d2ab058..4cd4092 100644
--- a/src/map/grfio.hpp
+++ b/src/map/grfio.hpp
@@ -26,10 +26,6 @@
#include <vector>
-#include "../strings/fwd.hpp"
-
-#include "../mmo/fwd.hpp"
-
namespace tmwa
{
diff --git a/src/map/intif.cpp b/src/map/intif.cpp
index 6cc3772..c6821b6 100644
--- a/src/map/intif.cpp
+++ b/src/map/intif.cpp
@@ -29,13 +29,14 @@
#include "../io/cxxstdio.hpp"
-#include "../net/packets.hpp"
#include "../net/socket.hpp"
-#include "../mmo/mmo.hpp"
+#include "../high/mmo.hpp"
#include "../proto2/char-map.hpp"
+#include "../wire/packets.hpp"
+
#include "battle.hpp"
#include "chrif.hpp"
#include "clif.hpp"
diff --git a/src/map/intif.hpp b/src/map/intif.hpp
index 00f3c49..d51ca11 100644
--- a/src/map/intif.hpp
+++ b/src/map/intif.hpp
@@ -22,16 +22,6 @@
#include "fwd.hpp"
-#include "../compat/fwd.hpp"
-
-#include "../strings/fwd.hpp"
-
-#include "../generic/fwd.hpp"
-
-#include "../net/fwd.hpp"
-
-#include "../mmo/fwd.hpp"
-
namespace tmwa
{
diff --git a/src/map/itemdb.cpp b/src/map/itemdb.cpp
index 5ffa725..2e3d0c5 100644
--- a/src/map/itemdb.cpp
+++ b/src/map/itemdb.cpp
@@ -29,10 +29,10 @@
#include "../generic/db.hpp"
#include "../io/cxxstdio.hpp"
+#include "../io/extract.hpp"
#include "../io/read.hpp"
#include "../mmo/config_parse.hpp"
-#include "../mmo/extract.hpp"
#include "../mmo/extract_enums.hpp"
#include "script-parse.hpp"
diff --git a/src/map/itemdb.hpp b/src/map/itemdb.hpp
index fccfa23..fcc92c4 100644
--- a/src/map/itemdb.hpp
+++ b/src/map/itemdb.hpp
@@ -23,7 +23,7 @@
#include "fwd.hpp"
#include "../mmo/ids.hpp"
-#include "../mmo/mmo.hpp"
+#include "../high/mmo.hpp"
#include "map.t.hpp"
#include "script-buffer.hpp"
diff --git a/src/map/magic-expr.cpp b/src/map/magic-expr.cpp
index 4afa3bc..9cc4e33 100644
--- a/src/map/magic-expr.cpp
+++ b/src/map/magic-expr.cpp
@@ -33,7 +33,8 @@
#include "../generic/random.hpp"
#include "../io/cxxstdio.hpp"
-#include "../io/cxxstdio_enums.hpp"
+
+#include "../mmo/cxxstdio_enums.hpp"
#include "battle.hpp"
#include "itemdb.hpp"
diff --git a/src/map/magic-expr.hpp b/src/map/magic-expr.hpp
index 2a4b4be..8b88142 100644
--- a/src/map/magic-expr.hpp
+++ b/src/map/magic-expr.hpp
@@ -21,15 +21,9 @@
#include "fwd.hpp"
-#include "../generic/fwd.hpp"
-
-#include "../range/fwd.hpp"
-
#include "../strings/zstring.hpp"
#include "../strings/literal.hpp"
-#include "../mmo/fwd.hpp"
-
#include "magic-interpreter.t.hpp"
diff --git a/src/map/magic-interpreter-base.cpp b/src/map/magic-interpreter-base.cpp
index be9a61a..7fde979 100644
--- a/src/map/magic-interpreter-base.cpp
+++ b/src/map/magic-interpreter-base.cpp
@@ -25,7 +25,8 @@
#include "../strings/xstring.hpp"
#include "../io/cxxstdio.hpp"
-#include "../io/cxxstdio_enums.hpp"
+
+#include "../mmo/cxxstdio_enums.hpp"
#include "../net/timer.hpp"
diff --git a/src/map/magic-interpreter-base.hpp b/src/map/magic-interpreter-base.hpp
index 4bb41a0..2557ecb 100644
--- a/src/map/magic-interpreter-base.hpp
+++ b/src/map/magic-interpreter-base.hpp
@@ -21,12 +21,6 @@
#include "fwd.hpp"
-#include "../strings/fwd.hpp"
-
-#include "../generic/fwd.hpp"
-
-#include "../mmo/fwd.hpp"
-
namespace tmwa
{
diff --git a/src/map/magic-interpreter.hpp b/src/map/magic-interpreter.hpp
index 09642cb..547e294 100644
--- a/src/map/magic-interpreter.hpp
+++ b/src/map/magic-interpreter.hpp
@@ -27,21 +27,17 @@
#include <memory>
-#include "../strings/fwd.hpp"
#include "../strings/rstring.hpp"
-#include "../generic/fwd.hpp"
-
#include "../sexpr/variant.hpp"
#include "../net/timer.t.hpp"
#include "../mmo/ids.hpp"
-#include "../mmo/utils.hpp"
#include "map.hpp"
#include "script-buffer.hpp"
-#include "skill.t.hpp"
+#include "../mmo/skill.t.hpp"
namespace tmwa
diff --git a/src/map/magic-stmt.cpp b/src/map/magic-stmt.cpp
index b532ec8..d5e1a15 100644
--- a/src/map/magic-stmt.cpp
+++ b/src/map/magic-stmt.cpp
@@ -29,7 +29,8 @@
#include "../generic/random2.hpp"
#include "../io/cxxstdio.hpp"
-#include "../io/cxxstdio_enums.hpp"
+
+#include "../mmo/cxxstdio_enums.hpp"
#include "../net/timer.hpp"
diff --git a/src/map/magic-stmt.hpp b/src/map/magic-stmt.hpp
index 0385858..cdbd40f 100644
--- a/src/map/magic-stmt.hpp
+++ b/src/map/magic-stmt.hpp
@@ -21,13 +21,9 @@
#include "fwd.hpp"
-#include "../range/fwd.hpp"
-
#include "../strings/zstring.hpp"
-#include "../generic/fwd.hpp"
-
-#include "skill.t.hpp"
+#include "../mmo/skill.t.hpp"
namespace tmwa
diff --git a/src/map/magic.hpp b/src/map/magic.hpp
index a420872..8c1ef84 100644
--- a/src/map/magic.hpp
+++ b/src/map/magic.hpp
@@ -21,12 +21,8 @@
#include "fwd.hpp"
-#include "../strings/fwd.hpp"
-
-#include "../generic/fwd.hpp"
-
#include "map.t.hpp"
-#include "skill.t.hpp"
+#include "../mmo/skill.t.hpp"
namespace tmwa
diff --git a/src/map/main.cpp b/src/map/main.cpp
index c16f642..a54bb3f 100644
--- a/src/map/main.cpp
+++ b/src/map/main.cpp
@@ -17,7 +17,7 @@
// 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 "../mmo/core.hpp"
+#include "../high/core.hpp"
#include "map.hpp"
diff --git a/src/map/map.cpp b/src/map/map.cpp
index dbb54d6..9ae865f 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -45,20 +45,21 @@
#include "../generic/random2.hpp"
#include "../io/cxxstdio.hpp"
-#include "../io/cxxstdio_enums.hpp"
+#include "../io/extract.hpp"
#include "../io/read.hpp"
#include "../io/tty.hpp"
#include "../io/write.hpp"
#include "../net/socket.hpp"
#include "../net/timer.hpp"
+#include "../net/timestamp-utils.hpp"
#include "../mmo/config_parse.hpp"
-#include "../mmo/core.hpp"
-#include "../mmo/extract.hpp"
-#include "../mmo/utils.hpp"
+#include "../mmo/cxxstdio_enums.hpp"
#include "../mmo/version.hpp"
+#include "../high/core.hpp"
+
#include "atcommand.hpp"
#include "battle.hpp"
#include "chrif.hpp"
@@ -127,11 +128,6 @@ VString<49> convert_for_printf(NpcEvent ev)
{
return STRNPRINTF(50, "%s::%s"_fmt, ev.npc, ev.label);
}
-bool extract(XString str, NpcEvent *ev)
-{
- XString mid;
- return extract(str, record<':'>(&ev->npc, &mid, &ev->label)) && !mid;
-}
/*==========================================
* 全map鯖総計での接続数設定
diff --git a/src/map/map.hpp b/src/map/map.hpp
index cb4273f..183b74d 100644
--- a/src/map/map.hpp
+++ b/src/map/map.hpp
@@ -30,7 +30,6 @@
#include "../ints/udl.hpp"
-#include "../strings/fwd.hpp"
#include "../strings/rstring.hpp"
#include "../strings/astring.hpp"
#include "../strings/vstring.hpp"
@@ -42,15 +41,13 @@
#include "../net/socket.hpp"
#include "../net/timer.t.hpp"
-#include "../mmo/utils.hpp"
-
#include "battle.t.hpp"
-#include "clif.t.hpp"
+#include "../mmo/clif.t.hpp"
#include "mapflag.hpp"
#include "mob.t.hpp"
#include "script-buffer.hpp"
#include "script-persist.hpp"
-#include "skill.t.hpp"
+#include "../mmo/skill.t.hpp"
namespace tmwa
@@ -69,35 +66,6 @@ constexpr int MAX_DROP_PER_MAP = 48;
constexpr interval_t DEFAULT_AUTOSAVE_INTERVAL = 1_min;
-// formerly VString<49>, as name::label
-struct NpcEvent
-{
- NpcName npc;
- ScriptLabel label;
-
- explicit operator bool()
- {
- return npc || label;
- }
- bool operator !()
- {
- return !bool(*this);
- }
-
- friend bool operator == (const NpcEvent& l, const NpcEvent& r)
- {
- return l.npc == r.npc && l.label == r.label;
- }
-
- friend bool operator < (const NpcEvent& l, const NpcEvent& r)
- {
- return l.npc < r.npc || (l.npc == r.npc && l.label < r.label);
- }
-
- friend VString<49> convert_for_printf(NpcEvent ev);
-};
-bool extract(XString str, NpcEvent *ev);
-
extern map_local undefined_gat;
struct block_list
diff --git a/src/map/map.t.hpp b/src/map/map.t.hpp
index b475f9b..e8a62bc 100644
--- a/src/map/map.t.hpp
+++ b/src/map/map.t.hpp
@@ -29,7 +29,7 @@
#include "../generic/enum.hpp"
#include "../mmo/ids.hpp"
-#include "../mmo/mmo.hpp"
+#include "../high/mmo.hpp"
namespace tmwa
@@ -191,11 +191,6 @@ ENUM_BITWISE_OPERATORS(MapCell)
}
using e::MapCell;
-struct MobName : VString<23> {};
-struct NpcName : VString<23> {};
-struct ScriptLabel : VString<23> {};
-struct ItemName : VString<23> {};
-
inline
BlockId account_to_block(AccountId a) { return wrap<BlockId>(unwrap<AccountId>(a)); }
inline
diff --git a/src/map/mapflag.cpp b/src/map/mapflag.cpp
index be2ae67..91dfe8d 100644
--- a/src/map/mapflag.cpp
+++ b/src/map/mapflag.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 "../strings/xstring.hpp"
+
#include "../poison.hpp"
diff --git a/src/map/mapflag.hpp b/src/map/mapflag.hpp
index 6d046fa..d964405 100644
--- a/src/map/mapflag.hpp
+++ b/src/map/mapflag.hpp
@@ -22,8 +22,6 @@
#include <cstdint>
-#include "../mmo/extract.hpp" // TODO remove this (requires specializing the *other* half)
-
namespace tmwa
{
diff --git a/src/map/mob.cpp b/src/map/mob.cpp
index a2932d0..cab17a0 100644
--- a/src/map/mob.cpp
+++ b/src/map/mob.cpp
@@ -36,14 +36,14 @@
#include "../generic/random.hpp"
#include "../io/cxxstdio.hpp"
-#include "../io/cxxstdio_enums.hpp"
+#include "../io/extract.hpp"
#include "../io/read.hpp"
#include "../net/socket.hpp"
#include "../net/timer.hpp"
#include "../mmo/config_parse.hpp"
-#include "../mmo/extract.hpp"
+#include "../mmo/cxxstdio_enums.hpp"
#include "../mmo/extract_enums.hpp"
#include "battle.hpp"
diff --git a/src/map/mob.hpp b/src/map/mob.hpp
index c4fcce1..6f6fb47 100644
--- a/src/map/mob.hpp
+++ b/src/map/mob.hpp
@@ -24,16 +24,15 @@
#include "fwd.hpp"
-#include "../generic/fwd.hpp"
#include "../generic/enum.hpp"
#include "../generic/random.t.hpp"
#include "../net/timer.t.hpp"
#include "battle.t.hpp"
-#include "clif.t.hpp"
+#include "../mmo/clif.t.hpp"
#include "map.hpp"
-#include "skill.t.hpp"
+#include "../mmo/skill.t.hpp"
namespace tmwa
diff --git a/src/map/npc-internal.hpp b/src/map/npc-internal.hpp
index 65cef3d..4ddcc84 100644
--- a/src/map/npc-internal.hpp
+++ b/src/map/npc-internal.hpp
@@ -23,8 +23,6 @@
#include "npc.hpp"
#include "fwd.hpp"
-#include "../generic/fwd.hpp"
-
namespace tmwa
{
diff --git a/src/map/npc-parse.cpp b/src/map/npc-parse.cpp
index f5b6a07..81a5ba2 100644
--- a/src/map/npc-parse.cpp
+++ b/src/map/npc-parse.cpp
@@ -31,10 +31,13 @@
#include "../generic/enum.hpp"
#include "../io/cxxstdio.hpp"
+#include "../io/extract.hpp"
#include "../io/read.hpp"
#include "../mmo/config_parse.hpp"
+#include "../high/extract_mmo.hpp"
+
#include "battle.hpp"
#include "clif.hpp"
#include "itemdb.hpp"
diff --git a/src/map/npc-parse.hpp b/src/map/npc-parse.hpp
index 0d66aa7..a9cf300 100644
--- a/src/map/npc-parse.hpp
+++ b/src/map/npc-parse.hpp
@@ -22,14 +22,6 @@
#include "fwd.hpp"
-#include "../compat/fwd.hpp"
-
-#include "../generic/fwd.hpp"
-
-#include "../strings/fwd.hpp"
-
-#include "../mmo/fwd.hpp"
-
namespace tmwa
{
diff --git a/src/map/npc.cpp b/src/map/npc.cpp
index 471553b..304224a 100644
--- a/src/map/npc.cpp
+++ b/src/map/npc.cpp
@@ -38,12 +38,10 @@
#include "../generic/db.hpp"
#include "../io/cxxstdio.hpp"
+#include "../io/extract.hpp"
#include "../net/timer.hpp"
-#include "../mmo/extract.hpp"
-#include "../mmo/utils.hpp"
-
#include "../proto2/map-user.hpp"
#include "battle.hpp"
diff --git a/src/map/npc.hpp b/src/map/npc.hpp
index 67a62a9..cb42dbd 100644
--- a/src/map/npc.hpp
+++ b/src/map/npc.hpp
@@ -26,14 +26,8 @@
#include "../range/slice.hpp"
-#include "../strings/fwd.hpp"
-
-#include "../generic/fwd.hpp"
-
#include "../net/timer.t.hpp"
-#include "../proto2/fwd.hpp"
-
#include "map.hpp"
#include "script-call.t.hpp"
diff --git a/src/map/party.cpp b/src/map/party.cpp
index 45c406a..8150743 100644
--- a/src/map/party.cpp
+++ b/src/map/party.cpp
@@ -32,7 +32,7 @@
#include "../net/timer.hpp"
#include "../mmo/ids.hpp"
-#include "../mmo/mmo.hpp"
+#include "../high/mmo.hpp"
#include "battle.hpp"
#include "clif.hpp"
diff --git a/src/map/party.hpp b/src/map/party.hpp
index 466ee6a..a3f28e3 100644
--- a/src/map/party.hpp
+++ b/src/map/party.hpp
@@ -24,14 +24,6 @@
#include <functional>
-#include "../compat/fwd.hpp"
-
-#include "../strings/fwd.hpp"
-
-#include "../generic/fwd.hpp"
-
-#include "../mmo/fwd.hpp"
-
namespace tmwa
{
diff --git a/src/map/path.cpp b/src/map/path.cpp
index 7f9a657..3c05d52 100644
--- a/src/map/path.cpp
+++ b/src/map/path.cpp
@@ -31,7 +31,7 @@
#include "../io/cxxstdio.hpp"
-#include "clif.t.hpp"
+#include "../mmo/clif.t.hpp"
#include "map.hpp"
#include "../poison.hpp"
diff --git a/src/map/path.hpp b/src/map/path.hpp
index a588f1b..49dac7f 100644
--- a/src/map/path.hpp
+++ b/src/map/path.hpp
@@ -22,8 +22,6 @@
#include "fwd.hpp"
-#include "../compat/fwd.hpp"
-
namespace tmwa
{
diff --git a/src/map/pc.cpp b/src/map/pc.cpp
index 68d478e..1e7d295 100644
--- a/src/map/pc.cpp
+++ b/src/map/pc.cpp
@@ -37,12 +37,12 @@
#include "../generic/random.hpp"
#include "../io/cxxstdio.hpp"
-#include "../io/cxxstdio_enums.hpp"
#include "../io/read.hpp"
-#include "../net/timer.hpp"
+#include "../mmo/cxxstdio_enums.hpp"
-#include "../mmo/utils.hpp"
+#include "../net/timer.hpp"
+#include "../net/timestamp-utils.hpp"
#include "../proto2/char-map.hpp"
diff --git a/src/map/pc.hpp b/src/map/pc.hpp
index 605915e..9795443 100644
--- a/src/map/pc.hpp
+++ b/src/map/pc.hpp
@@ -24,15 +24,9 @@
#include "fwd.hpp"
-#include "../strings/fwd.hpp"
-
#include "../generic/dumb_ptr.hpp"
-#include "../mmo/utils.hpp"
-
-#include "../proto2/fwd.hpp"
-
-#include "clif.t.hpp"
+#include "../mmo/clif.t.hpp"
#include "map.hpp"
diff --git a/src/map/script-call.cpp b/src/map/script-call.cpp
index 6d3e6f2..8af5099 100644
--- a/src/map/script-call.cpp
+++ b/src/map/script-call.cpp
@@ -25,7 +25,8 @@
#include "../generic/intern-pool.hpp"
#include "../io/cxxstdio.hpp"
-#include "../io/cxxstdio_enums.hpp"
+
+#include "../mmo/cxxstdio_enums.hpp"
#include "battle.hpp"
#include "map.hpp"
diff --git a/src/map/script-call.hpp b/src/map/script-call.hpp
index 89cadb8..1a405b2 100644
--- a/src/map/script-call.hpp
+++ b/src/map/script-call.hpp
@@ -26,12 +26,6 @@
#include "../compat/borrow.hpp"
-#include "../range/fwd.hpp"
-
-#include "../generic/fwd.hpp"
-
-#include "../mmo/fwd.hpp"
-
namespace tmwa
{
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp
index 958b127..69aee10 100644
--- a/src/map/script-fun.cpp
+++ b/src/map/script-fun.cpp
@@ -33,10 +33,11 @@
#include "../net/timer.hpp"
-#include "../mmo/core.hpp"
-
#include "../proto2/net-HumanTimeDiff.hpp"
+#include "../high/core.hpp"
+#include "../high/extract_mmo.hpp"
+
#include "atcommand.hpp"
#include "battle.hpp"
#include "chrif.hpp"
diff --git a/src/map/script-parse-internal.hpp b/src/map/script-parse-internal.hpp
index f7e153b..89a35fd 100644
--- a/src/map/script-parse-internal.hpp
+++ b/src/map/script-parse-internal.hpp
@@ -23,8 +23,6 @@
#include "script-parse.hpp"
#include "fwd.hpp"
-#include "../compat/fwd.hpp"
-
#include "../strings/rstring.hpp"
diff --git a/src/map/script-parse.cpp b/src/map/script-parse.cpp
index e2cb4c6..7956831 100644
--- a/src/map/script-parse.cpp
+++ b/src/map/script-parse.cpp
@@ -30,7 +30,8 @@
#include "../strings/rstring.hpp"
#include "../io/cxxstdio.hpp"
-#include "../io/cxxstdio_enums.hpp"
+
+#include "../mmo/cxxstdio_enums.hpp"
#include "map.t.hpp"
#include "script-buffer.hpp"
diff --git a/src/map/script-parse.hpp b/src/map/script-parse.hpp
index 6f536f8..d1f824f 100644
--- a/src/map/script-parse.hpp
+++ b/src/map/script-parse.hpp
@@ -24,10 +24,6 @@
#include <memory>
-#include "../strings/fwd.hpp"
-
-#include "../generic/fwd.hpp"
-
namespace tmwa
{
diff --git a/src/map/script-startup-internal.hpp b/src/map/script-startup-internal.hpp
index e4d6a8f..0b2b0e1 100644
--- a/src/map/script-startup-internal.hpp
+++ b/src/map/script-startup-internal.hpp
@@ -23,10 +23,6 @@
#include "script-startup.hpp"
#include "fwd.hpp"
-#include "../generic/fwd.hpp"
-
-#include "../strings/fwd.hpp"
-
#include "script-persist.hpp"
diff --git a/src/map/script-startup.cpp b/src/map/script-startup.cpp
index 27ec903..7c77a27 100644
--- a/src/map/script-startup.cpp
+++ b/src/map/script-startup.cpp
@@ -28,13 +28,12 @@
#include "../generic/intern-pool.hpp"
#include "../io/cxxstdio.hpp"
+#include "../io/extract.hpp"
#include "../io/read.hpp"
#include "../io/lock.hpp"
#include "../net/timer.hpp"
-#include "../mmo/extract.hpp"
-
#include "map.hpp"
#include "script-parse-internal.hpp"
#include "script-persist.hpp"
diff --git a/src/map/script-startup.hpp b/src/map/script-startup.hpp
index 8a6b50d..3894676 100644
--- a/src/map/script-startup.hpp
+++ b/src/map/script-startup.hpp
@@ -22,8 +22,6 @@
#include "fwd.hpp"
-#include "../strings/fwd.hpp"
-
namespace tmwa
{
void do_init_script(void);
diff --git a/src/map/skill-pools.cpp b/src/map/skill-pools.cpp
index 89bf426..8ed03b8 100644
--- a/src/map/skill-pools.cpp
+++ b/src/map/skill-pools.cpp
@@ -21,7 +21,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "../io/cxxstdio.hpp"
-#include "../io/cxxstdio_enums.hpp"
+
+#include "../mmo/cxxstdio_enums.hpp"
#include "battle.hpp"
#include "pc.hpp"
diff --git a/src/map/skill.cpp b/src/map/skill.cpp
index 7c79e46..9889772 100644
--- a/src/map/skill.cpp
+++ b/src/map/skill.cpp
@@ -39,12 +39,12 @@
#include "../generic/random.hpp"
#include "../io/cxxstdio.hpp"
-#include "../io/cxxstdio_enums.hpp"
+#include "../io/extract.hpp"
#include "../io/read.hpp"
#include "../net/timer.hpp"
-#include "../mmo/extract.hpp"
+#include "../mmo/cxxstdio_enums.hpp"
#include "../mmo/extract_enums.hpp"
#include "battle.hpp"
diff --git a/src/map/skill.hpp b/src/map/skill.hpp
index 5d23bae..4e6fff0 100644
--- a/src/map/skill.hpp
+++ b/src/map/skill.hpp
@@ -20,17 +20,15 @@
// 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 "skill.t.hpp"
+#include "../mmo/skill.t.hpp"
#include "fwd.hpp"
#include "skill-pools.hpp"
-#include "../strings/fwd.hpp"
#include "../strings/rstring.hpp"
#include "../strings/literal.hpp"
-#include "../generic/fwd.hpp"
#include "../generic/array.hpp"
#include "map.hpp"
diff --git a/src/map/storage.cpp b/src/map/storage.cpp
index 295eff0..1a98d5b 100644
--- a/src/map/storage.cpp
+++ b/src/map/storage.cpp
@@ -25,7 +25,7 @@
#include "../generic/db.hpp"
#include "../mmo/ids.hpp"
-#include "../mmo/mmo.hpp"
+#include "../high/mmo.hpp"
#include "chrif.hpp"
#include "clif.hpp"
diff --git a/src/map/storage.hpp b/src/map/storage.hpp
index 59a8858..038df7d 100644
--- a/src/map/storage.hpp
+++ b/src/map/storage.hpp
@@ -22,15 +22,9 @@
#include "fwd.hpp"
-#include "../compat/fwd.hpp"
-
-#include "../generic/fwd.hpp"
-
-#include "../mmo/fwd.hpp"
-
#include "../proto2/net-Storage.hpp"
-#include "clif.t.hpp"
+#include "../mmo/clif.t.hpp"
namespace tmwa
diff --git a/src/map/tmw.cpp b/src/map/tmw.cpp
index 60b5027..04906b6 100644
--- a/src/map/tmw.cpp
+++ b/src/map/tmw.cpp
@@ -29,7 +29,6 @@
#include "../io/cxxstdio.hpp"
#include "../mmo/human_time_diff.hpp"
-#include "../mmo/utils.hpp"
#include "atcommand.hpp"
#include "battle.hpp"
diff --git a/src/map/tmw.hpp b/src/map/tmw.hpp
index ffd6f7f..7f0a57e 100644
--- a/src/map/tmw.hpp
+++ b/src/map/tmw.hpp
@@ -21,10 +21,6 @@
#include "fwd.hpp"
-#include "../strings/fwd.hpp"
-
-#include "../generic/fwd.hpp"
-
namespace tmwa
{
diff --git a/src/map/trade.hpp b/src/map/trade.hpp
index 91ed954..86bfc96 100644
--- a/src/map/trade.hpp
+++ b/src/map/trade.hpp
@@ -22,9 +22,7 @@
#include "fwd.hpp"
-#include "../generic/fwd.hpp"
-
-#include "clif.t.hpp"
+#include "../mmo/clif.t.hpp"
namespace tmwa
diff --git a/src/map/clif.t.hpp b/src/mmo/clif.t.hpp
index 0f8cdbf..0a51523 100644
--- a/src/map/clif.t.hpp
+++ b/src/mmo/clif.t.hpp
@@ -30,8 +30,8 @@
#include "../generic/enum.hpp"
-#include "../mmo/consts.hpp"
-#include "../mmo/enums.hpp"
+#include "consts.hpp"
+#include "enums.hpp"
namespace tmwa
diff --git a/src/mmo/config_parse.hpp b/src/mmo/config_parse.hpp
index 50a115e..db097e9 100644
--- a/src/mmo/config_parse.hpp
+++ b/src/mmo/config_parse.hpp
@@ -20,8 +20,6 @@
#include "fwd.hpp"
-#include "../strings/fwd.hpp"
-
namespace tmwa
{
diff --git a/src/io/cxxstdio_enums.hpp b/src/mmo/cxxstdio_enums.hpp
index 6f428e8..6f428e8 100644
--- a/src/io/cxxstdio_enums.hpp
+++ b/src/mmo/cxxstdio_enums.hpp
diff --git a/src/mmo/extract_enums.cpp b/src/mmo/extract_enums.cpp
new file mode 100644
index 0000000..ecf6940
--- /dev/null
+++ b/src/mmo/extract_enums.cpp
@@ -0,0 +1,59 @@
+#include "extract_enums.hpp"
+// extract_enums.cpp - Opt-in integer extraction support for enums.
+//
+// Copyright © 2014 Ben Longbons <b.r.longbons@gmail.com>
+//
+// This file is part of The Mana World (Athena server)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// 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 tmwa
+{
+bool extract(XString str, DIR *d)
+{
+ unsigned di;
+ if (extract(str, &di) && di < 8)
+ {
+ *d = static_cast<DIR>(di);
+ return true;
+ }
+ const struct
+ {
+ LString str;
+ DIR d;
+ } dirs[] =
+ {
+ {"S"_s, DIR::S},
+ {"SW"_s, DIR::SW},
+ {"W"_s, DIR::W},
+ {"NW"_s, DIR::NW},
+ {"N"_s, DIR::N},
+ {"NE"_s, DIR::NE},
+ {"E"_s, DIR::E},
+ {"SE"_s, DIR::SE},
+ };
+ for (auto& pair : dirs)
+ {
+ if (str == pair.str)
+ {
+ *d = pair.d;
+ return true;
+ }
+ }
+ return false;
+}
+} // namespace tmwa
diff --git a/src/mmo/extract_enums.hpp b/src/mmo/extract_enums.hpp
index 60ad493..96e5df7 100644
--- a/src/mmo/extract_enums.hpp
+++ b/src/mmo/extract_enums.hpp
@@ -22,7 +22,9 @@
#include <cstdint>
-#include "extract.hpp"
+#include "../io/extract.hpp"
+
+#include "clif.t.hpp"
namespace tmwa
@@ -66,4 +68,6 @@ inline
bool extract(XString str, SkillID *iv) { return extract_as_int(str, iv); }
inline
bool extract(XString str, StatusChange *iv) { return extract_as_int(str, iv); }
+
+bool extract(XString, DIR *);
} // namespace tmwa
diff --git a/src/mmo/fwd.hpp b/src/mmo/fwd.hpp
index 6612aab..f51767d 100644
--- a/src/mmo/fwd.hpp
+++ b/src/mmo/fwd.hpp
@@ -20,13 +20,20 @@
#include "../sanity.hpp"
+#include "../ints/fwd.hpp" // rank 1
+#include "../strings/fwd.hpp" // rank 1
+#include "../compat/fwd.hpp" // rank 2
+#include "../generic/fwd.hpp" // rank 3
+#include "../io/fwd.hpp" // rank 4
+#include "../net/fwd.hpp" // rank 5
+// mmo/fwd.hpp is rank 6
+
namespace tmwa
{
// meh, add more when I feel like it
class MapName;
class CharName;
-class CharPair;
class HumanTimeDiff;
@@ -48,22 +55,9 @@ class VarName;
class MapName;
class CharName;
-class Item;
-#if 0
-class Point;
-class SkillValue;
-#endif
-class GlobalReg;
-#if 0
-class CharKey;
-class CharData;
-class CharPair;
-#endif
-class Storage;
-#if 0
-class GM_Account;
-class PartyMember;
-#endif
-class PartyMost;
-class PartyPair;
+struct MobName;
+struct NpcName;
+struct ScriptLabel;
+struct ItemName;
+struct NpcEvent;
} // namespace tmwa
diff --git a/src/mmo/human_time_diff.cpp b/src/mmo/human_time_diff.cpp
new file mode 100644
index 0000000..e434773
--- /dev/null
+++ b/src/mmo/human_time_diff.cpp
@@ -0,0 +1,68 @@
+#include "human_time_diff.hpp"
+// human_time_diff.cpp - broken deltas
+//
+// Copyright © 2013 Ben Longbons <b.r.longbons@gmail.com>
+//
+// This file is part of The Mana World (Athena server)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// 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 "../io/extract.hpp"
+
+#include "../poison.hpp"
+
+
+namespace tmwa
+{
+bool extract(XString str, HumanTimeDiff *iv)
+{
+ // str is a sequence of [-+]?[0-9]+([ay]|m|[jd]|h|mn|s)
+ // there are NO spaces here
+ // parse by counting the number starts
+ auto is_num = [](char c)
+ { return c == '-' || c == '+' || ('0' <= c && c <= '9'); };
+ if (!str || !is_num(str.front()))
+ return false;
+ *iv = HumanTimeDiff{};
+ while (str)
+ {
+ auto it = std::find_if_not(str.begin(), str.end(), is_num);
+ auto it2 = std::find_if(it, str.end(), is_num);
+ XString number = str.xislice_h(it);
+ XString suffix = str.xislice(it, it2);
+ str = str.xislice_t(it2);
+
+ short *ptr = nullptr;
+ if (suffix == "y"_s || suffix == "a"_s)
+ ptr = &iv->year;
+ else if (suffix == "m"_s)
+ ptr = &iv->month;
+ else if (suffix == "j"_s || suffix == "d"_s)
+ ptr = &iv->day;
+ else if (suffix == "h"_s)
+ ptr = &iv->hour;
+ else if (suffix == "mn"_s)
+ ptr = &iv->minute;
+ else if (suffix == "s"_s)
+ ptr = &iv->second;
+ else
+ return false;
+ if (number.startswith('+') && !number.startswith("+-"_s))
+ number = number.xslice_t(1);
+ if (*ptr || !extract(number, ptr))
+ return false;
+ }
+ return true;
+}
+} // namespace tmwa
diff --git a/src/mmo/human_time_diff.hpp b/src/mmo/human_time_diff.hpp
index b5c19fb..40352d0 100644
--- a/src/mmo/human_time_diff.hpp
+++ b/src/mmo/human_time_diff.hpp
@@ -24,8 +24,6 @@
#include "../strings/xstring.hpp"
-#include "extract.hpp"
-
namespace tmwa
{
@@ -44,46 +42,5 @@ struct HumanTimeDiff
return !bool(*this);
}
};
-
-inline
-bool extract(XString str, HumanTimeDiff *iv)
-{
- // str is a sequence of [-+]?[0-9]+([ay]|m|[jd]|h|mn|s)
- // there are NO spaces here
- // parse by counting the number starts
- auto is_num = [](char c)
- { return c == '-' || c == '+' || ('0' <= c && c <= '9'); };
- if (!str || !is_num(str.front()))
- return false;
- *iv = HumanTimeDiff{};
- while (str)
- {
- auto it = std::find_if_not(str.begin(), str.end(), is_num);
- auto it2 = std::find_if(it, str.end(), is_num);
- XString number = str.xislice_h(it);
- XString suffix = str.xislice(it, it2);
- str = str.xislice_t(it2);
-
- short *ptr = nullptr;
- if (suffix == "y"_s || suffix == "a"_s)
- ptr = &iv->year;
- else if (suffix == "m"_s)
- ptr = &iv->month;
- else if (suffix == "j"_s || suffix == "d"_s)
- ptr = &iv->day;
- else if (suffix == "h"_s)
- ptr = &iv->hour;
- else if (suffix == "mn"_s)
- ptr = &iv->minute;
- else if (suffix == "s"_s)
- ptr = &iv->second;
- else
- return false;
- if (number.startswith('+') && !number.startswith("+-"_s))
- number = number.xslice_t(1);
- if (*ptr || !extract(number, ptr))
- return false;
- }
- return true;
-}
+bool extract(XString str, HumanTimeDiff *iv);
} // namespace tmwa
diff --git a/src/mmo/ids.cpp b/src/mmo/ids.cpp
new file mode 100644
index 0000000..9c013ba
--- /dev/null
+++ b/src/mmo/ids.cpp
@@ -0,0 +1,42 @@
+#include "ids.hpp"
+// ids.cpp - special integer classes for various object IDs
+//
+// Copyright © 2014 Ben Longbons <b.r.longbons@gmail.com>
+//
+// This file is part of The Mana World (Athena server)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// 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 "../io/extract.hpp"
+
+#include "../poison.hpp"
+
+
+namespace tmwa
+{
+bool extract(XString str, Species *w)
+{
+ // lots of data files use this
+ if (str == "-1"_s)
+ {
+ *w = NEGATIVE_SPECIES;
+ return true;
+ }
+ return extract(str, &w->_value);
+}
+bool extract(XString str, GmLevel *lvl)
+{
+ return extract(str, &lvl->bits);
+}
+} // namespace tmwa
diff --git a/src/mmo/ids.hpp b/src/mmo/ids.hpp
index 4e2b97c..389f9e9 100644
--- a/src/mmo/ids.hpp
+++ b/src/mmo/ids.hpp
@@ -23,8 +23,6 @@
#include "../ints/little.hpp"
#include "../ints/wrap.hpp"
-#include "extract.hpp"
-
namespace tmwa
{
@@ -32,17 +30,7 @@ class Species : public Wrapped<uint16_t> { public: explicit operator bool() cons
constexpr Species NEGATIVE_SPECIES = Species();
-inline
-bool extract(XString str, Species *w)
-{
- // lots of data files use this
- if (str == "-1"_s)
- {
- *w = NEGATIVE_SPECIES;
- return true;
- }
- return extract(str, &w->_value);
-}
+bool extract(XString str, Species *w);
class AccountId : public Wrapped<uint32_t> { public: constexpr AccountId() : Wrapped<uint32_t>() {} protected: constexpr explicit AccountId(uint32_t a) : Wrapped<uint32_t>(a) {} };
@@ -53,11 +41,12 @@ class ItemNameId : public Wrapped<uint16_t> { public: constexpr ItemNameId() : W
class BlockId : public Wrapped<uint32_t> { public: constexpr BlockId() : Wrapped<uint32_t>() {} protected: constexpr explicit BlockId(uint32_t a) : Wrapped<uint32_t>(a) {} };
+bool extract(XString str, GmLevel *lvl);
class GmLevel
{
uint32_t bits;
- friend bool extract(XString str, GmLevel *lvl) { return extract(str, &lvl->bits); }
+ friend bool extract(XString str, GmLevel *lvl);
constexpr explicit
GmLevel(uint32_t b) : bits(b) {}
constexpr explicit
diff --git a/src/login/login.t.hpp b/src/mmo/login.t.hpp
index f2c775a..f2c775a 100644
--- a/src/login/login.t.hpp
+++ b/src/mmo/login.t.hpp
diff --git a/src/map/skill.t.hpp b/src/mmo/skill.t.hpp
index d0e3926..d0e3926 100644
--- a/src/map/skill.t.hpp
+++ b/src/mmo/skill.t.hpp
diff --git a/src/mmo/strs.hpp b/src/mmo/strs.hpp
index fea0c98..6a132c2 100644
--- a/src/mmo/strs.hpp
+++ b/src/mmo/strs.hpp
@@ -123,4 +123,37 @@ CharName stringish<CharName>(VString<23> iv)
{
return CharName(iv);
}
+
+struct MobName : VString<23> {};
+struct NpcName : VString<23> {};
+struct ScriptLabel : VString<23> {};
+struct ItemName : VString<23> {};
+
+// formerly VString<49>, as name::label
+struct NpcEvent
+{
+ NpcName npc;
+ ScriptLabel label;
+
+ explicit operator bool()
+ {
+ return npc || label;
+ }
+ bool operator !()
+ {
+ return !bool(*this);
+ }
+
+ friend bool operator == (const NpcEvent& l, const NpcEvent& r)
+ {
+ return l.npc == r.npc && l.label == r.label;
+ }
+
+ friend bool operator < (const NpcEvent& l, const NpcEvent& r)
+ {
+ return l.npc < r.npc || (l.npc == r.npc && l.label < r.label);
+ }
+
+ friend VString<49> convert_for_printf(NpcEvent ev);
+};
} // namespace tmwa
diff --git a/src/mmo/utils.hpp b/src/mmo/utils.hpp
deleted file mode 100644
index fc3ea74..0000000
--- a/src/mmo/utils.hpp
+++ /dev/null
@@ -1,167 +0,0 @@
-#pragma once
-// utils.hpp - Useful stuff that hasn't been categorized.
-//
-// Copyright © ????-2004 Athena Dev Teams
-// Copyright © 2004-2011 The Mana World Development Team
-// Copyright © 2011-2014 Ben Longbons <b.r.longbons@gmail.com>
-//
-// This file is part of The Mana World (Athena server)
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// 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 "fwd.hpp"
-
-#include <cstring>
-#include <ctime>
-
-#include <type_traits>
-
-#include "../ints/little.hpp"
-
-#include "../strings/fwd.hpp"
-#include "../strings/vstring.hpp"
-
-#include "../generic/operators.hpp"
-
-#include "../io/fwd.hpp"
-
-
-namespace tmwa
-{
-template<class T>
-struct is_trivially_copyable
-: std::integral_constant<bool,
- // come back when GCC actually implements the public traits properly
- __has_trivial_copy(T)
- && __has_trivial_assign(T)
- && __has_trivial_destructor(T)>
-{};
-
-bool e_mail_check(XString email);
-int config_switch (ZString str);
-
-template<class T>
-void really_memzero_this(T *v)
-{
- static_assert(is_trivially_copyable<T>::value, "only for mostly-pod types");
- static_assert(std::is_class<T>::value || std::is_union<T>::value, "Only for user-defined structures (for now)");
- memset(v, '\0', sizeof(*v));
-}
-template<class T, size_t n>
-void really_memzero_this(T (&)[n]) = delete;
-
-// Exists in place of time_t, to give it a predictable printf-format.
-// (on x86 and amd64, time_t == long, but not on x32)
-static_assert(sizeof(long long) >= sizeof(time_t), "long long >= time_t");
-struct TimeT : Comparable
-{
- long long value;
-
- // conversion
- TimeT(time_t t=0) : value(t) {}
- TimeT(struct tm t) : value(timegm(&t)) {}
- operator time_t() const { return value; }
- operator struct tm() const { time_t v = value; return *gmtime(&v); }
-
- explicit operator bool() const { return value; }
- bool operator !() const { return !value; }
-
- // prevent surprises
- template<class T>
- TimeT(T) = delete;
- template<class T>
- operator T() const = delete;
-
- static
- TimeT now()
- {
- // poisoned, but this is still in header-land
- return time(nullptr);
- }
-
- bool error() const
- {
- return value == -1;
- }
- bool okay() const
- {
- return !error();
- }
-};
-
-inline
-long long convert_for_printf(TimeT t)
-{
- return t.value;
-}
-
-// 2038 problem
-inline __attribute__((warn_unused_result))
-bool native_to_network(Little32 *net, TimeT nat)
-{
- time_t tmp = nat;
- return native_to_network(net, static_cast<uint32_t>(tmp));
-}
-
-inline __attribute__((warn_unused_result))
-bool network_to_native(TimeT *nat, Little32 net)
-{
- uint32_t tmp;
- bool rv = network_to_native(&tmp, net);
- *nat = static_cast<time_t>(tmp);
- return rv;
-}
-
-inline __attribute__((warn_unused_result))
-bool native_to_network(Little64 *net, TimeT nat)
-{
- time_t tmp = nat;
- return native_to_network(net, static_cast<uint64_t>(tmp));
-}
-
-inline __attribute__((warn_unused_result))
-bool network_to_native(TimeT *nat, Little64 net)
-{
- uint64_t tmp;
- bool rv = network_to_native(&tmp, net);
- *nat = static_cast<time_t>(tmp);
- return rv;
-}
-
-
-struct timestamp_seconds_buffer : VString<19> {};
-struct timestamp_milliseconds_buffer : VString<23> {};
-void stamp_time(timestamp_seconds_buffer&, const TimeT *t=nullptr);
-void stamp_time(timestamp_milliseconds_buffer&);
-
-void log_with_timestamp(io::WriteFile& out, XString line);
-
-// TODO VString?
-#define TIMESTAMP_DUMMY "YYYY-MM-DD HH:MM:SS"
-static_assert(sizeof(TIMESTAMP_DUMMY) == sizeof(timestamp_seconds_buffer),
- "timestamp size");
-#define WITH_TIMESTAMP(str) str TIMESTAMP_DUMMY
-// str: prefix: YYYY-MM-DD HH:MM:SS
-// sizeof: 01234567890123456789012345678
-// str + sizeof: ^
-// -1: ^
-// there's probably a better way to do this now
-#define REPLACE_TIMESTAMP(str, t) \
- stamp_time( \
- reinterpret_cast<timestamp_seconds_buffer *>( \
- str + sizeof(str) \
- )[-1], \
- &t \
- )
-} // namespace tmwa
diff --git a/src/mmo/version.cpp b/src/mmo/version.cpp
index 7c63614..56e21dc 100644
--- a/src/mmo/version.cpp
+++ b/src/mmo/version.cpp
@@ -24,7 +24,7 @@
#include "../strings/xstring.hpp"
-#include "extract.hpp"
+#include "../io/extract.hpp"
#include "../poison.hpp"
diff --git a/src/mmo/version.hpp b/src/mmo/version.hpp
index 6afcd58..1eed223 100644
--- a/src/mmo/version.hpp
+++ b/src/mmo/version.hpp
@@ -24,8 +24,6 @@
#include <cstdint>
-#include "../strings/fwd.hpp"
-
namespace tmwa
{
diff --git a/src/monitor/main.cpp b/src/monitor/main.cpp
index ec1139a..c27cf77 100644
--- a/src/monitor/main.cpp
+++ b/src/monitor/main.cpp
@@ -37,7 +37,8 @@
#include "../io/read.hpp"
#include "../mmo/config_parse.hpp"
-#include "../mmo/utils.hpp"
+
+#include "../net/timestamp-utils.hpp"
#include "../poison.hpp"
diff --git a/src/net/fwd.hpp b/src/net/fwd.hpp
index 2097772..5de8450 100644
--- a/src/net/fwd.hpp
+++ b/src/net/fwd.hpp
@@ -20,6 +20,13 @@
#include "../sanity.hpp"
+#include "../ints/fwd.hpp" // rank 1
+#include "../strings/fwd.hpp" // rank 1
+#include "../compat/fwd.hpp" // rank 2
+#include "../generic/fwd.hpp" // rank 3
+#include "../io/fwd.hpp" // rank 4
+// net/fwd.hpp is rank 5
+
namespace tmwa
{
@@ -28,6 +35,4 @@ class Session;
class IP4Address;
class TimerData;
-
-enum class RecvResult;
} // namespace tmwa
diff --git a/src/net/ip.cpp b/src/net/ip.cpp
index bfc2028..4ec022b 100644
--- a/src/net/ip.cpp
+++ b/src/net/ip.cpp
@@ -22,8 +22,7 @@
#include "../strings/vstring.hpp"
#include "../io/cxxstdio.hpp"
-
-#include "../mmo/extract.hpp"
+#include "../io/extract.hpp"
#include "../poison.hpp"
diff --git a/src/net/ip.hpp b/src/net/ip.hpp
index e9e71f4..ab45c56 100644
--- a/src/net/ip.hpp
+++ b/src/net/ip.hpp
@@ -25,8 +25,6 @@
#include <cstddef>
#include <cstdint>
-#include "../strings/fwd.hpp"
-
namespace tmwa
{
diff --git a/src/net/socket.cpp b/src/net/socket.cpp
index a01cd81..fce45fb 100644
--- a/src/net/socket.cpp
+++ b/src/net/socket.cpp
@@ -34,10 +34,6 @@
#include "../io/cxxstdio.hpp"
-// TODO get rid of ordering violations
-#include "../mmo/utils.hpp"
-#include "../mmo/core.hpp"
-
#include "timer.hpp"
#include "../poison.hpp"
@@ -399,7 +395,7 @@ void realloc_fifo(Session *s, size_t rfifo_size, size_t wfifo_size)
}
}
-void do_sendrecv(interval_t next_ms)
+bool do_sendrecv(interval_t next_ms)
{
bool any = false;
io::FD_Set rfd = readfds, wfd;
@@ -419,9 +415,9 @@ void do_sendrecv(interval_t next_ms)
{
PRINTF("Shutting down - nothing to do\n"_fmt);
// TODO hoist this
- runflag = false;
+ return false;
}
- return;
+ return true;
}
struct timeval timeout;
{
@@ -431,7 +427,7 @@ void do_sendrecv(interval_t next_ms)
timeout.tv_usec = next_us.count();
}
if (io::FD_Set::select(fd_max, &rfd, &wfd, nullptr, &timeout) <= 0)
- return;
+ return true;
for (io::FD i : iter_fds())
{
Session *s = get_session(i);
@@ -451,9 +447,10 @@ void do_sendrecv(interval_t next_ms)
s->func_recv(s);
}
}
+ return true;
}
-void do_parsepacket(void)
+bool do_parsepacket(void)
{
for (io::FD i : iter_fds())
{
@@ -483,5 +480,6 @@ void do_parsepacket(void)
/// Reclaim buffer space for what was read
RFIFOFLUSH(s);
}
+ return true;
}
} // namespace tmwa
diff --git a/src/net/socket.hpp b/src/net/socket.hpp
index 576ef85..d6caefd 100644
--- a/src/net/socket.hpp
+++ b/src/net/socket.hpp
@@ -22,20 +22,19 @@
#include "fwd.hpp"
-#include <algorithm>
-
#include <sys/select.h>
+#include <algorithm>
#include <memory>
-#include "../compat/iter.hpp"
-#include "../compat/rawmem.hpp"
-#include "../compat/time_t.hpp"
-
#include "../strings/astring.hpp"
#include "../strings/vstring.hpp"
#include "../strings/xstring.hpp"
+#include "../compat/iter.hpp"
+#include "../compat/rawmem.hpp"
+#include "../compat/time_t.hpp"
+
#include "../generic/dumb_ptr.hpp"
#include "../io/fd.hpp"
@@ -125,8 +124,8 @@ public:
io::FD fd;
- friend void do_sendrecv(interval_t next);
- friend void do_parsepacket(void);
+ friend bool do_sendrecv(interval_t next);
+ friend bool do_parsepacket(void);
friend void delete_session(Session *);
};
@@ -171,7 +170,7 @@ void delete_session(Session *);
/// Make a the internal queues bigger
void realloc_fifo(Session *s, size_t rfifo_size, size_t wfifo_size);
/// Update all sockets that can be read/written from the queues
-void do_sendrecv(interval_t next);
+bool do_sendrecv(interval_t next);
/// Call the parser function for every socket that has read data
-void do_parsepacket(void);
+bool do_parsepacket(void);
} // namespace tmwa
diff --git a/src/net/timer.hpp b/src/net/timer.hpp
index 338e339..5e7cc90 100644
--- a/src/net/timer.hpp
+++ b/src/net/timer.hpp
@@ -21,11 +21,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "timer.t.hpp"
-
#include "fwd.hpp"
-#include "../strings/fwd.hpp"
-
namespace tmwa
{
diff --git a/src/net/timestamp-utils.cpp b/src/net/timestamp-utils.cpp
new file mode 100644
index 0000000..b5873ca
--- /dev/null
+++ b/src/net/timestamp-utils.cpp
@@ -0,0 +1,72 @@
+#include "timestamp-utils.hpp"
+// timestamp-utils.cpp - Useful stuff that hasn't been categorized.
+//
+// Copyright © ????-2004 Athena Dev Teams
+// Copyright © 2004-2011 The Mana World Development Team
+// Copyright © 2011-2014 Ben Longbons <b.r.longbons@gmail.com>
+//
+// This file is part of The Mana World (Athena server)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// 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 <sys/time.h>
+
+#include <algorithm>
+
+#include "../strings/xstring.hpp"
+
+#include "../compat/time_t.hpp"
+
+#include "../io/write.hpp"
+
+#include "../poison.hpp"
+
+
+namespace tmwa
+{
+static_assert(sizeof(timestamp_seconds_buffer) == 20, "seconds buffer");
+static_assert(sizeof(timestamp_milliseconds_buffer) == 24, "millis buffer");
+
+void stamp_time(timestamp_seconds_buffer& out, const TimeT *t)
+{
+ struct tm when = t ? *t : TimeT::now();
+ char buf[20];
+ strftime(buf, 20, "%Y-%m-%d %H:%M:%S", &when);
+ out = stringish<timestamp_seconds_buffer>(VString<19>(strings::really_construct_from_a_pointer, buf));
+}
+void stamp_time(timestamp_milliseconds_buffer& out)
+{
+ struct timeval tv;
+ gettimeofday(&tv, nullptr);
+ struct tm when = TimeT(tv.tv_sec);
+ char buf[24];
+ strftime(buf, 20, "%Y-%m-%d %H:%M:%S", &when);
+ sprintf(buf + 19, ".%03d", static_cast<int>(tv.tv_usec / 1000));
+ out = stringish<timestamp_milliseconds_buffer>(VString<23>(strings::really_construct_from_a_pointer, buf));
+}
+
+void log_with_timestamp(io::WriteFile& out, XString line)
+{
+ if (!line)
+ {
+ out.put('\n');
+ return;
+ }
+ timestamp_milliseconds_buffer tmpstr;
+ stamp_time(tmpstr);
+ out.really_put(tmpstr.data(), tmpstr.size());
+ out.really_put(": ", 2);
+ out.put_line(line);
+}
+} // namespace tmwa
diff --git a/src/net/timestamp-utils.hpp b/src/net/timestamp-utils.hpp
new file mode 100644
index 0000000..f5b5dce
--- /dev/null
+++ b/src/net/timestamp-utils.hpp
@@ -0,0 +1,54 @@
+#pragma once
+// timestamp-utils.hpp - Useful stuff that hasn't been categorized.
+//
+// Copyright © ????-2004 Athena Dev Teams
+// Copyright © 2004-2011 The Mana World Development Team
+// Copyright © 2011-2014 Ben Longbons <b.r.longbons@gmail.com>
+//
+// This file is part of The Mana World (Athena server)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// 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 "fwd.hpp"
+
+#include "../strings/vstring.hpp"
+
+
+namespace tmwa
+{
+struct timestamp_seconds_buffer : VString<19> {};
+struct timestamp_milliseconds_buffer : VString<23> {};
+void stamp_time(timestamp_seconds_buffer&, const TimeT *t=nullptr);
+void stamp_time(timestamp_milliseconds_buffer&);
+
+void log_with_timestamp(io::WriteFile& out, XString line);
+
+// TODO VString?
+#define TIMESTAMP_DUMMY "YYYY-MM-DD HH:MM:SS"
+static_assert(sizeof(TIMESTAMP_DUMMY) == sizeof(timestamp_seconds_buffer),
+ "timestamp size");
+#define WITH_TIMESTAMP(str) str TIMESTAMP_DUMMY
+// str: prefix: YYYY-MM-DD HH:MM:SS
+// sizeof: 01234567890123456789012345678
+// str + sizeof: ^
+// -1: ^
+// there's probably a better way to do this now
+#define REPLACE_TIMESTAMP(str, t) \
+ stamp_time( \
+ reinterpret_cast<timestamp_seconds_buffer *>( \
+ str + sizeof(str) \
+ )[-1], \
+ &t \
+ )
+} // namespace tmwa
diff --git a/src/proto-base/fwd.hpp b/src/proto-base/fwd.hpp
index 560f7fc..1790717 100644
--- a/src/proto-base/fwd.hpp
+++ b/src/proto-base/fwd.hpp
@@ -20,6 +20,11 @@
#include "../sanity.hpp"
+#include "../strings/fwd.hpp" // rank 1
+#include "../generic/fwd.hpp" // rank 3
+#include "../mmo/fwd.hpp" // rank 6
+// proto-base/fwd.hpp is rank 7
+
namespace tmwa
{
diff --git a/src/range/fwd.hpp b/src/range/fwd.hpp
index 646eadb..4bad327 100644
--- a/src/range/fwd.hpp
+++ b/src/range/fwd.hpp
@@ -20,6 +20,8 @@
#include "../sanity.hpp"
+// range/fwd.hpp is rank 1
+
namespace tmwa
{
diff --git a/src/sexpr/fwd.hpp b/src/sexpr/fwd.hpp
index 580b322..41e21a1 100644
--- a/src/sexpr/fwd.hpp
+++ b/src/sexpr/fwd.hpp
@@ -20,6 +20,11 @@
#include "../sanity.hpp"
+#include "../strings/fwd.hpp" // rank 1
+#include "../compat/fwd.hpp" // rank 2
+#include "../io/fwd.hpp" // rank 4
+// sexpr/fwd.hpp is rank 5
+
namespace tmwa
{
diff --git a/src/sexpr/lexer.hpp b/src/sexpr/lexer.hpp
index 63be72d..744d8c5 100644
--- a/src/sexpr/lexer.hpp
+++ b/src/sexpr/lexer.hpp
@@ -22,7 +22,6 @@
#include <vector>
-#include "../strings/fwd.hpp"
#include "../strings/astring.hpp"
#include "../strings/zstring.hpp"
diff --git a/src/sexpr/parser.hpp b/src/sexpr/parser.hpp
index feed636..cfe8212 100644
--- a/src/sexpr/parser.hpp
+++ b/src/sexpr/parser.hpp
@@ -22,8 +22,6 @@
#include <cstdlib>
-#include "../strings/fwd.hpp"
-
#include "../io/line.hpp"
#include "lexer.hpp"
diff --git a/src/strings/astring.py b/src/strings/astring.py
index f4cbf66..a3306d9 100644
--- a/src/strings/astring.py
+++ b/src/strings/astring.py
@@ -25,7 +25,7 @@ class AString(object):
test_extra = '''
using tmwa::operator "" _s;
- #include "../src/strings/zstring.hpp"
+ #include "../strings/zstring.hpp"
'''
tests = [
diff --git a/src/strings/fwd.hpp b/src/strings/fwd.hpp
index b1b8266..29762f9 100644
--- a/src/strings/fwd.hpp
+++ b/src/strings/fwd.hpp
@@ -23,6 +23,8 @@
#include <cstddef>
#include <cstdint>
+// strings/fwd.hpp is rank 1
+
namespace tmwa
{
diff --git a/src/strings/rstring.py b/src/strings/rstring.py
index 61603d8..27e9ff2 100644
--- a/src/strings/rstring.py
+++ b/src/strings/rstring.py
@@ -31,7 +31,7 @@ class RString(object):
test_extra = '''
using tmwa::operator "" _s;
- #include "../src/strings/zstring.hpp"
+ #include "../strings/zstring.hpp"
'''
tests = [
diff --git a/src/tests/fwd.hpp b/src/tests/fwd.hpp
index 48627da..3ee52ff 100644
--- a/src/tests/fwd.hpp
+++ b/src/tests/fwd.hpp
@@ -20,6 +20,10 @@
#include "../sanity.hpp"
+#include "../strings/fwd.hpp" // rank 1
+#include "../io/fwd.hpp" // rank 4
+// tests/fwd.hpp is rank 5, but gtests do not require rank
+
namespace tmwa
{
diff --git a/src/wire/fwd.hpp b/src/wire/fwd.hpp
new file mode 100644
index 0000000..83d5b20
--- /dev/null
+++ b/src/wire/fwd.hpp
@@ -0,0 +1,34 @@
+#pragma once
+// wire/fwd.hpp - list of type names for network packets
+//
+// Copyright © 2014 Ben Longbons <b.r.longbons@gmail.com>
+//
+// This file is part of The Mana World (Athena server)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// 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 "../sanity.hpp"
+
+#include "../ints/fwd.hpp" // rank 1
+#include "../compat/fwd.hpp" // rank 2
+#include "../io/fwd.hpp" // rank 4
+#include "../net/fwd.hpp" // rank 5
+#include "../proto2/fwd.hpp" // rank 8
+// wire/fwd.hpp is rank 9
+
+namespace tmwa
+{
+enum class RecvResult;
+// meh, add more when I feel like it
+} // namespace tmwa
diff --git a/src/net/packets.cpp b/src/wire/packets.cpp
index 3cba856..3cba856 100644
--- a/src/net/packets.cpp
+++ b/src/wire/packets.cpp
diff --git a/src/net/packets.hpp b/src/wire/packets.hpp
index 5cc377c..a233344 100644
--- a/src/net/packets.hpp
+++ b/src/wire/packets.hpp
@@ -22,16 +22,13 @@
#include <vector>
-#include "../compat/cast.hpp"
-
#include "../ints/little.hpp"
-#include "../io/fwd.hpp"
+#include "../compat/cast.hpp"
-// TODO ordering violation, should invert
#include "../proto2/fwd.hpp"
-#include "socket.hpp"
+#include "../net/socket.hpp"
namespace tmwa
diff --git a/tools/protocol.py b/tools/protocol.py
index 7a4cbee..85266ae 100755
--- a/tools/protocol.py
+++ b/tools/protocol.py
@@ -161,6 +161,10 @@ class PolyFakeType(object):
for a in self.already:
a.add_headers_to(headers)
+ def dump_fwd(self, f):
+ for a in self.already:
+ a.dump_fwd(f)
+
def dump(self, f):
for a in self.already:
a.dump(f)
@@ -227,6 +231,10 @@ class EnumType(Type):
headers.update(self.native.includes)
headers.update(self.under.includes)
+ def dump_fwd(self, f):
+ # nothing to see here
+ pass
+
def dump(self, f):
native = self.native_tag()
under = self.under.native_tag()
@@ -272,6 +280,10 @@ class WrappedType(Type):
headers.update(self.native.includes)
headers.update(self.under.includes)
+ def dump_fwd(self, f):
+ # nothing to see here
+ pass
+
def dump(self, f):
native = self.native_tag()
under = self.under.native_tag()
@@ -311,6 +323,10 @@ class SkewLengthType(Type):
def network_tag(self):
return 'SkewedLength<%s, %d>' % (self.type.network_tag(), self.skew)
+ def dumpx_fwd(self, f):
+ # nothing to see here
+ pass
+
def dumpx(self):
# not registered properly, so the method name is wrong
# TODO remind myself to kill this code with fire before release
@@ -357,7 +373,9 @@ class StructType(Type):
def dump_fwd(self, fwd):
if self.id is not None:
fwd.write('template<>\n')
+ assert False
fwd.write('struct %s;\n' % self.name)
+ return
if self.id is not None:
fwd.write('template<>\n')
fwd.write('struct Net%s;\n' % self.name)
@@ -427,7 +445,7 @@ class PartialStructType(Type):
self.native = native
self.body = body
name = native.a_tag()
- self.includes = frozenset({'#include "../proto2/net-%s.hpp"\n' % name})
+ self.includes = frozenset({'#include "net-%s.hpp"\n' % name})
def __repr__(self):
return '<PartialStructType(%r) with %d fields>' % (self.native, len(self.body))
@@ -444,6 +462,10 @@ class PartialStructType(Type):
for n, t in self.body:
headers.update(t.includes)
+ def dump_fwd(self, f):
+ # nothing to see here
+ pass
+
def dump(self, f):
f.write('struct %s\n{\n' % self.network_tag())
for n, t in self.body:
@@ -517,7 +539,7 @@ class InvArrayType(Type):
self.count = count
self.includes = element.includes | {
'#include "../proto-base/net-array.hpp"\n',
- '#include "../map/clif.t.hpp"\n',
+ '#include "../mmo/clif.t.hpp"\n',
'#include "../mmo/consts.hpp"\n',
}
@@ -677,7 +699,7 @@ class Channel(object):
r = x
s = x
- def dump(self, outdir, fwd):
+ def dump(self, outdir):
server = self.server
client = self.client
header = '%s-%s.hpp' % (server, client)
@@ -705,9 +727,6 @@ class Channel(object):
f.write('// This is an internal protocol, and can be changed without notice\n')
f.write('\n')
for p in self.packets:
- p.dump_fwd(fwd)
- fwd.write('\n')
- for p in self.packets:
p.dump_native(f)
f.write('\n')
for p in self.packets:
@@ -769,13 +788,25 @@ class Context(object):
proto2 = relpath(outdir, 'src')
with OpenWrite(os.path.join(outdir, 'fwd.hpp')) as f:
header = '%s/fwd.hpp' % proto2
- desc = 'Forward declarations of network packets'
+ desc = 'Forward declarations of network packet body structs'
sanity = relpath('src/sanity.hpp', outdir)
+
f.write('#pragma once\n')
f.write(copyright.format(filename=header, description=desc))
f.write('\n')
+
f.write('#include "%s"\n\n' % sanity)
f.write('#include <cstdint>\n\n')
+
+ f.write('#include "../ints/fwd.hpp" // rank 1\n')
+ f.write('#include "../strings/fwd.hpp" // rank 1\n')
+ f.write('#include "../compat/fwd.hpp" // rank 2\n')
+ f.write('#include "../net/fwd.hpp" // rank 5\n')
+ f.write('#include "../mmo/fwd.hpp" // rank 6\n')
+ f.write('#include "../proto-base/fwd.hpp" // rank 7\n')
+ f.write('// proto2/fwd.hpp is rank 8\n')
+ f.write('\n\n')
+
f.write('namespace tmwa\n{\n')
for b in ['Fixed', 'Payload', 'Head', 'Repeat', 'Option']:
c = 'Packet_' + b
@@ -783,8 +814,12 @@ class Context(object):
f.write('template<uint16_t PACKET_ID> class Net%s;\n' % c)
f.write('\n')
+ for ty in self._types:
+ if not ty.do_dump:
+ continue
+ ty.dump_fwd(f)
for ch in self._channels:
- ch.dump(outdir, f)
+ ch.dump(outdir)
f.write('} // namespace tmwa\n')
@@ -890,6 +925,8 @@ def build_context():
vstring_h = ctx.include('src/strings/vstring.hpp')
+ timet_h = ctx.include('src/compat/time_t.hpp')
+
ip_h = ctx.include('src/net/ip.hpp')
timer_th = ctx.include('src/net/timer.t.hpp')
@@ -898,13 +935,13 @@ def build_context():
human_time_diff_h = ctx.include('src/mmo/human_time_diff.hpp')
ids_h = ctx.include('src/mmo/ids.hpp')
strs_h = ctx.include('src/mmo/strs.hpp')
- utils_h = ctx.include('src/mmo/utils.hpp')
+ utils_h = ctx.include('src/net/timestamp-utils.hpp')
version_h = ctx.include('src/mmo/version.hpp')
- login_th = ctx.include('src/login/login.t.hpp')
+ login_th = ctx.include('src/mmo/login.t.hpp')
- clif_th = ctx.include('src/map/clif.t.hpp')
- skill_th = ctx.include('src/map/skill.t.hpp')
+ clif_th = ctx.include('src/mmo/clif.t.hpp')
+ skill_th = ctx.include('src/mmo/skill.t.hpp')
## primitive types
char = NeutralType('char', None)
@@ -947,7 +984,7 @@ def build_context():
ip4 = ip_h.neutral('IP4Address')
- TimeT = utils_h.native('TimeT')
+ TimeT = timet_h.native('TimeT')
VString16 = vstring_h.native('VString<15>')
VString20 = vstring_h.native('VString<19>')