Exception handling improvements (Bug #3090)

openmw-38
scrawl 9 years ago
parent 2fe2f53b02
commit 1c8244276d

@ -34,7 +34,7 @@ namespace MWMechanics
MWBase::Environment::get().getWorld()->spawnEffect("meshes\\" + fx->mModel, MWBase::Environment::get().getWorld()->spawnEffect("meshes\\" + fx->mModel,
"", ptr.getRefData().getPosition().asVec3()); "", ptr.getRefData().getPosition().asVec3());
} }
else else if (creatureActorId != -1)
{ {
// We didn't find the creature. It's probably in an inactive cell. // We didn't find the creature. It's probably in an inactive cell.
// Add to graveyard so we can delete it when the cell becomes active. // Add to graveyard so we can delete it when the cell becomes active.
@ -132,6 +132,9 @@ namespace MWMechanics
if (!creatureID.empty()) if (!creatureID.empty())
{ {
MWWorld::CellStore* store = mActor.getCell(); MWWorld::CellStore* store = mActor.getCell();
int creatureActorId = -1;
try
{
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), creatureID, 1); MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), creatureID, 1);
ref.getPtr().getCellRef().setPosition(ipos); ref.getPtr().getCellRef().setPosition(ipos);
@ -140,7 +143,7 @@ namespace MWMechanics
// Make the summoned creature follow its master and help in fights // Make the summoned creature follow its master and help in fights
AiFollow package(mActor.getCellRef().getRefId()); AiFollow package(mActor.getCellRef().getRefId());
summonedCreatureStats.getAiSequence().stack(package, ref.getPtr()); summonedCreatureStats.getAiSequence().stack(package, ref.getPtr());
int creatureActorId = summonedCreatureStats.getActorId(); creatureActorId = summonedCreatureStats.getActorId();
MWWorld::Ptr placed = MWBase::Environment::get().getWorld()->safePlaceObject(ref.getPtr(),store,ipos); MWWorld::Ptr placed = MWBase::Environment::get().getWorld()->safePlaceObject(ref.getPtr(),store,ipos);
@ -152,6 +155,12 @@ namespace MWMechanics
if (fx) if (fx)
anim->addEffect("meshes\\" + fx->mModel, -1, false); anim->addEffect("meshes\\" + fx->mModel, -1, false);
} }
}
catch (std::exception& e)
{
std::cerr << "Failed to spawn summoned creature: " << e.what() << std::endl;
// still insert into creatureMap so we don't try to spawn again every frame, that would spam the warning log
}
creatureMap.insert(std::make_pair(*it, creatureActorId)); creatureMap.insert(std::make_pair(*it, creatureActorId));
} }

@ -518,8 +518,17 @@ namespace MWRender
} }
if (mTextKeyListener) if (mTextKeyListener)
{
try
{
mTextKeyListener->handleTextKey(groupname, key, map); mTextKeyListener->handleTextKey(groupname, key, map);
} }
catch (std::exception& e)
{
std::cerr << "Error handling text key " << evt << ": " << e.what() << std::endl;
}
}
}
void Animation::play(const std::string &groupname, const AnimPriority& priority, int blendMask, bool autodisable, float speedmult, void Animation::play(const std::string &groupname, const AnimPriority& priority, int blendMask, bool autodisable, float speedmult,
const std::string &start, const std::string &stop, float startpoint, size_t loops, bool loopfallback) const std::string &start, const std::string &stop, float startpoint, size_t loops, bool loopfallback)

Loading…
Cancel
Save