summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/logindata.h2
-rw-r--r--src/net/manaserv/connection.cpp2
-rw-r--r--src/net/manaserv/connection.h4
-rw-r--r--src/net/serverinfo.h24
4 files changed, 21 insertions, 11 deletions
diff --git a/src/net/logindata.h b/src/net/logindata.h
index 380f9061..1e19b541 100644
--- a/src/net/logindata.h
+++ b/src/net/logindata.h
@@ -40,7 +40,7 @@ public:
std::string email;
std::string captchaResponse;
- Gender gender;
+ Gender gender = GENDER_UNSPECIFIED;
bool remember; /**< Whether to store the username. */
bool registerLogin; /**< Whether an account is being registered. */
diff --git a/src/net/manaserv/connection.cpp b/src/net/manaserv/connection.cpp
index d439f964..896d86ad 100644
--- a/src/net/manaserv/connection.cpp
+++ b/src/net/manaserv/connection.cpp
@@ -42,7 +42,7 @@ Connection::~Connection()
connections--;
}
-bool Connection::connect(const std::string &address, short port)
+bool Connection::connect(const std::string &address, enet_uint16 port)
{
logger->log("Net::Connection::connect(%s, %i)", address.c_str(), port);
diff --git a/src/net/manaserv/connection.h b/src/net/manaserv/connection.h
index e6646e0e..dfd45e31 100644
--- a/src/net/manaserv/connection.h
+++ b/src/net/manaserv/connection.h
@@ -25,8 +25,6 @@
#include <enet/enet.h>
#include "net/manaserv/network.h"
-#include <iosfwd>
-
namespace ManaServ
{
class MessageOut;
@@ -49,7 +47,7 @@ namespace ManaServ
* This method is non-blocking, use isConnected to check whether the
* server is connected.
*/
- bool connect(const std::string &address, short port);
+ bool connect(const std::string &address, enet_uint16 port);
/**
* Disconnects from the given server.
diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h
index f9119d19..481ef7cd 100644
--- a/src/net/serverinfo.h
+++ b/src/net/serverinfo.h
@@ -24,8 +24,9 @@
#include "utils/stringutils.h"
-#include <string>
+#include <cstdint>
#include <deque>
+#include <string>
class ServerInfo
{
@@ -41,7 +42,7 @@ public:
Type type = UNKNOWN;
std::string name;
std::string hostname;
- unsigned short port = 0;
+ uint16_t port = 0;
std::string description;
VersionString version = std::make_pair(0, std::string());
@@ -51,7 +52,7 @@ public:
bool isValid() const
{
- return !(hostname.empty() || port == 0 || type == UNKNOWN);
+ return !hostname.empty() && port != 0 && type != UNKNOWN;
}
void clear()
@@ -76,24 +77,35 @@ public:
if (compareStrI(type, "tmwathena") == 0)
return TMWATHENA;
// Used for backward compatibility
- else if (compareStrI(type, "eathena") == 0)
+ if (compareStrI(type, "eathena") == 0)
return TMWATHENA;
- else if (compareStrI(type, "manaserv") == 0)
+ if (compareStrI(type, "manaserv") == 0)
return MANASERV;
return UNKNOWN;
}
- static unsigned short defaultPortForServerType(Type type)
+ static uint16_t defaultPortForServerType(Type type)
{
switch (type)
{
default:
+ case ServerInfo::UNKNOWN:
+ return 0;
case ServerInfo::TMWATHENA:
return 6901;
case ServerInfo::MANASERV:
return 9601;
}
}
+
+ static Type defaultServerTypeForPort(uint16_t port)
+ {
+ if (port == 6901)
+ return TMWATHENA;
+ if (port == 9601)
+ return MANASERV;
+ return UNKNOWN;
+ }
};
using ServerInfos = std::deque<ServerInfo>;