moved PlayerPos class from MWRender to MWWorld and renamed it to Player

actorid
Marc Zinnschlag 14 years ago
parent f3ae1ea737
commit 4a12be11bf

@ -14,7 +14,6 @@ set(GAMEREND
mwrender/cellimp.cpp
mwrender/interior.cpp
mwrender/exterior.cpp
mwrender/playerpos.cpp
mwrender/sky.cpp)
set(GAMEREND_HEADER
mwrender/cell.hpp
@ -22,7 +21,6 @@ set(GAMEREND_HEADER
mwrender/mwscene.hpp
mwrender/interior.hpp
mwrender/exterior.hpp
mwrender/playerpos.hpp
mwrender/sky.hpp)
source_group(apps\\openmw\\mwrender FILES ${GAMEREND} ${GAMEREND_HEADER})
@ -120,6 +118,7 @@ set(GAMEWORLD
mwworld/actiontalk.cpp
mwworld/actiontake.cpp
mwworld/containerutil.cpp
mwworld/player.cpp
)
set(GAMEWORLD_HEADER
mwworld/refdata.hpp
@ -137,6 +136,7 @@ set(GAMEWORLD_HEADER
mwworld/containerstore.hpp
mwworld/manualref.hpp
mwworld/containerutil.hpp
mwworld/player.hpp
)
source_group(apps\\openmw\\mwworld FILES ${GAMEWORLD} ${GAMEWORLD_HEADER})

@ -29,6 +29,7 @@
#include "mwworld/ptr.hpp"
#include "mwworld/environment.hpp"
#include "mwworld/class.hpp"
#include "mwworld/player.hpp"
#include "mwclass/classes.hpp"
@ -77,7 +78,7 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayerPos().getPlayer().getCell();
MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayer().getPlayer().getCell();
//If the region has changed
if(!(current->cell->data.flags & current->cell->Interior) && timer.elapsed() >= 10){
timer.restart();
@ -377,7 +378,7 @@ void OMW::Engine::go()
}
// Sets up the input system
MWInput::MWInputManager input(mOgre, mEnvironment.mWorld->getPlayerPos(),
MWInput::MWInputManager input(mOgre, mEnvironment.mWorld->getPlayer(),
*mEnvironment.mWindowManager, mDebug, *this);
mEnvironment.mInputManager = &input;
@ -439,7 +440,7 @@ void OMW::Engine::activate()
&ptr.getRefData().getLocals(), ptr);
boost::shared_ptr<MWWorld::Action> action =
MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayerPos().getPlayer(),
MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayer().getPlayer(),
mEnvironment);
interpreterContext.activate (ptr, action);

@ -5,8 +5,7 @@
#include <components/esm_store/cell_store.hpp>
#include "../mwrender/playerpos.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/nullaction.hpp"
#include "../mwworld/actionteleport.hpp"
@ -65,7 +64,7 @@ namespace MWClass
if (ref->ref.teleport)
{
// teleport door
if (environment.mWorld->getPlayerPos().getPlayer()==actor)
if (environment.mWorld->getPlayer().getPlayer()==actor)
{
// the player is using the door
return boost::shared_ptr<MWWorld::Action> (

@ -13,6 +13,7 @@
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwworld/refdata.hpp"
#include "../mwworld/player.hpp"
#include "../mwinput/inputmanager.hpp"
@ -225,7 +226,7 @@ namespace MWDialogue
// check cell
if (!info.cell.empty())
if (mEnvironment.mWorld->getPlayerPos().getPlayer().getCell()->cell->name != info.cell)
if (mEnvironment.mWorld->getPlayer().getPlayer().getCell()->cell->name != info.cell)
return false;
// TODO check DATAstruct

@ -4,6 +4,7 @@
#include "../mwmechanics/mechanicsmanager.hpp"
#include "../mwgui/window_manager.hpp"
#include <cmath>
#include <algorithm>
#include <iterator>
#include <boost/lexical_cast.hpp>

@ -8,6 +8,8 @@
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
#include <cmath>
using namespace MWGui;
using namespace Widgets;

@ -15,10 +15,11 @@
#include <mangle/input/filters/eventlist.hpp>
#include <libs/platform/strings.h>
#include "../mwrender/playerpos.hpp"
#include "../engine.hpp"
#include "../mwworld/player.hpp"
#include <boost/bind.hpp>
#include <boost/filesystem.hpp>
#include <OgreRoot.h>
@ -58,7 +59,7 @@ namespace MWInput
OEngine::Input::Poller poller;
OEngine::Render::MouseLookEventPtr mouse;
OEngine::GUI::EventInjectorPtr guiEvents;
MWRender::PlayerPos &player;
MWWorld::Player &player;
MWGui::WindowManager &windows;
OMW::Engine& mEngine;
@ -124,7 +125,7 @@ namespace MWInput
public:
InputImpl(OEngine::Render::OgreRenderer &_ogre,
MWRender::PlayerPos &_player,
MWWorld::Player &_player,
MWGui::WindowManager &_windows,
bool debug,
OMW::Engine& engine)
@ -286,7 +287,7 @@ namespace MWInput
};
MWInputManager::MWInputManager(OEngine::Render::OgreRenderer &ogre,
MWRender::PlayerPos &player,
MWWorld::Player &player,
MWGui::WindowManager &windows,
bool debug,
OMW::Engine& engine)
@ -300,7 +301,7 @@ namespace MWInput
}
void MWInputManager::setGuiMode(MWGui::GuiMode mode)
{
{
impl->setGuiMode(mode);
}
}

@ -11,9 +11,9 @@ namespace OEngine
}
}
namespace MWRender
namespace MWWorld
{
class PlayerPos;
class Player;
}
namespace MWGui
@ -42,7 +42,7 @@ namespace MWInput
public:
MWInputManager(OEngine::Render::OgreRenderer &_ogre,
MWRender::PlayerPos &_player,
MWWorld::Player&_player,
MWGui::WindowManager &_windows,
bool debug,
OMW::Engine& engine);

@ -8,12 +8,13 @@
#include "../mwworld/class.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwworld/player.hpp"
namespace MWMechanics
{
void MechanicsManager::buildPlayer()
{
MWWorld::Ptr ptr = mEnvironment.mWorld->getPlayerPos().getPlayer();
MWWorld::Ptr ptr = mEnvironment.mWorld->getPlayer().getPlayer();
MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
MWMechanics::NpcStats& npcStats = MWWorld::Class::get (ptr).getNpcStats (ptr);
@ -33,9 +34,9 @@ namespace MWMechanics
{
const ESM::Race *race =
mEnvironment.mWorld->getStore().races.find (
mEnvironment.mWorld->getPlayerPos().getRace());
mEnvironment.mWorld->getPlayer().getRace());
bool male = mEnvironment.mWorld->getPlayerPos().isMale();
bool male = mEnvironment.mWorld->getPlayer().isMale();
for (int i=0; i<8; ++i)
{
@ -75,11 +76,11 @@ namespace MWMechanics
}
// birthsign
if (!mEnvironment.mWorld->getPlayerPos().getBirthsign().empty())
if (!mEnvironment.mWorld->getPlayer().getBirthsign().empty())
{
const ESM::BirthSign *sign =
mEnvironment.mWorld->getStore().birthSigns.find (
mEnvironment.mWorld->getPlayerPos().getBirthsign());
mEnvironment.mWorld->getPlayer().getBirthsign());
for (std::vector<std::string>::const_iterator iter (sign->powers.list.begin());
iter!=sign->powers.list.end(); ++iter)
@ -91,7 +92,7 @@ namespace MWMechanics
// class
if (mClassSelected)
{
const ESM::Class& class_ = mEnvironment.mWorld->getPlayerPos().getClass();
const ESM::Class& class_ = mEnvironment.mWorld->getPlayer().getClass();
for (int i=0; i<2; ++i)
{
@ -330,12 +331,12 @@ namespace MWMechanics
if (mUpdatePlayer)
{
// basic player profile; should not change anymore after the creation phase is finished.
mEnvironment.mWindowManager->setValue ("name", mEnvironment.mWorld->getPlayerPos().getName());
mEnvironment.mWindowManager->setValue ("name", mEnvironment.mWorld->getPlayer().getName());
mEnvironment.mWindowManager->setValue ("race",
mEnvironment.mWorld->getStore().races.find (mEnvironment.mWorld->getPlayerPos().
mEnvironment.mWorld->getStore().races.find (mEnvironment.mWorld->getPlayer().
getRace())->name);
mEnvironment.mWindowManager->setValue ("class",
mEnvironment.mWorld->getPlayerPos().getClass().name);
mEnvironment.mWorld->getPlayer().getClass().name);
mUpdatePlayer = false;
MWGui::WindowManager::SkillList majorSkills (5);
@ -343,8 +344,8 @@ namespace MWMechanics
for (int i=0; i<5; ++i)
{
minorSkills[i] = mEnvironment.mWorld->getPlayerPos().getClass().data.skills[i][0];
majorSkills[i] = mEnvironment.mWorld->getPlayerPos().getClass().data.skills[i][1];
minorSkills[i] = mEnvironment.mWorld->getPlayer().getClass().data.skills[i][0];
majorSkills[i] = mEnvironment.mWorld->getPlayer().getClass().data.skills[i][1];
}
mEnvironment.mWindowManager->configureSkills (majorSkills, minorSkills);
@ -353,14 +354,14 @@ namespace MWMechanics
void MechanicsManager::setPlayerName (const std::string& name)
{
mEnvironment.mWorld->getPlayerPos().setName (name);
mEnvironment.mWorld->getPlayer().setName (name);
mUpdatePlayer = true;
}
void MechanicsManager::setPlayerRace (const std::string& race, bool male)
{
mEnvironment.mWorld->getPlayerPos().setGender (male);
mEnvironment.mWorld->getPlayerPos().setRace (race);
mEnvironment.mWorld->getPlayer().setGender (male);
mEnvironment.mWorld->getPlayer().setRace (race);
mRaceSelected = true;
buildPlayer();
mUpdatePlayer = true;
@ -368,14 +369,14 @@ namespace MWMechanics
void MechanicsManager::setPlayerBirthsign (const std::string& id)
{
mEnvironment.mWorld->getPlayerPos().setBirthsign (id);
mEnvironment.mWorld->getPlayer().setBirthsign (id);
buildPlayer();
mUpdatePlayer = true;
}
void MechanicsManager::setPlayerClass (const std::string& id)
{
mEnvironment.mWorld->getPlayerPos().setClass (*mEnvironment.mWorld->getStore().classes.find (id));
mEnvironment.mWorld->getPlayer().setClass (*mEnvironment.mWorld->getStore().classes.find (id));
mClassSelected = true;
buildPlayer();
mUpdatePlayer = true;
@ -383,7 +384,7 @@ namespace MWMechanics
void MechanicsManager::setPlayerClass (const ESM::Class& class_)
{
mEnvironment.mWorld->getPlayerPos().setClass (class_);
mEnvironment.mWorld->getPlayer().setClass (class_);
mClassSelected = true;
buildPlayer();
mUpdatePlayer = true;

@ -1,11 +1,11 @@
#include "playerpos.hpp"
#include "player.hpp"
#include "../mwworld/world.hpp"
#include "world.hpp"
namespace MWRender
namespace MWWorld
{
PlayerPos::PlayerPos (Ogre::Camera *cam, const ESM::NPC *player, MWWorld::World& world) :
Player::Player (Ogre::Camera *cam, const ESM::NPC *player, MWWorld::World& world) :
mCellStore (0), camera(cam), mWorld (world), mClass (0)
{
mPlayer.base = player;
@ -16,12 +16,12 @@ namespace MWRender
mClass = new ESM::Class (*world.getStore().classes.find (player->cls));
}
PlayerPos::~PlayerPos()
Player::~Player()
{
delete mClass;
}
void PlayerPos::setPos(float x, float y, float z, bool updateCamera)
void Player::setPos(float x, float y, float z, bool updateCamera)
{
mWorld.moveObject (getPlayer(), x, y, z);
@ -32,7 +32,7 @@ namespace MWRender
-mPlayer.ref.pos.pos[1]));
}
void PlayerPos::setClass (const ESM::Class& class_)
void Player::setClass (const ESM::Class& class_)
{
ESM::Class *new_class = new ESM::Class (class_);
delete mClass;

@ -1,5 +1,5 @@
#ifndef _MWRENDER_PLAYERPOS_H
#define _MWRENDER_PLAYERPOS_H
#ifndef GAME_MWWORLD_PLAYER_H
#define GAME_MWWORLD_PLAYER_H
#include "OgreCamera.h"
@ -13,12 +13,9 @@ namespace MWWorld
class World;
}
namespace MWRender
namespace MWWorld
{
// This class keeps track of the player position. It takes care of
// camera movement, sound listener updates, and collision handling
// (to be done).
class PlayerPos
class Player
{
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> mPlayer;
MWWorld::Ptr::CellStore *mCellStore;
@ -32,9 +29,9 @@ namespace MWRender
public:
PlayerPos(Ogre::Camera *cam, const ESM::NPC *player, MWWorld::World& world);
Player(Ogre::Camera *cam, const ESM::NPC *player, MWWorld::World& world);
~PlayerPos();
~Player();
// Set the player position. Uses Morrowind coordinates.
void setPos(float _x, float _y, float _z, bool updateCamera = false);

@ -17,7 +17,7 @@
#include "ptr.hpp"
#include "environment.hpp"
#include "class.hpp"
#include "player.hpp"
#include "refdata.hpp"
#include "globals.hpp"
@ -296,12 +296,12 @@ namespace MWWorld
void World::playerCellChange (Ptr::CellStore *cell, const ESM::Position& position)
{
mPlayerPos->setPos (position.pos[0], position.pos[1], position.pos[2], true);
mPlayerPos->setCell (cell);
mPlayer->setPos (position.pos[0], position.pos[1], position.pos[2], true);
mPlayer->setCell (cell);
// TODO orientation
mEnvironment.mMechanicsManager->addActor (mPlayerPos->getPlayer());
mEnvironment.mMechanicsManager->watchActor (mPlayerPos->getPlayer());
mEnvironment.mMechanicsManager->addActor (mPlayer->getPlayer());
mEnvironment.mMechanicsManager->watchActor (mPlayer->getPlayer());
}
@ -317,7 +317,7 @@ namespace MWWorld
World::World (OEngine::Render::OgreRenderer& renderer, const boost::filesystem::path& dataDir,
const std::string& master, bool newGame, Environment& environment)
: mSkyManager (0), mScene (renderer), mPlayerPos (0), mCurrentCell (0), mGlobalVariables (0),
: mSkyManager (0), mScene (renderer), mPlayer (0), mCurrentCell (0), mGlobalVariables (0),
mSky (false), mCellChanged (false), mEnvironment (environment)
{
boost::filesystem::path masterPath (dataDir);
@ -329,7 +329,7 @@ namespace MWWorld
mEsm.open (masterPath.file_string());
mStore.load (mEsm);
mPlayerPos = new MWRender::PlayerPos (mScene.getCamera(), mStore.npcs.find ("player"), *this);
mPlayer = new MWWorld::Player (mScene.getCamera(), mStore.npcs.find ("player"), *this);
// global variables
mGlobalVariables = new Globals (mStore);
@ -354,14 +354,14 @@ namespace MWWorld
iter!=mBufferedCells.end(); ++iter)
delete iter->second;
delete mPlayerPos;
delete mPlayer;
delete mSkyManager;
delete mGlobalVariables;
}
MWRender::PlayerPos& World::getPlayerPos()
MWWorld::Player& World::getPlayer()
{
return *mPlayerPos;
return *mPlayer;
}
ESMS::ESMStore& World::getStore()
@ -394,7 +394,7 @@ namespace MWWorld
// the player is always in an active cell.
if (name=="player")
{
return mPlayerPos->getPlayer();
return mPlayer->getPlayer();
}
// active cells
@ -763,7 +763,7 @@ namespace MWWorld
ptr.getCellRef().pos.pos[1] = y;
ptr.getCellRef().pos.pos[2] = z;
if (ptr==mPlayerPos->getPlayer())
if (ptr==mPlayer->getPlayer())
{
if (mCurrentCell)
{
@ -777,7 +777,7 @@ namespace MWWorld
if (mCurrentCell->cell->data.gridX!=cellX || mCurrentCell->cell->data.gridY!=cellY)
{
changeCell (cellX, cellY, mPlayerPos->getPlayer().getCellRef().pos);
changeCell (cellX, cellY, mPlayer->getPlayer().getCellRef().pos);
}
}
}
@ -800,7 +800,7 @@ namespace MWWorld
}
}
void World::positionToIndex (float x, float y, int &cellX, int &cellY) const
{

@ -8,7 +8,6 @@
#include <components/esm_store/cell_store.hpp>
#include "../mwrender/playerpos.hpp"
#include "../mwrender/mwscene.hpp"
#include "refdata.hpp"
@ -34,12 +33,13 @@ namespace MWRender
namespace MWWorld
{
class Environment;
class Player;
/// \brief The game world and its visual representation
class World
{
public:
typedef std::list<std::pair<std::string, Ptr> > ScriptList;
@ -49,7 +49,7 @@ namespace MWWorld
MWRender::SkyManager* mSkyManager;
MWRender::MWScene mScene;
MWRender::PlayerPos *mPlayerPos;
MWWorld::Player *mPlayer;
Ptr::CellStore *mCurrentCell; // the cell, the player is in
CellRenderCollection mActiveCells;
CellRenderCollection mBufferedCells; // loaded, but not active (buffering not implementd yet)
@ -94,7 +94,7 @@ namespace MWWorld
~World();
MWRender::PlayerPos& getPlayerPos();
MWWorld::Player& getPlayer();
ESMS::ESMStore& getStore();

Loading…
Cancel
Save