summaryrefslogtreecommitdiff
path: root/src/net/eathena
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-09-02 14:05:30 +0300
committerAndrei Karas <akaras@inbox.ru>2012-09-02 14:05:30 +0300
commit962f182fcc989ec587282e44f889188ce241ba31 (patch)
treeda100971ec4952d0c56cb404862099c670bcfe0e /src/net/eathena
parent4df121e6dcdf53436f50ce81dd60096ce0138a2c (diff)
downloadplus-962f182fcc989ec587282e44f889188ce241ba31.tar.gz
plus-962f182fcc989ec587282e44f889188ce241ba31.tar.bz2
plus-962f182fcc989ec587282e44f889188ce241ba31.tar.xz
plus-962f182fcc989ec587282e44f889188ce241ba31.zip
Add const to more classes.
Diffstat (limited to 'src/net/eathena')
-rw-r--r--src/net/eathena/beinghandler.cpp30
-rw-r--r--src/net/eathena/buysellhandler.cpp10
-rw-r--r--src/net/eathena/charserverhandler.cpp40
-rw-r--r--src/net/eathena/chathandler.cpp8
-rw-r--r--src/net/eathena/guildhandler.cpp3
-rw-r--r--src/net/eathena/messageout.cpp2
-rw-r--r--src/net/eathena/network.cpp8
-rw-r--r--src/net/eathena/npchandler.cpp4
-rw-r--r--src/net/eathena/partyhandler.cpp5
-rw-r--r--src/net/eathena/playerhandler.cpp2
10 files changed, 58 insertions, 54 deletions
diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp
index cfe90f198..eb2ce5f74 100644
--- a/src/net/eathena/beinghandler.cpp
+++ b/src/net/eathena/beinghandler.cpp
@@ -267,7 +267,7 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, bool look2)
if (!(dstBeing = actorSpriteManager->findBeing(msg.readInt32())))
return;
- int type = msg.readInt8();
+ const int type = msg.readInt8();
int id = 0;
int id2 = 0;
std::string color;
@@ -391,8 +391,8 @@ void BeingHandler::processNameResponse2(Net::MessageIn &msg)
Being *dstBeing;
- int len = msg.readInt16();
- int beingId = msg.readInt32();
+ const int len = msg.readInt16();
+ const int beingId = msg.readInt32();
std::string str = msg.readString(len - 8);
if ((dstBeing = actorSpriteManager->findBeing(beingId)))
{
@@ -411,10 +411,10 @@ void BeingHandler::processNameResponse2(Net::MessageIn &msg)
if (player_node)
{
- Party *party = player_node->getParty();
+ const Party *const party = player_node->getParty();
if (party && party->isMember(dstBeing->getId()))
{
- PartyMember *member = party->getMember(
+ PartyMember *const member = party->getMember(
dstBeing->getId());
if (member)
@@ -440,14 +440,14 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType)
int hairStyle, hairColor;
// An update about a player, potentially including movement.
- int id = msg.readInt32();
- short speed = msg.readInt16();
- uint16_t stunMode = msg.readInt16(); // opt1; Aethyra use this as cape
- uint32_t statusEffects = msg.readInt16(); // opt2;
- // Aethyra use this as misc1
+ const int id = msg.readInt32();
+ const short 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
- short job = msg.readInt16();
+ const short job = msg.readInt16();
dstBeing = actorSpriteManager->findBeing(id);
@@ -469,7 +469,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType)
dstBeing->setDirection(dir);
}
- if (Party *party = player_node->getParty())
+ if (Party *const party = player_node->getParty())
{
if (party->isMember(id))
dstBeing->setParty(party);
@@ -545,7 +545,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType)
if (srcX != dstX || srcY != dstY)
{
- int d = dstBeing->calcDirection(dstX, dstY);
+ const int d = dstBeing->calcDirection(dstX, dstY);
if (d && dstBeing->getDirection() != d)
dstBeing->setDirectionDelayed(static_cast<uint8_t>(d));
@@ -577,7 +577,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType)
if (msgType == 1 || msgType == 2)
{
- int type = msg.readInt8();
+ const int type = msg.readInt8();
switch (type)
{
case 0:
@@ -822,7 +822,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
if (job == 45 && socialWindow && outfitWindow)
{
- int num = socialWindow->getPortalIndex(x, y);
+ const int num = socialWindow->getPortalIndex(x, y);
if (num >= 0)
{
dstBeing->setName(keyboard.getKeyShortString(
diff --git a/src/net/eathena/buysellhandler.cpp b/src/net/eathena/buysellhandler.cpp
index 405d5f7ec..4dbc90e4b 100644
--- a/src/net/eathena/buysellhandler.cpp
+++ b/src/net/eathena/buysellhandler.cpp
@@ -101,18 +101,18 @@ void BuySellHandler::handleMessage(Net::MessageIn &msg)
void BuySellHandler::processNpcBuy(Net::MessageIn &msg)
{
msg.readInt16(); // length
- int sz = 11;
- int n_items = (msg.getLength() - 4) / sz;
+ const int sz = 11;
+ const int n_items = (msg.getLength() - 4) / sz;
mBuyDialog = new BuyDialog(mNpcId);
mBuyDialog->setMoney(PlayerInfo::getAttribute(PlayerInfo::MONEY));
for (int k = 0; k < n_items; k++)
{
- int value = msg.readInt32();
+ const int value = msg.readInt32();
msg.readInt32(); // DCvalue
msg.readInt8(); // type
- int itemId = msg.readInt16();
- unsigned char color = 1;
+ const int itemId = msg.readInt16();
+ const unsigned char color = 1;
mBuyDialog->addItem(itemId, color, 0, value);
}
}
diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp
index 512300704..2d98eaa6a 100644
--- a/src/net/eathena/charserverhandler.cpp
+++ b/src/net/eathena/charserverhandler.cpp
@@ -105,7 +105,8 @@ void CharServerHandler::handleMessage(Net::MessageIn &msg)
{
// msg.skip(4); // CharID, must be the same as player_node->charID
PlayerInfo::setCharId(msg.readInt32());
- GameHandler *gh = static_cast<GameHandler*>(Net::getGameHandler());
+ GameHandler *const gh = static_cast<GameHandler*>(
+ Net::getGameHandler());
gh->setMap(msg.readString(16));
if (config.getBoolValue("usePersistentIP"))
{
@@ -136,12 +137,13 @@ void CharServerHandler::handleMessage(Net::MessageIn &msg)
case SMSG_CHANGE_MAP_SERVER:
{
- GameHandler *gh = static_cast<GameHandler*>(Net::getGameHandler());
+ GameHandler *const gh = static_cast<GameHandler*>(
+ Net::getGameHandler());
if (!gh || !mNetwork)
return;
gh->setMap(msg.readString(16));
- int x = msg.readInt16();
- int y = msg.readInt16();
+ const int x = msg.readInt16();
+ const int y = msg.readInt16();
mapServer.hostname = ipToString(msg.readInt32());
mapServer.port = msg.readInt16();
@@ -169,7 +171,7 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
const Token &token =
static_cast<LoginHandler*>(Net::getLoginHandler())->getToken();
- LocalPlayer *tempPlayer = new LocalPlayer(msg.readInt32(), 0);
+ LocalPlayer *const tempPlayer = new LocalPlayer(msg.readInt32(), 0);
tempPlayer->setGender(token.sex);
PlayerInfoBackend &data = character->data;
@@ -178,14 +180,14 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
Stat &jobStat = data.mStats[JOB];
jobStat.exp = msg.readInt32();
- int temp = msg.readInt32();
+ const int temp = msg.readInt32();
jobStat.base = temp;
jobStat.mod = temp;
- int shoes = msg.readInt16();
- int gloves = msg.readInt16();
- int cape = msg.readInt16();
- int misc1 = msg.readInt16();
+ const int shoes = msg.readInt16();
+ const int gloves = msg.readInt16();
+ const int cape = msg.readInt16();
+ const int misc1 = msg.readInt16();
msg.readInt32(); // option
msg.readInt32(); // karma
@@ -199,23 +201,23 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
msg.readInt16(); // speed
tempPlayer->setSubtype(msg.readInt16()); // class (used for race)
- int hairStyle = msg.readInt16();
- uint16_t weapon = msg.readInt16(); // server not used it. may be need use?
+ const int hairStyle = msg.readInt16();
+ const uint16_t weapon = msg.readInt16(); // server not used it. may be need use?
tempPlayer->setSprite(SPRITE_WEAPON, weapon, "", 1, true);
data.mAttributes[PlayerInfo::LEVEL] = msg.readInt16();
msg.readInt16(); // skill point
- int bottomClothes = msg.readInt16();
- int shield = msg.readInt16();
+ const int bottomClothes = msg.readInt16();
+ const int shield = msg.readInt16();
int hat = msg.readInt16(); // head option top
- int topClothes = msg.readInt16();
+ const int topClothes = msg.readInt16();
tempPlayer->setSprite(SPRITE_HAIR, hairStyle * -1,
ItemDB::get(-hairStyle).getDyeColorsString(msg.readInt16()));
- int misc2 = msg.readInt16();
+ const int misc2 = msg.readInt16();
tempPlayer->setName(msg.readString(24));
character->dummy = tempPlayer;
@@ -311,7 +313,7 @@ void CharServerHandler::connect()
void CharServerHandler::processCharLogin(Net::MessageIn &msg)
{
msg.skip(2); // Length word
- int slots = msg.readInt16();
+ const int slots = msg.readInt16();
if (slots > 0 && slots < 30)
loginData.characterSlots = static_cast<short unsigned int>(slots);
@@ -321,11 +323,11 @@ void CharServerHandler::processCharLogin(Net::MessageIn &msg)
mCharacters.clear();
// Derive number of characters from message length
- int count = (msg.getLength() - 24) / 106;
+ const int count = (msg.getLength() - 24) / 106;
for (int i = 0; i < count; ++i)
{
- Net::Character *character = new Net::Character;
+ Net::Character *const character = new Net::Character;
readPlayerData(msg, character, false);
mCharacters.push_back(character);
if (character && character->dummy)
diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp
index 756faf6f3..77cf50acd 100644
--- a/src/net/eathena/chathandler.cpp
+++ b/src/net/eathena/chathandler.cpp
@@ -177,7 +177,7 @@ void ChatHandler::processRaw(MessageOut &outMsg, std::string &line)
size_t pos = line.find(":");
if (pos == std::string::npos)
{
- int i = atoi(line.c_str());
+ const int i = atoi(line.c_str());
if (line.length() <= 3)
outMsg.writeInt8(static_cast<char>(i));
else if (line.length() <= 5)
@@ -221,16 +221,16 @@ void ChatHandler::processRaw(MessageOut &outMsg, std::string &line)
pos = line.find(",");
if (pos != std::string::npos)
{
- unsigned short x = static_cast<unsigned short>(
+ const unsigned short x = static_cast<unsigned short>(
atoi(data.substr(0, pos).c_str()));
data = data.substr(pos + 1);
pos = line.find(",");
if (pos == std::string::npos)
break;
- unsigned short y = static_cast<unsigned short>(
+ const unsigned short y = static_cast<unsigned short>(
atoi(data.substr(0, pos).c_str()));
- int dir = atoi(data.substr(pos + 1).c_str());
+ const int dir = atoi(data.substr(pos + 1).c_str());
outMsg.writeCoordinates(x, y,
static_cast<unsigned char>(dir));
}
diff --git a/src/net/eathena/guildhandler.cpp b/src/net/eathena/guildhandler.cpp
index 719d82163..4e22fe691 100644
--- a/src/net/eathena/guildhandler.cpp
+++ b/src/net/eathena/guildhandler.cpp
@@ -202,7 +202,8 @@ void GuildHandler::invite(int guildId A_UNUSED,
if (!actorSpriteManager)
return;
- Being* being = actorSpriteManager->findBeingByName(name, Being::PLAYER);
+ const Being *const being = actorSpriteManager->findBeingByName(
+ name, Being::PLAYER);
if (being)
{
MessageOut msg(CMSG_GUILD_INVITE);
diff --git a/src/net/eathena/messageout.cpp b/src/net/eathena/messageout.cpp
index 26261aaa5..6e35c50c4 100644
--- a/src/net/eathena/messageout.cpp
+++ b/src/net/eathena/messageout.cpp
@@ -91,7 +91,7 @@ void MessageOut::writeCoordinates(unsigned short x, unsigned short y,
unsigned char direction)
{
DEBUGLOG(strprintf("writeCoordinates: %u,%u %u", x, y, direction));
- char *data = mData + mPos;
+ char *const data = mData + mPos;
mNetwork->mOutSize += 3;
mPos += 3;
diff --git a/src/net/eathena/network.cpp b/src/net/eathena/network.cpp
index 236d80310..475aaa72e 100644
--- a/src/net/eathena/network.cpp
+++ b/src/net/eathena/network.cpp
@@ -160,7 +160,7 @@ void Network::dispatchMessages()
{
MessageIn msg = getNextMessage();
- MessageHandlerIterator iter = mMessageHandlers.find(msg.getId());
+ const MessageHandlerIterator iter = mMessageHandlers.find(msg.getId());
if (msg.getLength() == 0)
logger->safeError("Zero length packet received. Exiting.");
@@ -186,7 +186,7 @@ bool Network::messageReady()
SDL_mutexP(mMutex);
if (mInSize >= 2)
{
- int msgId = readWord(0);
+ const int msgId = readWord(0);
if (msgId == SMSG_SERVER_VERSION_RESPONSE)
len = 10;
else if (msgId == SMSG_UPDATE_HOST2)
@@ -198,7 +198,7 @@ bool Network::messageReady()
len = readWord(2);
}
- bool ret = (mInSize >= static_cast<unsigned int>(len));
+ const bool ret = (mInSize >= static_cast<unsigned int>(len));
SDL_mutexV(mMutex);
return ret;
@@ -213,7 +213,7 @@ MessageIn Network::getNextMessage()
}
SDL_mutexP(mMutex);
- int msgId = readWord(0);
+ const int msgId = readWord(0);
int len = -1;
if (msgId == SMSG_SERVER_VERSION_RESPONSE)
{
diff --git a/src/net/eathena/npchandler.cpp b/src/net/eathena/npchandler.cpp
index aa141e089..aa77a23e5 100644
--- a/src/net/eathena/npchandler.cpp
+++ b/src/net/eathena/npchandler.cpp
@@ -128,7 +128,7 @@ void NpcHandler::closeDialog(int npcId)
MessageOut outMsg(CMSG_NPC_CLOSE);
outMsg.writeInt32(npcId);
- NpcDialogs::iterator it = mNpcDialogs.find(npcId);
+ const NpcDialogs::iterator it = mNpcDialogs.find(npcId);
if (it != mNpcDialogs.end())
{
if ((*it).second.dialog)
@@ -200,7 +200,7 @@ int NpcHandler::getNpc(Net::MessageIn &msg, bool haveLength)
const int npcId = msg.readInt32();
- NpcDialogs::const_iterator diag = mNpcDialogs.find(npcId);
+ const NpcDialogs::const_iterator diag = mNpcDialogs.find(npcId);
mDialog = nullptr;
if (diag == mNpcDialogs.end())
diff --git a/src/net/eathena/partyhandler.cpp b/src/net/eathena/partyhandler.cpp
index 04de35890..e1052d50d 100644
--- a/src/net/eathena/partyhandler.cpp
+++ b/src/net/eathena/partyhandler.cpp
@@ -122,7 +122,8 @@ void PartyHandler::invite(const std::string &name)
if (!actorSpriteManager)
return;
- Being* being = actorSpriteManager->findBeingByName(name, Being::PLAYER);
+ const Being *const being = actorSpriteManager->findBeingByName(
+ name, Being::PLAYER);
if (being)
{
MessageOut outMsg(CMSG_PARTY_INVITE);
@@ -161,7 +162,7 @@ void PartyHandler::kick(const std::string &name)
if (!Ea::taParty)
return;
- PartyMember *m = Ea::taParty->getMember(name);
+ const PartyMember *const m = Ea::taParty->getMember(name);
if (!m)
{
if (Ea::partyTab)
diff --git a/src/net/eathena/playerhandler.cpp b/src/net/eathena/playerhandler.cpp
index d9bb8c3b5..633bb12e4 100644
--- a/src/net/eathena/playerhandler.cpp
+++ b/src/net/eathena/playerhandler.cpp
@@ -160,7 +160,7 @@ void PlayerHandler::pickUp(const FloorItem *floorItem)
MessageOut outMsg(CMSG_ITEM_PICKUP);
outMsg.writeInt32(floorItem->getId());
- EAthena::InventoryHandler *handler =
+ EAthena::InventoryHandler *const handler =
static_cast<EAthena::InventoryHandler*>(Net::getInventoryHandler());
if (handler)
handler->pushPickup(floorItem->getId());