Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
36a09bd
initial commit with horrible code dupcliation haha lol
Crystalwarrior Oct 21, 2020
a11d03c
implement groundwork for internal demo server
Nov 11, 2020
798e84e
add core playback functionality
Nov 13, 2020
88a1199
make it work kinda by including SC packet in demo
Nov 13, 2020
c4b4c1a
Add a file dialog for loading a demo file instead of a hardcoded path
Crystalwarrior Nov 14, 2020
6795f22
Change /play to > in OOC to begin playback or skip to next element
Crystalwarrior Nov 14, 2020
eb8e982
Clear demo data when loading a demo file to prevent stacking demos
Crystalwarrior Nov 14, 2020
f3003cc
Properly disconnect the client when sending the request for file brow…
Crystalwarrior Nov 14, 2020
917e0ec
Fix append_to_file newlining even if file didn't exist prior to calli…
Crystalwarrior Nov 14, 2020
0069dcd
Add a very scuffed exception to not log or demo record anything that …
Crystalwarrior Nov 15, 2020
b527118
Reduce invalid file spam by checking for non-logging server better
Crystalwarrior Nov 15, 2020
a2eaccc
Fix the client crashing when receiving loading packets etc. at runtim…
Crystalwarrior Nov 15, 2020
2bc9991
Preserve newlines for demo packets such as "CT", "MS" etc.
Crystalwarrior Nov 15, 2020
20024e7
Implement /max_wait, /min_wait for adjusting the maximum and minimum …
Crystalwarrior Nov 15, 2020
5f71d33
Empty music list
Crystalwarrior Nov 15, 2020
07f347d
Allow -1 character ID or character ID that does not fit into the loca…
Crystalwarrior Nov 15, 2020
db54e80
Properly handle demo files without SC packet to dictate which chars e…
Crystalwarrior Nov 15, 2020
ec7775b
Fix logs bleeding into each other if you disabled logging or you join…
Crystalwarrior Nov 15, 2020
3bc4abe
Prevent logging even if log_filename is defined because a user might …
Crystalwarrior Nov 15, 2020
54e2a96
Fix custom shownames not appearing in the IC logs
Crystalwarrior Nov 16, 2020
0241c44
Set up new logic for max_wait, meaning that dead air being skipped is…
Crystalwarrior Nov 17, 2020
aee47d4
Better logic for min_wait to only affect important packets (IC Chat)
Crystalwarrior Nov 17, 2020
662a9e2
Merge branch 'master' into feature/demo-playback
Crystalwarrior Jan 8, 2021
16454df
Fix encoding not being performed on packets that are saved to the .de…
Crystalwarrior Jan 9, 2021
64f3d23
Merge branch 'master' into feature/demo-playback
Crystalwarrior Jan 12, 2021
1754674
Fix a weird setup in courtroom.cpp that happened out of the merge and…
Crystalwarrior Jan 12, 2021
55d2f6a
add missing feature flags to the demoserver
Crystalwarrior Jan 12, 2021
a2dbd0e
use random port
stonedDiscord Jan 13, 2021
365e018
move writing to the demo file to a function
stonedDiscord Jan 13, 2021
ef19441
only listen on localhost
Jan 13, 2021
eefbf87
remove copypasta
stonedDiscord Jan 13, 2021
d534ae3
Merge branch 'feature/demo-playback' of https://github.com/AttorneyOn…
stonedDiscord Jan 13, 2021
4082b62
add a help to the demo server
stonedDiscord Jan 13, 2021
9c7ace7
fix empty demo disconnecting the server
stonedDiscord Jan 13, 2021
e42ba82
tell the user how to begin
stonedDiscord Jan 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions include/aoapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "aopacket.h"
#include "datatypes.h"
#include "demoserver.h"
#include "discord_rich_presence.h"

#include "bass.h"
Expand All @@ -27,6 +28,8 @@
#include <QStringList>
#include <QTextStream>

#include <QElapsedTimer>

class NetworkManager;
class Lobby;
class Courtroom;
Expand Down Expand Up @@ -261,6 +264,9 @@ class AOApplication : public QApplication {
// directory if it doesn't exist.
bool append_to_file(QString p_text, QString p_file, bool make_dir = false);

// Append to the currently open demo file if there is one
void append_to_demofile(QString packet_string);

// Appends the argument string to serverlist.txt
void write_to_serverlist_txt(QString p_line);

Expand Down Expand Up @@ -458,6 +464,9 @@ class AOApplication : public QApplication {
void *user);
static void doBASSreset();

QElapsedTimer demo_timer;
DemoServer* demo_server = nullptr;

private:
const int RELEASE = 2;
const int MAJOR_VERSION = 8;
Expand Down
2 changes: 1 addition & 1 deletion include/aopacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AOPacket {

QString get_header() { return m_header; }
QStringList &get_contents() { return m_contents; }
QString to_string();
QString to_string(bool encoded = false);

void net_encode();
void net_decode();
Expand Down
55 changes: 55 additions & 0 deletions include/demoserver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#ifndef DEMOSERVER_H
#define DEMOSERVER_H

#include "aopacket.h"

#include <QDebug>
#include <QObject>
#include <QQueue>
#include <QTcpServer>
#include <QTcpSocket>
#include <QTimer>
#include <QFileDialog>

class DemoServer : public QObject
{
Q_OBJECT
public:
explicit DemoServer(QObject *parent = nullptr);

bool server_started = false;
int port = 27088;
int max_wait = -1;
int min_wait = -1;

private:
void handle_packet(AOPacket packet);
void load_demo(QString filename);

QTcpServer* tcp_server;
QTcpSocket* client_sock = nullptr;
bool client_connected = false;
bool partial_packet = false;
QString temp_packet = "";
QQueue<QString> demo_data;
QString sc_packet;
int num_chars = 0;
QString p_path;
QTimer *timer;
int elapsed_time = 0;

private slots:
void accept_connection();
void destroy_connection();
void recv_data();
void client_disconnect();
void playback();

public slots:
void start_server();

signals:

};

#endif // DEMOSERVER_H
4 changes: 4 additions & 0 deletions src/aoapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ void AOApplication::construct_lobby()
if (is_discord_enabled())
discord->state_lobby();

if (demo_server)
demo_server->deleteLater();
demo_server = new DemoServer();

w_lobby->show();
}

Expand Down
10 changes: 8 additions & 2 deletions src/aopacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ AOPacket::AOPacket(QString p_packet_string)
m_contents = packet_contents.mid(1, packet_contents.size()-2); // trims %
}

QString AOPacket::to_string()
QString AOPacket::to_string(bool encoded)
{
return m_header + "#" + m_contents.join("#") + "#%";
QStringList contents = m_contents;
if (encoded)
contents.replaceInStrings("#", "<num>")
.replaceInStrings("%", "<percent>")
.replaceInStrings("$", "<dollar>")
.replaceInStrings("&", "<and>");
return m_header + "#" + contents.join("#") + "#%";
}

void AOPacket::net_encode()
Expand Down
26 changes: 13 additions & 13 deletions src/courtroom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1147,13 +1147,20 @@ void Courtroom::done_received()
objection_player->set_volume(0);
blip_player->set_volume(0);

set_char_select_page();
if (char_list.size() > 0)
{
set_char_select_page();
set_char_select();
}
else
{
update_character(m_cid);
enter_courtroom();
}

set_mute_list();
set_pair_list();

set_char_select();

show();

ui_spectator->show();
Expand Down Expand Up @@ -1267,8 +1274,6 @@ void Courtroom::set_pos_dropdown(QStringList pos_dropdowns)
ui_pos_dropdown->addItems(pos_dropdown_list);
// Unblock the signals so the element can be used for setting pos again
ui_pos_dropdown->blockSignals(false);

qDebug() << pos_dropdown_list;
}

void Courtroom::update_character(int p_cid)
Expand Down Expand Up @@ -1311,7 +1316,6 @@ void Courtroom::update_character(int p_cid)
set_sfx_dropdown();
set_effects_dropdown();

qDebug() << "update_character called";
if (newchar) // Avoid infinite loop of death and suffering
set_iniswap_dropdown();

Expand Down Expand Up @@ -2507,7 +2511,7 @@ void Courtroom::play_char_sfx(QString sfx_name)
void Courtroom::initialize_chatbox()
{
int f_charid = m_chatmessage[CHAR_ID].toInt();
if (f_charid >= 0 &&
if (f_charid >= 0 && f_charid < char_list.size() &&
(m_chatmessage[SHOWNAME].isEmpty() || !ui_showname_enable->isChecked())) {
QString real_name = char_list.at(f_charid).name;

Expand Down Expand Up @@ -2955,7 +2959,7 @@ void Courtroom::log_ic_text(QString p_name, QString p_showname,
{
chatlogpiece log_entry(p_name, p_showname, p_message, p_action, p_color);
ic_chatlog_history.append(log_entry);
if (ao_app->get_auto_logging_enabled())
if (ao_app->get_auto_logging_enabled() && !ao_app->log_filename.isEmpty())
ao_app->append_to_file(log_entry.get_full(), ao_app->log_filename, true);

while (ic_chatlog_history.size() > log_maximum_blocks &&
Expand Down Expand Up @@ -3120,7 +3124,7 @@ void Courtroom::play_preanim(bool immediate)
else
anim_state = 1;
preanim_done();
qDebug() << "could not find " + anim_to_find;
qDebug() << "W: could not find " + anim_to_find;
return;
}

Expand Down Expand Up @@ -3782,9 +3786,6 @@ void Courtroom::on_ooc_return_pressed()
{
QString ooc_message = ui_ooc_chat_message->text();

if (ooc_message == "" || ui_ooc_chat_name->text() == "")
return;

if (ooc_message.startsWith("/pos")) {
if (ooc_message == "/pos jud") {
toggle_judge_buttons(true);
Expand Down Expand Up @@ -4737,7 +4738,6 @@ void Courtroom::on_area_list_double_clicked(QTreeWidgetItem *p_item, int column)
QStringList packet_contents;
packet_contents.append(p_area);
packet_contents.append(QString::number(m_cid));
qDebug() << packet_contents;
ao_app->send_server_packet(new AOPacket("MC", packet_contents), false);
}

Expand Down
Loading