diff --git a/lib/avatars.js b/lib/avatars.js index ff4e112..8bcc382 100644 --- a/lib/avatars.js +++ b/lib/avatars.js @@ -25,7 +25,7 @@ const validNameBarData = (value, account) => Number.isInteger(value) && value >= && badges.mayWear(account, defpacks.badgeIds()[value >> 8 & 0xFF]) // the ones the admin gives: lib/badges.js && (value >> 16) <= 1; -module.exports = ({others, findOnline, findBySfsId, refreshForOthers, petFields, sendAvatarData, sendItemList}) => { +module.exports = ({others, findOnline, findBySfsId, refreshForOthers, petFields}) => { // A player's card: who they are, the animal they are using and what it // wears. AvatarXtCommManager.avatarGetResponse reads [username, uuid, // status, accountType, isGuide, daysSinceLogin, perUserAvId, avInvId, @@ -97,13 +97,12 @@ module.exports = ({others, findOnline, findBySfsId, refreshForOthers, petFields, const messageRoom = session.room ? session.room.id : -1; const common = [1, session.id, avatar.perUserAvId, avatar.avInvId, avatar.customAvId, avatar.type, ...avatar.colors, avatar.name]; session.sendXt("as", messageRoom, ...common, avatar.petInvId, avatar.questLevel || 0); - // Switching changes the active animal, but the client keeps a separate - // editor model for each avatar. Refresh both parts of that model here: - // otherwise a newly bought animal can be shown in the switcher while its - // clothing inventory was never populated, leaving the editor unable to - // open until the player signs in again. - sendAvatarData(session, session, avatar.perUserAvId); - sendItemList(session, session, true, avatar.perUserAvId); + // Nothing more goes to the switching player here. The client swaps the + // animals during the transform animation (AvatarSwitch "hideAvatar"), + // copying the in-world avatar into the switcher slot first and asking + // for "ad" itself when it needs to. An unasked "ad"/"il" lands on the + // in-world avatar before that copy, so the old animal vanished from the + // switcher and the new one showed twice. if (session.pos) { for (const other of others(session)) { other.sendXt("as", messageRoom, ...common, ...petFields(activePet(account)), avatar.questLevel || 0); diff --git a/lib/world.js b/lib/world.js index b64ca02..ea34210 100644 --- a/lib/world.js +++ b/lib/world.js @@ -1338,7 +1338,6 @@ const context = { findOnline, findBySfsId, sendItemList, - sendAvatarData, sendAvatarCreate, refreshForOthers, petFields, diff --git a/test/smoke.js b/test/smoke.js index a9438da..682ad4c 100644 --- a/test/smoke.js +++ b/test/smoke.js @@ -347,10 +347,6 @@ const run = async () => { assert.deepStrictEqual(switched.slice(2, 4).concat(switched.slice(4, 8)), ["1", String(aliceId), aa[3], aa[4], "-1", "4"]); assert.strictEqual(switched[11], "15136|15224|15299"); assert.strictEqual((await c.nextXt("as")).length, switched.length + 7); - // The switch is followed by the animal's data and its full item list, so - // that the editor can open on the new animal (lib/avatars.js "as"). - assert.strictEqual((await a.nextXt("ad"))[2], "Alice"); - assert.strictEqual((await a.nextXt("il"))[2], "0"); a.xt("al", denId, "Alice"); assert.deepStrictEqual((await a.nextXt("al")).slice(5, 7), ["2", aa[3]]); a.xt("ak", denId, aa[3]); // cannot remove the animal in use