Merge remote-tracking branch 'scrawl/master'

pull/16/head
Marc Zinnschlag 12 years ago
commit 9fee99d56c

@ -366,7 +366,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
// Create the world
mEnvironment.setWorld( new MWWorld::World (*mOgre, mFileCollections, mMaster, mPlugins,
mResDir, mCfgMgr.getCachePath(), mNewGame, mEncoder, mFallbackMap,
mResDir, mCfgMgr.getCachePath(), mEncoder, mFallbackMap,
mActivationDistanceOverride));
MWBase::Environment::get().getWorld()->setupPlayer();
@ -379,8 +379,10 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
MWScript::registerExtensions (mExtensions);
mEnvironment.setWindowManager (new MWGui::WindowManager(
mExtensions, mFpsLevel, mNewGame, mOgre, mCfgMgr.getLogPath().string() + std::string("/"),
mExtensions, mFpsLevel, mOgre, mCfgMgr.getLogPath().string() + std::string("/"),
mCfgMgr.getCachePath ().string(), mScriptConsoleMode, mTranslationDataStorage));
if (mNewGame)
mEnvironment.getWindowManager()->setNewGame(true);
// Create sound system
mEnvironment.setSoundManager (new MWSound::SoundManager(mUseSound));
@ -409,24 +411,29 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
MWBase::Environment::get().getWorld()->getPlayer(),
*MWBase::Environment::get().getWindowManager(), mDebug, *this, keybinderUser, keybinderUserExists));
// load cell
ESM::Position pos;
pos.rot[0] = pos.rot[1] = pos.rot[2] = 0;
pos.pos[2] = 0;
mEnvironment.getWorld()->renderPlayer();
if (const ESM::Cell *exterior = MWBase::Environment::get().getWorld()->getExterior (mCellName))
if (!mNewGame)
{
MWBase::Environment::get().getWorld()->indexToPosition (exterior->mData.mX, exterior->mData.mY,
pos.pos[0], pos.pos[1], true);
MWBase::Environment::get().getWorld()->changeToExteriorCell (pos);
// load cell
ESM::Position pos;
pos.rot[0] = pos.rot[1] = pos.rot[2] = 0;
pos.pos[2] = 0;
if (const ESM::Cell *exterior = MWBase::Environment::get().getWorld()->getExterior (mCellName))
{
MWBase::Environment::get().getWorld()->indexToPosition (exterior->mData.mX, exterior->mData.mY,
pos.pos[0], pos.pos[1], true);
MWBase::Environment::get().getWorld()->changeToExteriorCell (pos);
}
else
{
pos.pos[0] = pos.pos[1] = 0;
MWBase::Environment::get().getWorld()->changeToInteriorCell (mCellName, pos);
}
}
else
{
pos.pos[0] = pos.pos[1] = 0;
MWBase::Environment::get().getWorld()->changeToInteriorCell (mCellName, pos);
}
mEnvironment.getWorld()->startNewGame();
Ogre::FrameEvent event;
event.timeSinceLastEvent = 0;

@ -23,6 +23,8 @@ namespace MWBase
DialogueManager() {}
virtual void clear() = 0;
virtual ~DialogueManager() {}
virtual bool isInChoice() const = 0;

@ -33,6 +33,8 @@ namespace MWBase
Journal() {}
virtual void clear() = 0;
virtual ~Journal() {}
virtual void addEntry (const std::string& id, int index) = 0;

@ -35,6 +35,8 @@ namespace MWBase
virtual ~ScriptManager() {}
virtual void resetGlobalScripts() = 0;
virtual void run (const std::string& name, Interpreter::Context& interpreterContext) = 0;
///< Run the script with the given name (compile first, if not compiled yet)

@ -81,12 +81,16 @@ namespace MWBase
*/
virtual void update() = 0;
virtual void setNewGame(bool newgame) = 0;
virtual void pushGuiMode (MWGui::GuiMode mode) = 0;
virtual void popGuiMode() = 0;
virtual void removeGuiMode (MWGui::GuiMode mode) = 0;
///< can be anywhere in the stack
virtual void updatePlayer() = 0;
virtual MWGui::GuiMode getMode() const = 0;
virtual bool isGuiMode() const = 0;

@ -94,6 +94,8 @@ namespace MWBase
virtual ~World() {}
virtual void startNewGame() = 0;
virtual OEngine::Render::Fader* getFader() = 0;
///< \ŧodo remove this function. Rendering details should not be exposed.

@ -50,12 +50,11 @@ namespace MWDialogue
, mTemporaryDispositionChange(0.f)
, mPermanentDispositionChange(0.f), mScriptVerbose (scriptVerbose)
, mTranslationDataStorage(translationDataStorage)
, mTalkedTo(false)
{
mChoice = -1;
mIsInChoice = false;
mCompilerContext.setExtensions (&extensions);
mDialogueMap.clear();
mActorKnownTopics.clear();
const MWWorld::Store<ESM::Dialogue> &dialogs =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>();
@ -67,6 +66,14 @@ namespace MWDialogue
}
}
void DialogueManager::clear()
{
mKnownTopics.clear();
mTalkedTo = false;
mTemporaryDispositionChange = 0;
mPermanentDispositionChange = 0;
}
void DialogueManager::addTopic (const std::string& topic)
{
mKnownTopics[Misc::StringUtils::lowerCase(topic)] = true;

@ -51,6 +51,8 @@ namespace MWDialogue
DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose, Translation::Storage& translationDataStorage);
virtual void clear();
virtual bool isInChoice() const;
virtual void startDialogue (const MWWorld::Ptr& actor);

@ -29,6 +29,13 @@ namespace MWDialogue
Journal::Journal()
{}
void Journal::clear()
{
mJournal.clear();
mQuests.clear();
mTopics.clear();
}
void Journal::addEntry (const std::string& id, int index)
{
// bail out of we already have heard this...

@ -21,6 +21,8 @@ namespace MWDialogue
Journal();
virtual void clear();
virtual void addEntry (const std::string& id, int index);
///< Add a journal entry.

@ -45,6 +45,7 @@ namespace MWGui
: WindowBase("openmw_alchemy_window.layout")
, mApparatus (4)
, mIngredients (4)
, mSortModel(NULL)
{
getWidget(mCreateButton, "CreateButton");
getWidget(mCancelButton, "CancelButton");
@ -60,10 +61,7 @@ namespace MWGui
getWidget(mNameEdit, "NameEdit");
getWidget(mItemView, "ItemView");
InventoryItemModel* model = new InventoryItemModel(MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
mSortModel = new SortFilterItemModel(model);
mSortModel->setFilter(SortFilterItemModel::Filter_OnlyIngredients);
mItemView->setModel (mSortModel);
mItemView->eventItemClicked += MyGUI::newDelegate(this, &AlchemyWindow::onSelectedItem);
mIngredients[0]->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onIngredientSelected);
@ -145,6 +143,11 @@ namespace MWGui
void AlchemyWindow::open()
{
InventoryItemModel* model = new InventoryItemModel(MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
mSortModel = new SortFilterItemModel(model);
mSortModel->setFilter(SortFilterItemModel::Filter_OnlyIngredients);
mItemView->setModel (mSortModel);
mNameEdit->setCaption("");
mAlchemy.setAlchemist (MWBase::Environment::get().getWorld()->getPlayer().getPlayer());

@ -53,15 +53,12 @@ namespace MWGui
mAvatar->eventMouseButtonClick += MyGUI::newDelegate(this, &InventoryWindow::onAvatarClicked);
mPtr = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer ();
getWidget(mItemView, "ItemView");
mTradeModel = new TradeItemModel(new InventoryItemModel(mPtr), MWWorld::Ptr());
mSortModel = new SortFilterItemModel(mTradeModel);
mItemView->setModel(mSortModel);
mItemView->eventItemClicked += MyGUI::newDelegate(this, &InventoryWindow::onItemSelected);
mItemView->eventBackgroundClicked += MyGUI::newDelegate(this, &InventoryWindow::onBackgroundSelected);
updatePlayer();
mFilterAll->eventMouseButtonClick += MyGUI::newDelegate(this, &InventoryWindow::onFilterChanged);
mFilterWeapon->eventMouseButtonClick += MyGUI::newDelegate(this, &InventoryWindow::onFilterChanged);
mFilterApparel->eventMouseButtonClick += MyGUI::newDelegate(this, &InventoryWindow::onFilterChanged);
@ -76,6 +73,16 @@ namespace MWGui
mPreview.setup();
}
void InventoryWindow::updatePlayer()
{
mPtr = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer ();
mTradeModel = new TradeItemModel(new InventoryItemModel(mPtr), MWWorld::Ptr());
mSortModel = new SortFilterItemModel(mTradeModel);
mItemView->setModel(mSortModel);
mPreview = MWRender::InventoryPreview(mPtr);
mPreview.setup();
}
TradeItemModel* InventoryWindow::getTradeModel()
{
return mTradeModel;

@ -45,6 +45,8 @@ namespace MWGui
void updateItemView();
void updatePlayer();
private:
DragAndDrop* mDragAndDrop;

@ -5,6 +5,9 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/journal.hpp"
#include "../mwbase/dialoguemanager.hpp"
namespace MWGui
{
@ -29,7 +32,7 @@ namespace MWGui
std::vector<std::string> buttons;
buttons.push_back("return");
//buttons.push_back("newgame");
buttons.push_back("newgame");
//buttons.push_back("loadgame");
//buttons.push_back("savegame");
buttons.push_back("options");
@ -72,6 +75,13 @@ namespace MWGui
MWBase::Environment::get().getWindowManager ()->pushGuiMode (GM_Settings);
else if (sender == mButtons["exitgame"])
Ogre::Root::getSingleton ().queueEndRendering ();
else if (sender == mButtons["newgame"])
{
MWBase::Environment::get().getWorld()->startNewGame();
MWBase::Environment::get().getWindowManager()->setNewGame(true);
MWBase::Environment::get().getDialogueManager()->clear();
MWBase::Environment::get().getJournal()->clear();
}
}
}

@ -47,7 +47,7 @@ namespace MWGui
{
WindowManager::WindowManager(
const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *ogre,
const Compiler::Extensions& extensions, int fpsLevel, OEngine::Render::OgreRenderer *ogre,
const std::string& logpath, const std::string& cacheDir, bool consoleOnlyScripts,
Translation::Storage& translationDataStorage)
: mGuiManager(NULL)
@ -94,8 +94,8 @@ namespace MWGui
, mGui(NULL)
, mGarbageDialogs()
, mShown(GW_ALL)
, mAllowed(newGame ? GW_None : GW_ALL)
, mRestAllowed(newGame ? false : true)
, mAllowed(GW_ALL)
, mRestAllowed(true)
, mShowFPSLevel(fpsLevel)
, mFPS(0.0f)
, mTriangleCount(0)
@ -203,13 +203,25 @@ namespace MWGui
unsetSelectedSpell();
unsetSelectedWeapon();
if (newGame)
disallowAll ();
// Set up visibility
updateVisible();
}
void WindowManager::setNewGame(bool newgame)
{
if (newgame)
{
disallowAll();
delete mCharGen;
mCharGen = new CharacterCreation();
mGuiModes.clear();
}
else
allow(GW_ALL);
mRestAllowed = !newgame;
}
WindowManager::~WindowManager()
{
delete mConsole;
@ -1200,4 +1212,9 @@ namespace MWGui
mInventoryWindow->doRenderUpdate ();
}
void WindowManager::updatePlayer()
{
mInventoryWindow->updatePlayer();
}
}

@ -80,7 +80,7 @@ namespace MWGui
typedef std::pair<std::string, int> Faction;
typedef std::vector<Faction> FactionList;
WindowManager(const Compiler::Extensions& extensions, int fpsLevel, bool newGame,
WindowManager(const Compiler::Extensions& extensions, int fpsLevel,
OEngine::Render::OgreRenderer *mOgre, const std::string& logpath,
const std::string& cacheDir, bool consoleOnlyScripts,
Translation::Storage& translationDataStorage);
@ -93,6 +93,8 @@ namespace MWGui
*/
virtual void update();
virtual void setNewGame(bool newgame);
virtual void pushGuiMode(GuiMode mode);
virtual void popGuiMode();
virtual void removeGuiMode(GuiMode mode); ///< can be anywhere in the stack
@ -227,6 +229,8 @@ namespace MWGui
virtual bool getPlayerSleeping();
virtual void wakeUpPlayer();
virtual void updatePlayer();
virtual void showCompanionWindow(MWWorld::Ptr actor);
virtual void startSpellMaking(MWWorld::Ptr actor);
virtual void startEnchanting(MWWorld::Ptr actor);

@ -29,7 +29,7 @@
namespace MWInput
{
InputManager::InputManager(OEngine::Render::OgreRenderer &ogre,
MWWorld::Player &player,
MWWorld::Player& player,
MWBase::WindowManager &windows,
bool debug,
OMW::Engine& engine,

@ -119,7 +119,7 @@ namespace MWInput
private:
OEngine::Render::OgreRenderer &mOgre;
MWWorld::Player &mPlayer;
MWWorld::Player& mPlayer;
MWBase::WindowManager &mWindows;
OMW::Engine& mEngine;

@ -156,17 +156,11 @@ namespace MWMechanics
creatureStats.setDynamic (i, stat);
}
// unequip any items that may not be equipped. we need this for when the race is changed to a beast race
// auto-equip again. we need this for when the race is changed to a beast race
MWWorld::InventoryStore& invStore = MWWorld::Class::get(ptr).getInventoryStore(ptr);
for (int i=0; i<MWWorld::InventoryStore::Slots; ++i)
{
MWWorld::ContainerStoreIterator it = invStore.getSlot(i);
if (it != invStore.end())
{
if (!MWWorld::Class::get(*it).canBeEquipped(*it, ptr).first)
invStore.equip(i, invStore.end());
}
}
invStore.equip(i, invStore.end());
invStore.autoEquip(ptr);
}
MechanicsManager::MechanicsManager()

@ -15,12 +15,18 @@ namespace MWScript
GlobalScripts::GlobalScripts (const MWWorld::ESMStore& store)
: mStore (store)
{
reset();
}
void GlobalScripts::reset()
{
mScripts.clear();
addScript ("Main");
MWWorld::Store<ESM::StartScript>::iterator iter =
store.get<ESM::StartScript>().begin();
mStore.get<ESM::StartScript>().begin();
for (; iter != store.get<ESM::StartScript>().end(); ++iter) {
for (; iter != mStore.get<ESM::StartScript>().end(); ++iter) {
addScript (iter->mScript);
}
}

@ -22,6 +22,8 @@ namespace MWScript
GlobalScripts (const MWWorld::ESMStore& store);
void reset();
void addScript (const std::string& name);
void removeScript (const std::string& name);

@ -221,4 +221,9 @@ namespace MWScript
throw std::runtime_error ("unable to access local variable " + variable + " of " + scriptId);
}
void ScriptManager::resetGlobalScripts()
{
mGlobalScripts.reset();
}
}

@ -61,6 +61,8 @@ namespace MWScript
///< Compile script with the given namen
/// \return Success?
virtual void resetGlobalScripts();
virtual std::pair<int, int> compileAll();
///< Compile all scripts
/// \return count, success

@ -586,7 +586,7 @@ void OpenAL_Sound::update()
alSourcef(mSource, AL_GAIN, gain);
alSourcef(mSource, AL_PITCH, pitch);
alSource3f(mSource, AL_POSITION, mPos[0], mPos[2], -mPos[1]);
alSource3f(mSource, AL_POSITION, mPos[0], mPos[1], mPos[2]);
alSource3f(mSource, AL_DIRECTION, 0.0f, 0.0f, 0.0f);
alSource3f(mSource, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
throwALerror();
@ -606,7 +606,7 @@ void OpenAL_Sound3D::update()
alSourcef(mSource, AL_GAIN, gain);
alSourcef(mSource, AL_PITCH, pitch);
alSource3f(mSource, AL_POSITION, mPos[0], mPos[2], -mPos[1]);
alSource3f(mSource, AL_POSITION, mPos[0], mPos[1], mPos[2]);
alSource3f(mSource, AL_DIRECTION, 0.0f, 0.0f, 0.0f);
alSource3f(mSource, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
throwALerror();
@ -923,10 +923,10 @@ void OpenAL_Output::updateListener(const Ogre::Vector3 &pos, const Ogre::Vector3
if(mContext)
{
ALfloat orient[6] = {
atdir.x, atdir.z, -atdir.y,
updir.x, updir.z, -updir.y
atdir.x, atdir.y, atdir.z,
updir.x, updir.y, updir.z
};
alListener3f(AL_POSITION, mPos.x, mPos.z, -mPos.y);
alListener3f(AL_POSITION, mPos.x, mPos.y, mPos.z);
alListenerfv(AL_ORIENTATION, orient);
throwALerror();
}

@ -36,6 +36,14 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getCellStore (const ESM::Cell *cell)
}
}
void MWWorld::Cells::clear()
{
mInteriors.clear();
mExteriors.clear();
std::fill(mIdCache.begin(), mIdCache.end(), std::make_pair("", (MWWorld::Ptr::CellStore*)0));
mIdCacheIndex = 0;
}
void MWWorld::Cells::fillContainers (Ptr::CellStore& cellStore)
{
for (CellRefList<ESM::Container>::List::iterator iter (

@ -37,6 +37,8 @@ namespace MWWorld
public:
void clear();
Cells (const MWWorld::ESMStore& store, std::vector<ESM::ESMReader>& reader);
///< \todo pass the dynamic part of the ESMStore isntead (once it is written) of the whole
/// world

@ -134,15 +134,6 @@ void ESMStore::setUp()
mSkills.setUp();
mMagicEffects.setUp();
mAttributes.setUp();
ESM::NPC item;
item.mId = "player";
const ESM::NPC *pIt = mNpcs.find("player");
assert(pIt != NULL);
mNpcs.insert(*pIt);
mNpcs.eraseStatic(pIt->mId);
}
} // end namespace

@ -67,6 +67,8 @@ namespace MWWorld
std::map<std::string, int> mIds;
std::map<int, StoreBase *> mStores;
ESM::NPC mPlayerTemplate;
unsigned int mDynamicCount;
public:
@ -141,6 +143,21 @@ namespace MWWorld
mStores[ESM::REC_WEAP] = &mWeapons;
}
void clearDynamic ()
{
for (std::map<int, StoreBase *>::iterator it = mStores.begin(); it != mStores.end(); ++it)
it->second->clearDynamic();
mNpcs.insert(mPlayerTemplate);
}
void movePlayerRecord ()
{
mPlayerTemplate = *mNpcs.find("player");
mNpcs.eraseStatic(mPlayerTemplate.mId);
mNpcs.insert(mPlayerTemplate);
}
void load(ESM::ESMReader &esm);
template <class T>

@ -121,7 +121,7 @@ namespace MWWorld
physicActor->enableCollisions(wasCollisionMode);
if (hit)
return newPosition;
return newPosition+Ogre::Vector3(0,0,4);
else
return position;
}

@ -24,6 +24,14 @@ namespace MWWorld
playerPos[0] = playerPos[1] = playerPos[2] = 0;
}
void Player::set(const ESM::NPC *player)
{
mPlayer.mBase = player;
float* playerPos = mPlayer.mData.getPosition().pos;
playerPos[0] = playerPos[1] = playerPos[2] = 0;
}
void Player::setCell (MWWorld::CellStore *cellStore)
{
mCellStore = cellStore;

@ -35,6 +35,8 @@ namespace MWWorld
Player(const ESM::NPC *player, const MWBase::World& world);
void set (const ESM::NPC *player);
void setCell (MWWorld::CellStore *cellStore);
MWWorld::Ptr getPlayer();

@ -68,7 +68,7 @@ namespace MWWorld
Ptr::CellStore *getCell() const
{
assert (mCell);
assert(mCell);
return mCell;
}

@ -186,6 +186,15 @@ namespace MWWorld
MWBase::Environment::get().getWindowManager()->changeCell(mCurrentCell);
}
void Scene::changeToVoid()
{
CellStoreCollection::iterator active = mActiveCells.begin();
while (active!=mActiveCells.end())
unloadCell (active++);
assert(mActiveCells.empty());
mCurrentCell = NULL;
}
void Scene::changeCell (int X, int Y, const ESM::Position& position, bool adjustPlayerPos)
{
Nif::NIFFile::CacheLock cachelock;

@ -47,7 +47,7 @@ namespace MWWorld
private:
//OEngine::Render::OgreRenderer& mRenderer;
CellStore* mCurrentCell; // the cell, the player is in
CellStore* mCurrentCell; // the cell the player is in
CellStoreCollection mActiveCells;
bool mCellChanged;
PhysicsSystem *mPhysics;
@ -85,6 +85,9 @@ namespace MWWorld
void changeToExteriorCell (const ESM::Position& position);
///< Move to exterior cell.
void changeToVoid();
///< Change into a void
void markCellAsUnchanged();
void update (float duration, bool paused);

@ -21,6 +21,7 @@ namespace MWWorld
virtual void load(ESM::ESMReader &esm, const std::string &id) = 0;
virtual bool eraseStatic(const std::string &id) {return false;}
virtual void clearDynamic() {}
};
template <class T>
@ -106,6 +107,13 @@ namespace MWWorld
typedef SharedIterator<T> iterator;
// setUp needs to be called again after
virtual void clearDynamic()
{
mDynamic.clear();
mShared.clear();
}
const T *search(const std::string &id) const {
T item;
item.mId = Misc::StringUtils::lowerCase(id);

@ -160,12 +160,12 @@ namespace MWWorld
World::World (OEngine::Render::OgreRenderer& renderer,
const Files::Collections& fileCollections,
const std::vector<std::string>& master, const std::vector<std::string>& plugins,
const boost::filesystem::path& resDir, const boost::filesystem::path& cacheDir, bool newGame,
const boost::filesystem::path& resDir, const boost::filesystem::path& cacheDir,
ToUTF8::Utf8Encoder* encoder, const std::map<std::string,std::string>& fallbackMap, int mActivationDistanceOverride)
: mPlayer (0), mLocalScripts (mStore), mGlobalVariables (0),
mSky (true), mCells (mStore, mEsm),
mNumFacing(0), mActivationDistanceOverride (mActivationDistanceOverride),
mFallback(fallbackMap), mNewGame(newGame)
mFallback(fallbackMap), mPlayIntro(0)
{
mPhysics = new PhysicsSystem(renderer);
mPhysEngine = mPhysics->getEngine();
@ -215,22 +215,70 @@ namespace MWWorld
if (mEsm[0].getFormat() == 0)
ensureNeededRecords();
mStore.movePlayerRecord();
mStore.setUp();
// global variables
mGlobalVariables = new Globals (mStore);
if (mNewGame)
{
// set new game mark
mGlobalVariables->setInt ("chargenstate", 1);
}
mWorldScene = new Scene(*mRendering, mPhysics);
}
void World::startNewGame()
{
mWorldScene->changeToVoid();
mStore.clearDynamic();
mStore.setUp();
mCells.clear();
// Rebuild player
setupPlayer();
const ESM::NPC* playerNpc = mStore.get<ESM::NPC>().find("player");
MWWorld::Ptr player = mPlayer->getPlayer();
// removes NpcStats, ContainerStore etc
player.getRefData().setCustomData(NULL);
// make sure to do this so that local scripts from items that were in the players inventory are removed
mLocalScripts.clear();
MWWorld::Class::get(player).getContainerStore(player).fill(playerNpc->mInventory, "", mStore);
MWWorld::Class::get(player).getInventoryStore(player).autoEquip(player);
MWBase::Environment::get().getWindowManager()->updatePlayer();
ESM::Position pos;
const int cellSize = 8192;
pos.pos[0] = cellSize/2;
pos.pos[1] = cellSize/2;
pos.pos[2] = 0;
pos.rot[0] = 0;
pos.rot[1] = 0;
pos.rot[2] = 0;
mWorldScene->changeToExteriorCell(pos);
// enable collision
if(!mPhysics->toggleCollisionMode())
mPhysics->toggleCollisionMode();
// FIXME: should be set to 1, but the sound manager won't pause newly started sounds
mPlayIntro = 2;
// global variables
delete mGlobalVariables;
mGlobalVariables = new Globals (mStore);
// set new game mark
mGlobalVariables->setInt ("chargenstate", 1);
mGlobalVariables->setInt ("pcrace", 3);
mWorldScene = new Scene(*mRendering, mPhysics);
// we don't want old weather to persist on a new game
delete mWeatherManager;
mWeatherManager = new MWWorld::WeatherManager(mRendering,&mFallback);
lastTick = mTimer.getMilliseconds();
MWBase::Environment::get().getScriptManager()->resetGlobalScripts();
}
@ -754,7 +802,7 @@ namespace MWWorld
CellStore *currCell = ptr.getCell();
bool isPlayer = ptr == mPlayer->getPlayer();
bool haveToMove = mWorldScene->isCellActive(*currCell) || isPlayer;
bool haveToMove = isPlayer || mWorldScene->isCellActive(*currCell);
if (*currCell != newCell)
{
@ -950,9 +998,9 @@ namespace MWWorld
float terrainHeight = mRendering->getTerrainHeightAt(pos);
if (pos.z < terrainHeight)
pos.z = terrainHeight+5; // place slightly above. will snap down to ground with code below
pos.z = terrainHeight;
ptr.getRefData().getPosition().pos[2] = pos.z;
ptr.getRefData().getPosition().pos[2] = pos.z + 20; // place slightly above. will snap down to ground with code below
if (!isFlying(ptr))
{
@ -961,7 +1009,7 @@ namespace MWWorld
pos.z = traced.z;
}
moveObject(ptr, pos.x, pos.y, pos.z);
moveObject(ptr, *ptr.getCell(), pos.x, pos.y, pos.z);
}
void World::rotateObject (const Ptr& ptr,float x,float y,float z, bool adjust)
@ -1193,6 +1241,13 @@ namespace MWWorld
void World::update (float duration, bool paused)
{
if (mPlayIntro)
{
--mPlayIntro;
if (mPlayIntro == 0)
mRendering->playVideo("mw_intro.bik", true);
}
mWeatherManager->update (duration);
mWorldScene->update (duration, paused);
@ -1547,23 +1602,19 @@ namespace MWWorld
void World::setupPlayer()
{
const ESM::NPC *player = mStore.get<ESM::NPC>().find("player");
mPlayer = new MWWorld::Player(player, *this);
if (!mPlayer)
mPlayer = new MWWorld::Player(player, *this);
else
mPlayer->set(player);
Ptr ptr = mPlayer->getPlayer();
mRendering->setupPlayer(ptr);
if (mNewGame)
{
MWWorld::Class::get(ptr).getContainerStore(ptr).fill(player->mInventory, "", mStore);
MWWorld::Class::get(ptr).getInventoryStore(ptr).autoEquip(ptr);
}
}
void World::renderPlayer()
{
mRendering->renderPlayer(mPlayer->getPlayer());
mPhysics->addActor(mPlayer->getPlayer());
if (mNewGame)
toggleCollisionMode();
}
void World::setupExternalRendering (MWRender::ExternalRendering& rendering)

@ -85,14 +85,9 @@ namespace MWWorld
float mFaced2Distance;
int mNumFacing;
bool mNewGame;
std::map<MWWorld::Ptr, int> mDoorStates;
///< only holds doors that are currently moving. 0 means closing, 1 opening
unsigned long lastTick;
Ogre::Timer mTimer;
int getDaysPerMonth (int month) const;
void rotateObjectImp (const Ptr& ptr, Ogre::Vector3 rot, bool adjust);
@ -120,16 +115,20 @@ namespace MWWorld
void ensureNeededRecords();
int mPlayIntro;
public:
World (OEngine::Render::OgreRenderer& renderer,
const Files::Collections& fileCollections,
const std::vector<std::string>& master, const std::vector<std::string>& plugins,
const boost::filesystem::path& resDir, const boost::filesystem::path& cacheDir, bool newGame,
const boost::filesystem::path& resDir, const boost::filesystem::path& cacheDir,
ToUTF8::Utf8Encoder* encoder, const std::map<std::string,std::string>& fallbackMap, int mActivationDistanceOverride);
virtual ~World();
virtual void startNewGame();
virtual OEngine::Render::Fader* getFader();
///< \ŧodo remove this function. Rendering details should not be exposed.

Loading…
Cancel
Save