diff --git a/CHANGELOG.md b/CHANGELOG.md index 587e5e7a52..03b5769c70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -223,6 +223,7 @@ Feature #7860: Lua: Expose NPC AI settings (fight, alarm, flee) Feature #7875: Disable MyGUI windows snapping Feature #7914: Do not allow to move GUI windows out of screen + Feature #7923: Don't show non-existent higher ranks for factions with fewer than 9 ranks Task #5896: Do not use deprecated MyGUI properties Task #6085: Replace boost::filesystem with std::filesystem Task #6149: Dehardcode Lua API_REVISION diff --git a/apps/openmw/mwgui/statswindow.cpp b/apps/openmw/mwgui/statswindow.cpp index 6e7d2c2ba2..69f0b4b449 100644 --- a/apps/openmw/mwgui/statswindow.cpp +++ b/apps/openmw/mwgui/statswindow.cpp @@ -582,9 +582,8 @@ namespace MWGui const std::set& expelled = PCstats.getExpelled(); bool firstFaction = true; - for (auto& factionPair : mFactions) + for (const auto& [factionId, factionRank] : mFactions) { - const ESM::RefId& factionId = factionPair.first; const ESM::Faction* faction = store.get().find(factionId); if (faction->mData.mIsHidden == 1) continue; @@ -611,10 +610,10 @@ namespace MWGui text += "\n#{fontcolourhtml=normal}#{sExpelled}"; else { - const int rank = std::clamp(factionPair.second, 0, 9); - text += std::string("\n#{fontcolourhtml=normal}") + faction->mRanks[rank]; - - if (rank < 9) + const auto rank = static_cast(std::max(0, factionRank)); + if (rank < faction->mRanks.size()) + text += std::string("\n#{fontcolourhtml=normal}") + faction->mRanks[rank]; + if (rank + 1 < faction->mRanks.size() && !faction->mRanks[rank + 1].empty()) { // player doesn't have max rank yet text += std::string("\n\n#{fontcolourhtml=header}#{sNextRank} ") + faction->mRanks[rank + 1];