mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-03 08:03:50 +00:00
fix: guard equipment set packets against unsupported expansions
Classic and TBC lack equipment set opcodes, so sending save/use/delete packets would transmit wire opcode 0xFFFF and potentially disconnect the client. Now all three methods check wireOpcode != 0xFFFF before sending, and the Outfits tab is only shown when the expansion supports equipment sets (via supportsEquipmentSets() check).
This commit is contained in:
parent
9600dd40e3
commit
e68a1fa2ec
3 changed files with 16 additions and 5 deletions
|
|
@ -1534,6 +1534,7 @@ public:
|
||||||
std::string iconName;
|
std::string iconName;
|
||||||
};
|
};
|
||||||
const std::vector<EquipmentSetInfo>& getEquipmentSets() const { return equipmentSetInfo_; }
|
const std::vector<EquipmentSetInfo>& getEquipmentSets() const { return equipmentSetInfo_; }
|
||||||
|
bool supportsEquipmentSets() const;
|
||||||
void useEquipmentSet(uint32_t setId);
|
void useEquipmentSet(uint32_t setId);
|
||||||
void saveEquipmentSet(const std::string& name, const std::string& iconName = "INV_Misc_QuestionMark",
|
void saveEquipmentSet(const std::string& name, const std::string& iconName = "INV_Misc_QuestionMark",
|
||||||
uint64_t existingGuid = 0, uint32_t setIndex = 0xFFFFFFFF);
|
uint64_t existingGuid = 0, uint32_t setIndex = 0xFFFFFFFF);
|
||||||
|
|
|
||||||
|
|
@ -10675,8 +10675,14 @@ void GameHandler::sendRequestVehicleExit() {
|
||||||
vehicleId_ = 0; // Optimistically clear; server will confirm via SMSG_PLAYER_VEHICLE_DATA(0)
|
vehicleId_ = 0; // Optimistically clear; server will confirm via SMSG_PLAYER_VEHICLE_DATA(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GameHandler::supportsEquipmentSets() const {
|
||||||
|
return wireOpcode(Opcode::CMSG_EQUIPMENT_SET_SAVE) != 0xFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
void GameHandler::useEquipmentSet(uint32_t setId) {
|
void GameHandler::useEquipmentSet(uint32_t setId) {
|
||||||
if (state != WorldState::IN_WORLD || !socket) return;
|
if (state != WorldState::IN_WORLD || !socket) return;
|
||||||
|
uint16_t wire = wireOpcode(Opcode::CMSG_EQUIPMENT_SET_USE);
|
||||||
|
if (wire == 0xFFFF) { addUIError("Equipment sets not supported."); return; }
|
||||||
// Find the equipment set to get target item GUIDs per slot
|
// Find the equipment set to get target item GUIDs per slot
|
||||||
const EquipmentSet* es = nullptr;
|
const EquipmentSet* es = nullptr;
|
||||||
for (const auto& s : equipmentSets_) {
|
for (const auto& s : equipmentSets_) {
|
||||||
|
|
@ -10687,7 +10693,7 @@ void GameHandler::useEquipmentSet(uint32_t setId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// CMSG_EQUIPMENT_SET_USE: 19 × (PackedGuid itemGuid + uint8 srcBag + uint8 srcSlot)
|
// CMSG_EQUIPMENT_SET_USE: 19 × (PackedGuid itemGuid + uint8 srcBag + uint8 srcSlot)
|
||||||
network::Packet pkt(wireOpcode(Opcode::CMSG_EQUIPMENT_SET_USE));
|
network::Packet pkt(wire);
|
||||||
for (int slot = 0; slot < 19; ++slot) {
|
for (int slot = 0; slot < 19; ++slot) {
|
||||||
uint64_t itemGuid = es->itemGuids[slot];
|
uint64_t itemGuid = es->itemGuids[slot];
|
||||||
MovementPacket::writePackedGuid(pkt, itemGuid);
|
MovementPacket::writePackedGuid(pkt, itemGuid);
|
||||||
|
|
@ -10733,6 +10739,8 @@ void GameHandler::useEquipmentSet(uint32_t setId) {
|
||||||
void GameHandler::saveEquipmentSet(const std::string& name, const std::string& iconName,
|
void GameHandler::saveEquipmentSet(const std::string& name, const std::string& iconName,
|
||||||
uint64_t existingGuid, uint32_t setIndex) {
|
uint64_t existingGuid, uint32_t setIndex) {
|
||||||
if (state != WorldState::IN_WORLD) return;
|
if (state != WorldState::IN_WORLD) return;
|
||||||
|
uint16_t wire = wireOpcode(Opcode::CMSG_EQUIPMENT_SET_SAVE);
|
||||||
|
if (wire == 0xFFFF) { addUIError("Equipment sets not supported."); return; }
|
||||||
// CMSG_EQUIPMENT_SET_SAVE: uint64 setGuid + uint32 setIndex + string name + string iconName
|
// CMSG_EQUIPMENT_SET_SAVE: uint64 setGuid + uint32 setIndex + string name + string iconName
|
||||||
// + 19 × PackedGuid itemGuid (one per equipment slot, 0–18)
|
// + 19 × PackedGuid itemGuid (one per equipment slot, 0–18)
|
||||||
if (setIndex == 0xFFFFFFFF) {
|
if (setIndex == 0xFFFFFFFF) {
|
||||||
|
|
@ -10742,7 +10750,7 @@ void GameHandler::saveEquipmentSet(const std::string& name, const std::string& i
|
||||||
if (es.setId >= setIndex) setIndex = es.setId + 1;
|
if (es.setId >= setIndex) setIndex = es.setId + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
network::Packet pkt(wireOpcode(Opcode::CMSG_EQUIPMENT_SET_SAVE));
|
network::Packet pkt(wire);
|
||||||
pkt.writeUInt64(existingGuid); // 0 = create new, nonzero = update
|
pkt.writeUInt64(existingGuid); // 0 = create new, nonzero = update
|
||||||
pkt.writeUInt32(setIndex);
|
pkt.writeUInt32(setIndex);
|
||||||
pkt.writeString(name);
|
pkt.writeString(name);
|
||||||
|
|
@ -10757,8 +10765,10 @@ void GameHandler::saveEquipmentSet(const std::string& name, const std::string& i
|
||||||
|
|
||||||
void GameHandler::deleteEquipmentSet(uint64_t setGuid) {
|
void GameHandler::deleteEquipmentSet(uint64_t setGuid) {
|
||||||
if (state != WorldState::IN_WORLD || setGuid == 0) return;
|
if (state != WorldState::IN_WORLD || setGuid == 0) return;
|
||||||
|
uint16_t wire = wireOpcode(Opcode::CMSG_DELETEEQUIPMENT_SET);
|
||||||
|
if (wire == 0xFFFF) { addUIError("Equipment sets not supported."); return; }
|
||||||
// CMSG_DELETEEQUIPMENT_SET: uint64 setGuid
|
// CMSG_DELETEEQUIPMENT_SET: uint64 setGuid
|
||||||
network::Packet pkt(wireOpcode(Opcode::CMSG_DELETEEQUIPMENT_SET));
|
network::Packet pkt(wire);
|
||||||
pkt.writeUInt64(setGuid);
|
pkt.writeUInt64(setGuid);
|
||||||
socket->send(pkt);
|
socket->send(pkt);
|
||||||
// Remove locally so UI updates immediately
|
// Remove locally so UI updates immediately
|
||||||
|
|
|
||||||
|
|
@ -1438,8 +1438,8 @@ void InventoryScreen::renderCharacterScreen(game::GameHandler& gameHandler) {
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Equipment Sets tab (WotLK — always show so player can create sets)
|
// Equipment Sets tab (WotLK only — requires server support)
|
||||||
if (ImGui::BeginTabItem("Outfits")) {
|
if (gameHandler.supportsEquipmentSets() && ImGui::BeginTabItem("Outfits")) {
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
|
|
||||||
// Save current gear as new set
|
// Save current gear as new set
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue