diff options
Diffstat (limited to 'src/net/manaserv')
-rw-r--r-- | src/net/manaserv/charhandler.cpp | 15 | ||||
-rw-r--r-- | src/net/manaserv/charhandler.h | 4 |
2 files changed, 7 insertions, 12 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); diff --git a/src/net/manaserv/charhandler.h b/src/net/manaserv/charhandler.h index 9ec5cdbb..3fabc81c 100644 --- a/src/net/manaserv/charhandler.h +++ b/src/net/manaserv/charhandler.h @@ -94,8 +94,6 @@ class CharHandler final : public MessageHandler, public Net::CharHandler double mod; }; - using CachedAttributes = std::map<int, CachedAttrbiute>; - struct CachedCharacterInfo { int slot; std::string name; @@ -105,7 +103,7 @@ class CharHandler final : public MessageHandler, public Net::CharHandler int level; int characterPoints; int correctionPoints; - CachedAttributes attribute; + std::map<int, CachedAttrbiute> attributes; }; void handleCharacterInfo(MessageIn &msg); |