summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-01-05 10:14:17 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-01-05 10:14:17 +0000
commitc887f550b55b6160f074cb3160a4442ca659fad9 (patch)
tree43cd78f7bdbf00e0764792a2dbd49e7b115ac971
parente880b17081962580afea1d003600afffe062d427 (diff)
downloadmana-c887f550b55b6160f074cb3160a4442ca659fad9.tar.gz
mana-c887f550b55b6160f074cb3160a4442ca659fad9.tar.bz2
mana-c887f550b55b6160f074cb3160a4442ca659fad9.tar.xz
mana-c887f550b55b6160f074cb3160a4442ca659fad9.zip
Implemented item dropping.
-rw-r--r--ChangeLog7
-rw-r--r--src/localplayer.cpp12
-rw-r--r--src/map.cpp4
-rw-r--r--src/map.h4
-rw-r--r--src/net/gameserver/player.cpp8
-rw-r--r--src/net/gameserver/player.h1
-rw-r--r--src/net/protocol.h4
7 files changed, 23 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index 3dc5f55f..bc85e5f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,9 @@
-2006-01-05 Bjørn Lindeijer <bjorn@lindeijer.nl>
+2007-01-05 Guillaume Melquiond <guillaume.melquiond@gmail.com>
+
+ * src/net/gameserver/player.h, src/net/gameserver/player.cpp,
+ src/net/protocol.h, src/localplayer.cpp: Implemented item dropping.
+
+2007-01-05 Bjørn Lindeijer <bjorn@lindeijer.nl>
* src/map.cpp, src/map.h: Declared some methods const.
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index b3e13a2a..1dd8bdf2 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -104,10 +104,7 @@ Item* LocalPlayer::getInvItem(int index)
void LocalPlayer::equipItem(Item *item)
{
- // XXX What's itemId and slot exactly? Same as eAthena?
- /*
- Net::GameServer::Player::equip(itemId, slot));
- */
+ Net::GameServer::Player::equip(item->getInvIndex());
}
void LocalPlayer::unequipItem(Item *item)
@@ -138,12 +135,7 @@ void LocalPlayer::useItem(Item *item)
void LocalPlayer::dropItem(Item *item, int quantity)
{
- // XXX Convert for new server
- /*
- MessageOut outMsg(CMSG_PLAYER_INVENTORY_DROP);
- outMsg.writeShort(item->getInvIndex());
- outMsg.writeShort(quantity);
- */
+ Net::GameServer::Player::drop(item->getInvIndex(), quantity);
}
void LocalPlayer::pickUp(FloorItem *item)
diff --git a/src/map.cpp b/src/map.cpp
index ec4abc50..a88926d7 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -286,7 +286,7 @@ Map::getWalk(int x, int y) const
}
bool
-Map::occupied(int x, int y)
+Map::occupied(int x, int y) const
{
Beings &beings = beingManager->getAll();
for (BeingIterator i = beings.begin(); i != beings.end(); i++)
@@ -308,7 +308,7 @@ Map::tileCollides(int x, int y) const
}
bool
-Map::contains(int x, int y)
+Map::contains(int x, int y) const
{
return x >= 0 && y >= 0 && x < mWidth && y < mHeight;
}
diff --git a/src/map.h b/src/map.h
index 6d366cb3..c8a6fdb3 100644
--- a/src/map.h
+++ b/src/map.h
@@ -202,12 +202,12 @@ class Map : public Properties
/**
* Tells whether a tile is occupied by a being.
*/
- bool occupied(int x, int y);
+ bool occupied(int x, int y) const;
/**
* Tells whether the given coordinates fall within the map boundaries.
*/
- bool contains(int x, int y);
+ bool contains(int x, int y) const;
int mWidth, mHeight;
int mTileWidth, mTileHeight;
diff --git a/src/net/gameserver/player.cpp b/src/net/gameserver/player.cpp
index 763f3d28..033327c9 100644
--- a/src/net/gameserver/player.cpp
+++ b/src/net/gameserver/player.cpp
@@ -52,6 +52,14 @@ void Net::GameServer::Player::pickUp(int x, int y)
Net::GameServer::connection->send(msg);
}
+void Net::GameServer::Player::drop(int slot, int amount)
+{
+ MessageOut msg(PGMSG_DROP);
+ msg.writeByte(slot);
+ msg.writeByte(amount);
+ Net::GameServer::connection->send(msg);
+}
+
void Net::GameServer::Player::equip(int slot)
{
MessageOut msg(PGMSG_EQUIP);
diff --git a/src/net/gameserver/player.h b/src/net/gameserver/player.h
index a5429e65..73a533d5 100644
--- a/src/net/gameserver/player.h
+++ b/src/net/gameserver/player.h
@@ -35,6 +35,7 @@ namespace Net
void say(const std::string &text);
void walk(int x, int y);
void pickUp(int x, int y);
+ void drop(int slot, int amount);
void equip(int slot);
void attack(unsigned char direction);
}
diff --git a/src/net/protocol.h b/src/net/protocol.h
index 4896b977..2fbd59e4 100644
--- a/src/net/protocol.h
+++ b/src/net/protocol.h
@@ -148,6 +148,8 @@ enum {
GPMSG_PLAYER_MAP_CHANGE = 0x0100, // S filename, W x, W y
GPMSG_PLAYER_SERVER_CHANGE = 0x0101, // B*32 token, S game address, W game port
PGMSG_PICKUP = 0x0110, // W*2 position
+ PGMSG_DROP = 0x0111, // B slot, B amount
+ PGMSG_EQUIP = 0x0112, // B slot
GPMSG_INVENTORY = 0x0120, // { B slot, W item id [, B amount] }*
GPMSG_BEING_ENTER = 0x0200, // B type, W being id
// player: S name, B hair style, B hair color, B gender
@@ -163,8 +165,6 @@ enum {
GPMSG_SAY = 0x02A1, // W being id, S text
PGMSG_USE_ITEM = 0x0300, // L item id
GPMSG_USE_RESPONSE = 0x0301, // B error
- PGMSG_EQUIP = 0x0302, // L item id, B slot
- GPMSG_EQUIP_RESPONSE = 0x0303, // B error
GPMSG_BEINGS_DAMAGE = 0x0310, // { W being id, W amount }*
// Chat