mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +00:00
Issue #31: create new exterior cells on the fly
This commit is contained in:
parent
8da15440e0
commit
b866323cf3
3 changed files with 26 additions and 5 deletions
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "world.hpp"
|
||||||
|
|
||||||
MWWorld::Ptr::CellStore *MWWorld::Cells::getCellStore (const ESM::Cell *cell)
|
MWWorld::Ptr::CellStore *MWWorld::Cells::getCellStore (const ESM::Cell *cell)
|
||||||
{
|
{
|
||||||
if (cell->data.flags & ESM::Cell::Interior)
|
if (cell->data.flags & ESM::Cell::Interior)
|
||||||
|
@ -33,8 +35,8 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getCellStore (const ESM::Cell *cell)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::Cells::Cells (const ESMS::ESMStore& store, ESM::ESMReader& reader)
|
MWWorld::Cells::Cells (const ESMS::ESMStore& store, ESM::ESMReader& reader, MWWorld::World& world)
|
||||||
: mStore (store), mReader (reader) {}
|
: mStore (store), mReader (reader), mWorld (world) {}
|
||||||
|
|
||||||
MWWorld::Ptr::CellStore *MWWorld::Cells::getExterior (int x, int y)
|
MWWorld::Ptr::CellStore *MWWorld::Cells::getExterior (int x, int y)
|
||||||
{
|
{
|
||||||
|
@ -43,7 +45,21 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getExterior (int x, int y)
|
||||||
|
|
||||||
if (result==mExteriors.end())
|
if (result==mExteriors.end())
|
||||||
{
|
{
|
||||||
const ESM::Cell *cell = mStore.cells.findExt (x, y);
|
const ESM::Cell *cell = mStore.cells.searchExt (x, y);
|
||||||
|
|
||||||
|
if (!cell)
|
||||||
|
{
|
||||||
|
// Cell isn't predefined. Make one on the fly.
|
||||||
|
ESM::Cell record;
|
||||||
|
|
||||||
|
record.data.flags = 0;
|
||||||
|
record.data.gridX = x;
|
||||||
|
record.data.gridY = y;
|
||||||
|
record.water = 0;
|
||||||
|
record.mapColor = 0;
|
||||||
|
|
||||||
|
cell = mWorld.createRecord (record);
|
||||||
|
}
|
||||||
|
|
||||||
result = mExteriors.insert (std::make_pair (
|
result = mExteriors.insert (std::make_pair (
|
||||||
std::make_pair (x, y), Ptr::CellStore (cell))).first;
|
std::make_pair (x, y), Ptr::CellStore (cell))).first;
|
||||||
|
|
|
@ -18,6 +18,8 @@ namespace ESM
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
|
class World;
|
||||||
|
|
||||||
/// \brief Cell container
|
/// \brief Cell container
|
||||||
class Cells
|
class Cells
|
||||||
{
|
{
|
||||||
|
@ -25,6 +27,7 @@ namespace MWWorld
|
||||||
ESM::ESMReader& mReader;
|
ESM::ESMReader& mReader;
|
||||||
std::map<std::string, Ptr::CellStore> mInteriors;
|
std::map<std::string, Ptr::CellStore> mInteriors;
|
||||||
std::map<std::pair<int, int>, Ptr::CellStore> mExteriors;
|
std::map<std::pair<int, int>, Ptr::CellStore> mExteriors;
|
||||||
|
MWWorld::World& mWorld;
|
||||||
|
|
||||||
Cells (const Cells&);
|
Cells (const Cells&);
|
||||||
Cells& operator= (const Cells&);
|
Cells& operator= (const Cells&);
|
||||||
|
@ -33,7 +36,9 @@ namespace MWWorld
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Cells (const ESMS::ESMStore& store, ESM::ESMReader& reader);
|
Cells (const ESMS::ESMStore& store, ESM::ESMReader& reader, MWWorld::World& world);
|
||||||
|
///< \todo pass the dynamic part of the ESMStore isntead (once it is written) of the whole
|
||||||
|
/// world
|
||||||
|
|
||||||
Ptr::CellStore *getExterior (int x, int y);
|
Ptr::CellStore *getExterior (int x, int y);
|
||||||
|
|
||||||
|
|
|
@ -214,7 +214,7 @@ namespace MWWorld
|
||||||
const std::string& master, const boost::filesystem::path& resDir,
|
const std::string& master, const boost::filesystem::path& resDir,
|
||||||
bool newGame, Environment& environment, const std::string& encoding)
|
bool newGame, Environment& environment, const std::string& encoding)
|
||||||
: mScene (renderer,physEng), mPlayer (0), mGlobalVariables (0),
|
: mScene (renderer,physEng), mPlayer (0), mGlobalVariables (0),
|
||||||
mSky (false), mEnvironment (environment), mNextDynamicRecord (0), mCells (mStore, mEsm)
|
mSky (false), mEnvironment (environment), mNextDynamicRecord (0), mCells (mStore, mEsm, *this)
|
||||||
{
|
{
|
||||||
mPhysEngine = physEng;
|
mPhysEngine = physEng;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue