summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/net.cpp16
-rw-r--r--src/net/net.h2
-rw-r--r--src/net/serverinfo.h51
3 files changed, 35 insertions, 34 deletions
diff --git a/src/net/net.cpp b/src/net/net.cpp
index c060d2e8..86f7dc13 100644
--- a/src/net/net.cpp
+++ b/src/net/net.cpp
@@ -125,18 +125,18 @@ Net::TradeHandler *Net::getTradeHandler()
namespace Net
{
-ServerInfo::Type networkType = ServerInfo::UNKNOWN;
+ServerType networkType = ServerType::UNKNOWN;
void connectToServer(ServerInfo &server)
{
- if (server.type == ServerInfo::UNKNOWN)
+ if (server.type == ServerType::UNKNOWN)
{
// TODO: Query the server about itself and choose the netcode based on
// that
if (server.port == 6901)
- server.type = ServerInfo::TMWATHENA;
+ server.type = ServerType::TMWATHENA;
else if (server.port == 9601)
- server.type = ServerInfo::MANASERV;
+ server.type = ServerType::MANASERV;
else
logger->error(_("Unknown Server Type! Exiting."));
}
@@ -147,7 +147,7 @@ void connectToServer(ServerInfo &server)
}
else
{
- if (networkType != ServerInfo::UNKNOWN && getGeneralHandler() != nullptr)
+ if (networkType != ServerType::UNKNOWN && getGeneralHandler() != nullptr)
{
getGeneralHandler()->unload();
}
@@ -155,11 +155,11 @@ void connectToServer(ServerInfo &server)
switch (server.type)
{
#ifdef MANASERV_SUPPORT
- case ServerInfo::MANASERV:
+ case ServerType::MANASERV:
new ManaServ::GeneralHandler;
break;
#endif
- case ServerInfo::TMWATHENA:
+ case ServerType::TMWATHENA:
new TmwAthena::GeneralHandler;
break;
default:
@@ -186,7 +186,7 @@ void unload()
}
}
-ServerInfo::Type getNetworkType()
+ServerType getNetworkType()
{
return networkType;
}
diff --git a/src/net/net.h b/src/net/net.h
index 46a63ce9..135f2cb7 100644
--- a/src/net/net.h
+++ b/src/net/net.h
@@ -62,7 +62,7 @@ PlayerHandler *getPlayerHandler();
SpecialHandler *getSpecialHandler();
TradeHandler *getTradeHandler();
-ServerInfo::Type getNetworkType();
+ServerType getNetworkType();
/**
* Handles server detection and connection
diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h
index 481ef7cd..fd66c676 100644
--- a/src/net/serverinfo.h
+++ b/src/net/serverinfo.h
@@ -28,18 +28,19 @@
#include <deque>
#include <string>
+enum class ServerType
+{
+ UNKNOWN,
+ MANASERV,
+ TMWATHENA
+};
+
class ServerInfo
{
public:
- enum Type {
- UNKNOWN,
- MANASERV,
- TMWATHENA
- };
-
using VersionString = std::pair<int, std::string>;
- Type type = UNKNOWN;
+ ServerType type = ServerType::UNKNOWN;
std::string name;
std::string hostname;
uint16_t port = 0;
@@ -52,7 +53,7 @@ public:
bool isValid() const
{
- return !hostname.empty() && port != 0 && type != UNKNOWN;
+ return !hostname.empty() && port != 0 && type != ServerType::UNKNOWN;
}
void clear()
@@ -72,39 +73,39 @@ public:
port != other.port);
}
- static Type parseType(const std::string &type)
+ static ServerType parseType(const std::string &type)
{
if (compareStrI(type, "tmwathena") == 0)
- return TMWATHENA;
+ return ServerType::TMWATHENA;
// Used for backward compatibility
if (compareStrI(type, "eathena") == 0)
- return TMWATHENA;
+ return ServerType::TMWATHENA;
if (compareStrI(type, "manaserv") == 0)
- return MANASERV;
- return UNKNOWN;
+ return ServerType::MANASERV;
+ return ServerType::UNKNOWN;
}
- static uint16_t defaultPortForServerType(Type type)
+ static uint16_t defaultPortForServerType(ServerType type)
{
switch (type)
{
- default:
- case ServerInfo::UNKNOWN:
- return 0;
- case ServerInfo::TMWATHENA:
- return 6901;
- case ServerInfo::MANASERV:
- return 9601;
+ default:
+ case ServerType::UNKNOWN:
+ return 0;
+ case ServerType::TMWATHENA:
+ return 6901;
+ case ServerType::MANASERV:
+ return 9601;
}
}
- static Type defaultServerTypeForPort(uint16_t port)
+ static ServerType defaultServerTypeForPort(uint16_t port)
{
if (port == 6901)
- return TMWATHENA;
+ return ServerType::TMWATHENA;
if (port == 9601)
- return MANASERV;
- return UNKNOWN;
+ return ServerType::MANASERV;
+ return ServerType::UNKNOWN;
}
};