mirror of
https://github.com/OpenMW/openmw.git
synced 2026-01-05 04:13:06 +00:00
Preserve static cell insertion order
This commit is contained in:
parent
ebad87bffb
commit
9cecc92d5c
2 changed files with 9 additions and 32 deletions
|
|
@ -639,20 +639,9 @@ namespace MWWorld
|
|||
for (const auto& [_, cell] : mDynamicInt)
|
||||
mCells.erase(cell->mId);
|
||||
mDynamicInt.clear();
|
||||
setUp();
|
||||
}
|
||||
|
||||
void Store<ESM::Cell>::setUp()
|
||||
{
|
||||
mSharedInt.clear();
|
||||
mSharedInt.reserve(mInt.size());
|
||||
for (auto& [_, cell] : mInt)
|
||||
mSharedInt.push_back(cell);
|
||||
|
||||
mSharedExt.clear();
|
||||
mSharedExt.reserve(mExt.size());
|
||||
for (auto& [_, cell] : mExt)
|
||||
mSharedExt.push_back(cell);
|
||||
mSharedInt.erase(mSharedInt.begin() + mInt.size(), mSharedInt.end());
|
||||
mSharedExt.erase(mSharedExt.begin() + mExt.size(), mSharedExt.end());
|
||||
}
|
||||
RecordId Store<ESM::Cell>::load(ESM::ESMReader& esm)
|
||||
{
|
||||
|
|
@ -685,7 +674,10 @@ namespace MWWorld
|
|||
{
|
||||
cell.loadCell(esm, true);
|
||||
if (newCell)
|
||||
{
|
||||
mInt[cell.mName] = &cell;
|
||||
mSharedInt.push_back(&cell);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -698,7 +690,10 @@ namespace MWWorld
|
|||
// push the new references on the list of references to manage
|
||||
cell.postLoad(esm);
|
||||
if (newCell)
|
||||
{
|
||||
mExt[std::make_pair(cell.mData.mX, cell.mData.mY)] = &cell;
|
||||
mSharedExt.push_back(&cell);
|
||||
}
|
||||
else
|
||||
{
|
||||
// merge lists of leased references, use newer data in case of conflict
|
||||
|
|
|
|||
|
|
@ -360,27 +360,10 @@ namespace MWWorld
|
|||
template <>
|
||||
class Store<ESM::Cell> : public DynamicStore
|
||||
{
|
||||
struct DynamicExtCmp
|
||||
{
|
||||
bool operator()(const std::pair<int, int>& left, const std::pair<int, int>& right) const
|
||||
{
|
||||
if (left.first == right.first && left.second == right.second)
|
||||
return false;
|
||||
|
||||
if (left.first == right.first)
|
||||
return left.second > right.second;
|
||||
|
||||
// Exterior cells are listed in descending, row-major order,
|
||||
// this is a workaround for an ambiguous chargen_plank reference in the vanilla game.
|
||||
// there is one at -22,16 and one at -2,-9, the latter should be used.
|
||||
return left.first > right.first;
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::unordered_map<std::string, ESM::Cell*, Misc::StringUtils::CiHash, Misc::StringUtils::CiEqual>
|
||||
DynamicInt;
|
||||
|
||||
typedef std::map<std::pair<int, int>, ESM::Cell*, DynamicExtCmp> DynamicExt;
|
||||
typedef std::map<std::pair<int, int>, ESM::Cell*> DynamicExt;
|
||||
|
||||
std::unordered_map<ESM::RefId, ESM::Cell> mCells;
|
||||
|
||||
|
|
@ -410,7 +393,6 @@ namespace MWWorld
|
|||
const ESM::Cell* find(int x, int y) const;
|
||||
|
||||
void clearDynamic() override;
|
||||
void setUp() override;
|
||||
|
||||
RecordId load(ESM::ESMReader& esm) override;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue