mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 03:35:27 +00:00
Merge branch 'classy' into 'master'
Replace empty NPC class with fallback Closes #6799 See merge request OpenMW/openmw!1982
This commit is contained in:
commit
8bce0a1bcf
@ -120,6 +120,7 @@
|
||||
Bug #6730: LoopGroup stalls animation after playing :Stop frame until another animation is played
|
||||
Bug #6753: Info records without a DATA subrecords are loaded incorrectly
|
||||
Bug #6794: Light sources are attached to mesh bounds centers instead of mesh origins when AttachLight NiNode is missing
|
||||
Bug #6799: Game crashes if an NPC has no Class attached
|
||||
Feature #890: OpenMW-CS: Column filtering
|
||||
Feature #1465: "Reset" argument for AI functions
|
||||
Feature #2491: Ability to make OpenMW "portable"
|
||||
|
@ -59,15 +59,18 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
const std::string& getDefaultClass(const MWWorld::Store<ESM::Class>& classes)
|
||||
{
|
||||
auto it = classes.begin();
|
||||
if (it != classes.end())
|
||||
return it->mId;
|
||||
throw std::runtime_error("List of NPC classes is empty!");
|
||||
}
|
||||
|
||||
std::vector<ESM::NPC> getNPCsToReplace(const MWWorld::Store<ESM::Faction>& factions, const MWWorld::Store<ESM::Class>& classes, const std::unordered_map<std::string, ESM::NPC, Misc::StringUtils::CiHash, Misc::StringUtils::CiEqual>& npcs)
|
||||
{
|
||||
// Cache first class from store - we will use it if current class is not found
|
||||
std::string defaultCls;
|
||||
auto it = classes.begin();
|
||||
if (it != classes.end())
|
||||
defaultCls = it->mId;
|
||||
else
|
||||
throw std::runtime_error("List of NPC classes is empty!");
|
||||
const std::string& defaultCls = getDefaultClass(classes);
|
||||
|
||||
// Validate NPCs for non-existing class and faction.
|
||||
// We will replace invalid entries by fixed ones
|
||||
@ -78,7 +81,7 @@ namespace
|
||||
ESM::NPC npc = npcIter.second;
|
||||
bool changed = false;
|
||||
|
||||
const std::string npcFaction = npc.mFaction;
|
||||
const std::string& npcFaction = npc.mFaction;
|
||||
if (!npcFaction.empty())
|
||||
{
|
||||
const ESM::Faction *fact = factions.search(npcFaction);
|
||||
@ -91,16 +94,13 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
std::string npcClass = npc.mClass;
|
||||
if (!npcClass.empty())
|
||||
const std::string& npcClass = npc.mClass;
|
||||
const ESM::Class *cls = classes.search(npcClass);
|
||||
if (!cls)
|
||||
{
|
||||
const ESM::Class *cls = classes.search(npcClass);
|
||||
if (!cls)
|
||||
{
|
||||
Log(Debug::Verbose) << "NPC '" << npc.mId << "' (" << npc.mName << ") has nonexistent class '" << npc.mClass << "', using '" << defaultCls << "' class as replacement.";
|
||||
npc.mClass = defaultCls;
|
||||
changed = true;
|
||||
}
|
||||
Log(Debug::Verbose) << "NPC '" << npc.mId << "' (" << npc.mName << ") has nonexistent class '" << npc.mClass << "', using '" << defaultCls << "' class as replacement.";
|
||||
npc.mClass = defaultCls;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (changed)
|
||||
|
Loading…
x
Reference in New Issue
Block a user