From cbf82c389b167efe515dd078564a1a5589a6f0d7 Mon Sep 17 00:00:00 2001 From: Ivo Julca Date: Thu, 6 Mar 2014 18:52:15 -0500 Subject: [PATCH] Fix crash when packing a team with custom mons Also synchronize fastUnpackTeam --- js/storage.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/js/storage.js b/js/storage.js index cff4b7402..2f50fb355 100644 --- a/js/storage.js +++ b/js/storage.js @@ -83,12 +83,16 @@ _Storage.prototype.packTeam = function(team) { var template = Tools.getTemplate(set.species || set.name); var abilities = template.abilities; id = toId(set.ability); - if (id == toId(abilities['0'])) { - buf += '|'; - } else if (id === toId(abilities['1'])) { - buf += '|1'; - } else if (id === toId(abilities['H'])) { - buf += '|H'; + if (abilities) { + if (id == toId(abilities['0'])) { + buf += '|'; + } else if (id === toId(abilities['1'])) { + buf += '|1'; + } else if (id === toId(abilities['H'])) { + buf += '|H'; + } else { + buf += '|' + id; + } } else { buf += '|' + id; } @@ -182,7 +186,7 @@ _Storage.prototype.fastUnpackTeam = function(buf) { j = buf.indexOf('|', i); var ability = buf.substring(i, j); var template = Tools.getTemplate(set.species); - set.ability = (ability in {'':1, 0:1, 1:1, H:1} ? template.abilities[ability||'0'] : ability); + set.ability = (template.abilities && ability in {'':1, 0:1, 1:1, H:1} ? template.abilities[ability||'0'] : ability); i = j+1; // moves