Fix vanilla spell casting and bag contents

Vanilla CMSG_CAST_SPELL target mask is uint16 (not uint32 like WotLK),
the extra 2 bytes were corrupting packets. Also implement full bag
content tracking: extract container slot GUIDs from CONTAINER update
objects, set proper bag sizes, and populate bag items in inventory
rebuild.
This commit is contained in:
Kelsi 2026-02-13 22:14:34 -08:00
parent 9f19b39451
commit e168a7cdd1
12 changed files with 191 additions and 9 deletions

View file

@ -257,6 +257,44 @@ network::Packet ClassicPacketParsers::buildMovementPacket(LogicalOpcode opcode,
return packet;
}
// ============================================================================
// Classic buildCastSpell
// Vanilla 1.12.x: NO castCount prefix, NO castFlags byte
// Format: uint32 spellId + uint32 targetFlags + [PackedGuid if unit target]
// ============================================================================
network::Packet ClassicPacketParsers::buildCastSpell(uint32_t spellId, uint64_t targetGuid, uint8_t /*castCount*/) {
network::Packet packet(wireOpcode(LogicalOpcode::CMSG_CAST_SPELL));
packet.writeUInt32(spellId);
// SpellCastTargets — vanilla uses uint16 target mask (not uint32 like WotLK)
if (targetGuid != 0) {
packet.writeUInt16(0x02); // TARGET_FLAG_UNIT
// Write packed GUID
uint8_t mask = 0;
uint8_t bytes[8];
int byteCount = 0;
uint64_t g = targetGuid;
for (int i = 0; i < 8; ++i) {
uint8_t b = g & 0xFF;
if (b != 0) {
mask |= (1 << i);
bytes[byteCount++] = b;
}
g >>= 8;
}
packet.writeUInt8(mask);
for (int i = 0; i < byteCount; ++i) {
packet.writeUInt8(bytes[i]);
}
} else {
packet.writeUInt16(0x00); // TARGET_FLAG_SELF
}
return packet;
}
// ============================================================================
// Classic 1.12.1 parseCharEnum
// Differences from TBC: