summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-17 11:03:22 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-17 11:03:22 +0300
commitdfaae6f6e804e7779ade870a211a1a14d3a5d9aa (patch)
treea7652f4e548e166b39a8203e27c890c02c62d5ca
parentfd050698f74b5dc7a9867bc93ba6b7c65ef2462f (diff)
downloadmv-dfaae6f6e804e7779ade870a211a1a14d3a5d9aa.tar.gz
mv-dfaae6f6e804e7779ade870a211a1a14d3a5d9aa.tar.bz2
mv-dfaae6f6e804e7779ade870a211a1a14d3a5d9aa.tar.xz
mv-dfaae6f6e804e7779ade870a211a1a14d3a5d9aa.zip
Remove getter for loginHandler.
-rw-r--r--src/client.cpp36
-rw-r--r--src/gui/windows/changeemaildialog.cpp6
-rw-r--r--src/gui/windows/changepassworddialog.cpp6
-rw-r--r--src/gui/windows/charselectdialog.cpp3
-rw-r--r--src/gui/windows/logindialog.cpp4
-rw-r--r--src/gui/windows/registerdialog.cpp14
-rw-r--r--src/gui/windows/unregisterdialog.cpp6
-rw-r--r--src/gui/windows/worldselectdialog.cpp2
-rw-r--r--src/net/eathena/charserverhandler.cpp7
-rw-r--r--src/net/eathena/gamehandler.cpp3
-rw-r--r--src/net/loginhandler.h2
-rw-r--r--src/net/net.cpp12
-rw-r--r--src/net/net.h2
-rw-r--r--src/net/tmwa/charserverhandler.cpp7
-rw-r--r--src/net/tmwa/gamehandler.cpp3
15 files changed, 47 insertions, 66 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 473162b93..d6dd49de8 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -616,8 +616,8 @@ void Client::gameClear()
StatusEffect::unload();
ModDB::unload();
- if (Net::getLoginHandler())
- Net::getLoginHandler()->clearWorlds();
+ if (loginHandler)
+ loginHandler->clearWorlds();
if (chatHandler)
chatHandler->clear();
@@ -818,7 +818,7 @@ int Client::gameExec()
if (mState == STATE_CONNECT_GAME &&
gameHandler->isConnected())
{
- Net::getLoginHandler()->disconnect();
+ loginHandler->disconnect();
}
else if (mState == STATE_CONNECT_SERVER &&
mOldState == STATE_CHOOSE_SERVER)
@@ -885,13 +885,13 @@ int Client::gameExec()
}
else if (mState == STATE_CONNECT_SERVER &&
mOldState != STATE_CHOOSE_SERVER &&
- Net::getLoginHandler()->isConnected())
+ loginHandler->isConnected())
{
mState = STATE_PRE_LOGIN;
}
else if (mState == STATE_WORLD_SELECT && mOldState == STATE_UPDATE)
{
- if (Net::getLoginHandler()->getWorlds().size() < 2)
+ if (loginHandler->getWorlds().size() < 2)
mState = STATE_PRE_LOGIN;
}
else if (mOldState == STATE_START ||
@@ -1107,7 +1107,7 @@ int Client::gameExec()
// TRANSLATORS: connection dialog header
_("Logging in"), STATE_SWITCH_SERVER);
mCurrentDialog->postInit();
- Net::getLoginHandler()->loginOrRegister(&loginData);
+ loginHandler->loginOrRegister(&loginData);
BLOCK_END("Client::gameExec STATE_LOGIN_ATTEMPT")
break;
@@ -1116,7 +1116,7 @@ int Client::gameExec()
logger->log1("State: WORLD SELECT");
{
TranslationManager::loadCurrentLang();
- Worlds worlds = Net::getLoginHandler()->getWorlds();
+ Worlds worlds = loginHandler->getWorlds();
if (worlds.empty())
{
@@ -1125,7 +1125,7 @@ int Client::gameExec()
}
else if (worlds.size() == 1)
{
- Net::getLoginHandler()->chooseServer(
+ loginHandler->chooseServer(
0, mCurrentServer.persistentIp);
mState = STATE_UPDATE;
}
@@ -1410,7 +1410,7 @@ int Client::gameExec()
// TRANSLATORS: connection dialog header
_("Requesting registration details"), STATE_LOGIN);
mCurrentDialog->postInit();
- Net::getLoginHandler()->getRegistrationDetails();
+ loginHandler->getRegistrationDetails();
BLOCK_END("Client::gameExec STATE_REGISTER_PREP")
break;
@@ -1423,7 +1423,7 @@ int Client::gameExec()
case STATE_REGISTER_ATTEMPT:
BLOCK_START("Client::gameExec STATE_REGISTER_ATTEMPT")
logger->log("Username is %s", loginData.username.c_str());
- Net::getLoginHandler()->registerAccount(&loginData);
+ loginHandler->registerAccount(&loginData);
BLOCK_END("Client::gameExec STATE_REGISTER_ATTEMPT")
break;
@@ -1439,7 +1439,7 @@ int Client::gameExec()
BLOCK_START("Client::gameExec "
"STATE_CHANGEPASSWORD_ATTEMPT")
logger->log1("State: CHANGE PASSWORD ATTEMPT");
- Net::getLoginHandler()->changePassword(loginData.username,
+ loginHandler->changePassword(loginData.username,
loginData.password, loginData.newPassword);
BLOCK_END("Client::gameExec STATE_CHANGEPASSWORD_ATTEMPT")
break;
@@ -1470,7 +1470,7 @@ int Client::gameExec()
case STATE_CHANGEEMAIL_ATTEMPT:
logger->log1("State: CHANGE EMAIL ATTEMPT");
- Net::getLoginHandler()->changeEmail(loginData.email);
+ loginHandler->changeEmail(loginData.email);
break;
case STATE_CHANGEEMAIL_SUCCESS:
@@ -1495,13 +1495,13 @@ int Client::gameExec()
case STATE_UNREGISTER_ATTEMPT:
logger->log1("State: UNREGISTER ATTEMPT");
- Net::getLoginHandler()->unregisterAccount(
+ loginHandler->unregisterAccount(
loginData.username, loginData.password);
break;
case STATE_UNREGISTER_SUCCESS:
logger->log1("State: UNREGISTER SUCCESS");
- Net::getLoginHandler()->disconnect();
+ loginHandler->disconnect();
mCurrentDialog = DialogsManager::openErrorDialog(
// TRANSLATORS: unregister message header
@@ -1518,7 +1518,7 @@ int Client::gameExec()
BLOCK_START("Client::gameExec STATE_SWITCH_SERVER")
logger->log1("State: SWITCH SERVER");
- Net::getLoginHandler()->disconnect();
+ loginHandler->disconnect();
gameHandler->disconnect();
gameHandler->clear();
settings.serverName.clear();
@@ -1535,10 +1535,10 @@ int Client::gameExec()
BLOCK_START("Client::gameExec STATE_SWITCH_LOGIN")
logger->log1("State: SWITCH LOGIN");
- Net::getLoginHandler()->logout();
- Net::getLoginHandler()->disconnect();
+ loginHandler->logout();
+ loginHandler->disconnect();
gameHandler->disconnect();
- Net::getLoginHandler()->connect();
+ loginHandler->connect();
mState = STATE_LOGIN;
BLOCK_END("Client::gameExec STATE_SWITCH_LOGIN")
diff --git a/src/gui/windows/changeemaildialog.cpp b/src/gui/windows/changeemaildialog.cpp
index 84da15ead..408fdf9d4 100644
--- a/src/gui/windows/changeemaildialog.cpp
+++ b/src/gui/windows/changeemaildialog.cpp
@@ -130,10 +130,8 @@ void ChangeEmailDialog::action(const ActionEvent &event)
std::stringstream errorMsg;
int error = 0;
- const unsigned int min = Net::getLoginHandler()
- ->getMinPasswordLength();
- const unsigned int max = Net::getLoginHandler()
- ->getMaxPasswordLength();
+ const unsigned int min = loginHandler->getMinPasswordLength();
+ const unsigned int max = loginHandler->getMaxPasswordLength();
if (newFirstEmail.length() < min)
{
diff --git a/src/gui/windows/changepassworddialog.cpp b/src/gui/windows/changepassworddialog.cpp
index 875fb2c3d..a5f97becb 100644
--- a/src/gui/windows/changepassworddialog.cpp
+++ b/src/gui/windows/changepassworddialog.cpp
@@ -110,10 +110,8 @@ void ChangePasswordDialog::action(const ActionEvent &event)
std::stringstream errorMsg;
int error = 0;
- const unsigned int min = Net::getLoginHandler()
- ->getMinPasswordLength();
- const unsigned int max = Net::getLoginHandler()
- ->getMaxPasswordLength();
+ const unsigned int min = loginHandler->getMinPasswordLength();
+ const unsigned int max = loginHandler->getMaxPasswordLength();
// Check old Password
if (oldPassword.empty())
diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp
index 95b3d6cfc..e2211d3fb 100644
--- a/src/gui/windows/charselectdialog.cpp
+++ b/src/gui/windows/charselectdialog.cpp
@@ -93,8 +93,7 @@ CharSelectDialog::CharSelectDialog(LoginData *const data) :
setCloseButton(true);
setFocusable(true);
- const int optionalActions = Net::getLoginHandler()
- ->supportedOptionalActions();
+ const int optionalActions = loginHandler->supportedOptionalActions();
ContainerPlacer placer;
placer = getPlacer(0, 0);
diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp
index ffcbc8c69..0b642f224 100644
--- a/src/gui/windows/logindialog.cpp
+++ b/src/gui/windows/logindialog.cpp
@@ -193,7 +193,7 @@ void LoginDialog::postInit()
mPassField->requestFocus();
mLoginButton->setEnabled(canSubmit());
- mRegisterButton->setEnabled(Net::getLoginHandler()->isRegistrationEnabled()
+ mRegisterButton->setEnabled(loginHandler->isRegistrationEnabled()
|| !mLoginData->registerUrl.empty());
}
@@ -218,7 +218,7 @@ void LoginDialog::action(const ActionEvent &event)
}
else if (eventId == "register")
{
- if (Net::getLoginHandler()->isRegistrationEnabled())
+ if (loginHandler->isRegistrationEnabled())
{
prepareUpdate();
client->setState(STATE_REGISTER_PREP);
diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp
index 7253c3630..5701395a7 100644
--- a/src/gui/windows/registerdialog.cpp
+++ b/src/gui/windows/registerdialog.cpp
@@ -73,7 +73,7 @@ RegisterDialog::RegisterDialog(LoginData *const data) :
{
setCloseButton(true);
- const int optionalActions = Net::getLoginHandler()->
+ const int optionalActions = loginHandler->
supportedOptionalActions();
// TRANSLATORS: register dialog. label.
@@ -178,14 +178,10 @@ void RegisterDialog::action(const ActionEvent &event)
std::string errorMsg;
int error = 0;
- const unsigned int minUser = Net::getLoginHandler()
- ->getMinUserNameLength();
- const unsigned int maxUser = Net::getLoginHandler()
- ->getMaxUserNameLength();
- const unsigned int minPass = Net::getLoginHandler()
- ->getMinPasswordLength();
- const unsigned int maxPass = Net::getLoginHandler()
- ->getMaxPasswordLength();
+ const unsigned int minUser = loginHandler->getMinUserNameLength();
+ const unsigned int maxUser = loginHandler->getMaxUserNameLength();
+ const unsigned int minPass = loginHandler->getMinPasswordLength();
+ const unsigned int maxPass = loginHandler->getMaxPasswordLength();
if (user.length() < minUser)
{
diff --git a/src/gui/windows/unregisterdialog.cpp b/src/gui/windows/unregisterdialog.cpp
index 0135cb7c9..018b583fa 100644
--- a/src/gui/windows/unregisterdialog.cpp
+++ b/src/gui/windows/unregisterdialog.cpp
@@ -121,10 +121,8 @@ void UnRegisterDialog::action(const ActionEvent &event)
std::stringstream errorMsg;
bool error = false;
- const unsigned int min = Net::getLoginHandler()
- ->getMinPasswordLength();
- const unsigned int max = Net::getLoginHandler()
- ->getMaxPasswordLength();
+ const unsigned int min = loginHandler->getMinPasswordLength();
+ const unsigned int max = loginHandler->getMaxPasswordLength();
if (password.length() < min)
{
diff --git a/src/gui/windows/worldselectdialog.cpp b/src/gui/windows/worldselectdialog.cpp
index db7db88aa..7cfb0319b 100644
--- a/src/gui/windows/worldselectdialog.cpp
+++ b/src/gui/windows/worldselectdialog.cpp
@@ -105,7 +105,7 @@ void WorldSelectDialog::action(const ActionEvent &event)
{
mChangeLoginButton->setEnabled(false);
mChooseWorld->setEnabled(false);
- Net::getLoginHandler()->chooseServer(mWorldList->getSelected(),
+ loginHandler->chooseServer(mWorldList->getSelected(),
settings.persistentIp);
// Check in case netcode moves us forward
diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp
index 189acb05d..bf1f18004 100644
--- a/src/net/eathena/charserverhandler.cpp
+++ b/src/net/eathena/charserverhandler.cpp
@@ -142,7 +142,7 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
return;
const Token &token =
- static_cast<LoginHandler*>(Net::getLoginHandler())->getToken();
+ static_cast<LoginHandler*>(loginHandler)->getToken();
LocalPlayer *const tempPlayer = new LocalPlayer(
msg.readInt32("player id"), 0);
@@ -274,7 +274,7 @@ void CharServerHandler::switchCharacter() const
void CharServerHandler::connect()
{
const Token &token =
- static_cast<LoginHandler*>(Net::getLoginHandler())->getToken();
+ static_cast<LoginHandler*>(loginHandler)->getToken();
if (!mNetwork)
return;
@@ -301,8 +301,7 @@ void CharServerHandler::setCharCreateDialog(CharCreateDialog *const window)
StringVect attributes;
- const Token &token =
- static_cast<LoginHandler*>(Net::getLoginHandler())->getToken();
+ const Token &token = static_cast<LoginHandler*>(loginHandler)->getToken();
mCharCreateDialog->setAttributes(attributes, 0, 0, 0);
mCharCreateDialog->setFixedGender(true, token.sex);
diff --git a/src/net/eathena/gamehandler.cpp b/src/net/eathena/gamehandler.cpp
index 07e4dd7c6..381131fbc 100644
--- a/src/net/eathena/gamehandler.cpp
+++ b/src/net/eathena/gamehandler.cpp
@@ -107,8 +107,7 @@ void GameHandler::connect()
mNetwork->connect(mapServer);
- const Token &token =
- static_cast<LoginHandler*>(Net::getLoginHandler())->getToken();
+ const Token &token = static_cast<LoginHandler*>(loginHandler)->getToken();
if (client->getState() == STATE_CONNECT_GAME)
diff --git a/src/net/loginhandler.h b/src/net/loginhandler.h
index 172dde361..89c55a334 100644
--- a/src/net/loginhandler.h
+++ b/src/net/loginhandler.h
@@ -109,4 +109,6 @@ class LoginHandler notfinal
} // namespace Net
+extern Net::LoginHandler *loginHandler;
+
#endif // NET_LOGINHANDLER_H
diff --git a/src/net/net.cpp b/src/net/net.cpp
index ed81a42ec..06768cb43 100644
--- a/src/net/net.cpp
+++ b/src/net/net.cpp
@@ -51,6 +51,7 @@ namespace Net
class GeneralHandler;
class GuildHandler;
class InventoryHandler;
+ class LoginHandler;
}
Net::AdminHandler *adminHandler = nullptr;
@@ -76,11 +77,6 @@ Net::CashShopHandler *cashShopHandler = nullptr;
Net::FamilyHandler *familyHandler = nullptr;
Net::BankHandler *bankHandler = nullptr;
-Net::LoginHandler *Net::getLoginHandler()
-{
- return loginHandler;
-}
-
Net::NpcHandler *Net::getNpcHandler()
{
return npcHandler;
@@ -164,10 +160,10 @@ void connectToServer(const ServerInfo &server)
networkType = server.type;
}
- if (getLoginHandler())
+ if (loginHandler)
{
- getLoginHandler()->setServer(server);
- getLoginHandler()->connect();
+ loginHandler->setServer(server);
+ loginHandler->connect();
}
BLOCK_END("Net::connectToServer")
}
diff --git a/src/net/net.h b/src/net/net.h
index baee5e9b2..a2c1c90b1 100644
--- a/src/net/net.h
+++ b/src/net/net.h
@@ -36,7 +36,6 @@
namespace Net
{
-class LoginHandler;
class MailHandler;
class NpcHandler;
class PartyHandler;
@@ -46,7 +45,6 @@ class SkillHandler;
class TradeHandler;
class ServerFeatures;
-LoginHandler *getLoginHandler() A_WARN_UNUSED;
NpcHandler *getNpcHandler() A_WARN_UNUSED;
PartyHandler *getPartyHandler() A_WARN_UNUSED;
PetHandler *getPetHandler() A_WARN_UNUSED;
diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp
index 969353cc4..d386206aa 100644
--- a/src/net/tmwa/charserverhandler.cpp
+++ b/src/net/tmwa/charserverhandler.cpp
@@ -138,7 +138,7 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
return;
const Token &token =
- static_cast<LoginHandler*>(Net::getLoginHandler())->getToken();
+ static_cast<LoginHandler*>(loginHandler)->getToken();
LocalPlayer *const tempPlayer = new LocalPlayer(
msg.readInt32("account id"), 0);
@@ -310,7 +310,7 @@ void CharServerHandler::switchCharacter() const
void CharServerHandler::connect()
{
const Token &token =
- static_cast<LoginHandler*>(Net::getLoginHandler())->getToken();
+ static_cast<LoginHandler*>(loginHandler)->getToken();
if (!mNetwork)
return;
@@ -359,8 +359,7 @@ void CharServerHandler::setCharCreateDialog(CharCreateDialog *const window)
// TRANSLATORS: playe stat
attributes.push_back(_("Luck:"));
- const Token &token =
- static_cast<LoginHandler*>(Net::getLoginHandler())->getToken();
+ const Token &token = static_cast<LoginHandler*>(loginHandler)->getToken();
int minStat = CharDB::getMinStat();
if (!minStat)
diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp
index f0c3c0d5d..8815803c6 100644
--- a/src/net/tmwa/gamehandler.cpp
+++ b/src/net/tmwa/gamehandler.cpp
@@ -103,8 +103,7 @@ void GameHandler::connect()
BLOCK_START("GameHandler::connect")
mNetwork->connect(mapServer);
- const Token &token = static_cast<LoginHandler*>(
- Net::getLoginHandler())->getToken();
+ const Token &token = static_cast<LoginHandler*>(loginHandler)->getToken();
if (client->getState() == STATE_CONNECT_GAME)
{