mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 07:53:51 +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 #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 #5416: Junk non-node records before the root node are not handled gracefully
|
||||||
Bug #5424: Creatures do not headtrack player
|
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
|
Feature #5362: Show the soul gems' trapped soul in count dialog
|
||||||
|
|
||||||
0.46.0
|
0.46.0
|
||||||
|
|
|
@ -46,10 +46,10 @@ namespace MWScript
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
|
MWWorld::Ptr from = R()(runtime);
|
||||||
std::string name = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string name = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Ptr from = R()(runtime);
|
|
||||||
if (from.getContainerStore()) // is the object contained?
|
if (from.getContainerStore()) // is the object contained?
|
||||||
{
|
{
|
||||||
MWWorld::Ptr container = MWBase::Environment::get().getWorld()->findContainer(from);
|
MWWorld::Ptr container = MWBase::Environment::get().getWorld()->findContainer(from);
|
||||||
|
@ -57,10 +57,24 @@ namespace MWScript
|
||||||
if (!container.isEmpty())
|
if (!container.isEmpty())
|
||||||
from = container;
|
from = container;
|
||||||
else
|
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;
|
float distance;
|
||||||
// If the objects are in different worldspaces, return a large value (just like vanilla)
|
// 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);
|
Ptr ret = searchPtr(name, activeOnly);
|
||||||
if (!ret.isEmpty())
|
if (!ret.isEmpty())
|
||||||
return ret;
|
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)
|
Ptr World::searchPtrViaActorId (int actorId)
|
||||||
|
|
Loading…
Reference in a new issue