From 555e43855d1d65576a6c47253cf414ead3b15d04 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Sun, 12 May 2019 20:57:54 +0300 Subject: [PATCH 1/2] Allow scripted faction leaving using PCLowerRank (feature #5036) --- CHANGELOG.md | 1 + apps/openmw/mwmechanics/npcstats.cpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2646bcbbda..5be672229e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -115,6 +115,7 @@ Feature #5010: Native graphics herbalism support Feature #5031: Make GetWeaponType function return different values for tools Feature #5033: Magic armor mitigation for creatures + Feature #5036: Allow scripted faction leaving Task #4686: Upgrade media decoder to a more current FFmpeg API Task #4695: Optimize Distant Terrain memory consumption Task #4721: Add NMake support to the Windows prebuild script diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index df61ee93b4..8a554ce127 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -85,7 +85,9 @@ void MWMechanics::NpcStats::lowerRank(const std::string &faction) std::map::iterator it = mFactionRank.find(lower); if (it != mFactionRank.end()) { - it->second = std::max(0, it->second-1); + it->second = it->second-1; + if (it->second < 0) + mFactionRank.erase(it); } } From bb0c989f879c22029a9cea0f6c41423ab23dc294 Mon Sep 17 00:00:00 2001 From: Alexei Dobrohotov <21265616+Capostrophic@users.noreply.github.com> Date: Mon, 13 May 2019 10:22:03 +0300 Subject: [PATCH 2/2] Clear expelled status when leaving faction --- apps/openmw/mwmechanics/npcstats.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index 8a554ce127..0d16e3a85b 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -87,7 +87,10 @@ void MWMechanics::NpcStats::lowerRank(const std::string &faction) { it->second = it->second-1; if (it->second < 0) + { mFactionRank.erase(it); + mExpelled.erase(lower); + } } }