From 2f4fc005937e75d931eb6ef87a3fe16364d45113 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Thu, 26 Jun 2014 21:59:27 -0700 Subject: Stick everything in a namespace --- src/mmo/config_parse.cpp | 4 ++++ src/mmo/config_parse.hpp | 4 ++++ src/mmo/consts.cpp | 5 +++++ src/mmo/consts.hpp | 4 ++++ src/mmo/core.cpp | 6 ++++++ src/mmo/core.hpp | 4 ++++ src/mmo/enums.cpp | 5 +++++ src/mmo/enums.hpp | 4 ++++ src/mmo/extract.cpp | 4 ++++ src/mmo/extract.hpp | 4 ++++ src/mmo/extract_test.cpp | 3 +++ src/mmo/fwd.hpp | 4 ++++ src/mmo/human_time_diff.cpp | 5 +++++ src/mmo/human_time_diff.hpp | 4 ++++ src/mmo/human_time_diff_test.cpp | 3 +++ src/mmo/ids.cpp | 5 +++++ src/mmo/ids.hpp | 4 ++++ src/mmo/md5more.cpp | 4 ++++ src/mmo/md5more.hpp | 4 ++++ src/mmo/mmo.cpp | 5 +++++ src/mmo/mmo.hpp | 4 ++++ src/mmo/strs.cpp | 5 +++++ src/mmo/strs.hpp | 4 ++++ src/mmo/utils.cpp | 4 ++++ src/mmo/utils.hpp | 5 +++++ src/mmo/version.cpp | 4 ++++ src/mmo/version.hpp | 4 ++++ 27 files changed, 115 insertions(+) (limited to 'src/mmo') 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 . #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(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); /// 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 . #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 bool do_extract(XString str, T t); @@ -227,5 +230,6 @@ bool extract(XString str, Wrapped *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 . #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 . #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 { public: explicit operator bool() const = delete; bool operator !() const = delete; constexpr Species() : Wrapped() {} protected: constexpr explicit Species(uint16_t a) : Wrapped(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(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 . #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 . #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(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 # include # include @@ -36,6 +37,9 @@ # include "../io/fwd.hpp" + +namespace tmwa +{ template struct is_trivially_copyable : std::integral_constant(&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 -- cgit v1.2.3-60-g2f50