diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-05-02 21:57:51 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-05-02 22:00:37 +0300 |
commit | eca890c92d3b43b8aae5f2c53cab49612f5efd1d (patch) | |
tree | 8acbdfe972044adcfbcc5a6bf7ea28b4bbb54382 /src | |
parent | 520a495c466793c29f3e721634dfe6cc616b8ede (diff) | |
download | plus-eca890c92d3b43b8aae5f2c53cab49612f5efd1d.tar.gz plus-eca890c92d3b43b8aae5f2c53cab49612f5efd1d.tar.bz2 plus-eca890c92d3b43b8aae5f2c53cab49612f5efd1d.tar.xz plus-eca890c92d3b43b8aae5f2c53cab49612f5efd1d.zip |
Add option "use same ip" for each server.
By default all servers using same ip for subservers.
Diffstat (limited to 'src')
-rw-r--r-- | src/client.cpp | 3 | ||||
-rw-r--r-- | src/client.h | 3 | ||||
-rw-r--r-- | src/defaults.cpp | 2 | ||||
-rw-r--r-- | src/gui/windows/editserverdialog.cpp | 13 | ||||
-rw-r--r-- | src/gui/windows/editserverdialog.h | 3 | ||||
-rw-r--r-- | src/gui/windows/serverdialog.cpp | 12 | ||||
-rw-r--r-- | src/gui/windows/worldselectdialog.cpp | 3 | ||||
-rw-r--r-- | src/net/ea/charserverhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/ea/loginhandler.cpp | 5 | ||||
-rw-r--r-- | src/net/ea/loginhandler.h | 3 | ||||
-rw-r--r-- | src/net/loginhandler.h | 3 | ||||
-rw-r--r-- | src/net/serverinfo.h | 9 |
12 files changed, 46 insertions, 15 deletions
diff --git a/src/client.cpp b/src/client.cpp index 78df4e161..023b17c3f 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1328,7 +1328,8 @@ int Client::gameExec() } else if (worlds.size() == 1) { - Net::getLoginHandler()->chooseServer(0); + Net::getLoginHandler()->chooseServer( + 0, mCurrentServer.persistentIp); mState = STATE_UPDATE; } else diff --git a/src/client.h b/src/client.h index 7d83cf789..1cb35835a 100644 --- a/src/client.h +++ b/src/client.h @@ -273,6 +273,9 @@ public: std::string getSupportUrl() const A_WARN_UNUSED { return mCurrentServer.supportUrl; } + bool getPersistentIp() const A_WARN_UNUSED + { return mCurrentServer.persistentIp; } + std::string getLogFileName() const A_WARN_UNUSED { return mLogFileName; } diff --git a/src/defaults.cpp b/src/defaults.cpp index 7e2e22769..8d170ab72 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -228,7 +228,7 @@ DefaultsData* getConfigDefaults() AddDEF("showBattleEvents", false); AddDEF("showMobHP", true); AddDEF("showOwnHP", true); - AddDEF("usePersistentIP", false); + AddDEF("usePersistentIP", true); AddDEF("showJobExp", true); AddDEF("showExtMinimaps", false); AddDEF("hideChatInput", true); diff --git a/src/gui/windows/editserverdialog.cpp b/src/gui/windows/editserverdialog.cpp index 6a25a2d77..a3b687113 100644 --- a/src/gui/windows/editserverdialog.cpp +++ b/src/gui/windows/editserverdialog.cpp @@ -31,6 +31,7 @@ #include "gui/windows/serverdialog.h" #include "gui/widgets/button.h" +#include "gui/widgets/checkbox.h" #include "gui/widgets/dropdown.h" #include "gui/widgets/label.h" #include "gui/widgets/layout.h" @@ -56,6 +57,9 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent, mOkButton(new Button(this, _("OK"), "addServer", this)), // TRANSLATORS: edit server dialog button mCancelButton(new Button(this, _("Cancel"), "cancel", this)), + // TRANSLATORS: edit server dialog label + mPersistentIp(new CheckBox(this, _("Use same ip"), + true, this, "persistentIp")), mTypeListModel(new TypeListModel), mTypeField(new DropDown(this, mTypeListModel, false, true)), mServerDialog(parent), @@ -96,9 +100,10 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent, place(1, 4, mDescriptionField, 4).setPadding(3); place(0, 5, onlineListUrlLabel); place(1, 5, mOnlineListUrlField, 4).setPadding(3); - place(0, 6, mConnectButton); - place(4, 6, mOkButton); - place(3, 6, mCancelButton); + place(0, 6, mPersistentIp, 4).setPadding(3); + place(0, 7, mConnectButton); + place(4, 7, mOkButton); + place(3, 7, mCancelButton); // Do this manually instead of calling reflowLayout so we can enforce a // minimum width. @@ -132,6 +137,7 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent, mOnlineListUrlField->setText(mServer.onlineListUrl); mServerAddressField->setText(mServer.hostname); mPortField->setText(toString(mServer.port)); + mPersistentIp->setSelected(mServer.persistentIp); switch (mServer.type) { @@ -200,6 +206,7 @@ void EditServerDialog::action(const ActionEvent &event) mServer.hostname = mServerAddressField->getText(); mServer.port = static_cast<int16_t>(atoi( mPortField->getText().c_str())); + mServer.persistentIp = mPersistentIp->isSelected(); if (mTypeField) { diff --git a/src/gui/windows/editserverdialog.h b/src/gui/windows/editserverdialog.h index 98f5e07fd..d6dc7d8b3 100644 --- a/src/gui/windows/editserverdialog.h +++ b/src/gui/windows/editserverdialog.h @@ -23,6 +23,7 @@ #define GUI_WINDOWS_EDITSERVERDIALOG_H class Button; +class CheckBox; class TextField; class DropDown; class ServerDialog; @@ -70,7 +71,7 @@ class EditServerDialog final : public Window, Button *mConnectButton; Button *mOkButton; Button *mCancelButton; - + CheckBox *mPersistentIp; TypeListModel *mTypeListModel; DropDown *mTypeField; diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index 9e85f5c89..c9695c2c1 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -328,6 +328,7 @@ void ServerDialog::connectToSelectedServer() mServerInfo->onlineListUrl = server.onlineListUrl; mServerInfo->supportUrl = server.supportUrl; mServerInfo->save = true; + mServerInfo->persistentIp = server.persistentIp; if (chatLogger) chatLogger->setServerName(mServerInfo->hostname); @@ -630,6 +631,12 @@ void ServerDialog::loadServers(const bool addNew) server.supportUrl = reinterpret_cast<const char*>( subNode->xmlChildrenNode->content); } + else if (xmlNameEqual(subNode, "persistentIp")) + { + std::string text = reinterpret_cast<const char*>( + subNode->xmlChildrenNode->content); + server.persistentIp = (text == "1" || text == "true"); + } } server.version.first = font->getWidth(version); @@ -651,6 +658,7 @@ void ServerDialog::loadServers(const bool addNew) mServers[i].onlineListUrl = server.onlineListUrl; mServers[i].supportUrl = server.supportUrl; mServers[i].althostname = server.althostname; + mServers[i].persistentIp = server.persistentIp; mServersListModel->setVersionString(i, version); found = true; break; @@ -675,6 +683,7 @@ void ServerDialog::loadCustomServers() const std::string portKey("MostUsedServerPort" + index); const std::string onlineListUrlKey ("MostUsedServerOnlineList" + index); + const std::string persistentIpKey("persistentIp" + index); ServerInfo server; server.name = config.getValue(nameKey, ""); @@ -682,6 +691,7 @@ void ServerDialog::loadCustomServers() server.onlineListUrl = config.getValue(onlineListUrlKey, ""); server.hostname = config.getValue(hostKey, ""); server.type = ServerInfo::parseType(config.getValue(typeKey, "")); + server.persistentIp = config.getValue(persistentIpKey, 0) ? true : false; const int defaultPort = defaultPortForServerType(server.type); server.port = static_cast<uint16_t>( @@ -739,6 +749,7 @@ void ServerDialog::saveCustomServers(const ServerInfo ¤tServer, const std::string portKey("MostUsedServerPort" + num); const std::string onlineListUrlKey ("MostUsedServerOnlineList" + num); + const std::string persistentIpKey("persistentIp" + num); config.setValue(nameKey, toString(server.name)); config.setValue(descKey, toString(server.description)); @@ -746,6 +757,7 @@ void ServerDialog::saveCustomServers(const ServerInfo ¤tServer, config.setValue(hostKey, toString(server.hostname)); config.setValue(typeKey, serverTypeToString(server.type)); config.setValue(portKey, toString(server.port)); + config.setValue(persistentIpKey, server.persistentIp); ++ savedServerCount; } diff --git a/src/gui/windows/worldselectdialog.cpp b/src/gui/windows/worldselectdialog.cpp index 5cd0a3b2f..4a70e3750 100644 --- a/src/gui/windows/worldselectdialog.cpp +++ b/src/gui/windows/worldselectdialog.cpp @@ -106,7 +106,8 @@ void WorldSelectDialog::action(const ActionEvent &event) { mChangeLoginButton->setEnabled(false); mChooseWorld->setEnabled(false); - Net::getLoginHandler()->chooseServer(mWorldList->getSelected()); + Net::getLoginHandler()->chooseServer(mWorldList->getSelected(), + client->getPersistentIp()); // Check in case netcode moves us forward if (client->getState() == STATE_WORLD_SELECT) diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp index d541ce09b..849fe15e1 100644 --- a/src/net/ea/charserverhandler.cpp +++ b/src/net/ea/charserverhandler.cpp @@ -242,7 +242,7 @@ void CharServerHandler::processCharMapInfo(Net::MessageIn &restrict msg, PlayerInfo::setCharId(msg.readInt32()); GameHandler *const gh = static_cast<GameHandler*>(Net::getGameHandler()); gh->setMap(msg.readString(16)); - if (config.getBoolValue("usePersistentIP")) + if (config.getBoolValue("usePersistentIP") || client->getPersistentIp()) { msg.readInt32(); server.hostname = client->getServerName(); diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index af86aaf93..d4cf0e59e 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -75,7 +75,8 @@ void LoginHandler::loginAccount(LoginData *const loginData1) const } } -void LoginHandler::chooseServer(const unsigned int server) const +void LoginHandler::chooseServer(const unsigned int server, + const bool persistentIp) const { if (server >= mWorlds.size() || !mWorlds[server]) return; @@ -83,7 +84,7 @@ void LoginHandler::chooseServer(const unsigned int server) const ServerInfo *const charServer = getCharServer(); if (charServer) { - if (config.getBoolValue("usePersistentIP")) + if (config.getBoolValue("usePersistentIP") || persistentIp) charServer->hostname = client->getServerName(); else charServer->hostname = ipToString(mWorlds[server]->address); diff --git a/src/net/ea/loginhandler.h b/src/net/ea/loginhandler.h index 8619d4c34..d8bffc0be 100644 --- a/src/net/ea/loginhandler.h +++ b/src/net/ea/loginhandler.h @@ -61,7 +61,8 @@ class LoginHandler : public Net::LoginHandler virtual void loginAccount(LoginData *const loginData) const override final; - virtual void chooseServer(const unsigned int server) const override; + virtual void chooseServer(const unsigned int server, + const bool persistentIp) const override; virtual void registerAccount(const LoginData *const loginData) const override final; diff --git a/src/net/loginhandler.h b/src/net/loginhandler.h index caad082ae..b00ffffe2 100644 --- a/src/net/loginhandler.h +++ b/src/net/loginhandler.h @@ -88,7 +88,8 @@ class LoginHandler const std::string &restrict newPassword) const = 0; - virtual void chooseServer(unsigned int server) const = 0; + virtual void chooseServer(unsigned int server, + const bool persistentIp) const = 0; virtual void registerAccount(const LoginData *const loginData) const = 0; diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h index 899400598..b2cd652bb 100644 --- a/src/net/serverinfo.h +++ b/src/net/serverinfo.h @@ -55,8 +55,8 @@ public: std::string supportUrl; uint16_t port; VersionString version; - bool save; + bool persistentIp; ServerInfo() : type(TMWATHENA), @@ -69,7 +69,8 @@ public: supportUrl(), port(6901), version(), - save(false) + save(false), + persistentIp(true) { version.first = 0; } @@ -85,7 +86,8 @@ public: supportUrl(info.supportUrl), port(info.port), version(), - save(info.save) + save(info.save), + persistentIp(info.persistentIp) { version.first = info.version.first; version.second = info.version.second; @@ -110,6 +112,7 @@ public: version.first = 0; version.second.clear(); save = false; + persistentIp = true; } bool operator==(const ServerInfo &other) const |