Fix broken avatar change messsage when using avatar numbers (#1379)

This commit is contained in:
asgdf
2019-10-01 19:23:48 +02:00
committed by Guangcong Luo
parent 0d0dc4f0bc
commit 17e4d9ff3f
2 changed files with 12 additions and 4 deletions

View File

@@ -923,8 +923,12 @@
case 'avatar':
var parts = target.split(',');
var avatar = parts[0].toLowerCase().replace(/[^a-z0-9-]+/g, '');
// Replace avatar number with name before sending it to the server, only the client knows what to do with the numbers
if (window.BattleAvatarNumbers && Object.prototype.hasOwnProperty.call(window.BattleAvatarNumbers, avatar)) {
avatar = window.BattleAvatarNumbers[avatar];
}
Dex.prefs('avatar', avatar);
return text; // Send the /avatar command through to the server.
return '/avatar ' + avatar; // Send the command through to the server.
case 'afd':
var cleanedTarget = toID(target);

View File

@@ -670,10 +670,14 @@
buf += '<p><button name="close">Cancel</button></p>';
this.$el.html(buf).css('max-width', 780);
},
setAvatar: function (i) {
app.send('/avatar ' + i);
setAvatar: function (avatar) {
// Replace avatar number with name before sending it to the server, only the client knows what to do with the numbers
if (window.BattleAvatarNumbers && Object.prototype.hasOwnProperty.call(window.BattleAvatarNumbers, avatar)) {
avatar = window.BattleAvatarNumbers[avatar];
}
app.send('/avatar ' + avatar);
app.send('/cmd userdetails ' + app.user.get('userid'));
Dex.prefs('avatar', i);
Dex.prefs('avatar', avatar);
this.close();
}
});