summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-11-21 16:30:11 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-11-21 16:30:11 +0000
commita5e6a44b51d4269ed6812c9a9e0b6a293d959a4d (patch)
treef269a803b58b47082156dc74bb0d6e8e2dc6519e /src/net
parent1f6975d34e2c6fe8404fcbe13da406e624d94b68 (diff)
downloadmana-a5e6a44b51d4269ed6812c9a9e0b6a293d959a4d.tar.gz
mana-a5e6a44b51d4269ed6812c9a9e0b6a293d959a4d.tar.bz2
mana-a5e6a44b51d4269ed6812c9a9e0b6a293d959a4d.tar.xz
mana-a5e6a44b51d4269ed6812c9a9e0b6a293d959a4d.zip
Renamed {read,write}{Byte,Short,Long} to {read,write}{Int8,Int16,Int32}. This
is less confusing in 64-bit context and less conflicting with the 0.0 client.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/accountserver/account.cpp24
-rw-r--r--src/net/accountserver/accountserver.cpp4
-rw-r--r--src/net/beinghandler.cpp196
-rw-r--r--src/net/buysellhandler.cpp16
-rw-r--r--src/net/charserverhandler.cpp22
-rw-r--r--src/net/chathandler.cpp28
-rw-r--r--src/net/chatserver/chatserver.cpp8
-rw-r--r--src/net/gameserver/gameserver.cpp2
-rw-r--r--src/net/gameserver/player.cpp46
-rw-r--r--src/net/inventoryhandler.cpp8
-rw-r--r--src/net/itemhandler.cpp6
-rw-r--r--src/net/loginhandler.cpp6
-rw-r--r--src/net/logouthandler.cpp8
-rw-r--r--src/net/messagein.cpp10
-rw-r--r--src/net/messagein.h6
-rw-r--r--src/net/messageout.cpp10
-rw-r--r--src/net/messageout.h6
-rw-r--r--src/net/npchandler.cpp2
-rw-r--r--src/net/playerhandler.cpp14
-rw-r--r--src/net/skillhandler.cpp26
-rw-r--r--src/net/tradehandler.cpp8
21 files changed, 228 insertions, 228 deletions
diff --git a/src/net/accountserver/account.cpp b/src/net/accountserver/account.cpp
index a90f75b8..f0778b1d 100644
--- a/src/net/accountserver/account.cpp
+++ b/src/net/accountserver/account.cpp
@@ -37,16 +37,16 @@ void Net::AccountServer::Account::createCharacter(
MessageOut msg(PAMSG_CHAR_CREATE);
msg.writeString(name);
- msg.writeByte(hairStyle);
- msg.writeByte(hairColor);
- msg.writeByte(gender);
- msg.writeShort(strength);
- msg.writeShort(agility);
- msg.writeShort(vitality);
- msg.writeShort(intelligence);
- msg.writeShort(dexterity);
- msg.writeShort(willpower);
- msg.writeShort(charisma);
+ msg.writeInt8(hairStyle);
+ msg.writeInt8(hairColor);
+ msg.writeInt8(gender);
+ msg.writeInt16(strength);
+ msg.writeInt16(agility);
+ msg.writeInt16(vitality);
+ msg.writeInt16(intelligence);
+ msg.writeInt16(dexterity);
+ msg.writeInt16(willpower);
+ msg.writeInt16(charisma);
Net::AccountServer::connection->send(msg);
}
@@ -55,7 +55,7 @@ void Net::AccountServer::Account::deleteCharacter(char slot)
{
MessageOut msg(PAMSG_CHAR_DELETE);
- msg.writeByte(slot);
+ msg.writeInt8(slot);
Net::AccountServer::connection->send(msg);
}
@@ -64,7 +64,7 @@ void Net::AccountServer::Account::selectCharacter(char slot)
{
MessageOut msg(PAMSG_CHAR_SELECT);
- msg.writeByte(slot);
+ msg.writeInt8(slot);
Net::AccountServer::connection->send(msg);
}
diff --git a/src/net/accountserver/accountserver.cpp b/src/net/accountserver/accountserver.cpp
index 92d803e6..651758a6 100644
--- a/src/net/accountserver/accountserver.cpp
+++ b/src/net/accountserver/accountserver.cpp
@@ -36,7 +36,7 @@ void Net::AccountServer::login(Net::Connection *connection, int version,
MessageOut msg(PAMSG_LOGIN);
- msg.writeLong(version);
+ msg.writeInt32(version);
msg.writeString(username);
msg.writeString(password);
@@ -51,7 +51,7 @@ void Net::AccountServer::registerAccount(Net::Connection *connection,
MessageOut msg(PAMSG_REGISTER);
- msg.writeLong(version); // client version
+ msg.writeInt32(version); // client version
msg.writeString(username);
msg.writeString(password);
msg.writeString(email);
diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp
index 56ec0192..a9f992af 100644
--- a/src/net/beinghandler.cpp
+++ b/src/net/beinghandler.cpp
@@ -105,12 +105,12 @@ void BeingHandler::handleMessage(MessageIn &msg)
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.readInt32();
+ speed = msg.readInt16();
+ msg.readInt16(); // unknown
+ msg.readInt16(); // unknown
+ msg.readInt16(); // option
+ job = msg.readInt16(); // class
dstBeing = beingManager->findBeing(id);
@@ -138,32 +138,32 @@ void BeingHandler::handleMessage(MessageIn &msg)
dstBeing->setWalkSpeed(speed);
dstBeing->mJob = job;
- dstBeing->setHairStyle(msg->readShort());
+ dstBeing->setHairStyle(msg->readInt16());
dstBeing->setVisibleEquipment(
- Being::WEAPON_SPRITE, msg->readShort());
+ Being::WEAPON_SPRITE, msg->readInt16());
dstBeing->setVisibleEquipment(
- Being::BOTTOMCLOTHES_SPRITE, msg->readShort());
+ Being::BOTTOMCLOTHES_SPRITE, msg->readInt16());
if (msg.getId() == SMSG_BEING_MOVE)
{
- msg.readLong(); // server tick
+ msg.readInt32(); // server tick
}
- msg->readShort(); // shield
- headTop = msg->readShort();
- headMid = msg->readShort();
+ msg->readInt16(); // shield
+ headTop = msg->readInt16();
+ headMid = msg->readInt16();
dstBeing->setVisibleEquipment(Being::HAT_SPRITE, headTop);
dstBeing->setVisibleEquipment(Being::TOPCLOTHES_SPRITE, headMid);
- 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
+ dstBeing->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
+ dstBeing->setSex(1 - msg->readInt8()); // sex
if (msg.getId() == SMSG_BEING_MOVE)
{
@@ -181,19 +181,19 @@ void BeingHandler::handleMessage(MessageIn &msg)
//dstBeing->setDirection(dir);
}
- 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
- dstBeing = beingManager->findBeing(msg.readLong());
+ dstBeing = beingManager->findBeing(msg.readInt32());
if (!dstBeing)
break;
- if (msg.readByte() == 1)
+ if (msg.readInt8() == 1)
{
dstBeing->setAction(Being::DEAD);
}
@@ -209,15 +209,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.readInt32());
+ dstBeing = beingManager->findBeing(msg.readInt32());
+ msg.readInt32(); // server tick
+ msg.readInt32(); // src speed
+ msg.readInt32(); // dst speed
+ param1 = msg.readInt16();
+ msg.readInt16(); // param 2
+ type = msg.readInt8();
+ msg.readInt16(); // param 3
switch (type)
{
@@ -247,7 +247,7 @@ void BeingHandler::handleMessage(MessageIn &msg)
break;
case SMSG_BEING_LEVELUP:
- id = (Uint32) msg->readLong();
+ id = (Uint32) msg->readInt32();
if (id == player_node->getId()) {
logger->log("Level up");
@@ -257,7 +257,7 @@ void BeingHandler::handleMessage(MessageIn &msg)
logger->log("Someone else went level up");
}
Particle *levelupFX;
- if (msg->readLong() == 0) { // type
+ if (msg->readInt32() == 0) { // type
levelupFX = particleEngine->addEffect(
"graphics/particles/levelup.particle.xml", 0, 0);
}
@@ -269,24 +269,24 @@ void BeingHandler::handleMessage(MessageIn &msg)
break;
case SMSG_BEING_EMOTION:
- if (!(dstBeing = beingManager->findBeing(msg.readLong())))
+ if (!(dstBeing = beingManager->findBeing(msg.readInt32())))
{
break;
}
- dstBeing->mEmotion = msg.readByte();
+ dstBeing->mEmotion = msg.readInt8();
dstBeing->mEmotionTime = EMOTION_TIME;
break;
case SMSG_BEING_CHANGE_LOOKS:
{
- if (!(dstBeing = beingManager->findBeing(msg.readLong())))
+ if (!(dstBeing = beingManager->findBeing(msg.readInt32())))
{
break;
}
- int type = msg.readByte();
- int id = msg.readByte();
+ int type = msg.readInt8();
+ int id = msg.readInt8();
switch (type) {
case 1:
@@ -319,7 +319,7 @@ void BeingHandler::handleMessage(MessageIn &msg)
break;
case SMSG_BEING_NAME_RESPONSE:
- if ((dstBeing = beingManager->findBeing(msg.readLong())))
+ if ((dstBeing = beingManager->findBeing(msg.readInt32())))
{
dstBeing->setName(msg.readString(24));
}
@@ -329,12 +329,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.readInt32();
+ speed = msg.readInt16();
+ msg.readInt16(); // option 1
+ msg.readInt16(); // option 2
+ msg.readInt16(); // option
+ job = msg.readInt16();
dstBeing = beingManager->findBeing(id);
@@ -345,27 +345,27 @@ void BeingHandler::handleMessage(MessageIn &msg)
dstBeing->setWalkSpeed(speed);
dstBeing->mJob = job;
- dstBeing->setHairStyle(msg->readShort());
+ dstBeing->setHairStyle(msg->readInt16());
dstBeing->setVisibleEquipment(
- Being::WEAPON_SPRITE, msg->readShort());
- msg->readShort(); // item id 2
- headBottom = msg->readShort();
+ Being::WEAPON_SPRITE, msg->readInt16());
+ msg->readInt16(); // item id 2
+ headBottom = msg->readInt16();
if (msg.getId() == SMSG_PLAYER_MOVE)
{
- msg.readLong(); // server tick
+ msg.readInt32(); // server tick
}
- headTop = msg.readShort();
- headMid = msg.readShort();
- 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
+ headTop = msg.readInt16();
+ headMid = msg.readInt16();
+ dstBeing->setHairColor(msg.readInt16());
+ msg.readInt16(); // unknown
+ msg.readInt16(); // head dir
+ msg.readInt32(); // guild
+ msg.readInt32(); // emblem
+ msg.readInt16(); // manner
+ msg.readInt8(); // karma
+ dstBeing->setSex(1 - msg.readInt8()); // sex
dstBeing->setVisibleEquipment(
Being::BOTTOMCLOTHES_SPRITE, headBottom);
dstBeing->setVisibleEquipment(Being::HAT_SPRITE, headTop);
@@ -386,23 +386,23 @@ void BeingHandler::handleMessage(MessageIn &msg)
//dstBeing->setDirection(dir);
}
- 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)
{
dstBeing->setAction(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
dstBeing->mWalkTime = tick_time;
dstBeing->mFrame = 0;
@@ -410,9 +410,9 @@ void BeingHandler::handleMessage(MessageIn &msg)
case 0x0119:
// Change in players look
- logger->log("0x0119 %i %i %i %x %i", msg->readLong(),
- msg->readShort(), msg->readShort(), msg->readShort(),
- msg->readByte());
+ logger->log("0x0119 %i %i %i %x %i", msg->readInt32(),
+ msg->readInt16(), msg->readInt16(), msg->readInt16(),
+ msg->readInt8());
break;
*/
}
@@ -426,7 +426,7 @@ static void handleLooks(Player *being, MessageIn &msg)
{ Being::WEAPON_SPRITE, Being::HAT_SPRITE, Being::TOPCLOTHES_SPRITE,
Being::BOTTOMCLOTHES_SPRITE };
- int mask = msg.readByte();
+ int mask = msg.readInt8();
if (mask & (1 << 7))
{
@@ -441,7 +441,7 @@ static void handleLooks(Player *being, MessageIn &msg)
for (int i = 0; i < nb_slots; ++i)
{
if (!(mask & (1 << i))) continue;
- int id = msg.readShort();
+ int id = msg.readInt16();
being->setVisibleEquipment(slots[i], id);
}
}
@@ -449,11 +449,11 @@ static void handleLooks(Player *being, MessageIn &msg)
void
BeingHandler::handleBeingEnterMessage(MessageIn &msg)
{
- int type = msg.readByte();
- int id = msg.readShort();
- Being::Action action = (Being::Action)msg.readByte();
- int px = msg.readShort();
- int py = msg.readShort();
+ int type = msg.readInt8();
+ int id = msg.readInt16();
+ Being::Action action = (Being::Action)msg.readInt8();
+ int px = msg.readInt16();
+ int py = msg.readInt16();
Being *being;
switch (type)
@@ -472,16 +472,16 @@ BeingHandler::handleBeingEnterMessage(MessageIn &msg)
being->setName(name);
}
Player *p = static_cast< Player * >(being);
- int hs = msg.readByte(), hc = msg.readByte();
+ int hs = msg.readInt8(), hc = msg.readInt8();
p->setHairStyle(hs, hc);
- p->setGender(msg.readByte());
+ p->setGender(msg.readInt8());
handleLooks(p, msg);
} break;
case OBJECT_MONSTER:
case OBJECT_NPC:
{
- int subtype = msg.readShort();
+ int subtype = msg.readInt16();
being = beingManager->createBeing(id, type, subtype);
} break;
@@ -497,7 +497,7 @@ BeingHandler::handleBeingEnterMessage(MessageIn &msg)
void BeingHandler::handleBeingLeaveMessage(MessageIn &msg)
{
- Being *being = beingManager->findBeing(msg.readShort());
+ Being *being = beingManager->findBeing(msg.readInt16());
if (!being) return;
beingManager->destroyBeing(being);
@@ -507,8 +507,8 @@ void BeingHandler::handleBeingsMoveMessage(MessageIn &msg)
{
while (msg.getUnreadLength())
{
- int id = msg.readShort();
- int flags = msg.readByte();
+ int id = msg.readInt16();
+ int flags = msg.readInt8();
Being *being = beingManager->findBeing(id);
int sx = 0, sy = 0, dx = 0, dy = 0, speed = 0;
if (flags & MOVING_POSITION)
@@ -517,12 +517,12 @@ void BeingHandler::handleBeingsMoveMessage(MessageIn &msg)
msg.readCoordinates(sx2, sy2);
sx = sx2 * 32 + 16;
sy = sy2 * 32 + 16;
- speed = msg.readByte();
+ speed = msg.readInt8();
}
if (flags & MOVING_DESTINATION)
{
- dx = msg.readShort();
- dy = msg.readShort();
+ dx = msg.readInt16();
+ dy = msg.readInt16();
if (!(flags & MOVING_POSITION))
{
sx = dx;
@@ -561,19 +561,19 @@ void BeingHandler::handleBeingsMoveMessage(MessageIn &msg)
void BeingHandler::handleBeingAttackMessage(MessageIn &msg)
{
- Being *being = beingManager->findBeing(msg.readShort());
+ Being *being = beingManager->findBeing(msg.readInt16());
if (!being) return;
being->setAction(Being::ATTACK);
- being->setDirection(msg.readByte());
+ being->setDirection(msg.readInt8());
}
void BeingHandler::handleBeingsDamageMessage(MessageIn &msg)
{
while (msg.getUnreadLength())
{
- Being *being = beingManager->findBeing(msg.readShort());
- int damage = msg.readShort();
+ Being *being = beingManager->findBeing(msg.readInt16());
+ int damage = msg.readInt16();
if (being)
{
being->takeDamage(damage);
@@ -583,15 +583,15 @@ void BeingHandler::handleBeingsDamageMessage(MessageIn &msg)
void BeingHandler::handleBeingActionChangeMessage(MessageIn &msg)
{
- Being* being = beingManager->findBeing(msg.readShort());
+ Being* being = beingManager->findBeing(msg.readInt16());
if (!being) return;
- being->setAction((Being::Action) msg.readByte());
+ being->setAction((Being::Action) msg.readInt8());
}
void BeingHandler::handleBeingLooksChangeMessage(MessageIn &msg)
{
- Being *being = beingManager->findBeing(msg.readShort());
+ Being *being = beingManager->findBeing(msg.readInt16());
if (!being || being->getType() != Being::PLAYER) return;
handleLooks(static_cast< Player * >(being), msg);
}
diff --git a/src/net/buysellhandler.cpp b/src/net/buysellhandler.cpp
index 9b96ced7..57806edc 100644
--- a/src/net/buysellhandler.cpp
+++ b/src/net/buysellhandler.cpp
@@ -53,7 +53,7 @@ BuySellHandler::BuySellHandler()
void BuySellHandler::handleMessage(MessageIn &msg)
{
- Being *being = beingManager->findBeing(msg.readShort());
+ Being *being = beingManager->findBeing(msg.readInt16());
if (!being || being->getType() != Being::NPC)
{
return;
@@ -70,7 +70,7 @@ 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.readInt32()));
break;
#endif
@@ -81,9 +81,9 @@ void BuySellHandler::handleMessage(MessageIn &msg)
while (msg.getUnreadLength())
{
- int itemId = msg.readShort();
- int amount = msg.readShort();
- int value = msg.readShort();
+ int itemId = msg.readInt16();
+ int amount = msg.readInt16();
+ int value = msg.readInt16();
buyDialog->addItem(itemId, amount, value);
}
break;
@@ -95,9 +95,9 @@ void BuySellHandler::handleMessage(MessageIn &msg)
while (msg.getUnreadLength())
{
- int itemId = msg.readShort();
- int amount = msg.readShort();
- int value = msg.readShort();
+ int itemId = msg.readInt16();
+ int amount = msg.readInt16();
+ int value = msg.readInt16();
sellDialog->addItem(itemId, amount, value);
}
break;
diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp
index 0082db4c..bbfa82a4 100644
--- a/src/net/charserverhandler.cpp
+++ b/src/net/charserverhandler.cpp
@@ -65,7 +65,7 @@ void CharServerHandler::handleMessage(MessageIn &msg)
case APMSG_CHAR_DELETE_RESPONSE:
{
- int errMsg = msg.readByte();
+ int errMsg = msg.readInt8();
// Character deletion successful
if (errMsg == ERRMSG_OK)
{
@@ -117,7 +117,7 @@ void CharServerHandler::handleMessage(MessageIn &msg)
void CharServerHandler::handleCharCreateResponse(MessageIn &msg)
{
- int errMsg = msg.readByte();
+ int errMsg = msg.readInt8();
// Character creation failed
if (errMsg != ERRMSG_OK)
@@ -168,15 +168,15 @@ void CharServerHandler::handleCharCreateResponse(MessageIn &msg)
void CharServerHandler::handleCharSelectResponse(MessageIn &msg)
{
- int errMsg = msg.readByte();
+ int errMsg = msg.readInt8();
if (errMsg == ERRMSG_OK)
{
token = msg.readString(32);
std::string gameServer = msg.readString();
- unsigned short gameServerPort = msg.readShort();
+ unsigned short gameServerPort = msg.readInt16();
std::string chatServer = msg.readString();
- unsigned short chatServerPort = msg.readShort();
+ unsigned short chatServerPort = msg.readInt16();
logger->log("Game server: %s:%d", gameServer.c_str(), gameServerPort);
logger->log("Chat server: %s:%d", chatServer.c_str(), chatServerPort);
@@ -210,17 +210,17 @@ void CharServerHandler::handleCharSelectResponse(MessageIn &msg)
LocalPlayer* CharServerHandler::readPlayerData(MessageIn &msg, int &slot)
{
LocalPlayer *tempPlayer = new LocalPlayer;
- slot = msg.readByte(); // character slot
+ slot = msg.readInt8(); // character slot
tempPlayer->mName = msg.readString();
- tempPlayer->setGender(msg.readByte());
- int hs = msg.readByte(), hc = msg.readByte();
+ tempPlayer->setGender(msg.readInt8());
+ int hs = msg.readInt8(), hc = msg.readInt8();
tempPlayer->setHairStyle(hs, hc);
- tempPlayer->setLevel(msg.readByte());
- tempPlayer->setMoney(msg.readLong());
+ tempPlayer->setLevel(msg.readInt8());
+ tempPlayer->setMoney(msg.readInt32());
for (int i = 0; i < 7; i++)
{
- tempPlayer->setAttributeBase(i, msg.readByte());
+ tempPlayer->setAttributeBase(i, msg.readInt8());
}
return tempPlayer;
diff --git a/src/net/chathandler.cpp b/src/net/chathandler.cpp
index 713b8f22..9fe231e6 100644
--- a/src/net/chathandler.cpp
+++ b/src/net/chathandler.cpp
@@ -73,7 +73,7 @@ void ChatHandler::handleMessage(MessageIn &msg)
switch (msg.getId())
{
case GPMSG_SAY:
- being = beingManager->findBeing(msg.readShort());
+ being = beingManager->findBeing(msg.readInt16());
chatMsg = msg.readString();
if (being)
{
@@ -86,9 +86,9 @@ void ChatHandler::handleMessage(MessageIn &msg)
}
break;
case CPMSG_REGISTER_CHANNEL_RESPONSE:
- if(msg.readByte() == ERRMSG_OK)
+ if(msg.readInt8() == ERRMSG_OK)
{
- channelId = msg.readShort();
+ channelId = msg.readInt16();
std::string channelName = msg.readString();
chatWindow->chatLog("Registered Channel " + channelName, BY_SERVER);
chatWindow->addChannel(channelId, channelName);
@@ -100,9 +100,9 @@ void ChatHandler::handleMessage(MessageIn &msg)
}
break;
case CPMSG_ENTER_CHANNEL_RESPONSE:
- if(msg.readByte() == ERRMSG_OK)
+ if(msg.readInt8() == ERRMSG_OK)
{
- channelId = msg.readShort();
+ channelId = msg.readInt16();
channelName = msg.readString();
std::string announcement = msg.readString();
std::vector<std::string> userList;
@@ -126,7 +126,7 @@ void ChatHandler::handleMessage(MessageIn &msg)
{
channelName = msg.readString();
std::ostringstream numUsers;
- numUsers << msg.readShort();
+ numUsers << msg.readInt16();
if(channelName != "")
{
channelName += " - ";
@@ -138,7 +138,7 @@ void ChatHandler::handleMessage(MessageIn &msg)
break;
case CPMSG_PUBMSG:
- channelId = msg.readShort();
+ channelId = msg.readInt16();
userNick = msg.readString();
chatMsg = msg.readString();
@@ -146,9 +146,9 @@ void ChatHandler::handleMessage(MessageIn &msg)
break;
case CPMSG_QUIT_CHANNEL_RESPONSE:
- if(msg.readByte() == ERRMSG_OK)
+ if(msg.readInt8() == ERRMSG_OK)
{
- channelId = msg.readShort();
+ channelId = msg.readInt16();
// remove the chat tab
chatWindow->removeChannel(channelId);
}
@@ -156,8 +156,8 @@ void ChatHandler::handleMessage(MessageIn &msg)
/*
// Received speech from being
case SMSG_BEING_CHAT:
- chatMsgLength = msg.readShort() - 8;
- being = beingManager->findBeing(msg.readLong());
+ chatMsgLength = msg.readInt16() - 8;
+ being = beingManager->findBeing(msg.readInt32());
if (!being || chatMsgLength <= 0)
{
@@ -173,7 +173,7 @@ void ChatHandler::handleMessage(MessageIn &msg)
case SMSG_PLAYER_CHAT:
case SMSG_GM_CHAT:
- chatMsgLength = msg.readShort() - 4;
+ chatMsgLength = msg.readInt16() - 4;
if (chatMsgLength <= 0)
{
@@ -200,13 +200,13 @@ void ChatHandler::handleMessage(MessageIn &msg)
break;
case SMSG_WHO_ANSWER:
- chatWindow->chatLog("Online users: " + toString(msg.readLong()),
+ chatWindow->chatLog("Online users: " + toString(msg.readInt32()),
BY_SERVER);
break;
case 0x010c:
// Display MVP player
- msg.readLong(); // id
+ msg.readInt32(); // id
chatWindow->chatLog("MVP player", BY_SERVER);
break;
*/
diff --git a/src/net/chatserver/chatserver.cpp b/src/net/chatserver/chatserver.cpp
index f24e4cd5..93fdc828 100644
--- a/src/net/chatserver/chatserver.cpp
+++ b/src/net/chatserver/chatserver.cpp
@@ -55,7 +55,7 @@ void Net::ChatServer::chat(short channel, const std::string &text)
MessageOut msg(PCMSG_CHAT);
msg.writeString(text);
- msg.writeShort(channel);
+ msg.writeInt16(channel);
connection->send(msg);
}
@@ -86,7 +86,7 @@ void Net::ChatServer::registerChannel(const std::string &name,
{
MessageOut msg(PCMSG_REGISTER_CHANNEL);
- msg.writeByte(isPrivate);
+ msg.writeInt8(isPrivate);
msg.writeString(name);
msg.writeString(announcement);
msg.writeString(password);
@@ -98,7 +98,7 @@ void Net::ChatServer::unregisterChannel(short channel)
{
MessageOut msg(PCMSG_UNREGISTER_CHANNEL);
- msg.writeShort(channel);
+ msg.writeInt16(channel);
connection->send(msg);
}
@@ -117,7 +117,7 @@ void Net::ChatServer::quitChannel(short channel)
{
MessageOut msg(PCMSG_QUIT_CHANNEL);
- msg.writeShort(channel);
+ msg.writeInt16(channel);
connection->send(msg);
}
diff --git a/src/net/gameserver/gameserver.cpp b/src/net/gameserver/gameserver.cpp
index 8f8ad8ac..e451d473 100644
--- a/src/net/gameserver/gameserver.cpp
+++ b/src/net/gameserver/gameserver.cpp
@@ -45,7 +45,7 @@ void Net::GameServer::logout(bool reconnectAccount)
{
MessageOut msg(PGMSG_DISCONNECT);
- msg.writeByte((unsigned char) reconnectAccount);
+ msg.writeInt8((unsigned char) reconnectAccount);
Net::GameServer::connection->send(msg);
}
diff --git a/src/net/gameserver/player.cpp b/src/net/gameserver/player.cpp
index 95f7dff9..bb3567d3 100644
--- a/src/net/gameserver/player.cpp
+++ b/src/net/gameserver/player.cpp
@@ -39,90 +39,90 @@ void Net::GameServer::Player::say(const std::string &text)
void Net::GameServer::Player::walk(int x, int y)
{
MessageOut msg(PGMSG_WALK);
- msg.writeShort(x);
- msg.writeShort(y);
+ msg.writeInt16(x);
+ msg.writeInt16(y);
Net::GameServer::connection->send(msg);
}
void Net::GameServer::Player::pickUp(int x, int y)
{
MessageOut msg(PGMSG_PICKUP);
- msg.writeShort(x);
- msg.writeShort(y);
+ msg.writeInt16(x);
+ msg.writeInt16(y);
Net::GameServer::connection->send(msg);
}
void Net::GameServer::Player::moveItem(int oldSlot, int newSlot, int amount)
{
MessageOut msg(PGMSG_MOVE_ITEM);
- msg.writeByte(oldSlot);
- msg.writeByte(newSlot);
- msg.writeByte(amount);
+ msg.writeInt8(oldSlot);
+ msg.writeInt8(newSlot);
+ msg.writeInt8(amount);
Net::GameServer::connection->send(msg);
}
void Net::GameServer::Player::drop(int slot, int amount)
{
MessageOut msg(PGMSG_DROP);
- msg.writeByte(slot);
- msg.writeByte(amount);
+ msg.writeInt8(slot);
+ msg.writeInt8(amount);
Net::GameServer::connection->send(msg);
}
void Net::GameServer::Player::equip(int slot)
{
MessageOut msg(PGMSG_EQUIP);
- msg.writeByte(slot);
+ msg.writeInt8(slot);
Net::GameServer::connection->send(msg);
}
void Net::GameServer::Player::unequip(int slot)
{
MessageOut msg(PGMSG_UNEQUIP);
- msg.writeByte(slot);
+ msg.writeInt8(slot);
Net::GameServer::connection->send(msg);
}
void Net::GameServer::Player::useItem(int slot)
{
MessageOut msg(PGMSG_USE_ITEM);
- msg.writeByte(slot);
+ msg.writeInt8(slot);
Net::GameServer::connection->send(msg);
}
void Net::GameServer::Player::attack(int direction)
{
MessageOut msg(PGMSG_ATTACK);
- msg.writeByte(direction);
+ msg.writeInt8(direction);
Net::GameServer::connection->send(msg);
}
void Net::GameServer::Player::changeAction(Being::Action action)
{
MessageOut msg(PGMSG_ACTION_CHANGE);
- msg.writeByte(action);
+ msg.writeInt8(action);
Net::GameServer::connection->send(msg);
}
void Net::GameServer::Player::talkToNPC(int id, bool restart)
{
MessageOut msg(restart ? PGMSG_NPC_TALK : PGMSG_NPC_TALK_NEXT);
- msg.writeShort(id);
+ msg.writeInt16(id);
Net::GameServer::connection->send(msg);
}
void Net::GameServer::Player::selectFromNPC(int id, int choice)
{
MessageOut msg(PGMSG_NPC_SELECT);
- msg.writeShort(id);
- msg.writeByte(choice);
+ msg.writeInt16(id);
+ msg.writeInt8(choice);
Net::GameServer::connection->send(msg);
}
void Net::GameServer::Player::requestTrade(int id)
{
MessageOut msg(PGMSG_TRADE_REQUEST);
- msg.writeShort(id);
+ msg.writeInt16(id);
Net::GameServer::connection->send(msg);
}
@@ -135,22 +135,22 @@ void Net::GameServer::Player::acceptTrade(bool accept)
void Net::GameServer::Player::tradeItem(int slot, int amount)
{
MessageOut msg(PGMSG_TRADE_ADD_ITEM);
- msg.writeByte(slot);
- msg.writeByte(amount);
+ msg.writeInt8(slot);
+ msg.writeInt8(amount);
Net::GameServer::connection->send(msg);
}
void Net::GameServer::Player::tradeMoney(int amount)
{
MessageOut msg(PGMSG_TRADE_SET_MONEY);
- msg.writeLong(amount);
+ msg.writeInt32(amount);
Net::GameServer::connection->send(msg);
}
void Net::GameServer::Player::tradeWithNPC(int item, int amount)
{
MessageOut msg(PGMSG_NPC_BUYSELL);
- msg.writeShort(item);
- msg.writeShort(amount);
+ msg.writeInt16(item);
+ msg.writeInt16(amount);
Net::GameServer::connection->send(msg);
}
diff --git a/src/net/inventoryhandler.cpp b/src/net/inventoryhandler.cpp
index 6fdb827d..d48a77a5 100644
--- a/src/net/inventoryhandler.cpp
+++ b/src/net/inventoryhandler.cpp
@@ -58,21 +58,21 @@ void InventoryHandler::handleMessage(MessageIn &msg)
case GPMSG_INVENTORY:
while (msg.getUnreadLength())
{
- int slot = msg.readByte();
+ int slot = msg.readInt8();
if (slot == 255)
{
- player_node->setMoney(msg.readLong());
+ player_node->setMoney(msg.readInt32());
continue;
}
- int id = msg.readShort();
+ int id = msg.readInt16();
if (slot < EQUIPMENT_SIZE)
{
player_node->mEquipment->setEquipment(slot, id);
}
else if (slot >= 32 && slot < 32 + INVENTORY_SIZE)
{
- int amount = id ? msg.readByte() : 0;
+ int amount = id ? msg.readInt8() : 0;
player_node->setInvItem(slot - 32, id, amount);
}
};
diff --git a/src/net/itemhandler.cpp b/src/net/itemhandler.cpp
index 7c4d3940..ea65bc3b 100644
--- a/src/net/itemhandler.cpp
+++ b/src/net/itemhandler.cpp
@@ -48,9 +48,9 @@ void ItemHandler::handleMessage(MessageIn &msg)
{
while (msg.getUnreadLength())
{
- int itemId = msg.readShort();
- int x = msg.readShort();
- int y = msg.readShort();
+ int itemId = msg.readInt16();
+ int x = msg.readInt16();
+ int y = msg.readInt16();
int id = (x << 16) | y; // dummy id
if (itemId)
diff --git a/src/net/loginhandler.cpp b/src/net/loginhandler.cpp
index 90f2dbd5..260c117d 100644
--- a/src/net/loginhandler.cpp
+++ b/src/net/loginhandler.cpp
@@ -45,7 +45,7 @@ void LoginHandler::handleMessage(MessageIn &msg)
{
case APMSG_LOGIN_RESPONSE:
{
- int errMsg = msg.readByte();
+ int errMsg = msg.readInt8();
// Successful login
if (errMsg == ERRMSG_OK)
{
@@ -77,7 +77,7 @@ void LoginHandler::handleMessage(MessageIn &msg)
break;
case APMSG_REGISTER_RESPONSE:
{
- int errMsg = msg.readByte();
+ int errMsg = msg.readInt8();
// Successful registration
if (errMsg == ERRMSG_OK)
{
@@ -109,7 +109,7 @@ void LoginHandler::handleMessage(MessageIn &msg)
break;
case APMSG_RECONNECT_RESPONSE:
{
- int errMsg = msg.readByte();
+ int errMsg = msg.readInt8();
// Successful login
if (errMsg == ERRMSG_OK)
{
diff --git a/src/net/logouthandler.cpp b/src/net/logouthandler.cpp
index d8b9d435..c7629490 100644
--- a/src/net/logouthandler.cpp
+++ b/src/net/logouthandler.cpp
@@ -48,7 +48,7 @@ void LogoutHandler::handleMessage(MessageIn &msg)
{
case APMSG_LOGOUT_RESPONSE:
{
- int errMsg = msg.readByte();
+ int errMsg = msg.readInt8();
// Successful logout
if (errMsg == ERRMSG_OK)
@@ -86,7 +86,7 @@ void LogoutHandler::handleMessage(MessageIn &msg)
break;
case APMSG_UNREGISTER_RESPONSE:
{
- int errMsg = msg.readByte();
+ int errMsg = msg.readInt8();
// Successful unregistration
if (errMsg == ERRMSG_OK)
{
@@ -110,7 +110,7 @@ void LogoutHandler::handleMessage(MessageIn &msg)
break;
case GPMSG_DISCONNECT_RESPONSE:
{
- int errMsg = msg.readByte();
+ int errMsg = msg.readInt8();
// Successful logout
if (errMsg == ERRMSG_OK)
{
@@ -156,7 +156,7 @@ void LogoutHandler::handleMessage(MessageIn &msg)
break;
case CPMSG_DISCONNECT_RESPONSE:
{
- int errMsg = msg.readByte();
+ int errMsg = msg.readInt8();
// Successful logout
if (errMsg == ERRMSG_OK)
{
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index e90084ff..b5d5b97a 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -33,10 +33,10 @@ MessageIn::MessageIn(const char *data, unsigned int length):
mPos(0)
{
// Read the message ID
- mId = readShort();
+ mId = readInt16();
}
-int MessageIn::readByte()
+int MessageIn::readInt8()
{
int value = -1;
if (mPos < mLength)
@@ -47,7 +47,7 @@ int MessageIn::readByte()
return value;
}
-int MessageIn::readShort()
+int MessageIn::readInt16()
{
int value = -1;
if (mPos + 2 <= mLength)
@@ -60,7 +60,7 @@ int MessageIn::readShort()
return value;
}
-int MessageIn::readLong()
+int MessageIn::readInt32()
{
int value = -1;
if (mPos + 4 <= mLength)
@@ -88,7 +88,7 @@ std::string MessageIn::readString(int length)
{
// Get string length
if (length < 0) {
- length = readShort();
+ length = readInt16();
}
// Make sure the string isn't erroneus
diff --git a/src/net/messagein.h b/src/net/messagein.h
index 37103f2c..3cc45a23 100644
--- a/src/net/messagein.h
+++ b/src/net/messagein.h
@@ -43,9 +43,9 @@ class MessageIn
int getId() { return mId; } /**< Returns the message ID. */
- int readByte(); /**< Reads a byte. */
- int readShort(); /**< Reads a short. */
- int readLong(); /**< Reads a long. */
+ int readInt8(); /**< Reads a byte. */
+ int readInt16(); /**< Reads a short. */
+ int readInt32(); /**< Reads a long. */
/**
* Reads a 3-byte block containing tile-based coordinates.
diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp
index 208196e2..10f1b1d4 100644
--- a/src/net/messageout.cpp
+++ b/src/net/messageout.cpp
@@ -33,7 +33,7 @@ MessageOut::MessageOut(short id):
mDataSize(0),
mPos(0)
{
- writeShort(id);
+ writeInt16(id);
}
MessageOut::~MessageOut()
@@ -51,14 +51,14 @@ MessageOut::expand(size_t bytes)
}
void
-MessageOut::writeByte(char value)
+MessageOut::writeInt8(char value)
{
expand(mPos + 1);
mData[mPos] = value;
mPos += 1;
}
-void MessageOut::writeShort(short value)
+void MessageOut::writeInt16(short value)
{
expand(mPos + 2);
uint16_t t = ENET_HOST_TO_NET_16(value);
@@ -67,7 +67,7 @@ void MessageOut::writeShort(short value)
}
void
-MessageOut::writeLong(long value)
+MessageOut::writeInt32(long value)
{
expand(mPos + 4);
uint32_t t = ENET_HOST_TO_NET_32(value);
@@ -82,7 +82,7 @@ MessageOut::writeString(const std::string &string, int length)
if (length < 0)
{
// Write the length at the start if not fixed
- writeShort(stringLength);
+ writeInt16(stringLength);
length = stringLength;
}
else if (length < stringLength)
diff --git a/src/net/messageout.h b/src/net/messageout.h
index 82412a30..032db190 100644
--- a/src/net/messageout.h
+++ b/src/net/messageout.h
@@ -45,9 +45,9 @@ class MessageOut
*/
~MessageOut();
- void writeByte(char value); /**< Writes a byte. */
- void writeShort(short value); /**< Writes a short. */
- void writeLong(long value); /**< Writes a long. */
+ void writeInt8(char value); /**< Writes a byte. */
+ void writeInt16(short value); /**< Writes a short. */
+ void writeInt32(long value); /**< Writes a long. */
/**
* Writes a string. If a fixed length is not given (-1), it is stored
diff --git a/src/net/npchandler.cpp b/src/net/npchandler.cpp
index 9cc93df1..a838c844 100644
--- a/src/net/npchandler.cpp
+++ b/src/net/npchandler.cpp
@@ -47,7 +47,7 @@ NPCHandler::NPCHandler()
void NPCHandler::handleMessage(MessageIn &msg)
{
- Being *being = beingManager->findBeing(msg.readShort());
+ Being *being = beingManager->findBeing(msg.readInt16());
if (!being || being->getType() != Being::NPC)
{
return;
diff --git a/src/net/playerhandler.cpp b/src/net/playerhandler.cpp
index afaeca69..f6f7a8fa 100644
--- a/src/net/playerhandler.cpp
+++ b/src/net/playerhandler.cpp
@@ -107,7 +107,7 @@ void PlayerHandler::handleMessage(MessageIn &msg)
{ // TODO: Implement reconnecting to another game server
std::string token = msg.readString(32);
std::string address = msg.readString();
- int port = msg.readShort();
+ int port = msg.readInt16();
logger->log("Changing server to %s:%d", address.c_str(), port);
} break;
@@ -116,9 +116,9 @@ void PlayerHandler::handleMessage(MessageIn &msg)
logger->log("ATTRIBUTE UPDATE:");
while (msg.getUnreadLength())
{
- int stat = msg.readByte();
- int base = msg.readShort();
- int value = msg.readShort();
+ int stat = msg.readInt8();
+ int base = msg.readInt16();
+ int value = msg.readInt16();
logger->log("%d set to %d %d", stat, base, value);
if (stat == BASE_ATTR_HP)
@@ -141,7 +141,7 @@ void PlayerHandler::handleMessage(MessageIn &msg)
/*
case SMSG_PLAYER_ARROW_MESSAGE:
{
- Sint16 type = msg.readShort();
+ Sint16 type = msg.readInt16();
switch (type) {
case 0:
@@ -162,8 +162,8 @@ void
PlayerHandler::handleMapChangeMessage(MessageIn &msg)
{
std::string mapName = msg.readString();
- unsigned short x = msg.readShort();
- unsigned short y = msg.readShort();
+ unsigned short x = msg.readInt16();
+ unsigned short y = msg.readInt16();
logger->log("Changing map to %s (%d, %d)", mapName.c_str(), x, y);
diff --git a/src/net/skillhandler.cpp b/src/net/skillhandler.cpp
index 50150ca8..8a19fe45 100644
--- a/src/net/skillhandler.cpp
+++ b/src/net/skillhandler.cpp
@@ -45,20 +45,20 @@ void SkillHandler::handleMessage(MessageIn &msg)
{
#if 0
case SMSG_PLAYER_SKILLS:
- msg.readShort(); // length
+ msg.readInt16(); // 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
+ 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)
{
@@ -76,11 +76,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.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)
{
diff --git a/src/net/tradehandler.cpp b/src/net/tradehandler.cpp
index db07b786..b659f8a4 100644
--- a/src/net/tradehandler.cpp
+++ b/src/net/tradehandler.cpp
@@ -76,7 +76,7 @@ void TradeHandler::handleMessage(MessageIn &msg)
{
case GPMSG_TRADE_REQUEST:
{
- Being *being = beingManager->findBeing(msg.readShort());
+ Being *being = beingManager->findBeing(msg.readInt16());
if (!being)
{
Net::GameServer::Player::acceptTrade(false);
@@ -92,13 +92,13 @@ void TradeHandler::handleMessage(MessageIn &msg)
case GPMSG_TRADE_ADD_ITEM:
{
- int type = msg.readShort();
- int amount = msg.readByte();
+ int type = msg.readInt16();
+ int amount = msg.readInt8();
tradeWindow->addItem(type, false, amount);
} break;
case GPMSG_TRADE_SET_MONEY:
- tradeWindow->setMoney(msg.readLong());
+ tradeWindow->setMoney(msg.readInt32());
break;
case GPMSG_TRADE_START: