summaryrefslogtreecommitdiff
path: root/src/net/tmwa/playerhandler.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-04-30 16:57:31 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-04-30 16:57:31 +0200
commit908dceb882723460cde35ec8ef22927b702ab874 (patch)
tree0598a9cb5d720c66c619fd350d64453490b35143 /src/net/tmwa/playerhandler.cpp
parent8a67e721880959b431d220e2d1fd5b60a4f11ad7 (diff)
parent0b1c6eb3c4941dc2d47ad3207bab4509ae1014cc (diff)
downloadmana-client-908dceb882723460cde35ec8ef22927b702ab874.tar.gz
mana-client-908dceb882723460cde35ec8ef22927b702ab874.tar.bz2
mana-client-908dceb882723460cde35ec8ef22927b702ab874.tar.xz
mana-client-908dceb882723460cde35ec8ef22927b702ab874.zip
Merge branch '0.5'
Conflicts: CMakeLists.txt po/fi.po po/fr.po src/gui/skilldialog.cpp src/localplayer.cpp src/net/manaserv/generalhandler.cpp src/net/tmwa/buysellhandler.cpp src/net/tmwa/generalhandler.cpp src/net/tmwa/playerhandler.cpp src/net/tmwa/specialhandler.cpp src/winver.h
Diffstat (limited to 'src/net/tmwa/playerhandler.cpp')
-rw-r--r--src/net/tmwa/playerhandler.cpp39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index 4bd637c3..ab63cc1d 100644
--- a/src/net/tmwa/playerhandler.cpp
+++ b/src/net/tmwa/playerhandler.cpp
@@ -22,8 +22,7 @@
#include "net/tmwa/playerhandler.h"
#include "net/tmwa/beinghandler.h"
-#include "client.h"
-#include "event.h"
+#include "configuration.h"
#include "game.h"
#include "localplayer.h"
#include "log.h"
@@ -227,6 +226,8 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg)
case SMSG_PLAYER_STAT_UPDATE_1:
{
+ if (!player_node)
+ break;
int type = msg.readInt16();
int value = msg.readInt32();
@@ -312,14 +313,24 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg)
PlayerInfo::setStatExperience(JOB, msg.readInt32(),
PlayerInfo::getStatExperience(JOB).second);
break;
- case 0x0014: {
+
+ case 0x0014:
+ {
int oldMoney = PlayerInfo::getAttribute(MONEY);
int newMoney = msg.readInt32();
+ std::string money = Units::formatCurrency(
+ newMoney - oldMoney);
PlayerInfo::setAttribute(MONEY, newMoney);
if (newMoney > oldMoney)
- SERVER_NOTICE(strprintf(_("You picked up %s."),
- Units::formatCurrency(newMoney -
- oldMoney).c_str()))
+ {
+ if (config.getBoolValue("showpickupchat"))
+ SERVER_NOTICE(strprintf(_("You picked up %s."),
+ Units::formatCurrency(newMoney -
+ oldMoney).c_str()))
+ if (config.getBoolValue("showpickupparticle"))
+ player_node->addMessageToQueue(money,
+ UserPalette::PICKUP_INFO);
+ }
}
break;
case 0x0016:
@@ -543,11 +554,17 @@ void PlayerHandler::increaseSkill(int skillId)
void PlayerHandler::pickUp(FloorItem *floorItem)
{
- if (floorItem)
- {
- MessageOut outMsg(CMSG_ITEM_PICKUP);
- outMsg.writeInt32(floorItem->getId());
- }
+ static Uint32 lastTime = 0;
+
+ // Avoid spamming the server with pick-up requests to prevent the player
+ // from being kicked.
+ if (!floorItem || SDL_GetTicks() < lastTime + 100)
+ return;
+
+ MessageOut outMsg(CMSG_ITEM_PICKUP);
+ outMsg.writeInt32(floorItem->getId());
+
+ lastTime = SDL_GetTicks();
}
void PlayerHandler::setDirection(char direction)