summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--src/Makefile.am2
-rw-r--r--src/net/beinghandler.cpp237
-rw-r--r--src/net/beinghandler.h6
-rw-r--r--src/net/buysellhandler.cpp32
-rw-r--r--src/net/buysellhandler.h2
-rw-r--r--src/net/charserverhandler.cpp28
-rw-r--r--src/net/charserverhandler.h5
-rw-r--r--src/net/chathandler.cpp20
-rw-r--r--src/net/chathandler.h2
-rw-r--r--src/net/equipmenthandler.cpp46
-rw-r--r--src/net/equipmenthandler.h2
-rw-r--r--src/net/inventoryhandler.cpp58
-rw-r--r--src/net/inventoryhandler.h2
-rw-r--r--src/net/itemhandler.cpp16
-rw-r--r--src/net/itemhandler.h2
-rw-r--r--src/net/loginhandler.cpp8
-rw-r--r--src/net/loginhandler.h2
-rw-r--r--src/net/maploginhandler.cpp6
-rw-r--r--src/net/maploginhandler.h2
-rw-r--r--src/net/messagehandler.h2
-rw-r--r--src/net/messagein.cpp2
-rw-r--r--src/net/messageout.cpp2
-rw-r--r--src/net/network.cpp2
-rw-r--r--src/net/npchandler.cpp18
-rw-r--r--src/net/npchandler.h2
-rw-r--r--src/net/packet.cpp40
-rw-r--r--src/net/packet.h47
-rw-r--r--src/net/playerhandler.cpp112
-rw-r--r--src/net/playerhandler.h2
-rw-r--r--src/net/skillhandler.cpp34
-rw-r--r--src/net/skillhandler.h2
-rw-r--r--src/net/tradehandler.cpp26
-rw-r--r--src/net/tradehandler.h2
34 files changed, 358 insertions, 416 deletions
diff --git a/ChangeLog b/ChangeLog
index 12e30213..8f589dcb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -25,6 +25,9 @@
selection of player character and implemented sending of game and chat
server tokens. It gets you in the game (or what's left of it), but not
on any map yet.
+ * src/net/*: Changed MessageHandler::handleMessage to take a reference
+ instead of a pointer. Removed unused Packet class. Added stub for
+ handling GPMSG_BEING_ENTER.
2006-08-19 Bjørn Lindeijer <bjorn@lindeijer.nl>
diff --git a/src/Makefile.am b/src/Makefile.am
index 42671f64..8f40c506 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -146,8 +146,6 @@ tmw_SOURCES = graphic/imagerect.h \
net/network.h \
net/npchandler.cpp \
net/npchandler.h \
- net/packet.cpp \
- net/packet.h \
net/playerhandler.cpp \
net/playerhandler.h \
net/protocol.cpp \
diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp
index 549797f9..ed0fc4b2 100644
--- a/src/net/beinghandler.cpp
+++ b/src/net/beinghandler.cpp
@@ -41,24 +41,25 @@ const int EMOTION_TIME = 150; /**< Duration of emotion icon */
BeingHandler::BeingHandler()
{
static const Uint16 _messages[] = {
- SMSG_BEING_VISIBLE,
- SMSG_BEING_MOVE,
- SMSG_BEING_REMOVE,
- SMSG_BEING_ACTION,
- SMSG_BEING_LEVELUP,
- SMSG_BEING_EMOTION,
- SMSG_BEING_CHANGE_LOOKS,
- SMSG_BEING_NAME_RESPONSE,
- SMSG_PLAYER_UPDATE_1,
- SMSG_PLAYER_UPDATE_2,
- SMSG_PLAYER_MOVE,
- 0x0119,
+ //SMSG_BEING_VISIBLE,
+ //SMSG_BEING_MOVE,
+ //SMSG_BEING_REMOVE,
+ //SMSG_BEING_ACTION,
+ //SMSG_BEING_LEVELUP,
+ //SMSG_BEING_EMOTION,
+ //SMSG_BEING_CHANGE_LOOKS,
+ //SMSG_BEING_NAME_RESPONSE,
+ //SMSG_PLAYER_UPDATE_1,
+ //SMSG_PLAYER_UPDATE_2,
+ //SMSG_PLAYER_MOVE,
+ //0x0119,
+ GPMSG_BEING_ENTER,
0
};
handledMessages = _messages;
}
-void BeingHandler::handleMessage(MessageIn *msg)
+void BeingHandler::handleMessage(MessageIn &msg)
{
Uint32 id;
Uint16 job, speed;
@@ -66,17 +67,21 @@ void BeingHandler::handleMessage(MessageIn *msg)
Sint8 type;
Being *srcBeing, *dstBeing;
- switch (msg->getId())
+ switch (msg.getId())
{
+ case GPMSG_BEING_ENTER:
+ handleBeingEnterMessage(msg);
+ break;
+
case SMSG_BEING_VISIBLE:
case SMSG_BEING_MOVE:
// Information about a being in range
- id = msg->readLong();
- speed = msg->readShort();
- msg->readShort(); // unknown
- msg->readShort(); // unknown
- msg->readShort(); // option
- job = msg->readShort(); // class
+ id = msg.readLong();
+ speed = msg.readShort();
+ msg.readShort(); // unknown
+ msg.readShort(); // unknown
+ msg.readShort(); // option
+ job = msg.readShort(); // class
dstBeing = beingManager->findBeing(id);
@@ -91,7 +96,7 @@ void BeingHandler::handleMessage(MessageIn *msg)
dstBeing = beingManager->createBeing(id, job);
}
- else if (msg->getId() == 0x0078)
+ else if (msg.getId() == 0x0078)
{
dstBeing->clearPath();
dstBeing->mFrame = 0;
@@ -104,33 +109,33 @@ void BeingHandler::handleMessage(MessageIn *msg)
dstBeing->setWalkSpeed(speed);
dstBeing->mJob = job;
- dstBeing->setHairStyle(msg->readShort());
- dstBeing->setWeapon(msg->readShort());
- dstBeing->setVisibleEquipment(3, msg->readShort()); // head bottom
+ dstBeing->setHairStyle(msg.readShort());
+ dstBeing->setWeapon(msg.readShort());
+ dstBeing->setVisibleEquipment(3, msg.readShort()); // head bottom
- if (msg->getId() == SMSG_BEING_MOVE)
+ if (msg.getId() == SMSG_BEING_MOVE)
{
- msg->readLong(); // server tick
+ msg.readLong(); // server tick
}
- msg->readShort(); // shield
- dstBeing->setVisibleEquipment(4, msg->readShort()); // head top
- dstBeing->setVisibleEquipment(5, msg->readShort()); // head mid
- dstBeing->setHairColor(msg->readShort());
- msg->readShort(); // unknown
- msg->readShort(); // head dir
- msg->readShort(); // guild
- msg->readShort(); // unknown
- msg->readShort(); // unknown
- msg->readShort(); // manner
- msg->readShort(); // karma
- msg->readByte(); // unknown
- dstBeing->setSex(1 - msg->readByte()); // sex
-
- if (msg->getId() == SMSG_BEING_MOVE)
+ msg.readShort(); // shield
+ dstBeing->setVisibleEquipment(4, msg.readShort()); // head top
+ dstBeing->setVisibleEquipment(5, msg.readShort()); // head mid
+ dstBeing->setHairColor(msg.readShort());
+ msg.readShort(); // unknown
+ msg.readShort(); // head dir
+ msg.readShort(); // guild
+ msg.readShort(); // unknown
+ msg.readShort(); // unknown
+ msg.readShort(); // manner
+ msg.readShort(); // karma
+ msg.readByte(); // unknown
+ dstBeing->setSex(1 - msg.readByte()); // sex
+
+ if (msg.getId() == SMSG_BEING_MOVE)
{
//Uint16 srcX, srcY, dstX, dstY;
- //msg->readCoordinatePair(srcX, srcY, dstX, dstY);
+ //msg.readCoordinatePair(srcX, srcY, dstX, dstY);
//dstBeing->setAction(Being::STAND);
//dstBeing->mX = srcX;
//dstBeing->mY = srcY;
@@ -138,22 +143,22 @@ void BeingHandler::handleMessage(MessageIn *msg)
}
else
{
- //msg->readCoordinates(dstBeing->mX, dstBeing->mY, dstBeing->mDirection);
+ //msg.readCoordinates(dstBeing->mX, dstBeing->mY, dstBeing->mDirection);
}
- msg->readByte(); // unknown
- msg->readByte(); // unknown
- msg->readByte(); // unknown / sit
+ msg.readByte(); // unknown
+ msg.readByte(); // unknown
+ msg.readByte(); // unknown / sit
break;
case SMSG_BEING_REMOVE:
// A being should be removed or has died
- dstBeing = beingManager->findBeing(msg->readLong());
+ dstBeing = beingManager->findBeing(msg.readLong());
if (!dstBeing)
break;
- if (msg->readByte() == 1)
+ if (msg.readByte() == 1)
{
// Death
switch (dstBeing->getType())
@@ -181,15 +186,15 @@ void BeingHandler::handleMessage(MessageIn *msg)
break;
case SMSG_BEING_ACTION:
- srcBeing = beingManager->findBeing(msg->readLong());
- dstBeing = beingManager->findBeing(msg->readLong());
- msg->readLong(); // server tick
- msg->readLong(); // src speed
- msg->readLong(); // dst speed
- param1 = msg->readShort();
- msg->readShort(); // param 2
- type = msg->readByte();
- msg->readShort(); // param 3
+ srcBeing = beingManager->findBeing(msg.readLong());
+ dstBeing = beingManager->findBeing(msg.readLong());
+ msg.readLong(); // server tick
+ msg.readLong(); // src speed
+ msg.readLong(); // dst speed
+ param1 = msg.readShort();
+ msg.readShort(); // param 2
+ type = msg.readByte();
+ msg.readShort(); // param 3
switch (type)
{
@@ -230,63 +235,63 @@ void BeingHandler::handleMessage(MessageIn *msg)
break;
case SMSG_BEING_LEVELUP:
- if ((Uint32)msg->readLong() == player_node->getId()) {
+ if ((Uint32) msg.readLong() == player_node->getId()) {
logger->log("Level up");
sound.playSfx("sfx/levelup.ogg");
} else {
logger->log("Someone else went level up");
}
- msg->readLong(); // type
+ msg.readLong(); // type
break;
case SMSG_BEING_EMOTION:
- if (!(dstBeing = beingManager->findBeing(msg->readLong())))
+ if (!(dstBeing = beingManager->findBeing(msg.readLong())))
{
break;
}
- dstBeing->mEmotion = msg->readByte();
+ dstBeing->mEmotion = msg.readByte();
dstBeing->mEmotionTime = EMOTION_TIME;
break;
case SMSG_BEING_CHANGE_LOOKS:
{
- if (!(dstBeing = beingManager->findBeing(msg->readLong())))
+ if (!(dstBeing = beingManager->findBeing(msg.readLong())))
{
break;
}
- int type = msg->readByte();
+ int type = msg.readByte();
switch (type) {
case 1:
- dstBeing->setHairStyle(msg->readByte());
+ dstBeing->setHairStyle(msg.readByte());
break;
case 2:
- dstBeing->setWeapon(msg->readByte());
+ dstBeing->setWeapon(msg.readByte());
break;
case 3:
case 4:
case 5:
// Equip/unequip head 3. Bottom 4. Top 5. Middle
- dstBeing->setVisibleEquipment(type, msg->readByte());
+ dstBeing->setVisibleEquipment(type, msg.readByte());
// First 3 slots of mVisibleEquipments are reserved for
// later use, probably accessories.
break;
case 6:
- dstBeing->setHairColor(msg->readByte());
+ dstBeing->setHairColor(msg.readByte());
break;
default:
- printf("c3: %i\n", msg->readByte()); // unsupported
+ printf("c3: %i\n", msg.readByte()); // unsupported
break;
}
}
break;
case SMSG_BEING_NAME_RESPONSE:
- if ((dstBeing = beingManager->findBeing(msg->readLong())))
+ if ((dstBeing = beingManager->findBeing(msg.readLong())))
{
- dstBeing->setName(msg->readString(24));
+ dstBeing->setName(msg.readString(24));
}
break;
@@ -294,12 +299,12 @@ void BeingHandler::handleMessage(MessageIn *msg)
case SMSG_PLAYER_UPDATE_2:
case SMSG_PLAYER_MOVE:
// An update about a player, potentially including movement.
- id = msg->readLong();
- speed = msg->readShort();
- msg->readShort(); // option 1
- msg->readShort(); // option 2
- msg->readShort(); // option
- job = msg->readShort();
+ id = msg.readLong();
+ speed = msg.readShort();
+ msg.readShort(); // option 1
+ msg.readShort(); // option 2
+ msg.readShort(); // option
+ job = msg.readShort();
dstBeing = beingManager->findBeing(id);
@@ -310,57 +315,57 @@ void BeingHandler::handleMessage(MessageIn *msg)
dstBeing->setWalkSpeed(speed);
dstBeing->mJob = job;
- dstBeing->setHairStyle(msg->readShort());
- dstBeing->setWeaponById(msg->readShort()); // item id 1
- msg->readShort(); // item id 2
- dstBeing->setVisibleEquipment(3, msg->readShort()); // head bottom
+ dstBeing->setHairStyle(msg.readShort());
+ dstBeing->setWeaponById(msg.readShort()); // item id 1
+ msg.readShort(); // item id 2
+ dstBeing->setVisibleEquipment(3, msg.readShort()); // head bottom
- if (msg->getId() == SMSG_PLAYER_MOVE)
+ if (msg.getId() == SMSG_PLAYER_MOVE)
{
- msg->readLong(); // server tick
+ msg.readLong(); // server tick
}
- dstBeing->setVisibleEquipment(4, msg->readShort()); // head top
- dstBeing->setVisibleEquipment(5, msg->readShort()); // head mid
- dstBeing->setHairColor(msg->readShort());
- msg->readShort(); // unknown
- msg->readShort(); // head dir
- msg->readLong(); // guild
- msg->readLong(); // emblem
- msg->readShort(); // manner
- msg->readByte(); // karma
- dstBeing->setSex(1 - msg->readByte()); // sex
-
- if (msg->getId() == SMSG_PLAYER_MOVE)
+ dstBeing->setVisibleEquipment(4, msg.readShort()); // head top
+ dstBeing->setVisibleEquipment(5, msg.readShort()); // head mid
+ dstBeing->setHairColor(msg.readShort());
+ msg.readShort(); // unknown
+ msg.readShort(); // head dir
+ msg.readLong(); // guild
+ msg.readLong(); // emblem
+ msg.readShort(); // manner
+ msg.readByte(); // karma
+ dstBeing->setSex(1 - msg.readByte()); // sex
+
+ if (msg.getId() == SMSG_PLAYER_MOVE)
{
//Uint16 srcX, srcY, dstX, dstY;
- //msg->readCoordinatePair(srcX, srcY, dstX, dstY);
+ //msg.readCoordinatePair(srcX, srcY, dstX, dstY);
//dstBeing->mX = srcX;
//dstBeing->mY = srcY;
//dstBeing->setDestination(dstX, dstY);
}
else
{
- //msg->readCoordinates(dstBeing->mX, dstBeing->mY, dstBeing->mDirection);
+ //msg.readCoordinates(dstBeing->mX, dstBeing->mY, dstBeing->mDirection);
}
- msg->readByte(); // unknown
- msg->readByte(); // unknown
+ msg.readByte(); // unknown
+ msg.readByte(); // unknown
- if (msg->getId() == SMSG_PLAYER_UPDATE_1)
+ if (msg.getId() == SMSG_PLAYER_UPDATE_1)
{
- if (msg->readByte() == 2)
+ if (msg.readByte() == 2)
{
dstBeing->setAction(Being::SIT);
}
}
- else if (msg->getId() == SMSG_PLAYER_MOVE)
+ else if (msg.getId() == SMSG_PLAYER_MOVE)
{
- msg->readByte(); // unknown
+ msg.readByte(); // unknown
}
- msg->readByte(); // Lv
- msg->readByte(); // unknown
+ msg.readByte(); // Lv
+ msg.readByte(); // unknown
dstBeing->mWalkTime = tick_time;
dstBeing->mFrame = 0;
@@ -368,9 +373,27 @@ void BeingHandler::handleMessage(MessageIn *msg)
case 0x0119:
// Change in players look
- printf("0x0119 %li %i %i %x %i\n", msg->readLong(),
- msg->readShort(), msg->readShort(), msg->readShort(),
- msg->readByte());
+ printf("0x0119 %li %i %i %x %i\n", msg.readLong(),
+ msg.readShort(), msg.readShort(), msg.readShort(),
+ msg.readByte());
break;
}
}
+
+void
+BeingHandler::handleBeingEnterMessage(MessageIn &msg)
+{
+ // Not sure what do to exactly with this message yet.
+ /*
+ unsigned char type = msg.readByte();
+ unsigned long id = msg.readLong();
+
+ if (type == OBJECT_PLAYER)
+ {
+ std::string name = msg.readString();
+ unsigned char hairStyle = msg.readByte();
+ unsigned char hairColor = msg.readByte();
+ unsigned char gender = msg.readByte();
+ }
+ */
+}
diff --git a/src/net/beinghandler.h b/src/net/beinghandler.h
index 03012f39..2dd81e1a 100644
--- a/src/net/beinghandler.h
+++ b/src/net/beinghandler.h
@@ -31,7 +31,11 @@ class BeingHandler : public MessageHandler
public:
BeingHandler();
- void handleMessage(MessageIn *msg);
+ void handleMessage(MessageIn &msg);
+
+ private:
+ void
+ handleBeingEnterMessage(MessageIn &msg);
};
#endif
diff --git a/src/net/buysellhandler.cpp b/src/net/buysellhandler.cpp
index 3b5fc87d..173c59d2 100644
--- a/src/net/buysellhandler.cpp
+++ b/src/net/buysellhandler.cpp
@@ -54,10 +54,10 @@ BuySellHandler::BuySellHandler()
handledMessages = _messages;
}
-void BuySellHandler::handleMessage(MessageIn *msg)
+void BuySellHandler::handleMessage(MessageIn &msg)
{
int n_items;
- switch (msg->getId())
+ switch (msg.getId())
{
case SMSG_NPC_BUY_SELL_CHOICE:
buyDialog->setVisible(false);
@@ -65,38 +65,38 @@ void BuySellHandler::handleMessage(MessageIn *msg)
sellDialog->setVisible(false);
sellDialog->reset();
buySellDialog->setVisible(true);
- current_npc = dynamic_cast<NPC*>(beingManager->findBeing(msg->readLong()));
+ current_npc = dynamic_cast<NPC*>(beingManager->findBeing(msg.readLong()));
break;
case SMSG_NPC_BUY:
- msg->readShort(); // length
- n_items = (msg->getLength() - 4) / 11;
+ msg.readShort(); // length
+ n_items = (msg.getLength() - 4) / 11;
buyDialog->reset();
buyDialog->setMoney(player_node->mMoney);
buyDialog->setVisible(true);
for (int k = 0; k < n_items; k++)
{
- Sint32 value = msg->readLong();
- msg->readLong(); // DCvalue
- msg->readByte(); // type
- Sint16 itemId = msg->readShort();
+ Sint32 value = msg.readLong();
+ msg.readLong(); // DCvalue
+ msg.readByte(); // type
+ Sint16 itemId = msg.readShort();
buyDialog->addItem(itemId, value);
}
break;
case SMSG_NPC_SELL:
- msg->readShort(); // length
- n_items = (msg->getLength() - 4) / 10;
+ msg.readShort(); // length
+ n_items = (msg.getLength() - 4) / 10;
if (n_items > 0) {
sellDialog->reset();
sellDialog->setVisible(true);
for (int k = 0; k < n_items; k++)
{
- Sint16 index = msg->readShort();
- Sint32 value = msg->readLong();
- msg->readLong(); // OCvalue
+ Sint16 index = msg.readShort();
+ Sint32 value = msg.readLong();
+ msg.readLong(); // OCvalue
Item *item = player_node->getInvItem(index);
if (item && !(item->isEquipped())) {
@@ -111,7 +111,7 @@ void BuySellHandler::handleMessage(MessageIn *msg)
break;
case SMSG_NPC_BUY_RESPONSE:
- if (msg->readByte() == 0) {
+ if (msg.readByte() == 0) {
chatWindow->chatLog("Thanks for buying", BY_SERVER);
} else {
chatWindow->chatLog("Unable to buy", BY_SERVER);
@@ -119,7 +119,7 @@ void BuySellHandler::handleMessage(MessageIn *msg)
break;
case SMSG_NPC_SELL_RESPONSE:
- if (msg->readByte() == 0) {
+ if (msg.readByte() == 0) {
chatWindow->chatLog("Thanks for selling", BY_SERVER);
} else {
chatWindow->chatLog("Unable to sell", BY_SERVER);
diff --git a/src/net/buysellhandler.h b/src/net/buysellhandler.h
index 673aaac1..e242d373 100644
--- a/src/net/buysellhandler.h
+++ b/src/net/buysellhandler.h
@@ -31,7 +31,7 @@ class BuySellHandler : public MessageHandler
public:
BuySellHandler();
- void handleMessage(MessageIn *msg);
+ void handleMessage(MessageIn &msg);
};
#endif
diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp
index 2bf2c4b4..5a2be683 100644
--- a/src/net/charserverhandler.cpp
+++ b/src/net/charserverhandler.cpp
@@ -48,20 +48,20 @@ CharServerHandler::CharServerHandler()
}
void
-CharServerHandler::handleMessage(MessageIn *msg)
+CharServerHandler::handleMessage(MessageIn &msg)
{
int slot;
LocalPlayer *tempPlayer;
- switch (msg->getId())
+ switch (msg.getId())
{
case APMSG_CHAR_CREATE_RESPONSE:
- handleCharCreateResponse(*msg);
+ handleCharCreateResponse(msg);
break;
case APMSG_CHAR_DELETE_RESPONSE:
{
- int errMsg = msg->readByte();
+ int errMsg = msg.readByte();
// Character deletion successful
if (errMsg == ERRMSG_OK)
{
@@ -101,7 +101,7 @@ CharServerHandler::handleMessage(MessageIn *msg)
break;
case APMSG_CHAR_SELECT_RESPONSE:
- handleCharSelectResponse(*msg);
+ handleCharSelectResponse(msg);
break;
}
}
@@ -193,18 +193,18 @@ CharServerHandler::handleCharSelectResponse(MessageIn &msg)
}
LocalPlayer*
-CharServerHandler::readPlayerData(MessageIn *msg, int &slot)
+CharServerHandler::readPlayerData(MessageIn &msg, int &slot)
{
LocalPlayer *tempPlayer = new LocalPlayer(mLoginData->account_ID, 0, NULL);
- slot = msg->readByte(); // character slot
- tempPlayer->mName = msg->readString();
- tempPlayer->mSex = msg->readByte();
- tempPlayer->setHairStyle(msg->readByte());
- tempPlayer->setHairColor(msg->readByte());
- tempPlayer->mLevel = msg->readByte();
- tempPlayer->mMoney = msg->readShort();
+ slot = msg.readByte(); // character slot
+ tempPlayer->mName = msg.readString();
+ tempPlayer->mSex = msg.readByte();
+ tempPlayer->setHairStyle(msg.readByte());
+ tempPlayer->setHairColor(msg.readByte());
+ tempPlayer->mLevel = msg.readByte();
+ tempPlayer->mMoney = msg.readShort();
for (int i = 0; i < 6; i++) {
- tempPlayer->mAttr[i] = msg->readByte();
+ tempPlayer->mAttr[i] = msg.readByte();
}
return tempPlayer;
}
diff --git a/src/net/charserverhandler.h b/src/net/charserverhandler.h
index b034b513..9ad11c6a 100644
--- a/src/net/charserverhandler.h
+++ b/src/net/charserverhandler.h
@@ -37,7 +37,7 @@ class CharServerHandler : public MessageHandler
CharServerHandler();
void
- handleMessage(MessageIn *msg);
+ handleMessage(MessageIn &msg);
void
setCharInfo(LockedArray<LocalPlayer*> *charInfo)
@@ -58,7 +58,8 @@ class CharServerHandler : public MessageHandler
LoginData *mLoginData;
LockedArray<LocalPlayer*> *mCharInfo;
- LocalPlayer* readPlayerData(MessageIn *msg, int &slot);
+ LocalPlayer*
+ readPlayerData(MessageIn &msg, int &slot);
};
#endif
diff --git a/src/net/chathandler.cpp b/src/net/chathandler.cpp
index d6f822f8..795b2a27 100644
--- a/src/net/chathandler.cpp
+++ b/src/net/chathandler.cpp
@@ -52,25 +52,25 @@ ChatHandler::ChatHandler()
handledMessages = _messages;
}
-void ChatHandler::handleMessage(MessageIn *msg)
+void ChatHandler::handleMessage(MessageIn &msg)
{
Being *being;
std::string chatMsg;
Sint16 chatMsgLength;
- switch (msg->getId())
+ switch (msg.getId())
{
// Received speech from being
case SMSG_BEING_CHAT:
- chatMsgLength = msg->readShort() - 8;
- being = beingManager->findBeing(msg->readLong());
+ chatMsgLength = msg.readShort() - 8;
+ being = beingManager->findBeing(msg.readLong());
if (!being || chatMsgLength <= 0)
{
break;
}
- chatMsg = msg->readString(chatMsgLength);
+ chatMsg = msg.readString(chatMsgLength);
chatWindow->chatLog(chatMsg, BY_OTHER);
chatMsg.erase(0, chatMsg.find(" : ", 0) + 3);
being->setSpeech(chatMsg, SPEECH_TIME);
@@ -78,16 +78,16 @@ void ChatHandler::handleMessage(MessageIn *msg)
case SMSG_PLAYER_CHAT:
case SMSG_GM_CHAT:
- chatMsgLength = msg->readShort() - 4;
+ chatMsgLength = msg.readShort() - 4;
if (chatMsgLength <= 0)
{
break;
}
- chatMsg = msg->readString(chatMsgLength);
+ chatMsg = msg.readString(chatMsgLength);
- if (msg->getId() == SMSG_PLAYER_CHAT)
+ if (msg.getId() == SMSG_PLAYER_CHAT)
{
chatWindow->chatLog(chatMsg, BY_PLAYER);
@@ -105,13 +105,13 @@ void ChatHandler::handleMessage(MessageIn *msg)
break;
case SMSG_WHO_ANSWER:
- chatWindow->chatLog("Online users: " + toString(msg->readLong()),
+ chatWindow->chatLog("Online users: " + toString(msg.readLong()),
BY_SERVER);
break;
case 0x010c:
// Display MVP player
- msg->readLong(); // id
+ msg.readLong(); // id
chatWindow->chatLog("MVP player", BY_SERVER);
break;
}
diff --git a/src/net/chathandler.h b/src/net/chathandler.h
index eed19206..e9db3575 100644
--- a/src/net/chathandler.h
+++ b/src/net/chathandler.h
@@ -31,7 +31,7 @@ class ChatHandler : public MessageHandler
public:
ChatHandler();
- void handleMessage(MessageIn *msg);
+ void handleMessage(MessageIn &msg);
};
#endif
diff --git a/src/net/equipmenthandler.cpp b/src/net/equipmenthandler.cpp
index aa372961..1c0fd4ca 100644
--- a/src/net/equipmenthandler.cpp
+++ b/src/net/equipmenthandler.cpp
@@ -48,7 +48,7 @@ EquipmentHandler::EquipmentHandler()
handledMessages = _messages;
}
-void EquipmentHandler::handleMessage(MessageIn *msg)
+void EquipmentHandler::handleMessage(MessageIn &msg)
{
Sint32 itemCount;
Sint16 index, equipPoint, itemId;
@@ -57,22 +57,22 @@ void EquipmentHandler::handleMessage(MessageIn *msg)
Being *being;
Item *item;
- switch (msg->getId())
+ switch (msg.getId())
{
case SMSG_PLAYER_EQUIPMENT:
- msg->readShort(); // length
- itemCount = (msg->getLength() - 4) / 20;
+ msg.readShort(); // length
+ itemCount = (msg.getLength() - 4) / 20;
for (int loop = 0; loop < itemCount; loop++)
{
- index = msg->readShort();
- itemId = msg->readShort();
- msg->readByte(); // type
- msg->readByte(); // identify flag
- msg->readShort(); // equip type
- equipPoint = msg->readShort();
- msg->readByte(); // attribute
- msg->readByte(); // refine
+ index = msg.readShort();
+ itemId = msg.readShort();
+ msg.readByte(); // type
+ msg.readByte(); // identify flag
+ msg.readShort(); // equip type
+ equipPoint = msg.readShort();
+ msg.readByte(); // attribute
+ msg.readByte(); // refine
player_node->addInvItem(index, itemId, 1, true);
@@ -92,9 +92,9 @@ void EquipmentHandler::handleMessage(MessageIn *msg)
break;
case SMSG_PLAYER_EQUIP:
- index = msg->readShort();
- equipPoint = msg->readShort();
- type = msg->readByte();
+ index = msg.readShort();
+ equipPoint = msg.readShort();
+ type = msg.readByte();
logger->log("Equipping: %i %i %i", index, equipPoint, type);
@@ -128,10 +128,10 @@ void EquipmentHandler::handleMessage(MessageIn *msg)
case 0x01d7:
// Equipment related
- being = beingManager->findBeing(msg->readLong());
- msg->readByte(); // equip point
- itemId = msg->readShort();
- msg->readShort(); // item id 2
+ being = beingManager->findBeing(msg.readLong());
+ msg.readByte(); // equip point
+ itemId = msg.readShort();
+ msg.readShort(); // item id 2
if (!being)
break;
@@ -140,9 +140,9 @@ void EquipmentHandler::handleMessage(MessageIn *msg)
break;
case SMSG_PLAYER_UNEQUIP:
- index = msg->readShort();
- equipPoint = msg->readShort();
- type = msg->readByte();
+ index = msg.readShort();
+ equipPoint = msg.readShort();
+ type = msg.readByte();
if (!type) {
chatWindow->chatLog("Unable to unequip.", BY_SERVER);
@@ -192,7 +192,7 @@ void EquipmentHandler::handleMessage(MessageIn *msg)
break;
case SMSG_PLAYER_ARROW_EQUIP:
- itemId = msg->readShort();
+ itemId = msg.readShort();
if (itemId <= 1)
break;
diff --git a/src/net/equipmenthandler.h b/src/net/equipmenthandler.h
index 656f7a73..c9c65d67 100644
--- a/src/net/equipmenthandler.h
+++ b/src/net/equipmenthandler.h
@@ -31,7 +31,7 @@ class EquipmentHandler : public MessageHandler
public:
EquipmentHandler();
- void handleMessage(MessageIn *msg);
+ void handleMessage(MessageIn &msg);
};
#endif
diff --git a/src/net/inventoryhandler.cpp b/src/net/inventoryhandler.cpp
index 51c71f8d..cb1883b0 100644
--- a/src/net/inventoryhandler.cpp
+++ b/src/net/inventoryhandler.cpp
@@ -46,27 +46,27 @@ InventoryHandler::InventoryHandler()
handledMessages = _messages;
}
-void InventoryHandler::handleMessage(MessageIn *msg)
+void InventoryHandler::handleMessage(MessageIn &msg)
{
Sint32 number;
Sint16 index, amount, itemId, equipType;
- switch (msg->getId())
+ switch (msg.getId())
{
case SMSG_PLAYER_INVENTORY:
// Only called on map load / warp. First reset all items
// to not load them twice on map change.
player_node->clearInventory();
- msg->readShort(); // length
- number = (msg->getLength() - 4) / 18;
+ msg.readShort(); // length
+ number = (msg.getLength() - 4) / 18;
for (int loop = 0; loop < number; loop++)
{
- index = msg->readShort();
- itemId = msg->readShort();
- msg->readByte(); // type
- msg->readByte(); // identify flag
- amount = msg->readShort();
+ index = msg.readShort();
+ itemId = msg.readShort();
+ msg.readByte(); // type
+ msg.readByte(); // identify flag
+ amount = msg.readShort();
player_node->addInvItem(index, itemId, amount, false);
@@ -79,16 +79,16 @@ void InventoryHandler::handleMessage(MessageIn *msg)
break;
case SMSG_PLAYER_INVENTORY_ADD:
- index = msg->readShort();
- amount = msg->readShort();
- itemId = msg->readShort();
- msg->readByte(); // identify flag
- msg->readByte(); // attribute
- msg->readByte(); // refine
- equipType = msg->readShort();
- msg->readByte(); // type
-
- if (msg->readByte()> 0) {
+ index = msg.readShort();
+ amount = msg.readShort();
+ itemId = msg.readShort();
+ msg.readByte(); // identify flag
+ msg.readByte(); // attribute
+ msg.readByte(); // refine
+ equipType = msg.readShort();
+ msg.readByte(); // type
+
+ if (msg.readByte()> 0) {
chatWindow->chatLog("Unable to pick up item", BY_SERVER);
} else {
player_node->addInvItem(index, itemId, amount, equipType != 0);
@@ -96,26 +96,26 @@ void InventoryHandler::handleMessage(MessageIn *msg)
break;
case SMSG_PLAYER_INVENTORY_REMOVE:
- index = msg->readShort();
- amount = msg->readShort();
+ index = msg.readShort();
+ amount = msg.readShort();
player_node->getInvItem(index)->increaseQuantity(-amount);
break;
case SMSG_PLAYER_INVENTORY_USE:
- index = msg->readShort();
- msg->readShort(); // item id
- msg->readLong(); // id
- amount = msg->readShort();
- msg->readByte(); // type
+ index = msg.readShort();
+ msg.readShort(); // item id
+ msg.readLong(); // id
+ amount = msg.readShort();
+ msg.readByte(); // type
player_node->getInvItem(index)->setQuantity(amount);
break;
case SMSG_ITEM_USE_RESPONSE:
- index = msg->readShort();
- amount = msg->readShort();
+ index = msg.readShort();
+ amount = msg.readShort();
- if (msg->readByte() == 0) {
+ if (msg.readByte() == 0) {
chatWindow->chatLog("Failed to use item", BY_SERVER);
} else {
player_node->getInvItem(index)->setQuantity(amount);
diff --git a/src/net/inventoryhandler.h b/src/net/inventoryhandler.h
index aedbc3a1..4190bf83 100644
--- a/src/net/inventoryhandler.h
+++ b/src/net/inventoryhandler.h
@@ -31,7 +31,7 @@ class InventoryHandler : public MessageHandler
public:
InventoryHandler();
- void handleMessage(MessageIn *msg);
+ void handleMessage(MessageIn &msg);
};
#endif
diff --git a/src/net/itemhandler.cpp b/src/net/itemhandler.cpp
index 23a9fa60..2961f71b 100644
--- a/src/net/itemhandler.cpp
+++ b/src/net/itemhandler.cpp
@@ -40,28 +40,28 @@ ItemHandler::ItemHandler()
handledMessages = _messages;
}
-void ItemHandler::handleMessage(MessageIn *msg)
+void ItemHandler::handleMessage(MessageIn &msg)
{
Uint32 id;
Uint16 x, y;
Sint16 itemId;
- switch (msg->getId())
+ switch (msg.getId())
{
case SMSG_ITEM_VISIBLE:
case SMSG_ITEM_DROPPED:
- id = msg->readLong();
- itemId = msg->readShort();
- msg->readByte(); // identify flag
- x = msg->readShort();
- y = msg->readShort();
+ id = msg.readLong();
+ itemId = msg.readShort();
+ msg.readByte(); // identify flag
+ x = msg.readShort();
+ y = msg.readShort();
floorItemManager->create(id, itemId, x, y, engine->getCurrentMap());
break;
case SMSG_ITEM_REMOVE:
FloorItem *item;
- item = floorItemManager->findById(msg->readLong());
+ item = floorItemManager->findById(msg.readLong());
if (item)
floorItemManager->destroy(item);
break;
diff --git a/src/net/itemhandler.h b/src/net/itemhandler.h
index b2104722..5ffcb134 100644
--- a/src/net/itemhandler.h
+++ b/src/net/itemhandler.h
@@ -31,7 +31,7 @@ class ItemHandler : public MessageHandler
public:
ItemHandler();
- void handleMessage(MessageIn *msg);
+ void handleMessage(MessageIn &msg);
};
#endif
diff --git a/src/net/loginhandler.cpp b/src/net/loginhandler.cpp
index 4790d7d1..700fb75a 100644
--- a/src/net/loginhandler.cpp
+++ b/src/net/loginhandler.cpp
@@ -41,13 +41,13 @@ LoginHandler::LoginHandler()
handledMessages = _messages;
}
-void LoginHandler::handleMessage(MessageIn *msg)
+void LoginHandler::handleMessage(MessageIn &msg)
{
- switch (msg->getId())
+ switch (msg.getId())
{
case APMSG_LOGIN_RESPONSE:
{
- int errMsg = msg->readByte();
+ int errMsg = msg.readByte();
// Successful login
if (errMsg == ERRMSG_OK)
{
@@ -79,7 +79,7 @@ void LoginHandler::handleMessage(MessageIn *msg)
break;
case APMSG_REGISTER_RESPONSE:
{
- int errMsg = msg->readByte();
+ int errMsg = msg.readByte();
// Successful registration
if (errMsg == ERRMSG_OK)
{
diff --git a/src/net/loginhandler.h b/src/net/loginhandler.h
index 1b15b736..508ec0f5 100644
--- a/src/net/loginhandler.h
+++ b/src/net/loginhandler.h
@@ -36,7 +36,7 @@ class LoginHandler : public MessageHandler
public:
LoginHandler();
- void handleMessage(MessageIn *msg);
+ void handleMessage(MessageIn &msg);
void setLoginData(LoginData *loginData) { mLoginData = loginData; };
diff --git a/src/net/maploginhandler.cpp b/src/net/maploginhandler.cpp
index 579e8542..323e07fb 100644
--- a/src/net/maploginhandler.cpp
+++ b/src/net/maploginhandler.cpp
@@ -40,14 +40,14 @@ MapLoginHandler::MapLoginHandler()
handledMessages = _messages;
}
-void MapLoginHandler::handleMessage(MessageIn *msg)
+void MapLoginHandler::handleMessage(MessageIn &msg)
{
//unsigned char direction;
- switch (msg->getId())
+ switch (msg.getId())
{
case SMSG_LOGIN_SUCCESS:
- msg->readLong(); // server tick
+ msg.readLong(); // server tick
//logger->log("Protocol: Player start position: (%d, %d), Direction: %d",
// player_node->mX, player_node->mY, direction);
state = STATE_GAME;
diff --git a/src/net/maploginhandler.h b/src/net/maploginhandler.h
index fe597549..3f779753 100644
--- a/src/net/maploginhandler.h
+++ b/src/net/maploginhandler.h
@@ -31,7 +31,7 @@ class MapLoginHandler : public MessageHandler
public:
MapLoginHandler();
- void handleMessage(MessageIn *msg);
+ void handleMessage(MessageIn &msg);
};
#endif
diff --git a/src/net/messagehandler.h b/src/net/messagehandler.h
index c09037f6..9f92636d 100644
--- a/src/net/messagehandler.h
+++ b/src/net/messagehandler.h
@@ -37,7 +37,7 @@ class MessageHandler
MessageHandler();
virtual ~MessageHandler();
- virtual void handleMessage(MessageIn *msg) =0;
+ virtual void handleMessage(MessageIn &msg) = 0;
void setNetwork(Network *network);
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index 7e85a813..23ea8181 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -27,8 +27,6 @@
#include <enet/enet.h>
-#include "packet.h"
-
MessageIn::MessageIn(const char *data, unsigned int length):
mData(data),
mLength(length),
diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp
index 426a1c0d..4fca662a 100644
--- a/src/net/messageout.cpp
+++ b/src/net/messageout.cpp
@@ -27,8 +27,6 @@
#include <enet/enet.h>
-#include "packet.h"
-
MessageOut::MessageOut():
mData(0),
mDataSize(0),
diff --git a/src/net/network.cpp b/src/net/network.cpp
index 2ce6fc2b..08b5fe92 100644
--- a/src/net/network.cpp
+++ b/src/net/network.cpp
@@ -160,7 +160,7 @@ Network::dispatchMessage(ENetPacket *packet)
if (iter != mMessageHandlers.end()) {
logger->log("Received packet %x (%i B)",
msg.getId(), msg.getLength());
- iter->second->handleMessage(&msg);
+ iter->second->handleMessage(msg);
}
else {
logger->log("Unhandled packet %x (%i B)",
diff --git a/src/net/npchandler.cpp b/src/net/npchandler.cpp
index 62355180..9c89e71f 100644
--- a/src/net/npchandler.cpp
+++ b/src/net/npchandler.cpp
@@ -47,21 +47,23 @@ NPCHandler::NPCHandler()
handledMessages = _messages;
}
-void NPCHandler::handleMessage(MessageIn *msg)
+void NPCHandler::handleMessage(MessageIn &msg)
{
- switch (msg->getId())
+ switch (msg.getId())
{
case SMSG_NPC_CHOICE:
- msg->readShort(); // length
- current_npc = dynamic_cast<NPC*>(beingManager->findBeing(msg->readLong()));
- npcListDialog->parseItems(msg->readString(msg->getLength() - 8));
+ msg.readShort(); // length
+ current_npc = dynamic_cast<NPC*>(
+ beingManager->findBeing(msg.readLong()));
+ npcListDialog->parseItems(msg.readString(msg.getLength() - 8));
npcListDialog->setVisible(true);
break;
case SMSG_NPC_MESSAGE:
- msg->readShort(); // length
- current_npc = dynamic_cast<NPC*>(beingManager->findBeing(msg->readLong()));
- npcTextDialog->addText(msg->readString(msg->getLength() - 8));
+ msg.readShort(); // length
+ current_npc = dynamic_cast<NPC*>(
+ beingManager->findBeing(msg.readLong()));
+ npcTextDialog->addText(msg.readString(msg.getLength() - 8));
npcListDialog->setVisible(false);
npcTextDialog->setVisible(true);
break;
diff --git a/src/net/npchandler.h b/src/net/npchandler.h
index 903ecd10..0cb40f64 100644
--- a/src/net/npchandler.h
+++ b/src/net/npchandler.h
@@ -31,7 +31,7 @@ class NPCHandler : public MessageHandler
public:
NPCHandler();
- void handleMessage(MessageIn *msg);
+ void handleMessage(MessageIn &msg);
};
#endif
diff --git a/src/net/packet.cpp b/src/net/packet.cpp
deleted file mode 100644
index e77ac117..00000000
--- a/src/net/packet.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * The Mana World
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World 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.
- *
- * The Mana World 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 The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#include "packet.h"
-
-#include <cstring>
-
-Packet::Packet(const char *data, int length):
- mLength(length)
-{
- // Create a copy of the data
- mData = new char[mLength];
- memcpy(mData, data, mLength);
-}
-
-Packet::~Packet()
-{
- // Clean up the data
- delete[] mData;
-}
diff --git a/src/net/packet.h b/src/net/packet.h
deleted file mode 100644
index 84d16d5e..00000000
--- a/src/net/packet.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * The Mana World
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World 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.
- *
- * The Mana World 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 The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#ifndef _TMW_PACKET_
-#define _TMW_PACKET_
-
-/**
- * A packet wraps a certain amount of bytes for sending and receiving.
- */
-class Packet
-{
- public:
- /**
- * Constructor.
- */
- Packet(const char *data, int length);
-
- /**
- * Destructor.
- */
- ~Packet();
-
- char *mData; /**< Packet data */
- unsigned int mLength; /**< Length of data in bytes */
-};
-
-#endif
diff --git a/src/net/playerhandler.cpp b/src/net/playerhandler.cpp
index d8ff81f4..f6065aaf 100644
--- a/src/net/playerhandler.cpp
+++ b/src/net/playerhandler.cpp
@@ -46,7 +46,9 @@ OkDialog *deathNotice = NULL;
namespace {
struct WeightListener : public gcn::ActionListener
{
- void action(const std::string &eventId, gcn::Widget *widget) { weightNotice = NULL; }
+ void action(const std::string &eventId, gcn::Widget *widget) {
+ weightNotice = NULL;
+ }
} weightListener;
}
@@ -80,9 +82,9 @@ PlayerHandler::PlayerHandler()
handledMessages = _messages;
}
-void PlayerHandler::handleMessage(MessageIn *msg)
+void PlayerHandler::handleMessage(MessageIn &msg)
{
- switch (msg->getId())
+ switch (msg.getId())
{
case SMSG_WALK_RESPONSE:
// It is assumed by the client any request to walk actually
@@ -93,9 +95,9 @@ void PlayerHandler::handleMessage(MessageIn *msg)
case SMSG_PLAYER_WARP:
{
- std::string mapPath = msg->readString(16);
- Uint16 x = msg->readShort();
- Uint16 y = msg->readShort();
+ std::string mapPath = msg.readString(16);
+ Uint16 x = msg.readShort();
+ Uint16 y = msg.readShort();
logger->log("Warping to %s (%d, %d)", mapPath.c_str(), x, y);
@@ -114,13 +116,13 @@ void PlayerHandler::handleMessage(MessageIn *msg)
case SMSG_PLAYER_STAT_UPDATE_1:
{
- Sint16 type = msg->readShort();
- Uint32 value = msg->readLong();
+ Sint16 type = msg.readShort();
+ Uint32 value = msg.readLong();
switch (type)
{
//case 0x0000:
- // player_node->setWalkSpeed(msg->readLong());
+ // player_node->setWalkSpeed(msg.readLong());
// break;
case 0x0005: player_node->mHp = value; break;
case 0x0006: player_node->mMaxHp = value; break;
@@ -169,30 +171,30 @@ void PlayerHandler::handleMessage(MessageIn *msg)
break;
case SMSG_PLAYER_STAT_UPDATE_2:
- switch (msg->readShort()) {
+ switch (msg.readShort()) {
case 0x0001:
- player_node->mXp = msg->readLong();
+ player_node->mXp = msg.readLong();
break;
case 0x0002:
- player_node->mJobXp = msg->readLong();
+ player_node->mJobXp = msg.readLong();
break;
case 0x0014:
- player_node->mMoney = msg->readLong();
+ player_node->mMoney = msg.readLong();
break;
case 0x0016:
- player_node->mXpForNextLevel = msg->readLong();
+ player_node->mXpForNextLevel = msg.readLong();
break;
case 0x0017:
- player_node->mJobXpForNextLevel = msg->readLong();
+ player_node->mJobXpForNextLevel = msg.readLong();
break;
}
break;
case SMSG_PLAYER_STAT_UPDATE_3:
{
- Sint32 type = msg->readLong();
- Sint32 base = msg->readLong();
- Sint32 bonus = msg->readLong();
+ Sint32 type = msg.readLong();
+ Sint32 base = msg.readLong();
+ Sint32 bonus = msg.readLong();
Sint32 total = base + bonus;
switch (type) {
@@ -214,9 +216,9 @@ void PlayerHandler::handleMessage(MessageIn *msg)
case SMSG_PLAYER_STAT_UPDATE_4:
{
- Sint16 type = msg->readShort();
- Sint8 fail = msg->readByte();
- Sint8 value = msg->readByte();
+ Sint16 type = msg.readShort();
+ Sint8 fail = msg.readByte();
+ Sint8 value = msg.readByte();
if (fail != 1)
break;
@@ -240,60 +242,60 @@ void PlayerHandler::handleMessage(MessageIn *msg)
// Updates stats and status points
case SMSG_PLAYER_STAT_UPDATE_5:
- player_node->mStatsPointsToAttribute = msg->readShort();
- player_node->mAttr[LocalPlayer::STR] = msg->readByte();
- player_node->mAttrUp[LocalPlayer::STR] = msg->readByte();
- player_node->mAttr[LocalPlayer::AGI] = msg->readByte();
- player_node->mAttrUp[LocalPlayer::AGI] = msg->readByte();
- player_node->mAttr[LocalPlayer::VIT] = msg->readByte();
- player_node->mAttrUp[LocalPlayer::VIT] = msg->readByte();
- player_node->mAttr[LocalPlayer::INT] = msg->readByte();
- player_node->mAttrUp[LocalPlayer::INT] = msg->readByte();
- player_node->mAttr[LocalPlayer::DEX] = msg->readByte();
- player_node->mAttrUp[LocalPlayer::DEX] = msg->readByte();
- player_node->mAttr[LocalPlayer::LUK] = msg->readByte();
- player_node->mAttrUp[LocalPlayer::LUK] = msg->readByte();
- player_node->ATK = msg->readShort(); // ATK
- player_node->ATK_BONUS = msg->readShort(); // ATK bonus
- player_node->MATK = msg->readShort(); // MATK max
- player_node->MATK_BONUS = msg->readShort(); // MATK min
- player_node->DEF = msg->readShort(); // DEF
- player_node->DEF_BONUS = msg->readShort(); // DEF bonus
- player_node->MDEF = msg->readShort(); // MDEF
- player_node->MDEF_BONUS = msg->readShort(); // MDEF bonus
- player_node->HIT = msg->readShort(); // HIT
- player_node->FLEE = msg->readShort(); // FLEE
- player_node->FLEE_BONUS = msg->readShort(); // FLEE bonus
- msg->readShort(); // critical
- msg->readShort(); // unknown
+ player_node->mStatsPointsToAttribute = msg.readShort();
+ player_node->mAttr[LocalPlayer::STR] = msg.readByte();
+ player_node->mAttrUp[LocalPlayer::STR] = msg.readByte();
+ player_node->mAttr[LocalPlayer::AGI] = msg.readByte();
+ player_node->mAttrUp[LocalPlayer::AGI] = msg.readByte();
+ player_node->mAttr[LocalPlayer::VIT] = msg.readByte();
+ player_node->mAttrUp[LocalPlayer::VIT] = msg.readByte();
+ player_node->mAttr[LocalPlayer::INT] = msg.readByte();
+ player_node->mAttrUp[LocalPlayer::INT] = msg.readByte();
+ player_node->mAttr[LocalPlayer::DEX] = msg.readByte();
+ player_node->mAttrUp[LocalPlayer::DEX] = msg.readByte();
+ player_node->mAttr[LocalPlayer::LUK] = msg.readByte();
+ player_node->mAttrUp[LocalPlayer::LUK] = msg.readByte();
+ player_node->ATK = msg.readShort(); // ATK
+ player_node->ATK_BONUS = msg.readShort(); // ATK bonus
+ player_node->MATK = msg.readShort(); // MATK max
+ player_node->MATK_BONUS = msg.readShort(); // MATK min
+ player_node->DEF = msg.readShort(); // DEF
+ player_node->DEF_BONUS = msg.readShort(); // DEF bonus
+ player_node->MDEF = msg.readShort(); // MDEF
+ player_node->MDEF_BONUS = msg.readShort(); // MDEF bonus
+ player_node->HIT = msg.readShort(); // HIT
+ player_node->FLEE = msg.readShort(); // FLEE
+ player_node->FLEE_BONUS = msg.readShort(); // FLEE bonus
+ msg.readShort(); // critical
+ msg.readShort(); // unknown
break;
case SMSG_PLAYER_STAT_UPDATE_6:
- switch (msg->readShort()) {
+ switch (msg.readShort()) {
case 0x0020:
- player_node->mAttrUp[LocalPlayer::STR] = msg->readByte();
+ player_node->mAttrUp[LocalPlayer::STR] = msg.readByte();
break;
case 0x0021:
- player_node->mAttrUp[LocalPlayer::AGI] = msg->readByte();
+ player_node->mAttrUp[LocalPlayer::AGI] = msg.readByte();
break;
case 0x0022:
- player_node->mAttrUp[LocalPlayer::VIT] = msg->readByte();
+ player_node->mAttrUp[LocalPlayer::VIT] = msg.readByte();
break;
case 0x0023:
- player_node->mAttrUp[LocalPlayer::INT] = msg->readByte();
+ player_node->mAttrUp[LocalPlayer::INT] = msg.readByte();
break;
case 0x0024:
- player_node->mAttrUp[LocalPlayer::DEX] = msg->readByte();
+ player_node->mAttrUp[LocalPlayer::DEX] = msg.readByte();
break;
case 0x0025:
- player_node->mAttrUp[LocalPlayer::LUK] = msg->readByte();
+ player_node->mAttrUp[LocalPlayer::LUK] = msg.readByte();
break;
}
break;
case SMSG_PLAYER_ARROW_MESSAGE:
{
- Sint16 type = msg->readShort();
+ Sint16 type = msg.readShort();
switch (type) {
case 0:
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
index b28a23f5..6d0baef7 100644
--- a/src/net/playerhandler.h
+++ b/src/net/playerhandler.h
@@ -31,7 +31,7 @@ class PlayerHandler : public MessageHandler
public:
PlayerHandler();
- void handleMessage(MessageIn *msg);
+ void handleMessage(MessageIn &msg);
};
#endif
diff --git a/src/net/skillhandler.cpp b/src/net/skillhandler.cpp
index 89009e47..d9bea775 100644
--- a/src/net/skillhandler.cpp
+++ b/src/net/skillhandler.cpp
@@ -39,27 +39,27 @@ SkillHandler::SkillHandler()
handledMessages = _messages;
}
-void SkillHandler::handleMessage(MessageIn *msg)
+void SkillHandler::handleMessage(MessageIn &msg)
{
int skillCount;
- switch (msg->getId())
+ switch (msg.getId())
{
case SMSG_PLAYER_SKILLS:
- msg->readShort(); // length
- skillCount = (msg->getLength() - 4) / 37;
+ msg.readShort(); // length
+ skillCount = (msg.getLength() - 4) / 37;
skillDialog->cleanList();
for (int k = 0; k < skillCount; k++)
{
- Sint16 skillId = msg->readShort();
- msg->readShort(); // target type
- msg->readShort(); // unknown
- Sint16 level = msg->readShort();
- Sint16 sp = msg->readShort();
- msg->readShort(); // range
- std::string skillName = msg->readString(24);
- Sint8 up = msg->readByte();
+ Sint16 skillId = msg.readShort();
+ msg.readShort(); // target type
+ msg.readShort(); // unknown
+ Sint16 level = msg.readShort();
+ Sint16 sp = msg.readShort();
+ msg.readShort(); // range
+ std::string skillName = msg.readString(24);
+ Sint8 up = msg.readByte();
if (level != 0 || up != 0)
{
@@ -77,11 +77,11 @@ void SkillHandler::handleMessage(MessageIn *msg)
// Action failed (ex. sit because you have not reached the
// right level)
CHATSKILL action;
- action.skill = msg->readShort();
- action.bskill = msg->readShort();
- action.unused = msg->readShort(); // unknown
- action.success = msg->readByte();
- action.reason = msg->readByte();
+ action.skill = msg.readShort();
+ action.bskill = msg.readShort();
+ action.unused = msg.readShort(); // unknown
+ action.success = msg.readByte();
+ action.reason = msg.readByte();
if (action.success != SKILL_FAILED &&
action.bskill == BSKILL_EMOTE)
{
diff --git a/src/net/skillhandler.h b/src/net/skillhandler.h
index 820a7b6a..8c0653d4 100644
--- a/src/net/skillhandler.h
+++ b/src/net/skillhandler.h
@@ -31,7 +31,7 @@ class SkillHandler : public MessageHandler
public:
SkillHandler();
- void handleMessage(MessageIn *msg);
+ void handleMessage(MessageIn &msg);
};
#endif
diff --git a/src/net/tradehandler.cpp b/src/net/tradehandler.cpp
index b0baa5ea..2ebc160f 100644
--- a/src/net/tradehandler.cpp
+++ b/src/net/tradehandler.cpp
@@ -63,9 +63,9 @@ TradeHandler::TradeHandler()
handledMessages = _messages;
}
-void TradeHandler::handleMessage(MessageIn *msg)
+void TradeHandler::handleMessage(MessageIn &msg)
{
- switch (msg->getId())
+ switch (msg.getId())
{
case SMSG_TRADE_REQUEST:
// If a trade window or request window is already open, send a
@@ -81,7 +81,7 @@ void TradeHandler::handleMessage(MessageIn *msg)
}
player_node->setTrading(true);
- tradePartnerName = msg->readString(24);
+ tradePartnerName = msg.readString(24);
ConfirmDialog *dlg;
dlg = new ConfirmDialog("Request for trade",
tradePartnerName +
@@ -90,7 +90,7 @@ void TradeHandler::handleMessage(MessageIn *msg)
break;
case SMSG_TRADE_RESPONSE:
- switch (msg->readByte())
+ switch (msg.readByte())
{
case 0: // Too far away
chatWindow->chatLog("Trading isn't possible. "
@@ -126,11 +126,11 @@ void TradeHandler::handleMessage(MessageIn *msg)
case SMSG_TRADE_ITEM_ADD:
{
- Sint32 amount = msg->readLong();
- Sint16 type = msg->readShort();
- msg->readByte(); // identified flag
- msg->readByte(); // attribute
- msg->readByte(); // refine
+ Sint32 amount = msg.readLong();
+ Sint16 type = msg.readShort();
+ msg.readByte(); // identified flag
+ msg.readByte(); // attribute
+ msg.readByte(); // refine
// TODO: handle also identified, etc
if (type == 0) {
@@ -144,10 +144,10 @@ void TradeHandler::handleMessage(MessageIn *msg)
case SMSG_TRADE_ITEM_ADD_RESPONSE:
// Trade: New Item add response (was 0x00ea, now 01b1)
{
- Item *item = player_node->getInvItem(msg->readShort());
- Sint16 quantity = msg->readShort();
+ Item *item = player_node->getInvItem(msg.readShort());
+ Sint16 quantity = msg.readShort();
- switch (msg->readByte())
+ switch (msg.readByte())
{
case 0:
// Successfully added item
@@ -175,7 +175,7 @@ void TradeHandler::handleMessage(MessageIn *msg)
case SMSG_TRADE_OK:
// 0 means ok from myself, 1 means ok from other;
- tradeWindow->receivedOk(msg->readByte() == 0);
+ tradeWindow->receivedOk(msg.readByte() == 0);
break;
case SMSG_TRADE_CANCEL:
diff --git a/src/net/tradehandler.h b/src/net/tradehandler.h
index a1971004..0b73c871 100644
--- a/src/net/tradehandler.h
+++ b/src/net/tradehandler.h
@@ -33,7 +33,7 @@ class TradeHandler : public MessageHandler
public:
TradeHandler();
- void handleMessage(MessageIn *msg);
+ void handleMessage(MessageIn &msg);
};
#endif