1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-20 07:23:51 +00:00

Avoid using getPtr for object search in scripting (bug #5220)

This commit is contained in:
Capostrophic 2019-12-01 14:00:24 +03:00
parent eacc185534
commit e7f6ab1ae2
3 changed files with 13 additions and 7 deletions

View file

@ -178,6 +178,7 @@
Bug #5211: Screen fades in if the first loaded save is in interior cell Bug #5211: Screen fades in if the first loaded save is in interior cell
Bug #5213: SameFaction script function is broken Bug #5213: SameFaction script function is broken
Bug #5218: Crash when disabling ToggleBorders Bug #5218: Crash when disabling ToggleBorders
Bug #5220: GetLOS crashes when actor isn't loaded
Feature #1774: Handle AvoidNode Feature #1774: Handle AvoidNode
Feature #2229: Improve pathfinding AI Feature #2229: Improve pathfinding AI
Feature #3025: Analogue gamepad movement controls Feature #3025: Analogue gamepad movement controls

View file

@ -382,9 +382,11 @@ namespace MWScript
std::string actorID = runtime.getStringLiteral (runtime[0].mInteger); std::string actorID = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop(); runtime.pop();
MWWorld::Ptr actor = MWBase::Environment::get().getWorld()->getPtr(actorID, true); MWWorld::Ptr actor = MWBase::Environment::get().getWorld()->searchPtr(actorID, true, false);
Interpreter::Type_Integer value = MWBase::Environment::get().getMechanicsManager()->isActorDetected(actor, observer); Interpreter::Type_Integer value = 0;
if (!actor.isEmpty())
value = MWBase::Environment::get().getMechanicsManager()->isActorDetected(actor, observer);
runtime.push (value); runtime.push (value);
} }
@ -404,9 +406,9 @@ namespace MWScript
runtime.pop(); runtime.pop();
MWWorld::Ptr dest = MWBase::Environment::get().getWorld()->getPtr(actorID,true); MWWorld::Ptr dest = MWBase::Environment::get().getWorld()->searchPtr(actorID, true, false);
bool value = false; bool value = false;
if(dest != MWWorld::Ptr() && source.getClass().isActor() && dest.getClass().isActor()) if (!dest.isEmpty() && source.getClass().isActor() && dest.getClass().isActor())
{ {
value = MWBase::Environment::get().getWorld()->getLOS(source,dest); value = MWBase::Environment::get().getWorld()->getLOS(source,dest);
} }
@ -447,7 +449,8 @@ namespace MWScript
std::string targetID = runtime.getStringLiteral (runtime[0].mInteger); std::string targetID = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop(); runtime.pop();
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->getPtr(targetID, true); MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtr(targetID, true, false);
if (!target.isEmpty())
MWBase::Environment::get().getMechanicsManager()->startCombat(actor, target); MWBase::Environment::get().getMechanicsManager()->startCombat(actor, target);
} }
}; };

View file

@ -1129,7 +1129,9 @@ namespace MWScript
return; return;
} }
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->getPtr (targetId, false); MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtr(targetId, false, false);
if (target.isEmpty())
return;
MWMechanics::CastSpell cast(ptr, target, false, true); MWMechanics::CastSpell cast(ptr, target, false, true);
cast.playSpellCastingEffects(spell->mId, false); cast.playSpellCastingEffects(spell->mId, false);