Do not create range query with no enemies
Do not create range query with no enemies as that triggers warning in
range manager.
This situation occurs when player has no enemies so empty list is
returned.
Fixing CCmpRangeManager: No owners in query for entity 0 warning
refs 38b2e37a61
Differential Revision: https://code.wildfiregames.com/D2601
Fixes: #5666
Reviewed by: @Freagarach
This was SVN commit r23467.
This commit is contained in:
parent
074dff2c91
commit
083a5947e6
@ -3581,7 +3581,10 @@ UnitAI.prototype.SetupRangeQuery = function(enable = true)
|
||||
|
||||
// Exclude allies, and self
|
||||
// TODO: How to handle neutral players - Special query to attack military only?
|
||||
var players = cmpPlayer.GetEnemies();
|
||||
let players = cmpPlayer.GetEnemies();
|
||||
if (!players.length)
|
||||
return;
|
||||
|
||||
var range = this.GetQueryRange(IID_Attack);
|
||||
|
||||
this.losRangeQuery = cmpRangeManager.CreateActiveQuery(this.entity, range.min, range.max, players, IID_Resistance, cmpRangeManager.GetEntityFlagMask("normal"));
|
||||
|
@ -61,7 +61,7 @@ function TestFormationExiting(mode)
|
||||
AddMock(playerEntity, IID_Player, {
|
||||
IsAlly: function() { return false; },
|
||||
IsEnemy: function() { return true; },
|
||||
GetEnemies: function() { return []; },
|
||||
GetEnemies: function() { return [2]; },
|
||||
});
|
||||
|
||||
AddMock(SYSTEM_ENTITY, IID_ObstructionManager, {
|
||||
@ -219,7 +219,7 @@ function TestMoveIntoFormationWhileAttacking()
|
||||
AddMock(playerEntity, IID_Player, {
|
||||
IsAlly: function() { return false; },
|
||||
IsEnemy: function() { return true; },
|
||||
GetEnemies: function() { return []; },
|
||||
GetEnemies: function() { return [2]; },
|
||||
});
|
||||
|
||||
// create units
|
||||
|
@ -303,7 +303,7 @@ Attacking.prototype.HandleAttackEffects = function(attackType, attackData, targe
|
||||
Attacking.prototype.EntitiesNearPoint = function(origin, radius, players)
|
||||
{
|
||||
// If there is insufficient data return an empty array.
|
||||
if (!origin || !radius || !players)
|
||||
if (!origin || !radius || !players || !players.length)
|
||||
return [];
|
||||
|
||||
let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
|
||||
@ -312,8 +312,12 @@ Attacking.prototype.EntitiesNearPoint = function(origin, radius, players)
|
||||
let gaiaEntities = [];
|
||||
let gaiaIndex = players.indexOf(0);
|
||||
if (gaiaIndex !== -1)
|
||||
{
|
||||
// splice() modifies players in-place and returns [0]
|
||||
gaiaEntities = gaiaEntities.concat(cmpRangeManager.ExecuteQueryAroundPos(origin, 0, radius, players.splice(gaiaIndex, 1), IID_Health));
|
||||
if (!players.length)
|
||||
return gaiaEntities;
|
||||
}
|
||||
|
||||
return cmpRangeManager.ExecuteQueryAroundPos(origin, 0, radius, players, 0).concat(gaiaEntities);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user