Fix crash when packing a team with custom mons

Also synchronize fastUnpackTeam
This commit is contained in:
Ivo Julca 2014-03-06 18:52:15 -05:00
parent e539388861
commit cbf82c389b

View File

@ -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