summaryrefslogtreecommitdiff
path: root/src/net/tmwa
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-08-30 15:11:45 +0300
committerAndrei Karas <akaras@inbox.ru>2015-08-30 15:11:45 +0300
commit7c8e0e0454f2e9acfde62faf669a1628e3935a58 (patch)
tree5beb7c7506fcea774c2102a16a1886e923ad0891 /src/net/tmwa
parenta0157bd0f1909af5758adc32370125bdb76ccc5a (diff)
downloadmanaplus-7c8e0e0454f2e9acfde62faf669a1628e3935a58.tar.gz
manaplus-7c8e0e0454f2e9acfde62faf669a1628e3935a58.tar.bz2
manaplus-7c8e0e0454f2e9acfde62faf669a1628e3935a58.tar.xz
manaplus-7c8e0e0454f2e9acfde62faf669a1628e3935a58.zip
Move receive code from playerhandler into separate file.
Diffstat (limited to 'src/net/tmwa')
-rw-r--r--src/net/tmwa/playerhandler.cpp150
-rw-r--r--src/net/tmwa/playerhandler.h5
-rw-r--r--src/net/tmwa/playerrecv.cpp166
-rw-r--r--src/net/tmwa/playerrecv.h39
4 files changed, 218 insertions, 142 deletions
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index f0d9d5b08..312a95644 100644
--- a/src/net/tmwa/playerhandler.cpp
+++ b/src/net/tmwa/playerhandler.cpp
@@ -27,8 +27,11 @@
#include "gui/windows/statuswindow.h"
+#include "net/ea/playerrecv.h"
+
#include "net/tmwa/inventoryhandler.h"
#include "net/tmwa/messageout.h"
+#include "net/tmwa/playerrecv.h"
#include "net/tmwa/protocol.h"
#include "debug.h"
@@ -67,44 +70,44 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg)
switch (msg.getId())
{
case SMSG_WALK_RESPONSE:
- processWalkResponse(msg);
+ PlayerRecv::processWalkResponse(msg);
break;
case SMSG_PLAYER_WARP:
- processPlayerWarp(msg);
+ Ea::PlayerRecv::processPlayerWarp(msg);
break;
case SMSG_PLAYER_STAT_UPDATE_1:
- processPlayerStatUpdate1(msg);
+ Ea::PlayerRecv::processPlayerStatUpdate1(msg);
break;
case SMSG_PLAYER_STAT_UPDATE_2:
- processPlayerStatUpdate2(msg);
+ Ea::PlayerRecv::processPlayerStatUpdate2(msg);
break;
case SMSG_PLAYER_STAT_UPDATE_3: // Update a base attribute
- processPlayerStatUpdate3(msg);
+ Ea::PlayerRecv::processPlayerStatUpdate3(msg);
break;
case SMSG_PLAYER_STAT_UPDATE_4: // Attribute increase ack
- processPlayerStatUpdate4(msg);
+ Ea::PlayerRecv::processPlayerStatUpdate4(msg);
break;
// Updates stats and status points
case SMSG_PLAYER_STAT_UPDATE_5:
- processPlayerStatUpdate5(msg);
+ PlayerRecv::processPlayerStatUpdate5(msg);
break;
case SMSG_PLAYER_STAT_UPDATE_6:
- processPlayerStatUpdate6(msg);
+ Ea::PlayerRecv::processPlayerStatUpdate6(msg);
break;
case SMSG_PLAYER_ARROW_MESSAGE:
- processPlayerArrowMessage(msg);
+ Ea::PlayerRecv::processPlayerArrowMessage(msg);
break;
case SMSG_MAP_MUSIC:
- processMapMusic(msg);
+ Ea::PlayerRecv::processMapMusic(msg);
break;
default:
@@ -235,133 +238,6 @@ void PlayerHandler::updateStatus(const uint8_t status A_UNUSED) const
{
}
-void PlayerHandler::processPlayerStatUpdate5(Net::MessageIn &msg)
-{
- BLOCK_START("PlayerHandler::processPlayerStatUpdate5")
- PlayerInfo::setAttribute(Attributes::CHAR_POINTS,
- msg.readInt16("char points"));
-
- unsigned int val = msg.readUInt8("str");
- PlayerInfo::setStatBase(Attributes::STR, val);
- if (statusWindow)
- {
- statusWindow->setPointsNeeded(Attributes::STR,
- msg.readUInt8("str cost"));
- }
- else
- {
- msg.readUInt8("str cost");
- }
-
- val = msg.readUInt8("agi");
- PlayerInfo::setStatBase(Attributes::AGI, val);
- if (statusWindow)
- {
- statusWindow->setPointsNeeded(Attributes::AGI,
- msg.readUInt8("agi cost"));
- }
- else
- {
- msg.readUInt8("agi cost");
- }
-
- val = msg.readUInt8("vit");
- PlayerInfo::setStatBase(Attributes::VIT, val);
- if (statusWindow)
- {
- statusWindow->setPointsNeeded(Attributes::VIT,
- msg.readUInt8("vit cost"));
- }
- else
- {
- msg.readUInt8("vit cost");
- }
-
- val = msg.readUInt8("int");
- PlayerInfo::setStatBase(Attributes::INT, val);
- if (statusWindow)
- {
- statusWindow->setPointsNeeded(Attributes::INT,
- msg.readUInt8("int cost"));
- }
- else
- {
- msg.readUInt8("int cost");
- }
-
- val = msg.readUInt8("dex");
- PlayerInfo::setStatBase(Attributes::DEX, val);
- if (statusWindow)
- {
- statusWindow->setPointsNeeded(Attributes::DEX,
- msg.readUInt8("dex cost"));
- }
- else
- {
- msg.readUInt8("dex cost");
- }
-
- val = msg.readUInt8("luk");
- PlayerInfo::setStatBase(Attributes::LUK, val);
- if (statusWindow)
- {
- statusWindow->setPointsNeeded(Attributes::LUK,
- msg.readUInt8("luk cost"));
- }
- else
- {
- msg.readUInt8("luk cost");
- }
-
- PlayerInfo::setStatBase(Attributes::ATK,
- msg.readInt16("atk"), Notify_false);
- PlayerInfo::setStatMod(Attributes::ATK, msg.readInt16("atk+"));
- PlayerInfo::updateAttrs();
-
- val = msg.readInt16("matk");
- PlayerInfo::setStatBase(Attributes::MATK, val, Notify_false);
-
- val = msg.readInt16("matk+");
- PlayerInfo::setStatMod(Attributes::MATK, val);
-
- PlayerInfo::setStatBase(Attributes::DEF,
- msg.readInt16("def"), Notify_false);
- PlayerInfo::setStatMod(Attributes::DEF, msg.readInt16("def+"));
-
- PlayerInfo::setStatBase(Attributes::MDEF,
- msg.readInt16("mdef"), Notify_false);
- PlayerInfo::setStatMod(Attributes::MDEF, msg.readInt16("mdef+"));
-
- PlayerInfo::setStatBase(Attributes::HIT, msg.readInt16("hit"));
-
- PlayerInfo::setStatBase(Attributes::FLEE,
- msg.readInt16("flee"), Notify_false);
- PlayerInfo::setStatMod(Attributes::FLEE, msg.readInt16("flee+"));
-
- PlayerInfo::setStatBase(Attributes::CRIT, msg.readInt16("crit"));
-
- PlayerInfo::setStatBase(Attributes::MANNER, msg.readInt16("manner"));
- msg.readInt16("unused?");
- BLOCK_END("PlayerHandler::processPlayerStatUpdate5")
-}
-
-void PlayerHandler::processWalkResponse(Net::MessageIn &msg)
-{
- BLOCK_START("PlayerHandler::processWalkResponse")
- /*
- * This client assumes that all walk messages succeed,
- * and that the server will send a correction notice
- * otherwise.
- */
- uint16_t srcX, srcY, dstX, dstY;
- msg.readInt32("tick");
- msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
- msg.readUInt8("unused");
- if (localPlayer)
- localPlayer->setRealPos(dstX, dstY);
- BLOCK_END("PlayerHandler::processWalkResponse")
-}
-
void PlayerHandler::setShortcut(const int idx A_UNUSED,
const uint8_t type A_UNUSED,
const int id A_UNUSED,
diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h
index f4e9e1e44..5af3e9676 100644
--- a/src/net/tmwa/playerhandler.h
+++ b/src/net/tmwa/playerhandler.h
@@ -79,16 +79,11 @@ class PlayerHandler final : public MessageHandler, public Ea::PlayerHandler
void setViewEquipment(const bool allow) const override final;
- protected:
void setStat(Net::MessageIn &msg,
const int type,
const int base,
const int mod,
const Notify notify) const override final;
-
- static void processPlayerStatUpdate5(Net::MessageIn &msg);
-
- static void processWalkResponse(Net::MessageIn &msg);
};
} // namespace TmwAthena
diff --git a/src/net/tmwa/playerrecv.cpp b/src/net/tmwa/playerrecv.cpp
new file mode 100644
index 000000000..88d2062bb
--- /dev/null
+++ b/src/net/tmwa/playerrecv.cpp
@@ -0,0 +1,166 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "net/tmwa/playerrecv.h"
+
+#include "being/localplayer.h"
+#include "being/playerinfo.h"
+
+#include "gui/windows/statuswindow.h"
+
+#include "net/tmwa/inventoryhandler.h"
+#include "net/tmwa/messageout.h"
+#include "net/tmwa/protocol.h"
+
+#include "debug.h"
+
+namespace TmwAthena
+{
+
+void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg)
+{
+ BLOCK_START("PlayerRecv::processPlayerStatUpdate5")
+ PlayerInfo::setAttribute(Attributes::CHAR_POINTS,
+ msg.readInt16("char points"));
+
+ unsigned int val = msg.readUInt8("str");
+ PlayerInfo::setStatBase(Attributes::STR, val);
+ if (statusWindow)
+ {
+ statusWindow->setPointsNeeded(Attributes::STR,
+ msg.readUInt8("str cost"));
+ }
+ else
+ {
+ msg.readUInt8("str cost");
+ }
+
+ val = msg.readUInt8("agi");
+ PlayerInfo::setStatBase(Attributes::AGI, val);
+ if (statusWindow)
+ {
+ statusWindow->setPointsNeeded(Attributes::AGI,
+ msg.readUInt8("agi cost"));
+ }
+ else
+ {
+ msg.readUInt8("agi cost");
+ }
+
+ val = msg.readUInt8("vit");
+ PlayerInfo::setStatBase(Attributes::VIT, val);
+ if (statusWindow)
+ {
+ statusWindow->setPointsNeeded(Attributes::VIT,
+ msg.readUInt8("vit cost"));
+ }
+ else
+ {
+ msg.readUInt8("vit cost");
+ }
+
+ val = msg.readUInt8("int");
+ PlayerInfo::setStatBase(Attributes::INT, val);
+ if (statusWindow)
+ {
+ statusWindow->setPointsNeeded(Attributes::INT,
+ msg.readUInt8("int cost"));
+ }
+ else
+ {
+ msg.readUInt8("int cost");
+ }
+
+ val = msg.readUInt8("dex");
+ PlayerInfo::setStatBase(Attributes::DEX, val);
+ if (statusWindow)
+ {
+ statusWindow->setPointsNeeded(Attributes::DEX,
+ msg.readUInt8("dex cost"));
+ }
+ else
+ {
+ msg.readUInt8("dex cost");
+ }
+
+ val = msg.readUInt8("luk");
+ PlayerInfo::setStatBase(Attributes::LUK, val);
+ if (statusWindow)
+ {
+ statusWindow->setPointsNeeded(Attributes::LUK,
+ msg.readUInt8("luk cost"));
+ }
+ else
+ {
+ msg.readUInt8("luk cost");
+ }
+
+ PlayerInfo::setStatBase(Attributes::ATK,
+ msg.readInt16("atk"), Notify_false);
+ PlayerInfo::setStatMod(Attributes::ATK, msg.readInt16("atk+"));
+ PlayerInfo::updateAttrs();
+
+ val = msg.readInt16("matk");
+ PlayerInfo::setStatBase(Attributes::MATK, val, Notify_false);
+
+ val = msg.readInt16("matk+");
+ PlayerInfo::setStatMod(Attributes::MATK, val);
+
+ PlayerInfo::setStatBase(Attributes::DEF,
+ msg.readInt16("def"), Notify_false);
+ PlayerInfo::setStatMod(Attributes::DEF, msg.readInt16("def+"));
+
+ PlayerInfo::setStatBase(Attributes::MDEF,
+ msg.readInt16("mdef"), Notify_false);
+ PlayerInfo::setStatMod(Attributes::MDEF, msg.readInt16("mdef+"));
+
+ PlayerInfo::setStatBase(Attributes::HIT, msg.readInt16("hit"));
+
+ PlayerInfo::setStatBase(Attributes::FLEE,
+ msg.readInt16("flee"), Notify_false);
+ PlayerInfo::setStatMod(Attributes::FLEE, msg.readInt16("flee+"));
+
+ PlayerInfo::setStatBase(Attributes::CRIT, msg.readInt16("crit"));
+
+ PlayerInfo::setStatBase(Attributes::MANNER, msg.readInt16("manner"));
+ msg.readInt16("unused?");
+ BLOCK_END("PlayerRecv::processPlayerStatUpdate5")
+}
+
+void PlayerRecv::processWalkResponse(Net::MessageIn &msg)
+{
+ BLOCK_START("PlayerRecv::processWalkResponse")
+ /*
+ * This client assumes that all walk messages succeed,
+ * and that the server will send a correction notice
+ * otherwise.
+ */
+ uint16_t srcX, srcY, dstX, dstY;
+ msg.readInt32("tick");
+ msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
+ msg.readUInt8("unused");
+ if (localPlayer)
+ localPlayer->setRealPos(dstX, dstY);
+ BLOCK_END("PlayerRecv::processWalkResponse")
+}
+
+} // namespace TmwAthena
diff --git a/src/net/tmwa/playerrecv.h b/src/net/tmwa/playerrecv.h
new file mode 100644
index 000000000..0fcadb104
--- /dev/null
+++ b/src/net/tmwa/playerrecv.h
@@ -0,0 +1,39 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NET_TMWA_PLAYERRECV_H
+#define NET_TMWA_PLAYERRECV_H
+
+#include "net/ea/playerhandler.h"
+
+#include "net/tmwa/messagehandler.h"
+
+namespace TmwAthena
+{
+ namespace PlayerRecv
+ {
+ void processPlayerStatUpdate5(Net::MessageIn &msg);
+ void processWalkResponse(Net::MessageIn &msg);
+ } // namespace PlayerRecv
+} // namespace TmwAthena
+
+#endif // NET_TMWA_PLAYERRECV_H