summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-04-21 18:57:48 +0300
committerAndrei Karas <akaras@inbox.ru>2013-04-21 18:57:48 +0300
commit35cfd460655878c9a615abc8ea1cb2f7577a7f3b (patch)
tree2b4cb899f7f442912f89de30f4a5ab0add0727ce /src/net
parentcfe4c893ba4ba30379919636d3c508ebf1594e23 (diff)
downloadmv-35cfd460655878c9a615abc8ea1cb2f7577a7f3b.tar.gz
mv-35cfd460655878c9a615abc8ea1cb2f7577a7f3b.tar.bz2
mv-35cfd460655878c9a615abc8ea1cb2f7577a7f3b.tar.xz
mv-35cfd460655878c9a615abc8ea1cb2f7577a7f3b.zip
some other fixes from cpplint.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/ea/beinghandler.cpp6
-rw-r--r--src/net/ea/beinghandler.h2
-rw-r--r--src/net/ea/guildhandler.cpp4
-rw-r--r--src/net/ea/partyhandler.cpp4
-rw-r--r--src/net/ea/skillhandler.cpp2
-rw-r--r--src/net/eathena/beinghandler.cpp12
-rw-r--r--src/net/eathena/charserverhandler.cpp6
-rw-r--r--src/net/eathena/chathandler.cpp18
-rw-r--r--src/net/eathena/guildhandler.h4
-rw-r--r--src/net/eathena/messagehandler.h4
-rw-r--r--src/net/eathena/messagein.h4
-rw-r--r--src/net/eathena/messageout.cpp10
-rw-r--r--src/net/eathena/messageout.h10
-rw-r--r--src/net/eathena/network.cpp4
-rw-r--r--src/net/eathena/playerhandler.cpp6
-rw-r--r--src/net/eathena/playerhandler.h2
-rw-r--r--src/net/logindata.h18
-rw-r--r--src/net/messagein.cpp20
-rw-r--r--src/net/messagein.h6
-rw-r--r--src/net/messageout.cpp6
-rw-r--r--src/net/messageout.h2
-rw-r--r--src/net/playerhandler.h2
-rw-r--r--src/net/serverinfo.h2
-rw-r--r--src/net/tmwa/beinghandler.cpp6
-rw-r--r--src/net/tmwa/charserverhandler.cpp6
-rw-r--r--src/net/tmwa/chathandler.cpp20
-rw-r--r--src/net/tmwa/guildhandler.h4
-rw-r--r--src/net/tmwa/messagehandler.h4
-rw-r--r--src/net/tmwa/messagein.h4
-rw-r--r--src/net/tmwa/messageout.cpp10
-rw-r--r--src/net/tmwa/messageout.h10
-rw-r--r--src/net/tmwa/network.cpp4
-rw-r--r--src/net/tmwa/playerhandler.cpp6
-rw-r--r--src/net/tmwa/playerhandler.h2
-rw-r--r--src/net/worldinfo.h2
35 files changed, 116 insertions, 116 deletions
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index ea668589c..5726f9ed0 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -65,7 +65,7 @@ BeingHandler::BeingHandler(const bool enableSync) :
{
}
-Being *BeingHandler::createBeing(const int id, const short job) const
+Being *BeingHandler::createBeing(const int id, const int16_t job) const
{
if (!actorSpriteManager)
return nullptr;
@@ -130,11 +130,11 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg,
else
spawnId = 0;
mSpawnId = 0;
- short speed = msg.readInt16();
+ int16_t speed = msg.readInt16();
const uint16_t stunMode = msg.readInt16(); // opt1
uint32_t statusEffects = msg.readInt16(); // opt2
statusEffects |= (static_cast<uint32_t>(msg.readInt16())) << 16; // option
- const short job = msg.readInt16(); // class
+ const int16_t job = msg.readInt16(); // class
Being *dstBeing = actorSpriteManager->findBeing(id);
diff --git a/src/net/ea/beinghandler.h b/src/net/ea/beinghandler.h
index 6552e5a69..6798726bd 100644
--- a/src/net/ea/beinghandler.h
+++ b/src/net/ea/beinghandler.h
@@ -37,7 +37,7 @@ class BeingHandler : public Net::BeingHandler
A_DELETE_COPY(BeingHandler)
protected:
- virtual Being *createBeing(int id, short job) const A_WARN_UNUSED;
+ virtual Being *createBeing(int id, int16_t job) const A_WARN_UNUSED;
virtual void setSprite(Being *const being, const unsigned int slot,
const int id,
diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp
index 65fa32634..3f0375fea 100644
--- a/src/net/ea/guildhandler.cpp
+++ b/src/net/ea/guildhandler.cpp
@@ -104,7 +104,7 @@ void GuildHandler::processGuildPositionInfo(Net::MessageIn &msg) const
msg.readInt8(); // Unused
std::string guildName = msg.readString(24);
- Guild *const g = Guild::getGuild(static_cast<short int>(guildId));
+ Guild *const g = Guild::getGuild(static_cast<int16_t>(guildId));
if (!g)
return;
@@ -190,7 +190,7 @@ void GuildHandler::processGuildBasicInfo(Net::MessageIn &msg)
castle.c_str()), BY_SERVER);
}
- Guild *const g = Guild::getGuild(static_cast<short int>(guildId));
+ Guild *const g = Guild::getGuild(static_cast<int16_t>(guildId));
if (!g)
return;
g->setName(name);
diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp
index 0909232dd..a8233bbf6 100644
--- a/src/net/ea/partyhandler.cpp
+++ b/src/net/ea/partyhandler.cpp
@@ -207,8 +207,8 @@ void PartyHandler::processPartySettings(Net::MessageIn &msg)
}
// These seem to indicate the sharing mode for exp and items
- const short exp = msg.readInt16();
- const short item = msg.readInt16();
+ const int16_t exp = msg.readInt16();
+ const int16_t item = msg.readInt16();
if (!Ea::partyTab)
return;
diff --git a/src/net/ea/skillhandler.cpp b/src/net/ea/skillhandler.cpp
index 0a3054527..7fe37be95 100644
--- a/src/net/ea/skillhandler.cpp
+++ b/src/net/ea/skillhandler.cpp
@@ -124,7 +124,7 @@ void SkillHandler::processSkillFailed(Net::MessageIn &msg) const
// Action failed (ex. sit because you have not reached the
// right level)
const int skillId = msg.readInt16();
- const short bskill = msg.readInt16();
+ const int16_t bskill = msg.readInt16();
msg.readInt16(); // btype
const signed char success = msg.readInt8();
const signed char reason = msg.readInt8();
diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp
index 76f2cd7cc..71a098510 100644
--- a/src/net/eathena/beinghandler.cpp
+++ b/src/net/eathena/beinghandler.cpp
@@ -432,12 +432,12 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg,
// An update about a player, potentially including movement.
const int id = msg.readInt32();
- const short speed = msg.readInt16();
+ const int16_t speed = msg.readInt16();
const uint16_t stunMode = msg.readInt16(); // opt1
uint32_t statusEffects = msg.readInt16(); // opt2
statusEffects |= (static_cast<uint32_t>(msg.readInt16()))
<< 16; // status.options; Aethyra uses this as misc2
- const short job = msg.readInt16();
+ const int16_t job = msg.readInt16();
Being *dstBeing = actorSpriteManager->findBeing(id);
@@ -492,7 +492,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg,
if (guild == 0)
dstBeing->clearGuilds();
else
- dstBeing->setGuild(Guild::getGuild(static_cast<short>(guild)));
+ dstBeing->setGuild(Guild::getGuild(static_cast<int16_t>(guild)));
}
msg.readInt16(); // emblem
@@ -634,11 +634,11 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg,
else
spawnId = 0;
mSpawnId = 0;
- short speed = msg.readInt16();
+ int16_t speed = msg.readInt16();
const uint16_t stunMode = msg.readInt16(); // opt1
uint32_t statusEffects = msg.readInt16(); // opt2
statusEffects |= (static_cast<uint32_t>(msg.readInt16())) << 16; // option
- const short job = msg.readInt16(); // class
+ const int16_t job = msg.readInt16(); // class
Being *dstBeing = actorSpriteManager->findBeing(id);
@@ -725,7 +725,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg,
msg.readInt16(); // manner
dstBeing->setStatusEffectBlock(32, msg.readInt16()); // opt3
msg.readInt8(); // karma
- short gender = msg.readInt8();
+ int16_t gender = msg.readInt8();
if (dstBeing->getType() == ActorSprite::PLAYER)
{
diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp
index ffb83ea73..6fafb3aa0 100644
--- a/src/net/eathena/charserverhandler.cpp
+++ b/src/net/eathena/charserverhandler.cpp
@@ -222,8 +222,8 @@ void CharServerHandler::newCharacter(const std::string &name, const int slot,
outMsg.writeInt8(static_cast<unsigned char>(stats[i]));
outMsg.writeInt8(static_cast<unsigned char>(slot));
- outMsg.writeInt16(static_cast<short>(hairColor));
- outMsg.writeInt16(static_cast<short>(hairstyle));
+ outMsg.writeInt16(static_cast<int16_t>(hairColor));
+ outMsg.writeInt16(static_cast<int16_t>(hairstyle));
}
void CharServerHandler::deleteCharacter(Net::Character *const character)
@@ -271,7 +271,7 @@ void CharServerHandler::processCharLogin(Net::MessageIn &msg)
msg.skip(2); // Length word
const int slots = msg.readInt16();
if (slots > 0 && slots < 30)
- loginData.characterSlots = static_cast<short unsigned int>(slots);
+ loginData.characterSlots = static_cast<uint16_t>(slots);
msg.skip(18); // 0 Unused
diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp
index 940227b3c..eae8e7ffc 100644
--- a/src/net/eathena/chathandler.cpp
+++ b/src/net/eathena/chathandler.cpp
@@ -113,7 +113,7 @@ void ChatHandler::talk(const std::string &text,
MessageOut outMsg(CMSG_CHAT_MESSAGE);
// Added + 1 in order to let eAthena parse admin commands correctly
- outMsg.writeInt16(static_cast<short>(mes.length() + 4 + 1));
+ outMsg.writeInt16(static_cast<int16_t>(mes.length() + 4 + 1));
outMsg.writeString(mes, static_cast<int>(mes.length() + 1));
}
@@ -121,7 +121,7 @@ void ChatHandler::talkRaw(const std::string &mes) const
{
MessageOut outMsg(CMSG_CHAT_MESSAGE);
// Added + 1 in order to let eAthena parse admin commands correctly
- outMsg.writeInt16(static_cast<short>(mes.length() + 4 + 1));
+ outMsg.writeInt16(static_cast<int16_t>(mes.length() + 4 + 1));
outMsg.writeString(mes, static_cast<int>(mes.length() + 1));
}
@@ -129,7 +129,7 @@ void ChatHandler::privateMessage(const std::string &recipient,
const std::string &text)
{
MessageOut outMsg(CMSG_CHAT_WHISPER);
- outMsg.writeInt16(static_cast<short>(text.length() + 28));
+ outMsg.writeInt16(static_cast<int16_t>(text.length() + 28));
outMsg.writeString(recipient, 24);
outMsg.writeString(text, static_cast<int>(text.length()));
mSentWhispers.push(recipient);
@@ -153,13 +153,13 @@ void ChatHandler::sendRaw(const std::string &args) const
if (pos != std::string::npos)
{
str = line.substr(0, pos);
- outMsg = new MessageOut(static_cast<short>(atoi(str.c_str())));
+ outMsg = new MessageOut(static_cast<int16_t>(atoi(str.c_str())));
line = line.substr(pos + 1);
pos = line.find(" ");
}
else
{
- outMsg = new MessageOut(static_cast<short>(atoi(line.c_str())));
+ outMsg = new MessageOut(static_cast<int16_t>(atoi(line.c_str())));
delete outMsg;
return;
}
@@ -185,7 +185,7 @@ void ChatHandler::processRaw(MessageOut &outMsg, const std::string &line)
if (line.length() <= 3)
outMsg.writeInt8(static_cast<unsigned char>(i));
else if (line.length() <= 5)
- outMsg.writeInt16(static_cast<short>(i));
+ outMsg.writeInt16(static_cast<int16_t>(i));
else
outMsg.writeInt32(i);
}
@@ -215,7 +215,7 @@ void ChatHandler::processRaw(MessageOut &outMsg, const std::string &line)
outMsg.writeInt8(static_cast<unsigned char>(i));
break;
case '2':
- outMsg.writeInt16(static_cast<short>(i));
+ outMsg.writeInt16(static_cast<int16_t>(i));
break;
case '4':
outMsg.writeInt32(i);
@@ -225,14 +225,14 @@ void ChatHandler::processRaw(MessageOut &outMsg, const std::string &line)
pos = line.find(",");
if (pos != std::string::npos)
{
- const unsigned short x = static_cast<unsigned short>(
+ const uint16_t x = static_cast<uint16_t>(
atoi(data.substr(0, pos).c_str()));
data = data.substr(pos + 1);
pos = line.find(",");
if (pos == std::string::npos)
break;
- const unsigned short y = static_cast<unsigned short>(
+ const uint16_t y = static_cast<uint16_t>(
atoi(data.substr(0, pos).c_str()));
const int dir = atoi(data.substr(pos + 1).c_str());
outMsg.writeCoordinates(x, y,
diff --git a/src/net/eathena/guildhandler.h b/src/net/eathena/guildhandler.h
index ad6a12aee..9d612c474 100644
--- a/src/net/eathena/guildhandler.h
+++ b/src/net/eathena/guildhandler.h
@@ -72,6 +72,6 @@ class GuildHandler final : public Ea::GuildHandler, public MessageHandler
extern Ea::GuildTab *guildTab;
extern Guild *taGuild;
-}
+} // namespace EAthena
-#endif // namespace EAthena
+#endif
diff --git a/src/net/eathena/messagehandler.h b/src/net/eathena/messagehandler.h
index 0139f0ee2..33216dca7 100644
--- a/src/net/eathena/messagehandler.h
+++ b/src/net/eathena/messagehandler.h
@@ -56,6 +56,6 @@ class MessageHandler : public Net::MessageHandler
typedef const std::auto_ptr<MessageHandler> MessageHandlerPtr;
-}
+} // namespace EAthena
-#endif // namespace EAthena
+#endif
diff --git a/src/net/eathena/messagein.h b/src/net/eathena/messagein.h
index 59faa7750..8c465a90b 100644
--- a/src/net/eathena/messagein.h
+++ b/src/net/eathena/messagein.h
@@ -52,6 +52,6 @@ class MessageIn final : public Net::MessageIn
int32_t readInt32(); /**< Reads a long. */
};
-}
+} // namespace EAthena
-#endif // namespace EAthena
+#endif
diff --git a/src/net/eathena/messageout.cpp b/src/net/eathena/messageout.cpp
index 210717503..6dc2e00f4 100644
--- a/src/net/eathena/messageout.cpp
+++ b/src/net/eathena/messageout.cpp
@@ -39,7 +39,7 @@
namespace EAthena
{
-MessageOut::MessageOut(const short id):
+MessageOut::MessageOut(const int16_t id):
Net::MessageOut(id),
mNetwork(EAthena::Network::instance())
{
@@ -85,10 +85,10 @@ void MessageOut::writeInt32(const int32_t value)
#define LOBYTE(w) (static_cast<unsigned char>(w))
#define HIBYTE(w) (static_cast<unsigned char>(( \
-static_cast<unsigned short>(w)) >> 8))
+static_cast<uint16_t>(w)) >> 8))
-void MessageOut::writeCoordinates(const unsigned short x,
- const unsigned short y,
+void MessageOut::writeCoordinates(const uint16_t x,
+ const uint16_t y,
unsigned char direction)
{
DEBUGLOG(strprintf("writeCoordinates: %u,%u %u", x, y, direction));
@@ -96,7 +96,7 @@ void MessageOut::writeCoordinates(const unsigned short x,
mNetwork->mOutSize += 3;
mPos += 3;
- short temp = x;
+ int16_t temp = x;
temp <<= 6;
data[0] = 0;
data[1] = 1;
diff --git a/src/net/eathena/messageout.h b/src/net/eathena/messageout.h
index ad1a9bfde..c76eae4c1 100644
--- a/src/net/eathena/messageout.h
+++ b/src/net/eathena/messageout.h
@@ -46,7 +46,7 @@ class MessageOut final : public Net::MessageOut
/**
* Constructor.
*/
- explicit MessageOut(const short id);
+ explicit MessageOut(const int16_t id);
A_DELETE_COPY(MessageOut)
@@ -57,8 +57,8 @@ class MessageOut final : public Net::MessageOut
/**
* Encodes coordinates and direction in 3 bytes.
*/
- void writeCoordinates(const unsigned short x,
- const unsigned short y,
+ void writeCoordinates(const uint16_t x,
+ const uint16_t y,
unsigned char direction);
void resetPos()
@@ -70,6 +70,6 @@ class MessageOut final : public Net::MessageOut
Network *mNetwork;
};
-}
+} // namespace EAthena
-#endif // namespace EAthena
+#endif
diff --git a/src/net/eathena/network.cpp b/src/net/eathena/network.cpp
index 1b234a13c..198c61bd4 100644
--- a/src/net/eathena/network.cpp
+++ b/src/net/eathena/network.cpp
@@ -40,7 +40,7 @@ namespace EAthena
/** Warning: buffers and other variables are shared,
so there can be only one connection active at a time */
-short packet_lengths[] =
+int16_t packet_lengths[] =
{
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -109,7 +109,7 @@ short packet_lengths[] =
};
static const int packet_lengths_size
- = static_cast<int>(sizeof(packet_lengths) / sizeof(short));
+ = static_cast<int>(sizeof(packet_lengths) / sizeof(int16_t));
static const int messagesSize = 0xffff;
Network *Network::mInstance = nullptr;
diff --git a/src/net/eathena/playerhandler.cpp b/src/net/eathena/playerhandler.cpp
index c5f3c3a0f..4897e6b70 100644
--- a/src/net/eathena/playerhandler.cpp
+++ b/src/net/eathena/playerhandler.cpp
@@ -146,7 +146,7 @@ void PlayerHandler::increaseAttribute(const int attr) const
}
}
-void PlayerHandler::increaseSkill(const unsigned short skillId) const
+void PlayerHandler::increaseSkill(const uint16_t skillId) const
{
if (PlayerInfo::getAttribute(PlayerInfo::SKILL_POINTS) <= 0)
return;
@@ -179,8 +179,8 @@ void PlayerHandler::setDestination(const int x, const int y,
const int direction) const
{
MessageOut outMsg(CMSG_PLAYER_CHANGE_DEST);
- outMsg.writeCoordinates(static_cast<short unsigned int>(x),
- static_cast<short unsigned int>(y),
+ outMsg.writeCoordinates(static_cast<uint16_t>(x),
+ static_cast<uint16_t>(y),
static_cast<unsigned char>(direction));
}
diff --git a/src/net/eathena/playerhandler.h b/src/net/eathena/playerhandler.h
index 6cea52890..4ea630a60 100644
--- a/src/net/eathena/playerhandler.h
+++ b/src/net/eathena/playerhandler.h
@@ -47,7 +47,7 @@ class PlayerHandler final : public MessageHandler, public Ea::PlayerHandler
void emote(const uint8_t emoteId) const override;
void increaseAttribute(const int attr) const override;
- void increaseSkill(const unsigned short skillId) const override;
+ void increaseSkill(const uint16_t skillId) const override;
void pickUp(const FloorItem *const floorItem) const override;
void setDirection(const unsigned char direction) const override;
diff --git a/src/net/logindata.h b/src/net/logindata.h
index 6e133b267..5611a9bc8 100644
--- a/src/net/logindata.h
+++ b/src/net/logindata.h
@@ -31,16 +31,16 @@ class LoginData final
{
public:
LoginData() :
- username(""),
- password(""),
- newPassword(""),
- updateHost(""),
+ username(),
+ password(),
+ newPassword(),
+ updateHost(),
updateHosts(),
lastLogin(),
updateType(0),
- email(""),
- captchaResponse(""),
- registerUrl(""),
+ email(),
+ captchaResponse(),
+ registerUrl(),
gender(GENDER_UNSPECIFIED),
remember(false),
registerLogin(false),
@@ -75,7 +75,7 @@ class LoginData final
bool remember; // Whether to store the username.
bool registerLogin; // Whether an account is being registered.
- unsigned short characterSlots; // The number of character slots
+ uint16_t characterSlots; // The number of character slots
void clear()
{
@@ -104,7 +104,7 @@ class LoginData final
*/
void resetCharacterSlots()
{
- characterSlots = 9; // Default value, used for TmwAthena.
+ characterSlots = 9; // Default value, used for TmwAthena.
}
};
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index 4ea6c7415..cca7eee01 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -30,8 +30,8 @@
#include "debug.h"
#define MAKEWORD(low, high) \
- (static_cast<unsigned short>((static_cast<unsigned char>(low)) | \
- (static_cast<unsigned short>(static_cast<unsigned char>(high))) << 8))
+ (static_cast<uint16_t>((static_cast<unsigned char>(low)) | \
+ (static_cast<uint16_t>(static_cast<unsigned char>(high))) << 8))
namespace Net
{
@@ -64,8 +64,8 @@ void MessageIn::readCoordinates(uint16_t &x, uint16_t &y)
{
const unsigned char *const p
= reinterpret_cast<unsigned char const *const>(mData + mPos);
- x = static_cast<short unsigned>(p[0] | ((p[1] & 0x07) << 8));
- y = static_cast<short unsigned>((p[1] >> 3) | ((p[2] & 0x3F) << 5));
+ x = static_cast<uint16_t>(p[0] | ((p[1] & 0x07) << 8));
+ y = static_cast<uint16_t>((p[1] >> 3) | ((p[2] & 0x3F) << 5));
}
mPos += 3;
PacketCounters::incInBytes(3);
@@ -114,9 +114,9 @@ void MessageIn::readCoordinates(uint16_t &x, uint16_t &y, uint8_t &direction)
{
const char *const data = mData + mPos;
int16_t temp = MAKEWORD(data[1] & 0x00c0, data[0] & 0x00ff);
- x = static_cast<unsigned short>(temp >> 6);
+ x = static_cast<uint16_t>(temp >> 6);
temp = MAKEWORD(data[2] & 0x00f0, data[1] & 0x003f);
- y = static_cast<unsigned short>(temp >> 4);
+ y = static_cast<uint16_t>(temp >> 4);
serverDir = static_cast<uint8_t>(data[2] & 0x000f);
direction = fromServerDirection(serverDir);
@@ -136,15 +136,15 @@ void MessageIn::readCoordinatePair(uint16_t &srcX, uint16_t &srcY,
{
const char *const data = mData + mPos;
int16_t temp = MAKEWORD(data[3], data[2] & 0x000f);
- dstX = static_cast<unsigned short>(temp >> 2);
+ dstX = static_cast<uint16_t>(temp >> 2);
dstY = MAKEWORD(data[4], data[3] & 0x0003);
temp = MAKEWORD(data[1], data[0]);
- srcX = static_cast<unsigned short>(temp >> 6);
+ srcX = static_cast<uint16_t>(temp >> 6);
temp = MAKEWORD(data[2], data[1] & 0x003f);
- srcY = static_cast<unsigned short>(temp >> 4);
+ srcY = static_cast<uint16_t>(temp >> 4);
}
mPos += 5;
DEBUGLOG(std::string("readCoordinatePair: ").append(toString(
@@ -215,7 +215,7 @@ std::string MessageIn::readRawString(int length)
if (stringEnd)
{
- const long len2 = length - (stringEnd - stringBeg) - 1;
+ const size_t len2 = length - (stringEnd - stringBeg) - 1;
const char *const stringBeg2 = stringEnd + 1;
const char *const stringEnd2
= static_cast<const char *const>(memchr(stringBeg2, '\0', len2));
diff --git a/src/net/messagein.h b/src/net/messagein.h
index ecd6e2dea..3ed723360 100644
--- a/src/net/messagein.h
+++ b/src/net/messagein.h
@@ -114,9 +114,9 @@ class MessageIn
*/
MessageIn(const char *data, unsigned int length);
- const char *mData; /**< The message data. */
- unsigned int mLength; /**< The length of the data. */
- unsigned short mId; /**< The message ID. */
+ const char *mData; /**< The message data. */
+ unsigned int mLength; /**< The length of the data. */
+ uint16_t mId; /**< The message ID. */
/**
* Actual position in the packet. From 0 to packet->length.
diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp
index 76e2085ee..cb948cdd5 100644
--- a/src/net/messageout.cpp
+++ b/src/net/messageout.cpp
@@ -36,7 +36,7 @@
namespace Net
{
-MessageOut::MessageOut(short id A_UNUSED):
+MessageOut::MessageOut(int16_t id A_UNUSED):
mData(nullptr),
mDataSize(0),
mPos(0)
@@ -60,7 +60,7 @@ void MessageOut::writeString(const std::string &string, int length)
if (length < 0)
{
// Write the length at the start if not fixed
- writeInt16(static_cast<short>(stringLength));
+ writeInt16(static_cast<int16_t>(stringLength));
length = stringLength;
}
else if (length < stringLength)
@@ -88,7 +88,7 @@ void MessageOut::writeStringNoLog(const std::string &string, int length)
if (length < 0)
{
// Write the length at the start if not fixed
- writeInt16(static_cast<short>(stringLength));
+ writeInt16(static_cast<int16_t>(stringLength));
length = stringLength;
}
else if (length < stringLength)
diff --git a/src/net/messageout.h b/src/net/messageout.h
index 4b8ef5fe3..f4b32191b 100644
--- a/src/net/messageout.h
+++ b/src/net/messageout.h
@@ -79,7 +79,7 @@ class MessageOut
/**
* Constructor.
*/
- explicit MessageOut(short id);
+ explicit MessageOut(int16_t id);
/**
* Expand the packet data to be able to hold more data.
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
index ad3d50f4a..d3b9dd6c3 100644
--- a/src/net/playerhandler.h
+++ b/src/net/playerhandler.h
@@ -46,7 +46,7 @@ class PlayerHandler
virtual void decreaseAttribute(const int attr) const = 0;
- virtual void increaseSkill(const unsigned short skillId) const = 0;
+ virtual void increaseSkill(const uint16_t skillId) const = 0;
virtual void pickUp(const FloorItem *const floorItem) const = 0;
diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h
index 114295560..cd16a1ffb 100644
--- a/src/net/serverinfo.h
+++ b/src/net/serverinfo.h
@@ -47,7 +47,7 @@ public:
Type type;
std::string name;
std::string hostname;
- unsigned short port;
+ uint16_t port;
std::string description;
std::string registerUrl;
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index d70dfb16d..35f2ded57 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -433,12 +433,12 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg,
// An update about a player, potentially including movement.
const int id = msg.readInt32();
- const short speed = msg.readInt16();
+ const int16_t speed = msg.readInt16();
const uint16_t stunMode = msg.readInt16(); // opt1;
uint32_t statusEffects = msg.readInt16(); // opt2;
statusEffects |= (static_cast<uint32_t>(msg.readInt16()))
<< 16; // status.options; Aethyra uses this as misc2
- const short job = msg.readInt16();
+ const int16_t job = msg.readInt16();
Being *dstBeing = actorSpriteManager->findBeing(id);
@@ -495,7 +495,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg,
if (guild == 0)
dstBeing->clearGuilds();
else
- dstBeing->setGuild(Guild::getGuild(static_cast<short>(guild)));
+ dstBeing->setGuild(Guild::getGuild(static_cast<int16_t>(guild)));
}
msg.readInt16(); // emblem
diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp
index 3a72ffa03..773a9d060 100644
--- a/src/net/tmwa/charserverhandler.cpp
+++ b/src/net/tmwa/charserverhandler.cpp
@@ -253,8 +253,8 @@ void CharServerHandler::newCharacter(const std::string &name, const int slot,
outMsg.writeInt8(static_cast<unsigned char>(stats[i]));
outMsg.writeInt8(static_cast<unsigned char>(slot));
- outMsg.writeInt16(static_cast<short>(hairColor));
- outMsg.writeInt16(static_cast<short>(hairstyle));
+ outMsg.writeInt16(static_cast<int16_t>(hairColor));
+ outMsg.writeInt16(static_cast<int16_t>(hairstyle));
if (serverVersion >= 2)
outMsg.writeInt8(race);
}
@@ -309,7 +309,7 @@ void CharServerHandler::processCharLogin(Net::MessageIn &msg)
msg.skip(2); // Length word
const int slots = msg.readInt16();
if (slots > 0 && slots < 30)
- loginData.characterSlots = static_cast<short unsigned int>(slots);
+ loginData.characterSlots = static_cast<uint16_t>(slots);
const bool version = msg.readInt8() == 1 && serverVersion > 0;
msg.skip(17); // 0 Unused
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp
index 6610dec26..8c455a186 100644
--- a/src/net/tmwa/chathandler.cpp
+++ b/src/net/tmwa/chathandler.cpp
@@ -129,7 +129,7 @@ void ChatHandler::talk(const std::string &text,
{
MessageOut outMsg(CMSG_CHAT_MESSAGE2);
// Added + 1 in order to let eAthena parse admin commands correctly
- outMsg.writeInt16(static_cast<short>(mes.length() + 4 + 3 + 1));
+ outMsg.writeInt16(static_cast<int16_t>(mes.length() + 4 + 3 + 1));
outMsg.writeInt8(channel[0]);
outMsg.writeInt8(channel[1]);
outMsg.writeInt8(channel[2]);
@@ -139,7 +139,7 @@ void ChatHandler::talk(const std::string &text,
{
MessageOut outMsg(CMSG_CHAT_MESSAGE);
// Added + 1 in order to let eAthena parse admin commands correctly
- outMsg.writeInt16(static_cast<short>(mes.length() + 4 + 1));
+ outMsg.writeInt16(static_cast<int16_t>(mes.length() + 4 + 1));
outMsg.writeString(mes, static_cast<int>(mes.length() + 1));
}
}
@@ -148,7 +148,7 @@ void ChatHandler::talkRaw(const std::string &mes) const
{
MessageOut outMsg(CMSG_CHAT_MESSAGE);
// Added + 1 in order to let eAthena parse admin commands correctly
- outMsg.writeInt16(static_cast<short>(mes.length() + 4 + 1));
+ outMsg.writeInt16(static_cast<int16_t>(mes.length() + 4 + 1));
outMsg.writeString(mes, static_cast<int>(mes.length() + 1));
}
@@ -156,7 +156,7 @@ void ChatHandler::privateMessage(const std::string &recipient,
const std::string &text)
{
MessageOut outMsg(CMSG_CHAT_WHISPER);
- outMsg.writeInt16(static_cast<short>(text.length() + 28));
+ outMsg.writeInt16(static_cast<int16_t>(text.length() + 28));
outMsg.writeString(recipient, 24);
outMsg.writeString(text, static_cast<int>(text.length()));
mSentWhispers.push(recipient);
@@ -180,13 +180,13 @@ void ChatHandler::sendRaw(const std::string &args) const
if (pos != std::string::npos)
{
str = line.substr(0, pos);
- outMsg = new MessageOut(static_cast<short>(atoi(str.c_str())));
+ outMsg = new MessageOut(static_cast<int16_t>(atoi(str.c_str())));
line = line.substr(pos + 1);
pos = line.find(" ");
}
else
{
- outMsg = new MessageOut(static_cast<short>(atoi(line.c_str())));
+ outMsg = new MessageOut(static_cast<int16_t>(atoi(line.c_str())));
delete outMsg;
return;
}
@@ -212,7 +212,7 @@ void ChatHandler::processRaw(MessageOut &outMsg, const std::string &line)
if (line.length() <= 3)
outMsg.writeInt8(static_cast<unsigned char>(i));
else if (line.length() <= 5)
- outMsg.writeInt16(static_cast<short>(i));
+ outMsg.writeInt16(static_cast<int16_t>(i));
else
outMsg.writeInt32(i);
}
@@ -241,7 +241,7 @@ void ChatHandler::processRaw(MessageOut &outMsg, const std::string &line)
outMsg.writeInt8(static_cast<unsigned char>(i));
break;
case '2':
- outMsg.writeInt16(static_cast<short>(i));
+ outMsg.writeInt16(static_cast<int16_t>(i));
break;
case '4':
outMsg.writeInt32(i);
@@ -251,14 +251,14 @@ void ChatHandler::processRaw(MessageOut &outMsg, const std::string &line)
pos = line.find(",");
if (pos != std::string::npos)
{
- const unsigned short x = static_cast<const unsigned short>(
+ const uint16_t x = static_cast<const uint16_t>(
atoi(data.substr(0, pos).c_str()));
data = data.substr(pos + 1);
pos = line.find(",");
if (pos == std::string::npos)
break;
- const unsigned short y = static_cast<const unsigned short>(
+ const uint16_t y = static_cast<const uint16_t>(
atoi(data.substr(0, pos).c_str()));
const int dir = atoi(data.substr(pos + 1).c_str());
outMsg.writeCoordinates(x, y,
diff --git a/src/net/tmwa/guildhandler.h b/src/net/tmwa/guildhandler.h
index d084350f2..98dcff784 100644
--- a/src/net/tmwa/guildhandler.h
+++ b/src/net/tmwa/guildhandler.h
@@ -72,6 +72,6 @@ class GuildHandler final : public Ea::GuildHandler, public MessageHandler
extern Ea::GuildTab *guildTab;
extern Guild *taGuild;
-}
+} // namespace TmwAthena
-#endif // namespace TmwAthena
+#endif
diff --git a/src/net/tmwa/messagehandler.h b/src/net/tmwa/messagehandler.h
index 9fd27c8ed..70d8dc3f7 100644
--- a/src/net/tmwa/messagehandler.h
+++ b/src/net/tmwa/messagehandler.h
@@ -56,6 +56,6 @@ class MessageHandler : public Net::MessageHandler
typedef const std::auto_ptr<MessageHandler> MessageHandlerPtr;
-}
+} // namespace TmwAthena
-#endif // namespace TmwAthena
+#endif
diff --git a/src/net/tmwa/messagein.h b/src/net/tmwa/messagein.h
index 6fc337ae3..8178e8aa0 100644
--- a/src/net/tmwa/messagein.h
+++ b/src/net/tmwa/messagein.h
@@ -52,6 +52,6 @@ class MessageIn final : public Net::MessageIn
int32_t readInt32(); /**< Reads a long. */
};
-}
+} // namespace TmwAthena
-#endif // namespace TmwAthena
+#endif
diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp
index b0fff0292..2fc0ff2d9 100644
--- a/src/net/tmwa/messageout.cpp
+++ b/src/net/tmwa/messageout.cpp
@@ -39,7 +39,7 @@
namespace TmwAthena
{
-MessageOut::MessageOut(const short id):
+MessageOut::MessageOut(const int16_t id):
Net::MessageOut(id),
mNetwork(TmwAthena::Network::instance())
{
@@ -85,10 +85,10 @@ void MessageOut::writeInt32(const int32_t value)
#define LOBYTE(w) (static_cast<unsigned char>(w))
#define HIBYTE(w) (static_cast<unsigned char>(( \
-static_cast<unsigned short>(w)) >> 8))
+static_cast<uint16_t>(w)) >> 8))
-void MessageOut::writeCoordinates(const unsigned short x,
- const unsigned short y,
+void MessageOut::writeCoordinates(const uint16_t x,
+ const uint16_t y,
unsigned char direction)
{
DEBUGLOG(strprintf("writeCoordinates: %u,%u %u",
@@ -98,7 +98,7 @@ void MessageOut::writeCoordinates(const unsigned short x,
mNetwork->mOutSize += 3;
mPos += 3;
- short temp = x;
+ int16_t temp = x;
temp <<= 6;
data[0] = 0;
data[1] = 1;
diff --git a/src/net/tmwa/messageout.h b/src/net/tmwa/messageout.h
index 22a6ae458..119425257 100644
--- a/src/net/tmwa/messageout.h
+++ b/src/net/tmwa/messageout.h
@@ -46,7 +46,7 @@ class MessageOut final : public Net::MessageOut
/**
* Constructor.
*/
- explicit MessageOut(const short id);
+ explicit MessageOut(const int16_t id);
A_DELETE_COPY(MessageOut)
@@ -57,8 +57,8 @@ class MessageOut final : public Net::MessageOut
/**
* Encodes coordinates and direction in 3 bytes.
*/
- void writeCoordinates(const unsigned short x,
- const unsigned short y,
+ void writeCoordinates(const uint16_t x,
+ const uint16_t y,
unsigned char direction);
void resetPos()
@@ -70,6 +70,6 @@ class MessageOut final : public Net::MessageOut
Network *mNetwork;
};
-}
+} // namespace TmwAthena
-#endif // namespace TmwAthena
+#endif
diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp
index dd752af72..417a3633e 100644
--- a/src/net/tmwa/network.cpp
+++ b/src/net/tmwa/network.cpp
@@ -39,7 +39,7 @@ namespace TmwAthena
/** Warning: buffers and other variables are shared,
so there can be only one connection active at a time */
-short packet_lengths[] =
+int16_t packet_lengths[] =
{
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -87,7 +87,7 @@ short packet_lengths[] =
};
static const int packet_lengths_size
- = static_cast<int>(sizeof(packet_lengths) / sizeof(short));
+ = static_cast<int>(sizeof(packet_lengths) / sizeof(int16_t));
static const int messagesSize = 0xffff;
Network *Network::mInstance = nullptr;
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index dd05e1b03..7ce018738 100644
--- a/src/net/tmwa/playerhandler.cpp
+++ b/src/net/tmwa/playerhandler.cpp
@@ -143,7 +143,7 @@ void PlayerHandler::increaseAttribute(const int attr) const
}
}
-void PlayerHandler::increaseSkill(const unsigned short skillId) const
+void PlayerHandler::increaseSkill(const uint16_t skillId) const
{
if (PlayerInfo::getAttribute(PlayerInfo::SKILL_POINTS) <= 0)
return;
@@ -176,8 +176,8 @@ void PlayerHandler::setDestination(const int x, const int y,
const int direction) const
{
MessageOut outMsg(CMSG_PLAYER_CHANGE_DEST);
- outMsg.writeCoordinates(static_cast<short unsigned int>(x),
- static_cast<short unsigned int>(y),
+ outMsg.writeCoordinates(static_cast<uint16_t>(x),
+ static_cast<uint16_t>(y),
static_cast<unsigned char>(direction));
}
diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h
index a0c355c40..5e15f5a3a 100644
--- a/src/net/tmwa/playerhandler.h
+++ b/src/net/tmwa/playerhandler.h
@@ -47,7 +47,7 @@ class PlayerHandler final : public MessageHandler, public Ea::PlayerHandler
void emote(const uint8_t emoteId) const override;
void increaseAttribute(const int attr) const override;
- void increaseSkill(const unsigned short skillId) const override;
+ void increaseSkill(const uint16_t skillId) const override;
void pickUp(const FloorItem *const floorItem) const override;
void setDirection(const unsigned char direction) const override;
diff --git a/src/net/worldinfo.h b/src/net/worldinfo.h
index ebc45343a..a9a8c6b4a 100644
--- a/src/net/worldinfo.h
+++ b/src/net/worldinfo.h
@@ -39,7 +39,7 @@ struct WorldInfo final
int address;
std::string name;
- short port;
+ uint16_t port;
int online_users;
std::string updateHost;
};