diff options
Diffstat (limited to 'src/packet_distribution.cpp')
| -rw-r--r-- | src/packet_distribution.cpp | 607 |
1 files changed, 362 insertions, 245 deletions
diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 8cb78eb8..1a0e798c 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -9,37 +9,41 @@ void AOApplication::append_to_demofile(QString packet_string) { - if (Options::getInstance().logToDemoFileEnabled() && !log_filename.isEmpty()) + if (Options::getInstance().logToDemoFileEnabled() && !log_filename.isEmpty()) + { + QString path = log_filename.left(log_filename.size()).replace(".log", ".demo"); + if (!demo_timer.isValid()) { - QString path = log_filename.left(log_filename.size()).replace(".log", ".demo"); - if (!demo_timer.isValid()) - demo_timer.start(); - else - append_to_file("wait#"+ QString::number(demo_timer.restart()) + "#%", path, true); - append_to_file(packet_string, path, true); + demo_timer.start(); } + else + { + append_to_file("wait#" + QString::number(demo_timer.restart()) + "#%", path, true); + } + append_to_file(packet_string, path, true); + } } -void AOApplication::server_packet_received(AOPacket *p_packet) +void AOApplication::server_packet_received(AOPacket packet) { - QStringList f_contents_encoded = p_packet->get_contents(); - QString f_packet_encoded = p_packet->to_string(); - p_packet->net_decode(); - - QString header = p_packet->get_header(); - QStringList f_contents = p_packet->get_contents(); - QString f_packet = p_packet->to_string(); + QString header = packet.header(); + QStringList content = packet.content(); bool log_to_demo = true; #ifdef DEBUG_NETWORK if (header != "checkconnection") + { qDebug() << "R:" << f_packet; + } #endif - if (header == "decryptor") { - if (f_contents.size() == 0) - goto end; + if (header == "decryptor") + { + if (content.size() == 0) + { + return; + } // default(legacy) values m_serverdata.set_features(QStringList()); @@ -48,65 +52,76 @@ void AOApplication::server_packet_received(AOPacket *p_packet) f_hdid = get_hdid(); QStringList f_contents = {f_hdid}; - AOPacket *hi_packet = new AOPacket("HI", f_contents); + AOPacket hi_packet("HI", f_contents); send_server_packet(hi_packet); log_to_demo = false; } - else if (header == "ID") { - if (f_contents.size() < 2) - goto end; + else if (header == "ID") + { + if (content.size() < 2) + { + return; + } - client_id = f_contents.at(0).toInt(); - m_serverdata.set_server_software(f_contents.at(1)); + client_id = content.at(0).toInt(); + m_serverdata.set_server_software(content.at(1)); net_manager->server_connected(true); QStringList f_contents = {"AO2", get_version_string()}; - send_server_packet(new AOPacket("ID", f_contents)); + send_server_packet(AOPacket("ID", f_contents)); } - else if (header == "CT") { - if (!courtroom_constructed || f_contents.size() < 2) { - goto end; -} + else if (header == "CT") + { + if (!is_courtroom_constructed() || content.size() < 2) + { + return; + } - if (f_contents.size() == 3) - w_courtroom->append_server_chatmessage( - f_contents.at(0), f_contents.at(1), f_contents.at(2)); + if (content.size() == 3) + { + w_courtroom->append_server_chatmessage(content.at(0), content.at(1), content.at(2)); + } else - w_courtroom->append_server_chatmessage(f_contents.at(0), - f_contents.at(1), "0"); + { + w_courtroom->append_server_chatmessage(content.at(0), content.at(1), "0"); + } } else if (header == "FL") { - QStringList l_features = f_packet.split("#", Qt::SkipEmptyParts); - l_features.removeAll("%"); - l_features.removeAll("FL"); - m_serverdata.set_features(l_features); + m_serverdata.set_features(content); log_to_demo = false; } - else if (header == "PN") { - if (!lobby_constructed || f_contents.size() < 2) - goto end; + else if (header == "PN") + { + if (!is_lobby_constructed() || content.size() < 2) + { + return; + } - w_lobby->set_player_count(f_contents.at(0).toInt(), - f_contents.at(1).toInt()); + w_lobby->set_player_count(content.at(0).toInt(), content.at(1).toInt()); - if (f_contents.size() >= 3) { - w_lobby->set_server_description(f_contents.at(2)); + if (content.size() >= 3) + { + w_lobby->set_server_description(content.at(2)); } log_to_demo = false; } - else if (header == "SI") { - if (!lobby_constructed || f_contents.size() != 3) { - goto end; -} + else if (header == "SI") + { + if (!is_lobby_constructed() || content.size() != 3) + { + return; + } -int char_list_size = f_contents.at(0).toInt(); -int evidence_list_size = f_contents.at(1).toInt(); -int music_list_size = f_contents.at(2).toInt(); + char_list_size = content.at(0).toInt(); + evidence_list_size = content.at(1).toInt(); + music_list_size = content.at(2).toInt(); -if (char_list_size < 0 || evidence_list_size < 0 || music_list_size < 0) - goto end; + if (char_list_size < 0 || evidence_list_size < 0 || music_list_size < 0) + { + return; + } generated_chars = 0; @@ -116,7 +131,8 @@ construct_courtroom(); courtroom_loaded = false; int selected_server = w_lobby->get_selected_server(); -QString server_address = "", server_name = ""; +QString server_address ; +QString server_name ; switch (w_lobby->pageSelected()) { case 0: if (selected_server >= 0 && selected_server < server_list.size()) { @@ -126,8 +142,9 @@ case 0: window_title = server_name; } break; + case 1: { - QVector<server_type> favorite_list = Options::getInstance().favorites(); + QVector<ServerInfo> favorite_list = Options::getInstance().favorites(); if (selected_server >= 0 && selected_server < favorite_list.size()) { auto info = favorite_list.at(selected_server); server_name = info.name; @@ -136,67 +153,81 @@ case 1: { } } break; case 2: - window_title = "Local Demo Recording"; - break; + window_title = "Local Demo Recording"; + break; default: - break; + break; } - if (courtroom_constructed) + if (is_courtroom_constructed()) + { w_courtroom->set_window_title(window_title); + } - AOPacket *f_packet; - - f_packet = new AOPacket("RC"); - send_server_packet(f_packet); + send_server_packet(AOPacket("RC")); // Remove any characters not accepted in folder names for the server_name // here - if (Options::getInstance().logToDemoFileEnabled() && server_name != "Demo playback") { - this->log_filename = QDateTime::currentDateTime().toUTC().toString( - "'logs/" + server_name.remove(QRegularExpression("[\\\\/:*?\"<>|\']")) + - "/'yyyy-MM-dd hh-mm-ss t'.log'"); - this->write_to_file("Joined server " + server_name + " hosted on address " + - server_address + " on " + - QDateTime::currentDateTime().toUTC().toString(), - log_filename, true); + if (Options::getInstance().logToDemoFileEnabled() && server_name != "Demo playback") + { + this->log_filename = QDateTime::currentDateTime().toUTC().toString("'logs/" + server_name.remove(QRegularExpression("[\\\\/:*?\"<>|\']")) + "/'yyyy-MM-dd hh-mm-ss t'.log'"); + this->write_to_file("Joined server " + server_name + " hosted on address " + server_address + " on " + QDateTime::currentDateTime().toUTC().toString(), log_filename, true); } else + { this->log_filename = ""; + } QCryptographicHash hash(QCryptographicHash::Algorithm::Sha256); hash.addData(server_address.toUtf8()); if (Options::getInstance().discordEnabled()) - discord->state_server(server_name.toStdString(), - hash.result().toBase64().toStdString()); + { + discord->state_server(server_name.toStdString(), hash.result().toBase64().toStdString()); + } log_to_demo = false; } - else if (header == "CharsCheck") { - if (!courtroom_constructed) - goto end; + else if (header == "CharsCheck") + { + if (!is_courtroom_constructed()) + { + return; + } - for (int n_char = 0; n_char < f_contents.size(); ++n_char) { - if (f_contents.at(n_char) == "-1") + for (int n_char = 0; n_char < content.size(); ++n_char) + { + if (content.at(n_char) == "-1") + { w_courtroom->set_taken(n_char, true); + } else + { w_courtroom->set_taken(n_char, false); + } } log_to_demo = false; } - else if (header == "SC") { - if (!courtroom_constructed) - goto end; + else if (header == "SC") + { + if (!is_courtroom_constructed()) + { + return; + } w_courtroom->clear_chars(); - for (int n_element = 0; n_element < f_contents.size(); ++n_element) { - QStringList sub_elements = f_contents.at(n_element).split("&"); - - AOPacket::unescape(sub_elements); + for (int n_element = 0; n_element < content.size(); ++n_element) + { + QStringList sub_elements = content.at(n_element).split("&"); + for (QString &sub_element : sub_elements) + { + sub_element = AOPacket::decode(sub_element); + } - char_type f_char; + CharacterSlot f_char; f_char.name = sub_elements.at(0); if (sub_elements.size() >= 2) + { f_char.description = sub_elements.at(1); + } // temporary. the CharsCheck packet sets this properly f_char.taken = false; @@ -205,55 +236,66 @@ case 1: { } if (!courtroom_loaded) - send_server_packet(new AOPacket("RM")); + { + send_server_packet(AOPacket("RM")); + } else + { w_courtroom->character_loading_finished(); + } } - else if (header == "SM") { - if (!courtroom_constructed || courtroom_loaded) - goto end; + else if (header == "SM") + { + if (!is_courtroom_constructed() || courtroom_loaded) + { + return; + } bool musics_time = false; int areas = 0; - for (int n_element = 0; n_element < f_contents.size(); ++n_element) { + for (int n_element = 0; n_element < content.size(); ++n_element) { + ++loaded_music; if (musics_time) { - w_courtroom->append_music(f_contents.at(n_element)); + w_courtroom->append_music(content.at(n_element)); } - else { - if (f_contents.at(n_element).endsWith(".wav") || - f_contents.at(n_element).endsWith(".mp3") || - f_contents.at(n_element).endsWith(".mp4") || - f_contents.at(n_element).endsWith(".ogg") || - f_contents.at(n_element).endsWith(".opus")) { + else + { + if (content.at(n_element).endsWith(".wav") || content.at(n_element).endsWith(".mp3") || content.at(n_element).endsWith(".mp4") || content.at(n_element).endsWith(".ogg") || content.at(n_element).endsWith(".opus")) + { musics_time = true; w_courtroom->fix_last_area(); - w_courtroom->append_music(f_contents.at(n_element)); + w_courtroom->append_music(content.at(n_element)); areas--; } - else { - w_courtroom->append_area(f_contents.at(n_element)); + else + { + w_courtroom->append_area(content.at(n_element)); areas++; } } } - for (int area_n = 0; area_n < areas; area_n++) { + for (int area_n = 0; area_n < areas; area_n++) + { w_courtroom->arup_append(0, "Unknown", "Unknown", "Unknown"); } - send_server_packet(new AOPacket("RD")); + send_server_packet(AOPacket("RD")); log_to_demo = false; } else if (header == "FM") // Fetch music ONLY { - if (!courtroom_constructed) - goto end; + if (!is_courtroom_constructed()) + { + return; + } w_courtroom->clear_music(); - for (int n_element = 0; n_element < f_contents.size(); ++n_element) { - w_courtroom->append_music(f_contents.at(n_element)); + for (int n_element = 0; n_element < content.size(); ++n_element) + { + w_courtroom->append_music(content.at(n_element)); } w_courtroom->list_music(); @@ -261,23 +303,29 @@ case 1: { } else if (header == "FA") // Fetch areas ONLY { - if (!courtroom_constructed) - goto end; + if (!is_courtroom_constructed()) + { + return; + } w_courtroom->clear_areas(); w_courtroom->arup_clear(); - for (int n_element = 0; n_element < f_contents.size(); ++n_element) { - w_courtroom->append_area(f_contents.at(n_element)); + for (int n_element = 0; n_element < content.size(); ++n_element) + { + w_courtroom->append_area(content.at(n_element)); w_courtroom->arup_append(0, "Unknown", "Unknown", "Unknown"); } w_courtroom->list_areas(); log_to_demo = false; } - else if (header == "DONE") { - if (!courtroom_constructed) - goto end; + else if (header == "DONE") + { + if (!is_courtroom_constructed()) + { + return; + } w_courtroom->character_loading_finished(); w_courtroom->done_received(); @@ -287,85 +335,116 @@ case 1: { destruct_lobby(); log_to_demo = false; } - else if (header == "BN") { - if (!courtroom_constructed || f_contents.isEmpty()) - goto end; + else if (header == "BN") + { + if (!is_courtroom_constructed() || content.isEmpty()) + { + return; + } - if (f_contents.size() >= 2) { + if (content.size() >= 2) + { // We have a pos included in the background packet! - if (!f_contents.at(1).isEmpty()) - //Not touching it when its empty. - w_courtroom->set_side(f_contents.at(1)); + if (!content.at(1).isEmpty()) + { + // Not touching it when its empty. + w_courtroom->set_side(content.at(1)); + } } - w_courtroom->set_background(f_contents.at(0), f_contents.size() >= 2); + w_courtroom->set_background(content.at(0), content.size() >= 2); } - else if (header == "SP") { - if (!courtroom_constructed || f_contents.isEmpty()) - goto end; + else if (header == "SP") + { + if (!is_courtroom_constructed() || content.isEmpty()) + { + return; + } // We were sent a "set position" packet - w_courtroom->set_side(f_contents.at(0)); + w_courtroom->set_side(content.at(0)); } else if (header == "SD") // Send pos dropdown { - if (!courtroom_constructed || f_contents.isEmpty()) - goto end; + if (!is_courtroom_constructed() || content.isEmpty()) + { + return; + } - w_courtroom->set_pos_dropdown(f_contents.at(0).split("*")); + w_courtroom->set_pos_dropdown(content.at(0).split("*")); } // server accepting char request(CC) packet - else if (header == "PV") { - if (!courtroom_constructed || f_contents.size() < 3) - goto end; + else if (header == "PV") + { + if (!is_courtroom_constructed() || content.size() < 3) + { + return; + } // For some reason, args 0 and 1 are not used (from tsu3 they're client ID and a string "CID") w_courtroom->enter_courtroom(); w_courtroom->set_courtroom_size(); - w_courtroom->update_character(f_contents.at(2).toInt()); + w_courtroom->update_character(content.at(2).toInt()); } - else if (header == "MS") { - if (courtroom_constructed && courtroom_loaded) + else if (header == "MS") + { + if (is_courtroom_constructed() && courtroom_loaded) { - w_courtroom->chatmessage_enqueue(p_packet->get_contents()); + w_courtroom->chatmessage_enqueue(packet.content()); } } - else if (header == "MC") { - if (courtroom_constructed && courtroom_loaded) + else if (header == "MC") + { + if (is_courtroom_constructed() && courtroom_loaded) { - w_courtroom->handle_song(&p_packet->get_contents()); + w_courtroom->handle_song(&packet.content()); } } - else if (header == "RT") { - if (f_contents.isEmpty()) - goto end; - if (courtroom_constructed) { - if (f_contents.size() == 1) - w_courtroom->handle_wtce(f_contents.at(0), 0); - else if (f_contents.size() >= 2) - w_courtroom->handle_wtce(f_contents.at(0), f_contents.at(1).toInt()); + else if (header == "RT") + { + if (content.isEmpty()) + { + return; + } + if (is_courtroom_constructed()) + { + if (content.size() == 1) + { + w_courtroom->handle_wtce(content.at(0), 0); + } + else if (content.size() >= 2) + { + w_courtroom->handle_wtce(content.at(0), content.at(1).toInt()); + } } } - else if (header == "HP") { - if (courtroom_constructed && f_contents.size() >= 2) + else if (header == "HP") + { + if (is_courtroom_constructed() && content.size() >= 2) { - w_courtroom->set_hp_bar(f_contents.at(0).toInt(), - f_contents.at(1).toInt()); + w_courtroom->set_hp_bar(content.at(0).toInt(), content.at(1).toInt()); } } - else if (header == "LE") { - if (courtroom_constructed) { - QVector<evi_type> f_evi_list; + else if (header == "LE") + { + if (is_courtroom_constructed()) + { + QVector<EvidenceItem> f_evi_list; - for (QString f_string : f_contents_encoded) { + for (QString f_string : packet.content()) + { QStringList sub_contents = f_string.split("&"); - if (sub_contents.size() < 3) + { continue; + } // decoding has to be done here instead of on reception // because this packet uses & as a delimiter for some reason - AOPacket::unescape(sub_contents); + for (QString &data : sub_contents) + { + data = AOPacket::decode(data); + } - evi_type f_evi; + EvidenceItem f_evi; f_evi.name = sub_contents.at(0); f_evi.description = sub_contents.at(1); f_evi.image = sub_contents.at(2); @@ -376,90 +455,113 @@ case 1: { w_courtroom->set_evidence_list(f_evi_list); } } - else if (header == "ARUP") { - if (courtroom_constructed && !f_contents.isEmpty()) { - int arup_type = f_contents.at(0).toInt(); - for (int n_element = 1; n_element < f_contents.size(); n_element++) { - w_courtroom->arup_modify(arup_type, n_element - 1, - f_contents.at(n_element)); + else if (header == "ARUP") + { + if (is_courtroom_constructed() && !content.isEmpty()) + { + int arup_type = content.at(0).toInt(); + for (int n_element = 1; n_element < content.size(); n_element++) + { + w_courtroom->arup_modify(arup_type, n_element - 1, content.at(n_element)); } w_courtroom->list_areas(); } log_to_demo = false; } - else if (header == "IL") { - if (courtroom_constructed && !f_contents.isEmpty()) - w_courtroom->set_ip_list(f_contents.at(0)); + else if (header == "IL") + { + if (is_courtroom_constructed() && !content.isEmpty()) + { + w_courtroom->set_ip_list(content.at(0)); + } log_to_demo = false; } - else if (header == "MU") { - if (courtroom_constructed && !f_contents.isEmpty()) - w_courtroom->set_mute(true, f_contents.at(0).toInt()); + else if (header == "MU") + { + if (is_courtroom_constructed() && !content.isEmpty()) + { + w_courtroom->set_mute(true, content.at(0).toInt()); + } log_to_demo = false; } - else if (header == "UM") { - if (courtroom_constructed && !f_contents.isEmpty()) { - w_courtroom->set_mute(false, f_contents.at(0).toInt()); - log_to_demo = false; -} + else if (header == "UM") + { + if (is_courtroom_constructed() && !content.isEmpty()) + { + w_courtroom->set_mute(false, content.at(0).toInt()); + log_to_demo = false; + } } - else if (header == "BB") { - if (courtroom_constructed && !f_contents.isEmpty()) { - call_notice(f_contents.at(0)); + else if (header == "BB") + { + if (is_courtroom_constructed() && !content.isEmpty()) + { + call_notice(content.at(0)); } log_to_demo = false; } - else if (header == "KK") { - if (courtroom_constructed && !f_contents.isEmpty()) { - call_notice(tr("You have been kicked from the server.\nReason: %1") - .arg(f_contents.at(0))); + else if (header == "KK") + { + if (is_courtroom_constructed() && !content.isEmpty()) + { + call_notice(tr("You have been kicked from the server.\nReason: %1").arg(content.at(0))); construct_lobby(); destruct_courtroom(); } log_to_demo = false; } - else if (header == "KB") { - if (courtroom_constructed && !f_contents.isEmpty()) { - call_notice(tr("You have been banned from the server.\nReason: %1") - .arg(f_contents.at(0))); + else if (header == "KB") + { + if (is_courtroom_constructed() && !content.isEmpty()) + { + call_notice(tr("You have been banned from the server.\nReason: %1").arg(content.at(0))); construct_lobby(); destruct_courtroom(); } log_to_demo = false; } - else if (header == "BD") { - if (f_contents.isEmpty()) { - goto end; + else if (header == "BD") + { + if (content.isEmpty()) + { + return; } - call_notice( - tr("You are banned on this server.\nReason: %1").arg(f_contents.at(0))); + call_notice(tr("You are banned on this server.\nReason: %1").arg(content.at(0))); log_to_demo = false; } - else if (header == "ZZ") { - if (courtroom_constructed && !f_contents.isEmpty()) - w_courtroom->mod_called(f_contents.at(0)); + else if (header == "ZZ") + { + if (is_courtroom_constructed() && !content.isEmpty()) + { + w_courtroom->mod_called(content.at(0)); + } } - else if (header == "TI") { // Timer packet - if (!courtroom_constructed || f_contents.size() < 2) - goto end; + else if (header == "TI") + { // Timer packet + if (!is_courtroom_constructed() || content.size() < 2) + { + return; + } // Timer ID is reserved as argument 0 - int id = f_contents.at(0).toInt(); + int id = content.at(0).toInt(); // Type 0 = start/resume/sync timer at time // Type 1 = pause timer at time // Type 2 = show timer // Type 3 = hide timer - int type = f_contents.at(1).toInt(); + int type = content.at(1).toInt(); if (type == 0 || type == 1) { - if (f_contents.size() < 3) - goto end; + if (content.size() < 3) + { + return; + } // The time as displayed on the clock, in milliseconds. // If the number received is negative, stop the timer. - qint64 timer_value = f_contents.at(2).toLongLong(); + qint64 timer_value = content.at(2).toLongLong(); if (timer_value > 0) { if (type == 0) @@ -479,100 +581,115 @@ case 1: { } } else if (type == 2) + { w_courtroom->set_clock_visibility(id, true); + } else if (type == 3) + { w_courtroom->set_clock_visibility(id, false); + } } - else if (header == "CHECK") { - if (!courtroom_constructed) - goto end; + else if (header == "CHECK") + { + if (!is_courtroom_constructed()) + { + return; + } qint64 ping_time = w_courtroom->pong(); qDebug() << "ping:" << ping_time; if (ping_time != -1) + { latency = ping_time; + } log_to_demo = false; } // Subtheme packet - else if (header == "ST") { - if (!courtroom_constructed || f_contents.isEmpty()) - goto end; + else if (header == "ST") + { + if (!is_courtroom_constructed() || content.isEmpty()) + { + return; + } // Subtheme reserved as argument 0 - subtheme = f_contents.at(0); + subtheme = content.at(0); // Check if we have subthemes set to "server" if (Options::getInstance().settingsSubTheme().toLower() != "server") + { // We don't. Simply acknowledge the subtheme sent by the server, but don't do anything else. return; + } // Reload theme request - if (f_contents.size() > 1 && f_contents.at(1) == "1") { + if (content.size() > 1 && content.at(1) == "1") + { Options::getInstance().setServerSubTheme(subtheme); w_courtroom->on_reload_theme_clicked(); } } // Auth packet else if (header == "AUTH") { - if (!courtroom_constructed || + if (!is_courtroom_constructed() || !m_serverdata.get_feature(server::BASE_FEATURE_SET::AUTH_PACKET) || - f_contents.isEmpty()) { - goto end; + contents.isEmpty()) { + return; } bool ok; - int authenticated = f_contents.at(0).toInt(&ok); - if (!ok) { - qWarning() << "Malformed AUTH packet! Contents:" << f_contents.at(0); + int authenticated = content.at(0).toInt(&ok); + if (!ok) + { + qWarning() << "Malformed AUTH packet! Contents:" << content.at(0); } w_courtroom->on_authentication_state_received(authenticated); log_to_demo = false; } - else if (header == "JD") { - if (!courtroom_constructed || f_contents.isEmpty()) { - goto end; + else if (header == "JD") + { + if (!is_courtroom_constructed() || content.isEmpty()) + { + return; } bool ok; - Courtroom::JudgeState state = static_cast<Courtroom::JudgeState>(f_contents.at(0).toInt(&ok)); - if (!ok) { - goto end; // ignore malformed packet + Courtroom::JudgeState state = static_cast<Courtroom::JudgeState>(content.at(0).toInt(&ok)); + if (!ok) + { + return; // ignore malformed packet } w_courtroom->set_judge_state(state); - if (w_courtroom->get_judge_state() != Courtroom::POS_DEPENDENT) { // If we receive JD -1, it means the server asks us to fall back to client-side judge buttons behavior + if (w_courtroom->get_judge_state() != Courtroom::POS_DEPENDENT) + { // If we receive JD -1, it means the server asks us to fall back to client-side judge buttons behavior w_courtroom->show_judge_controls(w_courtroom->get_judge_state() == Courtroom::SHOW_CONTROLS); } - else { + else + { w_courtroom->set_judge_buttons(); // client-side judge behavior } } - //AssetURL Packet - else if (header == "ASS") { - if (f_contents.size() > 1 || f_contents.isEmpty()) { // This can never be more than one link. - goto end; + // AssetURL Packet + else if (header == "ASS") + { + if (content.size() > 1 || content.isEmpty()) + { // This can never be more than one link. + return; } - m_serverdata.set_asset_url(f_contents.at(0)); + m_serverdata.set_asset_url(contents.at(0)); } - if (log_to_demo) { - append_to_demofile(f_packet_encoded); + if (log_to_demo) + { + append_to_demofile(packet.toString(true)); } - -end: - - delete p_packet; } -void AOApplication::send_server_packet(AOPacket *p_packet) +void AOApplication::send_server_packet(AOPacket p_packet) { - // ***NEVER*** send an unencoded packet. - p_packet->net_encode(); - - QString f_packet = p_packet->to_string(); + QString f_packet = p_packet.toString(); #ifdef DEBUG_NETWORK - qDebug() << "S:" << f_packet; + qDebug() << "S:" << p_packet.to_string(); #endif - net_manager->ship_server_packet(f_packet); - - delete p_packet; + net_manager->ship_server_packet(p_packet); } |
