mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 13:15:34 +00:00
Log caught exceptions
This commit is contained in:
parent
62930cb8db
commit
71369be796
15 changed files with 94 additions and 80 deletions
|
@ -511,8 +511,10 @@ namespace MWRender
|
||||||
refs[ref.mRefNum] = std::move(ref);
|
refs[ref.mRefNum] = std::move(ref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception&)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
|
Log(Debug::Warning) << "Failed to collect references from cell \"" << cell->getDescription()
|
||||||
|
<< "\": " << e.what();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -290,9 +290,9 @@ namespace MWRender
|
||||||
for (std::vector<std::string>::const_iterator it = mKeyframes.begin(); it != mKeyframes.end(); ++it)
|
for (std::vector<std::string>::const_iterator it = mKeyframes.begin(); it != mKeyframes.end(); ++it)
|
||||||
mResourceSystem->getKeyframeManager()->get(*it);
|
mResourceSystem->getKeyframeManager()->get(*it);
|
||||||
}
|
}
|
||||||
catch (std::exception&)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
// ignore error (will be shown when these are needed proper)
|
Log(Debug::Warning) << "Failed to preload common assets: " << e.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -610,9 +610,9 @@ namespace MWSound
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception&)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
Log(Debug::Error) << "Error updating stream \"" << mDecoder->getName() << "\"";
|
Log(Debug::Error) << "Error updating stream \"" << mDecoder->getName() << "\": " << e.what();
|
||||||
mIsFinished = true;
|
mIsFinished = true;
|
||||||
}
|
}
|
||||||
return !mIsFinished;
|
return !mIsFinished;
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include <components/debug/debuglog.hpp>
|
||||||
#include <components/esm/defs.hpp>
|
#include <components/esm/defs.hpp>
|
||||||
#include <components/esm3/esmreader.hpp>
|
#include <components/esm3/esmreader.hpp>
|
||||||
#include <components/misc/utf8stream.hpp>
|
|
||||||
|
|
||||||
#include <components/misc/strings/algorithm.hpp>
|
#include <components/misc/strings/algorithm.hpp>
|
||||||
|
#include <components/misc/utf8stream.hpp>
|
||||||
|
|
||||||
bool MWState::operator<(const Slot& left, const Slot& right)
|
bool MWState::operator<(const Slot& left, const Slot& right)
|
||||||
{
|
{
|
||||||
|
@ -99,9 +99,11 @@ MWState::Character::Character(const std::filesystem::path& saves, const std::str
|
||||||
{
|
{
|
||||||
addSlot(iter, game);
|
addSlot(iter, game);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
} // ignoring bad saved game files for now
|
Log(Debug::Warning) << "Failed to add slot for game \"" << game << "\" save " << iter << ": "
|
||||||
|
<< e.what();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort(mSlots.begin(), mSlots.end());
|
std::sort(mSlots.begin(), mSlots.end());
|
||||||
|
|
|
@ -103,17 +103,4 @@ namespace MWWorld
|
||||||
else
|
else
|
||||||
mGridPos = {};
|
mGridPos = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
ESM::RefId Cell::getWorldSpace() const
|
|
||||||
{
|
|
||||||
if (isExterior())
|
|
||||||
return mParent;
|
|
||||||
else
|
|
||||||
return mId;
|
|
||||||
}
|
|
||||||
|
|
||||||
ESM::ExteriorCellLocation Cell::getExteriorCellLocation() const
|
|
||||||
{
|
|
||||||
return { mGridPos.x(), mGridPos.y(), getWorldSpace() };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,8 +48,12 @@ namespace MWWorld
|
||||||
const MoodData& getMood() const { return mMood; }
|
const MoodData& getMood() const { return mMood; }
|
||||||
float getWaterHeight() const { return mWaterHeight; }
|
float getWaterHeight() const { return mWaterHeight; }
|
||||||
const ESM::RefId& getId() const { return mId; }
|
const ESM::RefId& getId() const { return mId; }
|
||||||
ESM::RefId getWorldSpace() const;
|
ESM::RefId getWorldSpace() const { return mIsExterior ? mParent : mId; }
|
||||||
ESM::ExteriorCellLocation getExteriorCellLocation() const;
|
|
||||||
|
ESM::ExteriorCellLocation getExteriorCellLocation() const
|
||||||
|
{
|
||||||
|
return ESM::ExteriorCellLocation(mGridPos.x(), mGridPos.y(), getWorldSpace());
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool mIsExterior;
|
bool mIsExterior;
|
||||||
|
|
|
@ -66,12 +66,12 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Constructor to be called from the main thread.
|
/// Constructor to be called from the main thread.
|
||||||
PreloadItem(MWWorld::CellStore* cell, Resource::SceneManager* sceneManager,
|
explicit PreloadItem(MWWorld::CellStore* cell, Resource::SceneManager* sceneManager,
|
||||||
Resource::BulletShapeManager* bulletShapeManager, Resource::KeyframeManager* keyframeManager,
|
Resource::BulletShapeManager* bulletShapeManager, Resource::KeyframeManager* keyframeManager,
|
||||||
Terrain::World* terrain, MWRender::LandManager* landManager, bool preloadInstances)
|
Terrain::World* terrain, MWRender::LandManager* landManager, bool preloadInstances)
|
||||||
: mIsExterior(cell->getCell()->isExterior())
|
: mIsExterior(cell->getCell()->isExterior())
|
||||||
, mX(cell->getCell()->getGridX())
|
, mCellLocation(cell->getCell()->getExteriorCellLocation())
|
||||||
, mY(cell->getCell()->getGridY())
|
, mCellId(cell->getCell()->getId())
|
||||||
, mSceneManager(sceneManager)
|
, mSceneManager(sceneManager)
|
||||||
, mBulletShapeManager(bulletShapeManager)
|
, mBulletShapeManager(bulletShapeManager)
|
||||||
, mKeyframeManager(keyframeManager)
|
, mKeyframeManager(keyframeManager)
|
||||||
|
@ -95,12 +95,13 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mTerrain->cacheCell(mTerrainView.get(), mX, mY);
|
mTerrain->cacheCell(mTerrainView.get(), mCellLocation.mX, mCellLocation.mY);
|
||||||
mPreloadedObjects.insert(
|
mPreloadedObjects.insert(mLandManager->getLand(mCellLocation));
|
||||||
mLandManager->getLand(ESM::ExteriorCellLocation(mX, mY, ESM::Cell::sDefaultWorldspaceId)));
|
|
||||||
}
|
}
|
||||||
catch (std::exception&)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
|
Log(Debug::Warning) << "Failed to cache terrain for exterior cell " << mCellLocation << ": "
|
||||||
|
<< e.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,8 +114,12 @@ namespace MWWorld
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
const VFS::Manager& vfs = *mSceneManager->getVFS();
|
||||||
mesh = Misc::ResourceHelpers::correctMeshPath(path);
|
mesh = Misc::ResourceHelpers::correctMeshPath(path);
|
||||||
mesh = Misc::ResourceHelpers::correctActorModelPath(mesh, mSceneManager->getVFS());
|
mesh = Misc::ResourceHelpers::correctActorModelPath(mesh, &vfs);
|
||||||
|
|
||||||
|
if (!vfs.exists(mesh))
|
||||||
|
continue;
|
||||||
|
|
||||||
size_t slashpos = mesh.find_last_of("/\\");
|
size_t slashpos = mesh.find_last_of("/\\");
|
||||||
if (slashpos != std::string::npos && slashpos != mesh.size() - 1)
|
if (slashpos != std::string::npos && slashpos != mesh.size() - 1)
|
||||||
|
@ -124,7 +129,7 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
kfname = mesh;
|
kfname = mesh;
|
||||||
kfname.replace(kfname.size() - 4, 4, ".kf");
|
kfname.replace(kfname.size() - 4, 4, ".kf");
|
||||||
if (mSceneManager->getVFS()->exists(kfname))
|
if (vfs.exists(kfname))
|
||||||
mPreloadedObjects.insert(mKeyframeManager->get(kfname));
|
mPreloadedObjects.insert(mKeyframeManager->get(kfname));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,18 +139,18 @@ namespace MWWorld
|
||||||
else
|
else
|
||||||
mPreloadedObjects.insert(mBulletShapeManager->getShape(mesh));
|
mPreloadedObjects.insert(mBulletShapeManager->getShape(mesh));
|
||||||
}
|
}
|
||||||
catch (std::exception&)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
// ignore error for now, would spam the log too much
|
Log(Debug::Warning) << "Failed to preload mesh \"" << path << "\" from cell " << mCellId << ": "
|
||||||
// error will be shown when visiting the cell
|
<< e.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool mIsExterior;
|
bool mIsExterior;
|
||||||
int mX;
|
ESM::ExteriorCellLocation mCellLocation;
|
||||||
int mY;
|
ESM::RefId mCellId;
|
||||||
std::vector<std::string_view> mMeshes;
|
std::vector<std::string_view> mMeshes;
|
||||||
Resource::SceneManager* mSceneManager;
|
Resource::SceneManager* mSceneManager;
|
||||||
Resource::BulletShapeManager* mBulletShapeManager;
|
Resource::BulletShapeManager* mBulletShapeManager;
|
||||||
|
|
|
@ -705,8 +705,10 @@ namespace MWWorld
|
||||||
state.mProjectileId
|
state.mProjectileId
|
||||||
= mPhysics->addProjectile(state.getCaster(), osg::Vec3f(esm.mPosition), model, false);
|
= mPhysics->addProjectile(state.getCaster(), osg::Vec3f(esm.mPosition), model, false);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
|
Log(Debug::Warning) << "Failed to add projectile for " << esm.mId
|
||||||
|
<< " while reading projectile record: " << e.what();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -734,10 +736,10 @@ namespace MWWorld
|
||||||
state.mEffects = getMagicBoltData(
|
state.mEffects = getMagicBoltData(
|
||||||
state.mIdMagic, state.mSoundIds, state.mSpeed, texture, state.mSourceName, state.mSpellId);
|
state.mIdMagic, state.mSoundIds, state.mSpeed, texture, state.mSourceName, state.mSpellId);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
Log(Debug::Warning) << "Warning: Failed to recreate magic projectile from saved data (id \""
|
Log(Debug::Warning) << "Failed to recreate magic projectile for " << esm.mId << " and spell "
|
||||||
<< state.mSpellId << "\" no longer exists?)";
|
<< state.mSpellId << " while reading projectile record: " << e.what();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -753,8 +755,10 @@ namespace MWWorld
|
||||||
MWWorld::Ptr ptr = ref.getPtr();
|
MWWorld::Ptr ptr = ref.getPtr();
|
||||||
model = ptr.getClass().getCorrectedModel(ptr);
|
model = ptr.getClass().getCorrectedModel(ptr);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
|
Log(Debug::Warning) << "Failed to get model for " << state.mIdMagic.at(0)
|
||||||
|
<< " while reading projectile record: " << e.what();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,21 +6,6 @@
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
|
|
||||||
std::string Ptr::toString() const
|
|
||||||
{
|
|
||||||
std::string res = "object";
|
|
||||||
if (mRef->isDeleted())
|
|
||||||
res = "deleted object";
|
|
||||||
res.append(getCellRef().getRefNum().toString());
|
|
||||||
res.append(" (");
|
|
||||||
res.append(getTypeDescription());
|
|
||||||
res.append(", ");
|
|
||||||
res.append(getCellRef().getRefId().toDebugString());
|
|
||||||
res.append(")");
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
SafePtr::SafePtr(const Ptr& ptr)
|
SafePtr::SafePtr(const Ptr& ptr)
|
||||||
: mId(ptr.getCellRef().getRefNum())
|
: mId(ptr.getCellRef().getRefNum())
|
||||||
, mPtr(ptr)
|
, mPtr(ptr)
|
||||||
|
|
|
@ -98,6 +98,20 @@ namespace MWWorld
|
||||||
return mContainerStore;
|
return mContainerStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string toString() const
|
||||||
|
{
|
||||||
|
if (mRef == nullptr)
|
||||||
|
return "null object";
|
||||||
|
std::string result = mRef->isDeleted() ? "object" : "deleted object";
|
||||||
|
result += mRef->mRef.getRefNum().toString();
|
||||||
|
result += " (";
|
||||||
|
result += mRef->getTypeDescription();
|
||||||
|
result += ", ";
|
||||||
|
result += mRef->mRef.getRefId().toDebugString();
|
||||||
|
result += ")";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
template <template <class> class TypeTransform2>
|
template <template <class> class TypeTransform2>
|
||||||
bool operator==(const PtrBase<TypeTransform2>& other) const
|
bool operator==(const PtrBase<TypeTransform2>& other) const
|
||||||
{
|
{
|
||||||
|
@ -128,8 +142,6 @@ namespace MWWorld
|
||||||
: PtrBase(liveCellRef, cell, nullptr)
|
: PtrBase(liveCellRef, cell, nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string toString() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @note The difference between Ptr and ConstPtr is that the second one adds const to the underlying pointers.
|
/// @note The difference between Ptr and ConstPtr is that the second one adds const to the underlying pointers.
|
||||||
|
|
|
@ -1109,8 +1109,9 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
mSceneManager->getTemplate(mMesh);
|
mSceneManager->getTemplate(mMesh);
|
||||||
}
|
}
|
||||||
catch (std::exception&)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
|
Log(Debug::Warning) << "Failed to get mesh template \"" << mMesh << "\" to preload: " << e.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1198,9 +1199,10 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
preloadCellWithSurroundings(mWorld.getWorldModel().getCell(door.getCellRef().getDestCell()));
|
preloadCellWithSurroundings(mWorld.getWorldModel().getCell(door.getCellRef().getDestCell()));
|
||||||
}
|
}
|
||||||
catch (std::exception&)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
// ignore error for now, would spam the log too much
|
Log(Debug::Warning) << "Failed to schedule preload for door " << door.toString() << ": "
|
||||||
|
<< e.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3363,9 +3363,10 @@ namespace MWWorld
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const std::exception&)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
// Ignore invalid item id
|
Log(Debug::Warning)
|
||||||
|
<< "Failed to process container item " << containerItem.mItem << ": " << e.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3692,19 +3693,23 @@ namespace MWWorld
|
||||||
return (targetPos - weaponPos);
|
return (targetPos - weaponPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void preload(MWWorld::Scene* scene, const ESMStore& store, const ESM::RefId& obj)
|
namespace
|
||||||
{
|
{
|
||||||
if (obj.empty())
|
void preload(MWWorld::Scene* scene, const ESMStore& store, const ESM::RefId& obj)
|
||||||
return;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
MWWorld::ManualRef ref(store, obj);
|
|
||||||
std::string model = ref.getPtr().getClass().getCorrectedModel(ref.getPtr());
|
|
||||||
if (!model.empty())
|
|
||||||
scene->preload(model, ref.getPtr().getClass().useAnim());
|
|
||||||
}
|
|
||||||
catch (std::exception&)
|
|
||||||
{
|
{
|
||||||
|
if (obj.empty())
|
||||||
|
return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MWWorld::ManualRef ref(store, obj);
|
||||||
|
std::string model = ref.getPtr().getClass().getCorrectedModel(ref.getPtr());
|
||||||
|
if (!model.empty())
|
||||||
|
scene->preload(model, ref.getPtr().getClass().useAnim());
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
Log(Debug::Warning) << "Failed to preload scene object " << obj << ": " << e.what();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include <components/esm3/loadcell.hpp>
|
#include <components/esm3/loadcell.hpp>
|
||||||
|
|
||||||
|
#include <ostream>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
namespace ESM
|
namespace ESM
|
||||||
|
@ -30,6 +31,11 @@ namespace ESM
|
||||||
{
|
{
|
||||||
return std::make_tuple(lhs.mX, lhs.mY, lhs.mWorldspace) < std::make_tuple(rhs.mX, rhs.mY, rhs.mWorldspace);
|
return std::make_tuple(lhs.mX, lhs.mY, lhs.mWorldspace) < std::make_tuple(rhs.mX, rhs.mY, rhs.mWorldspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
friend inline std::ostream& operator<<(std::ostream& stream, const ExteriorCellLocation& value)
|
||||||
|
{
|
||||||
|
return stream << "{" << value.mX << ", " << value.mY << ", " << value.mWorldspace << "}";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,9 +154,9 @@ namespace Resource
|
||||||
mTarget.mTextKeys.emplace(parseTimeSignature(line), parseTextKey(line));
|
mTarget.mTextKeys.emplace(parseTimeSignature(line), parseTextKey(line));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception&)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
Log(Debug::Warning) << "No textkey file found for " << mNormalized;
|
Log(Debug::Warning) << "Failed to use textkey file " << mNormalized << ": " << e.what();
|
||||||
}
|
}
|
||||||
|
|
||||||
callback->setEmulatedAnimations(emulatedAnimations);
|
callback->setEmulatedAnimations(emulatedAnimations);
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace VFS
|
||||||
assert(Path::isNormalized(normalizedName));
|
assert(Path::isNormalized(normalizedName));
|
||||||
const auto found = mIndex.find(normalizedName);
|
const auto found = mIndex.find(normalizedName);
|
||||||
if (found == mIndex.end())
|
if (found == mIndex.end())
|
||||||
throw std::runtime_error("Resource '" + std::string(normalizedName) + "' not found");
|
throw std::runtime_error("Resource '" + std::string(normalizedName) + "' is not found");
|
||||||
return found->second->open();
|
return found->second->open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ namespace VFS
|
||||||
|
|
||||||
const auto found = mIndex.find(normalized);
|
const auto found = mIndex.find(normalized);
|
||||||
if (found == mIndex.end())
|
if (found == mIndex.end())
|
||||||
throw std::runtime_error("Resource '" + normalized + "' not found");
|
throw std::runtime_error("Resource '" + normalized + "' is not found");
|
||||||
return found->second->getPath();
|
return found->second->getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue