mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:23:52 +00:00
fixed pathgrid loading
This commit is contained in:
parent
f4c9897bbd
commit
be3b229a5f
7 changed files with 77 additions and 10 deletions
|
@ -31,7 +31,7 @@ opencs_units_noqt (model/world
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_hdrs_noqt (model/world
|
opencs_hdrs_noqt (model/world
|
||||||
columnimp idcollection collection info
|
columnimp idcollection collection info subcellcollection
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,8 +59,8 @@ int CSMWorld::Data::count (RecordBase::State state, const CollectionBase& collec
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourcesManager)
|
CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourcesManager)
|
||||||
: mEncoder (encoding), mRefs (mCells), mResourcesManager (resourcesManager), mReader (0),
|
: mEncoder (encoding), mPathgrids (mCells), mRefs (mCells),
|
||||||
mDialogue (0)
|
mResourcesManager (resourcesManager), mReader (0), mDialogue (0)
|
||||||
{
|
{
|
||||||
mGlobals.addColumn (new StringIdColumn<ESM::Global>);
|
mGlobals.addColumn (new StringIdColumn<ESM::Global>);
|
||||||
mGlobals.addColumn (new RecordStateColumn<ESM::Global>);
|
mGlobals.addColumn (new RecordStateColumn<ESM::Global>);
|
||||||
|
@ -595,12 +595,12 @@ CSMWorld::IdCollection<ESM::MagicEffect>& CSMWorld::Data::getMagicEffects()
|
||||||
return mMagicEffects;
|
return mMagicEffects;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CSMWorld::IdCollection<CSMWorld::Pathgrid>& CSMWorld::Data::getPathgrids() const
|
const CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& CSMWorld::Data::getPathgrids() const
|
||||||
{
|
{
|
||||||
return mPathgrids;
|
return mPathgrids;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMWorld::IdCollection<CSMWorld::Pathgrid>& CSMWorld::Data::getPathgrids()
|
CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& CSMWorld::Data::getPathgrids()
|
||||||
{
|
{
|
||||||
return mPathgrids;
|
return mPathgrids;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "refcollection.hpp"
|
#include "refcollection.hpp"
|
||||||
#include "infocollection.hpp"
|
#include "infocollection.hpp"
|
||||||
#include "pathgrid.hpp"
|
#include "pathgrid.hpp"
|
||||||
|
#include "subcellcollection.hpp"
|
||||||
|
|
||||||
class QAbstractItemModel;
|
class QAbstractItemModel;
|
||||||
|
|
||||||
|
@ -74,7 +75,7 @@ namespace CSMWorld
|
||||||
IdCollection<ESM::Enchantment> mEnchantments;
|
IdCollection<ESM::Enchantment> mEnchantments;
|
||||||
IdCollection<ESM::BodyPart> mBodyParts;
|
IdCollection<ESM::BodyPart> mBodyParts;
|
||||||
IdCollection<ESM::MagicEffect> mMagicEffects;
|
IdCollection<ESM::MagicEffect> mMagicEffects;
|
||||||
IdCollection<Pathgrid> mPathgrids;
|
SubCellCollection<Pathgrid> mPathgrids;
|
||||||
IdCollection<ESM::DebugProfile> mDebugProfiles;
|
IdCollection<ESM::DebugProfile> mDebugProfiles;
|
||||||
IdCollection<ESM::SoundGenerator> mSoundGens;
|
IdCollection<ESM::SoundGenerator> mSoundGens;
|
||||||
InfoCollection mTopicInfos;
|
InfoCollection mTopicInfos;
|
||||||
|
@ -209,9 +210,9 @@ namespace CSMWorld
|
||||||
|
|
||||||
IdCollection<ESM::MagicEffect>& getMagicEffects();
|
IdCollection<ESM::MagicEffect>& getMagicEffects();
|
||||||
|
|
||||||
const IdCollection<Pathgrid>& getPathgrids() const;
|
const SubCellCollection<Pathgrid>& getPathgrids() const;
|
||||||
|
|
||||||
IdCollection<Pathgrid>& getPathgrids();
|
SubCellCollection<Pathgrid>& getPathgrids();
|
||||||
|
|
||||||
/// Throws an exception, if \a id does not match a resources list.
|
/// Throws an exception, if \a id does not match a resources list.
|
||||||
const Resources& getResources (const UniversalId& id) const;
|
const Resources& getResources (const UniversalId& id) const;
|
||||||
|
|
|
@ -11,6 +11,8 @@ namespace CSMWorld
|
||||||
template<typename ESXRecordT, typename IdAccessorT = IdAccessor<ESXRecordT> >
|
template<typename ESXRecordT, typename IdAccessorT = IdAccessor<ESXRecordT> >
|
||||||
class IdCollection : public Collection<ESXRecordT, IdAccessorT>
|
class IdCollection : public Collection<ESXRecordT, IdAccessorT>
|
||||||
{
|
{
|
||||||
|
virtual void loadRecord (ESXRecordT& record, ESM::ESMReader& reader);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void load (ESM::ESMReader& reader, bool base);
|
void load (ESM::ESMReader& reader, bool base);
|
||||||
|
@ -26,6 +28,13 @@ namespace CSMWorld
|
||||||
/// \return Has the ID been deleted?
|
/// \return Has the ID been deleted?
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename ESXRecordT, typename IdAccessorT>
|
||||||
|
void IdCollection<ESXRecordT, IdAccessorT>::loadRecord (ESXRecordT& record,
|
||||||
|
ESM::ESMReader& reader)
|
||||||
|
{
|
||||||
|
record.load (reader);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename ESXRecordT, typename IdAccessorT>
|
template<typename ESXRecordT, typename IdAccessorT>
|
||||||
void IdCollection<ESXRecordT, IdAccessorT>::load (ESM::ESMReader& reader, bool base)
|
void IdCollection<ESXRecordT, IdAccessorT>::load (ESM::ESMReader& reader, bool base)
|
||||||
{
|
{
|
||||||
|
@ -69,7 +78,7 @@ namespace CSMWorld
|
||||||
record = this->getRecord (index).get();
|
record = this->getRecord (index).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
record.load (reader);
|
loadRecord (record, reader);
|
||||||
|
|
||||||
if (index==-1)
|
if (index==-1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,6 +3,21 @@
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
void CSMWorld::Pathgrid::load (ESM::ESMReader &esm, const IdCollection<Cell>& cells)
|
||||||
|
{
|
||||||
|
load (esm);
|
||||||
|
|
||||||
|
// correct ID
|
||||||
|
if (!mId.empty() && mId[0]!='#' && cells.searchId (mId)==-1)
|
||||||
|
{
|
||||||
|
std::ostringstream stream;
|
||||||
|
|
||||||
|
stream << "#" << mData.mX << " " << mData.mY;
|
||||||
|
|
||||||
|
mId = stream.str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CSMWorld::Pathgrid::load (ESM::ESMReader &esm)
|
void CSMWorld::Pathgrid::load (ESM::ESMReader &esm)
|
||||||
{
|
{
|
||||||
ESM::Pathgrid::load (esm);
|
ESM::Pathgrid::load (esm);
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
|
|
||||||
#include <components/esm/loadpgrd.hpp>
|
#include <components/esm/loadpgrd.hpp>
|
||||||
|
|
||||||
|
#include "idcollection.hpp"
|
||||||
|
#include "cell.hpp"
|
||||||
|
|
||||||
namespace CSMWorld
|
namespace CSMWorld
|
||||||
{
|
{
|
||||||
/// \brief Wrapper for Pathgrid record
|
/// \brief Wrapper for Pathgrid record
|
||||||
|
@ -16,8 +19,9 @@ namespace CSMWorld
|
||||||
{
|
{
|
||||||
std::string mId;
|
std::string mId;
|
||||||
|
|
||||||
void load (ESM::ESMReader &esm);
|
void load (ESM::ESMReader &esm, const IdCollection<Cell>& cells);
|
||||||
|
|
||||||
|
void load (ESM::ESMReader &esm);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
38
apps/opencs/model/world/subcellcollection.hpp
Normal file
38
apps/opencs/model/world/subcellcollection.hpp
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#ifndef CSM_WOLRD_SUBCOLLECTION_H
|
||||||
|
#define CSM_WOLRD_SUBCOLLECTION_H
|
||||||
|
|
||||||
|
#include "idcollection.hpp"
|
||||||
|
|
||||||
|
namespace CSMWorld
|
||||||
|
{
|
||||||
|
/// \brief Single type collection of top level records that are associated with cells
|
||||||
|
template<typename ESXRecordT, typename IdAccessorT = IdAccessor<ESXRecordT> >
|
||||||
|
class SubCellCollection : public IdCollection<ESXRecordT, IdAccessorT>
|
||||||
|
{
|
||||||
|
const IdCollection<Cell>& mCells;
|
||||||
|
|
||||||
|
virtual void loadRecord (ESXRecordT& record, ESM::ESMReader& reader);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
SubCellCollection (const IdCollection<Cell>& cells);
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename ESXRecordT, typename IdAccessorT>
|
||||||
|
void SubCellCollection<ESXRecordT, IdAccessorT>::loadRecord (ESXRecordT& record,
|
||||||
|
ESM::ESMReader& reader)
|
||||||
|
{
|
||||||
|
record.load (reader, mCells);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename ESXRecordT, typename IdAccessorT>
|
||||||
|
SubCellCollection<ESXRecordT, IdAccessorT>::SubCellCollection (
|
||||||
|
const IdCollection<Cell>& cells)
|
||||||
|
: mCells (cells)
|
||||||
|
{}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in a new issue