From 9840e056057f4f7cd252da35b76864a37f51c5df Mon Sep 17 00:00:00 2001 From: gor_down Date: Sat, 29 Mar 2025 07:33:41 -0300 Subject: [PATCH] cocinando mi propia caca --- src/area_data.h | 3 ++ src/packet/packet_ms.cpp | 70 ++++++++++++++++++++++++++++++++++------ 2 files changed, 64 insertions(+), 9 deletions(-) diff --git a/src/area_data.h b/src/area_data.h index aa07d39..8947eb2 100644 --- a/src/area_data.h +++ b/src/area_data.h @@ -41,6 +41,9 @@ class AreaData : public QObject Q_OBJECT public: + + int m_autopair[2] = {-1, -1}; + int m_lastWitChar = -1; /** * @brief Constructor for the AreaData class. * diff --git a/src/packet/packet_ms.cpp b/src/packet/packet_ms.cpp index cb94adf..4b37b02 100644 --- a/src/packet/packet_ms.cpp +++ b/src/packet/packet_ms.cpp @@ -285,26 +285,78 @@ AOPacket *PacketMS::validateIcPacket(AOClient &client) const QString l_other_emote = "0"; QString l_other_offset = "0"; QString l_other_flip = "0"; - for (int l_client_id : area->joinedIDs()) { - AOClient *l_client = client.getServer()->getClientByID(l_client_id); - if (l_client->m_pairing_with == client.m_char_id && l_other_charid != client.m_char_id && l_client->m_char_id == client.m_pairing_with && l_client->m_pos == client.m_pos) { - l_other_name = l_client->m_current_iniswap; - l_other_emote = l_client->m_emote; - l_other_offset = l_client->m_offset; - l_other_flip = l_client->m_flipping; - l_pairing = true; + if (client.m_pairing_with != -1) { + for (int l_client_id : area->joinedIDs()) { + AOClient *l_client = client.getServer()->getClientByID(l_client_id); + if (l_client->m_pairing_with == client.m_char_id && l_other_charid != client.m_char_id && l_client->m_char_id == client.m_pairing_with && l_client->m_pos == client.m_pos) { + l_other_name = l_client->m_current_iniswap; + l_other_emote = l_client->m_emote; + l_other_offset = l_client->m_offset; + l_other_flip = l_client->m_flipping; + l_pairing = true; + } } } + if (!l_pairing) { + if (client.m_pos == "wit" && area->status() != AreaData::Status::CASING) { + int pair_index = -1; + for (int i = 0; i < 2; ++i) { + if (area->m_autopair[i] == client.m_char_id) { + pair_index = i; + } + } + if (pair_index == -1) { + int not_last_spoke_pair_index = 1; + for (int i = 0; i < 2; ++i) { + if (area->m_autopair[i] != area->m_lastWitChar) { + not_last_spoke_pair_index = i; + } + } + area->m_autopair[not_last_spoke_pair_index] = client.m_char_id; + pair_index = not_last_spoke_pair_index; + + } + l_other_charid = area->m_autopair[pair_index == 0 ? 1 : 0]; + + bool client_found = false; + for (int l_client_id : area->joinedIDs()) { + 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) { + 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"; + else l_other_offset = l_client->m_offset; + l_front_back = l_front_back == "" ? "^0" : l_front_back; + client_found = true; + } + } + if (!client_found){ + l_other_charid = -1; + l_front_back = ""; + 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 - client.m_offset = l_incoming_args[17].toString(); + if (l_incoming_args[17].toString() != "0&0" && client.m_offset != "0&0") { + client.m_offset = l_incoming_args[17].toString(); + } // 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];