diff options
283 files changed, 1095 insertions, 20 deletions
diff --git a/Makefile.in b/Makefile.in index e2e3bca..a30f5d7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -461,6 +461,8 @@ obj/%.cpp.formatted: src/%.cpp tools/indenter fgrep -q Copyright $< fgrep -q $(notdir $<) $< fgrep -q ../poison.hpp $< + grep -q '^namespace tmwa$$' $< + grep -q '^} // namespace tmwa$$' $< touch $@ obj/%.hpp.formatted: src/%.hpp tools/indenter $(MKDIR_FIRST) @@ -469,11 +471,15 @@ obj/%.hpp.formatted: src/%.hpp tools/indenter fgrep -q $(notdir $<) $< if [[ $< == *fwd* ]]; then fgrep -q ../sanity.hpp $<; else fgrep -q '"fwd.hpp"' $<; fi if [[ $< == *fwd* ]]; then ! fgrep -q '"fwd.hpp"' $<; else ! fgrep -q ../sanity.hpp $<; fi + grep -q '^namespace tmwa$$' $< + grep -q '^} // namespace tmwa$$' $< touch $@ obj/%.tcc.formatted: src/%.tcc tools/indenter $(MKDIR_FIRST) apply-filter 'indenter -cpp' $< fgrep -q Copyright $< fgrep -q $(notdir $<) $< + grep -q '^namespace tmwa$$' $< + grep -q '^} // namespace tmwa$$' $< touch $@ .PHONY: format format-cpp format-hpp diff --git a/src/admin/fwd.hpp b/src/admin/fwd.hpp index f987625..4865106 100644 --- a/src/admin/fwd.hpp +++ b/src/admin/fwd.hpp @@ -21,6 +21,10 @@ # include "../sanity.hpp" + +namespace tmwa +{ // meh, add more when I feel like it +} // namespace tmwa #endif // TMWA_ADMIN_FWD_HPP diff --git a/src/admin/ladmin.cpp b/src/admin/ladmin.cpp index bab5a7c..fdd64f3 100644 --- a/src/admin/ladmin.cpp +++ b/src/admin/ladmin.cpp @@ -55,6 +55,8 @@ #include "../poison.hpp" +namespace tmwa +{ static int eathena_interactive_session; #define Iprintf if (eathena_interactive_session) PRINTF @@ -2975,3 +2977,4 @@ int do_init(Slice<ZString> argv) return 0; } +} // namespace tmwa diff --git a/src/admin/ladmin.hpp b/src/admin/ladmin.hpp index 06580eb..81ed1f2 100644 --- a/src/admin/ladmin.hpp +++ b/src/admin/ladmin.hpp @@ -21,4 +21,9 @@ # include "fwd.hpp" + +namespace tmwa +{ +} // namespace tmwa + #endif // TMWA_ADMIN_LADMIN_HPP diff --git a/src/admin/main.cpp b/src/admin/main.cpp index 56fd7b4..678286e 100644 --- a/src/admin/main.cpp +++ b/src/admin/main.cpp @@ -20,3 +20,8 @@ #include "ladmin.hpp" #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/char/char.cpp b/src/char/char.cpp index 3b0d43e..392943a 100644 --- a/src/char/char.cpp +++ b/src/char/char.cpp @@ -78,6 +78,9 @@ #include "../poison.hpp" + +namespace tmwa +{ static Array<struct mmo_map_server, MAX_MAP_SERVERS> server; static @@ -3156,3 +3159,4 @@ int do_init(Slice<ZString> argv) return 0; } +} // namespace tmwa diff --git a/src/char/char.hpp b/src/char/char.hpp index f8adeb9..ffd6f06 100644 --- a/src/char/char.hpp +++ b/src/char/char.hpp @@ -31,6 +31,9 @@ # include "../mmo/mmo.hpp" + +namespace tmwa +{ constexpr int MAX_MAP_SERVERS = 30; struct mmo_map_server @@ -51,5 +54,6 @@ void char_log(XString line); # define CHAR_LOG(fmt, ...) \ char_log(STRPRINTF(fmt, ## __VA_ARGS__)) +} // namespace tmwa #endif // TMWA_CHAR_CHAR_HPP diff --git a/src/char/fwd.hpp b/src/char/fwd.hpp index 4721cc2..04097a6 100644 --- a/src/char/fwd.hpp +++ b/src/char/fwd.hpp @@ -21,6 +21,10 @@ # include "../sanity.hpp" + +namespace tmwa +{ // meh, add more when I feel like it +} // namespace tmwa #endif // TMWA_CHAR_FWD_HPP diff --git a/src/char/int_party.cpp b/src/char/int_party.cpp index b86b3a4..fc6136b 100644 --- a/src/char/int_party.cpp +++ b/src/char/int_party.cpp @@ -46,6 +46,9 @@ #include "../poison.hpp" + +namespace tmwa +{ AString party_txt = "save/party.txt"_s; static @@ -843,3 +846,4 @@ void inter_party_leave(PartyId party_id, AccountId account_id) { mapif_parse_PartyLeave(nullptr, party_id, account_id); } +} // namespace tmwa diff --git a/src/char/int_party.hpp b/src/char/int_party.hpp index 1d8cadc..88ce05f 100644 --- a/src/char/int_party.hpp +++ b/src/char/int_party.hpp @@ -29,6 +29,9 @@ # include "../mmo/fwd.hpp" + +namespace tmwa +{ void inter_party_init(void); int inter_party_save(void); @@ -37,5 +40,6 @@ RecvResult inter_party_parse_frommap(Session *ms, uint16_t); void inter_party_leave(PartyId party_id, AccountId account_id); extern AString party_txt; +} // namespace tmwa #endif // TMWA_CHAR_INT_PARTY_HPP diff --git a/src/char/int_storage.cpp b/src/char/int_storage.cpp index 784347b..01665ec 100644 --- a/src/char/int_storage.cpp +++ b/src/char/int_storage.cpp @@ -41,6 +41,9 @@ #include "../poison.hpp" + +namespace tmwa +{ // ファイル名のデフォルト // inter_config_read()で再設定される AString storage_txt = "save/storage.txt"_s; @@ -269,3 +272,4 @@ RecvResult inter_storage_parse_frommap(Session *ms, uint16_t packet_id) } return rv; } +} // namespace tmwa diff --git a/src/char/int_storage.hpp b/src/char/int_storage.hpp index 6bf3e1f..e93be14 100644 --- a/src/char/int_storage.hpp +++ b/src/char/int_storage.hpp @@ -29,6 +29,9 @@ # include "../mmo/fwd.hpp" + +namespace tmwa +{ void inter_storage_init(void); int inter_storage_save(void); void inter_storage_delete(AccountId account_id); @@ -37,5 +40,6 @@ Storage *account2storage(AccountId account_id); RecvResult inter_storage_parse_frommap(Session *ms, uint16_t); extern AString storage_txt; +} // namespace tmwa #endif // TMWA_CHAR_INT_STORAGE_HPP diff --git a/src/char/inter.cpp b/src/char/inter.cpp index 354cba7..1cf41ff 100644 --- a/src/char/inter.cpp +++ b/src/char/inter.cpp @@ -51,6 +51,9 @@ #include "../poison.hpp" + +namespace tmwa +{ static AString accreg_txt = "save/accreg.txt"_s; @@ -484,3 +487,4 @@ RecvResult inter_parse_frommap(Session *ms, uint16_t packet_id) return rv; } +} // namespace tmwa diff --git a/src/char/inter.hpp b/src/char/inter.hpp index 9269017..ecfaf08 100644 --- a/src/char/inter.hpp +++ b/src/char/inter.hpp @@ -27,11 +27,15 @@ # include "../net/fwd.hpp" + +namespace tmwa +{ bool inter_config(XString key, ZString value); void inter_init2(); void inter_save(void); RecvResult inter_parse_frommap(Session *ms, uint16_t packet_id); extern int party_share_level; +} // namespace tmwa #endif // TMWA_CHAR_INTER_HPP diff --git a/src/char/main.cpp b/src/char/main.cpp index c2fd038..6636196 100644 --- a/src/char/main.cpp +++ b/src/char/main.cpp @@ -20,3 +20,8 @@ #include "char.hpp" #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/compat/attr.hpp b/src/compat/attr.hpp index 531e6b4..73fcfc4 100644 --- a/src/compat/attr.hpp +++ b/src/compat/attr.hpp @@ -22,10 +22,13 @@ # include "fwd.hpp" +namespace tmwa +{ # ifdef __clang__ # define FALLTHROUGH [[clang::fallthrough]] # else # define FALLTHROUGH /* fallthrough */ # endif +} // namespace tmwa #endif // TMWA_COMPAT_ATTR_HPP diff --git a/src/compat/cast.cpp b/src/compat/cast.cpp index 43c0b53..482529d 100644 --- a/src/compat/cast.cpp +++ b/src/compat/cast.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/compat/cast.hpp b/src/compat/cast.hpp index b237df4..38a8997 100644 --- a/src/compat/cast.hpp +++ b/src/compat/cast.hpp @@ -25,6 +25,8 @@ # include <type_traits> +namespace tmwa +{ template<class T> const T& const_(T& t) { @@ -68,5 +70,6 @@ typename std::remove_pointer<T>::type *sign_cast(U *u) static_assert(sizeof(T_) == sizeof(U), "sign cast must be same size"); return reinterpret_cast<T_ *>(u); } +} // namespace tmwa #endif // TMWA_COMPAT_CAST_HPP diff --git a/src/compat/fun.hpp b/src/compat/fun.hpp index 072bda0..53a0ed6 100644 --- a/src/compat/fun.hpp +++ b/src/compat/fun.hpp @@ -23,6 +23,10 @@ # include <functional> + +namespace tmwa +{ namespace ph = std::placeholders; +} // namespace tmwa #endif // TMWA_COMPAT_FUN_HPP diff --git a/src/compat/fwd.hpp b/src/compat/fwd.hpp index 46934b8..729b963 100644 --- a/src/compat/fwd.hpp +++ b/src/compat/fwd.hpp @@ -21,6 +21,10 @@ # include "../sanity.hpp" + +namespace tmwa +{ // meh, add more when I feel like it +} // namespace tmwa #endif // TMWA_COMPAT_FWD_HPP diff --git a/src/compat/iter.cpp b/src/compat/iter.cpp index f0ab0af..b6d6b63 100644 --- a/src/compat/iter.cpp +++ b/src/compat/iter.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/compat/iter.hpp b/src/compat/iter.hpp index 08c139e..7ed24da 100644 --- a/src/compat/iter.hpp +++ b/src/compat/iter.hpp @@ -24,6 +24,8 @@ # include <iterator> +namespace tmwa +{ /// Simple class to use a pair of iterators with foreach template<class It> class IteratorPair @@ -149,5 +151,6 @@ IteratorPair<FilterIterator<T, F, C>> filter_iterator(C *c, F f=is_truthy<T>) { return {FilterIterator<T, F, C>(c, f), FilterIterator<T, F, C>(c, f)}; } +} // namespace tmwa #endif // TMWA_COMPAT_ITER_HPP diff --git a/src/compat/iter_test.cpp b/src/compat/iter_test.cpp index f0e6031..71cc891 100644 --- a/src/compat/iter_test.cpp +++ b/src/compat/iter_test.cpp @@ -27,6 +27,8 @@ #include "../poison.hpp" +namespace tmwa +{ #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" TEST(iterpair, strings) @@ -158,3 +160,4 @@ TEST(iterpair, filter3) EXPECT_EQ(sum, 6); EXPECT_EQ(count, 3); } +} // namespace tmwa diff --git a/src/compat/memory.cpp b/src/compat/memory.cpp index 5db23b2..f9f2c22 100644 --- a/src/compat/memory.cpp +++ b/src/compat/memory.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/compat/memory.hpp b/src/compat/memory.hpp index 3a2af96..702951c 100644 --- a/src/compat/memory.hpp +++ b/src/compat/memory.hpp @@ -25,6 +25,8 @@ # include <type_traits> +namespace tmwa +{ template<class T> struct is_array_of_unknown_bound : std::is_same<T, typename std::remove_extent<T>::type[]> @@ -42,5 +44,6 @@ typename std::enable_if<is_array_of_unknown_bound<T>::value, std::unique_ptr<T, typedef typename std::remove_extent<T>::type E; return std::unique_ptr<E[], D>(new E[sz]()); } +} // namespace tmwa #endif // TMWA_COMPAT_MEMORY_HPP diff --git a/src/compat/nullpo.cpp b/src/compat/nullpo.cpp index a31cc34..bb80b27 100644 --- a/src/compat/nullpo.cpp +++ b/src/compat/nullpo.cpp @@ -24,6 +24,9 @@ #include "../poison.hpp" + +namespace tmwa +{ /// Actual output function static void nullpo_info(const char *file, int line, const char *func) @@ -46,3 +49,4 @@ bool nullpo_chk(const char *file, int line, const char *func, nullpo_info(file, line, func); return 1; } +} // namespace tmwa diff --git a/src/compat/nullpo.hpp b/src/compat/nullpo.hpp index 5de8ab6..6e12f78 100644 --- a/src/compat/nullpo.hpp +++ b/src/compat/nullpo.hpp @@ -45,6 +45,9 @@ # include "fwd.hpp" + +namespace tmwa +{ /// Used by macros in this header bool nullpo_chk(const char *file, int line, const char *func, const void *target); @@ -59,5 +62,6 @@ bool nullpo_chk(const char *file, int line, const char *func, T *target) { return nullpo_chk(file, line, func, static_cast<const void *>(target)); } +} // namespace tmwa #endif // TMWA_COMPAT_NULLPO_HPP diff --git a/src/compat/rawmem.cpp b/src/compat/rawmem.cpp index 74fdc0b..d322437 100644 --- a/src/compat/rawmem.cpp +++ b/src/compat/rawmem.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/compat/rawmem.hpp b/src/compat/rawmem.hpp index f030963..dd038be 100644 --- a/src/compat/rawmem.hpp +++ b/src/compat/rawmem.hpp @@ -25,6 +25,9 @@ # include "fwd.hpp" + +namespace tmwa +{ inline void really_memcpy(uint8_t *dest, const uint8_t *src, size_t n) { @@ -47,5 +50,6 @@ void really_memset0(uint8_t *dest, size_t n) { memset(dest, '\0', n); } +} // namespace tmwa #endif // TMWA_COMPAT_RAWMEM_HPP diff --git a/src/compat/time_t.cpp b/src/compat/time_t.cpp index b1a3fb8..ee0bbde 100644 --- a/src/compat/time_t.cpp +++ b/src/compat/time_t.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/compat/time_t.hpp b/src/compat/time_t.hpp index 4e0ffb6..60005d0 100644 --- a/src/compat/time_t.hpp +++ b/src/compat/time_t.hpp @@ -24,4 +24,9 @@ // TODO fix this ordering violation by promoting TimeT here # include "../mmo/utils.hpp" + +namespace tmwa +{ +} // namespace tmwa + #endif // TMWA_COMPAT_TIMET_HPP diff --git a/src/conf/version.hpp b/src/conf/version.hpp index 56c12e0..23c49a4 100644 --- a/src/conf/version.hpp +++ b/src/conf/version.hpp @@ -35,4 +35,9 @@ # include "conf-raw/str-VERSION_STRING.h" + +namespace tmwa +{ +} // namespace tmwa + #endif // TMWA_CONF_VERSION_HPP diff --git a/src/generic/array.cpp b/src/generic/array.cpp index 96c85ac..3063569 100644 --- a/src/generic/array.cpp +++ b/src/generic/array.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/generic/array.hpp b/src/generic/array.hpp index 5e4dd67..cf50dc8 100644 --- a/src/generic/array.hpp +++ b/src/generic/array.hpp @@ -26,6 +26,9 @@ # include "oops.hpp" + +namespace tmwa +{ template<class I, I be, I en> struct ExclusiveIndexing { @@ -113,5 +116,6 @@ public: template<class T, size_t n> using Array = GenericArray<T, SimpleIndexing<n>>; +} // namespace tmwa #endif // TMWA_GENERIC_ARRAY_HPP diff --git a/src/generic/array_test.cpp b/src/generic/array_test.cpp index a4d4d74..eb31523 100644 --- a/src/generic/array_test.cpp +++ b/src/generic/array_test.cpp @@ -23,6 +23,8 @@ #include "../poison.hpp" +namespace tmwa +{ #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" TEST(Array, simple) @@ -159,3 +161,4 @@ TEST(Array, enum) SUCCEED(); } } +} // namespace tmwa diff --git a/src/generic/db.cpp b/src/generic/db.cpp index b953ff0..458068c 100644 --- a/src/generic/db.cpp +++ b/src/generic/db.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/generic/db.hpp b/src/generic/db.hpp index 0eac890..3caac91 100644 --- a/src/generic/db.hpp +++ b/src/generic/db.hpp @@ -24,6 +24,9 @@ # include <map> # include <memory> + +namespace tmwa +{ template<class K, class V> class Map { @@ -176,5 +179,6 @@ public: return impl.size(); } }; +} // namespace tmwa #endif // TMWA_GENERIC_DB_HPP diff --git a/src/generic/dumb_ptr.cpp b/src/generic/dumb_ptr.cpp index 77e3080..e690f7d 100644 --- a/src/generic/dumb_ptr.cpp +++ b/src/generic/dumb_ptr.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/generic/dumb_ptr.hpp b/src/generic/dumb_ptr.hpp index ed18317..4d4473f 100644 --- a/src/generic/dumb_ptr.hpp +++ b/src/generic/dumb_ptr.hpp @@ -30,6 +30,9 @@ # include "../strings/zstring.hpp" # include "../strings/xstring.hpp" + +namespace tmwa +{ // unmanaged new/delete-able pointer // should be replaced by std::unique_ptr<T> template<class T> @@ -267,5 +270,6 @@ const char *convert_for_printf(dumb_string ds) { return ds.c_str(); } +} // namespace tmwa #endif // TMWA_GENERIC_DUMB_PTR_HPP diff --git a/src/generic/enum.cpp b/src/generic/enum.cpp index 8c54aba..49402e9 100644 --- a/src/generic/enum.cpp +++ b/src/generic/enum.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/generic/enum.hpp b/src/generic/enum.hpp index 1e83c24..2fe748d 100644 --- a/src/generic/enum.hpp +++ b/src/generic/enum.hpp @@ -31,6 +31,9 @@ # include "array.hpp" + +namespace tmwa +{ template<class T, class E, E max> using earray = GenericArray<T, EnumIndexing<E, max>>; @@ -156,5 +159,6 @@ IteratorPair<ValueIterator<E, EnumMath<E>>> erange(E b, E e) { return {b, e}; } +} // namespace tmwa #endif // TMWA_GENERIC_ENUM_HPP diff --git a/src/generic/fwd.hpp b/src/generic/fwd.hpp index fcb1fab..93d664c 100644 --- a/src/generic/fwd.hpp +++ b/src/generic/fwd.hpp @@ -21,9 +21,13 @@ # include "../sanity.hpp" + +namespace tmwa +{ // meh, add more when I feel like it template<class T> class dumb_ptr; class dumb_string; +} // namespace tmwa #endif // TMWA_GENERIC_FWD_HPP diff --git a/src/generic/intern-pool.cpp b/src/generic/intern-pool.cpp index f6df5a6..f45b098 100644 --- a/src/generic/intern-pool.cpp +++ b/src/generic/intern-pool.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/generic/intern-pool.hpp b/src/generic/intern-pool.hpp index 62a1d7f..e209b4b 100644 --- a/src/generic/intern-pool.hpp +++ b/src/generic/intern-pool.hpp @@ -31,6 +31,9 @@ # include "../strings/zstring.hpp" # include "../strings/xstring.hpp" + +namespace tmwa +{ class InternPool { std::map<RString, size_t> known; @@ -59,5 +62,6 @@ public: return known.size(); } }; +} // namespace tmwa #endif // TMWA_GENERIC_INTERN_POOL_HPP diff --git a/src/generic/intern-pool_test.cpp b/src/generic/intern-pool_test.cpp index 66490be..5858031 100644 --- a/src/generic/intern-pool_test.cpp +++ b/src/generic/intern-pool_test.cpp @@ -25,6 +25,8 @@ #include "../poison.hpp" +namespace tmwa +{ #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" TEST(InternPool, whydoesthisalwaysneedasecondname) @@ -41,3 +43,4 @@ TEST(InternPool, whydoesthisalwaysneedasecondname) EXPECT_EQ("hello"_s, p.outtern(0)); EXPECT_EQ("world"_s, p.outtern(1)); } +} // namespace tmwa diff --git a/src/generic/matrix.cpp b/src/generic/matrix.cpp index e1e1f5e..b14ab7d 100644 --- a/src/generic/matrix.cpp +++ b/src/generic/matrix.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/generic/matrix.hpp b/src/generic/matrix.hpp index fb18a4c..36be084 100644 --- a/src/generic/matrix.hpp +++ b/src/generic/matrix.hpp @@ -25,6 +25,9 @@ # include "../compat/memory.hpp" + +namespace tmwa +{ template<class T> class Matrix { @@ -74,5 +77,6 @@ public: return _ys; } }; +} // namespace tmwa #endif // TMWA_GENERIC_MATRIX_HPP diff --git a/src/generic/md5.cpp b/src/generic/md5.cpp index 38a605c..771ad0f 100644 --- a/src/generic/md5.cpp +++ b/src/generic/md5.cpp @@ -24,6 +24,9 @@ #include "../poison.hpp" + +namespace tmwa +{ // auxilary data /* sin() constant table @@ -245,3 +248,4 @@ MD5_state MD5_from_string(XString msg) } return state; } +} // namespace tmwa diff --git a/src/generic/md5.hpp b/src/generic/md5.hpp index fd23eca..fbe25d1 100644 --- a/src/generic/md5.hpp +++ b/src/generic/md5.hpp @@ -28,6 +28,9 @@ # include "../strings/fwd.hpp" # include "../strings/vstring.hpp" + +namespace tmwa +{ /// The digest state - becomes the output struct MD5_state { @@ -54,5 +57,6 @@ void MD5_to_str(MD5_state state, md5_string& out); // Convenience MD5_state MD5_from_string(XString msg); +} // namespace tmwa #endif // TMWA_GENERIC_MD5CALC_HPP diff --git a/src/generic/md5_test.cpp b/src/generic/md5_test.cpp index b7854c9..929e94f 100644 --- a/src/generic/md5_test.cpp +++ b/src/generic/md5_test.cpp @@ -26,6 +26,8 @@ #include "../poison.hpp" +namespace tmwa +{ #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" // This should be made part of the main API, @@ -49,3 +51,4 @@ TEST(md5calc, rfc1321) EXPECT_EQ("d174ab98d277d9f5a5611c2c9f419d9f"_s, MD5("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"_s)); EXPECT_EQ("57edf4a22be3c955ac49da2e2107b67a"_s, MD5("12345678901234567890123456789012345678901234567890123456789012345678901234567890"_s)); } +} // namespace tmwa diff --git a/src/generic/oops.cpp b/src/generic/oops.cpp index 95fdcad..601ab37 100644 --- a/src/generic/oops.cpp +++ b/src/generic/oops.cpp @@ -25,6 +25,8 @@ //#include "../poison.hpp" +namespace tmwa +{ static std::string do_asprintf(const char *desc, const char *expr, const char *file, size_t line, const char *function) @@ -43,3 +45,4 @@ AssertionError::AssertionError(const char *desc, const char *expr, const char *file, size_t line, const char *function) : std::runtime_error(do_asprintf(desc, expr, file, line, function)) {} +} // namespace tmwa diff --git a/src/generic/oops.hpp b/src/generic/oops.hpp index cc0cdcd..7c03e42 100644 --- a/src/generic/oops.hpp +++ b/src/generic/oops.hpp @@ -28,6 +28,8 @@ # include "oops.hpp" +namespace tmwa +{ class AssertionError : public std::runtime_error { public: @@ -38,5 +40,6 @@ public: # define ALLEGE(desc, expr) \ if (expr) {} \ else throw AssertionError(desc, #expr, __FILE__, __LINE__, __PRETTY_FUNCTION__) +} // namespace tmwa #endif // TMWA_GENERIC_OOPS_HPP diff --git a/src/generic/oops_test.cpp b/src/generic/oops_test.cpp index 13f7fac..e1a5381 100644 --- a/src/generic/oops_test.cpp +++ b/src/generic/oops_test.cpp @@ -23,6 +23,8 @@ #include "../poison.hpp" +namespace tmwa +{ #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" TEST(oops, okay) @@ -48,6 +50,7 @@ TEST(oops, uhoh) catch (const AssertionError& e) { ASSERT_STREQ(strstr(e.what(), "src/generic/"), - "src/generic/oops_test.cpp:45: error: in 'virtual void oops_uhoh_Test::TestBody()', incorrectly alleged that 'the sky is falling' (1 == 0)"); + "src/generic/oops_test.cpp:47: error: in 'virtual void tmwa::oops_uhoh_Test::TestBody()', incorrectly alleged that 'the sky is falling' (1 == 0)"); } } +} // namespace tmwa diff --git a/src/generic/operators.cpp b/src/generic/operators.cpp index 8d79e1b..614ae51 100644 --- a/src/generic/operators.cpp +++ b/src/generic/operators.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/generic/operators.hpp b/src/generic/operators.hpp index ca9311a..15246ef 100644 --- a/src/generic/operators.hpp +++ b/src/generic/operators.hpp @@ -21,6 +21,9 @@ # include "fwd.hpp" + +namespace tmwa +{ namespace _operators { class Comparable {}; @@ -63,5 +66,6 @@ namespace _operators } using _operators::Comparable; +} // namespace tmwa #endif // TMWA_GENERIC_OPERATORS_HPP diff --git a/src/generic/random.cpp b/src/generic/random.cpp index 8a06571..e37a3d1 100644 --- a/src/generic/random.cpp +++ b/src/generic/random.cpp @@ -20,7 +20,11 @@ #include "../poison.hpp" + +namespace tmwa +{ namespace random_ { std::mt19937 generate{std::random_device()()}; } // namespace random_ +} // namespace tmwa diff --git a/src/generic/random.hpp b/src/generic/random.hpp index 3b27b36..71883cc 100644 --- a/src/generic/random.hpp +++ b/src/generic/random.hpp @@ -25,6 +25,9 @@ # include <random> + +namespace tmwa +{ // This is not namespace random since that collides with a C function, // but this can be revisited when everything goes into namespace tmwa. namespace random_ @@ -83,5 +86,6 @@ namespace random_ return random_::choice(il); } } // namespace random_ +} // namespace tmwa #endif // TMWA_GENERIC_RANDOM_HPP diff --git a/src/generic/random.t.hpp b/src/generic/random.t.hpp index b20cb64..c68643a 100644 --- a/src/generic/random.t.hpp +++ b/src/generic/random.t.hpp @@ -21,6 +21,9 @@ # include "fwd.hpp" + +namespace tmwa +{ namespace random_ { struct Fraction @@ -39,5 +42,6 @@ namespace random_ } }; } // namespace random_ +} // namespace tmwa #endif // TMWA_GENERIC_RANDOM_T_HPP diff --git a/src/generic/random2.hpp b/src/generic/random2.hpp index 47e4222..1aee094 100644 --- a/src/generic/random2.hpp +++ b/src/generic/random2.hpp @@ -27,6 +27,9 @@ # include "../compat/iter.hpp" + +namespace tmwa +{ namespace random_ { namespace detail @@ -91,5 +94,6 @@ namespace random_ std::random_shuffle(c.begin(), c.end(), random_::to); } } // namespace random_ +} // namespace tmwa #endif // TMWA_GENERIC_RANDOM2_HPP diff --git a/src/ints/cmp.cpp b/src/ints/cmp.cpp index 60a8fad..94ff0e3 100644 --- a/src/ints/cmp.cpp +++ b/src/ints/cmp.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/ints/cmp.hpp b/src/ints/cmp.hpp index de6a5f2..8839899 100644 --- a/src/ints/cmp.hpp +++ b/src/ints/cmp.hpp @@ -23,6 +23,9 @@ # include <limits> + +namespace tmwa +{ namespace ints { # pragma GCC diagnostic push @@ -64,5 +67,6 @@ namespace ints } // namespace ints using ints::saturate; +} // namespace tmwa #endif // TMWA_INTS_CMP_HPP diff --git a/src/ints/cmp_test.cpp b/src/ints/cmp_test.cpp index bcff87d..be99544 100644 --- a/src/ints/cmp_test.cpp +++ b/src/ints/cmp_test.cpp @@ -25,6 +25,8 @@ #include "../poison.hpp" +namespace tmwa +{ #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" // Google Test is *really* slow to compile this file @@ -1462,3 +1464,4 @@ TEST(ints, satu64) EXPECT_EQ(maybe_cast<uint64_t>(+0xfffffffffffffffeULL), saturate<uint64_t>(maybe_cast<uint64_t>(+0xfffffffffffffffeULL))); EXPECT_EQ(maybe_cast<uint64_t>(+0xffffffffffffffffULL), saturate<uint64_t>(maybe_cast<uint64_t>(+0xffffffffffffffffULL))); } +} // namespace tmwa diff --git a/src/ints/fwd.hpp b/src/ints/fwd.hpp index 7685da5..650e859 100644 --- a/src/ints/fwd.hpp +++ b/src/ints/fwd.hpp @@ -21,6 +21,10 @@ # include "../sanity.hpp" + +namespace tmwa +{ // meh, add more when I feel like it +} // namespace tmwa #endif // TMWA_INTS_FWD_HPP diff --git a/src/ints/little.cpp b/src/ints/little.cpp index 2f81954..0ae5bf7 100644 --- a/src/ints/little.cpp +++ b/src/ints/little.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/ints/little.hpp b/src/ints/little.hpp index 9dd32c2..62bd729 100644 --- a/src/ints/little.hpp +++ b/src/ints/little.hpp @@ -25,6 +25,9 @@ # include <cstdint> + +namespace tmwa +{ // We implement our own actual swapping, because glibc emits assembly // instead of letting the *compiler* do what it does best. # if __BYTE_ORDER != __BIG_ENDIAN && __BYTE_ORDER != __LITTLE_ENDIAN @@ -135,5 +138,6 @@ using ints::Byte; using ints::Little16; using ints::Little32; using ints::Little64; +} // namespace tmwa #endif // TMWA_INTS_LITTLE_HPP diff --git a/src/ints/udl.cpp b/src/ints/udl.cpp index 87dac9c..3988903 100644 --- a/src/ints/udl.cpp +++ b/src/ints/udl.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/ints/udl.hpp b/src/ints/udl.hpp index caed16b..8d18766 100644 --- a/src/ints/udl.hpp +++ b/src/ints/udl.hpp @@ -25,6 +25,9 @@ # include <type_traits> + +namespace tmwa +{ namespace ints { namespace @@ -222,5 +225,6 @@ using ints::operator "" _n8; using ints::operator "" _n16; using ints::operator "" _n32; using ints::operator "" _n64; +} // namespace tmwa #endif // TMWA_INTS_UDL_HPP diff --git a/src/ints/udl_test.cpp b/src/ints/udl_test.cpp index 3fe01f5..b3ad30d 100644 --- a/src/ints/udl_test.cpp +++ b/src/ints/udl_test.cpp @@ -25,6 +25,8 @@ #include "../poison.hpp" +namespace tmwa +{ #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" #pragma GCC diagnostic push @@ -783,3 +785,4 @@ TEST(ints, udl64) EXPECT_EQ(+0X7FFFFFFFFFFFFFFE_p64, maybe_cast<int64_t>(0X7FFFFFFFFFFFFFFE)); EXPECT_EQ(+0X7FFFFFFFFFFFFFFF_p64, maybe_cast<int64_t>(0X7FFFFFFFFFFFFFFF)); } +} // namespace tmwa diff --git a/src/ints/wrap.cpp b/src/ints/wrap.cpp index a80bd9f..84d4b33 100644 --- a/src/ints/wrap.cpp +++ b/src/ints/wrap.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/ints/wrap.hpp b/src/ints/wrap.hpp index 71f2673..2573de5 100644 --- a/src/ints/wrap.hpp +++ b/src/ints/wrap.hpp @@ -25,6 +25,9 @@ # include <type_traits> + +namespace tmwa +{ namespace ints { namespace wrapped @@ -105,5 +108,6 @@ namespace ints using ints::wrapped::Wrapped; using ints::wrapped::unwrap; using ints::wrapped::wrap; +} // namespace tmwa #endif // TMWA_INTS_WRAP_HPP diff --git a/src/io/cxxstdio.cpp b/src/io/cxxstdio.cpp index 8b18701..ca4e880 100644 --- a/src/io/cxxstdio.cpp +++ b/src/io/cxxstdio.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/io/cxxstdio.hpp b/src/io/cxxstdio.hpp index fc5829f..6e49c11 100644 --- a/src/io/cxxstdio.hpp +++ b/src/io/cxxstdio.hpp @@ -29,6 +29,8 @@ # include "../generic/enum.hpp" +namespace tmwa +{ namespace cxxstdio { // other implementations of do_vprint are injected by ADL. @@ -187,5 +189,6 @@ namespace cxxstdio }) } // namespace cxxstdio +} // namespace tmwa #endif // TMWA_IO_CXXSTDIO_HPP diff --git a/src/io/fd.cpp b/src/io/fd.cpp index 4fc33e9..4c61a6f 100644 --- a/src/io/fd.cpp +++ b/src/io/fd.cpp @@ -25,6 +25,9 @@ #include "../poison.hpp" + +namespace tmwa +{ namespace io { FD FD::open(ZString path, int flags, int mode) @@ -163,3 +166,4 @@ namespace io timeout, sigmask); } } // namespace io +} // namespace tmwa diff --git a/src/io/fd.hpp b/src/io/fd.hpp index a7460a8..9ea4d41 100644 --- a/src/io/fd.hpp +++ b/src/io/fd.hpp @@ -27,6 +27,8 @@ # include "../strings/fwd.hpp" +namespace tmwa +{ namespace io { class FD @@ -162,5 +164,6 @@ namespace io int pselect(int nfds, FD_Set *readfds, FD_Set *writefds, FD_Set *exceptfds, const struct timespec *timeout, const sigset_t *sigmask); }; } // namespace io +} // namespace tmwa #endif // TMWA_IO_FD_HPP diff --git a/src/io/fwd.hpp b/src/io/fwd.hpp index 1e5fa82..2032c3b 100644 --- a/src/io/fwd.hpp +++ b/src/io/fwd.hpp @@ -22,11 +22,14 @@ # include "../sanity.hpp" +namespace tmwa +{ namespace io { class ReadFile; class WriteFile; class AppendFile; } // namespace io +} // namespace tmwa #endif // TMWA_IO_FWD_HPP diff --git a/src/io/line.cpp b/src/io/line.cpp index 4df29c8..a1cdf42 100644 --- a/src/io/line.cpp +++ b/src/io/line.cpp @@ -28,6 +28,8 @@ #include "../poison.hpp" +namespace tmwa +{ namespace io { AString Line::message_str(ZString cat, ZString msg) const @@ -178,3 +180,4 @@ namespace io return line != 0; } } // namespace io +} // namespace tmwa diff --git a/src/io/line.hpp b/src/io/line.hpp index 510a8f5..f481505 100644 --- a/src/io/line.hpp +++ b/src/io/line.hpp @@ -28,6 +28,8 @@ # include "read.hpp" +namespace tmwa +{ namespace io { // TODO split this out @@ -103,5 +105,6 @@ namespace io bool is_open(); }; } // namespace io +} // namespace tmwa #endif // TMWA_IO_LINE_HPP diff --git a/src/io/line_test.cpp b/src/io/line_test.cpp index d6efa67..9f04bf8 100644 --- a/src/io/line_test.cpp +++ b/src/io/line_test.cpp @@ -26,6 +26,8 @@ #include "../poison.hpp" +namespace tmwa +{ #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" static @@ -420,3 +422,4 @@ TEST(io, linespan) "~~~\n"_s ); } +} // namespace tmwa diff --git a/src/io/lock.cpp b/src/io/lock.cpp index e06c2f1..7b8f014 100644 --- a/src/io/lock.cpp +++ b/src/io/lock.cpp @@ -35,6 +35,8 @@ #include "../poison.hpp" +namespace tmwa +{ /// number of backups to keep static const int backup_count = 10; @@ -91,3 +93,4 @@ namespace io rename(tmpfile.c_str(), filename.c_str()); } } // namespace io +} // namespace tmwa diff --git a/src/io/lock.hpp b/src/io/lock.hpp index ec8a82e..e4ec153 100644 --- a/src/io/lock.hpp +++ b/src/io/lock.hpp @@ -26,6 +26,8 @@ # include "../strings/rstring.hpp" +namespace tmwa +{ namespace io { class WriteLock : public WriteFile @@ -38,5 +40,6 @@ namespace io bool close() = delete; }; } // namespace io +} // namespace tmwa #endif // TMWA_IO_LOCK_HPP diff --git a/src/io/read.cpp b/src/io/read.cpp index 803d486..d3e2a19 100644 --- a/src/io/read.cpp +++ b/src/io/read.cpp @@ -30,6 +30,8 @@ #include "../poison.hpp" +namespace tmwa +{ namespace io { ReadFile::ReadFile(FD f) @@ -120,3 +122,4 @@ namespace io return fd != FD(); } } // namespace io +} // namespace tmwa diff --git a/src/io/read.hpp b/src/io/read.hpp index 3816294..6757496 100644 --- a/src/io/read.hpp +++ b/src/io/read.hpp @@ -25,6 +25,8 @@ # include "fd.hpp" +namespace tmwa +{ namespace io { class ReadFile @@ -49,5 +51,6 @@ namespace io bool is_open(); }; } // namespace io +} // namespace tmwa #endif // TMWA_IO_READ_HPP diff --git a/src/io/read_test.cpp b/src/io/read_test.cpp index 8cf7d7a..6fc1563 100644 --- a/src/io/read_test.cpp +++ b/src/io/read_test.cpp @@ -27,6 +27,8 @@ #include "../poison.hpp" +namespace tmwa +{ #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" static @@ -87,3 +89,4 @@ TEST(io, read5) EXPECT_FALSE(hi); EXPECT_FALSE(rf.getline(hi)); } +} // namespace tmwa diff --git a/src/io/tty.cpp b/src/io/tty.cpp index e71ee44..c498740 100644 --- a/src/io/tty.cpp +++ b/src/io/tty.cpp @@ -20,4 +20,8 @@ #include "../poison.hpp" + +namespace tmwa +{ /* Nothing to see here, move along */ +} // namespace tmwa diff --git a/src/io/tty.hpp b/src/io/tty.hpp index b6eb227..86dc6d5 100644 --- a/src/io/tty.hpp +++ b/src/io/tty.hpp @@ -22,6 +22,8 @@ # include "fwd.hpp" +namespace tmwa +{ # define SGR_BLACK "\e[30m" # define SGR_RED "\e[31m" # define SGR_GREEN "\e[32m" @@ -34,5 +36,6 @@ # define SGR_BOLD "\e[1m" # define SGR_RESET "\e[0m" +} // namespace tmwa #endif // TMWA_IO_TTY_HPP diff --git a/src/io/write.cpp b/src/io/write.cpp index 18c4f9d..3326d2c 100644 --- a/src/io/write.cpp +++ b/src/io/write.cpp @@ -31,6 +31,8 @@ #include "../poison.hpp" +namespace tmwa +{ namespace io { WriteFile::WriteFile(FD f, bool linebuffered) @@ -177,3 +179,4 @@ namespace io return len; } } // namespace io +} // namespace tmwa diff --git a/src/io/write.hpp b/src/io/write.hpp index 1d67494..7e57841 100644 --- a/src/io/write.hpp +++ b/src/io/write.hpp @@ -27,6 +27,9 @@ # include "fd.hpp" + +namespace tmwa +{ namespace io { class WriteFile @@ -64,5 +67,6 @@ namespace io __attribute__((format(printf, 2, 0))) int do_vprint(WriteFile& out, const char *fmt, va_list ap); } // namespace io +} // namespace tmwa #endif // TMWA_IO_WRITE_HPP diff --git a/src/io/write_test.cpp b/src/io/write_test.cpp index ff2553a..7219c4b 100644 --- a/src/io/write_test.cpp +++ b/src/io/write_test.cpp @@ -31,6 +31,8 @@ #include "../poison.hpp" +namespace tmwa +{ #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" static @@ -104,3 +106,4 @@ TEST(io, write2) EXPECT_TRUE(wf.close()); EXPECT_EQ("XXX"_s, pw.slurp()); } +} // namespace tmwa diff --git a/src/login/fwd.hpp b/src/login/fwd.hpp index b2d2d24..ef0b6af 100644 --- a/src/login/fwd.hpp +++ b/src/login/fwd.hpp @@ -21,6 +21,10 @@ # include "../sanity.hpp" + +namespace tmwa +{ // meh, add more when I feel like it +} // namespace tmwa #endif // TMWA_LOGIN_FWD_HPP diff --git a/src/login/login.cpp b/src/login/login.cpp index be38b04..82ab89a 100644 --- a/src/login/login.cpp +++ b/src/login/login.cpp @@ -71,6 +71,9 @@ #include "../poison.hpp" + +namespace tmwa +{ constexpr int MAX_SERVERS = 30; constexpr AccountId START_ACCOUNT_NUM = wrap<AccountId>(2000000); @@ -3997,3 +4000,4 @@ int do_init(Slice<ZString> argv) return 0; } +} // namespace tmwa diff --git a/src/login/login.hpp b/src/login/login.hpp index dc817cc..e713d44 100644 --- a/src/login/login.hpp +++ b/src/login/login.hpp @@ -23,4 +23,9 @@ # include "login.t.hpp" + +namespace tmwa +{ +} // namespace tmwa + #endif // TMWA_LOGIN_LOGIN_HPP diff --git a/src/login/login.t.hpp b/src/login/login.t.hpp index b49fc4b..6de5c98 100644 --- a/src/login/login.t.hpp +++ b/src/login/login.t.hpp @@ -27,6 +27,9 @@ # include "../generic/enum.hpp" + +namespace tmwa +{ namespace e { enum class VERSION_2 : uint8_t @@ -39,5 +42,6 @@ enum class VERSION_2 : uint8_t ENUM_BITWISE_OPERATORS(VERSION_2) } using e::VERSION_2; +} // namespace tmwa #endif // TMWA_LOGIN_LOGIN_T_HPP diff --git a/src/login/main.cpp b/src/login/main.cpp index 857d493..b1eb8dd 100644 --- a/src/login/main.cpp +++ b/src/login/main.cpp @@ -20,3 +20,8 @@ #include "login.hpp" #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index 1b857f4..e6e321d 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -72,6 +72,8 @@ #include "../poison.hpp" +namespace tmwa +{ enum class ATCE { OKAY, @@ -5345,3 +5347,4 @@ Map<XString, AtCommandInfo> atcommand_info = 0, atcommand_source, "Legal information about source code (must be a level 0 command!)"_s}}, }; +} // namespace tmwa diff --git a/src/map/atcommand.hpp b/src/map/atcommand.hpp index a2aaf5b..16b17a3 100644 --- a/src/map/atcommand.hpp +++ b/src/map/atcommand.hpp @@ -31,6 +31,9 @@ # include "../mmo/fwd.hpp" + +namespace tmwa +{ bool is_atcommand(Session *s, dumb_ptr<map_session_data> sd, ZString message, GmLevel gmlvl); @@ -42,5 +45,6 @@ void log_atcommand(dumb_ptr<map_session_data> sd, ZString cmd); extern AString gm_log; void atcommand_config_write(ZString cfgName); +} // namespace tmwa #endif // TMWA_MAP_ATCOMMAND_HPP diff --git a/src/map/battle.cpp b/src/map/battle.cpp index 95826bb..5219675 100644 --- a/src/map/battle.cpp +++ b/src/map/battle.cpp @@ -47,6 +47,8 @@ #include "../poison.hpp" +namespace tmwa +{ static Battle_Config init_battle_config(); #pragma GCC diagnostic push @@ -2683,3 +2685,4 @@ void battle_config_check() battle_config.mask_ip_gms = 1; } } +} // namespace tmwa diff --git a/src/map/battle.hpp b/src/map/battle.hpp index 5bf7dde..c5e7d95 100644 --- a/src/map/battle.hpp +++ b/src/map/battle.hpp @@ -35,6 +35,9 @@ # include "map.t.hpp" # include "skill.t.hpp" + +namespace tmwa +{ // ダメージ struct Damage { @@ -223,5 +226,6 @@ extern struct Battle_Config bool battle_config_read(ZString cfgName); void battle_config_check(); +} // namespace tmwa #endif // TMWA_MAP_BATTLE_HPP diff --git a/src/map/battle.t.hpp b/src/map/battle.t.hpp index 09e2512..fad357d 100644 --- a/src/map/battle.t.hpp +++ b/src/map/battle.t.hpp @@ -27,6 +27,9 @@ # include "../generic/enum.hpp" + +namespace tmwa +{ namespace e { enum class BF : uint16_t @@ -239,5 +242,6 @@ earray<Races, Race, Race::COUNT> race_shift //= Races::boss, Races::other, }}; +} // namespace tmwa #endif // TMWA_MAP_BATTLE_T_HPP diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp index 18482f6..7c47ea7 100644 --- a/src/map/chrif.cpp +++ b/src/map/chrif.cpp @@ -51,6 +51,8 @@ #include "../poison.hpp" +namespace tmwa +{ Session *char_session; static IP4Address char_ip; @@ -1329,3 +1331,4 @@ void do_init_chrif(void) std::chrono::seconds(5) ).detach(); } +} // namespace tmwa diff --git a/src/map/chrif.hpp b/src/map/chrif.hpp index 321b3bd..27c1b50 100644 --- a/src/map/chrif.hpp +++ b/src/map/chrif.hpp @@ -31,6 +31,9 @@ # include "../mmo/fwd.hpp" + +namespace tmwa +{ void chrif_setuserid(AccountName); void chrif_setpasswd(AccountPass); AccountPass chrif_getpasswd(void); @@ -61,5 +64,6 @@ void do_init_chrif(void); // only used by intif.cpp // and clif.cpp for the new on_delete stuff ... extern Session *char_session; +} // namespace tmwa #endif // TMWA_MAP_CHRIF_HPP diff --git a/src/map/clif.cpp b/src/map/clif.cpp index addfa59..a8a57e6 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -69,6 +69,9 @@ #include "../poison.hpp" + +namespace tmwa +{ constexpr int EMOTE_IGNORED = 0x0e; // functions list. Rate is how many milliseconds are required between @@ -5679,3 +5682,4 @@ void do_init_clif(void) { make_listen_port(map_port, SessionParsers{.func_parse= clif_parse, .func_delete= clif_delete}); } +} // namespace tmwa diff --git a/src/map/clif.hpp b/src/map/clif.hpp index 0087d78..bf208b8 100644 --- a/src/map/clif.hpp +++ b/src/map/clif.hpp @@ -41,6 +41,9 @@ # include "pc.t.hpp" # include "skill.t.hpp" + +namespace tmwa +{ void clif_setip(IP4Address); void clif_setport(int); @@ -187,5 +190,6 @@ int clif_GM_kick(dumb_ptr<map_session_data> sd, dumb_ptr<map_session_data> tsd, int clif_foreachclient(std::function<void(dumb_ptr<map_session_data>)>); void do_init_clif(void); +} // namespace tmwa #endif // TMWA_MAP_CLIF_HPP diff --git a/src/map/clif.t.hpp b/src/map/clif.t.hpp index 0a3737a..9d5df79 100644 --- a/src/map/clif.t.hpp +++ b/src/map/clif.t.hpp @@ -35,6 +35,8 @@ # include "../mmo/enums.hpp" +namespace tmwa +{ namespace e { // [Fate] status.option properties. These are persistent status changes. @@ -713,5 +715,6 @@ bool network_to_native(SOff1 *native, Little16 network) { return network_to_native(&native->index, network); } +} // namespace tmwa #endif // TMWA_MAP_CLIF_T_HPP diff --git a/src/map/fwd.hpp b/src/map/fwd.hpp index 13d5f54..d58637e 100644 --- a/src/map/fwd.hpp +++ b/src/map/fwd.hpp @@ -21,6 +21,9 @@ # include "../sanity.hpp" + +namespace tmwa +{ // meh, add more when I feel like it class BlockId; struct block_list; @@ -52,5 +55,6 @@ struct env_t; struct magic_conf_t; struct component_t; struct effect_set_t; +} // namespace tmwa #endif // TMWA_MAP_FWD_HPP diff --git a/src/map/grfio.cpp b/src/map/grfio.cpp index c5ca9a1..4a1656b 100644 --- a/src/map/grfio.cpp +++ b/src/map/grfio.cpp @@ -40,6 +40,9 @@ #include "../poison.hpp" + +namespace tmwa +{ static std::map<MapName, RString> resnametable; @@ -103,3 +106,4 @@ std::vector<uint8_t> grfio_reads(MapName rname) close(fd); return buffer; } +} // namespace tmwa diff --git a/src/map/grfio.hpp b/src/map/grfio.hpp index d9329d3..002d475 100644 --- a/src/map/grfio.hpp +++ b/src/map/grfio.hpp @@ -31,11 +31,15 @@ # include "../mmo/fwd.hpp" + +namespace tmwa +{ bool load_resnametable(ZString filename); /// Load a resource into memory, subject to data/resnametable.txt. /// Normally, resourcename is xxx-y.gat and the file is xxx-y.wlk. /// Currently there is exactly one .wlk per .gat, but multiples are fine. std::vector<uint8_t> grfio_reads(MapName resourcename); +} // namespace tmwa #endif // TMWA_MAP_GRFIO_HPP diff --git a/src/map/intif.cpp b/src/map/intif.cpp index 4dbd5f7..314db24 100644 --- a/src/map/intif.cpp +++ b/src/map/intif.cpp @@ -47,6 +47,8 @@ #include "../poison.hpp" +namespace tmwa +{ //----------------------------------------------------------------- // inter serverへの送信 @@ -695,3 +697,4 @@ RecvResult intif_parse(Session *s, uint16_t packet_id) } return rv; } +} // namespace tmwa diff --git a/src/map/intif.hpp b/src/map/intif.hpp index 44bd8eb..0e23a94 100644 --- a/src/map/intif.hpp +++ b/src/map/intif.hpp @@ -31,6 +31,9 @@ # include "../mmo/fwd.hpp" + +namespace tmwa +{ RecvResult intif_parse(Session *, uint16_t packet_id); void intif_GMmessage(XString mes); @@ -53,5 +56,6 @@ void intif_party_leave(PartyId party_id, AccountId accound_id); void intif_party_changemap(dumb_ptr<map_session_data> sd, int online); void intif_party_message(PartyId party_id, AccountId account_id, XString mes); void intif_party_checkconflict(PartyId party_id, AccountId account_id, CharName nick); +} // namespace tmwa #endif // TMWA_MAP_INTIF_HPP diff --git a/src/map/itemdb.cpp b/src/map/itemdb.cpp index 67b6d21..edc9982 100644 --- a/src/map/itemdb.cpp +++ b/src/map/itemdb.cpp @@ -36,6 +36,9 @@ #include "../poison.hpp" + +namespace tmwa +{ static Map<ItemNameId, struct item_data> item_db; @@ -261,3 +264,4 @@ void do_final_itemdb(void) itemdb_final(&pair.second); item_db.clear(); } +} // namespace tmwa diff --git a/src/map/itemdb.hpp b/src/map/itemdb.hpp index 1d132ad..a6d4104 100644 --- a/src/map/itemdb.hpp +++ b/src/map/itemdb.hpp @@ -29,6 +29,9 @@ # include "map.t.hpp" # include "script.hpp" + +namespace tmwa +{ struct item_data { ItemNameId nameid; @@ -102,5 +105,6 @@ void itemdb_reload(void); void do_final_itemdb(void); bool itemdb_readdb(ZString filename); +} // namespace tmwa #endif // TMWA_MAP_ITEMDB_HPP diff --git a/src/map/magic-expr-eval.cpp b/src/map/magic-expr-eval.cpp index 36b69f5..0283b8d 100644 --- a/src/map/magic-expr-eval.cpp +++ b/src/map/magic-expr-eval.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/map/magic-expr-eval.hpp b/src/map/magic-expr-eval.hpp index 8500fc0..82cde5c 100644 --- a/src/map/magic-expr-eval.hpp +++ b/src/map/magic-expr-eval.hpp @@ -26,6 +26,9 @@ # include "magic-interpreter.t.hpp" + +namespace tmwa +{ // TODO kill this like I killed VAR # define ARGINT(x) args[x].v.v_int # define ARGDIR(x) args[x].v.v_dir @@ -53,5 +56,6 @@ # define ARGMOB(x) (ARGENTITY(x)->is_mob()) # define ARG_MAY_BE_AREA(x) (ARG_TYPE(x) == TYPE::AREA || ARG_TYPE(x) == TYPE::LOCATION) +} // namespace tmwa #endif // TMWA_MAP_MAGIC_EXPR_EVAL_HPP diff --git a/src/map/magic-expr.cpp b/src/map/magic-expr.cpp index d54bbee..dfb65c5 100644 --- a/src/map/magic-expr.cpp +++ b/src/map/magic-expr.cpp @@ -44,6 +44,9 @@ #include "../poison.hpp" + +namespace tmwa +{ template<class T> bool CHECK_TYPE(T *v, TYPE t) { @@ -1768,3 +1771,4 @@ dumb_ptr<expr_t> magic_new_expr(EXPR ty) expr->ty = ty; return expr; } +} // namespace tmwa diff --git a/src/map/magic-expr.hpp b/src/map/magic-expr.hpp index c3e994b..4bf43e8 100644 --- a/src/map/magic-expr.hpp +++ b/src/map/magic-expr.hpp @@ -33,6 +33,9 @@ # include "magic-interpreter.t.hpp" + +namespace tmwa +{ /* * Argument types: * i : int @@ -104,5 +107,6 @@ int magic_signature_check(ZString opname, ZString funname, ZString signature, void magic_area_rect(map_local **m, int *x, int *y, int *width, int *height, area_t& area); +} // namespace tmwa #endif // TMWA_MAP_MAGIC_EXPR_HPP diff --git a/src/map/magic-interpreter-base.cpp b/src/map/magic-interpreter-base.cpp index cf14ae0..fa53c51 100644 --- a/src/map/magic-interpreter-base.cpp +++ b/src/map/magic-interpreter-base.cpp @@ -35,6 +35,9 @@ #include "../poison.hpp" + +namespace tmwa +{ static void set_int_p(val_t *v, int i, TYPE t) { @@ -555,3 +558,4 @@ int spell_unbind(dumb_ptr<map_session_data> subject, dumb_ptr<invocation> invoca return 1; } +} // namespace tmwa diff --git a/src/map/magic-interpreter-base.hpp b/src/map/magic-interpreter-base.hpp index d569434..2f10e72 100644 --- a/src/map/magic-interpreter-base.hpp +++ b/src/map/magic-interpreter-base.hpp @@ -28,6 +28,9 @@ # include "../mmo/fwd.hpp" + +namespace tmwa +{ extern magic_conf_t magic_conf; /* Global magic conf */ extern env_t magic_default_env; /* Fake default environment */ @@ -82,5 +85,6 @@ dumb_ptr<invocation> spell_clone_effect(dumb_ptr<invocation> source); dumb_ptr<spell_t> magic_find_spell(XString invocation); void spell_update_location(dumb_ptr<invocation> invocation); +} // namespace tmwa #endif // TMWA_MAP_MAGIC_INTERPRETER_BASE_HPP diff --git a/src/map/magic-interpreter.cpp b/src/map/magic-interpreter.cpp index cca5500..87ac23e 100644 --- a/src/map/magic-interpreter.cpp +++ b/src/map/magic-interpreter.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/map/magic-interpreter.hpp b/src/map/magic-interpreter.hpp index d8a8d9c..9b6025c 100644 --- a/src/map/magic-interpreter.hpp +++ b/src/map/magic-interpreter.hpp @@ -42,6 +42,9 @@ # include "script.hpp" # include "skill.t.hpp" + +namespace tmwa +{ struct location_t { map_local *m; @@ -424,5 +427,6 @@ struct proc_t , body() {} }; +} // namespace tmwa #endif // TMWA_MAP_MAGIC_INTERPRETER_HPP diff --git a/src/map/magic-interpreter.py b/src/map/magic-interpreter.py index 8170f27..f6fa4c9 100644 --- a/src/map/magic-interpreter.py +++ b/src/map/magic-interpreter.py @@ -2,7 +2,7 @@ class area_t(object): ''' print an area_t ''' __slots__ = ('_value') - name = 'area_t' + name = 'tmwa::area_t' enabled = True def __init__(self, value): @@ -31,7 +31,7 @@ class val_t(object): ''' print a val_t ''' __slots__ = ('_value') - name = 'val_t' + name = 'tmwa::val_t' enabled = True def __init__(self, value): @@ -69,7 +69,7 @@ class e_area_t(object): ''' print an e_area_t ''' __slots__ = ('_value') - name = 'e_area_t' + name = 'tmwa::e_area_t' enabled = True def __init__(self, value): @@ -97,7 +97,7 @@ class expr_t(object): ''' print an expr_t ''' __slots__ = ('_value') - name = 'expr_t' + name = 'tmwa::expr_t' enabled = True def __init__(self, value): @@ -129,7 +129,7 @@ class effect_t(object): ''' print an effect_t ''' __slots__ = ('_value') - name = 'effect_t' + name = 'tmwa::effect_t' enabled = True def __init__(self, value): @@ -166,7 +166,7 @@ class spellguard_t(object): ''' print a spellguard_t ''' __slots__ = ('_value') - name = 'spellguard_t' + name = 'tmwa::spellguard_t' enabled = True def __init__(self, value): @@ -201,7 +201,7 @@ class cont_activation_record_t(object): ''' print a cont_activation_record_t ''' __slots__ = ('_value') - name = 'cont_activation_record_t' + name = 'tmwa::cont_activation_record_t' enabled = True def __init__(self, value): diff --git a/src/map/magic-interpreter.t.hpp b/src/map/magic-interpreter.t.hpp index 780d011..addaf18 100644 --- a/src/map/magic-interpreter.t.hpp +++ b/src/map/magic-interpreter.t.hpp @@ -24,6 +24,9 @@ # include "../generic/enum.hpp" + +namespace tmwa +{ enum class SPELLARG : uint8_t { NONE, @@ -144,5 +147,6 @@ enum class INVOCATION_FLAG : uint8_t ENUM_BITWISE_OPERATORS(INVOCATION_FLAG) } using e::INVOCATION_FLAG; +} // namespace tmwa #endif // TMWA_MAP_MAGIC_INTERPRETER_T_HPP diff --git a/src/map/magic-stmt.cpp b/src/map/magic-stmt.cpp index 2fbe556..57fbe66 100644 --- a/src/map/magic-stmt.cpp +++ b/src/map/magic-stmt.cpp @@ -46,6 +46,9 @@ #include "../poison.hpp" + +namespace tmwa +{ /* used for local spell effects */ constexpr Species INVISIBLE_NPC = wrap<Species>(127); @@ -1635,3 +1638,4 @@ int spell_attack(BlockId caster_id, BlockId target_id) return 1; } +} // namespace tmwa diff --git a/src/map/magic-stmt.hpp b/src/map/magic-stmt.hpp index 745b9b5..3050350 100644 --- a/src/map/magic-stmt.hpp +++ b/src/map/magic-stmt.hpp @@ -30,6 +30,9 @@ # include "skill.t.hpp" + +namespace tmwa +{ struct op_t { ZString name; @@ -86,5 +89,6 @@ void magic_stop_completely(dumb_ptr<map_session_data> c); int spell_attack(BlockId caster, BlockId target); void spell_free_invocation(dumb_ptr<invocation> invocation); +} // namespace tmwa #endif // TMWA_MAP_MAGIC_STMT_HPP diff --git a/src/map/magic-v2.cpp b/src/map/magic-v2.cpp index a287519..a671dea 100644 --- a/src/map/magic-v2.cpp +++ b/src/map/magic-v2.cpp @@ -42,6 +42,9 @@ #include "../poison.hpp" + +namespace tmwa +{ namespace magic_v2 { static @@ -1260,3 +1263,4 @@ bool load_magic_file_v2(ZString filename) } return rv; } +} // namespace tmwa diff --git a/src/map/magic-v2.hpp b/src/map/magic-v2.hpp index 92b6f4e..9c357bc 100644 --- a/src/map/magic-v2.hpp +++ b/src/map/magic-v2.hpp @@ -23,8 +23,12 @@ # include "../strings/zstring.hpp" + +namespace tmwa +{ bool magic_init0(); // must be called after itemdb initialization bool load_magic_file_v2(ZString filename); +} // namespace tmwa #endif // TMWA_MAP_MAGIC_V2_HPP diff --git a/src/map/magic.cpp b/src/map/magic.cpp index ff4a278..b899a5e 100644 --- a/src/map/magic.cpp +++ b/src/map/magic.cpp @@ -37,6 +37,9 @@ #include "../poison.hpp" + +namespace tmwa +{ #undef DEBUG /// Return a pair of strings, {spellname, parameter} @@ -124,3 +127,4 @@ int magic_message(dumb_ptr<map_session_data> caster, XString source_invocation) return 0; /* Not a spell */ } +} // namespace tmwa diff --git a/src/map/magic.hpp b/src/map/magic.hpp index e54661b..4df204f 100644 --- a/src/map/magic.hpp +++ b/src/map/magic.hpp @@ -29,6 +29,9 @@ # include "map.t.hpp" # include "skill.t.hpp" + +namespace tmwa +{ /** * Try to cast magic. * @@ -41,5 +44,6 @@ * message should not be repeated. */ int magic_message(dumb_ptr<map_session_data> caster, XString source_invocation); +} // namespace tmwa #endif // TMWA_MAP_MAGIC_HPP diff --git a/src/map/main.cpp b/src/map/main.cpp index 8354f1c..8e8e9d5 100644 --- a/src/map/main.cpp +++ b/src/map/main.cpp @@ -20,3 +20,8 @@ #include "map.hpp" #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/map/map.cpp b/src/map/map.cpp index 97523b0..033f299 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -78,6 +78,9 @@ #include "../poison.hpp" + +namespace tmwa +{ DMap<BlockId, dumb_ptr<block_list>> id_db; UPMap<MapName, map_abstract> maps_db; @@ -1786,3 +1789,4 @@ int map_scriptcont(dumb_ptr<map_session_data> sd, BlockId id) return 0; } +} // namespace tmwa diff --git a/src/map/map.hpp b/src/map/map.hpp index aa2d97a..af08ae4 100644 --- a/src/map/map.hpp +++ b/src/map/map.hpp @@ -52,6 +52,9 @@ # include "script.hpp" // change to script.t.hpp # include "skill.t.hpp" + +namespace tmwa +{ constexpr int MAX_NPC_PER_MAP = 512; constexpr int BLOCK_SIZE = 8; # define AREA_SIZE battle_config.area_size @@ -720,5 +723,6 @@ inline dumb_ptr<npc_data_script> npc_data::is_script() { return npc_subtype == N inline dumb_ptr<npc_data_shop> npc_data::is_shop() { return npc_subtype == NpcSubtype::SHOP ? as_shop() : nullptr ; } inline dumb_ptr<npc_data_warp> npc_data::is_warp() { return npc_subtype == NpcSubtype::WARP ? as_warp() : nullptr ; } inline dumb_ptr<npc_data_message> npc_data::is_message() { return npc_subtype == NpcSubtype::MESSAGE ? as_message() : nullptr ; } +} // namespace tmwa #endif // TMWA_MAP_MAP_HPP diff --git a/src/map/map.t.hpp b/src/map/map.t.hpp index 4eba867..79e9448 100644 --- a/src/map/map.t.hpp +++ b/src/map/map.t.hpp @@ -32,6 +32,9 @@ # include "../mmo/ids.hpp" # include "../mmo/mmo.hpp" + +namespace tmwa +{ enum class BL : uint8_t { NUL, @@ -198,5 +201,6 @@ inline BlockId account_to_block(AccountId a) { return wrap<BlockId>(unwrap<AccountId>(a)); } inline AccountId block_to_account(BlockId b) { return wrap<AccountId>(unwrap<BlockId>(b)); } +} // namespace tmwa #endif // TMWA_MAP_MAP_T_HPP diff --git a/src/map/mapflag.cpp b/src/map/mapflag.cpp index 65126d9..f9cf8f6 100644 --- a/src/map/mapflag.cpp +++ b/src/map/mapflag.cpp @@ -20,6 +20,9 @@ #include "../poison.hpp" + +namespace tmwa +{ // because bitfields, that's why bool MapFlags::get(MapFlag mf) const @@ -89,3 +92,4 @@ MapFlag map_flag_from_int(int shift) { return static_cast<MapFlag>(1 << shift); } +} // namespace tmwa diff --git a/src/map/mapflag.hpp b/src/map/mapflag.hpp index 5e36055..1f42bc9 100644 --- a/src/map/mapflag.hpp +++ b/src/map/mapflag.hpp @@ -25,6 +25,9 @@ # include "../mmo/extract.hpp" // TODO remove this (requires specializing the *other* half) + +namespace tmwa +{ // originally from script.cpp // These are part of the script API, so they can't change ever, // even though they are silly. @@ -79,5 +82,6 @@ template<> bool extract<MapFlag, void, void>(XString str, MapFlag *mf); MapFlag map_flag_from_int(int shift); +} // namespace tmwa #endif // TMWA_MAP_MAPFLAG_HPP diff --git a/src/map/mapflag.py b/src/map/mapflag.py index 3bc9f1a..fec8c05 100644 --- a/src/map/mapflag.py +++ b/src/map/mapflag.py @@ -2,7 +2,7 @@ class MapFlags(object): ''' print a set of map flags ''' __slots__ = ('_value') - name = 'MapFlags' + name = 'tmwa::MapFlags' enabled = True def __init__(self, value): diff --git a/src/map/mob.cpp b/src/map/mob.cpp index 166031f..f9edda9 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -56,6 +56,9 @@ #include "../poison.hpp" + +namespace tmwa +{ constexpr interval_t MIN_MOBTHINKTIME = std::chrono::milliseconds(100); // Move probability in the negligent mode MOB (rate of 1000 minute) @@ -3736,3 +3739,4 @@ void do_init_mob2(void) MIN_MOBTHINKTIME * 10 ).detach(); } +} // namespace tmwa diff --git a/src/map/mob.hpp b/src/map/mob.hpp index 8860ab5..87b7d3f 100644 --- a/src/map/mob.hpp +++ b/src/map/mob.hpp @@ -36,6 +36,9 @@ # include "map.hpp" # include "skill.t.hpp" + +namespace tmwa +{ # define ENGLISH_NAME stringish<MobName>("--en--"_s) # define JAPANESE_NAME stringish<MobName>("--ja--"_s) # define MOB_THIS_MAP stringish<MapName>("this"_s) @@ -134,5 +137,6 @@ void mobskill_castend_pos(TimerData *tid, tick_t tick, BlockId id); int mob_summonslave(dumb_ptr<mob_data> md2, int *value, int amount, int flag); void mob_reload(void); +} // namespace tmwa #endif // TMWA_MAP_MOB_HPP diff --git a/src/map/mob.t.hpp b/src/map/mob.t.hpp index 5e056d5..b96fb09 100644 --- a/src/map/mob.t.hpp +++ b/src/map/mob.t.hpp @@ -25,6 +25,9 @@ # include <cstdint> + +namespace tmwa +{ enum class MobSkillTarget { MST_TARGET = 0, @@ -59,5 +62,6 @@ enum class MobSkillState : uint8_t MSS_LOOT, MSS_CHASE, }; +} // namespace tmwa #endif // TMWA_MAP_MOB_T_HPP diff --git a/src/map/npc.cpp b/src/map/npc.cpp index 275b41d..16090b2 100644 --- a/src/map/npc.cpp +++ b/src/map/npc.cpp @@ -59,6 +59,9 @@ #include "../poison.hpp" + +namespace tmwa +{ static std::list<AString> npc_srcs; @@ -1784,3 +1787,4 @@ bool do_init_npc(void) } return rv; } +} // namespace tmwa diff --git a/src/map/npc.hpp b/src/map/npc.hpp index f8ae650..d6d3b62 100644 --- a/src/map/npc.hpp +++ b/src/map/npc.hpp @@ -35,6 +35,9 @@ # include "map.hpp" + +namespace tmwa +{ constexpr BlockId START_NPC_NUM = wrap<BlockId>(110000000); // TODO make these species, see npc_class in npc_data @@ -96,5 +99,6 @@ void npc_timerevent_stop(dumb_ptr<npc_data_script> nd); interval_t npc_gettimerevent_tick(dumb_ptr<npc_data_script> nd); void npc_settimerevent_tick(dumb_ptr<npc_data_script> nd, interval_t newtimer); int npc_delete(dumb_ptr<npc_data> nd); +} // namespace tmwa #endif // TMWA_MAP_NPC_HPP diff --git a/src/map/party.cpp b/src/map/party.cpp index 61df355..7784a02 100644 --- a/src/map/party.cpp +++ b/src/map/party.cpp @@ -42,6 +42,9 @@ #include "../poison.hpp" + +namespace tmwa +{ // 座標やHP送信の間隔 constexpr interval_t PARTY_SEND_XYHP_INVERVAL = std::chrono::seconds(1); @@ -804,3 +807,4 @@ void party_foreachsamemap(std::function<void(dumb_ptr<block_list>)> func, if (list[i]->bl_prev) // 有効かどうかチェック func(list[i]); } +} // namespace tmwa diff --git a/src/map/party.hpp b/src/map/party.hpp index d4000f7..b1c1092 100644 --- a/src/map/party.hpp +++ b/src/map/party.hpp @@ -31,6 +31,9 @@ # include "../mmo/fwd.hpp" + +namespace tmwa +{ void do_init_party(void); PartyPair party_search(PartyId party_id); PartyPair party_searchname(PartyName str); @@ -67,5 +70,6 @@ int party_exp_share(PartyPair p, map_local *map, int base_exp, int job_exp); void party_foreachsamemap(std::function<void(dumb_ptr<block_list>)> func, dumb_ptr<map_session_data> sd, int type); +} // namespace tmwa #endif // TMWA_MAP_PARTY_HPP diff --git a/src/map/path.cpp b/src/map/path.cpp index 432d9cf..6950797 100644 --- a/src/map/path.cpp +++ b/src/map/path.cpp @@ -36,6 +36,9 @@ #include "../poison.hpp" + +namespace tmwa +{ constexpr int MAX_HEAP = 150; struct tmp_path { @@ -358,3 +361,4 @@ int path_search(struct walkpath_data *wpd, map_local *m, int x0, int y0, int x1, return -1; } } +} // namespace tmwa diff --git a/src/map/path.hpp b/src/map/path.hpp index 5f03a90..019a987 100644 --- a/src/map/path.hpp +++ b/src/map/path.hpp @@ -23,6 +23,10 @@ # include "fwd.hpp" + +namespace tmwa +{ int path_search(struct walkpath_data *, map_local *, int, int, int, int, int); +} // namespace tmwa #endif // TMWA_MAP_PATH_HPP diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 48afffc..3b3a6b3 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -63,6 +63,9 @@ #include "../poison.hpp" + +namespace tmwa +{ // PVP順位計算の間隔 constexpr std::chrono::milliseconds PVP_CALCRANK_INTERVAL = std::chrono::seconds(1); @@ -5273,3 +5276,4 @@ int pc_logout(dumb_ptr<map_session_data> sd) // [fate] Player logs out MAP_LOG_STATS(sd, "LOGOUT"_fmt); return 0; } +} // namespace tmwa diff --git a/src/map/pc.hpp b/src/map/pc.hpp index 6e07070..d40353b 100644 --- a/src/map/pc.hpp +++ b/src/map/pc.hpp @@ -36,6 +36,9 @@ # include "clif.t.hpp" # include "map.hpp" + +namespace tmwa +{ inline void pc_setsit(dumb_ptr<map_session_data> sd) { @@ -182,5 +185,6 @@ int pc_logout(dumb_ptr<map_session_data> sd); // [fate] Player logs out void pc_show_motd(dumb_ptr<map_session_data> sd); void do_init_pc(void); +} // namespace tmwa #endif // TMWA_MAP_PC_HPP diff --git a/src/map/pc.t.hpp b/src/map/pc.t.hpp index 86817a7..ec882ab 100644 --- a/src/map/pc.t.hpp +++ b/src/map/pc.t.hpp @@ -26,6 +26,9 @@ # include <cstdint> + +namespace tmwa +{ enum class PC_GAINEXP_REASON { KILLING = 0, @@ -52,5 +55,6 @@ enum class CalcStatus NOW, LATER, }; +} // namespace tmwa #endif // TMWA_MAP_PC_T_HPP diff --git a/src/map/script.cpp b/src/map/script.cpp index b9d90ea..adc7789 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -73,6 +73,9 @@ #include "../poison.hpp" + +namespace tmwa +{ constexpr bool DEBUG_DISP = false; constexpr bool DEBUG_RUN = false; @@ -5116,3 +5119,4 @@ ZString get_script_var_s(dumb_ptr<map_session_data> sd, VarName var, int e) PRINTF("Warning: you lied about the type and I can't fix it!"_fmt); return ZString(); } +} // namespace tmwa diff --git a/src/map/script.hpp b/src/map/script.hpp index 6708bbc..4d6e8df 100644 --- a/src/map/script.hpp +++ b/src/map/script.hpp @@ -39,6 +39,9 @@ # include "clif.t.hpp" # include "map.t.hpp" + +namespace tmwa +{ enum class ByteCode : uint8_t; struct str_data_t; @@ -197,5 +200,6 @@ void set_script_var_s(dumb_ptr<map_session_data> sd, VarName var, int e, XString int get_script_var_i(dumb_ptr<map_session_data> sd, VarName var, int e); ZString get_script_var_s(dumb_ptr<map_session_data> sd, VarName var, int e); +} // namespace tmwa #endif // TMWA_MAP_SCRIPT_HPP diff --git a/src/map/script.py b/src/map/script.py index 068307a..dcde08d 100644 --- a/src/map/script.py +++ b/src/map/script.py @@ -3,7 +3,7 @@ class ByteCode: (workaround for gcc bug 58150) ''' __slots__ = ('_value') - name = 'ByteCode' + name = 'tmwa::ByteCode' enabled = True def __init__(self, value): @@ -34,7 +34,7 @@ class script_data(object): ''' print a script_data ''' __slots__ = ('_value') - name = 'script_data' + name = 'tmwa::script_data' enabled = True def __init__(self, value): diff --git a/src/map/skill-pools.cpp b/src/map/skill-pools.cpp index 3e9639a..e37b7e3 100644 --- a/src/map/skill-pools.cpp +++ b/src/map/skill-pools.cpp @@ -27,6 +27,9 @@ #include "../poison.hpp" + +namespace tmwa +{ Array<SkillID, MAX_POOL_SKILLS> skill_pool_skills; int skill_pool_skills_size = 0; @@ -143,3 +146,4 @@ int skill_power_bl(dumb_ptr<block_list> bl, SkillID skill) else return 0; } +} // namespace tmwa diff --git a/src/map/skill-pools.hpp b/src/map/skill-pools.hpp index 28351b1..d75d344 100644 --- a/src/map/skill-pools.hpp +++ b/src/map/skill-pools.hpp @@ -21,4 +21,9 @@ # include "fwd.hpp" + +namespace tmwa +{ +} // namespace tmwa + #endif // TMWA_MAP_SKILL_POOLS_HPP diff --git a/src/map/skill.cpp b/src/map/skill.cpp index e8ad878..5b5ca63 100644 --- a/src/map/skill.cpp +++ b/src/map/skill.cpp @@ -53,6 +53,9 @@ #include "../poison.hpp" + +namespace tmwa +{ struct skill_name_db skill_names[] = { {SkillID::AC_OWL, "OWL"_s, "Owl's_Eye"_s}, @@ -1314,3 +1317,4 @@ skill_name_db& skill_lookup_by_name(XString name) return ner; return skill_names[num_names - 1]; } +} // namespace tmwa diff --git a/src/map/skill.hpp b/src/map/skill.hpp index 0e566c6..bdaf184 100644 --- a/src/map/skill.hpp +++ b/src/map/skill.hpp @@ -35,6 +35,9 @@ # include "map.hpp" + +namespace tmwa +{ constexpr int MAX_SKILL_PRODUCE_DB = 150; constexpr int MAX_SKILL_ARROW_DB = 150; constexpr int MAX_SKILL_ABRA_DB = 350; @@ -164,4 +167,6 @@ int skill_power_bl(dumb_ptr<block_list> bl, SkillID skill); // [Fate] Remember that a certain skill ID belongs to a pool skill void skill_pool_register(SkillID id); +} // namespace tmwa + #endif // TMWA_MAP_SKILL_HPP diff --git a/src/map/skill.t.hpp b/src/map/skill.t.hpp index b2ef2de..014080b 100644 --- a/src/map/skill.t.hpp +++ b/src/map/skill.t.hpp @@ -27,6 +27,9 @@ # include "../generic/enum.hpp" + +namespace tmwa +{ // TODO remove most of these as their corresponding SkillIDs get deleted. enum class StatusChange : uint16_t { @@ -131,5 +134,6 @@ enum class SkillFlags : uint16_t ENUM_BITWISE_OPERATORS(SkillFlags) } using e::SkillFlags; +} // namespace tmwa #endif // TMWA_MAP_SKILL_T_HPP diff --git a/src/map/storage.cpp b/src/map/storage.cpp index b063250..a6e6a0d 100644 --- a/src/map/storage.cpp +++ b/src/map/storage.cpp @@ -36,6 +36,9 @@ #include "../poison.hpp" + +namespace tmwa +{ static Map<AccountId, Storage> storage_db; @@ -331,3 +334,4 @@ int storage_storage_saved(AccountId account_id) } return 0; } +} // namespace tmwa diff --git a/src/map/storage.hpp b/src/map/storage.hpp index fe29664..cb9cbc5 100644 --- a/src/map/storage.hpp +++ b/src/map/storage.hpp @@ -29,6 +29,9 @@ # include "clif.t.hpp" + +namespace tmwa +{ int storage_storageopen(dumb_ptr<map_session_data> sd); int storage_storageadd(dumb_ptr<map_session_data> sd, IOff0 index, int amount); int storage_storageget(dumb_ptr<map_session_data> sd, SOff0 index, int amount); @@ -39,5 +42,6 @@ Storage *account2storage2(AccountId account_id); int storage_storage_quit(dumb_ptr<map_session_data> sd); int storage_storage_save(AccountId account_id, int final); int storage_storage_saved(AccountId account_id); +} // namespace tmwa #endif // TMWA_MAP_STORAGE_HPP diff --git a/src/map/tmw.cpp b/src/map/tmw.cpp index 38b96ce..60b5027 100644 --- a/src/map/tmw.cpp +++ b/src/map/tmw.cpp @@ -41,6 +41,9 @@ #include "../poison.hpp" + +namespace tmwa +{ static void tmw_AutoBan(dumb_ptr<map_session_data> sd, ZString reason, int length); static @@ -163,3 +166,4 @@ void tmw_GmHackMsg(ZString line) GmLevel::from(static_cast<uint32_t>(battle_config.hack_info_GM_level)), line); } +} // namespace tmwa diff --git a/src/map/tmw.hpp b/src/map/tmw.hpp index dae6e69..610c80c 100644 --- a/src/map/tmw.hpp +++ b/src/map/tmw.hpp @@ -26,7 +26,11 @@ # include "../generic/fwd.hpp" + +namespace tmwa +{ int tmw_CheckChatSpam(dumb_ptr<map_session_data> sd, XString message); void tmw_GmHackMsg(ZString line); +} // namespace tmwa #endif // TMWA_MAP_TMW_HPP diff --git a/src/map/trade.cpp b/src/map/trade.cpp index c21fd27..c52377d 100644 --- a/src/map/trade.cpp +++ b/src/map/trade.cpp @@ -34,6 +34,9 @@ #include "../poison.hpp" + +namespace tmwa +{ /*========================================== * 取引要請を相手に送る *------------------------------------------ @@ -462,3 +465,4 @@ void trade_verifyzeny(dumb_ptr<map_session_data> sd) } } } +} // namespace tmwa diff --git a/src/map/trade.hpp b/src/map/trade.hpp index 370fcdf..b9fce57 100644 --- a/src/map/trade.hpp +++ b/src/map/trade.hpp @@ -27,6 +27,9 @@ # include "clif.t.hpp" + +namespace tmwa +{ void trade_traderequest(dumb_ptr<map_session_data> sd, BlockId target_id); void trade_tradeack(dumb_ptr<map_session_data> sd, int type); void trade_tradeadditem(dumb_ptr<map_session_data> sd, IOff2 index, int amount); @@ -34,5 +37,6 @@ void trade_tradeok(dumb_ptr<map_session_data> sd); void trade_tradecancel(dumb_ptr<map_session_data> sd); void trade_tradecommit(dumb_ptr<map_session_data> sd); void trade_verifyzeny(dumb_ptr<map_session_data> sd); +} // namespace tmwa #endif // TMWA_MAP_TRADE_HPP diff --git a/src/mmo/config_parse.cpp b/src/mmo/config_parse.cpp index c6ddde2..8362810 100644 --- a/src/mmo/config_parse.cpp +++ b/src/mmo/config_parse.cpp @@ -30,6 +30,9 @@ #include "../poison.hpp" + +namespace tmwa +{ bool is_comment(XString line) { return not line or line.startswith("//"_s); @@ -154,3 +157,4 @@ bool load_config_file(ZString filename, ConfigItemParser slave) } return rv; } +} // namespace tmwa diff --git a/src/mmo/config_parse.hpp b/src/mmo/config_parse.hpp index 080f13c..5389b5d 100644 --- a/src/mmo/config_parse.hpp +++ b/src/mmo/config_parse.hpp @@ -23,6 +23,9 @@ # include "../strings/fwd.hpp" + +namespace tmwa +{ typedef bool (*ConfigItemParser)(XString key, ZString value); bool is_comment(XString line); @@ -32,5 +35,6 @@ bool config_split(XString line, XString *key, XString *value); /// Master config parser. This handles 'import' and 'version-ge' etc. /// Then it defers to the inferior parser for a line it does not understand. bool load_config_file(ZString filename, ConfigItemParser slave); +} // namespace tmwa #endif // TMWA_MMO_CONFIG_PARSE_HPP diff --git a/src/mmo/consts.cpp b/src/mmo/consts.cpp index ee59429..e49cdf5 100644 --- a/src/mmo/consts.cpp +++ b/src/mmo/consts.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/mmo/consts.hpp b/src/mmo/consts.hpp index f7dbc36..0fdd7de 100644 --- a/src/mmo/consts.hpp +++ b/src/mmo/consts.hpp @@ -28,6 +28,9 @@ # include "ids.hpp" # include "strs.hpp" + +namespace tmwa +{ constexpr int FIFOSIZE_SERVERLINK = 256 * 1024; constexpr int MAX_MAP_PER_SERVER = 512; @@ -61,5 +64,6 @@ struct PartyMember int leader, online, lv; struct map_session_data *sd; }; +} // namespace tmwa #endif // TMWA_MMO_CONSTS_HPP diff --git a/src/mmo/core.cpp b/src/mmo/core.cpp index 431c0db..444a44c 100644 --- a/src/mmo/core.cpp +++ b/src/mmo/core.cpp @@ -37,6 +37,9 @@ #include "../poison.hpp" + +namespace tmwa +{ // Added by Gabuzomeu // // This is an implementation of signal() using sigaction() for portability. @@ -95,8 +98,11 @@ void sig_proc(int) Unless you use SA_SIGINFO and *carefully* check the origin, that means they must be SIG_DFL. */ +} // namespace tmwa + int main(int argc, char **argv) { + using namespace tmwa; // ZString args[argc]; is (deliberately!) not supported by clang yet ZString *args = static_cast<ZString *>(alloca(argc * sizeof(ZString))); for (int i = 0; i < argc; ++i) diff --git a/src/mmo/core.hpp b/src/mmo/core.hpp index 99e41c8..e9ffab6 100644 --- a/src/mmo/core.hpp +++ b/src/mmo/core.hpp @@ -27,6 +27,9 @@ # include "../strings/fwd.hpp" + +namespace tmwa +{ /// core.c contains a server-independent main() function /// and then runs a do_sendrecv loop @@ -40,5 +43,6 @@ extern int do_init(Slice<ZString>); /// Cleanup function called whenever a signal kills us /// or when if we manage to exit() gracefully. extern void term_func(void); +} // namespace tmwa #endif // TMWA_MMO_CORE_HPP diff --git a/src/mmo/enums.cpp b/src/mmo/enums.cpp index fe01c5d..d05be91 100644 --- a/src/mmo/enums.cpp +++ b/src/mmo/enums.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/mmo/enums.hpp b/src/mmo/enums.hpp index 52e1009..62ce8ee 100644 --- a/src/mmo/enums.hpp +++ b/src/mmo/enums.hpp @@ -27,6 +27,9 @@ # include "../generic/enum.hpp" + +namespace tmwa +{ enum class SkillID : uint16_t; constexpr SkillID MAX_SKILL = SkillID(474); // not 450 constexpr SkillID get_enum_min_value(SkillID) { return SkillID(); } @@ -157,5 +160,6 @@ bool network_to_native(SEX *native, char network) *native = sex_from_char(network); return true; } +} // namespace tmwa #endif // TMWA_MMO_ENUMS_HPP diff --git a/src/mmo/extract.cpp b/src/mmo/extract.cpp index deb3a64..2f8b644 100644 --- a/src/mmo/extract.cpp +++ b/src/mmo/extract.cpp @@ -28,6 +28,9 @@ #include "../poison.hpp" + +namespace tmwa +{ bool extract(XString str, XString *rv) { *rv = str; @@ -85,3 +88,4 @@ bool extract(XString str, CharName *out) } return false; } +} // namespace tmwa diff --git a/src/mmo/extract.hpp b/src/mmo/extract.hpp index 1154545..16b3cf1 100644 --- a/src/mmo/extract.hpp +++ b/src/mmo/extract.hpp @@ -35,6 +35,9 @@ # include "utils.hpp" + +namespace tmwa +{ template<class T> bool do_extract(XString str, T t); @@ -227,5 +230,6 @@ bool extract(XString str, Wrapped<R> *w) { return extract(str, &w->_value); } +} // namespace tmwa #endif // TMWA_MMO_EXTRACT_HPP diff --git a/src/mmo/extract_test.cpp b/src/mmo/extract_test.cpp index 18d7771..0116f6c 100644 --- a/src/mmo/extract_test.cpp +++ b/src/mmo/extract_test.cpp @@ -27,6 +27,8 @@ #include "../poison.hpp" +namespace tmwa +{ #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" TEST(extract, record_int) @@ -357,3 +359,4 @@ TEST(extract, mapname) EXPECT_TRUE(extract("abcdefghijklmno.gat"_s, &map)); EXPECT_EQ(map, "abcdefghijklmno"_s); } +} // namespace tmwa diff --git a/src/mmo/fwd.hpp b/src/mmo/fwd.hpp index 7bf766e..379b370 100644 --- a/src/mmo/fwd.hpp +++ b/src/mmo/fwd.hpp @@ -21,6 +21,9 @@ # include "../sanity.hpp" + +namespace tmwa +{ // meh, add more when I feel like it class MapName; class CharName; @@ -63,5 +66,6 @@ class PartyMember; # endif class PartyMost; class PartyPair; +} // namespace tmwa #endif // TMWA_MMO_FWD_HPP diff --git a/src/mmo/human_time_diff.cpp b/src/mmo/human_time_diff.cpp index f2f720e..49a7664 100644 --- a/src/mmo/human_time_diff.cpp +++ b/src/mmo/human_time_diff.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/mmo/human_time_diff.hpp b/src/mmo/human_time_diff.hpp index 0340a4b..3fd044d 100644 --- a/src/mmo/human_time_diff.hpp +++ b/src/mmo/human_time_diff.hpp @@ -27,6 +27,9 @@ # include "extract.hpp" + +namespace tmwa +{ struct HumanTimeDiff { short year, month, day, hour, minute, second; @@ -84,5 +87,6 @@ bool extract(XString str, HumanTimeDiff *iv) } return true; } +} // namespace tmwa #endif // TMWA_MMO_HUMAN_TIME_DIFF_HPP diff --git a/src/mmo/human_time_diff_test.cpp b/src/mmo/human_time_diff_test.cpp index 3ace280..590e2b3 100644 --- a/src/mmo/human_time_diff_test.cpp +++ b/src/mmo/human_time_diff_test.cpp @@ -23,6 +23,8 @@ #include "../poison.hpp" +namespace tmwa +{ #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" // a sequence of [-+]?[0-9]+([ay]|m|[jd]|h|mn|s) @@ -104,3 +106,4 @@ TEST(humantimediff, multiple) EXPECT_EQ(0, diff.second); EXPECT_FALSE(extract("1y2y"_s, &diff)); } +} // namespace tmwa diff --git a/src/mmo/ids.cpp b/src/mmo/ids.cpp index 971013b..d40d5c3 100644 --- a/src/mmo/ids.cpp +++ b/src/mmo/ids.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/mmo/ids.hpp b/src/mmo/ids.hpp index c79b93c..4225103 100644 --- a/src/mmo/ids.hpp +++ b/src/mmo/ids.hpp @@ -26,6 +26,9 @@ # include "extract.hpp" + +namespace tmwa +{ class Species : public Wrapped<uint16_t> { public: explicit operator bool() const = delete; bool operator !() const = delete; constexpr Species() : Wrapped<uint16_t>() {} protected: constexpr explicit Species(uint16_t a) : Wrapped<uint16_t>(a) {} }; constexpr Species NEGATIVE_SPECIES = Species(); @@ -163,5 +166,6 @@ uint32_t convert_for_printf(GmLevel g) { return g.get_all_bits(); } +} // namespace tmwa #endif // TMWA_MMO_IDS_HPP diff --git a/src/mmo/md5more.cpp b/src/mmo/md5more.cpp index 96b12a7..4e5d2da 100644 --- a/src/mmo/md5more.cpp +++ b/src/mmo/md5more.cpp @@ -35,6 +35,9 @@ #include "../poison.hpp" + +namespace tmwa +{ #define X block.data // TODO - refactor MD5 into a stream, and merge the implementations @@ -153,3 +156,4 @@ IP4Address MD5_ip(IP4Address ip) static_cast<uint8_t>(obuf[6] ^ obuf[7] ^ obuf[14] ^ obuf[15]), }); } +} // namespace tmwa diff --git a/src/mmo/md5more.hpp b/src/mmo/md5more.hpp index f3ab363..f2bc9d0 100644 --- a/src/mmo/md5more.hpp +++ b/src/mmo/md5more.hpp @@ -29,6 +29,9 @@ # include "../net/fwd.hpp" + +namespace tmwa +{ MD5_state MD5_from_FILE(io::ReadFile& in); // whoever wrote this fails basic understanding of @@ -43,5 +46,6 @@ bool pass_ok(AccountPass password, AccountCrypt crypted); /// This returns an IP4Address because it is configurable whether it gets called at all IP4Address MD5_ip(IP4Address ip); +} // namespace tmwa #endif // TMWA_MMO_MD5MORE_HPP diff --git a/src/mmo/mmo.cpp b/src/mmo/mmo.cpp index 8bf7edf..aafa431 100644 --- a/src/mmo/mmo.cpp +++ b/src/mmo/mmo.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/mmo/mmo.hpp b/src/mmo/mmo.hpp index d749daa..8e92ecb 100644 --- a/src/mmo/mmo.hpp +++ b/src/mmo/mmo.hpp @@ -27,6 +27,9 @@ # include "../proto2/types.hpp" + +namespace tmwa +{ inline bool operator == (const SkillValue& l, const SkillValue& r) { @@ -64,5 +67,6 @@ struct PartyPair bool operator !() const { return !party_most; } PartyMost *operator->() const { return party_most; } }; +} // namespace tmwa #endif // TMWA_MMO_MMO_HPP diff --git a/src/mmo/strs.cpp b/src/mmo/strs.cpp index 979d6ac..71dceec 100644 --- a/src/mmo/strs.cpp +++ b/src/mmo/strs.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/mmo/strs.hpp b/src/mmo/strs.hpp index ad2a1b5..16e524a 100644 --- a/src/mmo/strs.hpp +++ b/src/mmo/strs.hpp @@ -25,6 +25,9 @@ # include "../strings/vstring.hpp" + +namespace tmwa +{ // affects CharName # define NAME_IGNORING_CASE 1 @@ -121,5 +124,6 @@ CharName stringish<CharName>(VString<23> iv) { return CharName(iv); } +} // namespace tmwa #endif // TMWA_MMO_STRS_HPP diff --git a/src/mmo/utils.cpp b/src/mmo/utils.cpp index 2199c33..f8aff2e 100644 --- a/src/mmo/utils.cpp +++ b/src/mmo/utils.cpp @@ -34,6 +34,9 @@ #include "../poison.hpp" + +namespace tmwa +{ //--------------------------------------------------- // E-mail check: return 0 (not correct) or 1 (valid). //--------------------------------------------------- @@ -117,3 +120,4 @@ void log_with_timestamp(io::WriteFile& out, XString line) out.really_put(": ", 2); out.put_line(line); } +} // namespace tmwa diff --git a/src/mmo/utils.hpp b/src/mmo/utils.hpp index f8e84fe..95c89fc 100644 --- a/src/mmo/utils.hpp +++ b/src/mmo/utils.hpp @@ -23,6 +23,7 @@ # include "fwd.hpp" +# include <cstring> # include <ctime> # include <type_traits> @@ -36,6 +37,9 @@ # include "../io/fwd.hpp" + +namespace tmwa +{ template<class T> struct is_trivially_copyable : std::integral_constant<bool, @@ -161,5 +165,6 @@ static_assert(sizeof(TIMESTAMP_DUMMY) == sizeof(timestamp_seconds_buffer), )[-1], \ &t \ ) +} // namespace tmwa #endif // TMWA_MMO_UTILS_HPP diff --git a/src/mmo/version.cpp b/src/mmo/version.cpp index 1fab68d..2e337c1 100644 --- a/src/mmo/version.cpp +++ b/src/mmo/version.cpp @@ -28,6 +28,9 @@ #include "../poison.hpp" + +namespace tmwa +{ Version CURRENT_VERSION = { VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, @@ -70,3 +73,4 @@ bool extract(XString str, Version *vers) // It would've been useful during the magic migration. return extract(str, record<'.'>(&vers->major, &vers->minor, &vers->patch)); } +} // namespace tmwa diff --git a/src/mmo/version.hpp b/src/mmo/version.hpp index f2c146b..634c27f 100644 --- a/src/mmo/version.hpp +++ b/src/mmo/version.hpp @@ -27,6 +27,9 @@ # include "../strings/fwd.hpp" + +namespace tmwa +{ // TODO make these bitwise enums # define TMWA_FLAG_REGISTRATION 0x01 @@ -88,5 +91,6 @@ extern Version CURRENT_MAP_SERVER_VERSION; extern LString CURRENT_VERSION_STRING; bool extract(XString str, Version *vers); +} // namespace tmwa #endif // TMWA_MMO_VERSION_HPP diff --git a/src/monitor/main.cpp b/src/monitor/main.cpp index da03f60..5d7478d 100644 --- a/src/monitor/main.cpp +++ b/src/monitor/main.cpp @@ -47,6 +47,8 @@ #define CONFIG "conf/eathena-monitor.conf"_s +namespace tmwa +{ // initialiized to $HOME/tmwserver static AString workdir; @@ -166,9 +168,11 @@ void stop_process(int sig) #pragma GCC diagnostic pop raise(sig); } +} // namespace tmwa int main(int argc, char *argv[]) { + using namespace tmwa; // These are all the signals we are likely to get // The shell handles stop/cont signal(SIGTERM, stop_process); diff --git a/src/net/fwd.hpp b/src/net/fwd.hpp index 109aeed..2438ccf 100644 --- a/src/net/fwd.hpp +++ b/src/net/fwd.hpp @@ -21,6 +21,9 @@ # include "../sanity.hpp" + +namespace tmwa +{ class Session; class IP4Address; @@ -28,5 +31,6 @@ class IP4Address; class TimerData; enum class RecvResult; +} // namespace tmwa #endif // TMWA_NET_FWD_HPP diff --git a/src/net/ip.cpp b/src/net/ip.cpp index 591faab..bfc2028 100644 --- a/src/net/ip.cpp +++ b/src/net/ip.cpp @@ -27,6 +27,9 @@ #include "../poison.hpp" + +namespace tmwa +{ bool extract(XString str, IP4Address *rv) { if (str.endswith('.')) @@ -114,3 +117,4 @@ VString<31> convert_for_printf(IP4Mask a) return STRNPRINTF(32, "%s/%s"_fmt, a.addr(), a.mask()); } +} // namespace tmwa diff --git a/src/net/ip.hpp b/src/net/ip.hpp index 42a4689..9afc691 100644 --- a/src/net/ip.hpp +++ b/src/net/ip.hpp @@ -28,6 +28,9 @@ # include "../strings/fwd.hpp" + +namespace tmwa +{ // TODO - in the long run ports belong here also // and of course, IPv6 stuff. // But what about unix socket addresses? @@ -161,5 +164,6 @@ VString<31> convert_for_printf(IP4Mask m); bool extract(XString str, IP4Address *iv); bool extract(XString str, IP4Mask *iv); +} // namespace tmwa #endif // TMWA_NET_IP_HPP diff --git a/src/net/ip.py b/src/net/ip.py index e6a8183..bcf90a2 100644 --- a/src/net/ip.py +++ b/src/net/ip.py @@ -2,7 +2,7 @@ class IP4Address(object): ''' print an IP4Address ''' __slots__ = ('_value') - name = 'IP4Address' + name = 'tmwa::IP4Address' enabled = True def __init__(self, value): diff --git a/src/net/ip_test.cpp b/src/net/ip_test.cpp index 9058804..c2095ee 100644 --- a/src/net/ip_test.cpp +++ b/src/net/ip_test.cpp @@ -28,6 +28,8 @@ #include "../poison.hpp" +namespace tmwa +{ #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" #define CB(X) (std::integral_constant<bool, (X)>::value) @@ -356,3 +358,4 @@ TEST(ip4mask, cover) EXPECT_FALSE(m.covers(IP4Address({88, 56, 72, 0}))); EXPECT_FALSE(m.covers(IP4Address({88, 56, 72, 255}))); } +} // namespace tmwa diff --git a/src/net/packets.cpp b/src/net/packets.cpp index fbec8c4..3cba856 100644 --- a/src/net/packets.cpp +++ b/src/net/packets.cpp @@ -23,6 +23,9 @@ #include "../poison.hpp" + +namespace tmwa +{ size_t packet_avail(Session *s) { return s->rdata_size - s->rdata_pos; @@ -100,3 +103,4 @@ void packet_dump(io::WriteFile& logfp, Session *s) } FPRINTF(logfp, "\n"_fmt); } +} // namespace tmwa diff --git a/src/net/packets.hpp b/src/net/packets.hpp index 9cfb1da..e025a63 100644 --- a/src/net/packets.hpp +++ b/src/net/packets.hpp @@ -34,6 +34,9 @@ # include "socket.hpp" + +namespace tmwa +{ struct Buffer { std::vector<Byte> bytes; @@ -580,5 +583,6 @@ RecvResult recv_packet_repeatonly(Session *s, AString& repeat) Packet_Head<id> head; return recv_vpacket<id, 4, repeatsize>(s, head, repeat); } +} // namespace tmwa #endif // TMWA_NET_PACKETS_HPP diff --git a/src/net/socket.cpp b/src/net/socket.cpp index 6e523de..548d3c6 100644 --- a/src/net/socket.cpp +++ b/src/net/socket.cpp @@ -42,6 +42,9 @@ #include "../poison.hpp" + +namespace tmwa +{ static io::FD_Set readfds; static @@ -485,3 +488,4 @@ void do_parsepacket(void) RFIFOFLUSH(s); } } +} // namespace tmwa diff --git a/src/net/socket.hpp b/src/net/socket.hpp index 2b60ac6..64eaf1a 100644 --- a/src/net/socket.hpp +++ b/src/net/socket.hpp @@ -44,6 +44,9 @@ # include "ip.hpp" # include "timer.t.hpp" + +namespace tmwa +{ struct SessionData { }; @@ -172,5 +175,6 @@ void realloc_fifo(Session *s, size_t rfifo_size, size_t wfifo_size); void do_sendrecv(interval_t next); /// Call the parser function for every socket that has read data void do_parsepacket(void); +} // namespace tmwa #endif // TMWA_NET_SOCKET_HPP diff --git a/src/net/timer.cpp b/src/net/timer.cpp index 64077c6..8d03c17 100644 --- a/src/net/timer.cpp +++ b/src/net/timer.cpp @@ -32,6 +32,9 @@ #include "../poison.hpp" + +namespace tmwa +{ struct TimerData { /// This will be reset on call, to avoid problems. @@ -215,3 +218,4 @@ bool has_timers() { return !timer_heap.empty(); } +} // namespace tmwa diff --git a/src/net/timer.hpp b/src/net/timer.hpp index 8fd383d..beda3bf 100644 --- a/src/net/timer.hpp +++ b/src/net/timer.hpp @@ -27,6 +27,9 @@ # include "../strings/fwd.hpp" + +namespace tmwa +{ // updated automatically when using milli_clock::now() // which is done only by core.cpp extern tick_t gettick_cache; @@ -46,5 +49,6 @@ tick_t file_modified(ZString name); /// Check if there are any events at all scheduled. bool has_timers(); +} // namespace tmwa #endif // TMWA_NET_TIMER_HPP diff --git a/src/net/timer.t.hpp b/src/net/timer.t.hpp index 0ed8987..5961f51 100644 --- a/src/net/timer.t.hpp +++ b/src/net/timer.t.hpp @@ -32,6 +32,9 @@ # include "../generic/dumb_ptr.hpp" + +namespace tmwa +{ /// An implementation of the C++ "clock" concept, exposing /// durations in milliseconds. class milli_clock @@ -137,5 +140,6 @@ public: /// Check if there is no connected timer. bool operator !() { return !td; } }; +} // namespace tmwa #endif // TMWA_NET_TIMER_T_HPP diff --git a/src/proto2/any-user.hpp b/src/proto2/any-user.hpp index 6cbf8e3..be77b21 100644 --- a/src/proto2/any-user.hpp +++ b/src/proto2/any-user.hpp @@ -25,6 +25,8 @@ # include "types.hpp" +namespace tmwa +{ // This is a public protocol, and changes require client cooperation template<> @@ -210,5 +212,6 @@ bool network_to_native(Packet_Payload<0x8000> *native, NetPacket_Payload<0x8000> return rv; } +} // namespace tmwa #endif // TMWA_PROTO2_ANY_USER_HPP diff --git a/src/proto2/any-user_test.cpp b/src/proto2/any-user_test.cpp index 5f9747c..3cf15bf 100644 --- a/src/proto2/any-user_test.cpp +++ b/src/proto2/any-user_test.cpp @@ -21,3 +21,7 @@ // This is a generated file, edit tools/protocol.py instead #include "../poison.hpp" + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/proto2/char-map.hpp b/src/proto2/char-map.hpp index 6383130..bd16099 100644 --- a/src/proto2/char-map.hpp +++ b/src/proto2/char-map.hpp @@ -25,6 +25,8 @@ # include "types.hpp" +namespace tmwa +{ // This is an internal protocol, and can be changed without notice template<> @@ -3532,5 +3534,6 @@ bool network_to_native(Packet_Repeat<0x3827> *native, NetPacket_Repeat<0x3827> n return rv; } +} // namespace tmwa #endif // TMWA_PROTO2_CHAR_MAP_HPP diff --git a/src/proto2/char-map_test.cpp b/src/proto2/char-map_test.cpp index e941f1a..b4ba642 100644 --- a/src/proto2/char-map_test.cpp +++ b/src/proto2/char-map_test.cpp @@ -21,3 +21,7 @@ // This is a generated file, edit tools/protocol.py instead #include "../poison.hpp" + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/proto2/char-user.hpp b/src/proto2/char-user.hpp index 2fc3856..89d19de 100644 --- a/src/proto2/char-user.hpp +++ b/src/proto2/char-user.hpp @@ -25,6 +25,8 @@ # include "types.hpp" +namespace tmwa +{ // This is a public protocol, and changes require client cooperation template<> @@ -618,5 +620,6 @@ bool network_to_native(Packet_Fixed<0x0071> *native, NetPacket_Fixed<0x0071> net return rv; } +} // namespace tmwa #endif // TMWA_PROTO2_CHAR_USER_HPP diff --git a/src/proto2/char-user_test.cpp b/src/proto2/char-user_test.cpp index 696b6e4..ade1843 100644 --- a/src/proto2/char-user_test.cpp +++ b/src/proto2/char-user_test.cpp @@ -21,3 +21,7 @@ // This is a generated file, edit tools/protocol.py instead #include "../poison.hpp" + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/proto2/fwd.hpp b/src/proto2/fwd.hpp index d41b7fe..82d917d 100644 --- a/src/proto2/fwd.hpp +++ b/src/proto2/fwd.hpp @@ -23,6 +23,8 @@ # include <cstdint> +namespace tmwa +{ template<uint16_t PACKET_ID> class Packet_Fixed; template<uint16_t PACKET_ID> class NetPacket_Fixed; template<uint16_t PACKET_ID> class Packet_Payload; @@ -1719,5 +1721,6 @@ template<> struct NetPacket_Payload<0x8000>; +} // namespace tmwa #endif // TMWA_PROTO2_FWD_HPP diff --git a/src/proto2/include_clif_t_test.cpp b/src/proto2/include_clif_t_test.cpp index 75d36a0..f0125fe 100644 --- a/src/proto2/include_clif_t_test.cpp +++ b/src/proto2/include_clif_t_test.cpp @@ -20,6 +20,8 @@ #include "../poison.hpp" +namespace tmwa +{ using Test_Position1 = Position1; using Test_NetPosition1 = NetPosition1; using Test_Position2 = Position2; @@ -36,3 +38,4 @@ using Test_SP = SP; using Test_LOOK = LOOK; using Test_IOff2 = IOff2; using Test_SOff1 = SOff1; +} // namespace tmwa diff --git a/src/proto2/include_consts_test.cpp b/src/proto2/include_consts_test.cpp index b093dab..634c0e9 100644 --- a/src/proto2/include_consts_test.cpp +++ b/src/proto2/include_consts_test.cpp @@ -20,4 +20,7 @@ #include "../poison.hpp" +namespace tmwa +{ using Test_PartyMember = PartyMember; +} // namespace tmwa diff --git a/src/proto2/include_cstdint_test.cpp b/src/proto2/include_cstdint_test.cpp index 7462057..917a325 100644 --- a/src/proto2/include_cstdint_test.cpp +++ b/src/proto2/include_cstdint_test.cpp @@ -20,7 +20,10 @@ #include "../poison.hpp" +namespace tmwa +{ using Test_uint8_t = uint8_t; using Test_uint16_t = uint16_t; using Test_uint32_t = uint32_t; using Test_uint64_t = uint64_t; +} // namespace tmwa diff --git a/src/proto2/include_enums_test.cpp b/src/proto2/include_enums_test.cpp index 6fd81f8..f409d28 100644 --- a/src/proto2/include_enums_test.cpp +++ b/src/proto2/include_enums_test.cpp @@ -20,7 +20,10 @@ #include "../poison.hpp" +namespace tmwa +{ using Test_SEX = SEX; using Test_Option = Option; using Test_EPOS = EPOS; using Test_ItemLook = ItemLook; +} // namespace tmwa diff --git a/src/proto2/include_human_time_diff_test.cpp b/src/proto2/include_human_time_diff_test.cpp index 3a5cc49..2e16c99 100644 --- a/src/proto2/include_human_time_diff_test.cpp +++ b/src/proto2/include_human_time_diff_test.cpp @@ -20,4 +20,7 @@ #include "../poison.hpp" +namespace tmwa +{ using Test_HumanTimeDiff = HumanTimeDiff; +} // namespace tmwa diff --git a/src/proto2/include_ids_test.cpp b/src/proto2/include_ids_test.cpp index 7dc26dc..1c1eeca 100644 --- a/src/proto2/include_ids_test.cpp +++ b/src/proto2/include_ids_test.cpp @@ -20,6 +20,8 @@ #include "../poison.hpp" +namespace tmwa +{ using Test_Species = Species; using Test_AccountId = AccountId; using Test_CharId = CharId; @@ -27,3 +29,4 @@ using Test_PartyId = PartyId; using Test_ItemNameId = ItemNameId; using Test_BlockId = BlockId; using Test_GmLevel = GmLevel; +} // namespace tmwa diff --git a/src/proto2/include_ip_test.cpp b/src/proto2/include_ip_test.cpp index a489d9a..d380651 100644 --- a/src/proto2/include_ip_test.cpp +++ b/src/proto2/include_ip_test.cpp @@ -20,4 +20,7 @@ #include "../poison.hpp" +namespace tmwa +{ using Test_IP4Address = IP4Address; +} // namespace tmwa diff --git a/src/proto2/include_little_test.cpp b/src/proto2/include_little_test.cpp index 5e62b33..08a4fbd 100644 --- a/src/proto2/include_little_test.cpp +++ b/src/proto2/include_little_test.cpp @@ -20,7 +20,10 @@ #include "../poison.hpp" +namespace tmwa +{ using Test_Byte = Byte; using Test_Little16 = Little16; using Test_Little32 = Little32; using Test_Little64 = Little64; +} // namespace tmwa diff --git a/src/proto2/include_login_t_test.cpp b/src/proto2/include_login_t_test.cpp index 3273ba3..808e02e 100644 --- a/src/proto2/include_login_t_test.cpp +++ b/src/proto2/include_login_t_test.cpp @@ -20,4 +20,7 @@ #include "../poison.hpp" +namespace tmwa +{ using Test_VERSION_2 = VERSION_2; +} // namespace tmwa diff --git a/src/proto2/include_skill_t_test.cpp b/src/proto2/include_skill_t_test.cpp index e4b957f..4bd944f 100644 --- a/src/proto2/include_skill_t_test.cpp +++ b/src/proto2/include_skill_t_test.cpp @@ -20,6 +20,9 @@ #include "../poison.hpp" +namespace tmwa +{ using Test_SkillID = SkillID; using Test_StatusChange = StatusChange; using Test_SkillFlags = SkillFlags; +} // namespace tmwa diff --git a/src/proto2/include_strs_test.cpp b/src/proto2/include_strs_test.cpp index eeaed7c..67b41f4 100644 --- a/src/proto2/include_strs_test.cpp +++ b/src/proto2/include_strs_test.cpp @@ -20,6 +20,8 @@ #include "../poison.hpp" +namespace tmwa +{ using Test_AccountName = AccountName; using Test_AccountPass = AccountPass; using Test_AccountEmail = AccountEmail; @@ -28,3 +30,4 @@ using Test_PartyName = PartyName; using Test_VarName = VarName; using Test_CharName = CharName; using Test_MapName = MapName; +} // namespace tmwa diff --git a/src/proto2/include_timer_t_test.cpp b/src/proto2/include_timer_t_test.cpp index 859757f..a936021 100644 --- a/src/proto2/include_timer_t_test.cpp +++ b/src/proto2/include_timer_t_test.cpp @@ -20,5 +20,8 @@ #include "../poison.hpp" +namespace tmwa +{ using Test_tick_t = tick_t; using Test_interval_t = interval_t; +} // namespace tmwa diff --git a/src/proto2/include_utils_test.cpp b/src/proto2/include_utils_test.cpp index 106bb59..5b6c92d 100644 --- a/src/proto2/include_utils_test.cpp +++ b/src/proto2/include_utils_test.cpp @@ -20,6 +20,9 @@ #include "../poison.hpp" +namespace tmwa +{ using Test_TimeT = TimeT; using Test_timestamp_seconds_buffer = timestamp_seconds_buffer; using Test_timestamp_milliseconds_buffer = timestamp_milliseconds_buffer; +} // namespace tmwa diff --git a/src/proto2/include_version_test.cpp b/src/proto2/include_version_test.cpp index ed31f49..13856b9 100644 --- a/src/proto2/include_version_test.cpp +++ b/src/proto2/include_version_test.cpp @@ -20,4 +20,7 @@ #include "../poison.hpp" +namespace tmwa +{ using Test_Version = Version; +} // namespace tmwa diff --git a/src/proto2/include_vstring_test.cpp b/src/proto2/include_vstring_test.cpp index 24504ed..3570a29 100644 --- a/src/proto2/include_vstring_test.cpp +++ b/src/proto2/include_vstring_test.cpp @@ -20,8 +20,11 @@ #include "../poison.hpp" +namespace tmwa +{ using Test_VString_15_ = VString<15>; using Test_VString_19_ = VString<19>; using Test_VString_23_ = VString<23>; using Test_VString_31_ = VString<31>; using Test_VString_39_ = VString<39>; +} // namespace tmwa diff --git a/src/proto2/login-admin.hpp b/src/proto2/login-admin.hpp index 30cdb8b..f4965d0 100644 --- a/src/proto2/login-admin.hpp +++ b/src/proto2/login-admin.hpp @@ -25,6 +25,8 @@ # include "types.hpp" +namespace tmwa +{ // This is an internal protocol, and can be changed without notice template<> @@ -2214,5 +2216,6 @@ bool network_to_native(Packet_Fixed<0x7955> *native, NetPacket_Fixed<0x7955> net return rv; } +} // namespace tmwa #endif // TMWA_PROTO2_LOGIN_ADMIN_HPP diff --git a/src/proto2/login-admin_test.cpp b/src/proto2/login-admin_test.cpp index 2cccef2..1bc322d 100644 --- a/src/proto2/login-admin_test.cpp +++ b/src/proto2/login-admin_test.cpp @@ -21,3 +21,7 @@ // This is a generated file, edit tools/protocol.py instead #include "../poison.hpp" + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/proto2/login-char.hpp b/src/proto2/login-char.hpp index a2e0b8e..6b96a03 100644 --- a/src/proto2/login-char.hpp +++ b/src/proto2/login-char.hpp @@ -25,6 +25,8 @@ # include "types.hpp" +namespace tmwa +{ // This is an internal protocol, and can be changed without notice template<> @@ -1231,5 +1233,6 @@ bool network_to_native(Packet_Fixed<0x2741> *native, NetPacket_Fixed<0x2741> net return rv; } +} // namespace tmwa #endif // TMWA_PROTO2_LOGIN_CHAR_HPP diff --git a/src/proto2/login-char_test.cpp b/src/proto2/login-char_test.cpp index ec25fb5..0b61645 100644 --- a/src/proto2/login-char_test.cpp +++ b/src/proto2/login-char_test.cpp @@ -21,3 +21,7 @@ // This is a generated file, edit tools/protocol.py instead #include "../poison.hpp" + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/proto2/login-user.hpp b/src/proto2/login-user.hpp index 5eda66c..822d224 100644 --- a/src/proto2/login-user.hpp +++ b/src/proto2/login-user.hpp @@ -25,6 +25,8 @@ # include "types.hpp" +namespace tmwa +{ // This is a public protocol, and changes require client cooperation template<> @@ -321,5 +323,6 @@ bool network_to_native(Packet_Fixed<0x006a> *native, NetPacket_Fixed<0x006a> net return rv; } +} // namespace tmwa #endif // TMWA_PROTO2_LOGIN_USER_HPP diff --git a/src/proto2/login-user_test.cpp b/src/proto2/login-user_test.cpp index 293a458..fa2128a 100644 --- a/src/proto2/login-user_test.cpp +++ b/src/proto2/login-user_test.cpp @@ -21,3 +21,7 @@ // This is a generated file, edit tools/protocol.py instead #include "../poison.hpp" + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/proto2/map-user.hpp b/src/proto2/map-user.hpp index 598ef3b..efeb0bc 100644 --- a/src/proto2/map-user.hpp +++ b/src/proto2/map-user.hpp @@ -25,6 +25,8 @@ # include "types.hpp" +namespace tmwa +{ // This is a public protocol, and changes require client cooperation template<> @@ -7927,5 +7929,6 @@ bool network_to_native(Packet_Fixed<0x0212> *native, NetPacket_Fixed<0x0212> net return rv; } +} // namespace tmwa #endif // TMWA_PROTO2_MAP_USER_HPP diff --git a/src/proto2/map-user_test.cpp b/src/proto2/map-user_test.cpp index 7d404fe..75d39d5 100644 --- a/src/proto2/map-user_test.cpp +++ b/src/proto2/map-user_test.cpp @@ -21,3 +21,7 @@ // This is a generated file, edit tools/protocol.py instead #include "../poison.hpp" + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/proto2/types.hpp b/src/proto2/types.hpp index e6730c1..bd13114 100644 --- a/src/proto2/types.hpp +++ b/src/proto2/types.hpp @@ -41,6 +41,8 @@ # include "../map/clif.t.hpp" # include "../map/skill.t.hpp" +namespace tmwa +{ template<class T> bool native_to_network(T *network, T native) { @@ -1417,4 +1419,6 @@ bool network_to_native(Storage *native, NetStorage network) return rv; } +} // namespace tmwa + #endif // TMWA_PROTO2_TYPES_HPP diff --git a/src/range/fwd.hpp b/src/range/fwd.hpp index 0c22595..65fd010 100644 --- a/src/range/fwd.hpp +++ b/src/range/fwd.hpp @@ -21,8 +21,12 @@ # include "../sanity.hpp" + +namespace tmwa +{ // meh, add more when I feel like it template<class T> class Slice; +} // namespace tmwa #endif // TMWA_RANGE_FWD_HPP diff --git a/src/range/slice.cpp b/src/range/slice.cpp index 5e00233..f93c19f 100644 --- a/src/range/slice.cpp +++ b/src/range/slice.cpp @@ -19,3 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include "../poison.hpp" + + +namespace tmwa +{ +} // namespace tmwa diff --git a/src/range/slice.hpp b/src/range/slice.hpp index ce35acf..8cd9203 100644 --- a/src/range/slice.hpp +++ b/src/range/slice.hpp @@ -26,6 +26,9 @@ # include <type_traits> # include <vector> + +namespace tmwa +{ template<class T> class Slice { @@ -67,6 +70,7 @@ public: Slice pslice(size_t b, size_t e) const; Slice islice(iterator b, iterator e) const; }; +} // namespace tmwa # include "slice.tcc" diff --git a/src/range/slice.tcc b/src/range/slice.tcc index 45dac50..a1c136f 100644 --- a/src/range/slice.tcc +++ b/src/range/slice.tcc @@ -19,6 +19,9 @@ #include <cassert> + +namespace tmwa +{ // simple pointer-wrapping iterator template<class T> class Slice<T>::iterator @@ -212,3 +215,4 @@ Slice<T> Slice<T>::islice(iterator b, iterator e) const { return Slice(&*b, &*e); } +} // namespace tmwa diff --git a/src/range/slice_test.cpp b/src/range/slice_test.cpp index a58cc78..f49b360 100644 --- a/src/range/slice_test.cpp +++ b/src/range/slice_test.cpp @@ -23,6 +23,8 @@ #include "../poison.hpp" +namespace tmwa +{ #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" TEST(slice, slice) @@ -110,3 +112,4 @@ TEST(slice, cast) EXPECT_EQ(foos.size(), slice.size()); EXPECT_EQ(&foos.end()[-1], &slice.end()[-1]); } +} // namespace tmwa diff --git a/src/sexpr/fwd.hpp b/src/sexpr/fwd.hpp index ad8304b..722d923 100644 --- a/src/sexpr/fwd.hpp +++ b/src/sexpr/fwd.hpp @@ -21,6 +21,10 @@ # include "../sanity.hpp" + +namespace tmwa +{ // meh, add more when I feel like it +} // namespace tmwa #endif // TMWA_SEXPR_FWD_HPP diff --git a/src/sexpr/lexer.cpp b/src/sexpr/lexer.cpp index a032c92..ea1890e 100644 --- a/src/sexpr/lexer.cpp +++ b/src/sexpr/lexer.cpp @@ -26,6 +26,9 @@ #include "../poison.hpp" + +namespace tmwa +{ namespace sexpr { Lexeme Lexer::_adv() @@ -228,3 +231,4 @@ namespace sexpr } } } // namespace sexpr +} // namespace tmwa diff --git a/src/sexpr/lexer.hpp b/src/sexpr/lexer.hpp index 2fec51a..d1c4643 100644 --- a/src/sexpr/lexer.hpp +++ b/src/sexpr/lexer.hpp @@ -29,6 +29,9 @@ # include "../io/line.hpp" + +namespace tmwa +{ namespace sexpr { enum Lexeme @@ -70,5 +73,6 @@ namespace sexpr LString token_name(Lexeme tok); } // namespace sexpr +} // namespace tmwa #endif // TMWA_SEXPR_LEXER_HPP diff --git a/src/sexpr/lexer_test.cpp b/src/sexpr/lexer_test.cpp index 936e92a..acdfa2f 100644 --- a/src/sexpr/lexer_test.cpp +++ b/src/sexpr/lexer_test.cpp @@ -25,6 +25,8 @@ #include "../poison.hpp" +namespace tmwa +{ #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" static @@ -136,3 +138,4 @@ TEST(sexpr, lexbad) EXPECT_EQ(lexer.peek(), sexpr::TOK_ERROR); } } +} // namespace tmwa diff --git a/src/sexpr/parser.cpp b/src/sexpr/parser.cpp index 00d2480..8768e14 100644 --- a/src/sexpr/parser.cpp +++ b/src/sexpr/parser.cpp @@ -25,6 +25,9 @@ #include "../poison.hpp" + +namespace tmwa +{ namespace sexpr { bool token_is_int(ZString s, int64_t& out, bool& ok) @@ -82,3 +85,4 @@ namespace sexpr return rv; } } // namespace sexpr +} // namespace tmwa diff --git a/src/sexpr/parser.hpp b/src/sexpr/parser.hpp index ad3ad90..2404a9a 100644 --- a/src/sexpr/parser.hpp +++ b/src/sexpr/parser.hpp @@ -29,6 +29,9 @@ # include "lexer.hpp" + +namespace tmwa +{ namespace sexpr { enum Type @@ -78,5 +81,6 @@ namespace sexpr /// return false on error or eof, check lex.peek() == TOK_EOF to see bool parse(Lexer& lex, SExpr& out); } // namespace sexpr +} // namespace tmwa #endif // TMWA_SEXPR_PARSER_HPP diff --git a/src/sexpr/parser.py b/src/sexpr/parser.py index d638259..201f457 100644 --- a/src/sexpr/parser.py +++ b/src/sexpr/parser.py @@ -2,7 +2,7 @@ class SExpr(object): ''' print a SExpr ''' __slots__ = ('_value') - name = 'sexpr::SExpr' + name = 'tmwa::sexpr::SExpr' enabled = True def __init__(self, value): diff --git a/src/sexpr/parser_test.cpp b/src/sexpr/parser_test.cpp index e37b78f..5113c1a 100644 --- a/src/sexpr/parser_test.cpp +++ b/src/sexpr/parser_test.cpp @@ -23,6 +23,8 @@ #include "../poison.hpp" +namespace tmwa +{ #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" static @@ -110,3 +112,4 @@ TEST(sexpr, parsebad) EXPECT_EQ(lexer.peek(), sexpr::TOK_ERROR); } } +} // namespace tmwa diff --git a/src/strings/all.hpp b/src/strings/all.hpp index 6b67bee..9311ba4 100644 --- a/src/strings/all.hpp +++ b/src/strings/all.hpp @@ -32,4 +32,9 @@ # include "literal.hpp" # include "vstring.hpp" + +namespace tmwa +{ +} // namespace tmwa + #endif // TMWA_STRINGS_ALL_HPP diff --git a/src/strings/astring.cpp b/src/strings/astring.cpp index 9811f17..f1f12c3 100644 --- a/src/strings/astring.cpp +++ b/src/strings/astring.cpp @@ -34,6 +34,9 @@ // doing sneaky tricks here //#include "../poison.hpp" + +namespace tmwa +{ namespace strings { static_assert(sizeof(AString) == 256, "AString"); @@ -220,3 +223,4 @@ namespace strings return len; } } // namespace strings +} // namespace tmwa diff --git a/src/strings/astring.hpp b/src/strings/astring.hpp index 9e9adc2..cf33cc5 100644 --- a/src/strings/astring.hpp +++ b/src/strings/astring.hpp @@ -24,6 +24,9 @@ # include "base.hpp" # include "rstring.hpp" + +namespace tmwa +{ namespace strings { /// An owning string that has reached its final contents. @@ -77,6 +80,7 @@ namespace strings __attribute__((format(printf, 2, 0))) int do_vprint(AString& out, const char *fmt, va_list ap); } // namespace strings +} // namespace tmwa # include "astring.tcc" diff --git a/src/strings/astring.py b/src/strings/astring.py index ec1dafe..063e721 100644 --- a/src/strings/astring.py +++ b/src/strings/astring.py @@ -2,7 +2,7 @@ class AString(object): ''' print an AString ''' __slots__ = ('_value') - name = 'strings::AString' + name = 'tmwa::strings::AString' enabled = True def __init__(self, value): diff --git a/src/strings/astring.tcc b/src/strings/astring.tcc index f9606d8..f2d0dc9 100644 --- a/src/strings/astring.tcc +++ b/src/strings/astring.tcc @@ -19,6 +19,9 @@ #include "mstring.hpp" + +namespace tmwa +{ namespace strings { template<class It> @@ -57,3 +60,4 @@ namespace strings new(r_ptr()) RString(); } } // namespace strings +} // namespace tmwa diff --git a/src/strings/base.hpp b/src/strings/base.hpp index b1aff34..122d46d 100644 --- a/src/strings/base.hpp +++ b/src/strings/base.hpp @@ -26,6 +26,9 @@ # include <iterator> + +namespace tmwa +{ // It is a common mistake to assume that one string class for everything. // Because C++ and TMWA have a C legacy, there are a few more here // than would probably be necessary in an ideal language. @@ -195,6 +198,7 @@ namespace strings template<class L, class R, typename=typename std::enable_if<string_comparison_allowed<L, R>::value>::type> auto operator >= (const L& l, const R& r) -> decltype((pair_compare(l, r), true)); } // namespace strings +} // namespace tmwa # include "base.tcc" diff --git a/src/strings/base.tcc b/src/strings/base.tcc index 8b7982b..83dff70 100644 --- a/src/strings/base.tcc +++ b/src/strings/base.tcc @@ -23,6 +23,9 @@ #include "pair.hpp" + +namespace tmwa +{ namespace strings { namespace detail @@ -442,3 +445,4 @@ namespace strings return pair_compare(l, r) >= 0; } } // namespace strings +} // namespace tmwa diff --git a/src/strings/base_test.cpp b/src/strings/base_test.cpp index cab47be..2083fdc 100644 --- a/src/strings/base_test.cpp +++ b/src/strings/base_test.cpp @@ -30,6 +30,9 @@ #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" + +namespace tmwa +{ using namespace strings; struct _test : VString<1> {}; @@ -50,3 +53,4 @@ TEST(strings, contains) EXPECT_TRUE(hi.contains_any("Hi"_s)); EXPECT_FALSE(hi.contains_any("hi"_s)); } +} // namespace tmwa diff --git a/src/strings/fwd.hpp b/src/strings/fwd.hpp index de86301..4f1fe89 100644 --- a/src/strings/fwd.hpp +++ b/src/strings/fwd.hpp @@ -24,6 +24,9 @@ # include <cstddef> # include <cstdint> + +namespace tmwa +{ // It is a common mistake to assume that one string class for everything. // Because C++ and TMWA have a C legacy, there are a few more here // than would probably be necessary in an ideal language. @@ -70,5 +73,6 @@ using strings::VString; using strings::operator "" _s; using strings::operator "" _fmt; +} // namespace tmwa #endif // TMWA_STRINGS_FWD_HPP diff --git a/src/strings/literal.cpp b/src/strings/literal.cpp index 506b79b..252bfcb 100644 --- a/src/strings/literal.cpp +++ b/src/strings/literal.cpp @@ -22,6 +22,9 @@ #include "../poison.hpp" + +namespace tmwa +{ namespace strings { LString::LString(const char *b, const char *e) @@ -50,3 +53,4 @@ namespace strings return zs.c_str(); } } // namespace strings +} // namespace tmwa diff --git a/src/strings/literal.hpp b/src/strings/literal.hpp index 001dc46..207ccff 100644 --- a/src/strings/literal.hpp +++ b/src/strings/literal.hpp @@ -23,6 +23,9 @@ # include "base.hpp" + +namespace tmwa +{ namespace strings { /// A statically owned string that is guaranteed to be NUL-terminated. @@ -73,5 +76,6 @@ namespace strings return FormatString(s); } } // namespace strings +} // namespace tmwa #endif // TMWA_STRINGS_LSTRING_HPP diff --git a/src/strings/mstring.cpp b/src/strings/mstring.cpp index 2a1ca62..d48bff2 100644 --- a/src/strings/mstring.cpp +++ b/src/strings/mstring.cpp @@ -22,6 +22,9 @@ #include "../poison.hpp" + +namespace tmwa +{ namespace strings { MString::iterator MString::begin() @@ -100,3 +103,4 @@ namespace strings return _hack.back(); } } // namespace strings +} // namespace tmwa diff --git a/src/strings/mstring.hpp b/src/strings/mstring.hpp index 47becc4..b1ecce3 100644 --- a/src/strings/mstring.hpp +++ b/src/strings/mstring.hpp @@ -23,6 +23,9 @@ # include <deque> + +namespace tmwa +{ namespace strings { /// An owning string that is still expected to change. @@ -62,5 +65,6 @@ namespace strings char& back(); }; } // namespace strings +} // namespace tmwa #endif // TMWA_STRINGS_MSTRING_HPP diff --git a/src/strings/pair.hpp b/src/strings/pair.hpp index cd59537..e249d9e 100644 --- a/src/strings/pair.hpp +++ b/src/strings/pair.hpp @@ -21,6 +21,9 @@ # include "fwd.hpp" + +namespace tmwa +{ namespace strings { // TODO instead typedef ranges::Contiguous<const char> @@ -60,5 +63,6 @@ namespace strings {} }; } // namespace strings +} // namespace tmwa #endif // TMWA_STRINGS_PAIR_HPP diff --git a/src/strings/rstring.cpp b/src/strings/rstring.cpp index c2ca64b..3e5a46d 100644 --- a/src/strings/rstring.cpp +++ b/src/strings/rstring.cpp @@ -31,6 +31,9 @@ // doing sneaky tricks here //#include "../poison.hpp" + +namespace tmwa +{ namespace strings { static_assert(sizeof(RString) == sizeof(const char *), "RString"); @@ -173,3 +176,4 @@ namespace strings return len; } } // namespace strings +} // namespace tmwa diff --git a/src/strings/rstring.hpp b/src/strings/rstring.hpp index ae8b374..c656622 100644 --- a/src/strings/rstring.hpp +++ b/src/strings/rstring.hpp @@ -25,6 +25,9 @@ # include "base.hpp" + +namespace tmwa +{ namespace strings { /// An owning string that has reached its final contents. @@ -83,6 +86,7 @@ namespace strings __attribute__((format(printf, 2, 0))) int do_vprint(RString& out, const char *fmt, va_list ap); } // namespace strings +} // namespace tmwa # include "rstring.tcc" diff --git a/src/strings/rstring.py b/src/strings/rstring.py index f0618d6..8021ec2 100644 --- a/src/strings/rstring.py +++ b/src/strings/rstring.py @@ -2,7 +2,7 @@ class RString(object): ''' print a RString ''' __slots__ = ('_value') - name = 'strings::RString' + name = 'tmwa::strings::RString' enabled = True def __init__(self, value): diff --git a/src/strings/rstring.tcc b/src/strings/rstring.tcc index 6bfc7b0..c247b8f 100644 --- a/src/strings/rstring.tcc +++ b/src/strings/rstring.tcc @@ -19,6 +19,9 @@ #include "mstring.hpp" + +namespace tmwa +{ namespace strings { template<class It> @@ -59,3 +62,4 @@ namespace strings _assign(v.begin(), v.end()); } } // namespace strings +} // namespace tmwa diff --git a/src/strings/sstring.cpp b/src/strings/sstring.cpp index 35885e8..0500129 100644 --- a/src/strings/sstring.cpp +++ b/src/strings/sstring.cpp @@ -27,6 +27,9 @@ #include "../poison.hpp" + +namespace tmwa +{ namespace strings { SString::SString() @@ -102,3 +105,4 @@ namespace strings return &_s; } } // namespace strings +} // namespace tmwa diff --git a/src/strings/sstring.hpp b/src/strings/sstring.hpp index 60fa4f3..5c5a2f5 100644 --- a/src/strings/sstring.hpp +++ b/src/strings/sstring.hpp @@ -24,6 +24,9 @@ # include "base.hpp" # include "rstring.hpp" + +namespace tmwa +{ namespace strings { /// An owning string that represents a arbitrary slice of an RString. @@ -54,6 +57,7 @@ namespace strings const RString *base() const; }; } // namespace strings +} // namespace tmwa # include "sstring.tcc" diff --git a/src/strings/sstring.tcc b/src/strings/sstring.tcc index 89effbc..315e19a 100644 --- a/src/strings/sstring.tcc +++ b/src/strings/sstring.tcc @@ -19,6 +19,9 @@ #include "vstring.hpp" + +namespace tmwa +{ namespace strings { template<uint8_t n> @@ -26,3 +29,4 @@ namespace strings : _s(v), _b(0), _e(_s.size()) {} } // namespace strings +} // namespace tmwa diff --git a/src/strings/strings2_test.cpp b/src/strings/strings2_test.cpp index 23f09fd..872d201 100644 --- a/src/strings/strings2_test.cpp +++ b/src/strings/strings2_test.cpp @@ -24,6 +24,8 @@ #include "../poison.hpp" +namespace tmwa +{ #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" TEST(StringTests, traits2) @@ -226,3 +228,4 @@ TEST(StringTests, rlong) EXPECT_EQ(&*r.begin(), &*r3.begin()); EXPECT_EQ(&*a.begin(), &*a3.begin()); } +} // namespace tmwa diff --git a/src/strings/strings_test.cpp b/src/strings/strings_test.cpp index df4c2c3..8c3d80a 100644 --- a/src/strings/strings_test.cpp +++ b/src/strings/strings_test.cpp @@ -26,6 +26,8 @@ #include "../poison.hpp" +namespace tmwa +{ #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" template<typename T> @@ -308,3 +310,4 @@ typedef ::testing::Types< RString, AString, TString, ZString, VString<255> > NulStringTypes; INSTANTIATE_TYPED_TEST_CASE_P(NulStringStuff, NulStringTest, NulStringTypes); +} // namespace tmwa diff --git a/src/strings/tstring.cpp b/src/strings/tstring.cpp index 77d4b40..b0bd74a 100644 --- a/src/strings/tstring.cpp +++ b/src/strings/tstring.cpp @@ -27,6 +27,9 @@ #include "../poison.hpp" + +namespace tmwa +{ namespace strings { TString::TString() @@ -101,3 +104,4 @@ namespace strings return ts.c_str(); } } // namespace strings +} // namespace tmwa diff --git a/src/strings/tstring.hpp b/src/strings/tstring.hpp index 748af9e..054ce69 100644 --- a/src/strings/tstring.hpp +++ b/src/strings/tstring.hpp @@ -24,6 +24,9 @@ # include "base.hpp" # include "rstring.hpp" + +namespace tmwa +{ namespace strings { /// An owning string that represents a tail slice of an RString. @@ -60,6 +63,7 @@ namespace strings // Actually, it might now. const char *decay_for_printf(const TString& ts); } // namespace strings +} // namespace tmwa # include "tstring.tcc" diff --git a/src/strings/tstring.tcc b/src/strings/tstring.tcc index c62987b..2641fb7 100644 --- a/src/strings/tstring.tcc +++ b/src/strings/tstring.tcc @@ -19,6 +19,9 @@ #include "vstring.hpp" + +namespace tmwa +{ namespace strings { template<uint8_t n> @@ -26,3 +29,4 @@ namespace strings : _s(v), _o(0) {} } // namespace strings +} // namespace tmwa diff --git a/src/strings/vstring.cpp b/src/strings/vstring.cpp index 0ef8f3d..1cb313a 100644 --- a/src/strings/vstring.cpp +++ b/src/strings/vstring.cpp @@ -20,6 +20,10 @@ #include "../poison.hpp" + +namespace tmwa +{ namespace strings { } // namespace strings +} // namespace tmwa diff --git a/src/strings/vstring.hpp b/src/strings/vstring.hpp index 022347a..25051c8 100644 --- a/src/strings/vstring.hpp +++ b/src/strings/vstring.hpp @@ -25,6 +25,9 @@ # include "base.hpp" + +namespace tmwa +{ namespace strings { template<uint8_t n> @@ -73,6 +76,7 @@ T stringish(VString<sizeof(T) - 1> iv) static_cast<VString<sizeof(T) - 1>&>(rv) = iv; return rv; } +} // namespace tmwa # include "vstring.tcc" diff --git a/src/strings/vstring.py b/src/strings/vstring.py index 39e657b..fa975b2 100644 --- a/src/strings/vstring.py +++ b/src/strings/vstring.py @@ -2,7 +2,7 @@ class VString(object): ''' print a VString ''' __slots__ = ('_value') - name = 'strings::VString' + name = 'tmwa::strings::VString' enabled = True def __init__(self, value): diff --git a/src/strings/vstring.tcc b/src/strings/vstring.tcc index 577261a..4f24a20 100644 --- a/src/strings/vstring.tcc +++ b/src/strings/vstring.tcc @@ -29,6 +29,9 @@ #include "xstring.hpp" #include "literal.hpp" + +namespace tmwa +{ namespace strings { template<uint8_t n> @@ -146,3 +149,4 @@ namespace strings return len; } } // namespace strings +} // namespace tmwa diff --git a/src/strings/xstring.cpp b/src/strings/xstring.cpp index 2f97c01..4635a90 100644 --- a/src/strings/xstring.cpp +++ b/src/strings/xstring.cpp @@ -27,6 +27,9 @@ #include "../poison.hpp" + +namespace tmwa +{ namespace strings { XString::XString() @@ -75,3 +78,4 @@ namespace strings return _base; } } // namespace strings +} // namespace tmwa diff --git a/src/strings/xstring.hpp b/src/strings/xstring.hpp index 91371c8..0de2be3 100644 --- a/src/strings/xstring.hpp +++ b/src/strings/xstring.hpp @@ -23,6 +23,9 @@ # include "base.hpp" + +namespace tmwa +{ namespace strings { /// A non-owning string that is not guaranteed to be NUL-terminated. @@ -55,6 +58,7 @@ namespace strings const RString *base() const; }; } // namespace strings +} // namespace tmwa # include "xstring.tcc" diff --git a/src/strings/xstring.py b/src/strings/xstring.py index 92cb78b..fa0abcb 100644 --- a/src/strings/xstring.py +++ b/src/strings/xstring.py @@ -2,7 +2,7 @@ class XString(object): ''' print a XString ''' __slots__ = ('_value') - name = 'strings::XString' + name = 'tmwa::strings::XString' enabled = True def __init__(self, value): diff --git a/src/strings/xstring.tcc b/src/strings/xstring.tcc index 8115d23..e9f0f1e 100644 --- a/src/strings/xstring.tcc +++ b/src/strings/xstring.tcc @@ -19,6 +19,9 @@ #include "vstring.hpp" + +namespace tmwa +{ namespace strings { template<uint8_t n> @@ -26,3 +29,4 @@ namespace strings : _b(&*s.begin()), _e(&*s.end()), _base(nullptr) {} } // namespace strings +} // namespace tmwa diff --git a/src/strings/zstring.cpp b/src/strings/zstring.cpp index 94535d0..01e9c2b 100644 --- a/src/strings/zstring.cpp +++ b/src/strings/zstring.cpp @@ -28,6 +28,9 @@ #include "../poison.hpp" + +namespace tmwa +{ namespace strings { ZString::ZString() @@ -75,3 +78,4 @@ namespace strings return zs.c_str(); } } // namespace strings +} // namespace tmwa diff --git a/src/strings/zstring.hpp b/src/strings/zstring.hpp index a0dda2c..e82c9fb 100644 --- a/src/strings/zstring.hpp +++ b/src/strings/zstring.hpp @@ -23,6 +23,9 @@ # include "base.hpp" + +namespace tmwa +{ namespace strings { /// A non-owning string that is guaranteed to be NUL-terminated. @@ -60,6 +63,7 @@ namespace strings // Actually, it might now. const char *decay_for_printf(const ZString& zs); } // namespace strings +} // namespace tmwa # include "zstring.tcc" diff --git a/src/strings/zstring.py b/src/strings/zstring.py index 5021e1c..dca5f4e 100644 --- a/src/strings/zstring.py +++ b/src/strings/zstring.py @@ -2,7 +2,7 @@ class ZString(object): ''' print a ZString ''' __slots__ = ('_value') - name = 'strings::ZString' + name = 'tmwa::strings::ZString' enabled = True def __init__(self, value): diff --git a/src/strings/zstring.tcc b/src/strings/zstring.tcc index eb55f5a..2eaa8c0 100644 --- a/src/strings/zstring.tcc +++ b/src/strings/zstring.tcc @@ -19,6 +19,9 @@ #include "vstring.hpp" + +namespace tmwa +{ namespace strings { template<uint8_t n> @@ -26,3 +29,4 @@ namespace strings : _b(&*s.begin()), _e(&*s.end()), _base(nullptr) {} } // namespace strings +} // namespace tmwa diff --git a/src/tests/test.cpp b/src/tests/test.cpp index a45eecf..d731d7c 100644 --- a/src/tests/test.cpp +++ b/src/tests/test.cpp @@ -21,6 +21,11 @@ #include "../poison.hpp" + +namespace tmwa +{ +} // namespace tmwa + int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/tools/protocol.py b/tools/protocol.py index a6214fc..6883c3a 100755 --- a/tools/protocol.py +++ b/tools/protocol.py @@ -424,10 +424,11 @@ class Include(object): f.write(self.pp(0)) f.write(copyright.format(filename=filename, description=desc)) f.write('\n') - f.write('#include "%s"\n\n' % poison) + f.write('#include "%s"\n\nnamespace tmwa\n{\n' % poison) for t in self._types: f.write('using %s = %s;\n' % ('Test_' + ident(t.name), t.name)) + f.write('} // namespace tmwa\n') def pp(self, n): return '#%*sinclude %s\n' % (n, '', self.path) @@ -563,6 +564,7 @@ class Channel(object): f.write('# include "fwd.hpp"\n\n') f.write('# include "types.hpp"\n') f.write('\n') + f.write('namespace tmwa\n{\n') if client == 'user': f.write('// This is a public protocol, and changes require client cooperation\n') else: @@ -579,6 +581,7 @@ class Channel(object): f.write('\n') for p in self.packets: p.dump_convert(f) + f.write('} // namespace tmwa\n') f.write('\n') f.write('#endif // %s\n' % define) @@ -589,7 +592,8 @@ class Channel(object): f.write('\n') f.write(generated) f.write('\n') - f.write('#include "{}"\n'.format(poison)) + f.write('#include "%s"\n\nnamespace tmwa\n{\n' % poison) + f.write('} // namespace tmwa\n') ident_translation = ''.join(chr(c) if chr(c).isalnum() else '_' for c in range(256)) @@ -647,6 +651,7 @@ class Context(object): f.write('\n') f.write('# include "%s"\n\n' % sanity) f.write('# include <cstdint>\n\n') + f.write('namespace tmwa\n{\n') for b in ['Fixed', 'Payload', 'Head', 'Repeat', 'Option']: c = 'Packet_' + b f.write('template<uint16_t PACKET_ID> class %s;\n' % c) @@ -656,6 +661,7 @@ class Context(object): for ch in self._channels: ch.dump(outdir, f) + f.write('} // namespace tmwa\n') f.write('\n') f.write('#endif // %s\n' % define) @@ -677,6 +683,7 @@ class Context(object): # this is writing another file inc.testcase(outdir) f.write('\n') + f.write('namespace tmwa\n{\n') f.write('template<class T>\n') f.write('bool native_to_network(T *network, T native)\n{\n') @@ -784,6 +791,7 @@ class Context(object): for ty in self._types: ty.dump(f) + f.write('} // namespace tmwa\n\n') f.write('#endif // %s\n' % define) for g in glob.glob(os.path.join(outdir, '*.old')): |