forked from mirror/openmw-tes3mp
load() method for records with string id
This commit is contained in:
parent
5ac54d1fff
commit
ce91c5636d
1 changed files with 28 additions and 1 deletions
|
@ -184,7 +184,9 @@ namespace MWWorld
|
|||
std::vector<T *> mShared;
|
||||
|
||||
public:
|
||||
Store() {}
|
||||
Store()
|
||||
: mComp(false)
|
||||
{}
|
||||
|
||||
Store(bool ci)
|
||||
: mComp(ci)
|
||||
|
@ -217,6 +219,31 @@ namespace MWWorld
|
|||
return ptr;
|
||||
}
|
||||
|
||||
void load(ESM::ESMReader &esm, const std::string &id) {
|
||||
// reduce size of allocated memory to copy
|
||||
mData.push_back(T());
|
||||
|
||||
// some records requires id before loading
|
||||
// make sure that string case is the same across container
|
||||
if (mComp.isCaseInsensitive()) {
|
||||
mData.back().mId = id;
|
||||
} else {
|
||||
mData.back().mId = lowerCase(id);
|
||||
}
|
||||
mData.back().load(esm);
|
||||
|
||||
// allow records to overwrite id on loading
|
||||
if (!mComp.isCaseInsensitive()) {
|
||||
std::string &s = mData.back().mId;
|
||||
std::transform(
|
||||
s.begin(),
|
||||
s.end(),
|
||||
s.begin(),
|
||||
(int (*)(int)) std::tolower
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void setUp() {
|
||||
std::sort(mData.begin(), mData.end(), mComp);
|
||||
|
||||
|
|
Loading…
Reference in a new issue