mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-29 17: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);
|
||||
}
|
||||
}
|
||||
catch (std::exception&)
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
Log(Debug::Warning) << "Failed to collect references from cell \"" << cell->getDescription()
|
||||
<< "\": " << e.what();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -290,9 +290,9 @@ namespace MWRender
|
|||
for (std::vector<std::string>::const_iterator it = mKeyframes.begin(); it != mKeyframes.end(); ++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;
|
||||
}
|
||||
return !mIsFinished;
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/esm/defs.hpp>
|
||||
#include <components/esm3/esmreader.hpp>
|
||||
#include <components/misc/utf8stream.hpp>
|
||||
|
||||
#include <components/misc/strings/algorithm.hpp>
|
||||
#include <components/misc/utf8stream.hpp>
|
||||
|
||||
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);
|
||||
}
|
||||
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());
|
||||
|
|
|
@ -103,17 +103,4 @@ namespace MWWorld
|
|||
else
|
||||
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; }
|
||||
float getWaterHeight() const { return mWaterHeight; }
|
||||
const ESM::RefId& getId() const { return mId; }
|
||||
ESM::RefId getWorldSpace() const;
|
||||
ESM::ExteriorCellLocation getExteriorCellLocation() const;
|
||||
ESM::RefId getWorldSpace() const { return mIsExterior ? mParent : mId; }
|
||||
|
||||
ESM::ExteriorCellLocation getExteriorCellLocation() const
|
||||
{
|
||||
return ESM::ExteriorCellLocation(mGridPos.x(), mGridPos.y(), getWorldSpace());
|
||||
}
|
||||
|
||||
private:
|
||||
bool mIsExterior;
|
||||
|
|
|
@ -66,12 +66,12 @@ namespace MWWorld
|
|||
{
|
||||
public:
|
||||
/// 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,
|
||||
Terrain::World* terrain, MWRender::LandManager* landManager, bool preloadInstances)
|
||||
: mIsExterior(cell->getCell()->isExterior())
|
||||
, mX(cell->getCell()->getGridX())
|
||||
, mY(cell->getCell()->getGridY())
|
||||
, mCellLocation(cell->getCell()->getExteriorCellLocation())
|
||||
, mCellId(cell->getCell()->getId())
|
||||
, mSceneManager(sceneManager)
|
||||
, mBulletShapeManager(bulletShapeManager)
|
||||
, mKeyframeManager(keyframeManager)
|
||||
|
@ -95,12 +95,13 @@ namespace MWWorld
|
|||
{
|
||||
try
|
||||
{
|
||||
mTerrain->cacheCell(mTerrainView.get(), mX, mY);
|
||||
mPreloadedObjects.insert(
|
||||
mLandManager->getLand(ESM::ExteriorCellLocation(mX, mY, ESM::Cell::sDefaultWorldspaceId)));
|
||||
mTerrain->cacheCell(mTerrainView.get(), mCellLocation.mX, mCellLocation.mY);
|
||||
mPreloadedObjects.insert(mLandManager->getLand(mCellLocation));
|
||||
}
|
||||
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
|
||||
{
|
||||
const VFS::Manager& vfs = *mSceneManager->getVFS();
|
||||
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("/\\");
|
||||
if (slashpos != std::string::npos && slashpos != mesh.size() - 1)
|
||||
|
@ -124,7 +129,7 @@ namespace MWWorld
|
|||
{
|
||||
kfname = mesh;
|
||||
kfname.replace(kfname.size() - 4, 4, ".kf");
|
||||
if (mSceneManager->getVFS()->exists(kfname))
|
||||
if (vfs.exists(kfname))
|
||||
mPreloadedObjects.insert(mKeyframeManager->get(kfname));
|
||||
}
|
||||
}
|
||||
|
@ -134,18 +139,18 @@ namespace MWWorld
|
|||
else
|
||||
mPreloadedObjects.insert(mBulletShapeManager->getShape(mesh));
|
||||
}
|
||||
catch (std::exception&)
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
// ignore error for now, would spam the log too much
|
||||
// error will be shown when visiting the cell
|
||||
Log(Debug::Warning) << "Failed to preload mesh \"" << path << "\" from cell " << mCellId << ": "
|
||||
<< e.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
bool mIsExterior;
|
||||
int mX;
|
||||
int mY;
|
||||
ESM::ExteriorCellLocation mCellLocation;
|
||||
ESM::RefId mCellId;
|
||||
std::vector<std::string_view> mMeshes;
|
||||
Resource::SceneManager* mSceneManager;
|
||||
Resource::BulletShapeManager* mBulletShapeManager;
|
||||
|
|
|
@ -705,8 +705,10 @@ namespace MWWorld
|
|||
state.mProjectileId
|
||||
= 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;
|
||||
}
|
||||
|
||||
|
@ -734,10 +736,10 @@ namespace MWWorld
|
|||
state.mEffects = getMagicBoltData(
|
||||
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 \""
|
||||
<< state.mSpellId << "\" no longer exists?)";
|
||||
Log(Debug::Warning) << "Failed to recreate magic projectile for " << esm.mId << " and spell "
|
||||
<< state.mSpellId << " while reading projectile record: " << e.what();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -753,8 +755,10 @@ namespace MWWorld
|
|||
MWWorld::Ptr ptr = ref.getPtr();
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,21 +6,6 @@
|
|||
|
||||
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)
|
||||
: mId(ptr.getCellRef().getRefNum())
|
||||
, mPtr(ptr)
|
||||
|
|
|
@ -98,6 +98,20 @@ namespace MWWorld
|
|||
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>
|
||||
bool operator==(const PtrBase<TypeTransform2>& other) const
|
||||
{
|
||||
|
@ -128,8 +142,6 @@ namespace MWWorld
|
|||
: 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.
|
||||
|
|
|
@ -1109,8 +1109,9 @@ namespace MWWorld
|
|||
{
|
||||
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()));
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
void preload(MWWorld::Scene* scene, const ESMStore& store, const ESM::RefId& obj)
|
||||
namespace
|
||||
{
|
||||
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 (std::exception&)
|
||||
void preload(MWWorld::Scene* scene, const ESMStore& store, const ESM::RefId& obj)
|
||||
{
|
||||
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 <ostream>
|
||||
#include <tuple>
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace VFS
|
|||
assert(Path::isNormalized(normalizedName));
|
||||
const auto found = mIndex.find(normalizedName);
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ namespace VFS
|
|||
|
||||
const auto found = mIndex.find(normalized);
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue