- Restore ability to generate references in the same cell from multiple plugins

- Disable some code related to deleting entries in the store so that it builds again
actorid
Mark Siewert 12 years ago
parent b103426cf0
commit 049b0e66e0

@ -83,8 +83,6 @@ namespace MWWorld
// Load references from all plugins that do something with this cell. // Load references from all plugins that do something with this cell.
for (size_t i = 0; i < mCell->mContextList.size(); i++) for (size_t i = 0; i < mCell->mContextList.size(); i++)
{ {
if (mCell->mContextList.size() > 1)
std::cout << "number of lists " << mCell->mContextList.size() << std::endl;
// Reopen the ESM reader and seek to the right position. // Reopen the ESM reader and seek to the right position.
int index = mCell->mContextList.at(i).index; int index = mCell->mContextList.at(i).index;
mCell->restore (esm[index], i); mCell->restore (esm[index], i);

@ -87,12 +87,14 @@ void ESMStore::load(ESM::ESMReader &esm)
// ... unless it got deleted! This means that the following record // ... unless it got deleted! This means that the following record
// has been deleted, and trying to load it using standard assumptions // has been deleted, and trying to load it using standard assumptions
// on the structure will (probably) fail. // on the structure will (probably) fail.
/*
if (esm.isNextSub("DELE")) { if (esm.isNextSub("DELE")) {
esm.skipRecord(); esm.skipRecord();
all.erase(id); all.erase(id);
it->second->remove(id); it->second->remove(id);
continue; continue;
} }
*/
it->second->load(esm, id); it->second->load(esm, id);
if (n.val==ESM::REC_DIAL) { if (n.val==ESM::REC_DIAL) {

@ -371,15 +371,15 @@ namespace MWWorld
} }
}; };
std::vector<ESM::Cell> mInt; typedef std::map<std::string, ESM::Cell> DynamicInt;
std::vector<ESM::Cell> mExt; typedef std::map<std::pair<int, int>, ESM::Cell> DynamicExt;
DynamicInt mInt;
DynamicExt mExt;
std::vector<ESM::Cell *> mSharedInt; std::vector<ESM::Cell *> mSharedInt;
std::vector<ESM::Cell *> mSharedExt; std::vector<ESM::Cell *> mSharedExt;
typedef std::map<std::string, ESM::Cell> DynamicInt;
typedef std::map<std::pair<int, int>, ESM::Cell> DynamicExt;
DynamicInt mDynamicInt; DynamicInt mDynamicInt;
DynamicExt mDynamicExt; DynamicExt mDynamicExt;
@ -401,11 +401,10 @@ namespace MWWorld
ESM::Cell cell; ESM::Cell cell;
cell.mName = StringUtils::lowerCase(id); cell.mName = StringUtils::lowerCase(id);
std::vector<ESM::Cell>::const_iterator it = std::map<std::string, ESM::Cell>::const_iterator it = mInt.find(cell.mName);
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->second.mName, id)) {
return &(*it); return &(it->second);
} }
DynamicInt::const_iterator dit = mDynamicInt.find(cell.mName); DynamicInt::const_iterator dit = mDynamicInt.find(cell.mName);
@ -420,14 +419,12 @@ 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::vector<ESM::Cell>::const_iterator it = std::pair<int, int> key(x, y);
std::lower_bound(mExt.begin(), mExt.end(), cell, ExtCmp()); std::map<std::pair<int, int>, ESM::Cell>::const_iterator it = mExt.find(key);
if (it != mExt.end()) {
if (it != mExt.end() && it->mData.mX == x && it->mData.mY == y) { return &(it->second);
return &(*it);
} }
std::pair<int, int> key(x, y);
DynamicExt::const_iterator dit = mDynamicExt.find(key); DynamicExt::const_iterator dit = mDynamicExt.find(key);
if (dit != mDynamicExt.end()) { if (dit != mDynamicExt.end()) {
return &dit->second; return &dit->second;
@ -457,18 +454,20 @@ namespace MWWorld
} }
void setUp() { void setUp() {
typedef std::vector<ESM::Cell>::iterator Iterator; //typedef std::vector<ESM::Cell>::iterator Iterator;
typedef std::map<std::pair<int, int>, ESM::Cell>::iterator ExtIterator;
typedef std::map<std::string, ESM::Cell>::iterator IntIterator;
std::sort(mInt.begin(), mInt.end(), RecordCmp()); //std::sort(mInt.begin(), mInt.end(), RecordCmp());
mSharedInt.reserve(mInt.size()); mSharedInt.reserve(mInt.size());
for (Iterator it = mInt.begin(); it != mInt.end(); ++it) { for (IntIterator it = mInt.begin(); it != mInt.end(); ++it) {
mSharedInt.push_back(&(*it)); mSharedInt.push_back(&(it->second));
} }
std::sort(mExt.begin(), mExt.end(), ExtCmp()); //std::sort(mExt.begin(), mExt.end(), ExtCmp());
mSharedExt.reserve(mExt.size()); mSharedExt.reserve(mExt.size());
for (Iterator it = mExt.begin(); it != mExt.end(); ++it) { for (ExtIterator it = mExt.begin(); it != mExt.end(); ++it) {
mSharedExt.push_back(&(*it)); mSharedExt.push_back(&(it->second));
} }
} }
@ -497,14 +496,13 @@ namespace MWWorld
// have new cell replace old cell // have new cell replace old cell
*oldcell = *cell; *oldcell = *cell;
} else } else
mInt.push_back(*cell); mInt[cell->mName] = *cell;
delete cell; delete cell;
} }
else else
{ {
// Store exterior cells by grid position, try to merge with existing parent data. // Store exterior cells by grid position, try to merge with existing parent data.
ESM::Cell *oldcell = const_cast<ESM::Cell*>(search(cell->getGridX(), cell->getGridY())); ESM::Cell *oldcell = const_cast<ESM::Cell*>(search(cell->getGridX(), cell->getGridY()));
std::cout << "setup - " << oldcell << " " << cell->getGridX() << " " << cell->getGridY() << std::endl;
if (oldcell) { if (oldcell) {
// push the new references on the list of references to manage // push the new references on the list of references to manage
oldcell->mContextList.push_back(cell->mContextList.at(0)); oldcell->mContextList.push_back(cell->mContextList.at(0));
@ -513,7 +511,7 @@ namespace MWWorld
// have new cell replace old cell // have new cell replace old cell
*oldcell = *cell; *oldcell = *cell;
} else } else
mExt.push_back(*cell); mExt[std::make_pair(cell->mData.mX, cell->mData.mY)] = *cell;
delete cell; delete cell;
} }
} }

@ -201,7 +201,6 @@ bool Cell::getNextRef(ESMReader &esm, CellRef &ref)
ref.mRefnum &= 0x00ffffff; // delete old plugin ID ref.mRefnum &= 0x00ffffff; // delete old plugin ID
const ESM::ESMReader::MasterList &masters = esm.getMasters(); const ESM::ESMReader::MasterList &masters = esm.getMasters();
global = masters[local-1].index + 1; global = masters[local-1].index + 1;
std::cout << "moved ref: " << local << " " << global << std::endl;
ref.mRefnum |= global << 24; // insert global plugin ID ref.mRefnum |= global << 24; // insert global plugin ID
} }
else else

Loading…
Cancel
Save