1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-03 19:49:41 +00:00

[Client] Make it possible to override Cell records in ESMStore

This commit is contained in:
David Cernat 2019-09-28 13:10:43 +03:00
parent 0b85829e38
commit 18a7ac5940
3 changed files with 60 additions and 0 deletions

View file

@ -241,6 +241,20 @@ namespace MWWorld
///< \return Known type?
};
/*
Start of tes3mp addition
Make it possible to override a cell record similarly to how
other types of records can be overridden
*/
template <>
inline const ESM::Cell *ESMStore::overrideRecord<ESM::Cell>(const ESM::Cell &cell) {
return mCells.override(cell);
}
/*
End of tes3mp addition
*/
template <>
inline const ESM::Cell *ESMStore::insert<ESM::Cell>(const ESM::Cell &cell) {
return mCells.insert(cell);

View file

@ -801,6 +801,42 @@ namespace MWWorld
list.push_back(sharedCell->mName);
}
}
/*
Start of tes3mp addition
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)
{
if (search(cell) != 0)
{
for (auto it = mSharedInt.begin(); it != mSharedInt.end(); ++it)
{
if (Misc::StringUtils::ciEqual((*it)->mName, cell.mName))
{
(*it) = &const_cast<ESM::Cell&>(cell);
break;
}
}
for (auto it = mInt.begin(); it != mInt.end(); ++it)
{
if (Misc::StringUtils::ciEqual((*it).second.mName, cell.mName))
{
(*it).second = cell;
return &(*it).second;
}
}
}
else
{
return insert(cell);
}
}
/*
End of tes3mp addition
*/
ESM::Cell *Store<ESM::Cell>::insert(const ESM::Cell &cell)
{
if (search(cell) != 0)

View file

@ -315,6 +315,16 @@ namespace MWWorld
void listIdentifier(std::vector<std::string> &list) const;
/*
Start of tes3mp addition
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);
/*
End of tes3mp addition
*/
ESM::Cell *insert(const ESM::Cell &cell);
bool erase(const ESM::Cell &cell);