summaryrefslogtreecommitdiff
path: root/src/net/tmwa
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/tmwa
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/tmwa')
-rw-r--r--src/net/tmwa/beinghandler.cpp24
-rw-r--r--src/net/tmwa/buysellhandler.cpp6
-rw-r--r--src/net/tmwa/charserverhandler.cpp42
-rw-r--r--src/net/tmwa/chathandler.cpp8
-rw-r--r--src/net/tmwa/guildhandler.cpp3
-rw-r--r--src/net/tmwa/loginhandler.cpp12
-rw-r--r--src/net/tmwa/messageout.cpp2
-rw-r--r--src/net/tmwa/network.cpp8
-rw-r--r--src/net/tmwa/npchandler.cpp6
-rw-r--r--src/net/tmwa/partyhandler.cpp5
-rw-r--r--src/net/tmwa/playerhandler.cpp4
-rw-r--r--src/net/tmwa/questhandler.cpp10
12 files changed, 67 insertions, 63 deletions
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index a4ab0f48b..2eac3c4a2 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/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)
@@ -442,14 +442,14 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType)
// 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
+ const int id = msg.readInt32();
+ const short speed = msg.readInt16();
+ const uint16_t stunMode = msg.readInt16(); // opt1; Aethyra use this as cape
uint32_t statusEffects = msg.readInt16(); // opt2;
// Aethyra use this as misc1
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);
@@ -471,7 +471,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);
@@ -559,7 +559,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));
@@ -591,7 +591,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:
diff --git a/src/net/tmwa/buysellhandler.cpp b/src/net/tmwa/buysellhandler.cpp
index 5a3877734..f3021207b 100644
--- a/src/net/tmwa/buysellhandler.cpp
+++ b/src/net/tmwa/buysellhandler.cpp
@@ -105,16 +105,16 @@ void BuySellHandler::processNpcBuy(Net::MessageIn &msg)
int sz = 11;
if (serverVersion > 0)
sz += 1;
- int n_items = (msg.getLength() - 4) / sz;
+ 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();
+ const int itemId = msg.readInt16();
unsigned char color = 1;
if (serverVersion > 0)
color = msg.readInt8();
diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp
index 777abc54e..235028f71 100644
--- a/src/net/tmwa/charserverhandler.cpp
+++ b/src/net/tmwa/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();
@@ -170,7 +172,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;
@@ -179,14 +181,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
@@ -200,23 +202,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(); // unused on server. 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 hat = msg.readInt16(); // head option top
+ 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;
@@ -343,11 +345,11 @@ 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);
- bool version = msg.readInt8() == 1 && serverVersion > 0;
+ const bool version = msg.readInt8() == 1 && serverVersion > 0;
msg.skip(17); // 0 Unused
delete_all(mCharacters);
@@ -362,7 +364,7 @@ void CharServerHandler::processCharLogin(Net::MessageIn &msg)
for (int i = 0; i < count; ++i)
{
- Net::Character *character = new Net::Character;
+ Net::Character *const character = new Net::Character;
readPlayerData(msg, character, version);
mCharacters.push_back(character);
if (character && character->dummy)
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp
index 6b695c1ee..6bf00aecc 100644
--- a/src/net/tmwa/chathandler.cpp
+++ b/src/net/tmwa/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<const 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<const 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/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp
index e57ae8e98..c8886283a 100644
--- a/src/net/tmwa/guildhandler.cpp
+++ b/src/net/tmwa/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/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp
index d95cbfe54..d4741538d 100644
--- a/src/net/tmwa/loginhandler.cpp
+++ b/src/net/tmwa/loginhandler.cpp
@@ -157,13 +157,13 @@ void LoginHandler::requestUpdateHosts()
void LoginHandler::processServerVersion(Net::MessageIn &msg)
{
- char b1 = msg.readInt8(); // -1
- char b2 = msg.readInt8(); // E
- char b3 = msg.readInt8(); // V
- char b4 = msg.readInt8(); // L
+ const char b1 = msg.readInt8(); // -1
+ const char b2 = msg.readInt8(); // E
+ const char b3 = msg.readInt8(); // V
+ const char b4 = msg.readInt8(); // L
if (b1 == -1 && b2 == 'E' && b3 == 'V' && b4 == 'L')
{
- unsigned int options = msg.readInt8();
+ const unsigned int options = msg.readInt8();
mRegistrationEnabled = options;
msg.skip(2); // 0 unused
serverVersion = msg.readInt8();
@@ -172,7 +172,7 @@ void LoginHandler::processServerVersion(Net::MessageIn &msg)
}
else
{
- unsigned int options = msg.readInt32();
+ const unsigned int options = msg.readInt32();
mRegistrationEnabled = options;
serverVersion = 0;
}
diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp
index 1c802d3e8..1a291a9b7 100644
--- a/src/net/tmwa/messageout.cpp
+++ b/src/net/tmwa/messageout.cpp
@@ -93,7 +93,7 @@ void MessageOut::writeCoordinates(unsigned short x, unsigned short y,
DEBUGLOG(strprintf("writeCoordinates: %u,%u %u",
static_cast<unsigned>(x), static_cast<unsigned>(y),
static_cast<unsigned>(direction)));
- char *data = mData + mPos;
+ char *const data = mData + mPos;
mNetwork->mOutSize += 3;
mPos += 3;
diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp
index aab05c7b9..1a7a46e95 100644
--- a/src/net/tmwa/network.cpp
+++ b/src/net/tmwa/network.cpp
@@ -138,7 +138,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.");
@@ -164,7 +164,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;
@@ -186,7 +186,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;
@@ -201,7 +201,7 @@ MessageIn Network::getNextMessage()
}
SDL_mutexP(mMutex);
- int msgId = readWord(0);
+ const int msgId = readWord(0);
int len;
if (msgId == SMSG_SERVER_VERSION_RESPONSE)
len = 10;
diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp
index d68a78c8c..7b74ad91f 100644
--- a/src/net/tmwa/npchandler.cpp
+++ b/src/net/tmwa/npchandler.cpp
@@ -61,7 +61,7 @@ NpcHandler::NpcHandler() :
void NpcHandler::handleMessage(Net::MessageIn &msg)
{
- int npcId = getNpc(msg, msg.getId() == SMSG_NPC_CHOICE
+ const int npcId = getNpc(msg, msg.getId() == SMSG_NPC_CHOICE
|| msg.getId() == SMSG_NPC_MESSAGE);
if (msg.getId() != SMSG_NPC_STR_INPUT)
@@ -125,7 +125,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)
@@ -208,7 +208,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/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp
index 8a59f2a48..77bfbb8fb 100644
--- a/src/net/tmwa/partyhandler.cpp
+++ b/src/net/tmwa/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/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index 4549234f4..dae4f8eeb 100644
--- a/src/net/tmwa/playerhandler.cpp
+++ b/src/net/tmwa/playerhandler.cpp
@@ -154,7 +154,7 @@ void PlayerHandler::pickUp(const FloorItem *floorItem)
MessageOut outMsg(CMSG_ITEM_PICKUP);
outMsg.writeInt32(floorItem->getId());
- TmwAthena::InventoryHandler *handler =
+ TmwAthena::InventoryHandler *const handler =
static_cast<TmwAthena::InventoryHandler*>(Net::getInventoryHandler());
if (handler)
handler->pushPickup(floorItem->getId());
@@ -216,7 +216,7 @@ void PlayerHandler::processOnlineList(Net::MessageIn &msg)
if (!whoIsOnline)
return;
- int size = msg.readInt16() - 4;
+ const int size = msg.readInt16() - 4;
std::vector<OnlinePlayer*> arr;
if (!size)
diff --git a/src/net/tmwa/questhandler.cpp b/src/net/tmwa/questhandler.cpp
index 759037bb5..d3209cb9e 100644
--- a/src/net/tmwa/questhandler.cpp
+++ b/src/net/tmwa/questhandler.cpp
@@ -68,8 +68,8 @@ void QuestHandler::handleMessage(Net::MessageIn &msg)
void QuestHandler::processSetQuestVar(Net::MessageIn &msg A_UNUSED)
{
- int var = msg.readInt16(); // variable
- int val = msg.readInt32(); // value
+ const int var = msg.readInt16(); // variable
+ const int val = msg.readInt32(); // value
if (questsWindow)
{
questsWindow->updateQuest(var, val);
@@ -79,11 +79,11 @@ void QuestHandler::processSetQuestVar(Net::MessageIn &msg A_UNUSED)
void QuestHandler::processPlayerQuests(Net::MessageIn &msg A_UNUSED)
{
- int count = (msg.readInt16() - 4) / 6;
+ const int count = (msg.readInt16() - 4) / 6;
for (int f = 0; f < count; f ++)
{
- int var = msg.readInt16(); // variable
- int val = msg.readInt32(); // value
+ const int var = msg.readInt16(); // variable
+ const int val = msg.readInt32(); // value
if (questsWindow)
questsWindow->updateQuest(var, val);
}