mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 11:53:53 +00:00
MWWorld::Player cleanup
This commit is contained in:
parent
7136ac0079
commit
e8c32d0c3d
6 changed files with 88 additions and 59 deletions
|
@ -54,7 +54,7 @@ add_openmw_dir (mwworld
|
|||
containerstore actiontalk actiontake manualref player cellfunctors failedaction
|
||||
cells localscripts customdata weather inventorystore ptr actionopen actionread
|
||||
actionequip timestamp actionalchemy cellstore actionapply actioneat
|
||||
esmstore store recordcmp fallback actionrepair actionsoulgem
|
||||
esmstore store recordcmp fallback actionrepair actionsoulgem livecellref
|
||||
)
|
||||
|
||||
add_openmw_dir (mwclass
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include "../mwworld/player.hpp"
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
#include "../mwmechanics/npcstats.hpp"
|
||||
|
||||
|
|
|
@ -6,45 +6,12 @@
|
|||
#include <deque>
|
||||
#include <algorithm>
|
||||
|
||||
#include "refdata.hpp"
|
||||
#include "livecellref.hpp"
|
||||
#include "esmstore.hpp"
|
||||
|
||||
struct C;
|
||||
namespace MWWorld
|
||||
{
|
||||
class Ptr;
|
||||
class ESMStore;
|
||||
|
||||
/// A reference to one object (of any type) in a cell.
|
||||
///
|
||||
/// Constructing this with a CellRef instance in the constructor means that
|
||||
/// in practice (where D is RefData) the possibly mutable data is copied
|
||||
/// across to mData. If later adding data (such as position) to CellRef
|
||||
/// this would have to be manually copied across.
|
||||
template <typename X>
|
||||
struct LiveCellRef
|
||||
{
|
||||
LiveCellRef(const ESM::CellRef& cref, const X* b = NULL)
|
||||
: mBase(b), mRef(cref), mData(mRef)
|
||||
{}
|
||||
|
||||
LiveCellRef(const X* b = NULL)
|
||||
: mBase(b), mData(mRef)
|
||||
{}
|
||||
|
||||
// The object that this instance is based on.
|
||||
const X* mBase;
|
||||
|
||||
/* Information about this instance, such as 3D location and
|
||||
rotation and individual type-dependent data.
|
||||
*/
|
||||
ESM::CellRef mRef;
|
||||
|
||||
/// runtime-data
|
||||
RefData mData;
|
||||
};
|
||||
|
||||
template<typename X> bool operator==(const LiveCellRef<X>& ref, int pRefnum);
|
||||
|
||||
/// A list of cell references
|
||||
template <typename X>
|
||||
|
|
45
apps/openmw/mwworld/livecellref.hpp
Normal file
45
apps/openmw/mwworld/livecellref.hpp
Normal file
|
@ -0,0 +1,45 @@
|
|||
#ifndef GAME_MWWORLD_LIVECELLREF_H
|
||||
#define GAME_MWWORLD_LIVECELLREF_H
|
||||
|
||||
#include <components/esm/loadcell.hpp>
|
||||
|
||||
#include "refdata.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class Ptr;
|
||||
class ESMStore;
|
||||
|
||||
/// A reference to one object (of any type) in a cell.
|
||||
///
|
||||
/// Constructing this with a CellRef instance in the constructor means that
|
||||
/// in practice (where D is RefData) the possibly mutable data is copied
|
||||
/// across to mData. If later adding data (such as position) to CellRef
|
||||
/// this would have to be manually copied across.
|
||||
template <typename X>
|
||||
struct LiveCellRef
|
||||
{
|
||||
LiveCellRef(const ESM::CellRef& cref, const X* b = NULL)
|
||||
: mBase(b), mRef(cref), mData(mRef)
|
||||
{}
|
||||
|
||||
LiveCellRef(const X* b = NULL)
|
||||
: mBase(b), mData(mRef)
|
||||
{}
|
||||
|
||||
// The object that this instance is based on.
|
||||
const X* mBase;
|
||||
|
||||
/* Information about this instance, such as 3D location and
|
||||
rotation and individual type-dependent data.
|
||||
*/
|
||||
ESM::CellRef mRef;
|
||||
|
||||
/// runtime-data
|
||||
RefData mData;
|
||||
};
|
||||
|
||||
template<typename X> bool operator==(const LiveCellRef<X>& ref, int pRefnum);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,14 +1,13 @@
|
|||
|
||||
#include "player.hpp"
|
||||
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
#include "../mwmechanics/movement.hpp"
|
||||
#include "../mwmechanics/npcstats.hpp"
|
||||
|
||||
#include "esmstore.hpp"
|
||||
#include "class.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
|
@ -25,12 +24,38 @@ namespace MWWorld
|
|||
playerPos[0] = playerPos[1] = playerPos[2] = 0;
|
||||
}
|
||||
|
||||
void Player::setCell (MWWorld::CellStore *cellStore)
|
||||
{
|
||||
mCellStore = cellStore;
|
||||
}
|
||||
|
||||
MWWorld::Ptr Player::getPlayer()
|
||||
{
|
||||
MWWorld::Ptr ptr (&mPlayer, mCellStore);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void Player::setBirthSign (const std::string &sign)
|
||||
{
|
||||
mSign = sign;
|
||||
}
|
||||
|
||||
const std::string& Player::getBirthSign() const
|
||||
{
|
||||
return mSign;
|
||||
}
|
||||
|
||||
void Player::setDrawState (MWMechanics::DrawState_ state)
|
||||
{
|
||||
MWWorld::Ptr ptr = getPlayer();
|
||||
MWWorld::Class::get(ptr).getNpcStats(ptr).setDrawState (state);
|
||||
}
|
||||
|
||||
bool Player::getAutoMove() const
|
||||
{
|
||||
return mAutoMove;
|
||||
}
|
||||
|
||||
void Player::setAutoMove (bool enable)
|
||||
{
|
||||
MWWorld::Ptr ptr = getPlayer();
|
||||
|
|
|
@ -1,15 +1,20 @@
|
|||
#ifndef GAME_MWWORLD_PLAYER_H
|
||||
#define GAME_MWWORLD_PLAYER_H
|
||||
|
||||
#include "../mwworld/cellstore.hpp"
|
||||
#include "../mwworld/refdata.hpp"
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/livecellref.hpp"
|
||||
|
||||
#include "../mwmechanics/drawstate.hpp"
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
struct NPC;
|
||||
}
|
||||
|
||||
namespace MWBase
|
||||
{
|
||||
class World;
|
||||
class Ptr;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
|
@ -30,31 +35,17 @@ namespace MWWorld
|
|||
|
||||
Player(const ESM::NPC *player, const MWBase::World& world);
|
||||
|
||||
void setCell (MWWorld::CellStore *cellStore)
|
||||
{
|
||||
mCellStore = cellStore;
|
||||
}
|
||||
void setCell (MWWorld::CellStore *cellStore);
|
||||
|
||||
MWWorld::Ptr getPlayer()
|
||||
{
|
||||
MWWorld::Ptr ptr (&mPlayer, mCellStore);
|
||||
return ptr;
|
||||
}
|
||||
MWWorld::Ptr getPlayer();
|
||||
|
||||
void setBirthSign(const std::string &sign) {
|
||||
mSign = sign;
|
||||
}
|
||||
void setBirthSign(const std::string &sign);
|
||||
|
||||
const std::string &getBirthSign() const {
|
||||
return mSign;
|
||||
}
|
||||
const std::string &getBirthSign() const;
|
||||
|
||||
void setDrawState (MWMechanics::DrawState_ state);
|
||||
|
||||
bool getAutoMove() const
|
||||
{
|
||||
return mAutoMove;
|
||||
}
|
||||
bool getAutoMove() const;
|
||||
|
||||
MWMechanics::DrawState_ getDrawState(); /// \todo constness
|
||||
|
||||
|
|
Loading…
Reference in a new issue