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