mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-18 17:27:50 -05:00
fix(avatars): a newly switched-to animal's editor opens
Switching animals ("as") changed the active animal, but the client keeps
an editor model of each animal and was never sent the new one's data or
clothes, so an animal bought this session showed in the switcher and its
editor would not open until the next login. The switch is now followed by
its "ad" and its full item list.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
8839f86e6c
commit
3423df10f8
3 files changed
+13
-1
No files matched your search
+8
-1
@@ -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
|
&& badges.mayWear(account, defpacks.badgeIds()[value >> 8 & 0xFF]) // the ones the admin gives: lib/badges.js
|
||||||
&& (value >> 16) <= 1;
|
&& (value >> 16) <= 1;
|
||||||
|
|
||||||
module.exports = ({others, findOnline, findBySfsId, refreshForOthers, petFields}) => {
|
module.exports = ({others, findOnline, findBySfsId, refreshForOthers, petFields, sendAvatarData, sendItemList}) => {
|
||||||
// A player's card: who they are, the animal they are using and what it
|
// A player's card: who they are, the animal they are using and what it
|
||||||
// wears. AvatarXtCommManager.avatarGetResponse reads [username, uuid,
|
// wears. AvatarXtCommManager.avatarGetResponse reads [username, uuid,
|
||||||
// status, accountType, isGuide, daysSinceLogin, perUserAvId, avInvId,
|
// status, accountType, isGuide, daysSinceLogin, perUserAvId, avInvId,
|
||||||
@@ -97,6 +97,13 @@ module.exports = ({others, findOnline, findBySfsId, refreshForOthers, petFields}
|
|||||||
const messageRoom = session.room ? session.room.id : -1;
|
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];
|
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);
|
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);
|
||||||
if (session.pos) {
|
if (session.pos) {
|
||||||
for (const other of others(session)) {
|
for (const other of others(session)) {
|
||||||
other.sendXt("as", messageRoom, ...common, ...petFields(activePet(account)), avatar.questLevel || 0);
|
other.sendXt("as", messageRoom, ...common, ...petFields(activePet(account)), avatar.questLevel || 0);
|
||||||
|
|||||||
@@ -1314,6 +1314,7 @@ const context = {
|
|||||||
findOnline,
|
findOnline,
|
||||||
findBySfsId,
|
findBySfsId,
|
||||||
sendItemList,
|
sendItemList,
|
||||||
|
sendAvatarData,
|
||||||
sendAvatarCreate,
|
sendAvatarCreate,
|
||||||
refreshForOthers,
|
refreshForOthers,
|
||||||
petFields,
|
petFields,
|
||||||
|
|||||||
@@ -336,6 +336,10 @@ const run = async () => {
|
|||||||
assert.deepStrictEqual(switched.slice(2, 4).concat(switched.slice(4, 8)), ["1", String(aliceId), aa[3], aa[4], "-1", "4"]);
|
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(switched[11], "15136|15224|15299");
|
||||||
assert.strictEqual((await c.nextXt("as")).length, switched.length + 7);
|
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");
|
a.xt("al", denId, "Alice");
|
||||||
assert.deepStrictEqual((await a.nextXt("al")).slice(5, 7), ["2", aa[3]]);
|
assert.deepStrictEqual((await a.nextXt("al")).slice(5, 7), ["2", aa[3]]);
|
||||||
a.xt("ak", denId, aa[3]); // cannot remove the animal in use
|
a.xt("ak", denId, aa[3]); // cannot remove the animal in use
|
||||||
|
|||||||
Reference in new issue
Block a user