mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 03:40:14 +00:00
std::set version
This commit is contained in:
parent
f81be5b463
commit
7772f5111b
@ -422,9 +422,8 @@ namespace MWWorld
|
||||
const ESM::Land *Store<ESM::Land>::search(int x, int y) const
|
||||
{
|
||||
std::pair<int, int> comp(x,y);
|
||||
if (auto it = mStatic.find(comp); it != mStatic.end() && (*it)->mX == x && (*it)->mY == y) {
|
||||
return it->get();
|
||||
}
|
||||
if (auto it = mStatic.find(comp); it != mStatic.end() && it->mX == x && it->mY == y)
|
||||
return &*it;
|
||||
return nullptr;
|
||||
}
|
||||
const ESM::Land *Store<ESM::Land>::find(int x, int y) const
|
||||
@ -439,13 +438,13 @@ namespace MWWorld
|
||||
}
|
||||
RecordId Store<ESM::Land>::load(ESM::ESMReader &esm)
|
||||
{
|
||||
auto ptr = std::make_unique<ESM::Land>();
|
||||
ESM::Land land;
|
||||
bool isDeleted = false;
|
||||
|
||||
ptr->load(esm, isDeleted);
|
||||
land.load(esm, isDeleted);
|
||||
|
||||
// Same area defined in multiple plugins? -> last plugin wins
|
||||
mStatic.insert(std::move(ptr));
|
||||
mStatic.insert(std::move(land));
|
||||
|
||||
return RecordId("", isDeleted);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <boost/container/flat_set.hpp>
|
||||
#include <set>
|
||||
|
||||
#include "recordcmp.hpp"
|
||||
|
||||
@ -239,30 +239,24 @@ namespace MWWorld
|
||||
{
|
||||
using is_transparent = void;
|
||||
|
||||
bool operator()(const std::unique_ptr<ESM::Land>& x, const std::unique_ptr<ESM::Land>& y) const {
|
||||
if (x->mX == y->mX) {
|
||||
return x->mY < y->mY;
|
||||
}
|
||||
return x->mX < y->mX;
|
||||
bool operator()(const ESM::Land& x, const ESM::Land& y) const
|
||||
{
|
||||
return std::tie(x.mX, x.mY) < std::tie(y.mX, y.mY);
|
||||
}
|
||||
bool operator()(const std::unique_ptr<ESM::Land>& x, const std::pair<int, int>& y) const {
|
||||
if (x->mX == y.first) {
|
||||
return x->mY < y.second;
|
||||
}
|
||||
return x->mX < y.first;
|
||||
bool operator()(const ESM::Land& x, const std::pair<int, int>& y) const
|
||||
{
|
||||
return std::tie(x.mX, x.mY) < std::tie(y.first, y.second);
|
||||
}
|
||||
bool operator()(const std::pair<int, int>& x, const std::unique_ptr<ESM::Land>& y) const {
|
||||
if (x.first == y->mX) {
|
||||
return x.second < y->mY;
|
||||
}
|
||||
return x.first < y->mX;
|
||||
bool operator()(const std::pair<int, int>& x, const ESM::Land& y) const
|
||||
{
|
||||
return std::tie(x.first, x.second) < std::tie(y.mX, y.mY);
|
||||
}
|
||||
};
|
||||
using Statics = boost::container::flat_set<std::unique_ptr<ESM::Land>, SpatialComparator>;
|
||||
using Statics = std::set<ESM::Land, SpatialComparator>;
|
||||
Statics mStatic;
|
||||
|
||||
public:
|
||||
typedef SharedIterator<ESM::Land, Statics> iterator;
|
||||
typedef typename Statics::iterator iterator;
|
||||
|
||||
virtual ~Store();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user