From 77b4b6c02948cfbea24de7ce62dfcd841d94d2c7 Mon Sep 17 00:00:00 2001 From: gor_down Date: Sun, 30 Mar 2025 05:01:32 -0300 Subject: [PATCH] AUTOPAIR EN WIT --- src/packet/packet_ms.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/packet/packet_ms.cpp b/src/packet/packet_ms.cpp index 5bd3577..0728ae0 100644 --- a/src/packet/packet_ms.cpp +++ b/src/packet/packet_ms.cpp @@ -288,6 +288,7 @@ AOPacket *PacketMS::validateIcPacket(AOClient &client) const QString l_other_emote = "0"; QString l_other_offset = "0"; QString l_other_flip = "0"; + QString new_offset = "0&0"; if (client.m_pairing_with != -1) { for (int l_client_id : area->joinedIDs()) { AOClient *l_client = client.getServer()->getClientByID(l_client_id); @@ -300,7 +301,7 @@ AOPacket *PacketMS::validateIcPacket(AOClient &client) const } } } - + bool autopaired = false; if (!l_pairing) { if (client.m_pos == "wit" && area->status() != AreaData::Status::CASING) { int pair_index = -1; @@ -320,55 +321,60 @@ AOPacket *PacketMS::validateIcPacket(AOClient &client) const pair_index = not_last_spoke_pair_index; } - l_other_charid = area->m_autopair[pair_index == 0 ? 1 : 0]; + int other_index = pair_index == 0 ? 1 : 0; + l_other_charid = area->m_autopair[other_index]; bool client_found = false; for (int l_client_id : area->joinedIDs()) { - if(l_client_id == client.clientId()){ + if(l_client_id == client.clientId()) { continue; } AOClient *l_client = client.getServer()->getClientByID(l_client_id); - if (l_client->m_char_id == l_other_charid) { + if (l_client->m_char_id == l_other_charid && l_client->m_pos == client.m_pos) { + client_found = true; + autopaired = true; l_other_name = l_client->m_current_iniswap; l_other_emote = l_client->m_emote; l_other_flip = l_client->m_flipping; - client.m_offset = pair_index == 0 ? "-25&0" : "25&0"; - if(l_client->m_offset == "0&0" || l_client->m_offset == "") l_other_offset = pair_index == 0 ? "25&0" : "-25&0"; + int offset = pair_index == 0 ? -25 : 25; + new_offset = QString::number(offset); + if(l_client->m_offset == "0&0" || l_client->m_offset == "") { + l_other_offset = QString::number(offset * -1); + } else l_other_offset = l_client->m_offset; l_front_back = l_front_back == "" ? "^0" : l_front_back; - client_found = true; } } - if (!client_found){ + if (!client_found) { l_other_charid = -1; l_front_back = ""; + area->m_autopair[other_index] = -1; area->m_autopair[1] = client.m_char_id; - client.m_offset = l_incoming_args[17].toString(); } area->m_lastWitChar = client.m_char_id; } }else { l_other_charid = -1; l_front_back = ""; - client.m_offset = l_incoming_args[17].toString(); } l_args.append(QString::number(l_other_charid) + l_front_back); l_args.append(l_other_name); l_args.append(l_other_emote); // self offset - if (l_incoming_args[17].toString() != "0&0" && client.m_offset != "0&0") { + if (!autopaired) { client.m_offset = l_incoming_args[17].toString(); + new_offset = client.m_offset; } // versions 2.6-2.8 cannot validate y-offset so we send them just the x-offset if ((client.m_version.release == 2) && (client.m_version.major == 6 || client.m_version.major == 7 || client.m_version.major == 8)) { - QString l_x_offset = client.m_offset.split("&")[0]; + QString l_x_offset = new_offset.split("&")[0]; l_args.append(l_x_offset); QString l_other_x_offset = l_other_offset.split("&")[0]; l_args.append(l_other_x_offset); } else { - l_args.append(client.m_offset); + l_args.append(new_offset); l_args.append(l_other_offset); } l_args.append(l_other_flip);