Index: binaries/data/mods/public/simulation/components/GarrisonHolder.js =================================================================== --- binaries/data/mods/public/simulation/components/GarrisonHolder.js +++ binaries/data/mods/public/simulation/components/GarrisonHolder.js @@ -40,10 +40,7 @@ */ GarrisonHolder.prototype.Init = function() { - // Garrisoned Units this.entities = []; - this.timer = undefined; - this.allowGarrisoning = new Map(); this.allowedClasses = ApplyValueModificationsToEntity("GarrisonHolder/List/_string", this.template.List._string, this.entity); }; @@ -114,12 +111,18 @@ */ GarrisonHolder.prototype.AllowGarrisoning = function(allow, callerID) { + if (!this.allowGarrisoning) + this.allowGarrisoning = new Map(); this.allowGarrisoning.set(callerID, allow); }; +/** + * @return {boolean} - Whether (un)garrisoning is allowed. + */ GarrisonHolder.prototype.IsGarrisoningAllowed = function() { - return Array.from(this.allowGarrisoning.values()).every(allow => allow); + return !this.allowGarrisoning || + Array.from(this.allowGarrisoning.values()).every(allow => allow); }; GarrisonHolder.prototype.GetGarrisonedEntitiesCount = function() @@ -422,7 +425,7 @@ if (!this.entities.length) { cmpTimer.CancelTimer(this.timer); - this.timer = undefined; + delete this.timer; return; } @@ -629,7 +632,7 @@ { let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); cmpTimer.CancelTimer(this.timer); - this.timer = undefined; + delete this.timer; } else if (!this.timer && this.GetHealRate() > 0) {