1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 06:35:30 +00:00

added test for actor ID

This commit is contained in:
Marc Zinnschlag 2010-08-08 14:28:35 +02:00
parent 8086933282
commit 2acfe22975
7 changed files with 36 additions and 2 deletions

View File

@ -10,6 +10,14 @@
namespace MWClass
{
std::string Creature::getId (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
ptr.get<ESM::Creature>();
return ref->base->mId;
}
std::string Creature::getName (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =

View File

@ -9,6 +9,9 @@ namespace MWClass
{
public:
virtual std::string getId (const MWWorld::Ptr& ptr) const;
///< Return ID of \a ptr
virtual std::string getName (const MWWorld::Ptr& ptr) const;
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.

View File

@ -10,6 +10,14 @@
namespace MWClass
{
std::string Npc::getId (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
ptr.get<ESM::NPC>();
return ref->base->mId;
}
std::string Npc::getName (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =

View File

@ -9,6 +9,9 @@ namespace MWClass
{
public:
virtual std::string getId (const MWWorld::Ptr& ptr) const;
///< Return ID of \a ptr
virtual std::string getName (const MWWorld::Ptr& ptr) const;
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.

View File

@ -114,7 +114,11 @@ namespace MWDialogue
bool DialogueManager::isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const
{
// TODO check actor id
// actor id
if (!info.actor.empty())
if (info.actor!=MWWorld::Class::get (actor).getId (actor))
return false;
// TODO check actor race
// TODO check actor class
// TODO check actor faction
@ -134,7 +138,6 @@ namespace MWDialogue
std::cout
<< "unchecked entries:" << std::endl
<< " actor id: " << info.actor << std::endl
<< " actor race: " << info.race << std::endl
<< " actor class: " << info.clas << std::endl
<< " actor faction: " << info.npcFaction << std::endl

View File

@ -14,6 +14,11 @@ namespace MWWorld
Class::~Class() {}
std::string Class::getId (const Ptr& ptr) const
{
throw std::runtime_error ("class does not support ID retrieval");
}
MWMechanics::CreatureStats& Class::getCreatureStats (const Ptr& ptr) const
{
throw std::runtime_error ("class does not have creature stats");

View File

@ -36,6 +36,10 @@ namespace MWWorld
virtual ~Class();
virtual std::string getId (const Ptr& ptr) const;
///< Return ID of \a ptr or throw an exception, if class does not support ID retrieval
/// (default implementation: throw an exception)
virtual std::string getName (const Ptr& ptr) const = 0;
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.