From 1d9b70f32e96abeed4f3faed5bb46881a2b98ae9 Mon Sep 17 00:00:00 2001 From: Burrowdev Date: Sun, 18 Oct 2026 19:35:16 +0300 Subject: [PATCH] fix(avatars): keep the gem count when an animal is recycled The animal switcher shows the second field of "ak" as the player's gems; it was always 0, so recycling an animal showed 0 gems until the next login. --- lib/avatars.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/avatars.js b/lib/avatars.js index 6e841e1..1493a4f 100644 --- a/lib/avatars.js +++ b/lib/avatars.js @@ -104,12 +104,12 @@ module.exports = ({others, findOnline, findBySfsId, refreshForOthers, petFields} } }, - // AvatarSwitch.avatarKillResponse: [success, ?] + // AvatarSwitch.avatarKillResponse: [success, gems] ak(session, roomId, [perUserAvId]) { const {account} = session; const avatar = account.avatars.find(candidate => candidate.perUserAvId === Number(perUserAvId)); if (!avatar || avatar === activeAvatar(account) || account.avatars.length < 2) { - session.sendXt("ak", -1, 0, 0); + session.sendXt("ak", -1, 0, account.currency.gems); return; } account.avatars = account.avatars.filter(candidate => candidate !== avatar); @@ -117,7 +117,9 @@ module.exports = ({others, findOnline, findBySfsId, refreshForOthers, petFields} item.on = item.on.filter(avInvId => avInvId !== avatar.avInvId); } accounts.save(account); - session.sendXt("ak", -1, 1, 0); + // [success, gems]: the animal switcher (AvatarSwitcher.recycleAvatarCallback) + // shows the second as the player's gems, so it is their total, unchanged. + session.sendXt("ak", -1, 1, account.currency.gems); }, // AvatarXtCommManager.requestColorChange: [color1, color2, color3, nameBarData]