mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-05 22:19:42 +00:00
[Client] Reuse Pathgrid records from base Cells when creating new Cells
This commit is contained in:
parent
2a3d6ea7f0
commit
43f531e9a5
4 changed files with 67 additions and 3 deletions
|
@ -368,6 +368,14 @@ void RecordHelper::overrideRecord(const mwmp::CellRecord& record)
|
|||
world->unloadCell(finalData);
|
||||
world->clearCellStore(finalData);
|
||||
world->getModifiableStore().overrideRecord(finalData);
|
||||
|
||||
// Create a Pathgrid record for this new Cell based on the base Cell's Pathgrid
|
||||
// Note: This has to be done after the new Cell has been created so the Pathgrid override
|
||||
// can correctly determine whether the Cell is an interior or an exterior
|
||||
const ESM::Pathgrid* basePathgrid = world->getStore().get<ESM::Pathgrid>().search(record.baseId);
|
||||
ESM::Pathgrid finalPathgrid = *basePathgrid;
|
||||
finalPathgrid.mCell = recordData.mName;
|
||||
world->getModifiableStore().overrideRecord(finalPathgrid);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -276,7 +276,7 @@ namespace MWWorld
|
|||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Make it possible to override a cell record similarly to how
|
||||
Make it possible to override a Cell record similarly to how
|
||||
other types of records can be overridden
|
||||
*/
|
||||
template <>
|
||||
|
@ -287,6 +287,20 @@ namespace MWWorld
|
|||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Make it possible to override a Pathgrid record similarly to how
|
||||
other types of records can be overridden
|
||||
*/
|
||||
template <>
|
||||
inline const ESM::Pathgrid* ESMStore::overrideRecord<ESM::Pathgrid>(const ESM::Pathgrid& pathgrid) {
|
||||
return mPathgrids.override(pathgrid);
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
template <>
|
||||
inline const ESM::Cell *ESMStore::insert<ESM::Cell>(const ESM::Cell &cell) {
|
||||
return mCells.insert(cell);
|
||||
|
|
|
@ -796,7 +796,7 @@ namespace MWWorld
|
|||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Make it possible to override a cell record similarly to how
|
||||
Make it possible to override a Cell record similarly to how
|
||||
other types of records can be overridden
|
||||
*/
|
||||
ESM::Cell *Store<ESM::Cell>::override(const ESM::Cell &cell)
|
||||
|
@ -949,6 +949,37 @@ namespace MWWorld
|
|||
|
||||
return RecordId("", isDeleted);
|
||||
}
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Make it possible to override a Pathgrid record similarly to how
|
||||
other types of records can be overridden
|
||||
*/
|
||||
ESM::Pathgrid* Store<ESM::Pathgrid>::override(const ESM::Pathgrid& pathgrid)
|
||||
{
|
||||
bool interior = mCells->search(pathgrid.mCell) != nullptr;
|
||||
|
||||
// Try to overwrite existing record
|
||||
if (interior)
|
||||
{
|
||||
std::pair<Interior::iterator, bool> ret = mInt.insert(std::make_pair(pathgrid.mCell, pathgrid));
|
||||
if (!ret.second)
|
||||
ret.first->second = pathgrid;
|
||||
|
||||
return &ret.first->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::pair<Exterior::iterator, bool> ret = mExt.insert(std::make_pair(std::make_pair(pathgrid.mData.mX, pathgrid.mData.mY), pathgrid));
|
||||
if (!ret.second)
|
||||
ret.first->second = pathgrid;
|
||||
|
||||
return &ret.first->second;
|
||||
}
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
size_t Store<ESM::Pathgrid>::getSize() const
|
||||
{
|
||||
return mInt.size() + mExt.size();
|
||||
|
|
|
@ -325,7 +325,7 @@ namespace MWWorld
|
|||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Make it possible to override a cell record similarly to how
|
||||
Make it possible to override a Cell record similarly to how
|
||||
other types of records can be overridden
|
||||
*/
|
||||
ESM::Cell *override(const ESM::Cell &cell);
|
||||
|
@ -362,6 +362,17 @@ namespace MWWorld
|
|||
|
||||
void setUp() override;
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Make it possible to override a Pathgrid record similarly to how
|
||||
other types of records can be overridden
|
||||
*/
|
||||
ESM::Pathgrid* override(const ESM::Pathgrid& pathgrid);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
const ESM::Pathgrid *search(int x, int y) const;
|
||||
const ESM::Pathgrid *search(const std::string& name) const;
|
||||
const ESM::Pathgrid *find(int x, int y) const;
|
||||
|
|
Loading…
Reference in a new issue