1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-05-25 07:41:29 +00:00

Catch exceptions thrown during reference loading (Bug #3238)

This commit is contained in:
scrawl 2016-03-07 21:28:50 +01:00
parent b139ad56b7
commit d0aba0d9ee

View file

@ -463,27 +463,34 @@ 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++)
{ {
// Reopen the ESM reader and seek to the right position. try
int index = mCell->mContextList.at(i).index;
mCell->restore (esm[index], i);
ESM::CellRef ref;
// Get each reference in turn
bool deleted = false;
while (mCell->getNextRef (esm[index], ref, deleted))
{ {
if (deleted) // Reopen the ESM reader and seek to the right position.
continue; int index = mCell->mContextList.at(i).index;
mCell->restore (esm[index], i);
// Don't list reference if it was moved to a different cell. ESM::CellRef ref;
ESM::MovedCellRefTracker::const_iterator iter =
std::find(mCell->mMovedRefs.begin(), mCell->mMovedRefs.end(), ref.mRefNum); // Get each reference in turn
if (iter != mCell->mMovedRefs.end()) { bool deleted = false;
continue; while (mCell->getNextRef (esm[index], ref, deleted))
{
if (deleted)
continue;
// Don't list reference if it was moved to a different cell.
ESM::MovedCellRefTracker::const_iterator iter =
std::find(mCell->mMovedRefs.begin(), mCell->mMovedRefs.end(), ref.mRefNum);
if (iter != mCell->mMovedRefs.end()) {
continue;
}
mIds.push_back (Misc::StringUtils::lowerCase (ref.mRefID));
} }
}
mIds.push_back (Misc::StringUtils::lowerCase (ref.mRefID)); catch (std::exception& e)
{
std::cerr << "An error occured listing references for cell " << getCell()->getDescription() << ": " << e.what() << std::endl;
} }
} }
@ -510,25 +517,32 @@ 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++)
{ {
// Reopen the ESM reader and seek to the right position. try
int index = mCell->mContextList.at(i).index;
mCell->restore (esm[index], i);
ESM::CellRef ref;
ref.mRefNum.mContentFile = ESM::RefNum::RefNum_NoContentFile;
// Get each reference in turn
bool deleted = false;
while(mCell->getNextRef(esm[index], ref, deleted))
{ {
// Don't load reference if it was moved to a different cell. // Reopen the ESM reader and seek to the right position.
ESM::MovedCellRefTracker::const_iterator iter = int index = mCell->mContextList.at(i).index;
std::find(mCell->mMovedRefs.begin(), mCell->mMovedRefs.end(), ref.mRefNum); mCell->restore (esm[index], i);
if (iter != mCell->mMovedRefs.end()) {
continue;
}
loadRef (ref, deleted); ESM::CellRef ref;
ref.mRefNum.mContentFile = ESM::RefNum::RefNum_NoContentFile;
// Get each reference in turn
bool deleted = false;
while(mCell->getNextRef(esm[index], ref, deleted))
{
// Don't load reference if it was moved to a different cell.
ESM::MovedCellRefTracker::const_iterator iter =
std::find(mCell->mMovedRefs.begin(), mCell->mMovedRefs.end(), ref.mRefNum);
if (iter != mCell->mMovedRefs.end()) {
continue;
}
loadRef (ref, deleted);
}
}
catch (std::exception& e)
{
std::cerr << "An error occured loading references for cell " << getCell()->getDescription() << ": " << e.what() << std::endl;
} }
} }