diff options
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/eathena/serverfeatures.cpp | 2 | ||||
-rw-r--r-- | src/net/net.cpp | 16 | ||||
-rw-r--r-- | src/net/net.h | 2 | ||||
-rw-r--r-- | src/net/serverinfo.h | 40 |
4 files changed, 28 insertions, 32 deletions
diff --git a/src/net/eathena/serverfeatures.cpp b/src/net/eathena/serverfeatures.cpp index 8cf172d20..956c134e3 100644 --- a/src/net/eathena/serverfeatures.cpp +++ b/src/net/eathena/serverfeatures.cpp @@ -162,7 +162,7 @@ bool ServerFeatures::haveBankApi() const bool ServerFeatures::haveServerVersion() const { - return Net::getNetworkType() == ServerInfo::EVOL2; + return Net::getNetworkType() == ServerType::EVOL2; } bool ServerFeatures::haveMapServerVersion() const diff --git a/src/net/net.cpp b/src/net/net.cpp index 6c832e5f4..e744786cd 100644 --- a/src/net/net.cpp +++ b/src/net/net.cpp @@ -102,7 +102,7 @@ Net::MarketHandler *marketHandler = nullptr; namespace Net { -ServerInfo::Type networkType = ServerInfo::UNKNOWN; +ServerType::Type networkType = ServerType::UNKNOWN; std::set<int> ignorePackets; void connectToServer(const ServerInfo &server) @@ -114,22 +114,22 @@ void connectToServer(const ServerInfo &server) } else { - if (networkType != ServerInfo::UNKNOWN && generalHandler) + if (networkType != ServerType::UNKNOWN && generalHandler) generalHandler->unload(); switch (server.type) { - case ServerInfo::EATHENA: - case ServerInfo::EVOL2: + case ServerType::EATHENA: + case ServerType::EVOL2: #ifdef EATHENA_SUPPORT new EAthena::GeneralHandler; #else new TmwAthena::GeneralHandler; #endif break; - case ServerInfo::TMWATHENA: - case ServerInfo::EVOL: - case ServerInfo::UNKNOWN: + case ServerType::TMWATHENA: + case ServerType::EVOL: + case ServerType::UNKNOWN: default: #ifdef TMWA_SUPPORT new TmwAthena::GeneralHandler; @@ -160,7 +160,7 @@ void unload() ignorePackets.clear(); } -ServerInfo::Type getNetworkType() +ServerType::Type getNetworkType() { return networkType; } diff --git a/src/net/net.h b/src/net/net.h index 9c8b3f4de..ccd363b81 100644 --- a/src/net/net.h +++ b/src/net/net.h @@ -36,7 +36,7 @@ namespace Net { -ServerInfo::Type getNetworkType() A_WARN_UNUSED; +ServerType::Type getNetworkType() A_WARN_UNUSED; /** * Handles server detection and connection diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h index 35e40e889..a1b0c5b41 100644 --- a/src/net/serverinfo.h +++ b/src/net/serverinfo.h @@ -23,6 +23,8 @@ #ifndef NET_SERVERINFO_H #define NET_SERVERINFO_H +#include "enums/net/servertype.h" + #include "utils/stringutils.h" #include <SDL_stdinc.h> @@ -35,18 +37,9 @@ class ServerInfo final { public: - enum Type - { - UNKNOWN = 0, - TMWATHENA, - EVOL, - EATHENA, - EVOL2 - }; - typedef std::pair<int, std::string> VersionString; - Type type; + ServerType::Type type; std::string name; std::string hostname; std::string althostname; @@ -61,7 +54,7 @@ class ServerInfo final bool persistentIp; ServerInfo() : - type(TMWATHENA), + type(ServerType::TMWATHENA), name(), hostname(), althostname(), @@ -103,12 +96,14 @@ class ServerInfo final bool isValid() const A_WARN_UNUSED { - return !(hostname.empty() || port == 0 || type == UNKNOWN); + return !(hostname.empty() + || port == 0 + || type == ServerType::UNKNOWN); } void clear() { - type = UNKNOWN; + type = ServerType::UNKNOWN; name.clear(); hostname.clear(); althostname.clear(); @@ -136,30 +131,31 @@ class ServerInfo final port != other.port); } - static Type parseType(const std::string &serverType) A_WARN_UNUSED + static ServerType::Type parseType(const std::string &serverType) + A_WARN_UNUSED { #ifdef TMWA_SUPPORT if (compareStrI(serverType, "tmwathena") == 0) - return TMWATHENA; + return ServerType::TMWATHENA; if (compareStrI(serverType, "evol") == 0) - return EVOL; + return ServerType::EVOL; #else if (compareStrI(serverType, "tmwathena") == 0 || compareStrI(serverType, "evol") == 0) - return EATHENA; + return ServerType::EATHENA; #endif #ifdef EATHENA_SUPPORT else if (compareStrI(serverType, "eathena") == 0) - return EATHENA; + return ServerType::EATHENA; else if (compareStrI(serverType, "evol2") == 0) - return EVOL2; + return ServerType::EVOL2; #else else if (compareStrI(serverType, "eathena") == 0) - return TMWATHENA; + return ServerType::TMWATHENA; else if (compareStrI(serverType, "evol2") == 0) - return TMWATHENA; + return ServerType::TMWATHENA; #endif - return UNKNOWN; + return ServerType::UNKNOWN; } }; |