From 4049daaef15baba9b855cb96c334064b72e153e0 Mon Sep 17 00:00:00 2001 From: kprzybylski Date: Tue, 21 Jul 2026 04:08:53 -0700 Subject: [PATCH] Clear gumball buff when a nano slot's occupant changes The gumball (stimpak) buff is keyed to the nano slot (ECSB_STIMPAKSLOT1 + slot), not to the nano that consumed the gumball. Nothing cleared that buff when the slot's occupant changed, so swapping or replacing an equipped nano left the buff on the slot and the incoming nano inherited the boost. This bypassed the gumball/nano-style check in useGumball() and mislabeled the wrong nano as buffed on the client HUD. A slot swap carries no source slot and no dedicated opcode, so the client expresses it as NANO_EQUIP packets that overwrite slots in place; drop the slot's stimpak buff in nanoEquipHandler whenever the occupant changes, and in nanoUnEquipHandler when the nano leaves the slot. removeBuff() clears the effect and resends the corrected condition bitflag, fixing both the boost and the HUD icon. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/Nanos.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Nanos.cpp b/src/Nanos.cpp index bb249748..45c31899 100644 --- a/src/Nanos.cpp +++ b/src/Nanos.cpp @@ -215,6 +215,14 @@ static void nanoEquipHandler(CNSocket* sock, CNPacketData* data) { resp.iNanoID = nano->iNanoID; resp.iNanoSlotNum = nano->iNanoSlotNum; + /* + * A gumball (stimpak) buff is keyed to the nano slot, not the nano itself. + * If this slot's occupant is changing, drop the buff so the incoming nano + * doesn't inherit the boost (which would also bypass the gumball type check). + */ + if (plr->equippedNanos[nano->iNanoSlotNum] != nano->iNanoID) + plr->removeBuff(ECSB_STIMPAKSLOT1 + nano->iNanoSlotNum); + // Update player plr->equippedNanos[nano->iNanoSlotNum] = nano->iNanoID; @@ -240,6 +248,9 @@ static void nanoUnEquipHandler(CNSocket* sock, CNPacketData* data) { if (plr->equippedNanos[nano->iNanoSlotNum] == plr->activeNano) summonNano(sock, -1); + // a gumball (stimpak) buff is tied to this slot; drop it as the nano leaves + plr->removeBuff(ECSB_STIMPAKSLOT1 + nano->iNanoSlotNum); + // update player plr->equippedNanos[nano->iNanoSlotNum] = 0;