summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
authorPhilipp Sehmisch <crush@themanaworld.org>2009-03-29 18:33:44 +0200
committerPhilipp Sehmisch <crush@themanaworld.org>2009-03-29 18:33:44 +0200
commit9587fb9b86ee4081ba14d23c1133bf1a09ee4578 (patch)
tree7682df3ec17534be553caae85ffa9e5a68c9a815 /src/localplayer.cpp
parent63b41440a0555c6b39141eab94ef4627f712b476 (diff)
parent8748f26234bba1e71bbe059147fb02256f8cec2a (diff)
downloadmana-client-9587fb9b86ee4081ba14d23c1133bf1a09ee4578.tar.gz
mana-client-9587fb9b86ee4081ba14d23c1133bf1a09ee4578.tar.bz2
mana-client-9587fb9b86ee4081ba14d23c1133bf1a09ee4578.tar.xz
mana-client-9587fb9b86ee4081ba14d23c1133bf1a09ee4578.zip
Merge branch 'master' of git@gitorious.org:tmw/mainline
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp83
1 files changed, 35 insertions, 48 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index f8fad1e8..eb54b4b1 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -18,7 +18,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <cassert>
+
+#include "localplayer.h"
#include "configuration.h"
#include "equipment.h"
@@ -27,7 +28,6 @@
#include "graphics.h"
#include "inventory.h"
#include "item.h"
-#include "localplayer.h"
#include "map.h"
#include "monster.h"
#include "particle.h"
@@ -65,6 +65,8 @@
#include "utils/gettext.h"
#include "utils/stringutils.h"
+#include <cassert>
+
#ifdef TMWSERV_SUPPORT
const short walkingKeyboardDelay = 100;
#endif
@@ -96,7 +98,6 @@ LocalPlayer::LocalPlayer(int id, int job, Map *map):
mStatPoint(0), mSkillPoint(0),
mStatsPointsToAttribute(0),
mEquipment(new Equipment),
- mNetwork(0),
mXp(0),
mInStorage(false),
mTargetTime(-1),
@@ -111,13 +112,12 @@ LocalPlayer::LocalPlayer(int id, int job, Map *map):
mLastAction(-1),
mWalkingDir(0),
mDestX(0), mDestY(0),
+ mInventory(new Inventory(INVENTORY_SIZE)),
#ifdef TMWSERV_SUPPORT
mLocalWalkTime(-1),
- mInventory(new Inventory(INVENTORY_SIZE)),
mExpMessageTime(0)
#else
- mInventory(new Inventory(INVENTORY_SIZE, 2)),
- mStorage(new Inventory(STORAGE_SIZE, 1))
+ mStorage(new Inventory(STORAGE_SIZE))
#endif
{
// Variable to keep the local player from doing certain actions before a map
@@ -363,11 +363,6 @@ void LocalPlayer::inviteToGuild(Being *being)
}
}
-void LocalPlayer::inviteToParty(const std::string &name)
-{
- Net::ChatServer::Party::invitePlayer(name);
-}
-
void LocalPlayer::clearInventory()
{
mEquipment->clear();
@@ -381,6 +376,15 @@ void LocalPlayer::setInvItem(int index, int id, int amount)
#endif
+void LocalPlayer::inviteToParty(const std::string &name)
+{
+#ifdef TMWSERV_SUPPORT
+ Net::ChatServer::Party::invitePlayer(name);
+#else
+
+#endif
+}
+
void LocalPlayer::moveInvItem(Item *item, int newIndex)
{
// special case, the old and new cannot copy over each other.
@@ -399,9 +403,8 @@ void LocalPlayer::equipItem(Item *item)
#ifdef TMWSERV_SUPPORT
Net::GameServer::Player::equip(item->getInvIndex());
#else
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(CMSG_PLAYER_EQUIP);
- outMsg.writeInt16(item->getInvIndex());
+ MessageOut outMsg(CMSG_PLAYER_EQUIP);
+ outMsg.writeInt16(item->getInvIndex() + INVENTORY_OFFSET);
outMsg.writeInt16(0);
#endif
}
@@ -428,9 +431,8 @@ void LocalPlayer::unequipItem(Item *item)
if (!item)
return;
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(CMSG_PLAYER_UNEQUIP);
- outMsg.writeInt16(item->getInvIndex());
+ MessageOut outMsg(CMSG_PLAYER_UNEQUIP);
+ outMsg.writeInt16(item->getInvIndex() + INVENTORY_OFFSET);
// Tidy equipment directly to avoid weapon still shown bug, for instance
mEquipment->removeEquipment(item->getInvIndex());
@@ -438,9 +440,8 @@ void LocalPlayer::unequipItem(Item *item)
void LocalPlayer::useItem(Item *item)
{
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(CMSG_PLAYER_INVENTORY_USE);
- outMsg.writeInt16(item->getInvIndex());
+ MessageOut outMsg(CMSG_PLAYER_INVENTORY_USE);
+ outMsg.writeInt16(item->getInvIndex() + INVENTORY_OFFSET);
outMsg.writeInt32(item->getId());
// Note: id is dest of item, usually player_node->account_ID ??
}
@@ -453,9 +454,8 @@ void LocalPlayer::dropItem(Item *item, int quantity)
Net::GameServer::Player::drop(item->getInvIndex(), quantity);
#else
// TODO: Fix wrong coordinates of drops, serverside?
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(CMSG_PLAYER_INVENTORY_DROP);
- outMsg.writeInt16(item->getInvIndex());
+ MessageOut outMsg(CMSG_PLAYER_INVENTORY_DROP);
+ outMsg.writeInt16(item->getInvIndex() + INVENTORY_OFFSET);
outMsg.writeInt16(quantity);
#endif
}
@@ -488,8 +488,7 @@ void LocalPlayer::pickUp(FloorItem *item)
int id = item->getId();
Net::GameServer::Player::pickUp(id >> 16, id & 0xFFFF);
#else
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(CMSG_ITEM_PICKUP);
+ MessageOut outMsg(CMSG_ITEM_PICKUP);
outMsg.writeInt32(item->getId());
#endif
mPickUpTarget = NULL;
@@ -689,9 +688,8 @@ void LocalPlayer::setDestination(Uint16 x, Uint16 y)
effectManager->trigger(15,x,y);
#else
char temp[4] = "";
- MessageOut outMsg(mNetwork);
set_coordinates(temp, x, y, mDirection);
- outMsg.writeInt16(0x0085);
+ MessageOut outMsg(0x0085);
outMsg.writeString(temp, 3);
#endif
}
@@ -734,8 +732,7 @@ void LocalPlayer::stopWalking(bool sendToServer)
#ifdef EATHENA_SUPPORT
void LocalPlayer::raiseAttribute(Attribute attr)
{
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(CMSG_STAT_UPDATE_REQUEST);
+ MessageOut outMsg(CMSG_STAT_UPDATE_REQUEST);
switch (attr)
{
@@ -771,8 +768,7 @@ void LocalPlayer::raiseSkill(Uint16 skillId)
if (mSkillPoint <= 0)
return;
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(CMSG_SKILL_LEVELUP_REQUEST);
+ MessageOut outMsg(CMSG_SKILL_LEVELUP_REQUEST);
outMsg.writeInt16(skillId);
}
#endif
@@ -795,8 +791,7 @@ void LocalPlayer::toggleSit()
setAction(newAction);
Net::GameServer::Player::changeAction(newAction);
#else
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(0x0089);
+ MessageOut outMsg(0x0089);
outMsg.writeInt32(0);
outMsg.writeInt8((newAction == SIT) ? 2 : 3);
#endif
@@ -810,8 +805,7 @@ void LocalPlayer::emote(Uint8 emotion)
// XXX Convert for new server
#ifdef EATHENA_SUPPORT
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(0x00bf);
+ MessageOut outMsg(0x00bf);
outMsg.writeInt8(emotion);
#endif
}
@@ -822,8 +816,7 @@ void LocalPlayer::tradeReply(bool accept)
if (!accept)
mTrading = false;
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(CMSG_TRADE_RESPONSE);
+ MessageOut outMsg(CMSG_TRADE_RESPONSE);
outMsg.writeInt8(accept ? 3 : 4);
}
#endif
@@ -837,8 +830,7 @@ void LocalPlayer::trade(Being *being) const
tradePartnerID = being->getId();
Net::GameServer::Player::requestTrade(tradePartnerID);
#else
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(CMSG_TRADE_REQUEST);
+ MessageOut outMsg(CMSG_TRADE_REQUEST);
outMsg.writeInt32(being->getId());
#endif
}
@@ -957,8 +949,7 @@ void LocalPlayer::attack(Being *target, bool keep)
sound.playSfx("sfx/fist-swish.ogg");
}
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(0x0089);
+ MessageOut outMsg(0x0089);
outMsg.writeInt32(target->getId());
outMsg.writeInt8(0);
@@ -983,8 +974,7 @@ void LocalPlayer::revive()
{
// XXX Convert for new server
#ifdef EATHENA_SUPPORT
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(0x00b2);
+ MessageOut outMsg(0x00b2);
outMsg.writeInt8(0);
#endif
}
@@ -1209,12 +1199,9 @@ void LocalPlayer::loadTargetCursor(std::string filename, int width, int height,
assert(size > -1);
assert(size < 3);
- ImageSet* currentImageSet;
- SimpleAnimation* currentCursor;
-
ResourceManager *resman = ResourceManager::getInstance();
- currentImageSet = resman->getImageSet(filename, width, height);
+ ImageSet *currentImageSet = resman->getImageSet(filename, width, height);
Animation *anim = new Animation;
for (unsigned int i = 0; i < currentImageSet->size(); ++i)
@@ -1224,7 +1211,7 @@ void LocalPlayer::loadTargetCursor(std::string filename, int width, int height,
(16 - (currentImageSet->getHeight() / 2)));
}
- currentCursor = new SimpleAnimation(anim);
+ SimpleAnimation *currentCursor = new SimpleAnimation(anim);
const int index = outRange ? 1 : 0;