summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-12-05 00:12:04 -0700
committerJared Adams <jaxad0127@gmail.com>2009-12-05 00:12:04 -0700
commit3353d1a87fbfe2e6830a4b77470d9a5a1cdac593 (patch)
treef272b22eee0baa24f1de3cbc136327652045bb58
parent1eb02f83a5d3895e4e18db30ea10d88da94ba4c0 (diff)
downloadmana-3353d1a87fbfe2e6830a4b77470d9a5a1cdac593.tar.gz
mana-3353d1a87fbfe2e6830a4b77470d9a5a1cdac593.tar.bz2
mana-3353d1a87fbfe2e6830a4b77470d9a5a1cdac593.tar.xz
mana-3353d1a87fbfe2e6830a4b77470d9a5a1cdac593.zip
Add a type member to ServerInfo and code for it
Some of the code is waiting for ifdef removal.
-rw-r--r--src/gui/serverdialog.cpp16
-rw-r--r--src/net/net.cpp51
-rw-r--r--src/net/serverinfo.h28
3 files changed, 85 insertions, 10 deletions
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index ec2b0cf4..39c2792f 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -355,8 +355,8 @@ void ServerDialog::loadServers()
{
// check wether the build matches (remove with last instances
// if _SUPPORT ifdefs)
- if (compareStrI(XML::getProperty(server, "type", "unknown"),
- SERVER_BUILD))
+ std::string type = XML::getProperty(server, "type", "unknown");
+ if (compareStrI(type, SERVER_BUILD))
{
continue;
}
@@ -368,6 +368,18 @@ void ServerDialog::loadServers()
{
if (xmlStrEqual(subnode->name, BAD_CAST "connection"))
{
+ if (compareStrI(type, "manaserv"))
+ {
+ currentServer.type = ServerInfo::MANASERV;
+ }
+ else if (compareStrI(type, "eathena"))
+ {
+ currentServer.type = ServerInfo::EATHENA;
+ }
+ else
+ {
+ currentServer.type = ServerInfo::UNKNOWN;
+ }
currentServer.hostname = XML::getProperty(subnode, "hostname", std::string());
currentServer.port = XML::getProperty(subnode, "port", DEFAULT_PORT);
}
diff --git a/src/net/net.cpp b/src/net/net.cpp
index 9740844d..50baac73 100644
--- a/src/net/net.cpp
+++ b/src/net/net.cpp
@@ -121,15 +121,13 @@ Net::TradeHandler *Net::getTradeHandler()
namespace Net
{
- bool networkLoaded = false;
+ ServerInfo::Type networkType = ServerInfo::UNKNOWN;
} // namespace Net
void Net::connectToServer(const ServerInfo &server)
{
- // TODO: Actually query the server about itself and choose the netcode
- // based on that
-
- if (networkLoaded)
+ // Remove with ifdefs
+ if (networkType != ServerInfo::UNKNOWN)
{
getGeneralHandler()->reload();
}
@@ -142,9 +140,50 @@ void Net::connectToServer(const ServerInfo &server)
#endif
getGeneralHandler()->load();
+
+ networkType = server.type;
}
+ // End remove section
+
+ // Uncomment after ifdefs removed
+ /*ServerInfo server = ServerInfo(inServer);
+ if (server.type == ServerInfo::UNKNOWN)
+ {
+ // TODO: Query the server about itself and choose the netcode based on
+ // that
+ }
+
+ //if (networkType == server.type)
+ if (networkType != ServerInfo::UNKNOWN)
+ {
+ getGeneralHandler()->reload();
+ }
+ else
+ {
+ if (networkType != ServerInfo::UNKNOWN)
+ {
+ getGeneralHandler()->unload();
+ }
+
+ switch (server.type)
+ {
+ case ServerInfo::MANASERV:
+ new ManaServ::GeneralHandler;
+ break;
+
+ case ServerInfo::EATHENA:
+ new EAthena::GeneralHandler;
+ break;
+
+ default:
+ // Shouldn't happen...
+ break;
+ }
+
+ getGeneralHandler()->load();
- networkLoaded = true;
+ networkType = server.type;
+ }*/
getLoginHandler()->setServer(server);
diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h
index 4f68c6d6..82d11fec 100644
--- a/src/net/serverinfo.h
+++ b/src/net/serverinfo.h
@@ -28,12 +28,34 @@
class ServerInfo
{
public:
+ enum Type {
+ UNKNOWN,
+ MANASERV,
+ EATHENA
+ };
+
+ Type type;
std::string name;
std::string hostname;
unsigned short port;
+ ServerInfo()
+ {
+ type = UNKNOWN;
+ port = 0;
+ }
+
+ ServerInfo(const ServerInfo &info)
+ {
+ type = info.type;
+ name = info.name;
+ hostname = info.hostname;
+ port = info.port;
+ }
+
void clear()
{
+ type = UNKNOWN;
name.clear();
hostname.clear();
port = 0;
@@ -41,12 +63,14 @@ public:
bool operator==(const ServerInfo &other)
{
- return (hostname == other.hostname && port == other.port);
+ return (type == other.type && hostname == other.hostname &&
+ port == other.port);
}
bool operator!=(const ServerInfo &other)
{
- return (hostname != other.hostname || port != other.port);
+ return (type != other.type || hostname != other.hostname ||
+ port != other.port);
}
};