mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-12 07:43:51 +00:00
refactor: replace magic slot offset 23 with NUM_EQUIP_SLOTS, simplify channel search
- Replace all 11 occurrences of magic number 23 in backpack slot calculations with Inventory::NUM_EQUIP_SLOTS across inventory_handler, spell_handler, and inventory.cpp - Add why-comment to NUM_EQUIP_SLOTS explaining WoW slot layout (equipment 0-22, backpack starts at 23 in bag 0xFF) - Add why-comment on 0x80000000 bit mask in item query response (high bit flags negative/missing entry response) - Replace manual channel membership loops with std::find in chat_handler.cpp (YOU_JOINED and PLAYER_ALREADY_MEMBER cases) - Add why-comment on PLAYER_ALREADY_MEMBER reconnect edge case
This commit is contained in:
parent
a9ce22f315
commit
f313eec24e
5 changed files with 21 additions and 23 deletions
|
|
@ -435,11 +435,7 @@ void ChatHandler::handleChannelNotify(network::Packet& packet) {
|
|||
|
||||
switch (data.notifyType) {
|
||||
case ChannelNotifyType::YOU_JOINED: {
|
||||
bool found = false;
|
||||
for (const auto& ch : joinedChannels_) {
|
||||
if (ch == data.channelName) { found = true; break; }
|
||||
}
|
||||
if (!found) {
|
||||
if (std::find(joinedChannels_.begin(), joinedChannels_.end(), data.channelName) == joinedChannels_.end()) {
|
||||
joinedChannels_.push_back(data.channelName);
|
||||
}
|
||||
MessageChatData msg;
|
||||
|
|
@ -461,11 +457,9 @@ void ChatHandler::handleChannelNotify(network::Packet& packet) {
|
|||
break;
|
||||
}
|
||||
case ChannelNotifyType::PLAYER_ALREADY_MEMBER: {
|
||||
bool found = false;
|
||||
for (const auto& ch : joinedChannels_) {
|
||||
if (ch == data.channelName) { found = true; break; }
|
||||
}
|
||||
if (!found) {
|
||||
// Server confirms we're in this channel but our local list doesn't have it yet —
|
||||
// can happen after reconnect or if the join notification was missed.
|
||||
if (std::find(joinedChannels_.begin(), joinedChannels_.end(), data.channelName) == joinedChannels_.end()) {
|
||||
joinedChannels_.push_back(data.channelName);
|
||||
LOG_INFO("Already in channel: ", data.channelName);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue