diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/aoapplication.cpp | 7 | ||||
| -rw-r--r-- | src/lobby.cpp | 5 | ||||
| -rw-r--r-- | src/packet_distribution.cpp | 5 |
3 files changed, 11 insertions, 6 deletions
diff --git a/src/aoapplication.cpp b/src/aoapplication.cpp index ecfd97a..f253a5a 100644 --- a/src/aoapplication.cpp +++ b/src/aoapplication.cpp @@ -65,11 +65,6 @@ void AOApplication::construct_lobby() discord->state_lobby(); } - if (demo_server) - { - demo_server->deleteLater(); - } - demo_server = new DemoServer(this); w_lobby->show(); } @@ -120,6 +115,8 @@ void AOApplication::destruct_courtroom() return; } + delete demo_server; + demo_server = nullptr; delete w_courtroom; w_courtroom = nullptr; } diff --git a/src/lobby.cpp b/src/lobby.cpp index a283d4e..6c0e551 100644 --- a/src/lobby.cpp +++ b/src/lobby.cpp @@ -443,6 +443,11 @@ void Lobby::on_demo_clicked(QTreeWidgetItem *item, int column) } QString l_filepath = (get_app_path() + "/logs/%1/%2").arg(item->data(0, Qt::DisplayRole).toString(), item->data(1, Qt::DisplayRole).toString()); + + if (ao_app->demo_server == nullptr) + { + ao_app->demo_server = new DemoServer(ao_app); + } ao_app->demo_server->start_server(); ServerInfo demo_server; demo_server.address = "127.0.0.1"; diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 69448d4..6e7dd72 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -6,6 +6,7 @@ #include "lobby.h" #include "networkmanager.h" #include "options.h" +#include "file_functions.h" void AOApplication::append_to_demofile(QString packet_string) { @@ -176,7 +177,9 @@ void AOApplication::server_packet_received(AOPacket packet) static QRegularExpression illegal_filename_chars("[\\\\/:*?\"<>|\']"); if (Options::getInstance().logToDemoFileEnabled() && !demo_server) { - this->log_filename = QDateTime::currentDateTime().toUTC().toString("'logs/" + server_name_stripped.remove(illegal_filename_chars) + "/'yyyy-MM-dd hh-mm-ss t'.log'"); + server_name_stripped.remove(illegal_filename_chars); + QString timestamp = QDateTime::currentDateTime().toUTC().toString("yyyy-MM-dd hh-mm-ss t"); + this->log_filename = QDir(get_app_path()).filePath("logs/" + server_name_stripped + "/" + timestamp + ".log"); this->write_to_file("Joined server " + server_name_stripped + " hosted on address " + server_address + " on " + QDateTime::currentDateTime().toUTC().toString(), log_filename, true); } else |
