mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-07-04 05:55:47 -07:00
Fix checks for range existence following 6bc99c47e1
Function introduced in 6bc99c47e1, GetRange can return undefined when
required component does not exist. Fixing two oversights, when check is
needed.
Differential Revision: https://code.wildfiregames.com/D2608
Fixes: #5666
This was SVN commit r23471.
This commit is contained in:
parent
8def60082d
commit
39bfd15aca
1 changed files with 5 additions and 1 deletions
|
|
@ -4739,6 +4739,8 @@ UnitAI.prototype.FaceTowardsTarget = function(target)
|
|||
UnitAI.prototype.CheckTargetDistanceFromHeldPosition = function(target, iid, type)
|
||||
{
|
||||
let range = this.GetRange(iid, type);
|
||||
if (!range)
|
||||
return false;
|
||||
|
||||
let cmpPosition = Engine.QueryInterface(target, IID_Position);
|
||||
if (!cmpPosition || !cmpPosition.IsInWorld())
|
||||
|
|
@ -5809,6 +5811,8 @@ UnitAI.prototype.GetQueryRange = function(iid)
|
|||
else if (this.GetStance().respondHoldGround)
|
||||
{
|
||||
let range = this.GetRange(iid);
|
||||
if (!range)
|
||||
return ret;
|
||||
ret.max = Math.min(range.max + visionRange / 2, visionRange);
|
||||
}
|
||||
// We probably have stance 'passive' and we wouldn't have a range,
|
||||
|
|
@ -5912,7 +5916,7 @@ UnitAI.prototype.GetRange = function(iid, type)
|
|||
{
|
||||
let component = Engine.QueryInterface(this.entity, iid);
|
||||
if (!component)
|
||||
return;
|
||||
return undefined;
|
||||
|
||||
return component.GetRange(type);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue