mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 16:15:31 +00:00
Improve GetDistance and object search warnings (bug #5427)
Allow GetDistance to work with a non-existent object argument or with inventory items that belong to a container store that doesn't exist
This commit is contained in:
parent
2618974ad6
commit
c9c9599ec5
3 changed files with 22 additions and 4 deletions
|
@ -17,6 +17,7 @@
|
|||
Bug #5415: Environment maps in ebony cuirass and HiRez Armors Indoril cuirass don't work
|
||||
Bug #5416: Junk non-node records before the root node are not handled gracefully
|
||||
Bug #5424: Creatures do not headtrack player
|
||||
Bug #5427: GetDistance unknown ID error is misleading
|
||||
Feature #5362: Show the soul gems' trapped soul in count dialog
|
||||
|
||||
0.46.0
|
||||
|
|
|
@ -46,10 +46,10 @@ namespace MWScript
|
|||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr from = R()(runtime);
|
||||
std::string name = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr from = R()(runtime);
|
||||
if (from.getContainerStore()) // is the object contained?
|
||||
{
|
||||
MWWorld::Ptr container = MWBase::Environment::get().getWorld()->findContainer(from);
|
||||
|
@ -57,10 +57,24 @@ namespace MWScript
|
|||
if (!container.isEmpty())
|
||||
from = container;
|
||||
else
|
||||
throw std::runtime_error("failed to find container ptr");
|
||||
{
|
||||
std::string error = "Failed to find the container of object '" + from.getCellRef().getRefId() + "'";
|
||||
runtime.getContext().report(error);
|
||||
Log(Debug::Error) << error;
|
||||
runtime.push(0.f);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const MWWorld::Ptr to = MWBase::Environment::get().getWorld()->getPtr(name, false);
|
||||
const MWWorld::Ptr to = MWBase::Environment::get().getWorld()->searchPtr(name, false);
|
||||
if (to.isEmpty())
|
||||
{
|
||||
std::string error = "Failed to find an instance of object '" + name + "'";
|
||||
runtime.getContext().report(error);
|
||||
Log(Debug::Error) << error;
|
||||
runtime.push(0.f);
|
||||
return;
|
||||
}
|
||||
|
||||
float distance;
|
||||
// If the objects are in different worldspaces, return a large value (just like vanilla)
|
||||
|
|
|
@ -741,7 +741,10 @@ namespace MWWorld
|
|||
Ptr ret = searchPtr(name, activeOnly);
|
||||
if (!ret.isEmpty())
|
||||
return ret;
|
||||
throw std::runtime_error ("unknown ID: " + name);
|
||||
std::string error = "failed to find an instance of object '" + name + "'";
|
||||
if (activeOnly)
|
||||
error += " in active cells";
|
||||
throw std::runtime_error(error);
|
||||
}
|
||||
|
||||
Ptr World::searchPtrViaActorId (int actorId)
|
||||
|
|
Loading…
Reference in a new issue