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