summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/serverdialog.cpp51
-rw-r--r--src/gui/serverdialog.h3
-rw-r--r--src/net/net.cpp4
3 files changed, 58 insertions, 0 deletions
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index c8a16b35..abe898b0 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -198,13 +198,18 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
mDownloadStatus(DOWNLOADING_PREPARING),
mDownloadProgress(-1.0f),
mServers(ServerInfos()),
+#ifndef MANASERV_SUPPORT
+ mManaservServers(ServerInfos()),
+#endif
mServerInfo(serverInfo)
{
setWindowName("ServerDialog");
Label *serverLabel = new Label(_("Server:"));
Label *portLabel = new Label(_("Port:"));
+#ifdef MANASERV_SUPPORT
Label *typeLabel = new Label(_("Server type:"));
+#endif
mServerNameField = new TextField(mServerInfo->hostname);
mPortField = new TextField(toString(mServerInfo->port));
@@ -242,6 +247,7 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
place(1, 0, mServerNameField, 4).setPadding(3);
place(0, 1, portLabel);
place(1, 1, mPortField, 4).setPadding(3);
+#ifdef MANASERV_SUPPORT
place(0, 2, typeLabel);
place(1, 2, mTypeField, 4).setPadding(3);
place(0, 3, usedScroll, 5, 5).setPadding(3);
@@ -250,6 +256,14 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
place(1, 9, mDeleteButton);
place(3, 9, mQuitButton);
place(4, 9, mConnectButton);
+#else
+ place(0, 2, usedScroll, 5, 5).setPadding(3);
+ place(0, 7, mDescription, 5);
+ place(0, 8, mManualEntryButton);
+ place(1, 8, mDeleteButton);
+ place(3, 8, mQuitButton);
+ place(4, 8, mConnectButton);
+#endif
// Make sure the list has enough height
getLayout().setRowHeight(3, 80);
@@ -454,7 +468,11 @@ void ServerDialog::setFieldsReadOnly(bool readOnly)
mServersList->setSelected(-1);
mServerNameField->setText(std::string());
+#ifdef MANASERV_SUPPORT
mPortField->setText(std::string());
+#else
+ mPortField->setText(std::string("6901"));
+#endif
mServerNameField->requestFocus();
}
@@ -576,7 +594,11 @@ void ServerDialog::loadServers()
}
}
+#ifdef MANASERV_SUPPORT
if (!found)
+#else
+ if (!found && server.type != ServerInfo::MANASERV)
+#endif
mServers.push_back(server);
}
}
@@ -602,7 +624,15 @@ void ServerDialog::loadCustomServers()
break;
server.save = true;
+
+#ifdef MANASERV_SUPPORT
mServers.push_back(server);
+#else
+ if (server.type == ServerInfo::MANASERV)
+ mManaservServers.push_back(server);
+ else
+ mServers.push_back(server);
+#endif
}
}
@@ -645,6 +675,27 @@ void ServerDialog::saveCustomServers(const ServerInfo &currentServer)
++savedServerCount;
}
+#ifndef MANASERV_SUPPORT
+ for (unsigned i = 0;
+ i < mManaservServers.size() && savedServerCount < MAX_SERVERLIST; ++i)
+ {
+ const ServerInfo &server = mManaservServers.at(i);
+
+ // Only save servers that were loaded from settings
+ if (!(server.save && server.isValid()))
+ continue;
+
+ const std::string index = toString(savedServerCount);
+ const std::string nameKey = "MostUsedServerName" + index;
+ const std::string typeKey = "MostUsedServerType" + index;
+ const std::string portKey = "MostUsedServerPort" + index;
+
+ config.setValue(nameKey, toString(server.hostname));
+ config.setValue(typeKey, serverTypeToString(server.type));
+ config.setValue(portKey, toString(server.port));
+ ++savedServerCount;
+ }
+#endif
// Insert an invalid entry at the end to make the loading stop there
if (savedServerCount < MAX_SERVERLIST)
config.setValue("MostUsedServerName" + toString(savedServerCount), "");
diff --git a/src/gui/serverdialog.h b/src/gui/serverdialog.h
index ed733f9c..aae8b2e0 100644
--- a/src/gui/serverdialog.h
+++ b/src/gui/serverdialog.h
@@ -191,6 +191,9 @@ class ServerDialog : public Window,
float mDownloadProgress;
ServerInfos mServers;
+#ifndef MANASERV_SUPPORT
+ ServerInfos mManaservServers;
+#endif
ServerInfo *mServerInfo;
};
diff --git a/src/net/net.cpp b/src/net/net.cpp
index 7e7395a6..25dcd981 100644
--- a/src/net/net.cpp
+++ b/src/net/net.cpp
@@ -134,12 +134,16 @@ void connectToServer(ServerInfo &server)
// TODO: Query the server about itself and choose the netcode based on
// that
+#ifndef MANASERV_SUPPORT
+ server.type = ServerInfo::TMWATHENA;
+#else
if (server.port == 6901)
server.type = ServerInfo::TMWATHENA;
else if (server.port == 9601)
server.type = ServerInfo::MANASERV;
else
logger->error(_("Unknown Server Type! Exiting."));
+#endif
}
if (networkType == server.type && getGeneralHandler() != NULL)