From 80258d5f9eed1efc291d909dff5592f24dea6c94 Mon Sep 17 00:00:00 2001 From: Zach Toogood Date: Thu, 19 Oct 2023 17:06:36 +0100 Subject: [PATCH] [core] Fix issue with set-update-style packets (CMonipulatorPacket1 & 2) --- src/map/packets/monipulator1.cpp | 9 ++++++--- src/map/packets/monipulator2.cpp | 16 +++++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/map/packets/monipulator1.cpp b/src/map/packets/monipulator1.cpp index 4d0bcc32bc1..f36fa57d431 100644 --- a/src/map/packets/monipulator1.cpp +++ b/src/map/packets/monipulator1.cpp @@ -31,14 +31,17 @@ CMonipulatorPacket1::CMonipulatorPacket1(CCharEntity* PChar) this->setType(0x63); this->setSize(0xDC); + // NOTE: These packets have to be at least partially populated, or the + // player will lose their abilities and get a big selection of incorrect traits. + + ref(0x04) = 0x03; // Update Type + ref(0x06) = 0xD8; // Variable Data Size + if (PChar->m_PMonstrosity == nullptr) { return; } - ref(0x04) = 0x03; // Update Type - ref(0x06) = 0xD8; // Variable Data Size - ref(0x08) = PChar->m_PMonstrosity->Species; ref(0x0A) = PChar->m_PMonstrosity->Flags; diff --git a/src/map/packets/monipulator2.cpp b/src/map/packets/monipulator2.cpp index a3cef1ebf78..647f5c9c0aa 100644 --- a/src/map/packets/monipulator2.cpp +++ b/src/map/packets/monipulator2.cpp @@ -30,17 +30,23 @@ CMonipulatorPacket2::CMonipulatorPacket2(CCharEntity* PChar) this->setType(0x63); this->setSize(0xB4); - if (PChar->m_PMonstrosity == nullptr) - { - return; - } + // NOTE: These packets have to be at least partially populated, or the + // player will lose their abilities and get a big selection of incorrect traits. std::memset(data + 4, 0, PACKET_SIZE - 4); - // TODO: What are these? + // NOTE: These are the equivalent entries from Monipulator1 packet + // ref(0x04) = 0x03; // Update Type + // ref(0x06) = 0xD8; // Variable Data Size + std::array packet2 = { 0x04, 0x00, 0xB0 }; std::memcpy(data + 0x04, &packet2, sizeof(packet2)); + if (PChar->m_PMonstrosity == nullptr) + { + return; + } + // NOTE: SE added these after-the-fact, so they're not sent in Monipulator1 and they're at the end of the array! // Slime Level ref(0x86) = PChar->m_PMonstrosity->levels[126];