summaryrefslogtreecommitdiff
path: root/src/net
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
parent4df121e6dcdf53436f50ce81dd60096ce0138a2c (diff)
downloadManaVerse-962f182fcc989ec587282e44f889188ce241ba31.tar.gz
ManaVerse-962f182fcc989ec587282e44f889188ce241ba31.tar.bz2
ManaVerse-962f182fcc989ec587282e44f889188ce241ba31.tar.xz
ManaVerse-962f182fcc989ec587282e44f889188ce241ba31.zip
Add const to more classes.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/ea/beinghandler.cpp81
-rw-r--r--src/net/ea/buysellhandler.cpp12
-rw-r--r--src/net/ea/charserverhandler.cpp2
-rw-r--r--src/net/ea/chathandler.cpp22
-rw-r--r--src/net/ea/gui/partytab.cpp6
-rw-r--r--src/net/ea/guildhandler.cpp100
-rw-r--r--src/net/ea/inventoryhandler.cpp36
-rw-r--r--src/net/ea/itemhandler.cpp37
-rw-r--r--src/net/ea/loginhandler.cpp10
-rw-r--r--src/net/ea/network.cpp15
-rw-r--r--src/net/ea/network.h1
-rw-r--r--src/net/ea/npchandler.cpp2
-rw-r--r--src/net/ea/partyhandler.cpp40
-rw-r--r--src/net/ea/playerhandler.cpp40
-rw-r--r--src/net/ea/specialhandler.cpp16
-rw-r--r--src/net/ea/tradehandler.cpp12
-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
-rw-r--r--src/net/messagein.cpp28
-rw-r--r--src/net/net.cpp2
-rw-r--r--src/net/packetcounters.cpp2
-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
41 files changed, 359 insertions, 347 deletions
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index d8fd49fe2..1dc98f776 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -79,7 +79,7 @@ Being *BeingHandler::createBeing(int id, short job)
else if (job == 45)
type = ActorSprite::PORTAL;
- Being *being = actorSpriteManager->createBeing(id, type, job);
+ Being *const being = actorSpriteManager->createBeing(id, type, job);
if (type == ActorSprite::PLAYER || type == ActorSprite::NPC)
{
@@ -212,12 +212,12 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
{
if (serverVersion > 0)
{
- int hp = msg.readInt32();
- int maxHP = msg.readInt32();
+ const int hp = msg.readInt32();
+ const int maxHP = msg.readInt32();
if (hp && maxHP)
{
dstBeing->setMaxHP(maxHP);
- int oldHP = dstBeing->getHP();
+ const int oldHP = dstBeing->getHP();
if (!oldHP || oldHP > hp)
dstBeing->setHP(hp);
}
@@ -247,7 +247,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
dstBeing->setStatusEffectBlock(32, msg.readInt16()); // opt3
if (serverVersion > 0 && dstBeing->getType() == ActorSprite::MONSTER)
{
- int attackRange = msg.readInt8(); // karma
+ const int attackRange = msg.readInt8(); // karma
dstBeing->setAttackRange(attackRange);
}
else
@@ -310,7 +310,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(
@@ -347,7 +347,7 @@ void BeingHandler::processBeingMove2(Net::MessageIn &msg)
* later versions of eAthena for both mobs and
* players
*/
- Being *dstBeing = actorSpriteManager->findBeing(msg.readInt32());
+ Being *const dstBeing = actorSpriteManager->findBeing(msg.readInt32());
/*
* This packet doesn't have enough info to actually
@@ -387,8 +387,8 @@ void BeingHandler::processBeingRemove(Net::MessageIn &msg)
// A being should be removed or has died
- int id = msg.readInt32();
- Being *dstBeing = actorSpriteManager->findBeing(id);
+ const int id = msg.readInt32();
+ Being *const dstBeing = actorSpriteManager->findBeing(id);
if (!dstBeing)
return;
@@ -429,8 +429,8 @@ void BeingHandler::processBeingResurrect(Net::MessageIn &msg)
// A being changed mortality status
- int id = msg.readInt32();
- Being *dstBeing = actorSpriteManager->findBeing(id);
+ const int id = msg.readInt32();
+ Being *const dstBeing = actorSpriteManager->findBeing(id);
if (!dstBeing)
return;
@@ -452,7 +452,7 @@ void BeingHandler::processSkillDamage(Net::MessageIn &msg)
Being *dstBeing;
int param1;
- int id = msg.readInt16(); // Skill Id
+ const int id = msg.readInt16(); // Skill Id
srcBeing = actorSpriteManager->findBeing(msg.readInt32());
dstBeing = actorSpriteManager->findBeing(msg.readInt32());
msg.readInt32(); // Server tick
@@ -482,15 +482,15 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg)
if (!actorSpriteManager)
return;
- Being *srcBeing = actorSpriteManager->findBeing(msg.readInt32());
- Being *dstBeing = actorSpriteManager->findBeing(msg.readInt32());
+ Being *const srcBeing = actorSpriteManager->findBeing(msg.readInt32());
+ Being *const dstBeing = actorSpriteManager->findBeing(msg.readInt32());
msg.readInt32(); // server tick
- int srcSpeed = msg.readInt32(); // src speed
+ const int srcSpeed = msg.readInt32(); // src speed
msg.readInt32(); // dst speed
- int param1 = msg.readInt16();
+ const int param1 = msg.readInt16();
msg.readInt16(); // param 2
- int type = msg.readInt8();
+ const int type = msg.readInt8();
msg.readInt16(); // param 3
switch (type)
@@ -565,14 +565,12 @@ void BeingHandler::processBeingSelfEffect(Net::MessageIn &msg)
if (!effectManager || !actorSpriteManager)
return;
- int id;
-
- id = static_cast<uint32_t>(msg.readInt32());
- Being* being = actorSpriteManager->findBeing(id);
+ int id = static_cast<uint32_t>(msg.readInt32());
+ Being *const being = actorSpriteManager->findBeing(id);
if (!being)
return;
- int effectType = msg.readInt32();
+ const int effectType = msg.readInt32();
effectManager->trigger(effectType, being);
@@ -597,7 +595,7 @@ void BeingHandler::processBeingEmotion(Net::MessageIn &msg)
if (player_relations.hasPermission(dstBeing, PlayerRelation::EMOTE))
{
- unsigned char emote = msg.readInt8();
+ const unsigned char emote = msg.readInt8();
if (emote)
{
dstBeing->setEmote(emote, EMOTION_TIME);
@@ -615,7 +613,7 @@ void BeingHandler::processNameResponse(Net::MessageIn &msg)
Being *dstBeing;
- int beingId = msg.readInt32();
+ const int beingId = msg.readInt32();
if ((dstBeing = actorSpriteManager->findBeing(beingId)))
{
if (beingId == player_node->getId())
@@ -633,10 +631,11 @@ void BeingHandler::processNameResponse(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(dstBeing->getId());
+ PartyMember *const member = party->getMember(
+ dstBeing->getId());
if (member)
member->setName(dstBeing->getName());
@@ -691,7 +690,7 @@ void BeingHandler::processBeingChangeDirection(Net::MessageIn &msg)
msg.readInt16(); // unused
- unsigned char dir = msg.readInt8();
+ const unsigned char dir = msg.readInt8();
dstBeing->setDirection(dir);
if (player_node)
player_node->imitateDirection(dstBeing, dir);
@@ -714,11 +713,11 @@ void BeingHandler::processPlayerStop(Net::MessageIn &msg)
* of the config setting.
*/
- int id = msg.readInt32();
+ const int id = msg.readInt32();
if (mSync || id != player_node->getId())
{
- Being *dstBeing = actorSpriteManager->findBeing(id);
+ Being *const dstBeing = actorSpriteManager->findBeing(id);
if (dstBeing)
{
uint16_t x, y;
@@ -750,12 +749,12 @@ void BeingHandler::processPlaterStatusChange(Net::MessageIn &msg)
// Change in players' flags
- int id = msg.readInt32();
- Being *dstBeing = actorSpriteManager->findBeing(id);
+ const int id = msg.readInt32();
+ Being *const dstBeing = actorSpriteManager->findBeing(id);
if (!dstBeing)
return;
- uint16_t stunMode = msg.readInt16();
+ const uint16_t stunMode = msg.readInt16();
uint32_t statusEffects = msg.readInt16();
statusEffects |= (static_cast<uint32_t>(msg.readInt16())) << 16;
msg.readInt8(); // Unused?
@@ -773,11 +772,11 @@ void BeingHandler::processBeingStatusChange(Net::MessageIn &msg)
return;
// Status change
- uint16_t status = msg.readInt16();
- int id = msg.readInt32();
- int flag = msg.readInt8(); // 0: stop, 1: start
+ const uint16_t status = msg.readInt16();
+ const int id = msg.readInt32();
+ const int flag = msg.readInt8(); // 0: stop, 1: start
- Being *dstBeing = actorSpriteManager->findBeing(id);
+ Being *const dstBeing = actorSpriteManager->findBeing(id);
if (dstBeing)
dstBeing->setStatusEffect(status, flag);
}
@@ -804,23 +803,23 @@ void BeingHandler::processSkillNoDamage(Net::MessageIn &msg)
void BeingHandler::processPvpMapMode(Net::MessageIn &msg)
{
- Game *game = Game::instance();
+ const Game *const game = Game::instance();
if (!game)
return;
- Map *map = game->getCurrentMap();
+ Map *const map = game->getCurrentMap();
if (map)
map->setPvpMode(msg.readInt16());
}
void BeingHandler::processPvpSet(Net::MessageIn &msg)
{
- int id = msg.readInt32(); // id
- int rank = msg.readInt32(); // rank
+ const int id = msg.readInt32(); // id
+ const int rank = msg.readInt32(); // rank
msg.readInt32(); // num
if (actorSpriteManager)
{
- Being *dstBeing = actorSpriteManager->findBeing(id);
+ Being *const dstBeing = actorSpriteManager->findBeing(id);
if (dstBeing)
dstBeing->setPvpRank(rank);
}
diff --git a/src/net/ea/buysellhandler.cpp b/src/net/ea/buysellhandler.cpp
index 8566bcab7..9cee4d434 100644
--- a/src/net/ea/buysellhandler.cpp
+++ b/src/net/ea/buysellhandler.cpp
@@ -139,19 +139,19 @@ void BuySellHandler::processNpcBuySellChoice(Net::MessageIn &msg)
void BuySellHandler::processNpcSell(Net::MessageIn &msg, int offset)
{
msg.readInt16(); // length
- int n_items = (msg.getLength() - 4) / 10;
+ const int n_items = (msg.getLength() - 4) / 10;
if (n_items > 0)
{
- SellDialog *dialog = new SellDialog(mNpcId);
+ SellDialog *const dialog = new SellDialog(mNpcId);
dialog->setMoney(PlayerInfo::getAttribute(PlayerInfo::MONEY));
for (int k = 0; k < n_items; k++)
{
- int index = msg.readInt16() - offset;
- int value = msg.readInt32();
- msg.readInt32(); // OCvalue
+ const int index = msg.readInt16() - offset;
+ const int value = msg.readInt32();
+ msg.readInt32(); // value
- Item *item = PlayerInfo::getInventory()->getItem(index);
+ const Item *const item = PlayerInfo::getInventory()->getItem(index);
if (item && !(item->isEquipped()))
dialog->addItem(item, value);
diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp
index 62c9090e9..7e0a5106d 100644
--- a/src/net/ea/charserverhandler.cpp
+++ b/src/net/ea/charserverhandler.cpp
@@ -124,7 +124,7 @@ void CharServerHandler::processCharLoginError(Net::MessageIn &msg)
void CharServerHandler::processCharCreate(Net::MessageIn &msg, bool withColors)
{
- Net::Character *character = new Net::Character;
+ Net::Character *const character = new Net::Character;
readPlayerData(msg, character, withColors);
mCharacters.push_back(character);
diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp
index 6aea0e2f8..4d761a1ce 100644
--- a/src/net/ea/chathandler.cpp
+++ b/src/net/ea/chathandler.cpp
@@ -113,7 +113,7 @@ void ChatHandler::processWhisperResponse(Net::MessageIn &msg)
mSentWhispers.pop();
}
- int type = msg.readInt8();
+ const int type = msg.readInt8();
switch (type)
{
case 0x00:
@@ -147,7 +147,7 @@ void ChatHandler::processWhisperResponse(Net::MessageIn &msg)
void ChatHandler::processWhisper(Net::MessageIn &msg)
{
- int chatMsgLength = msg.readInt16() - 28;
+ const int chatMsgLength = msg.readInt16() - 28;
std::string nick = msg.readString(24);
if (chatMsgLength <= 0)
@@ -171,8 +171,8 @@ void ChatHandler::processWhisper(Net::MessageIn &msg)
if (player_relations.hasPermission(nick, PlayerRelation::WHISPER))
{
- bool tradeBot = config.getBoolValue("tradebot");
- bool showMsg = !config.getBoolValue("hideShopMessages");
+ const bool tradeBot = config.getBoolValue("tradebot");
+ const bool showMsg = !config.getBoolValue("hideShopMessages");
if (player_relations.hasPermission(nick, PlayerRelation::TRADE))
{
if (shopWindow)
@@ -255,8 +255,8 @@ void ChatHandler::processBeingChat(Net::MessageIn &msg)
if (!actorSpriteManager)
return;
- int chatMsgLength = msg.readInt16() - 8;
- Being *being = actorSpriteManager->findBeing(msg.readInt32());
+ const int chatMsgLength = msg.readInt16() - 8;
+ Being *const being = actorSpriteManager->findBeing(msg.readInt32());
if (!being || chatMsgLength <= 0)
return;
@@ -301,7 +301,7 @@ void ChatHandler::processBeingChat(Net::MessageIn &msg)
void ChatHandler::processChat(Net::MessageIn &msg, bool normalChat)
{
- int chatMsgLength = msg.readInt16() - 4;
+ const int chatMsgLength = msg.readInt16() - 4;
if (chatMsgLength <= 0)
return;
@@ -338,10 +338,10 @@ void ChatHandler::processChat(Net::MessageIn &msg, bool normalChat)
void ChatHandler::processMVP(Net::MessageIn &msg)
{
// Display MVP player
- int id = msg.readInt32(); // id
+ const int id = msg.readInt32(); // id
if (localChatTab && actorSpriteManager && config.getBoolValue("showMVP"))
{
- Being *being = actorSpriteManager->findBeing(id);
+ const Being *const being = actorSpriteManager->findBeing(id);
if (!being)
{
localChatTab->chatLog(_("MVP player."), BY_SERVER);
@@ -356,8 +356,8 @@ void ChatHandler::processMVP(Net::MessageIn &msg)
void ChatHandler::processIgnoreAllResponse(Net::MessageIn &msg)
{
- int action = msg.readInt8();
- int fail = msg.readInt8();
+ const int action = msg.readInt8();
+ const int fail = msg.readInt8();
if (!localChatTab)
return;
diff --git a/src/net/ea/gui/partytab.cpp b/src/net/ea/gui/partytab.cpp
index edbd867d9..9441f15b3 100644
--- a/src/net/ea/gui/partytab.cpp
+++ b/src/net/ea/gui/partytab.cpp
@@ -160,7 +160,7 @@ bool PartyTab::handleCommand(const std::string &type, const std::string &args)
}
}
- char opt = CommandHandler::parseBoolean(args);
+ const char opt = CommandHandler::parseBoolean(args);
switch (opt)
{
@@ -199,7 +199,7 @@ bool PartyTab::handleCommand(const std::string &type, const std::string &args)
}
}
- char opt = CommandHandler::parseBoolean(args);
+ const char opt = CommandHandler::parseBoolean(args);
switch (opt)
{
@@ -228,7 +228,7 @@ void PartyTab::getAutoCompleteList(StringVect &names) const
if (!player_node)
return;
- Party *p = player_node->getParty();
+ const Party *const p = player_node->getParty();
if (p)
p->getNames(names);
diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp
index fb14540cb..9d4126106 100644
--- a/src/net/ea/guildhandler.cpp
+++ b/src/net/ea/guildhandler.cpp
@@ -71,7 +71,7 @@ bool GuildHandler::isSupported()
void GuildHandler::processGuildCreateResponse(Net::MessageIn &msg)
{
- int flag = msg.readInt8();
+ const int flag = msg.readInt8();
switch (flag)
{
@@ -104,14 +104,14 @@ void GuildHandler::processGuildCreateResponse(Net::MessageIn &msg)
void GuildHandler::processGuildPositionInfo(Net::MessageIn &msg)
{
- int guildId = msg.readInt32();
- int emblem = msg.readInt32();
- int posMode = msg.readInt32();
+ const int guildId = msg.readInt32();
+ const int emblem = msg.readInt32();
+ const int posMode = msg.readInt32();
msg.readInt32(); // Unused
msg.readInt8(); // Unused
std::string guildName = msg.readString(24);
- Guild *g = Guild::getGuild(static_cast<short int>(guildId));
+ Guild *const g = Guild::getGuild(static_cast<short int>(guildId));
if (!g)
return;
@@ -140,12 +140,12 @@ void GuildHandler::processGuildPositionInfo(Net::MessageIn &msg)
void GuildHandler::processGuildMemberLogin(Net::MessageIn &msg)
{
- int accountId = msg.readInt32(); // Account ID
- int charId = msg.readInt32(); // Char ID
- int online = msg.readInt32(); // Flag
+ const int accountId = msg.readInt32(); // Account ID
+ const int charId = msg.readInt32(); // Char ID
+ const int online = msg.readInt32(); // Flag
if (taGuild)
{
- GuildMember *m = taGuild->getMember(accountId, charId);
+ GuildMember *const m = taGuild->getMember(accountId, charId);
if (m)
m->setOnline(online);
}
@@ -158,13 +158,13 @@ void GuildHandler::processGuildMasterOrMember(Net::MessageIn &msg)
void GuildHandler::processGuildBasicInfo(Net::MessageIn &msg)
{
- int guildId = msg.readInt32(); // Guild ID
- int level = msg.readInt32(); // Guild level
- int members = msg.readInt32(); // 'Connect member'
- int maxMembers = msg.readInt32(); // 'Max member'
- int avgLevel = msg.readInt32(); // Average level
- int exp = msg.readInt32(); // Exp
- int nextExp = msg.readInt32(); // Next exp
+ const int guildId = msg.readInt32(); // Guild ID
+ const int level = msg.readInt32(); // Guild level
+ const int members = msg.readInt32(); // 'Connect member'
+ const int maxMembers = msg.readInt32(); // 'Max member'
+ const int avgLevel = msg.readInt32(); // Average level
+ const int exp = msg.readInt32(); // Exp
+ const int nextExp = msg.readInt32(); // Next exp
msg.skip(16); // 0 unused
std::string name = msg.readString(24); // Name
std::string master = msg.readString(24); // Master's name
@@ -192,7 +192,7 @@ void GuildHandler::processGuildBasicInfo(Net::MessageIn &msg)
castle.c_str()), BY_SERVER);
}
- Guild *g = Guild::getGuild(static_cast<short int>(guildId));
+ Guild *const g = Guild::getGuild(static_cast<short int>(guildId));
if (!g)
return;
g->setName(name);
@@ -200,10 +200,10 @@ void GuildHandler::processGuildBasicInfo(Net::MessageIn &msg)
void GuildHandler::processGuildAlianceInfo(Net::MessageIn &msg)
{
- int length = msg.readInt16();
+ const int length = msg.readInt16();
if (length < 4)
return;
- int count = (length - 4) / 32;
+ const int count = (length - 4) / 32;
for (int i = 0; i < count; i++)
{
@@ -215,10 +215,10 @@ void GuildHandler::processGuildAlianceInfo(Net::MessageIn &msg)
void GuildHandler::processGuildMemberList(Net::MessageIn &msg)
{
- int length = msg.readInt16();
+ const int length = msg.readInt16();
if (length < 4)
return;
- int count = (length - 4) / 104;
+ const int count = (length - 4) / 104;
if (!taGuild)
{
logger->log1("!taGuild");
@@ -229,20 +229,20 @@ void GuildHandler::processGuildMemberList(Net::MessageIn &msg)
for (int i = 0; i < count; i++)
{
- int id = msg.readInt32(); // Account ID
- int charId = msg.readInt32(); // Char ID
+ const int id = msg.readInt32(); // Account ID
+ const int charId = msg.readInt32(); // Char ID
msg.readInt16(); // Hair
msg.readInt16(); // Hair color
- int gender = msg.readInt16(); // Gender
- int race = msg.readInt16(); // Class
- int level = msg.readInt16(); // Level
- int exp = msg.readInt32(); // Exp
- int online = msg.readInt32(); // Online
- int pos = msg.readInt32(); // Position
+ const int gender = msg.readInt16(); // Gender
+ const int race = msg.readInt16(); // Class
+ const int level = msg.readInt16(); // Level
+ const int exp = msg.readInt32(); // Exp
+ const int online = msg.readInt32(); // Online
+ const int pos = msg.readInt32(); // Position
msg.skip(50); // 0 unused
std::string name = msg.readString(24); // Name
- GuildMember *m = taGuild->addMember(id, charId, name);
+ GuildMember *const m = taGuild->addMember(id, charId, name);
if (m)
{
m->setOnline(online);
@@ -255,7 +255,7 @@ void GuildHandler::processGuildMemberList(Net::MessageIn &msg)
m->setRace(race);
if (actorSpriteManager)
{
- Being *being = actorSpriteManager->findBeingByName(
+ Being *const being = actorSpriteManager->findBeingByName(
name, Being::PLAYER);
if (being)
{
@@ -285,14 +285,14 @@ void GuildHandler::processGuildPosNameList(Net::MessageIn &msg)
return;
}
- int length = msg.readInt16();
+ const int length = msg.readInt16();
if (length < 4)
return;
- int count = (length - 4) / 28;
+ const int count = (length - 4) / 28;
for (int i = 0; i < count; i++)
{
- int id = msg.readInt32(); // ID
+ const int id = msg.readInt32(); // ID
std::string name = msg.readString(24); // Position name
taGuild->addPos(id, name);
}
@@ -300,10 +300,10 @@ void GuildHandler::processGuildPosNameList(Net::MessageIn &msg)
void GuildHandler::processGuildPosInfoList(Net::MessageIn &msg)
{
- int length = msg.readInt16();
+ const int length = msg.readInt16();
if (length < 4)
return;
- int count = (length - 4) / 16;
+ const int count = (length - 4) / 16;
for (int i = 0; i < count; i++)
{
@@ -327,12 +327,12 @@ void GuildHandler::processGuildPositionChanged(Net::MessageIn &msg)
void GuildHandler::processGuildMemberPosChange(Net::MessageIn &msg)
{
msg.readInt16(); // Always 16
- int accountId = msg.readInt32(); // Account ID
- int charId = msg.readInt32(); // Char ID
- int pos = msg.readInt32(); // Position
+ const int accountId = msg.readInt32(); // Account ID
+ const int charId = msg.readInt32(); // Char ID
+ const int pos = msg.readInt32(); // Position
if (taGuild)
{
- GuildMember *m = taGuild->getMember(accountId, charId);
+ GuildMember *const m = taGuild->getMember(accountId, charId);
if (m)
m->setPos(pos);
}
@@ -340,7 +340,7 @@ void GuildHandler::processGuildMemberPosChange(Net::MessageIn &msg)
void GuildHandler::processGuildEmblem(Net::MessageIn &msg)
{
- int length = msg.readInt16();
+ const int length = msg.readInt16();
msg.readInt32(); // Guild ID
msg.readInt32(); // Emblem ID
@@ -351,8 +351,8 @@ void GuildHandler::processGuildEmblem(Net::MessageIn &msg)
void GuildHandler::processGuildSkillInfo(Net::MessageIn &msg)
{
- int length = msg.readInt16();
- int count = (length - 6) / 37;
+ const int length = msg.readInt16();
+ const int count = (length - 6) / 37;
msg.readInt16(); // 'Skill point'
@@ -384,7 +384,7 @@ void GuildHandler::processGuildNotice(Net::MessageIn &msg)
void GuildHandler::processGuildInvite(Net::MessageIn &msg)
{
- int guildId = msg.readInt32();
+ const int guildId = msg.readInt32();
std::string guildName = msg.readString(24);
if (socialWindow)
@@ -393,7 +393,7 @@ void GuildHandler::processGuildInvite(Net::MessageIn &msg)
void GuildHandler::processGuildInviteAck(Net::MessageIn &msg)
{
- int flag = msg.readInt8();
+ const int flag = msg.readInt8();
if (!guildTab)
return;
@@ -457,7 +457,7 @@ void GuildHandler::processGuildLeave(Net::MessageIn &msg)
}
if (actorSpriteManager)
{
- Being *b = actorSpriteManager->findBeingByName(
+ Being *const b = actorSpriteManager->findBeingByName(
nick, Being::PLAYER);
if (b)
@@ -506,7 +506,7 @@ void GuildHandler::processGuildExpulsion(Net::MessageIn &msg)
if (actorSpriteManager)
{
- Being *b = actorSpriteManager->findBeingByName(
+ Being *const b = actorSpriteManager->findBeingByName(
nick, Being::PLAYER);
if (b)
@@ -519,11 +519,11 @@ void GuildHandler::processGuildExpulsion(Net::MessageIn &msg)
void GuildHandler::processGuildExpulsionList(Net::MessageIn &msg)
{
- int length = msg.readInt16();
+ const int length = msg.readInt16();
if (length < 4)
return;
- int count = (length - 4) / 88;
+ const int count = (length - 4) / 88;
for (int i = 0; i < count; i++)
{
@@ -535,7 +535,7 @@ void GuildHandler::processGuildExpulsionList(Net::MessageIn &msg)
void GuildHandler::processGuildMessage(Net::MessageIn &msg)
{
- int msgLength = msg.readInt16() - 4;
+ const int msgLength = msg.readInt16() - 4;
if (msgLength <= 0)
return;
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index 6a4818129..1da1fe4ea 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -185,7 +185,7 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg,
}
msg.readInt16(); // length
- int number = (msg.getLength() - 4) / 18;
+ const int number = (msg.getLength() - 4) / 18;
for (int loop = 0; loop < number; loop++)
{
@@ -214,7 +214,7 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg,
if (playerInvintory)
{
// Trick because arrows are not considered equipment
- bool isEquipment = arrow & 0x8000;
+ const bool isEquipment = arrow & 0x8000;
if (inventory)
{
@@ -237,7 +237,7 @@ void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg)
unsigned char identified;
msg.readInt16(); // length
- int number = (msg.getLength() - 4) / 20;
+ const int number = (msg.getLength() - 4) / 20;
for (int loop = 0; loop < number; loop++)
{
@@ -300,7 +300,7 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg)
const ItemInfo &itemInfo = ItemDB::get(itemId);
- unsigned char err = msg.readInt8();
+ const unsigned char err = msg.readInt8();
if (mSentPickups.empty())
{
floorId = 0;
@@ -326,7 +326,7 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg)
if (inventory)
{
- Item *item = inventory->getItem(index);
+ const Item *const item = inventory->getItem(index);
if (item && item->getId() == itemId)
amount += item->getQuantity();
@@ -351,7 +351,7 @@ void InventoryHandler::processPlayerInventoryRemove(Net::MessageIn &msg)
amount = msg.readInt16();
if (inventory)
{
- if (Item *item = inventory->getItem(index))
+ if (Item *const item = inventory->getItem(index))
{
item->increaseQuantity(-amount);
if (item->getQuantity() == 0)
@@ -377,7 +377,7 @@ void InventoryHandler::processPlayerInventoryUse(Net::MessageIn &msg)
if (inventory)
{
- if (Item *item = inventory->getItem(index))
+ if (Item *const item = inventory->getItem(index))
{
if (amount)
item->setQuantity(amount);
@@ -405,7 +405,7 @@ void InventoryHandler::processItemUseResponse(Net::MessageIn &msg)
{
if (inventory)
{
- if (Item *item = inventory->getItem(index))
+ if (Item *const item = inventory->getItem(index))
{
if (amount)
item->setQuantity(amount);
@@ -424,7 +424,7 @@ void InventoryHandler::processPlayerStorageStatus(Net::MessageIn &msg)
* packets that update storage contents.
*/
msg.readInt16(); // Used count
- int size = msg.readInt16(); // Max size
+ const int size = msg.readInt16(); // Max size
if (!mStorage)
mStorage = new Inventory(Inventory::STORAGE, size);
@@ -456,7 +456,7 @@ void InventoryHandler::processPlayerStorageAdd(Net::MessageIn &msg)
for (int i = 0; i < 4; i++)
msg.readInt16(); // card i
- if (Item *item = mStorage->getItem(index))
+ if (Item *const item = mStorage->getItem(index))
{
item->setId(itemId, identified);
item->increaseQuantity(amount);
@@ -483,7 +483,7 @@ void InventoryHandler::processPlayerStorageRemove(Net::MessageIn &msg)
amount = msg.readInt16();
if (mStorage)
{
- if (Item *item = mStorage->getItem(index))
+ if (Item *const item = mStorage->getItem(index))
{
item->increaseQuantity(-amount);
if (item->getQuantity() == 0)
@@ -528,7 +528,7 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg)
{
index = msg.readInt16() - INVENTORY_OFFSET;
itemId = msg.readInt16();
- int itemType = msg.readInt8(); // type
+ const int itemType = msg.readInt8(); // type
identified = msg.readInt8(); // identify flag
msg.readInt16(); // equip type
@@ -561,9 +561,9 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg)
void InventoryHandler::processPlayerEquip(Net::MessageIn &msg)
{
- int index = msg.readInt16() - INVENTORY_OFFSET;
- int equipType = msg.readInt16();
- int flag = msg.readInt8();
+ const int index = msg.readInt16() - INVENTORY_OFFSET;
+ const int equipType = msg.readInt16();
+ const int flag = msg.readInt8();
if (!flag)
SERVER_NOTICE(_("Unable to equip."))
@@ -574,8 +574,8 @@ void InventoryHandler::processPlayerEquip(Net::MessageIn &msg)
void InventoryHandler::processPlayerUnEquip(Net::MessageIn &msg)
{
msg.readInt16(); // inder val - INVENTORY_OFFSET;
- int equipType = msg.readInt16();
- int flag = msg.readInt8();
+ const int equipType = msg.readInt16();
+ const int flag = msg.readInt8();
if (flag)
mEquips.setEquipment(getSlot(equipType), -1);
@@ -585,7 +585,7 @@ void InventoryHandler::processPlayerUnEquip(Net::MessageIn &msg)
void InventoryHandler::processPlayerAttackRange(Net::MessageIn &msg)
{
- int range = msg.readInt16();
+ const int range = msg.readInt16();
if (player_node)
player_node->setAttackRange(range);
PlayerInfo::setStatBase(PlayerInfo::ATTACK_RANGE, range);
diff --git a/src/net/ea/itemhandler.cpp b/src/net/ea/itemhandler.cpp
index f4954d3d5..f216fe01a 100644
--- a/src/net/ea/itemhandler.cpp
+++ b/src/net/ea/itemhandler.cpp
@@ -35,14 +35,14 @@ ItemHandler::ItemHandler()
void ItemHandler::processItemVisible(Net::MessageIn &msg)
{
- int id = msg.readInt32();
- int itemId = msg.readInt16();
- unsigned char identify = msg.readInt8(); // identify flag
- int x = msg.readInt16();
- int y = msg.readInt16();
- int amount = msg.readInt16();
- int subX = msg.readInt8();
- int subY = msg.readInt8();
+ const int id = msg.readInt32();
+ const int itemId = msg.readInt16();
+ const unsigned char identify = msg.readInt8(); // identify flag
+ const int x = msg.readInt16();
+ const int y = msg.readInt16();
+ const int amount = msg.readInt16();
+ const int subX = msg.readInt8();
+ const int subY = msg.readInt8();
if (actorSpriteManager)
{
@@ -53,14 +53,14 @@ void ItemHandler::processItemVisible(Net::MessageIn &msg)
void ItemHandler::processItemDropped(Net::MessageIn &msg)
{
- int id = msg.readInt32();
- int itemId = msg.readInt16();
- unsigned char identify = msg.readInt8(); // identify flag
- int x = msg.readInt16();
- int y = msg.readInt16();
- int subX = msg.readInt8();
- int subY = msg.readInt8();
- int amount = msg.readInt16();
+ const int id = msg.readInt32();
+ const int itemId = msg.readInt16();
+ const unsigned char identify = msg.readInt8(); // identify flag
+ const int x = msg.readInt16();
+ const int y = msg.readInt16();
+ const int subX = msg.readInt8();
+ const int subY = msg.readInt8();
+ const int amount = msg.readInt16();
if (actorSpriteManager)
{
@@ -73,8 +73,11 @@ void ItemHandler::processItemRemove(Net::MessageIn &msg)
{
if (actorSpriteManager)
{
- if (FloorItem *item = actorSpriteManager->findItem(msg.readInt32()))
+ if (FloorItem *const item = actorSpriteManager
+ ->findItem(msg.readInt32()))
+ {
actorSpriteManager->destroy(item);
+ }
}
}
diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp
index 18cc26351..09a4066e0 100644
--- a/src/net/ea/loginhandler.cpp
+++ b/src/net/ea/loginhandler.cpp
@@ -78,7 +78,7 @@ void LoginHandler::chooseServer(unsigned int server)
if (server >= mWorlds.size() || !mWorlds[server])
return;
- ServerInfo *charServer = getCharServer();
+ ServerInfo *const charServer = getCharServer();
if (charServer)
{
if (config.getBoolValue("usePersistentIP"))
@@ -130,7 +130,7 @@ void LoginHandler::clearWorlds()
void LoginHandler::procecessCharPasswordResponse(Net::MessageIn &msg)
{
// 0: acc not found, 1: success, 2: password mismatch, 3: pass too short
- int errMsg = msg.readInt8();
+ const int errMsg = msg.readInt8();
// Successful pass change
if (errMsg == 1)
{
@@ -184,7 +184,7 @@ void LoginHandler::processLoginData(Net::MessageIn &msg)
clearWorlds();
- int worldCount = (msg.getLength() - 47) / 32;
+ const int worldCount = (msg.getLength() - 47) / 32;
mToken.session_ID1 = msg.readInt32();
mToken.account_ID = msg.readInt32();
@@ -199,7 +199,7 @@ void LoginHandler::processLoginData(Net::MessageIn &msg)
for (int i = 0; i < worldCount; i++)
{
- WorldInfo *world = new WorldInfo;
+ WorldInfo *const world = new WorldInfo;
world->address = msg.readInt32();
world->port = msg.readInt16();
@@ -220,7 +220,7 @@ void LoginHandler::processLoginData(Net::MessageIn &msg)
void LoginHandler::processLoginError(Net::MessageIn &msg)
{
- int code = msg.readInt8();
+ const int code = msg.readInt8();
logger->log("Login::error code: %i", code);
switch (code)
diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp
index fc50c0971..679ff450d 100644
--- a/src/net/ea/network.cpp
+++ b/src/net/ea/network.cpp
@@ -44,7 +44,7 @@ const unsigned int BUFFER_LIMIT = 930000;
int networkThread(void *data)
{
- Network *network = static_cast<Network*>(data);
+ Network *const network = static_cast<Network *const>(data);
if (!network || !network->realConnect())
return -1;
@@ -62,11 +62,12 @@ Network::Network() :
mOutSize(0),
mToSkip(0),
mState(IDLE),
- mWorkerThread(nullptr)
+ mWorkerThread(nullptr),
+ mMutex(SDL_CreateMutex()),
+ mSleep(config.getIntValue("networksleep"))
{
SDLNet_Init();
- mMutex = SDL_CreateMutex();
}
Network::~Network()
@@ -135,9 +136,8 @@ void Network::disconnect()
// need call SDLNet_TCP_DelSocket?
SDLNet_TCP_Close(mSocket);
mSocket = nullptr;
- int sleep = config.getIntValue("networksleep");
- if (sleep > 0)
- SDL_Delay(sleep);
+ if (mSleep > 0)
+ SDL_Delay(mSleep);
}
}
@@ -237,7 +237,8 @@ void Network::receive()
{
// TODO Try to get this to block all the time while still being able
// to escape the loop
- int numReady = SDLNet_CheckSockets(set, (static_cast<uint32_t>(500)));
+ const int numReady = SDLNet_CheckSockets(
+ set, (static_cast<uint32_t>(500)));
int ret;
switch (numReady)
{
diff --git a/src/net/ea/network.h b/src/net/ea/network.h
index 2fe2037a9..913af7e6b 100644
--- a/src/net/ea/network.h
+++ b/src/net/ea/network.h
@@ -104,6 +104,7 @@ class Network
SDL_Thread *mWorkerThread;
SDL_mutex *mMutex;
+ int mSleep;
};
} // namespace Ea
diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp
index 9ce72fd96..155a1f36f 100644
--- a/src/net/ea/npchandler.cpp
+++ b/src/net/ea/npchandler.cpp
@@ -54,7 +54,7 @@ void NpcHandler::endShopping(int beingId A_UNUSED)
void NpcHandler::clearDialogs()
{
NpcDialogs::iterator it = mNpcDialogs.begin();
- NpcDialogs::iterator it_end = mNpcDialogs.end();
+ const NpcDialogs::iterator it_end = mNpcDialogs.end();
while (it != it_end)
{
delete (*it).second.dialog;
diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp
index fa853bb4b..70207ec2a 100644
--- a/src/net/ea/partyhandler.cpp
+++ b/src/net/ea/partyhandler.cpp
@@ -103,11 +103,11 @@ void PartyHandler::processPartyInfo(Net::MessageIn &msg)
if (Ea::taParty)
Ea::taParty->clearMembers();
- int length = msg.readInt16();
+ const int length = msg.readInt16();
if (Ea::taParty)
Ea::taParty->setName(msg.readString(24));
- int count = (length - 28) / 46;
+ const int count = (length - 28) / 46;
if (player_node && Ea::taParty)
{
player_node->setParty(Ea::taParty);
@@ -116,11 +116,11 @@ void PartyHandler::processPartyInfo(Net::MessageIn &msg)
for (int i = 0; i < count; i++)
{
- int id = msg.readInt32();
+ const int id = msg.readInt32();
std::string nick = msg.readString(24);
std::string map = msg.readString(16);
- bool leader = msg.readInt8() == 0;
- bool online = msg.readInt8() == 0;
+ const bool leader = msg.readInt8() == 0;
+ const bool online = msg.readInt8() == 0;
if (Ea::taParty)
{
@@ -195,10 +195,10 @@ void PartyHandler::processPartyInviteResponse(Net::MessageIn &msg)
void PartyHandler::processPartyInvited(Net::MessageIn &msg)
{
- int id = msg.readInt32();
+ const int id = msg.readInt32();
std::string partyName = msg.readString(24);
std::string nick("");
- Being *being;
+ const Being *being;
if (actorSpriteManager)
{
@@ -225,8 +225,8 @@ void PartyHandler::processPartySettings(Net::MessageIn &msg)
}
// These seem to indicate the sharing mode for exp and items
- short exp = msg.readInt16();
- short item = msg.readInt16();
+ const short exp = msg.readInt16();
+ const short item = msg.readInt16();
if (!Ea::partyTab)
return;
@@ -310,7 +310,7 @@ void PartyHandler::processPartySettings(Net::MessageIn &msg)
void PartyHandler::processPartyMove(Net::MessageIn &msg)
{
- int id = msg.readInt32(); // id
+ const int id = msg.readInt32(); // id
PartyMember *m = nullptr;
if (Ea::taParty)
m = Ea::taParty->getMember(id);
@@ -338,7 +338,7 @@ void PartyHandler::processPartyMove(Net::MessageIn &msg)
void PartyHandler::processPartyLeave(Net::MessageIn &msg)
{
- int id = msg.readInt32();
+ const int id = msg.readInt32();
std::string nick = msg.readString(24);
msg.readInt8(); // fail
if (!player_node)
@@ -369,7 +369,7 @@ void PartyHandler::processPartyLeave(Net::MessageIn &msg)
}
if (actorSpriteManager)
{
- Being *b = actorSpriteManager->findBeing(id);
+ Being *const b = actorSpriteManager->findBeing(id);
if (b && b->getType() == Being::PLAYER)
{
b->setParty(nullptr);
@@ -383,9 +383,9 @@ void PartyHandler::processPartyLeave(Net::MessageIn &msg)
void PartyHandler::processPartyUpdateHp(Net::MessageIn &msg)
{
- int id = msg.readInt32();
- int hp = msg.readInt16();
- int maxhp = msg.readInt16();
+ const int id = msg.readInt32();
+ const int hp = msg.readInt16();
+ const int maxhp = msg.readInt16();
PartyMember *m = nullptr;
if (Ea::taParty)
m = Ea::taParty->getMember(id);
@@ -399,14 +399,14 @@ void PartyHandler::processPartyUpdateHp(Net::MessageIn &msg)
// lets make sure they get the party hilight.
if (actorSpriteManager && Ea::taParty)
{
- if (Being *b = actorSpriteManager->findBeing(id))
+ if (Being *const b = actorSpriteManager->findBeing(id))
b->setParty(Ea::taParty);
}
}
void PartyHandler::processPartyUpdateCoords(Net::MessageIn &msg)
{
- int id = msg.readInt32(); // id
+ const int id = msg.readInt32(); // id
PartyMember *m = nullptr;
if (Ea::taParty)
m = Ea::taParty->getMember(id);
@@ -424,16 +424,16 @@ void PartyHandler::processPartyUpdateCoords(Net::MessageIn &msg)
void PartyHandler::processPartyMessage(Net::MessageIn &msg)
{
- int msgLength = msg.readInt16() - 8;
+ const int msgLength = msg.readInt16() - 8;
if (msgLength <= 0)
return;
- int id = msg.readInt32();
+ const int id = msg.readInt32();
std::string chatMsg = msg.readString(msgLength);
if (Ea::taParty && Ea::partyTab)
{
- PartyMember *member = Ea::taParty->getMember(id);
+ const PartyMember *const member = Ea::taParty->getMember(id);
if (member)
{
Ea::partyTab->chatLog(member->getName(), chatMsg);
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index b73782d3e..de687e96b 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -79,7 +79,7 @@ namespace
if (viewport)
viewport->closePopupMenu();
- Net::NpcHandler *handler = Net::getNpcHandler();
+ Net::NpcHandler *const handler = Net::getNpcHandler();
if (handler)
handler->clearDialogs();
if (player_node)
@@ -205,10 +205,10 @@ void PlayerHandler::processPlayerWarp(Net::MessageIn &msg)
if (player_node)
player_node->stopAttack();
- Game *game = Game::instance();
+ Game *const game = Game::instance();
const std::string &currentMapName = game->getCurrentMapName();
- bool sameMap = (currentMapName == mapPath);
+ const bool sameMap = (currentMapName == mapPath);
// Switch the actual map, deleting the previous one if necessary
mapPath = mapPath.substr(0, mapPath.rfind("."));
@@ -219,7 +219,7 @@ void PlayerHandler::processPlayerWarp(Net::MessageIn &msg)
if (player_node)
{
- Map *map = game->getCurrentMap();
+ const Map *const map = game->getCurrentMap();
if (map)
{
if (x >= map->getWidth())
@@ -262,8 +262,8 @@ void PlayerHandler::processPlayerWarp(Net::MessageIn &msg)
void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
{
- int type = msg.readInt16();
- int value = msg.readInt32();
+ const int type = msg.readInt16();
+ const int value = msg.readInt32();
if (!player_node)
return;
@@ -280,7 +280,7 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
PlayerInfo::setAttribute(PlayerInfo::HP, value);
if (player_node->isInParty() && Party::getParty(1))
{
- PartyMember *m = Party::getParty(1)
+ PartyMember *const m = Party::getParty(1)
->getMember(player_node->getId());
if (m)
{
@@ -294,7 +294,7 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
if (player_node->isInParty() && Party::getParty(1))
{
- PartyMember *m = Party::getParty(1)->getMember(
+ PartyMember *const m = Party::getParty(1)->getMember(
player_node->getId());
if (m)
{
@@ -453,7 +453,7 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
void PlayerHandler::processPlayerStatUpdate2(Net::MessageIn &msg)
{
- int type = msg.readInt16();
+ const int type = msg.readInt16();
switch (type)
{
case 0x0001:
@@ -467,8 +467,8 @@ void PlayerHandler::processPlayerStatUpdate2(Net::MessageIn &msg)
break;
case 0x0014:
{
- int oldMoney = PlayerInfo::getAttribute(PlayerInfo::MONEY);
- int newMoney = msg.readInt32();
+ const int oldMoney = PlayerInfo::getAttribute(PlayerInfo::MONEY);
+ const int newMoney = msg.readInt32();
if (newMoney > oldMoney)
{
SERVER_NOTICE(strprintf(_("You picked up %s."),
@@ -500,9 +500,9 @@ void PlayerHandler::processPlayerStatUpdate2(Net::MessageIn &msg)
void PlayerHandler::processPlayerStatUpdate3(Net::MessageIn &msg)
{
- int type = msg.readInt32();
- int base = msg.readInt32();
- int bonus = msg.readInt32();
+ const int type = msg.readInt32();
+ const int base = msg.readInt32();
+ const int bonus = msg.readInt32();
PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
type), base, false);
@@ -514,13 +514,13 @@ void PlayerHandler::processPlayerStatUpdate3(Net::MessageIn &msg)
void PlayerHandler::processPlayerStatUpdate4(Net::MessageIn &msg)
{
- int type = msg.readInt16();
- int ok = msg.readInt8();
- int value = msg.readInt8();
+ const int type = msg.readInt16();
+ const int ok = msg.readInt8();
+ const int value = msg.readInt8();
if (ok != 1)
{
- int oldValue = PlayerInfo::getStatBase(
+ const int oldValue = PlayerInfo::getStatBase(
static_cast<PlayerInfo::Attribute>(type));
int points = PlayerInfo::getAttribute(PlayerInfo::CHAR_POINTS);
points += oldValue - value;
@@ -616,7 +616,7 @@ void PlayerHandler::processPlayerStatUpdate5(Net::MessageIn &msg)
void PlayerHandler::processPlayerStatUpdate6(Net::MessageIn &msg)
{
- int type = msg.readInt16();
+ const int type = msg.readInt16();
if (statusWindow)
{
switch (type)
@@ -649,7 +649,7 @@ void PlayerHandler::processPlayerStatUpdate6(Net::MessageIn &msg)
void PlayerHandler::processPlayerArrowMessage(Net::MessageIn &msg)
{
- int type = msg.readInt16();
+ const int type = msg.readInt16();
switch (type)
{
diff --git a/src/net/ea/specialhandler.cpp b/src/net/ea/specialhandler.cpp
index 226531a11..7bb69954f 100644
--- a/src/net/ea/specialhandler.cpp
+++ b/src/net/ea/specialhandler.cpp
@@ -84,14 +84,14 @@ void SpecialHandler::processPlayerSkills(Net::MessageIn &msg)
for (int k = 0; k < skillCount; k++)
{
- int skillId = msg.readInt16();
+ const int skillId = msg.readInt16();
msg.readInt16(); // target type
msg.skip(2); // skill pool flags
- int level = msg.readInt16();
+ const int level = msg.readInt16();
msg.readInt16(); // sp
- int range = msg.readInt16();
+ const int range = msg.readInt16();
msg.skip(24); // 0 unused
- int up = msg.readInt8();
+ const int up = msg.readInt8();
PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
skillId), level);
@@ -108,8 +108,8 @@ void SpecialHandler::processPlayerSkillUp(Net::MessageIn &msg)
const int skillId = msg.readInt16();
const int level = msg.readInt16();
msg.readInt16(); // sp
- int range = msg.readInt16();
- int up = msg.readInt8();
+ const int range = msg.readInt16();
+ const int up = msg.readInt8();
PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
skillId), level);
@@ -127,8 +127,8 @@ void SpecialHandler::processSkillFailed(Net::MessageIn &msg)
const int skillId = msg.readInt16();
const short bskill = msg.readInt16();
msg.readInt16(); // btype
- char success = msg.readInt8();
- char reason = msg.readInt8();
+ const char success = msg.readInt8();
+ const char reason = msg.readInt8();
if (success != static_cast<int>(SKILL_FAILED)
&& bskill == static_cast<int>(BSKILL_EMOTE))
{
diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp
index fb49bdc62..32ddcfb98 100644
--- a/src/net/ea/tradehandler.cpp
+++ b/src/net/ea/tradehandler.cpp
@@ -177,11 +177,11 @@ void TradeHandler::processTradeResponse(Net::MessageIn &msg)
void TradeHandler::processTradeItemAdd(Net::MessageIn &msg)
{
- int amount = msg.readInt32();
- int type = msg.readInt16();
- int identify = msg.readInt8(); // identified flag
+ const int amount = msg.readInt32();
+ const int type = msg.readInt16();
+ const int identify = msg.readInt8(); // identified flag
msg.readInt8(); // attribute
- int refine = msg.readInt8(); // refine
+ const int refine = msg.readInt8(); // refine
msg.skip(8); // card (4 shorts)
// TODO: handle also identified, etc
@@ -213,9 +213,9 @@ void TradeHandler::processTradeItemAddResponse(Net::MessageIn &msg)
tradeWindow->receivedOk(true);
return;
}
- int quantity = msg.readInt16();
+ const int quantity = msg.readInt16();
- int res = msg.readInt8();
+ const int res = msg.readInt8();
switch (res)
{
case 0:
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());
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index ca1d86881..acce46592 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -62,8 +62,8 @@ void MessageIn::readCoordinates(uint16_t &x, uint16_t &y)
{
if (mPos + 3 <= mLength)
{
- unsigned char const *p
- = reinterpret_cast< unsigned char const * >(mData + mPos);
+ unsigned char const *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));
}
@@ -111,7 +111,7 @@ void MessageIn::readCoordinates(uint16_t &x, uint16_t &y, uint8_t &direction)
uint8_t serverDir = 0;
if (mPos + 3 <= mLength)
{
- const char *data = mData + mPos;
+ const char *const data = mData + mPos;
int16_t temp;
temp = MAKEWORD(data[1] & 0x00c0, data[0] & 0x00ff);
@@ -134,7 +134,7 @@ void MessageIn::readCoordinatePair(uint16_t &srcX, uint16_t &srcY,
{
if (mPos + 5 <= mLength)
{
- const char *data = mData + mPos;
+ const char *const data = mData + mPos;
int16_t temp;
temp = MAKEWORD(data[3], data[2] & 0x000f);
@@ -178,8 +178,8 @@ std::string MessageIn::readString(int length)
}
// Read the string
- char const *stringBeg = mData + mPos;
- char const *stringEnd
+ char const *const stringBeg = mData + mPos;
+ char const *const stringEnd
= static_cast<char const *>(memchr(stringBeg, '\0', length));
std::string str(stringBeg, stringEnd ? stringEnd - stringBeg : length);
@@ -203,9 +203,9 @@ std::string MessageIn::readRawString(int length)
}
// Read the string
- char const *stringBeg = mData + mPos;
- char const *stringEnd
- = static_cast<char const *>(memchr(stringBeg, '\0', length));
+ char const *const stringBeg = mData + mPos;
+ char const *const stringEnd
+ = static_cast<char const *const>(memchr(stringBeg, '\0', length));
std::string str(stringBeg, stringEnd ? stringEnd - stringBeg : length);
mPos += length;
@@ -214,10 +214,10 @@ std::string MessageIn::readRawString(int length)
if (stringEnd)
{
- long len2 = length - (stringEnd - stringBeg) - 1;
- char const *stringBeg2 = stringEnd + 1;
- char const *stringEnd2
- = static_cast<char const *>(memchr(stringBeg2, '\0', len2));
+ const long len2 = length - (stringEnd - stringBeg) - 1;
+ char const *const stringBeg2 = stringEnd + 1;
+ char const *const stringEnd2
+ = static_cast<char const *const>(memchr(stringBeg2, '\0', len2));
std::string hiddenPart = std::string(stringBeg2,
stringEnd2 ? stringEnd2 - stringBeg2 : len2);
if (hiddenPart.length() > 0)
@@ -245,7 +245,7 @@ unsigned char *MessageIn::readBytes(int length)
return nullptr;
}
- unsigned char *buf = new unsigned char[length + 2];
+ unsigned char *const buf = new unsigned char[length + 2];
memcpy (buf, mData + mPos, length);
buf[length] = 0;
diff --git a/src/net/net.cpp b/src/net/net.cpp
index bfa46d086..1f8195f06 100644
--- a/src/net/net.cpp
+++ b/src/net/net.cpp
@@ -204,7 +204,7 @@ void connectToServer(const ServerInfo &server)
void unload()
{
- GeneralHandler *handler = getGeneralHandler();
+ GeneralHandler *const handler = getGeneralHandler();
if (handler)
handler->unload();
}
diff --git a/src/net/packetcounters.cpp b/src/net/packetcounters.cpp
index dc504768e..6fb8588fe 100644
--- a/src/net/packetcounters.cpp
+++ b/src/net/packetcounters.cpp
@@ -106,7 +106,7 @@ int PacketCounters::getOutPackets()
void PacketCounters::updateCounter(int &currentSec, int &calc, int &counter)
{
- int idx = cur_time % 60;
+ const int idx = cur_time % 60;
if (currentSec != idx)
{
currentSec = idx;
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);
}