summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2005-10-16 21:18:11 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2005-10-16 21:18:11 +0000
commitd3175115354bb2417f01877a96d0068e2f2c875d (patch)
tree3fe6dde2b7922eb12bc376687ae18a59971d908e
parent43a80fa64acb7f02cf5305b4a3d2ef6040b4b8c9 (diff)
downloadmana-d3175115354bb2417f01877a96d0068e2f2c875d.tar.gz
mana-d3175115354bb2417f01877a96d0068e2f2c875d.tar.bz2
mana-d3175115354bb2417f01877a96d0068e2f2c875d.tar.xz
mana-d3175115354bb2417f01877a96d0068e2f2c875d.zip
Rename {read,write}{Byte,Short,Long} to {read,write}Int{8,16,32}.
-rw-r--r--ChangeLog9
-rw-r--r--src/being.cpp4
-rw-r--r--src/game.cpp476
-rw-r--r--src/gui/buy.cpp8
-rw-r--r--src/gui/buysell.cpp6
-rw-r--r--src/gui/char_select.cpp102
-rw-r--r--src/gui/char_server.cpp78
-rw-r--r--src/gui/chat.cpp4
-rw-r--r--src/gui/connection.cpp16
-rw-r--r--src/gui/login.cpp22
-rw-r--r--src/gui/npc.cpp6
-rw-r--r--src/gui/npc_text.cpp4
-rw-r--r--src/gui/popupmenu.cpp14
-rw-r--r--src/gui/requesttrade.cpp8
-rw-r--r--src/gui/sell.cpp8
-rw-r--r--src/gui/skill.cpp4
-rw-r--r--src/gui/status.cpp16
-rw-r--r--src/gui/trade.cpp18
-rw-r--r--src/inventory.cpp22
-rw-r--r--src/net/messagein.cpp48
-rw-r--r--src/net/messagein.h21
-rw-r--r--src/net/messageout.cpp49
-rw-r--r--src/net/messageout.h13
-rw-r--r--src/net/protocol.cpp8
24 files changed, 484 insertions, 480 deletions
diff --git a/ChangeLog b/ChangeLog
index bbc94944..26384cc5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,15 @@
2005-10-16 Björn Steinbrink <B.Steinbrink@gmx.de>
+ * src/being.cpp, src/game.cpp, src/inventory.cpp, src/gui/buy.cpp,
+ src/gui/buysell.cpp, src/gui/char_select.cpp, src/gui/char_server.cpp,
+ src/gui/chat.cpp, src/gui/connection.cpp, src/gui/login.cpp,
+ src/gui/npc.cpp, src/gui/npc_text.cpp, src/gui/popupmenu.cpp,
+ src/gui/requesttrade.cpp, src/gui/sell.cpp, src/gui/skill.cpp,
+ src/gui/status.cpp, src/gui/trade.cpp, src/net/messagein.cpp,
+ src/net/messagein.h, src/net/messageout.cpp, src/net/messageout.h,
+ src/net/protocol.cpp: Rename {read,write}{Byte,Short,Long} to
+ {read,write}Int{8,16,32}.
* src/being.cpp, src/engine.cpp, src/engine.h, src/game.cpp,
src/main.cpp, src/gui/equipmentwindow.cpp, src/gui/itemcontainer.cpp,
src/resources/resourcemanager.cpp, src/resources/resourcemanager.h:
diff --git a/src/being.cpp b/src/being.cpp
index 42b2c2f5..6b26afad 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -95,8 +95,8 @@ Being* createBeing(Uint32 id, Uint16 job, Map *map)
if (being->getType() == Being::PLAYER)
{
MessageOut outMsg;
- outMsg.writeShort(0x0094);
- outMsg.writeLong(being->getId());//readLong(2));
+ outMsg.writeInt16(0x0094);
+ outMsg.writeInt32(being->getId());//readLong(2));
}
// If the being is a monster then load the monsterset
else if (being->job >= 1002 &&
diff --git a/src/game.cpp b/src/game.cpp
index 35196e4a..9e437d2b 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -141,8 +141,8 @@ class DeathNoticeListener : public gcn::ActionListener {
public:
void action(const std::string &eventId) {
MessageOut outMsg;
- outMsg.writeShort(0x00b2);
- outMsg.writeByte(0);
+ outMsg.writeInt16(0x00b2);
+ outMsg.writeInt8(0);
deathNotice = NULL;
}
} deathNoticeListener;
@@ -573,8 +573,8 @@ void do_input()
// TODO: Remove duplicated code, probably add a
// pick up command
MessageOut outMsg;
- outMsg.writeShort(0x009f);
- outMsg.writeLong(id);
+ outMsg.writeInt16(0x009f);
+ outMsg.writeInt32(id);
}
used = true;
}
@@ -669,8 +669,8 @@ void do_input()
if (emotion)
{
MessageOut outMsg;
- outMsg.writeShort(0x00bf);
- outMsg.writeByte(emotion);
+ outMsg.writeInt16(0x00bf);
+ outMsg.writeInt8(emotion);
action_time = false;
used = true;
}
@@ -708,9 +708,9 @@ void do_input()
if (!current_npc)
{
MessageOut outMsg;
- outMsg.writeShort(CMSG_NPC_TALK);
- outMsg.writeLong(target->getId());
- outMsg.writeByte(0);
+ outMsg.writeInt16(CMSG_NPC_TALK);
+ outMsg.writeInt32(target->getId());
+ outMsg.writeInt8(0);
current_npc = target->getId();
}
break;
@@ -752,8 +752,8 @@ void do_input()
if ((dx*dx + dy*dy) < 4)
{
MessageOut outMsg;
- outMsg.writeShort(0x009f);
- outMsg.writeLong(floorItemId);
+ outMsg.writeInt16(0x009f);
+ outMsg.writeInt32(floorItemId);
}
}
@@ -948,8 +948,8 @@ void do_input()
if (id != 0)
{
MessageOut outMsg;
- outMsg.writeShort(CMSG_ITEM_PICKUP);
- outMsg.writeLong(id);
+ outMsg.writeInt16(CMSG_ITEM_PICKUP);
+ outMsg.writeInt32(id);
}
}
else if (joy[JOY_BTN2] && action_time)
@@ -981,7 +981,7 @@ void do_parse()
{
case SMSG_LOGIN_SUCCESS:
// Connected to game server succesfully, set spawn point
- msg.readLong(); // server tick
+ msg.readInt32(); // server tick
msg.readCoordinates(player_node->x, player_node->y,
player_node->direction);
msg.skip(2); // unknown
@@ -990,8 +990,8 @@ void do_parse()
// Received speech from being
case SMSG_BEING_CHAT:
{
- Sint16 chatMsgLength = msg.readShort() - 8;
- being = findNode(msg.readLong());
+ Sint16 chatMsgLength = msg.readInt16() - 8;
+ being = findNode(msg.readInt32());
if (!being || chatMsgLength <= 0)
{
@@ -1010,7 +1010,7 @@ void do_parse()
case SMSG_PLAYER_CHAT:
case SMSG_GM_CHAT:
{
- Sint16 chatMsgLength = msg.readShort() - 4;
+ Sint16 chatMsgLength = msg.readInt16() - 4;
if (chatMsgLength <= 0)
{
@@ -1048,12 +1048,12 @@ void do_parse()
case SMSG_BEING_MOVE:
// Information about a being in range
{
- Uint32 id = msg.readLong();
- Uint16 speed = msg.readShort();
- msg.readShort(); // unknown
- msg.readShort(); // unknown
- msg.readShort(); // option
- Uint16 job = msg.readShort(); // class
+ Uint32 id = msg.readInt32();
+ Uint16 speed = msg.readInt16();
+ msg.readInt16(); // unknown
+ msg.readInt16(); // unknown
+ msg.readInt16(); // option
+ Uint16 job = msg.readInt16(); // class
being = findNode(id);
@@ -1081,28 +1081,28 @@ void do_parse()
being->setWalkSpeed(speed);
being->job = job;
- being->setHairStyle(msg.readShort());
- being->setWeapon(msg.readShort());
- msg.readShort(); // head option bottom
+ being->setHairStyle(msg.readInt16());
+ being->setWeapon(msg.readInt16());
+ msg.readInt16(); // head option bottom
if (msg.getId() == SMSG_BEING_MOVE)
{
- msg.readLong(); // server tick
+ msg.readInt32(); // server tick
}
- msg.readShort(); // shield
- msg.readShort(); // head option top
- msg.readShort(); // head option mid
- being->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
- msg.readByte(); // sex
+ msg.readInt16(); // shield
+ msg.readInt16(); // head option top
+ msg.readInt16(); // head option mid
+ being->setHairColor(msg.readInt16());
+ msg.readInt16(); // unknown
+ msg.readInt16(); // head dir
+ msg.readInt16(); // guild
+ msg.readInt16(); // unknown
+ msg.readInt16(); // unknown
+ msg.readInt16(); // manner
+ msg.readInt16(); // karma
+ msg.readInt8(); // unknown
+ msg.readInt8(); // sex
if (msg.getId() == SMSG_BEING_MOVE)
{
@@ -1119,19 +1119,19 @@ void do_parse()
being->direction);
}
- msg.readByte(); // unknown
- msg.readByte(); // unknown
- msg.readByte(); // unknown / sit
+ msg.readInt8(); // unknown
+ msg.readInt8(); // unknown
+ msg.readInt8(); // unknown / sit
}
break;
case SMSG_BEING_REMOVE:
// A being should be removed or has died
- being = findNode(msg.readLong());
+ being = findNode(msg.readInt32());
if (being != NULL)
{
- if (msg.readByte() == 1)
+ if (msg.readInt8() == 1)
{
// Death
switch (being->getType())
@@ -1164,12 +1164,12 @@ void do_parse()
case SMSG_PLAYER_MOVE:
// An update about a player, potentially including movement.
{
- Uint32 id = msg.readLong();
- Uint16 speed = msg.readShort();
- msg.readShort(); // option 1
- msg.readShort(); // option 2
- msg.readShort(); // option
- Uint16 job = msg.readShort();
+ Uint32 id = msg.readInt32();
+ Uint16 speed = msg.readInt16();
+ msg.readInt16(); // option 1
+ msg.readInt16(); // option 2
+ msg.readInt16(); // option
+ Uint16 job = msg.readInt16();
being = findNode(id);
@@ -1180,26 +1180,26 @@ void do_parse()
being->setWalkSpeed(speed);
being->job = job;
- being->setHairStyle(msg.readShort());
- being->setWeaponById(msg.readShort()); // item id 1
- msg.readShort(); // item id 2
- msg.readShort(); // head option bottom
+ being->setHairStyle(msg.readInt16());
+ being->setWeaponById(msg.readInt16()); // item id 1
+ msg.readInt16(); // item id 2
+ msg.readInt16(); // head option bottom
if (msg.getId() == SMSG_PLAYER_MOVE)
{
- msg.readLong(); // server tick
+ msg.readInt32(); // server tick
}
- msg.readShort(); // head option top
- msg.readShort(); // head option mid
- being->setHairColor(msg.readShort());
- msg.readShort(); // unknown
- msg.readShort(); // head dir
- msg.readLong(); // guild
- msg.readLong(); // emblem
- msg.readShort(); // manner
- msg.readByte(); // karma
- msg.readByte(); // sex
+ msg.readInt16(); // head option top
+ msg.readInt16(); // head option mid
+ being->setHairColor(msg.readInt16());
+ msg.readInt16(); // unknown
+ msg.readInt16(); // head dir
+ msg.readInt32(); // guild
+ msg.readInt32(); // emblem
+ msg.readInt16(); // manner
+ msg.readInt8(); // karma
+ msg.readInt8(); // sex
if (msg.getId() == SMSG_PLAYER_MOVE)
{
@@ -1215,23 +1215,23 @@ void do_parse()
being->direction);
}
- msg.readByte(); // unknown
- msg.readByte(); // unknown
+ msg.readInt8(); // unknown
+ msg.readInt8(); // unknown
if (msg.getId() == SMSG_PLAYER_UPDATE_1)
{
- if (msg.readByte() == 2)
+ if (msg.readInt8() == 2)
{
being->action = Being::SIT;
}
}
else if (msg.getId() == SMSG_PLAYER_MOVE)
{
- msg.readByte(); // unknown
+ msg.readInt8(); // unknown
}
- msg.readByte(); // Lv
- msg.readByte(); // unknown
+ msg.readInt8(); // Lv
+ msg.readInt8(); // unknown
being->walk_time = tick_time;
being->mFrame = 0;
@@ -1239,8 +1239,8 @@ void do_parse()
break;
case SMSG_NPC_MESSAGE:
- msg.readShort(); // length
- current_npc = msg.readLong();
+ msg.readInt16(); // length
+ current_npc = msg.readInt32();
npcTextDialog->addText(msg.readString(msg.getLength() - 8));
npcListDialog->setVisible(false);
npcTextDialog->setVisible(true);
@@ -1262,8 +1262,8 @@ void do_parse()
if (tradeWindow->isVisible() || requestTradeDialogOpen)
{
MessageOut outMsg;
- outMsg.writeShort(CMSG_TRADE_RESPONSE);
- outMsg.writeByte(4);
+ outMsg.writeInt16(CMSG_TRADE_RESPONSE);
+ outMsg.writeInt8(4);
break;
}
@@ -1273,7 +1273,7 @@ void do_parse()
break;
case SMSG_TRADE_RESPONSE:
- switch (msg.readByte())
+ switch (msg.readInt8())
{
case 0: // Too far away
chatWindow->chat_log("Trading isn't possible. "
@@ -1309,11 +1309,11 @@ void do_parse()
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.readInt32();
+ Sint16 type = msg.readInt16();
+ msg.readInt8(); // identified flag
+ msg.readInt8(); // attribute
+ msg.readInt8(); // refine
msg.skip(8); // card (4 shorts)
// TODO: handle also identified, etc
@@ -1328,10 +1328,10 @@ void do_parse()
case SMSG_TRADE_ITEM_ADD_RESPONSE:
// Trade: New Item add response (was 0x00ea, now 01b1)
{
- Item *item = inventory->getItem(msg.readShort());
- Sint16 quantity = msg.readShort();
+ Item *item = inventory->getItem(msg.readInt16());
+ Sint16 quantity = msg.readInt16();
- switch (msg.readByte())
+ switch (msg.readInt8())
{
case 0:
// Successfully added item
@@ -1359,7 +1359,7 @@ void do_parse()
case SMSG_TRADE_OK:
// 0 means ok from myself, 1 means ok from other;
- tradeWindow->receivedOk(msg.readByte() == 0);
+ tradeWindow->receivedOk(msg.readInt8() == 0);
break;
case SMSG_TRADE_CANCEL:
@@ -1379,16 +1379,16 @@ void do_parse()
// Only called on map load / warp. First reset all items
// to not load them twice on map change.
inventory->resetItems();
- msg.readShort(); // length
+ msg.readInt16(); // length
Sint32 number = (msg.getLength() - 4) / 18;
for (int loop = 0; loop < number; loop++)
{
- Sint16 index = msg.readShort();
- Sint16 itemId = msg.readShort();
- msg.readByte(); // type
- msg.readByte(); // identify flag
- Sint16 amount = msg.readShort();
+ Sint16 index = msg.readInt16();
+ Sint16 itemId = msg.readInt16();
+ msg.readInt8(); // type
+ msg.readInt8(); // identify flag
+ Sint16 amount = msg.readInt16();
msg.skip(2); // unknown
msg.skip(8); // card (4 shorts)
@@ -1405,19 +1405,19 @@ void do_parse()
case SMSG_PLAYER_EQUIPMENT:
{
- msg.readShort(); // length
+ msg.readInt16(); // length
Sint32 number = (msg.getLength() - 4) / 20;
for (int loop = 0; loop < number; loop++)
{
- Sint16 index = msg.readShort();
- Sint16 itemId = msg.readShort();
- msg.readByte(); // type
- msg.readByte(); // identify flag
- msg.readShort(); // equip type
- Sint16 equipPoint = msg.readShort();
- msg.readByte(); // attribute
- msg.readByte(); // refine
+ Sint16 index = msg.readInt16();
+ Sint16 itemId = msg.readInt16();
+ msg.readInt8(); // type
+ msg.readInt8(); // identify flag
+ msg.readInt16(); // equip type
+ Sint16 equipPoint = msg.readInt16();
+ msg.readInt8(); // attribute
+ msg.readInt8(); // refine
msg.skip(8); // card
inventory->addItem(index, itemId, 1, true);
@@ -1441,10 +1441,10 @@ void do_parse()
case SMSG_ITEM_USE_RESPONSE:
{
- Sint16 index = msg.readShort();
- Sint16 amount = msg.readShort();
+ Sint16 index = msg.readInt16();
+ Sint16 amount = msg.readInt16();
- if (msg.readByte() == 0) {
+ if (msg.readInt8() == 0) {
chatWindow->chat_log("Failed to use item", BY_SERVER);
} else {
inventory->getItem(index)->setQuantity(amount);
@@ -1459,8 +1459,8 @@ void do_parse()
map_path = map_path.substr(0, map_path.rfind(".")) +
".tmx.gz";
- Uint16 x = msg.readShort();
- Uint16 y = msg.readShort();
+ Uint16 x = msg.readInt16();
+ Uint16 y = msg.readInt16();
logger->log("Warping to %s (%d, %d)",
map_path.c_str(), x, y);
@@ -1479,7 +1479,7 @@ void do_parse()
// Send "map loaded"
MessageOut outMsg;
- outMsg.writeShort(CMSG_MAP_LOADED);
+ outMsg.writeInt16(CMSG_MAP_LOADED);
}
break;
@@ -1487,11 +1487,11 @@ void do_parse()
// 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.readInt16();
+ action.bskill = msg.readInt16();
+ action.unused = msg.readInt16(); // unknown
+ action.success = msg.readInt8();
+ action.reason = msg.readInt8();
if (action.success != SKILL_FAILED &&
action.bskill == BSKILL_EMOTE)
{
@@ -1502,13 +1502,13 @@ void do_parse()
case SMSG_PLAYER_STAT_UPDATE_1:
{
- Sint16 type = msg.readShort();
- Sint32 value = msg.readLong();
+ Sint16 type = msg.readInt16();
+ Sint32 value = msg.readInt32();
switch (type)
{
//case 0x0000:
- // player_node->setWalkSpeed(msg.readLong());
+ // player_node->setWalkSpeed(msg.readInt32());
// break;
case 0x0005: player_info->hp = value; break;
case 0x0006: player_info->maxHp = value; break;
@@ -1558,7 +1558,7 @@ void do_parse()
// Stop walking
// case 0x0088: // Disabled because giving some problems
- //if (being = findNode(readLong(2))) {
+ //if (being = findNode(readInt32(2))) {
// if (being->getId() != player_node->getId()) {
// being->action = STAND;
// being->mFrame = 0;
@@ -1571,15 +1571,15 @@ void do_parse()
case SMSG_BEING_ACTION:
{
- Being *srcBeing = findNode(msg.readLong());
- Being *dstBeing = findNode(msg.readLong());
- msg.readLong(); // server tick
- msg.readLong(); // src speed
- msg.readLong(); // dst speed
- Sint16 param1 = msg.readShort();
- msg.readShort(); // param 2
- Sint8 type = msg.readByte();
- msg.readShort(); // param 3
+ Being *srcBeing = findNode(msg.readInt32());
+ Being *dstBeing = findNode(msg.readInt32());
+ msg.readInt32(); // server tick
+ msg.readInt32(); // src speed
+ msg.readInt32(); // dst speed
+ Sint16 param1 = msg.readInt16();
+ msg.readInt16(); // param 2
+ Sint8 type = msg.readInt8();
+ msg.readInt16(); // param 3
switch (type)
{
@@ -1614,50 +1614,50 @@ void do_parse()
break;
case SMSG_PLAYER_STAT_UPDATE_2:
- switch (msg.readShort()) {
+ switch (msg.readInt16()) {
case 0x0001:
- player_info->xp = msg.readLong();
+ player_info->xp = msg.readInt32();
break;
case 0x0002:
- player_info->jobXp = msg.readLong();
+ player_info->jobXp = msg.readInt32();
break;
case 0x0014:
- player_info->gp = msg.readLong();
+ player_info->gp = msg.readInt32();
break;
case 0x0016:
- player_info->xpForNextLevel = msg.readLong();
+ player_info->xpForNextLevel = msg.readInt32();
break;
case 0x0017:
- player_info->jobXpForNextLevel = msg.readLong();
+ player_info->jobXpForNextLevel = msg.readInt32();
break;
}
break;
case SMSG_BEING_LEVELUP:
- if ((Uint32)msg.readLong() == player_node->getId()) {
+ if ((Uint32)msg.readInt32() == player_node->getId()) {
logger->log("Level up");
sound.playSfx("sfx/levelup.ogg");
} else {
logger->log("Someone else went level up");
}
- msg.readLong(); // type
+ msg.readInt32(); // type
break;
case SMSG_BEING_EMOTION:
- if (!(being = findNode(msg.readLong())))
+ if (!(being = findNode(msg.readInt32())))
{
break;
}
- being->emotion = msg.readByte();
+ being->emotion = msg.readInt8();
being->emotion_time = EMOTION_TIME;
break;
case SMSG_PLAYER_STAT_UPDATE_3:
{
- Sint32 type = msg.readLong();
- Sint32 base = msg.readLong();
- Sint32 bonus = msg.readLong();
+ Sint32 type = msg.readInt32();
+ Sint32 base = msg.readInt32();
+ Sint32 bonus = msg.readInt32();
Sint32 total = base + bonus;
switch (type) {
@@ -1677,11 +1677,11 @@ void do_parse()
sellDialog->setVisible(false);
sellDialog->reset();
buySellDialog->setVisible(true);
- current_npc = msg.readLong();
+ current_npc = msg.readInt32();
break;
case SMSG_NPC_BUY:
- msg.readShort(); // length
+ msg.readInt16(); // length
n_items = (msg.getLength() - 4) / 11;
buyDialog->reset();
buyDialog->setMoney(player_info->gp);
@@ -1689,16 +1689,16 @@ void do_parse()
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.readInt32();
+ msg.readInt32(); // DCvalue
+ msg.readInt8(); // type
+ Sint16 itemId = msg.readInt16();
buyDialog->addItem(itemId, value);
}
break;
case SMSG_NPC_SELL:
- msg.readShort(); // length
+ msg.readInt16(); // length
n_items = (msg.getLength() - 4) / 10;
if (n_items > 0) {
sellDialog->reset();
@@ -1706,9 +1706,9 @@ void do_parse()
for (int k = 0; k < n_items; k++)
{
- Sint16 index = msg.readShort();
- Sint32 value = msg.readLong();
- msg.readLong(); // OCvalue
+ Sint16 index = msg.readInt16();
+ Sint32 value = msg.readInt32();
+ msg.readInt32(); // OCvalue
Item *item = inventory->getItem(index);
if (item && !(item->isEquipped())) {
@@ -1723,7 +1723,7 @@ void do_parse()
break;
case SMSG_NPC_BUY_RESPONSE:
- if (msg.readByte() == 0) {
+ if (msg.readInt8() == 0) {
chatWindow->chat_log("Thanks for buying", BY_SERVER);
} else {
chatWindow->chat_log("Unable to buy", BY_SERVER);
@@ -1731,7 +1731,7 @@ void do_parse()
break;
case SMSG_NPC_SELL_RESPONSE:
- if (msg.readByte() == 0) {
+ if (msg.readInt8() == 0) {
chatWindow->chat_log("Thanks for selling", BY_SERVER);
} else {
chatWindow->chat_log("Unable to sell", BY_SERVER);
@@ -1740,16 +1740,16 @@ void do_parse()
case SMSG_PLAYER_INVENTORY_ADD:
{
- Sint16 index = msg.readShort();
- Sint16 amount = msg.readShort();
- Sint16 itemId = msg.readShort();
- msg.readByte(); // identify flag
- msg.readByte(); // attribute
- msg.readByte(); // refine
+ Sint16 index = msg.readInt16();
+ Sint16 amount = msg.readInt16();
+ Sint16 itemId = msg.readInt16();
+ msg.readInt8(); // identify flag
+ msg.readInt8(); // attribute
+ msg.readInt8(); // refine
msg.skip(8); // card
- Sint16 equipType = msg.readShort();
- msg.readByte(); // type
- Sint8 fail = msg.readByte();
+ Sint16 equipType = msg.readInt16();
+ msg.readInt8(); // type
+ Sint8 fail = msg.readInt8();
if (fail > 0) {
chatWindow->chat_log("Unable to pick up item",
@@ -1763,39 +1763,39 @@ void do_parse()
case SMSG_PLAYER_INVENTORY_REMOVE:
{
- Sint16 index = msg.readShort();
- Sint16 amount = msg.readShort();
+ Sint16 index = msg.readInt16();
+ Sint16 amount = msg.readInt16();
inventory->getItem(index)->increaseQuantity(-amount);
}
break;
case SMSG_PLAYER_INVENTORY_USE:
{
- Sint16 index = msg.readShort();
- msg.readShort(); // item id
- msg.readLong(); // id
- Sint16 amountLeft = msg.readShort();
- msg.readByte(); // type
+ Sint16 index = msg.readInt16();
+ msg.readInt16(); // item id
+ msg.readInt32(); // id
+ Sint16 amountLeft = msg.readInt16();
+ msg.readInt8(); // type
inventory->getItem(index)->setQuantity(amountLeft);
}
break;
case SMSG_PLAYER_SKILLS:
- msg.readShort(); // length
+ msg.readInt16(); // length
n_items = (msg.getLength() - 4) / 37;
skillDialog->cleanList();
for (int k = 0; k < n_items; k++)
{
- Sint16 skillId = msg.readShort();
- msg.readShort(); // target type
- msg.readShort(); // unknown
- Sint16 level = msg.readShort();
- Sint16 sp = msg.readShort();
- msg.readShort(); // range
+ Sint16 skillId = msg.readInt16();
+ msg.readInt16(); // target type
+ msg.readInt16(); // unknown
+ Sint16 level = msg.readInt16();
+ Sint16 sp = msg.readInt16();
+ msg.readInt16(); // range
std::string skillName = msg.readString(24);
- Sint8 up = msg.readByte();
+ Sint8 up = msg.readInt8();
if (level != 0 || up != 0)
{
@@ -1811,18 +1811,18 @@ void do_parse()
case 0x010c:
// Display MVP player
- msg.readLong(); // id
+ msg.readInt32(); // id
chatWindow->chat_log("MVP player", BY_SERVER);
break;
case SMSG_ITEM_VISIBLE:
case SMSG_ITEM_DROPPED:
{
- Uint32 id = msg.readLong();
- Sint16 itemId = msg.readShort();
- msg.readByte(); // identify flag
- Uint16 x = msg.readShort();
- Uint16 y = msg.readShort();
+ Uint32 id = msg.readInt32();
+ Sint16 itemId = msg.readInt16();
+ msg.readInt8(); // identify flag
+ Uint16 x = msg.readInt16();
+ Uint16 y = msg.readInt16();
msg.skip(4); // amount,subX,subY / subX,subY,amount
add_floor_item(new FloorItem(id, itemId, x, y, tiledMap));
@@ -1830,43 +1830,43 @@ void do_parse()
break;
case SMSG_ITEM_REMOVE:
- remove_floor_item(msg.readLong());
+ remove_floor_item(msg.readInt32());
break;
case SMSG_NPC_CHOICE:
- msg.readShort(); // length
- current_npc = msg.readLong();
+ msg.readInt16(); // length
+ current_npc = msg.readInt32();
npcListDialog->parseItems(msg.readString(msg.getLength() - 8));
npcListDialog->setVisible(true);
break;
case SMSG_BEING_CHANGE_LOOKS:
- if (!(being = findNode(msg.readLong())))
+ if (!(being = findNode(msg.readInt32())))
{
break;
}
- switch (msg.readByte()) {
+ switch (msg.readInt8()) {
case 1:
- being->setHairStyle(msg.readByte());
+ being->setHairStyle(msg.readInt8());
break;
case 2:
- being->setWeapon(msg.readByte());
+ being->setWeapon(msg.readInt8());
break;
case 6:
- being->setHairColor(msg.readByte());
+ being->setHairColor(msg.readInt8());
break;
default:
- msg.readByte(); // unsupported
+ msg.readInt8(); // unsupported
break;
}
break;
case SMSG_PLAYER_EQUIP:
{
- Sint16 index = msg.readShort();
- Sint16 equipPoint = msg.readShort();
- Sint8 type = msg.readByte();
+ Sint16 index = msg.readInt16();
+ Sint16 equipPoint = msg.readInt16();
+ Sint8 type = msg.readInt8();
logger->log("Equipping: %i %i %i",
index, equipPoint, type);
@@ -1900,10 +1900,10 @@ void do_parse()
case 0x01d7:
// Equipment related
{
- being = findNode(msg.readLong());
- msg.readByte(); // equip point
- Sint16 itemId1 = msg.readShort();
- msg.readShort(); // item id 2
+ being = findNode(msg.readInt32());
+ msg.readInt8(); // equip point
+ Sint16 itemId1 = msg.readInt16();
+ msg.readInt16(); // item id 2
if (being != NULL)
{
@@ -1914,9 +1914,9 @@ void do_parse()
case SMSG_PLAYER_UNEQUIP:
{
- Sint16 index = msg.readShort();
- Sint16 equipPoint = msg.readShort();
- Sint8 type = msg.readByte();
+ Sint16 index = msg.readInt16();
+ Sint16 equipPoint = msg.readInt16();
+ Sint8 type = msg.readInt8();
if (type == 0) {
chatWindow->chat_log("Unable to unequip.", BY_SERVER);
@@ -1968,7 +1968,7 @@ void do_parse()
case SMSG_PLAYER_ARROW_EQUIP:
{
- Sint16 id = msg.readShort();
+ Sint16 id = msg.readInt16();
if (id > 1) {
Item *item = inventory->getItem(id);
@@ -1983,7 +1983,7 @@ void do_parse()
case SMSG_PLAYER_ARROW_MESSAGE:
{
- Sint16 type = msg.readShort();
+ Sint16 type = msg.readInt16();
switch (type) {
case 0:
@@ -1999,9 +1999,9 @@ void do_parse()
case SMSG_PLAYER_STAT_UPDATE_4:
{
- Sint16 type = msg.readShort();
- Sint8 fail = msg.readByte();
- Sint8 value = msg.readByte();
+ Sint16 type = msg.readInt16();
+ Sint8 fail = msg.readInt8();
+ Sint8 value = msg.readInt8();
if (fail == 1)
{
@@ -2019,47 +2019,47 @@ void do_parse()
// Updates stats and status points
case SMSG_PLAYER_STAT_UPDATE_5:
- player_info->statsPointsToAttribute = msg.readShort();
- player_info->STR = msg.readByte();
- player_info->STRUp = msg.readByte();
- player_info->AGI = msg.readByte();
- player_info->AGIUp = msg.readByte();
- player_info->VIT = msg.readByte();
- player_info->VITUp = msg.readByte();
- player_info->INT = msg.readByte();
- player_info->INTUp = msg.readByte();
- player_info->DEX = msg.readByte();
- player_info->DEXUp = msg.readByte();
- player_info->LUK = msg.readByte();
- player_info->LUKUp = msg.readByte();
- player_info->ATK = msg.readShort(); // ATK
- player_info->ATKBonus = msg.readShort(); // ATK bonus
- player_info->MATK = msg.readShort(); // MATK max
- player_info->MATKBonus = msg.readShort(); // MATK min
- player_info->DEF = msg.readShort(); // DEF
- player_info->DEFBonus = msg.readShort(); // DEF bonus
- player_info->MDEF = msg.readShort(); // MDEF
- player_info->MDEFBonus = msg.readShort(); // MDEF bonus
- player_info->HIT = msg.readShort(); // HIT
- player_info->FLEE = msg.readShort(); // FLEE
- player_info->FLEEBonus = msg.readShort(); // FLEE bonus
- msg.readShort(); // critical
- msg.readShort(); // unknown
+ player_info->statsPointsToAttribute = msg.readInt16();
+ player_info->STR = msg.readInt8();
+ player_info->STRUp = msg.readInt8();
+ player_info->AGI = msg.readInt8();
+ player_info->AGIUp = msg.readInt8();
+ player_info->VIT = msg.readInt8();
+ player_info->VITUp = msg.readInt8();
+ player_info->INT = msg.readInt8();
+ player_info->INTUp = msg.readInt8();
+ player_info->DEX = msg.readInt8();
+ player_info->DEXUp = msg.readInt8();
+ player_info->LUK = msg.readInt8();
+ player_info->LUKUp = msg.readInt8();
+ player_info->ATK = msg.readInt16(); // ATK
+ player_info->ATKBonus = msg.readInt16(); // ATK bonus
+ player_info->MATK = msg.readInt16(); // MATK max
+ player_info->MATKBonus = msg.readInt16(); // MATK min
+ player_info->DEF = msg.readInt16(); // DEF
+ player_info->DEFBonus = msg.readInt16(); // DEF bonus
+ player_info->MDEF = msg.readInt16(); // MDEF
+ player_info->MDEFBonus = msg.readInt16(); // MDEF bonus
+ player_info->HIT = msg.readInt16(); // HIT
+ player_info->FLEE = msg.readInt16(); // FLEE
+ player_info->FLEEBonus = msg.readInt16(); // FLEE bonus
+ msg.readInt16(); // critical
+ msg.readInt16(); // unknown
break;
case SMSG_PLAYER_STAT_UPDATE_6:
- switch (msg.readShort()) {
- case 0x0020: player_info->STRUp = msg.readByte(); break;
- case 0x0021: player_info->AGIUp = msg.readByte(); break;
- case 0x0022: player_info->VITUp = msg.readByte(); break;
- case 0x0023: player_info->INTUp = msg.readByte(); break;
- case 0x0024: player_info->DEXUp = msg.readByte(); break;
- case 0x0025: player_info->LUKUp = msg.readByte(); break;
+ switch (msg.readInt16()) {
+ case 0x0020: player_info->STRUp = msg.readInt8(); break;
+ case 0x0021: player_info->AGIUp = msg.readInt8(); break;
+ case 0x0022: player_info->VITUp = msg.readInt8(); break;
+ case 0x0023: player_info->INTUp = msg.readInt8(); break;
+ case 0x0024: player_info->DEXUp = msg.readInt8(); break;
+ case 0x0025: player_info->LUKUp = msg.readInt8(); break;
}
break;
case SMSG_BEING_NAME_RESPONSE:
- if ((being = findNode(msg.readLong())))
+ if ((being = findNode(msg.readInt32())))
{
being->setName(msg.readString(24));
}
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index 185709d1..f918d45a 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -237,10 +237,10 @@ void BuyDialog::action(const std::string& eventId)
else if (eventId == "buy" && (m_amountItems > 0 &&
m_amountItems <= m_maxItems)) {
MessageOut outMsg;
- outMsg.writeShort(CMSG_NPC_BUY_REQUEST);
- outMsg.writeShort(8);
- outMsg.writeShort(m_amountItems);
- outMsg.writeShort(shopInventory[selectedItem].id);
+ outMsg.writeInt16(CMSG_NPC_BUY_REQUEST);
+ outMsg.writeInt16(8);
+ outMsg.writeInt16(m_amountItems);
+ outMsg.writeInt16(shopInventory[selectedItem].id);
// update money !
m_money -= m_amountItems * shopInventory[selectedItem].price;
diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp
index 1f40e7b5..627d119f 100644
--- a/src/gui/buysell.cpp
+++ b/src/gui/buysell.cpp
@@ -82,9 +82,9 @@ void BuySellDialog::action(const std::string& eventId)
}
if (actionId > -1) {
MessageOut outMsg;
- outMsg.writeShort(CMSG_NPC_BUY_SELL_REQUEST);
- outMsg.writeLong(current_npc);
- outMsg.writeByte(actionId);
+ outMsg.writeInt16(CMSG_NPC_BUY_SELL_REQUEST);
+ outMsg.writeInt32(current_npc);
+ outMsg.writeInt8(actionId);
}
setVisible(false);
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index 46ead1dc..a22a25de 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -195,8 +195,8 @@ void CharSelectDialog::serverCharDelete()
{
// Request character deletion
MessageOut outMsg;
- outMsg.writeShort(0x0068);
- outMsg.writeLong(char_info[0]->id);
+ outMsg.writeInt16(0x0068);
+ outMsg.writeInt32(char_info[0]->id);
outMsg.writeString("a@a.com", 40);
MessageIn msg = get_next_message();
@@ -225,8 +225,8 @@ void CharSelectDialog::serverCharSelect()
{
// Request character selection
MessageOut outMsg;
- outMsg.writeShort(0x0066);
- outMsg.writeByte(0);
+ outMsg.writeInt16(0x0066);
+ outMsg.writeInt8(0);
MessageIn msg = get_next_message();
@@ -235,11 +235,11 @@ void CharSelectDialog::serverCharSelect()
if (msg.getId() == 0x0071)
{
- char_ID = msg.readLong();
+ char_ID = msg.readInt32();
map_path = "maps/" + msg.readString(16);
map_path= map_path.substr(0, map_path.rfind(".")) + ".tmx.gz";
- map_address = msg.readLong();
- map_port = msg.readShort();
+ map_address = msg.readInt32();
+ map_port = msg.readInt16();
player_info = char_info[0];
state = CONNECTING_STATE;
@@ -250,7 +250,7 @@ void CharSelectDialog::serverCharSelect()
}
else if (msg.getId() == 0x006c)
{
- switch (msg.readByte()) {
+ switch (msg.readInt8()) {
case 0:
errorMessage = "Access denied";
break;
@@ -265,7 +265,7 @@ void CharSelectDialog::serverCharSelect()
}
else if (msg.getId() == 0x0081)
{
- switch (msg.readByte()) {
+ switch (msg.readInt8()) {
case 1:
errorMessage = "Map server offline";
break;
@@ -416,17 +416,17 @@ void CharCreateDialog::serverCharCreate()
{
// Send character infos
MessageOut outMsg;
- outMsg.writeShort(0x0067);
+ outMsg.writeInt16(0x0067);
outMsg.writeString(getName(), 24);
- outMsg.writeByte(5);
- outMsg.writeByte(5);
- outMsg.writeByte(5);
- outMsg.writeByte(5);
- outMsg.writeByte(5);
- outMsg.writeByte(5);
- outMsg.writeByte(0);
- outMsg.writeShort(playerBox->hairColor + 1);
- outMsg.writeShort(playerBox->hairStyle + 1);
+ outMsg.writeInt8(5);
+ outMsg.writeInt8(5);
+ outMsg.writeInt8(5);
+ outMsg.writeInt8(5);
+ outMsg.writeInt8(5);
+ outMsg.writeInt8(5);
+ outMsg.writeInt8(0);
+ outMsg.writeInt16(playerBox->hairColor + 1);
+ outMsg.writeInt16(playerBox->hairStyle + 1);
MessageIn msg = get_next_message();
@@ -435,41 +435,41 @@ void CharCreateDialog::serverCharCreate()
char_info = (PLAYER_INFO**)malloc(sizeof(PLAYER_INFO*));
char_info[0] = new PLAYER_INFO;
- char_info[0]->id = msg.readLong();
- char_info[0]->xp = msg.readLong();
- char_info[0]->gp = msg.readLong();
- char_info[0]->jobXp = msg.readLong();
- char_info[0]->jobLvl = msg.readLong();
+ char_info[0]->id = msg.readInt32();
+ char_info[0]->xp = msg.readInt32();
+ char_info[0]->gp = msg.readInt32();
+ char_info[0]->jobXp = msg.readInt32();
+ char_info[0]->jobLvl = msg.readInt32();
msg.skip(8); // unknown
- msg.readLong(); // option
- msg.readLong(); // karma
- msg.readLong(); // manner
+ msg.readInt32(); // option
+ msg.readInt32(); // karma
+ msg.readInt32(); // manner
msg.skip(2); // unknown
- char_info[0]->hp = msg.readShort();
- char_info[0]->maxHp = msg.readShort();
- char_info[0]->mp = msg.readShort();
- char_info[0]->maxMp = msg.readShort();
- msg.readShort(); // speed
- msg.readShort(); // class
- char_info[0]->hairStyle = msg.readShort();
- char_info[0]->weapon = msg.readShort();
- char_info[0]->lvl = msg.readShort();
- msg.readShort(); // skill point
- msg.readShort(); // head bottom
- msg.readShort(); // shield
- msg.readShort(); // head option top
- msg.readShort(); // head option mid
- char_info[0]->hairColor = msg.readShort();
- msg.readShort(); // unknown
+ char_info[0]->hp = msg.readInt16();
+ char_info[0]->maxHp = msg.readInt16();
+ char_info[0]->mp = msg.readInt16();
+ char_info[0]->maxMp = msg.readInt16();
+ msg.readInt16(); // speed
+ msg.readInt16(); // class
+ char_info[0]->hairStyle = msg.readInt16();
+ char_info[0]->weapon = msg.readInt16();
+ char_info[0]->lvl = msg.readInt16();
+ msg.readInt16(); // skill point
+ msg.readInt16(); // head bottom
+ msg.readInt16(); // shield
+ msg.readInt16(); // head option top
+ msg.readInt16(); // head option mid
+ char_info[0]->hairColor = msg.readInt16();
+ msg.readInt16(); // unknown
char_info[0]->name = msg.readString(24);
- char_info[0]->STR = msg.readByte();
- char_info[0]->AGI = msg.readByte();
- char_info[0]->VIT = msg.readByte();
- char_info[0]->INT = msg.readByte();
- char_info[0]->DEX = msg.readByte();
- char_info[0]->LUK = msg.readByte();
- char_info[0]->characterNumber = msg.readByte(); // character number
- msg.readByte(); // unknown
+ char_info[0]->STR = msg.readInt8();
+ char_info[0]->AGI = msg.readInt8();
+ char_info[0]->VIT = msg.readInt8();
+ char_info[0]->INT = msg.readInt8();
+ char_info[0]->DEX = msg.readInt8();
+ char_info[0]->LUK = msg.readInt8();
+ char_info[0]->characterNumber = msg.readInt8(); // character number
+ msg.readInt8(); // unknown
n_character = 1;
}
diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp
index 22ac484b..4135d9c5 100644
--- a/src/gui/char_server.cpp
+++ b/src/gui/char_server.cpp
@@ -160,12 +160,12 @@ void ServerSelectDialog::selectServer(int index)
{
// Send login infos
MessageOut outMsg;
- outMsg.writeShort(0x0065);
- outMsg.writeLong(account_ID);
- outMsg.writeLong(session_ID1);
- outMsg.writeLong(session_ID2);
- outMsg.writeShort(0); // unknown
- outMsg.writeByte(sex);
+ outMsg.writeInt16(0x0065);
+ outMsg.writeInt32(account_ID);
+ outMsg.writeInt32(session_ID1);
+ outMsg.writeInt32(session_ID2);
+ outMsg.writeInt16(0); // unknown
+ outMsg.writeInt8(sex);
// Skipping a mysterious 4 bytes
while ((in_size < 4) || (out_size > 0)) flush();
@@ -189,41 +189,41 @@ void ServerSelectDialog::selectServer(int index)
char_info[i]->totalWeight = 0;
char_info[i]->maxWeight = 0;
char_info[i]->lastAttackTime = 0;
- char_info[i]->id = msg.readLong();
- char_info[i]->xp = msg.readLong();
- char_info[i]->gp = msg.readLong();
- char_info[i]->jobXp = msg.readLong();
- char_info[i]->jobLvl = msg.readLong();
+ char_info[i]->id = msg.readInt32();
+ char_info[i]->xp = msg.readInt32();
+ char_info[i]->gp = msg.readInt32();
+ char_info[i]->jobXp = msg.readInt32();
+ char_info[i]->jobLvl = msg.readInt32();
msg.skip(8); // unknown
- msg.readLong(); // option
- msg.readLong(); // karma
- msg.readLong(); // manner
+ msg.readInt32(); // option
+ msg.readInt32(); // karma
+ msg.readInt32(); // manner
msg.skip(2); // unknown
- char_info[i]->hp = msg.readShort();
- char_info[i]->maxHp = msg.readShort();
- char_info[i]->mp = msg.readShort();
- char_info[i]->maxMp = msg.readShort();
- msg.readShort(); // speed
- msg.readShort(); // class
- char_info[i]->hairStyle = msg.readShort();
- char_info[i]->weapon = msg.readShort();
- char_info[i]->lvl = msg.readShort();
- msg.readShort(); // skill point
- msg.readShort(); // head bottom
- msg.readShort(); // shield
- msg.readShort(); // head option top
- msg.readShort(); // head option mid
- char_info[i]->hairColor = msg.readShort();
- msg.readShort(); // unknown
+ char_info[i]->hp = msg.readInt16();
+ char_info[i]->maxHp = msg.readInt16();
+ char_info[i]->mp = msg.readInt16();
+ char_info[i]->maxMp = msg.readInt16();
+ msg.readInt16(); // speed
+ msg.readInt16(); // class
+ char_info[i]->hairStyle = msg.readInt16();
+ char_info[i]->weapon = msg.readInt16();
+ char_info[i]->lvl = msg.readInt16();
+ msg.readInt16(); // skill point
+ msg.readInt16(); // head bottom
+ msg.readInt16(); // shield
+ msg.readInt16(); // head option top
+ msg.readInt16(); // head option mid
+ char_info[i]->hairColor = msg.readInt16();
+ msg.readInt16(); // unknown
char_info[i]->name = msg.readString(24);
- char_info[i]->STR = msg.readByte();
- char_info[i]->AGI = msg.readByte();
- char_info[i]->VIT = msg.readByte();
- char_info[i]->INT = msg.readByte();
- char_info[i]->DEX = msg.readByte();
- char_info[i]->LUK = msg.readByte();
- char_info[i]->characterNumber = msg.readByte(); // character number
- msg.readByte(); // unknown
+ char_info[i]->STR = msg.readInt8();
+ char_info[i]->AGI = msg.readInt8();
+ char_info[i]->VIT = msg.readInt8();
+ char_info[i]->INT = msg.readInt8();
+ char_info[i]->DEX = msg.readInt8();
+ char_info[i]->LUK = msg.readInt8();
+ char_info[i]->characterNumber = msg.readInt8(); // character number
+ msg.readInt8(); // unknown
}
state = CHAR_SELECT_STATE;
@@ -236,7 +236,7 @@ void ServerSelectDialog::selectServer(int index)
else if (msg.getId() == 0x006c)
{
std::string errorStr;
- switch (msg.readByte()) {
+ switch (msg.readInt8()) {
case 0: errorStr = "Access denied"; break;
case 1: errorStr = "Cannot use this ID"; break;
default: errorStr = "Rejected from server"; break;
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 7e1458c9..20deb1a7 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -251,8 +251,8 @@ ChatWindow::chat_send(std::string nick, std::string msg)
// send processed message
MessageOut outMsg;
- outMsg.writeShort(packetId);
- outMsg.writeShort(msg.length() + 4);
+ outMsg.writeInt16(packetId);
+ outMsg.writeInt16(msg.length() + 4);
outMsg.writeString(msg, msg.length());
}
diff --git a/src/gui/connection.cpp b/src/gui/connection.cpp
index 0e885598..bfa69f23 100644
--- a/src/gui/connection.cpp
+++ b/src/gui/connection.cpp
@@ -104,12 +104,12 @@ void ConnectionDialog::mapLogin()
{
// Send login infos
MessageOut outMsg;
- outMsg.writeShort(0x0072);
- outMsg.writeLong(account_ID);
- outMsg.writeLong(char_ID);
- outMsg.writeLong(session_ID1);
- outMsg.writeLong(session_ID2);
- outMsg.writeByte(sex);
+ outMsg.writeInt16(0x0072);
+ outMsg.writeInt32(account_ID);
+ outMsg.writeInt32(char_ID);
+ outMsg.writeInt32(session_ID1);
+ outMsg.writeInt32(session_ID2);
+ outMsg.writeInt8(sex);
// Skip a mysterious 4 bytes
while ((in_size < 4)|| (out_size > 0)) flush();
@@ -120,7 +120,7 @@ void ConnectionDialog::mapLogin()
if (msg.getId() == SMSG_LOGIN_SUCCESS)
{
unsigned char direction;
- msg.readLong(); // server tick
+ msg.readInt32(); // server tick
msg.readCoordinates(startX, startY, direction);
msg.skip(2); // unknown
logger->log("Protocol: Player start position: (%d, %d), Direction: %d",
@@ -140,7 +140,7 @@ void ConnectionDialog::mapLogin()
// Send "map loaded"
// TODO: be able to reuse the same msg
MessageOut newMsg;
- newMsg.writeShort(0x007d);
+ newMsg.writeInt16(0x007d);
}
void connectionInputHandler(SDL_KeyboardEvent *keyEvent)
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index 6846059c..4f08216b 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -342,11 +342,11 @@ LoginDialog::attemptLogin(const std::string& user, const std::string& pass)
{
// Send login infos
MessageOut outMsg;
- outMsg.writeShort(0x0064);
- outMsg.writeLong(0); // client version
+ outMsg.writeInt16(0x0064);
+ outMsg.writeInt32(0); // client version
outMsg.writeString(user, 24);
outMsg.writeString(pass, 24);
- outMsg.writeByte(0); // unknown
+ outMsg.writeInt8(0); // unknown
// Receive reply
MessageIn msg = get_next_message();
@@ -365,20 +365,20 @@ LoginDialog::attemptLogin(const std::string& user, const std::string& pass)
n_server = (msg.getLength() - 47) / 32;
server_info = (SERVER_INFO**)malloc(sizeof(SERVER_INFO*) * n_server);
- session_ID1 = msg.readLong();
- account_ID = msg.readLong();
- session_ID2 = msg.readLong();
+ session_ID1 = msg.readInt32();
+ account_ID = msg.readInt32();
+ session_ID2 = msg.readInt32();
msg.skip(30); // unknown
- sex = msg.readByte();
+ sex = msg.readInt8();
for (int i = 0; i < n_server; i++)
{
server_info[i] = new SERVER_INFO;
- server_info[i]->address = msg.readLong();
- server_info[i]->port = msg.readShort();
+ server_info[i]->address = msg.readInt32();
+ server_info[i]->port = msg.readInt16();
server_info[i]->name = msg.readString(20);
- server_info[i]->online_users = msg.readLong();
+ server_info[i]->online_users = msg.readInt32();
msg.skip(2); // unknown
logger->log("Network: Server: %s (%s:%d)",
@@ -392,7 +392,7 @@ LoginDialog::attemptLogin(const std::string& user, const std::string& pass)
}
else if (msg.getId() == 0x006a)
{
- int loginError = msg.readByte();
+ int loginError = msg.readInt8();
logger->log("Login::error code: %i", loginError);
switch (loginError) {
diff --git a/src/gui/npc.cpp b/src/gui/npc.cpp
index 16641916..68856705 100644
--- a/src/gui/npc.cpp
+++ b/src/gui/npc.cpp
@@ -129,9 +129,9 @@ NpcListDialog::action(const std::string& eventId)
if (choice)
{
MessageOut outMsg;
- outMsg.writeShort(CMSG_NPC_LIST_CHOICE);
- outMsg.writeLong(current_npc);
- outMsg.writeByte(choice);
+ outMsg.writeInt16(CMSG_NPC_LIST_CHOICE);
+ outMsg.writeInt32(current_npc);
+ outMsg.writeInt8(choice);
setVisible(false);
reset();
current_npc = 0;
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp
index 2e0b0837..5f5ea9cb 100644
--- a/src/gui/npc_text.cpp
+++ b/src/gui/npc_text.cpp
@@ -83,8 +83,8 @@ NpcTextDialog::action(const std::string& eventId)
if (eventId == "ok")
{
MessageOut outMsg;
- outMsg.writeShort(CMSG_NPC_NEXT_REQUEST);
- outMsg.writeLong(current_npc);
+ outMsg.writeInt16(CMSG_NPC_NEXT_REQUEST);
+ outMsg.writeInt32(current_npc);
setText("");
setVisible(false);
current_npc = 0;
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 6bb57f60..e6d3b402 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -135,9 +135,9 @@ void PopupMenu::handleLink(const std::string& link)
current_npc == 0)
{
MessageOut outMsg;
- outMsg.writeShort(CMSG_NPC_TALK);
- outMsg.writeLong(mBeing->getId());
- outMsg.writeByte(0);
+ outMsg.writeInt16(CMSG_NPC_TALK);
+ outMsg.writeInt32(mBeing->getId());
+ outMsg.writeInt8(0);
current_npc = mBeing->getId();
}
@@ -147,8 +147,8 @@ void PopupMenu::handleLink(const std::string& link)
mBeing->getType() == Being::PLAYER)
{
MessageOut outMsg;
- outMsg.writeShort(CMSG_TRADE_REQUEST);
- outMsg.writeLong(mBeing->getId());
+ outMsg.writeInt16(CMSG_TRADE_REQUEST);
+ outMsg.writeInt32(mBeing->getId());
//tradePartner.flush();
//tradePartner << "Trade: You and " << being->name<< "";
tradePartnerName = mBeing->getName();
@@ -183,8 +183,8 @@ void PopupMenu::handleLink(const std::string& link)
else if ((link == "pickup") && mFloorItem != NULL)
{
MessageOut outMsg;
- outMsg.writeShort(CMSG_ITEM_PICKUP);
- outMsg.writeLong(mFloorItem->getId());
+ outMsg.writeInt16(CMSG_ITEM_PICKUP);
+ outMsg.writeInt32(mFloorItem->getId());
}
// Look To action
diff --git a/src/gui/requesttrade.cpp b/src/gui/requesttrade.cpp
index e4423c59..6c7ef2ce 100644
--- a/src/gui/requesttrade.cpp
+++ b/src/gui/requesttrade.cpp
@@ -87,16 +87,16 @@ RequestTradeDialog::~RequestTradeDialog()
void RequestTradeDialog::action(const std::string& eventId)
{
int choice = 4; // 4 means trade canceled
-
+
if (eventId == "accept") {
choice = 3; // ok to trade
}
else if (eventId == "cancel") {
requestTradeDialogOpen = false;
}
-
+
MessageOut outMsg;
- outMsg.writeShort(CMSG_TRADE_RESPONSE);
- outMsg.writeByte(choice);
+ outMsg.writeInt16(CMSG_TRADE_RESPONSE);
+ outMsg.writeInt8(choice);
scheduleDelete();
}
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index 73880861..a147fa44 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -232,10 +232,10 @@ void SellDialog::action(const std::string& eventId)
assert(m_amountItems > 0 && m_amountItems <= m_maxItems);
MessageOut outMsg;
- outMsg.writeShort(CMSG_NPC_SELL_REQUEST);
- outMsg.writeShort(8);
- outMsg.writeShort(shopInventory[selectedItem].index);
- outMsg.writeShort(m_amountItems);
+ outMsg.writeInt16(CMSG_NPC_SELL_REQUEST);
+ outMsg.writeInt16(8);
+ outMsg.writeInt16(shopInventory[selectedItem].index);
+ outMsg.writeInt16(m_amountItems);
m_maxItems -= m_amountItems;
m_amountItems = 0;
diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp
index b65fcfd9..c2e09819 100644
--- a/src/gui/skill.cpp
+++ b/src/gui/skill.cpp
@@ -133,8 +133,8 @@ void SkillDialog::action(const std::string& eventId)
if (player_info->skillPoint > 0 && selectedSkill >= 0)
{
MessageOut outMsg;
- outMsg.writeShort(CMSG_SKILL_LEVELUP_REQUEST);
- outMsg.writeShort(skillList[selectedSkill]->id);
+ outMsg.writeInt16(CMSG_SKILL_LEVELUP_REQUEST);
+ outMsg.writeInt16(skillList[selectedSkill]->id);
}
}
else if (eventId == "skill")
diff --git a/src/gui/status.cpp b/src/gui/status.cpp
index f5302e95..0c20b6fc 100644
--- a/src/gui/status.cpp
+++ b/src/gui/status.cpp
@@ -454,32 +454,32 @@ void StatusWindow::action(const std::string& eventId)
if (eventId.length() == 3)
{
MessageOut outMsg;
- outMsg.writeShort(CMSG_STAT_UPDATE_REQUEST);
+ outMsg.writeInt16(CMSG_STAT_UPDATE_REQUEST);
if (eventId == "STR")
{
- outMsg.writeShort(0x000d);
+ outMsg.writeInt16(0x000d);
}
if (eventId == "AGI")
{
- outMsg.writeShort(0x000e);
+ outMsg.writeInt16(0x000e);
}
if (eventId == "VIT")
{
- outMsg.writeShort(0x000f);
+ outMsg.writeInt16(0x000f);
}
if (eventId == "INT")
{
- outMsg.writeShort(0x0010);
+ outMsg.writeInt16(0x0010);
}
if (eventId == "DEX")
{
- outMsg.writeShort(0x0011);
+ outMsg.writeInt16(0x0011);
}
if (eventId == "LUK")
{
- outMsg.writeShort(0x0012);
+ outMsg.writeInt16(0x0012);
}
- outMsg.writeByte(1);
+ outMsg.writeInt8(1);
}
}
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index 19aaab9e..818b8b61 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -242,9 +242,9 @@ void TradeWindow::receivedOk(bool own)
void TradeWindow::tradeItem(Item *item, int quantity)
{
MessageOut outMsg;
- outMsg.writeShort(CMSG_TRADE_ITEM_ADD_REQUEST);
- outMsg.writeShort(item->getInvIndex());
- outMsg.writeLong(quantity);
+ outMsg.writeInt16(CMSG_TRADE_ITEM_ADD_REQUEST);
+ outMsg.writeInt16(item->getInvIndex());
+ outMsg.writeInt32(quantity);
}
void TradeWindow::mouseClick(int x, int y, int button, int count)
@@ -314,7 +314,7 @@ void TradeWindow::action(const std::string &eventId)
else if (eventId == "cancel")
{
MessageOut outMsg;
- outMsg.writeShort(CMSG_TRADE_CANCEL_REQUEST);
+ outMsg.writeInt16(CMSG_TRADE_CANCEL_REQUEST);
}
else if (eventId == "ok")
{
@@ -327,19 +327,19 @@ void TradeWindow::action(const std::string &eventId)
moneyField->setText(tempMoney[1].str());
MessageOut outMsg;
- outMsg.writeShort(CMSG_TRADE_ITEM_ADD_REQUEST);
- outMsg.writeShort(0);
- outMsg.writeLong(tempInt);
+ outMsg.writeInt16(CMSG_TRADE_ITEM_ADD_REQUEST);
+ outMsg.writeInt16(0);
+ outMsg.writeInt32(tempInt);
} else {
moneyField->setText("");
}
moneyField->setEnabled(false);
MessageOut outMsg;
- outMsg.writeShort(CMSG_TRADE_ADD_COMPLETE);
+ outMsg.writeInt16(CMSG_TRADE_ADD_COMPLETE);
}
else if (eventId == "trade")
{
MessageOut outMsg;
- outMsg.writeShort(CMSG_TRADE_OK);
+ outMsg.writeInt16(CMSG_TRADE_OK);
}
}
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 63fbab7a..3a2d3742 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -98,9 +98,9 @@ bool Inventory::contains(Item *item)
int Inventory::useItem(Item *item)
{
MessageOut outMsg;
- outMsg.writeShort(CMSG_PLAYER_INVENTORY_USE);
- outMsg.writeShort(item->getInvIndex());
- outMsg.writeLong(item->getId());
+ outMsg.writeInt16(CMSG_PLAYER_INVENTORY_USE);
+ outMsg.writeInt16(item->getInvIndex());
+ outMsg.writeInt32(item->getId());
// Note: id is dest of item, usually player_node->account_ID ??
return 0;
}
@@ -109,25 +109,25 @@ int Inventory::dropItem(Item *item, int quantity)
{
// TODO: Fix wrong coordinates of drops, serverside?
MessageOut outMsg;
- outMsg.writeShort(CMSG_PLAYER_INVENTORY_DROP);
- outMsg.writeShort(item->getInvIndex());
- outMsg.writeShort(quantity);
+ outMsg.writeInt16(CMSG_PLAYER_INVENTORY_DROP);
+ outMsg.writeInt16(item->getInvIndex());
+ outMsg.writeInt16(quantity);
return 0;
}
void Inventory::equipItem(Item *item)
{
MessageOut outMsg;
- outMsg.writeShort(CMSG_PLAYER_EQUIP);
- outMsg.writeShort(item->getInvIndex());
- outMsg.writeShort(0);
+ outMsg.writeInt16(CMSG_PLAYER_EQUIP);
+ outMsg.writeInt16(item->getInvIndex());
+ outMsg.writeInt16(0);
}
void Inventory::unequipItem(Item *item)
{
MessageOut outMsg;
- outMsg.writeShort(CMSG_PLAYER_UNEQUIP);
- outMsg.writeShort(item->getInvIndex());
+ outMsg.writeInt16(CMSG_PLAYER_UNEQUIP);
+ outMsg.writeInt16(item->getInvIndex());
// Tidy equipment directly to avoid weapon still shown bug, by instance
Equipment::getInstance()->removeEquipment(item);
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index 25bf2f07..9f2b38f7 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -38,49 +38,47 @@ MessageIn::MessageIn(const char *data, unsigned int length):
mPos(0)
{
// Read the message ID
- mId = readShort();
+ mId = readInt16();
}
-char
-MessageIn::readByte()
+Sint8
+MessageIn::readInt8()
{
assert(mPos < mLength);
return mData[mPos++];
}
-short
-MessageIn::readShort()
+Sint16
+MessageIn::readInt16()
{
assert(mPos + 2 <= mLength);
mPos += 2;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- return SDL_Swap16(*(short*)(mData + (mPos - 2)));
+ return SDL_Swap16(*(Sint16*)(mData + (mPos - 2)));
#else
- return (*(short*)(mData + (mPos - 2)));
+ return (*(Sint16*)(mData + (mPos - 2)));
#endif
}
-long
-MessageIn::readLong()
+Sint32
+MessageIn::readInt32()
{
assert(mPos + 4 <= mLength);
mPos += 4;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- return SDL_Swap32(*(long*)(mData + (mPos - 4)));
+ return SDL_Swap32(*(Sint32*)(mData + (mPos - 4)));
#else
- return (*(long*)(mData + (mPos - 4)));
+ return (*(Sint32*)(mData + (mPos - 4)));
#endif
}
void
-MessageIn::readCoordinates(unsigned short &x,
- unsigned short &y,
- unsigned char &direction)
+MessageIn::readCoordinates(Uint16 &x, Uint16 &y, Uint8 &direction)
{
assert(mPos + 3 <= mLength);
const char *data = mData + mPos;
- short temp;
+ Sint16 temp;
temp = MAKEWORD(data[1] & 0x00c0, data[0] & 0x00ff);
x = temp >> 6;
@@ -93,13 +91,13 @@ MessageIn::readCoordinates(unsigned short &x,
}
void
-MessageIn::readCoordinatePair(unsigned short &srcX, unsigned short &srcY,
- unsigned short &dstX, unsigned short &dstY)
+MessageIn::readCoordinatePair(Uint16 &srcX, Uint16 &srcY,
+ Uint16 &dstX, Uint16 &dstY)
{
assert(mPos + 5 <= mLength);
const char *data = mData + mPos;
- short temp;
+ Sint16 temp;
temp = MAKEWORD(data[3], data[2] & 0x000f);
dstX = temp >> 2;
@@ -129,7 +127,7 @@ MessageIn::readString(int length)
// Get string length
if (length < 0) {
- stringLength = readShort();
+ stringLength = readInt16();
} else {
stringLength = length;
}
@@ -149,20 +147,20 @@ MessageIn::readString(int length)
return read;
}
-char& operator<<(char &lhs, MessageIn &msg)
+Sint8& operator<<(Sint8 &lhs, MessageIn &msg)
{
- lhs = msg.readByte();
+ lhs = msg.readInt8();
return lhs;
}
-short& operator<<(short &lhs, MessageIn &msg)
+Sint16& operator<<(Sint16 &lhs, MessageIn &msg)
{
- lhs = msg.readShort();
+ lhs = msg.readInt16();
return lhs;
}
-long& operator<<(long &lhs, MessageIn &msg)
+Sint32& operator<<(Sint32 &lhs, MessageIn &msg)
{
- lhs = msg.readLong();
+ lhs = msg.readInt32();
return lhs;
}
diff --git a/src/net/messagein.h b/src/net/messagein.h
index 087d325c..d97cd8b6 100644
--- a/src/net/messagein.h
+++ b/src/net/messagein.h
@@ -25,15 +25,16 @@
#define _TMW_MESSAGEIN_
#include <string>
+#include <SDL_types.h>
/**
* Used for parsing an incoming message.
*/
class MessageIn
{
- friend char& operator<<(char &lhs, MessageIn &msg);
- friend short& operator<<(short &lhs, MessageIn &msg);
- friend long& operator<<(long &lhs, MessageIn &msg);
+ friend Sint8& operator<<(Sint8 &lhs, MessageIn &msg);
+ friend Sint16& operator<<(Sint16 &lhs, MessageIn &msg);
+ friend Sint32& operator<<(Sint32 &lhs, MessageIn &msg);
public:
/**
@@ -53,26 +54,24 @@ class MessageIn
unsigned int
getLength() { return mLength; }
- char readByte(); /**< Reads a byte. */
- short readShort(); /**< Reads a short. */
- long readLong(); /**< Reads a long. */
+ Sint8 readInt8(); /**< Reads a byte. */
+ Sint16 readInt16(); /**< Reads a short. */
+ Sint32 readInt32(); /**< Reads a long. */
/**
* Reads a special 3 byte block used by eAthena, containing x and y
* coordinates and direction.
*/
void
- readCoordinates(unsigned short &x,
- unsigned short &y,
- unsigned char &direction);
+ readCoordinates(Uint16 &x, Uint16 &y, Uint8 &direction);
/**
* Reads a special 5 byte block used by eAthena, containing a source
* and destination coordinate pair.
*/
void
- readCoordinatePair(unsigned short &srcX, unsigned short &srcY,
- unsigned short &dstX, unsigned short &dstY);
+ readCoordinatePair(Uint16 &srcX, Uint16 &srcY,
+ Uint16 &dstX, Uint16 &dstY);
/**
* Skips a given number of bytes.
diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp
index 713d49be..9b27a6a5 100644
--- a/src/net/messageout.cpp
+++ b/src/net/messageout.cpp
@@ -57,39 +57,36 @@ void MessageOut::expand(size_t bytes)
mDataSize = bytes;*/
}
-void MessageOut::writeByte(char value)
+void MessageOut::writeInt8(Sint8 value)
{
- expand(mPos + sizeof(char));
+ expand(mPos + sizeof(Sint8));
mData[mPos] = value;
- mPos += sizeof(char);
- out_size += sizeof(char);
+ mPos += sizeof(Sint8);
+ out_size += sizeof(Sint8);
}
-void MessageOut::writeShort(short value)
+void MessageOut::writeInt16(Sint16 value)
{
- expand(mPos + sizeof(short));
+ expand(mPos + sizeof(Sint16));
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- (*(short *)(mData + mPos)) = SDL_Swap16(value);
+ (*(Sint16 *)(mData + mPos)) = SDL_Swap16(value);
#else
- (*(short *)(mData + mPos)) = value;
+ (*(Sint16 *)(mData + mPos)) = value;
#endif
- mPos += sizeof(short);
- out_size += sizeof(short);
+ mPos += sizeof(Sint16);
+ out_size += sizeof(Sint16);
}
-/*
- writeLong should use an int because long is 8 bytes in x86_64 arch !
-*/
-void MessageOut::writeLong(int value)
+void MessageOut::writeInt32(Sint32 value)
{
- expand(mPos + sizeof(int));
+ expand(mPos + sizeof(Sint32));
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- (*(int *)(mData + mPos)) = SDL_Swap32(value);
+ (*(Sint32 *)(mData + mPos)) = SDL_Swap32(value);
#else
- (*(int *)(mData + mPos)) = value;
+ (*(Sint32 *)(mData + mPos)) = value;
#endif
- mPos += sizeof(int);
- out_size += sizeof(int);
+ mPos += sizeof(Sint32);
+ out_size += sizeof(Sint32);
}
void MessageOut::writeString(const std::string &string, int length)
@@ -99,7 +96,7 @@ void MessageOut::writeString(const std::string &string, int length)
if (length < 0)
{
// Write the length at the start if not fixed
- writeShort(string.length());
+ writeInt16(string.length());
expand(mPos + string.length());
}
else
@@ -133,20 +130,20 @@ const Packet *MessageOut::getPacket()
return mPacket;
}
-MessageOut& operator<<(MessageOut &msg, const char &rhs)
+MessageOut& operator<<(MessageOut &msg, const Sint8 &rhs)
{
- msg.writeByte(rhs);
+ msg.writeInt8(rhs);
return msg;
}
-MessageOut& operator<<(MessageOut &msg, const short &rhs)
+MessageOut& operator<<(MessageOut &msg, const Sint16 &rhs)
{
- msg.writeShort(rhs);
+ msg.writeInt16(rhs);
return msg;
}
-MessageOut& operator<<(MessageOut &msg, const long &rhs)
+MessageOut& operator<<(MessageOut &msg, const Sint32 &rhs)
{
- msg.writeLong(rhs);
+ msg.writeInt32(rhs);
return msg;
}
diff --git a/src/net/messageout.h b/src/net/messageout.h
index 04a5ba91..b2ee506e 100644
--- a/src/net/messageout.h
+++ b/src/net/messageout.h
@@ -25,6 +25,7 @@
#define _TMW_MESSAGEOUT_
#include <iosfwd>
+#include <SDL_types.h>
class Packet;
@@ -33,9 +34,9 @@ class Packet;
*/
class MessageOut
{
- friend MessageOut& operator<<(MessageOut &msg, const char &rhs);
- friend MessageOut& operator<<(MessageOut &msg, const short &rhs);
- friend MessageOut& operator<<(MessageOut &msg, const long &rhs);
+ friend MessageOut& operator<<(MessageOut &msg, const Sint8 &rhs);
+ friend MessageOut& operator<<(MessageOut &msg, const Sint16 &rhs);
+ friend MessageOut& operator<<(MessageOut &msg, const Sint32 &rhs);
public:
/**
@@ -48,9 +49,9 @@ class MessageOut
*/
~MessageOut();
- void writeByte(char value); /**< Writes a byte. */
- void writeShort(short value); /**< Writes a short. */
- void writeLong(int value); /**< Writes a long. */
+ void writeInt8(Sint8 value); /**< Writes a byte. */
+ void writeInt16(Sint16 value); /**< Writes a short. */
+ void writeInt32(Sint32 value); /**< Writes a long. */
/**
* Writes a string. If a fixed length is not given (-1), it is stored
diff --git a/src/net/protocol.cpp b/src/net/protocol.cpp
index 516afa59..e57be110 100644
--- a/src/net/protocol.cpp
+++ b/src/net/protocol.cpp
@@ -73,16 +73,16 @@ void walk(unsigned short x, unsigned short y, unsigned char direction)
char temp[3];
MessageOut outMsg;
set_coordinates(temp, x, y, direction);
- outMsg.writeShort(0x0085);
+ outMsg.writeInt16(0x0085);
outMsg.writeString(temp, 3);
}
void action(char type, int id)
{
MessageOut outMsg;
- outMsg.writeShort(0x0089);
- outMsg.writeLong(id);
- outMsg.writeByte(type);
+ outMsg.writeInt16(0x0089);
+ outMsg.writeInt32(id);
+ outMsg.writeInt8(type);
}
Being* attack(unsigned short x, unsigned short y, unsigned char direction)