mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-07-04 05:55:47 -07:00
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:
parent
bf988bfde5
commit
298d459e45
1 changed files with 9 additions and 6 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue