Skip to content

Commit

Permalink
Fix crash when packing a team with custom mons
Browse files Browse the repository at this point in the history
Also synchronize fastUnpackTeam
  • Loading branch information
Slayer95 committed Mar 6, 2014
1 parent e539388 commit cbf82c3
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cbf82c3

Please sign in to comment.