From a77a1bcfb41ead7f6eb2845d33847cbbb428e273 Mon Sep 17 00:00:00 2001 From: Burrowdev Date: Tue, 20 Oct 2026 15:25:12 +0300 Subject: [PATCH] fix(pets): name a hatched egg without throwing "pn" (EggPetHatchedPopup) saved `account`, which that handler never defined since aa455f5: a ReferenceError after the name was set in memory, so no reply went out and the game's loading spiral never ended, and the name was not saved, so the popup came back at every login. "account is not defined" at lib/pets.js in prod's log several times an hour since 10-17. qol.js names the egg it buys and waits for the answer. Co-Authored-By: Claude Opus 5.5 --- lib/pets.js | 3 ++- test/qol.js | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/pets.js b/lib/pets.js index 113e0a4..7e75fea 100644 --- a/lib/pets.js +++ b/lib/pets.js @@ -215,7 +215,8 @@ module.exports = ({others, findOnline, petFields}) => { // EggPetHatchedPopup: [petInvIdx, nameId1, nameId2] names a pet hatched // from an egg. PetManager.onPetEggNameResponse: [success, invIdx, name]. pn(session, roomId, [invIdx, name1, name2]) { - const pet = ownPet(session.account, invIdx); + const {account} = session; + const pet = ownPet(account, invIdx); const def = pet && defpacks.petDef(pet.lBits & 0xFF); if (!pet || ![name1, name2].every(isUint) || pet.name || !def || def.isEgg !== "1" || pet.createdAt + SECONDS_TO_HATCH > Math.floor(Date.now() / 1000)) { diff --git a/test/qol.js b/test/qol.js index 1eba684..e79a7c5 100644 --- a/test/qol.js +++ b/test/qol.js @@ -180,6 +180,9 @@ const run = async () => { const made = await a.untilXt("pc"); assert.strictEqual(made[2], "1"); assert.ok(Number(made[10]) <= Date.now() / 1000 - 259200); + // ... and named from the hatched popup (EggPetHatchedPopup waits for this answer) + a.xt("pn", roomId, made[5], 15386, 15428); + assert.deepStrictEqual((await a.untilXt("pn")).slice(2), ["1", made[5], "15386|15428"]); // --- she starts in the township as ever, in a look picked at random if she asked for one say(a, roomId, "!theme random on");