1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-25 16:43:33 +00:00

Fixed assorted issues

* destructor is virtual
* renamed class to Actor
* corrected indentation of case statement
This commit is contained in:
dteviot 2015-08-25 18:19:16 +12:00
parent bb54bbd273
commit 541d7fb4fb
6 changed files with 31 additions and 31 deletions

View File

@ -74,7 +74,7 @@ add_openmw_dir (mwphysics
add_openmw_dir (mwclass add_openmw_dir (mwclass
classes activator creature npc weapon armor potion apparatus book clothing container door classes activator creature npc weapon armor potion apparatus book clothing container door
ingredient creaturelevlist itemlevlist light lockpick misc probe repair static mobile ingredient creaturelevlist itemlevlist light lockpick misc probe repair static actor
) )
add_openmw_dir (mwmechanics add_openmw_dir (mwmechanics

View File

@ -1,4 +1,4 @@
#include "mobile.hpp" #include "actor.hpp"
#include <components/esm/loadmgef.hpp> #include <components/esm/loadmgef.hpp>
@ -17,16 +17,16 @@
namespace MWClass namespace MWClass
{ {
Mobile::Mobile() {} Actor::Actor() {}
Mobile::~Mobile() {} Actor::~Actor() {}
void Mobile::adjustPosition(const MWWorld::Ptr& ptr, bool force) const void Actor::adjustPosition(const MWWorld::Ptr& ptr, bool force) const
{ {
MWBase::Environment::get().getWorld()->adjustPosition(ptr, force); MWBase::Environment::get().getWorld()->adjustPosition(ptr, force);
} }
void Mobile::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const void Actor::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
{ {
if (!model.empty()) if (!model.empty())
{ {
@ -37,7 +37,7 @@ namespace MWClass
MWBase::Environment::get().getMechanicsManager()->add(ptr); MWBase::Environment::get().getMechanicsManager()->add(ptr);
} }
void Mobile::block(const MWWorld::Ptr &ptr) const void Actor::block(const MWWorld::Ptr &ptr) const
{ {
MWWorld::InventoryStore& inv = getInventoryStore(ptr); MWWorld::InventoryStore& inv = getInventoryStore(ptr);
MWWorld::ContainerStoreIterator shield = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft); MWWorld::ContainerStoreIterator shield = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
@ -47,26 +47,26 @@ namespace MWClass
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager(); MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
switch (shield->getClass().getEquipmentSkill(*shield)) switch (shield->getClass().getEquipmentSkill(*shield))
{ {
case ESM::Skill::LightArmor: case ESM::Skill::LightArmor:
sndMgr->playSound3D(ptr, "Light Armor Hit", 1.0f, 1.0f); sndMgr->playSound3D(ptr, "Light Armor Hit", 1.0f, 1.0f);
break; break;
case ESM::Skill::MediumArmor: case ESM::Skill::MediumArmor:
sndMgr->playSound3D(ptr, "Medium Armor Hit", 1.0f, 1.0f); sndMgr->playSound3D(ptr, "Medium Armor Hit", 1.0f, 1.0f);
break; break;
case ESM::Skill::HeavyArmor: case ESM::Skill::HeavyArmor:
sndMgr->playSound3D(ptr, "Heavy Armor Hit", 1.0f, 1.0f); sndMgr->playSound3D(ptr, "Heavy Armor Hit", 1.0f, 1.0f);
break; break;
default: default:
return; return;
} }
} }
bool Mobile::hasToolTip(const MWWorld::Ptr& ptr) const bool Actor::hasToolTip(const MWWorld::Ptr& ptr) const
{ {
return !ptr.getClass().getCreatureStats(ptr).getAiSequence().isInCombat() || getCreatureStats(ptr).isDead(); return !ptr.getClass().getCreatureStats(ptr).getAiSequence().isInCombat() || getCreatureStats(ptr).isDead();
} }
osg::Vec3f Mobile::getRotationVector(const MWWorld::Ptr& ptr) const osg::Vec3f Actor::getRotationVector(const MWWorld::Ptr& ptr) const
{ {
MWMechanics::Movement &movement = getMovementSettings(ptr); MWMechanics::Movement &movement = getMovementSettings(ptr);
osg::Vec3f vec(movement.mRotation[0], movement.mRotation[1], movement.mRotation[2]); osg::Vec3f vec(movement.mRotation[0], movement.mRotation[1], movement.mRotation[2]);
@ -76,7 +76,7 @@ namespace MWClass
return vec; return vec;
} }
float Mobile::getEncumbrance(const MWWorld::Ptr& ptr) const float Actor::getEncumbrance(const MWWorld::Ptr& ptr) const
{ {
float weight = getContainerStore(ptr).getWeight(); float weight = getContainerStore(ptr).getWeight();
const MWMechanics::MagicEffects& effects = getCreatureStats(ptr).getMagicEffects(); const MWMechanics::MagicEffects& effects = getCreatureStats(ptr).getMagicEffects();

View File

@ -11,14 +11,14 @@ namespace ESM
namespace MWClass namespace MWClass
{ {
/// \brief Class holding functionality common to Creature and NPC /// \brief Class holding functionality common to Creature and NPC
class Mobile : public MWWorld::Class class Actor : public MWWorld::Class
{ {
protected: protected:
Mobile(); Actor();
public: public:
~Mobile(); virtual ~Actor();
virtual void adjustPosition(const MWWorld::Ptr& ptr, bool force) const; virtual void adjustPosition(const MWWorld::Ptr& ptr, bool force) const;
///< Adjust position to stand on ground. Must be called post model load ///< Adjust position to stand on ground. Must be called post model load
@ -39,8 +39,8 @@ namespace MWClass
/// effects). Throws an exception, if the object can't hold other objects. /// effects). Throws an exception, if the object can't hold other objects.
// not implemented // not implemented
Mobile(const Mobile&); Actor(const Actor&);
Mobile& operator= (const Mobile&); Actor& operator= (const Actor&);
}; };
} }

View File

@ -1,7 +1,7 @@
#ifndef GAME_MWCLASS_CREATURE_H #ifndef GAME_MWCLASS_CREATURE_H
#define GAME_MWCLASS_CREATURE_H #define GAME_MWCLASS_CREATURE_H
#include "mobile.hpp" #include "actor.hpp"
namespace ESM namespace ESM
{ {
@ -10,7 +10,7 @@ namespace ESM
namespace MWClass namespace MWClass
{ {
class Creature : public Mobile class Creature : public Actor
{ {
void ensureCustomData (const MWWorld::Ptr& ptr) const; void ensureCustomData (const MWWorld::Ptr& ptr) const;

View File

@ -946,7 +946,7 @@ namespace MWClass
{ {
// According to UESP, inventory weight is ignored in werewolf form. Does that include // According to UESP, inventory weight is ignored in werewolf form. Does that include
// feather and burden effects? // feather and burden effects?
return getNpcStats(ptr).isWerewolf() ? 0.0f : Mobile::getEncumbrance(ptr); return getNpcStats(ptr).isWerewolf() ? 0.0f : Actor::getEncumbrance(ptr);
} }
bool Npc::apply (const MWWorld::Ptr& ptr, const std::string& id, bool Npc::apply (const MWWorld::Ptr& ptr, const std::string& id,

View File

@ -1,7 +1,7 @@
#ifndef GAME_MWCLASS_NPC_H #ifndef GAME_MWCLASS_NPC_H
#define GAME_MWCLASS_NPC_H #define GAME_MWCLASS_NPC_H
#include "mobile.hpp" #include "actor.hpp"
namespace ESM namespace ESM
{ {
@ -10,7 +10,7 @@ namespace ESM
namespace MWClass namespace MWClass
{ {
class Npc : public Mobile class Npc : public Actor
{ {
void ensureCustomData (const MWWorld::Ptr& ptr) const; void ensureCustomData (const MWWorld::Ptr& ptr) const;