mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-09-08 20:05:19 -04:00
Redo debug warnings in interpreter
This commit is contained in:
parent
67795543a2
commit
61ebb4b259
@ -4,6 +4,7 @@
|
||||
#include <sstream>
|
||||
|
||||
#include <components/compiler/locals.hpp>
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/esm/records.hpp>
|
||||
|
||||
#include "../mwworld/esmstore.hpp"
|
||||
@ -300,7 +301,16 @@ namespace MWScript
|
||||
|
||||
std::string_view InterpreterContext::getNPCFaction() const
|
||||
{
|
||||
const ESM::NPC* npc = getReferenceImp().get<ESM::NPC>()->mBase;
|
||||
const MWWorld::Ptr& ptr = getReferenceImp();
|
||||
const MWWorld::Class& ptrClass = ptr.getClass();
|
||||
const ESM::RefId& factionId = ptrClass.getPrimaryFaction(ptr);
|
||||
if (factionId.empty())
|
||||
{
|
||||
Log(Debug::Warning) << "getNPCFaction(): NPC " << ptrClass.getName(ptr) << " has no primary faction";
|
||||
return "%";
|
||||
}
|
||||
|
||||
const ESM::NPC* npc = ptr.get<ESM::NPC>()->mBase;
|
||||
const ESM::Faction* faction = MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(npc->mFaction);
|
||||
return faction->mName;
|
||||
}
|
||||
@ -308,18 +318,26 @@ namespace MWScript
|
||||
std::string_view InterpreterContext::getNPCRank() const
|
||||
{
|
||||
const MWWorld::Ptr& ptr = getReferenceImp();
|
||||
const ESM::RefId& faction = ptr.getClass().getPrimaryFaction(ptr);
|
||||
if (faction.empty())
|
||||
throw std::runtime_error("getNPCRank(): NPC is not in a faction");
|
||||
|
||||
int rank = ptr.getClass().getPrimaryFactionRank(ptr);
|
||||
if (rank < 0 || rank > 9)
|
||||
throw std::runtime_error("getNPCRank(): invalid rank");
|
||||
const MWWorld::Class& ptrClass = ptr.getClass();
|
||||
const ESM::RefId& factionId = ptrClass.getPrimaryFaction(ptr);
|
||||
if (factionId.empty())
|
||||
{
|
||||
Log(Debug::Warning) << "getNPCRank(): NPC " << ptrClass.getName(ptr) << " has no primary faction";
|
||||
return "%";
|
||||
}
|
||||
|
||||
MWBase::World* world = MWBase::Environment::get().getWorld();
|
||||
const MWWorld::ESMStore& store = world->getStore();
|
||||
const ESM::Faction* fact = store.get<ESM::Faction>().find(faction);
|
||||
return fact->mRanks[rank];
|
||||
const ESM::Faction* faction = store.get<ESM::Faction>().find(factionId);
|
||||
|
||||
int rank = ptrClass.getPrimaryFactionRank(ptr);
|
||||
if (rank < 0 || rank > 9)
|
||||
{
|
||||
Log(Debug::Warning) << "getNPCRank(): NPC " << ptrClass.getName(ptr) << " has invalid rank " << rank
|
||||
<< " in faction " << faction->mName;
|
||||
return "%";
|
||||
}
|
||||
return faction->mRanks[rank];
|
||||
}
|
||||
|
||||
std::string_view InterpreterContext::getPCName() const
|
||||
@ -344,13 +362,17 @@ namespace MWScript
|
||||
|
||||
std::string_view InterpreterContext::getPCRank() const
|
||||
{
|
||||
const MWWorld::Ptr& ptr = getReferenceImp();
|
||||
const MWWorld::Class& ptrClass = ptr.getClass();
|
||||
const ESM::RefId& factionId = ptrClass.getPrimaryFaction(ptr);
|
||||
if (factionId.empty())
|
||||
{
|
||||
Log(Debug::Warning) << "getPCRank(): NPC " << ptrClass.getName(ptr) << " has no primary faction";
|
||||
return "%";
|
||||
}
|
||||
|
||||
MWBase::World* world = MWBase::Environment::get().getWorld();
|
||||
MWWorld::Ptr player = world->getPlayerPtr();
|
||||
|
||||
const ESM::RefId& factionId = getReferenceImp().getClass().getPrimaryFaction(getReferenceImp());
|
||||
if (factionId.empty())
|
||||
throw std::runtime_error("getPCRank(): NPC is not in a faction");
|
||||
|
||||
const auto& ranks = player.getClass().getNpcStats(player).getFactionRanks();
|
||||
auto it = ranks.find(factionId);
|
||||
int rank = -1;
|
||||
@ -373,13 +395,17 @@ namespace MWScript
|
||||
|
||||
std::string_view InterpreterContext::getPCNextRank() const
|
||||
{
|
||||
const MWWorld::Ptr& ptr = getReferenceImp();
|
||||
const MWWorld::Class& ptrClass = ptr.getClass();
|
||||
const ESM::RefId& factionId = ptrClass.getPrimaryFaction(ptr);
|
||||
if (factionId.empty())
|
||||
{
|
||||
Log(Debug::Warning) << "getPCNextRank(): NPC " << ptrClass.getName(ptr) << " has no primary faction";
|
||||
return "%";
|
||||
}
|
||||
|
||||
MWBase::World* world = MWBase::Environment::get().getWorld();
|
||||
MWWorld::Ptr player = world->getPlayerPtr();
|
||||
|
||||
const ESM::RefId& factionId = getReferenceImp().getClass().getPrimaryFaction(getReferenceImp());
|
||||
if (factionId.empty())
|
||||
throw std::runtime_error("getPCNextRank(): NPC is not in a faction");
|
||||
|
||||
const auto& ranks = player.getClass().getNpcStats(player).getFactionRanks();
|
||||
auto it = ranks.find(factionId);
|
||||
int rank = -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user