Preliminary region sound framework2

actorid
Jason Hooks 14 years ago
parent cab2341259
commit a038c67e5a

@ -1,10 +1,12 @@
#include "engine.hpp" #include "engine.hpp"
#include "components/esm/loadcell.hpp"
#include <cassert> #include <cassert>
#include <iostream> #include <iostream>
#include <utility> #include <utility>
#include <components/esm_store/cell_store.hpp>
#include <components/misc/fileops.hpp> #include <components/misc/fileops.hpp>
#include <components/bsa/bsa_archive.hpp> #include <components/bsa/bsa_archive.hpp>
#include <components/esm/loadregn.hpp> #include <components/esm/loadregn.hpp>
@ -107,11 +109,14 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
} }
//If the region has changed //If the region has changed
if(mEnvironment.mWorld->getIsExterior() && test.name != mEnvironment.mWorld->getCurrentRegion().name){ MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayerPos().getPlayer().getCell();
test = mEnvironment.mWorld->getCurrentRegion(); if(!(current->cell->data.flags & current->cell->Interior) && (test.name != current->cell->region)){
test = *(mEnvironment.mWorld->getStore().regions.find(current->cell->region));
if(test.soundList.size() > 0) if(test.soundList.size() > 0)
{ {
std::vector<ESM::Region::SoundRef>::iterator soundIter = test.soundList.begin(); std::vector<ESM::Region::SoundRef>::iterator soundIter = test.soundList.begin();
mEnvironment.mWorld->getPlayerPos().getPlayer().getCell();
//mEnvironment.mSoundManager
while (!(soundIter == test.soundList.end())) while (!(soundIter == test.soundList.end()))
{ {
ESM::NAME32 go = soundIter->sound; ESM::NAME32 go = soundIter->sound;
@ -126,7 +131,7 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
//printf("REGION: %s\n", test.name); //printf("REGION: %s\n", test.name);
} }
else if(!mEnvironment.mWorld->getIsExterior()) else if(current->cell->data.flags & current->cell->Interior)
{ {
test.name = ""; test.name = "";
} }

@ -66,30 +66,7 @@ namespace
namespace MWWorld namespace MWWorld
{ {
ESM::ESMReader World::getEsmReader(){
return mEsm;
}
Ptr::CellStore World::getMCurrentCell()
{
return *mCurrentCell;
}
ESM::Region World::getCurrentRegion()
{
return *currentRegion;
}
bool World::getIsExterior()
{
return isExterior;
}
void World::setIsExterior(bool set)
{
isExterior = set;
}
void World::insertInteriorScripts (ESMS::CellStore<RefData>& cell) void World::insertInteriorScripts (ESMS::CellStore<RefData>& cell)
{ {
listCellScripts (mStore, cell.activators, mLocalScripts, &cell); listCellScripts (mStore, cell.activators, mLocalScripts, &cell);
@ -343,7 +320,6 @@ namespace MWWorld
: mSkyManager (0), mScene (renderer), mPlayerPos (0), mCurrentCell (0), mGlobalVariables (0), : mSkyManager (0), mScene (renderer), mPlayerPos (0), mCurrentCell (0), mGlobalVariables (0),
mSky (false), mCellChanged (false), mEnvironment (environment) mSky (false), mCellChanged (false), mEnvironment (environment)
{ {
isExterior = false;
boost::filesystem::path masterPath (dataDir); boost::filesystem::path masterPath (dataDir);
masterPath /= master; masterPath /= master;
@ -634,7 +610,6 @@ namespace MWWorld
adjustSky(); adjustSky();
mCellChanged = true; mCellChanged = true;
isExterior = false;
//currentRegion->name = ""; //currentRegion->name = "";
} }
@ -712,11 +687,11 @@ namespace MWWorld
mCellChanged = true; mCellChanged = true;
} }
void World::changeToExteriorCell (const ESM::Position& position)
void World::changeToExteriorCell (const ESM::Position& position)
{ {
int x = 0; int x = 0;
int y = 0; int y = 0;
isExterior = true;
positionToIndex (position.pos[0], position.pos[1], x, y); positionToIndex (position.pos[0], position.pos[1], x, y);
@ -727,21 +702,9 @@ namespace MWWorld
{ {
// first try named cells // first try named cells
if (const ESM::Cell *cell = mStore.cells.searchExtByName (cellName)) if (const ESM::Cell *cell = mStore.cells.searchExtByName (cellName))
{
//mCellChanged = true;
getExteriorRegion(cell->region);
return cell; return cell;
} // didn't work -> now check for regions
return getExteriorRegion(cellName);
}
const ESM::Cell *World::getExteriorRegion(const std::string& cellName) const
{
// didn't work -> now check for regions
std::string cellName2 = ESMS::RecListT<ESM::Region>::toLower (cellName); std::string cellName2 = ESMS::RecListT<ESM::Region>::toLower (cellName);
for (ESMS::RecListT<ESM::Region>::MapType::const_iterator iter (mStore.regions.list.begin()); for (ESMS::RecListT<ESM::Region>::MapType::const_iterator iter (mStore.regions.list.begin());
@ -749,7 +712,6 @@ namespace MWWorld
{ {
if (ESMS::RecListT<ESM::Region>::toLower (iter->second.name)==cellName2) if (ESMS::RecListT<ESM::Region>::toLower (iter->second.name)==cellName2)
{ {
*currentRegion = iter->second;
if (const ESM::Cell *cell = mStore.cells.searchExtByRegion (iter->first)) if (const ESM::Cell *cell = mStore.cells.searchExtByRegion (iter->first))
return cell; return cell;
@ -757,9 +719,8 @@ namespace MWWorld
} }
} }
return 0; return 0;
} }
void World::markCellAsUnchanged() void World::markCellAsUnchanged()
{ {
mCellChanged = false; mCellChanged = false;

@ -43,12 +43,6 @@ namespace MWWorld
public: public:
typedef std::list<std::pair<std::string, Ptr> > ScriptList; typedef std::list<std::pair<std::string, Ptr> > ScriptList;
ESM::ESMReader getEsmReader();
Ptr::CellStore getMCurrentCell();
ESM::Region getCurrentRegion();
bool getIsExterior();
void setIsExterior(bool set);
private: private:
typedef std::map<Ptr::CellStore *, MWRender::CellRender *> CellRenderCollection; typedef std::map<Ptr::CellStore *, MWRender::CellRender *> CellRenderCollection;
@ -56,7 +50,7 @@ namespace MWWorld
MWRender::SkyManager* mSkyManager; MWRender::SkyManager* mSkyManager;
MWRender::MWScene mScene; MWRender::MWScene mScene;
MWRender::PlayerPos *mPlayerPos; MWRender::PlayerPos *mPlayerPos;
Ptr::CellStore *mCurrentCell; // the cell, the player is in Ptr::CellStore *mCurrentCell; // the cell, the player is in
CellRenderCollection mActiveCells; CellRenderCollection mActiveCells;
CellRenderCollection mBufferedCells; // loaded, but not active (buffering not implementd yet) CellRenderCollection mBufferedCells; // loaded, but not active (buffering not implementd yet)
ESM::ESMReader mEsm; ESM::ESMReader mEsm;
@ -67,9 +61,7 @@ namespace MWWorld
MWWorld::Globals *mGlobalVariables; MWWorld::Globals *mGlobalVariables;
bool mSky; bool mSky;
bool mCellChanged; bool mCellChanged;
bool isExterior;
Environment& mEnvironment; Environment& mEnvironment;
ESM::Region *currentRegion;
// not implemented // not implemented
World (const World&); World (const World&);
@ -104,7 +96,7 @@ namespace MWWorld
MWRender::PlayerPos& getPlayerPos(); MWRender::PlayerPos& getPlayerPos();
ESMS::ESMStore& getStore(); ESMS::ESMStore& getStore();
const ScriptList& getLocalScripts() const; const ScriptList& getLocalScripts() const;
///< Names and local variable state of all local scripts in active cells. ///< Names and local variable state of all local scripts in active cells.
@ -154,7 +146,6 @@ namespace MWWorld
void changeToExteriorCell (const ESM::Position& position); void changeToExteriorCell (const ESM::Position& position);
const ESM::Cell *getExterior (const std::string& cellName) const; const ESM::Cell *getExterior (const std::string& cellName) const;
const ESM::Cell *getExteriorRegion (const std::string& cellName) const;
///< Return a cell matching the given name or a 0-pointer, if there is no such cell. ///< Return a cell matching the given name or a 0-pointer, if there is no such cell.
void markCellAsUnchanged(); void markCellAsUnchanged();

Loading…
Cancel
Save