mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-20 23:44:08 +00:00
Handle empty Auras reference in checkrefs
This commit is contained in:
@@ -84,14 +84,9 @@ Auras.prototype.GetRangeOverlays = function()
|
||||
{
|
||||
const rangeOverlays = [];
|
||||
|
||||
// Check if this is a preview entity
|
||||
const cmpVisibility = Engine.QueryInterface(this.entity, IID_Visibility);
|
||||
const isPreview = cmpVisibility && cmpVisibility.GetPreview && cmpVisibility.GetPreview();
|
||||
|
||||
for (const name of this.GetAuraNames())
|
||||
{
|
||||
// For preview entities, show auras even if isApplied is false
|
||||
if (!this.IsRangeAura(name) || (!isPreview && !this[name].isApplied))
|
||||
if (!this.IsRangeAura(name) || !this.AreTechnologyRequirementsMet(name))
|
||||
continue;
|
||||
|
||||
const rangeOverlay = AuraTemplates.Get(name).rangeOverlay;
|
||||
@@ -144,22 +139,27 @@ Auras.prototype.CalculateAffectedPlayers = function(name)
|
||||
}
|
||||
};
|
||||
|
||||
Auras.prototype.CanApply = function(name)
|
||||
Auras.prototype.AreTechnologyRequirementsMet = function(name)
|
||||
{
|
||||
// Check if this is a preview entity via Visibility component
|
||||
// If it is, then we don't apply the aura
|
||||
const cmpVisibility = Engine.QueryInterface(this.entity, IID_Visibility);
|
||||
if (cmpVisibility && cmpVisibility.GetPreview && cmpVisibility.GetPreview())
|
||||
return false;
|
||||
|
||||
if (!AuraTemplates.Get(name).requiredTechnology)
|
||||
const aura = AuraTemplates.Get(name);
|
||||
if (!aura || !aura.requiredTechnology)
|
||||
return true;
|
||||
|
||||
const cmpTechnologyManager = QueryOwnerInterface(this.entity, IID_TechnologyManager);
|
||||
if (!cmpTechnologyManager)
|
||||
return false;
|
||||
|
||||
return cmpTechnologyManager.IsTechnologyResearched(AuraTemplates.Get(name).requiredTechnology);
|
||||
return cmpTechnologyManager.IsTechnologyResearched(aura.requiredTechnology);
|
||||
};
|
||||
|
||||
Auras.prototype.CanApply = function(name)
|
||||
{
|
||||
// Check if this is a preview entity
|
||||
const cmpVisibility = Engine.QueryInterface(this.entity, IID_Visibility);
|
||||
if (cmpVisibility && cmpVisibility.GetPreview && cmpVisibility.GetPreview())
|
||||
return false;
|
||||
|
||||
return this.AreTechnologyRequirementsMet(name);
|
||||
};
|
||||
|
||||
Auras.prototype.HasFormationAura = function()
|
||||
|
||||
@@ -432,12 +432,13 @@ class CheckRefs:
|
||||
cmp_auras = entity.find("Auras")
|
||||
if cmp_auras is not None:
|
||||
aura_string = cmp_auras.text
|
||||
for aura in aura_string.split():
|
||||
if not aura:
|
||||
continue
|
||||
if aura.startswith("-"):
|
||||
continue
|
||||
self.deps.append((fp, Path(f"simulation/data/auras/{aura}.json")))
|
||||
if aura_string:
|
||||
for aura in aura_string.split():
|
||||
if not aura:
|
||||
continue
|
||||
if aura.startswith("-"):
|
||||
continue
|
||||
self.deps.append((fp, Path(f"simulation/data/auras/{aura}.json")))
|
||||
|
||||
cmp_identity = entity.find("Identity")
|
||||
if cmp_identity is not None:
|
||||
|
||||
Reference in New Issue
Block a user