mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-19 17:09:40 +00:00
Don't crash in StatsWindow for invalid faction rank values
PcRaiseRank: don't allow to raise rank beyond max rank
This commit is contained in:
parent
2193977eec
commit
c3e4160a0a
2 changed files with 9 additions and 5 deletions
|
@ -488,14 +488,16 @@ namespace MWGui
|
|||
text += "\n#BF9959#{sExpelled}";
|
||||
else
|
||||
{
|
||||
text += std::string("\n#BF9959") + faction->mRanks[it->second];
|
||||
int rank = it->second;
|
||||
rank = std::max(0, std::min(9, rank));
|
||||
text += std::string("\n#BF9959") + faction->mRanks[rank];
|
||||
|
||||
if (it->second < 9)
|
||||
if (rank < 9)
|
||||
{
|
||||
// player doesn't have max rank yet
|
||||
text += std::string("\n\n#DDC79E#{sNextRank} ") + faction->mRanks[it->second+1];
|
||||
text += std::string("\n\n#DDC79E#{sNextRank} ") + faction->mRanks[rank+1];
|
||||
|
||||
ESM::RankData rankData = faction->mData.mRankData[it->second+1];
|
||||
ESM::RankData rankData = faction->mData.mRankData[rank+1];
|
||||
const ESM::Attribute* attr1 = store.get<ESM::Attribute>().find(faction->mData.mAttribute[0]);
|
||||
const ESM::Attribute* attr2 = store.get<ESM::Attribute>().find(faction->mData.mAttribute[1]);
|
||||
|
||||
|
|
|
@ -587,7 +587,9 @@ namespace MWScript
|
|||
}
|
||||
else
|
||||
{
|
||||
player.getClass().getNpcStats(player).getFactionRanks()[factionID] = player.getClass().getNpcStats(player).getFactionRanks()[factionID] +1;
|
||||
player.getClass().getNpcStats(player).getFactionRanks()[factionID] =
|
||||
std::min(player.getClass().getNpcStats(player).getFactionRanks()[factionID] +1,
|
||||
9);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue