diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-01-26 16:21:43 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-01-29 14:18:06 +0100 |
commit | e7c285e3423ddd660447f6a6fc6bbae25f99f386 (patch) | |
tree | 1d700f09a5e96a2a0d390af30581097bdec0bf77 /src/resources/hairdb.cpp | |
parent | e1a7c1d0ca30c2c4a293ffbff6b9c51c881d23e3 (diff) | |
download | mana-e7c285e3423ddd660447f6a6fc6bbae25f99f386.tar.gz mana-e7c285e3423ddd660447f6a6fc6bbae25f99f386.tar.bz2 mana-e7c285e3423ddd660447f6a6fc6bbae25f99f386.tar.xz mana-e7c285e3423ddd660447f6a6fc6bbae25f99f386.zip |
Apply C++11 fixits
modernize-loop-convert
modernize-deprecated-headers
Diffstat (limited to 'src/resources/hairdb.cpp')
-rw-r--r-- | src/resources/hairdb.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/resources/hairdb.cpp b/src/resources/hairdb.cpp index 4ca4fa5c..310ba0c4 100644 --- a/src/resources/hairdb.cpp +++ b/src/resources/hairdb.cpp @@ -23,7 +23,7 @@ #include "log.h" -#include <assert.h> +#include <cassert> #define COLOR_WHITE "#ffffff" @@ -78,31 +78,30 @@ void HairDB::addHairStyle(int id) mHairStyles.insert(id); } -const std::string &HairDB::getHairColor(int id) +const std::string &HairDB::getHairColor(int id) const { if (!mLoaded) { // no idea if this can happen, but that check existed before logger->log("WARNING: HairDB::getHairColor() called before settings were loaded!"); } - ColorConstIterator it = mHairColors.find(id); + auto it = mHairColors.find(id); if (it != mHairColors.end()) return it->second; logger->log("HairDb: Error, unknown color Id# %d", id); - return mHairColors[0]; + return mHairColors.at(0); } std::vector<int> HairDB::getHairStyleIds(int maxId) const { std::vector<int> hairStylesIds; - for (auto it = mHairStyles.begin(), - it_end = mHairStyles.end(); it != it_end; ++it) + for (int hairStyle : mHairStyles) { // Don't give ids higher than the requested maximum. - if (maxId > 0 && (*it) > maxId) + if (maxId > 0 && hairStyle > maxId) continue; - hairStylesIds.push_back(*it); + hairStylesIds.push_back(hairStyle); } return hairStylesIds; } @@ -110,13 +109,12 @@ std::vector<int> HairDB::getHairStyleIds(int maxId) const std::vector<int> HairDB::getHairColorIds(int maxId) const { std::vector<int> hairColorsIds; - for (auto it = mHairColors.begin(), - it_end = mHairColors.end(); it != it_end; ++it) + for (const auto &hairColor : mHairColors) { // Don't give ids higher than the requested maximum. - if (maxId > 0 && it->first > maxId) + if (maxId > 0 && hairColor.first > maxId) continue; - hairColorsIds.push_back(it->first); + hairColorsIds.push_back(hairColor.first); } return hairColorsIds; } |