1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 21:53:51 +00:00

change to static --> dynamic search order

This commit is contained in:
greye 2012-11-06 17:58:49 +04:00
parent 9f1733a415
commit 83f5b1df81

View file

@ -107,17 +107,18 @@ namespace MWWorld
T item; T item;
item.mId = StringUtils::lowerCase(id); item.mId = StringUtils::lowerCase(id);
typename Dynamic::const_iterator dit = mDynamic.find(item.mId);
if (dit != mDynamic.end()) {
return &dit->second;
}
typename std::vector<T>::const_iterator it = typename std::vector<T>::const_iterator it =
std::lower_bound(mStatic.begin(), mStatic.end(), item, RecordCmp()); std::lower_bound(mStatic.begin(), mStatic.end(), item, RecordCmp());
if (it != mStatic.end() && it->mId == item.mId) { if (it != mStatic.end() && it->mId == item.mId) {
return &(*it); return &(*it);
} }
typename Dynamic::const_iterator dit = mDynamic.find(item.mId);
if (dit != mDynamic.end()) {
return &dit->second;
}
return 0; return 0;
} }
@ -388,17 +389,18 @@ namespace MWWorld
ESM::Cell cell; ESM::Cell cell;
cell.mName = StringUtils::lowerCase(id); cell.mName = StringUtils::lowerCase(id);
DynamicInt::const_iterator dit = mDynamicInt.find(cell.mName);
if (dit != mDynamicInt.end()) {
return &dit->second;
}
std::vector<ESM::Cell>::const_iterator it = std::vector<ESM::Cell>::const_iterator it =
std::lower_bound(mInt.begin(), mInt.end(), cell, RecordCmp()); std::lower_bound(mInt.begin(), mInt.end(), cell, RecordCmp());
if (it != mInt.end() && StringUtils::ciEqual(it->mName, id)) { if (it != mInt.end() && StringUtils::ciEqual(it->mName, id)) {
return &(*it); return &(*it);
} }
DynamicInt::const_iterator dit = mDynamicInt.find(cell.mName);
if (dit != mDynamicInt.end()) {
return &dit->second;
}
return 0; return 0;
} }
@ -406,18 +408,19 @@ namespace MWWorld
ESM::Cell cell; ESM::Cell cell;
cell.mData.mX = x, cell.mData.mY = y; cell.mData.mX = x, cell.mData.mY = y;
std::pair<int, int> key(x, y);
DynamicExt::const_iterator dit = mDynamicExt.find(key);
if (dit != mDynamicExt.end()) {
return &dit->second;
}
std::vector<ESM::Cell>::const_iterator it = std::vector<ESM::Cell>::const_iterator it =
std::lower_bound(mExt.begin(), mExt.end(), cell, ExtCmp()); std::lower_bound(mExt.begin(), mExt.end(), cell, ExtCmp());
if (it != mExt.end() && it->mData.mX == x && it->mData.mY == y) { if (it != mExt.end() && it->mData.mX == x && it->mData.mY == y) {
return &(*it); return &(*it);
} }
std::pair<int, int> key(x, y);
DynamicExt::const_iterator dit = mDynamicExt.find(key);
if (dit != mDynamicExt.end()) {
return &dit->second;
}
return 0; return 0;
} }