Handle empty token list gracefully.

This was SVN commit r13477.
This commit is contained in:
leper 2013-06-14 16:13:59 +00:00
parent bcf99e2a13
commit 9ea830c855
5 changed files with 12 additions and 6 deletions

View File

@ -199,7 +199,8 @@ Attack.prototype.GetAttackTypes = function()
Attack.prototype.GetPreferredClasses = function(type)
{
if (this.template[type] && this.template[type].PreferredClasses)
if (this.template[type] && this.template[type].PreferredClasses
&& this.template[type].PreferredClasses._string)
{
return this.template[type].PreferredClasses._string.split(/\s+/);
}
@ -208,7 +209,8 @@ Attack.prototype.GetPreferredClasses = function(type)
Attack.prototype.GetRestrictedClasses = function(type)
{
if (this.template[type] && this.template[type].RestrictedClasses)
if (this.template[type] && this.template[type].RestrictedClasses
&& this.template[type].RestrictedClasses._string)
{
return this.template[type].RestrictedClasses._string.split(/\s+/);
}

View File

@ -54,7 +54,7 @@ GarrisonHolder.prototype.GetEntities = function()
*/
GarrisonHolder.prototype.GetAllowedClassesList = function()
{
var string = this.template.List._string;
var string = this.template.List._string || "";
return string.split(/\s+/);
};

View File

@ -76,6 +76,8 @@ ProductionQueue.prototype.GetEntitiesList = function()
return [];
var string = this.template.Entities._string;
if (!string)
return [];
// Replace the "{civ}" codes with this entity's civ ID
var cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity);
@ -94,6 +96,8 @@ ProductionQueue.prototype.GetTechnologiesList = function()
return [];
var string = this.template.Technologies._string;
if (!string)
return [];
var cmpTechnologyManager = QueryOwnerInterface(this.entity, IID_TechnologyManager);
if (!cmpTechnologyManager)

View File

@ -14,13 +14,13 @@
</Obstruction>
<ProductionQueue>
<Technologies datatype="tokens">
-pair_walls_01
-pair_walls_01
</Technologies>
</ProductionQueue>
<VisualActor>
<Actor>structures/iberians/wall_tower.xml</Actor>
</VisualActor>
<WallPiece>
<Length>10</Length>
<Length>10</Length>
</WallPiece>
</Entity>

View File

@ -62,7 +62,7 @@
<ProductionQueue>
<BatchTimeModifier>0.8</BatchTimeModifier>
<Technologies datatype="tokens">
pair_walls_01
pair_walls_01
</Technologies>
</ProductionQueue>
<Sound>