summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-01-24 14:41:18 -0700
committerJared Adams <jaxad0127@gmail.com>2010-01-24 14:41:18 -0700
commit889108ea9a75a0591cac7efb49bac65629b6fb86 (patch)
tree9350c4d10df554c15d1135acc8b4738b531f1018 /src
parentbee1477e6f7c029c94c1c0e119e4529d3a55ecda (diff)
downloadmana-client-889108ea9a75a0591cac7efb49bac65629b6fb86.tar.gz
mana-client-889108ea9a75a0591cac7efb49bac65629b6fb86.tar.bz2
mana-client-889108ea9a75a0591cac7efb49bac65629b6fb86.tar.xz
mana-client-889108ea9a75a0591cac7efb49bac65629b6fb86.zip
Better handle server types
Now they are stored in the config file instead of defaulting to current build type.
Diffstat (limited to 'src')
-rw-r--r--src/gui/serverdialog.cpp53
-rw-r--r--src/net/serverinfo.h9
2 files changed, 39 insertions, 23 deletions
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index 40add9a6..7318a534 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -47,6 +47,35 @@
#define MAX_SERVERLIST 5
+ServerInfo::Type stringToServerType(const std::string &type)
+{
+ if (compareStrI(type, "eathena") == 0)
+ {
+ return ServerInfo::MANASERV;
+ }
+ else if (compareStrI(type, "manaserv") == 0)
+ {
+ return ServerInfo::MANASERV;
+ }
+ else
+ {
+ return ServerInfo::UNKNOWN;
+ }
+}
+
+std::string serverTypeToString(ServerInfo::Type type)
+{
+ switch (type)
+ {
+ case ServerInfo::EATHENA:
+ return "eAthena";
+ case ServerInfo::MANASERV:
+ return "manaserv";
+ default:
+ return "";
+ }
+}
+
ServersListModel::ServersListModel(ServerInfos *servers, ServerDialog *parent):
mServers(servers),
mParent(parent)
@@ -108,7 +137,10 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
currentConfig = "MostUsedServerPort" + toString(i);
currentServer.port = (short) config.getValue(currentConfig, DEFAULT_PORT);
- currentServer.type = ServerInfo::getCurrentType();
+
+ currentConfig = "MostUsedServerType" + toString(i);
+ currentServer.type = stringToServerType(config
+ .getValue(currentConfig, ""));
if (!currentServer.hostname.empty() && currentServer.port != 0)
{
@@ -208,12 +240,14 @@ void ServerDialog::action(const gcn::ActionEvent &event)
ServerInfo tempServer;
currentServer.hostname = mServerNameField->getText();
currentServer.port = (short) atoi(mPortField->getText().c_str());
- currentServer.type = ServerInfo::getCurrentType();
+ currentServer.type = ServerInfo::UNKNOWN;
// now rewrite the configuration...
// id = 0 is always the last selected server
config.setValue("MostUsedServerName0", currentServer.hostname);
config.setValue("MostUsedServerPort0", currentServer.port);
+ config.setValue("MostUsedServerType0",
+ serverTypeToString(currentServer.type));
// now add the rest of the list...
std::string currentConfig = "";
@@ -229,6 +263,8 @@ void ServerDialog::action(const gcn::ActionEvent &event)
config.setValue(currentConfig, toString(tempServer.hostname));
currentConfig = "MostUsedServerPort" + toString(configCount);
config.setValue(currentConfig, toString(tempServer.port));
+ currentConfig = "MostUsedServerType" + toString(configCount);
+ config.setValue(currentConfig, serverTypeToString(tempServer.type));
configCount++;
}
@@ -386,18 +422,7 @@ 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.type = stringToServerType(type);
currentServer.hostname = XML::getProperty(subnode, "hostname", std::string());
currentServer.port = XML::getProperty(subnode, "port", DEFAULT_PORT);
}
diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h
index 335a2115..ec8cc655 100644
--- a/src/net/serverinfo.h
+++ b/src/net/serverinfo.h
@@ -74,15 +74,6 @@ public:
return (type != other.type || hostname != other.hostname ||
port != other.port);
}
-
- Type static getCurrentType()
- {
-#ifdef MANASERV_SUPPORT
- return MANASERV;
-#else
- return EATHENA;
-#endif
- }
};
typedef std::vector<ServerInfo> ServerInfos;