summaryrefslogtreecommitdiff
path: root/src/net/eathena/generalhandler.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-03-28 23:21:07 +0300
committerAndrei Karas <akaras@inbox.ru>2013-03-28 23:21:07 +0300
commitbe3c1cf049d3df146d18acfb7cbead2ef3f660f1 (patch)
tree9f70999543adce3be255abdad6a9e284de266f50 /src/net/eathena/generalhandler.cpp
parent58974e6733a39bd55b9511f0010e0a8b7cd49aa4 (diff)
downloadmv-be3c1cf049d3df146d18acfb7cbead2ef3f660f1.tar.gz
mv-be3c1cf049d3df146d18acfb7cbead2ef3f660f1.tar.bz2
mv-be3c1cf049d3df146d18acfb7cbead2ef3f660f1.tar.xz
mv-be3c1cf049d3df146d18acfb7cbead2ef3f660f1.zip
improve generalhandler class.
Diffstat (limited to 'src/net/eathena/generalhandler.cpp')
-rw-r--r--src/net/eathena/generalhandler.cpp118
1 files changed, 50 insertions, 68 deletions
diff --git a/src/net/eathena/generalhandler.cpp b/src/net/eathena/generalhandler.cpp
index d34edff7c..ad59ce664 100644
--- a/src/net/eathena/generalhandler.cpp
+++ b/src/net/eathena/generalhandler.cpp
@@ -107,8 +107,6 @@ GeneralHandler::GeneralHandler() :
stats.push_back(ItemDB::Stat("luck", _("Luck %+d")));
ItemDB::setStatsList(stats);
-
- listen(CHANNEL_GAME);
}
GeneralHandler::~GeneralHandler()
@@ -119,12 +117,11 @@ GeneralHandler::~GeneralHandler()
void GeneralHandler::handleMessage(Net::MessageIn &msg)
{
- int code;
-
switch (msg.getId())
{
case SMSG_CONNECTION_PROBLEM:
- code = msg.readInt8();
+ {
+ const int code = msg.readInt8();
logger->log("Connection problem: %i", code);
switch (code)
@@ -158,6 +155,7 @@ void GeneralHandler::handleMessage(Net::MessageIn &msg)
}
Client::setState(STATE_ERROR);
break;
+ }
default:
break;
@@ -194,11 +192,10 @@ void GeneralHandler::reload()
mNetwork->disconnect();
static_cast<LoginHandler*>(mLoginHandler.get())->clearWorlds();
- static_cast<CharServerHandler*>(
- mCharServerHandler.get())->setCharCreateDialog(nullptr);
- static_cast<CharServerHandler*>(
- mCharServerHandler.get())->setCharSelectDialog(nullptr);
-
+ CharServerHandler *charHandler = static_cast<CharServerHandler*>(
+ mCharServerHandler.get());
+ charHandler->setCharCreateDialog(nullptr);
+ charHandler->setCharSelectDialog(nullptr);
static_cast<PartyHandler*>(mPartyHandler.get())->reload();
}
@@ -237,70 +234,55 @@ void GeneralHandler::clearHandlers()
mNetwork->clearHandlers();
}
-void GeneralHandler::processEvent(Channels channel,
- const DepricatedEvent &event)
+void GeneralHandler::gameStarted() const
{
- if (channel == CHANNEL_GAME)
- {
- if (event.getName() == EVENT_GUIWINDOWSLOADED)
- {
- if (inventoryWindow)
- inventoryWindow->setSplitAllowed(false);
- if (skillDialog)
- skillDialog->loadSkills();
-
- if (!statusWindow)
- return;
-
- // protection against double addition attributes.
- statusWindow->clearAttributes();
-
- statusWindow->addAttribute(STR, _("Strength"), "str", true, "");
- statusWindow->addAttribute(AGI, _("Agility"), "agi", true, "");
- statusWindow->addAttribute(VIT, _("Vitality"), "vit", true, "");
- statusWindow->addAttribute(INT, _("Intelligence"),
- "int", true, "");
- statusWindow->addAttribute(DEX, _("Dexterity"), "dex", true, "");
- statusWindow->addAttribute(LUK, _("Luck"), "luk", true, "");
-
- statusWindow->addAttribute(ATK, _("Attack"));
- statusWindow->addAttribute(DEF, _("Defense"));
- statusWindow->addAttribute(MATK, _("M.Attack"));
- statusWindow->addAttribute(MDEF, _("M.Defense"));
- // xgettext:no-c-format
- statusWindow->addAttribute(HIT, _("% Accuracy"));
- // xgettext:no-c-format
- statusWindow->addAttribute(FLEE, _("% Evade"));
- // xgettext:no-c-format
- statusWindow->addAttribute(CRIT, _("% Critical"));
- statusWindow->addAttribute(PlayerInfo::ATTACK_DELAY,
- _("Attack Delay"));
- statusWindow->addAttribute(PlayerInfo::WALK_SPEED,
- _("Walk Delay"));
- statusWindow->addAttribute(PlayerInfo::ATTACK_RANGE,
- _("Attack Range"));
- statusWindow->addAttribute(PlayerInfo::ATTACK_SPEED,
- _("Damage per sec."));
- }
- else if (event.getName() == EVENT_GUIWINDOWSUNLOADING)
- {
- if (socialWindow)
- {
- socialWindow->removeTab(Ea::taGuild);
- socialWindow->removeTab(Ea::taParty);
- }
+ if (inventoryWindow)
+ inventoryWindow->setSplitAllowed(false);
+ if (skillDialog)
+ skillDialog->loadSkills();
- delete Ea::guildTab;
- Ea::guildTab = nullptr;
+ if (!statusWindow)
+ return;
- delete Ea::partyTab;
- Ea::partyTab = nullptr;
- }
- }
+ // protection against double addition attributes.
+ statusWindow->clearAttributes();
+
+ statusWindow->addAttribute(STR, _("Strength"), "str", true, "");
+ statusWindow->addAttribute(AGI, _("Agility"), "agi", true, "");
+ statusWindow->addAttribute(VIT, _("Vitality"), "vit", true, "");
+ statusWindow->addAttribute(INT, _("Intelligence"), "int", true, "");
+ statusWindow->addAttribute(DEX, _("Dexterity"), "dex", true, "");
+ statusWindow->addAttribute(LUK, _("Luck"), "luk", true, "");
+
+ statusWindow->addAttribute(ATK, _("Attack"));
+ statusWindow->addAttribute(DEF, _("Defense"));
+ statusWindow->addAttribute(MATK, _("M.Attack"));
+ statusWindow->addAttribute(MDEF, _("M.Defense"));
+ // xgettext:no-c-format
+ statusWindow->addAttribute(HIT, _("% Accuracy"));
+ // xgettext:no-c-format
+ statusWindow->addAttribute(FLEE, _("% Evade"));
+ // xgettext:no-c-format
+ statusWindow->addAttribute(CRIT, _("% Critical"));
+ statusWindow->addAttribute(PlayerInfo::ATTACK_DELAY, _("Attack Delay"));
+ statusWindow->addAttribute(PlayerInfo::WALK_SPEED, _("Walk Delay"));
+ statusWindow->addAttribute(PlayerInfo::ATTACK_RANGE, _("Attack Range"));
+ statusWindow->addAttribute(PlayerInfo::ATTACK_SPEED, _("Damage per sec."));
}
-void GeneralHandler::requestOnlineList()
+void GeneralHandler::gameEnded() const
{
+ if (socialWindow)
+ {
+ socialWindow->removeTab(Ea::taGuild);
+ socialWindow->removeTab(Ea::taParty);
+ }
+
+ delete Ea::guildTab;
+ Ea::guildTab = nullptr;
+
+ delete Ea::partyTab;
+ Ea::partyTab = nullptr;
}
} // namespace EAthena