diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-01-10 00:07:12 +0200 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-01-10 00:07:12 +0200 |
commit | c674793a8657aa099c9637c92f8696f230c327ca (patch) | |
tree | c5e8a8903aae7f4548fb7ce7f74e6c62b328059a /src | |
parent | ef1a9531d3e48d2035ece3571b9fa1b537aedca2 (diff) | |
download | plus-c674793a8657aa099c9637c92f8696f230c327ca.tar.gz plus-c674793a8657aa099c9637c92f8696f230c327ca.tar.bz2 plus-c674793a8657aa099c9637c92f8696f230c327ca.tar.xz plus-c674793a8657aa099c9637c92f8696f230c327ca.zip |
Add persistent ip as connection option.
Usefull is player using some kind of port mapping.
Diffstat (limited to 'src')
-rw-r--r-- | src/defaults.cpp | 1 | ||||
-rw-r--r-- | src/gui/serverdialog.cpp | 18 | ||||
-rw-r--r-- | src/gui/serverdialog.h | 2 | ||||
-rw-r--r-- | src/net/tmwa/charserverhandler.cpp | 10 | ||||
-rw-r--r-- | src/net/tmwa/loginhandler.cpp | 5 |
5 files changed, 28 insertions, 8 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp index 190c1816c..da5aa4e84 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -190,6 +190,7 @@ DefaultsData* getConfigDefaults() AddDEF(configData, "showBattleEvents", false); AddDEF(configData, "showMobHP", true); AddDEF(configData, "showOwnHP", true); + AddDEF(configData, "usePersistentIP", false); return configData; } diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index c7e1d0f94..3556efc35 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -211,7 +211,8 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): mDownload(0), mDownloadProgress(-1.0f), mServers(ServerInfos()), - mServerInfo(serverInfo) + mServerInfo(serverInfo), + mPersistentIPCheckBox(false) { if (isSafeMode) setCaption("Choose Your Server *** SAFE MODE ***"); @@ -223,6 +224,9 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): Label *typeLabel = new Label(_("Server type:")); mServerNameField = new TextField(mServerInfo->hostname); mPortField = new TextField(toString(mServerInfo->port)); + mPersistentIPCheckBox = new CheckBox(_("Use same ip for game sub servers"), + config.getBoolValue("usePersistentIP"), + this, "persitent ip"); loadCustomServers(); @@ -264,11 +268,12 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): place(1, 2, mTypeField, 5).setPadding(3); place(0, 3, usedScroll, 6, 5).setPadding(3); place(0, 8, mDescription, 6); - place(0, 9, mManualEntryButton); - place(1, 9, mDeleteButton); - place(2, 9, mLoadButton); - place(4, 9, mQuitButton); - place(5, 9, mConnectButton); + place(0, 9, mPersistentIPCheckBox, 6); + place(0, 10, mManualEntryButton); + place(1, 10, mDeleteButton); + place(2, 10, mLoadButton); + place(4, 10, mQuitButton); + place(5, 10, mConnectButton); // Make sure the list has enough height getLayout().setRowHeight(3, 80); @@ -390,6 +395,7 @@ void ServerDialog::action(const gcn::ActionEvent &event) LoginDialog::savedPassword = ""; } + config.setValue("usePersistentIP", mPersistentIPCheckBox->isSelected()); Client::setState(STATE_CONNECT_SERVER); } } diff --git a/src/gui/serverdialog.h b/src/gui/serverdialog.h index b9a67e246..e16dd09b5 100644 --- a/src/gui/serverdialog.h +++ b/src/gui/serverdialog.h @@ -23,6 +23,7 @@ #define SERVERDIALOG_H #include "gui/widgets/window.h" +#include "gui/widgets/checkbox.h" #include "net/download.h" #include "net/serverinfo.h" @@ -199,6 +200,7 @@ class ServerDialog : public Window, ServerInfos mServers; ServerInfo *mServerInfo; + CheckBox *mPersistentIPCheckBox; }; #endif diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index e500f667b..4bf9df8b3 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -160,7 +160,15 @@ void CharServerHandler::handleMessage(Net::MessageIn &msg) PlayerInfo::setCharId(msg.readInt32()); GameHandler *gh = static_cast<GameHandler*>(Net::getGameHandler()); gh->setMap(msg.readString(16)); - mapServer.hostname = ipToString(msg.readInt32()); + if (config.getBoolValue("usePersistentIP")) + { + msg.readInt32(); + mapServer.hostname = Client::getServerName(); + } + else + { + mapServer.hostname = ipToString(msg.readInt32()); + } mapServer.port = msg.readInt16(); // Prevent the selected local player from being deleted diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp index 73fec1322..05a28513c 100644 --- a/src/net/tmwa/loginhandler.cpp +++ b/src/net/tmwa/loginhandler.cpp @@ -288,7 +288,10 @@ void LoginHandler::chooseServer(unsigned int server) return; charServer.clear(); - charServer.hostname = ipToString(mWorlds[server]->address); + if (config.getBoolValue("usePersistentIP")) + charServer.hostname = Client::getServerName(); + else + charServer.hostname = ipToString(mWorlds[server]->address); charServer.port = mWorlds[server]->port; Client::setState(STATE_UPDATE); |