summaryrefslogtreecommitdiff
path: root/src/net/manaserv/charhandler.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-12 15:46:39 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-13 11:03:27 +0100
commitd62f7855e304553a672508d2167aee15b1cb99ad (patch)
treec23e04b4e0663bcc6219ce11e74c6b5735718d24 /src/net/manaserv/charhandler.cpp
parent55dbddded11691ece499370b49215011d3c867f0 (diff)
downloadmana-d62f7855e304553a672508d2167aee15b1cb99ad.tar.gz
mana-d62f7855e304553a672508d2167aee15b1cb99ad.tar.bz2
mana-d62f7855e304553a672508d2167aee15b1cb99ad.tar.xz
mana-d62f7855e304553a672508d2167aee15b1cb99ad.zip
Cleaned up some code in CharHandler::updateCharactersmanaserv-char-attr
This is Manaserv related code, which can't be tested right now due to protocol changes.
Diffstat (limited to 'src/net/manaserv/charhandler.cpp')
-rw-r--r--src/net/manaserv/charhandler.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp
index e7afa173..be32a12d 100644
--- a/src/net/manaserv/charhandler.cpp
+++ b/src/net/manaserv/charhandler.cpp
@@ -113,11 +113,10 @@ void CharHandler::handleCharacterInfo(MessageIn &msg)
while (msg.getUnreadLength() > 0)
{
int id = msg.readInt32();
- CachedAttrbiute attr;
+
+ CachedAttrbiute &attr = info.attributes[id];
attr.base = msg.readInt32() / 256.0;
attr.mod = msg.readInt32() / 256.0;
-
- info.attribute[id] = attr;
}
mCachedCharacterInfos.push_back(info);
@@ -380,10 +379,8 @@ void CharHandler::updateCharacters()
return;
// Create new characters and initialize them from the cached infos
- for (unsigned i = 0; i < mCachedCharacterInfos.size(); ++i)
+ for (const auto &info : mCachedCharacterInfos)
{
- const CachedCharacterInfo &info = mCachedCharacterInfos.at(i);
-
auto *character = new Net::Character;
character->slot = info.slot;
LocalPlayer *player = character->dummy = new LocalPlayer;
@@ -395,10 +392,10 @@ void CharHandler::updateCharacters()
character->data.mAttributes[CHAR_POINTS] = info.characterPoints;
character->data.mAttributes[CORR_POINTS] = info.correctionPoints;
- for (const auto &it : info.attribute)
+ for (const auto &[id, attr] : info.attributes)
{
- character->data.mStats[i].base = it.second.base;
- character->data.mStats[i].mod = it.second.mod;
+ character->data.mStats[id].base = attr.base;
+ character->data.mStats[id].mod = attr.mod;
}
mCharacters.push_back(character);