Fix asking for non-existing templates of killed units

This was SVN commit r14614.
This commit is contained in:
sanderd17 2014-01-18 20:56:21 +00:00
parent 3cde5632ff
commit c2d43b009c

View File

@ -194,7 +194,11 @@ AIInterface.prototype.OnGlobalValueModification = function(msg)
var cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);
for each (var ent in msg.entities)
{
var template = cmpTemplateManager.GetTemplateWithoutValidation(cmpTemplateManager.GetCurrentTemplateName(ent));
var templateName = cmpTemplateManager.GetCurrentTemplateName(ent);
// if there's no template name, the unit is probably killed, ignore it.
if (!templateName || !templateName.length)
continue;
var template = cmpTemplateManager.GetTemplateWithoutValidation(templateName);
for each (var value in msg.valueNames)
{
// let's get the base template value.