Do not initialise null values in cmpGarrisonHolder.

Saves some serialisation data (refs #3834).

Ticket: #5979
Differential revision: https://code.wildfiregames.com/D3468
Comments by: @Angen, @Stan
This was SVN commit r24993.
This commit is contained in:
Freagarach 2021-03-03 10:18:57 +00:00
parent bf988bfde5
commit 298d459e45

View file

@ -40,10 +40,7 @@ GarrisonHolder.prototype.Schema =
*/
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.GetHealRate = function()
*/
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 @@ GarrisonHolder.prototype.HealTimeout = function(data)
if (!this.entities.length)
{
cmpTimer.CancelTimer(this.timer);
this.timer = undefined;
delete this.timer;
return;
}
@ -629,7 +632,7 @@ GarrisonHolder.prototype.OnValueModification = function(msg)
{
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)
{