Skip to content

Commit bdbcfcc

Browse files
authored
Merge branch 'master' into charlist-perf
2 parents d10ac87 + 22a9414 commit bdbcfcc

4 files changed

Lines changed: 49 additions & 11 deletions

File tree

src/aoapplication.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void AOApplication::construct_lobby()
6262
{
6363
demo_server->deleteLater();
6464
}
65-
demo_server = new DemoServer(this);
65+
6666
w_lobby->show();
6767
}
6868

src/courtroom.cpp

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3506,6 +3506,29 @@ void Courtroom::handle_ic_speaking()
35063506
start_chat_ticking();
35073507
}
35083508

3509+
struct PauseInfo
3510+
{
3511+
int ms;
3512+
int digit_count;
3513+
};
3514+
3515+
static std::optional<PauseInfo> parse_pause_duration(const QString &text, int start_pos)
3516+
{
3517+
int pos = start_pos;
3518+
while (pos < text.length() && text[pos].isDigit())
3519+
{
3520+
pos++;
3521+
}
3522+
3523+
if (pos == start_pos)
3524+
{
3525+
return PauseInfo{1000, 0};
3526+
}
3527+
3528+
int value = qMin(10000, text.mid(start_pos, pos - start_pos).toInt());
3529+
return std::optional<PauseInfo>{PauseInfo{value, pos - start_pos}};
3530+
}
3531+
35093532
QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos, int default_color)
35103533
{
35113534
QString p_text_escaped;
@@ -3723,6 +3746,13 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos, int
37233746
if (f_character == "s" || f_character == "f" || f_character == "p") // screenshake/flash/pause
37243747
{
37253748
skip = true;
3749+
if (f_character == "p") // also skip any following digits
3750+
{
3751+
if (auto info = parse_pause_duration(p_text, check_pos + f_char_bytes))
3752+
{
3753+
check_pos += info->digit_count;
3754+
}
3755+
}
37263756
}
37273757

37283758
parse_escape_seq = false;
@@ -4420,6 +4450,13 @@ void Courtroom::chat_tick()
44204450
if (f_character == "p")
44214451
{
44224452
formatting_char = true;
4453+
if (auto info = parse_pause_duration(f_message, tick_pos))
4454+
{
4455+
tick_pos += info->digit_count;
4456+
real_tick_pos += f_char_length;
4457+
chat_tick_timer->start(info->ms);
4458+
return;
4459+
}
44234460
}
44244461
next_character_is_not_special = false;
44254462
}
@@ -4441,11 +4478,6 @@ void Courtroom::chat_tick()
44414478

44424479
if ((msg_delay <= 0 && tick_pos < f_message.size() - 1) || formatting_char)
44434480
{
4444-
if (f_character == "p")
4445-
{
4446-
chat_tick_timer->start(100); // wait the pause lol
4447-
}
4448-
else
44494481
{
44504482
chat_tick_timer->start(0); // Don't bother rendering anything out as we're
44514483
// doing the SPEED. (there's latency otherwise)

src/lobby.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,13 +433,19 @@ void Lobby::on_demo_clicked(QTreeWidgetItem *item, int column)
433433
return;
434434
}
435435

436+
if (ao_app->demo_server)
437+
{
438+
ao_app->demo_server->deleteLater();
439+
}
440+
ao_app->demo_server = new DemoServer(this);
441+
436442
QString l_filepath = (get_app_path() + "/logs/%1/%2").arg(item->data(0, Qt::DisplayRole).toString(), item->data(1, Qt::DisplayRole).toString());
437443
ao_app->demo_server->start_server();
438-
ServerInfo demo_server;
439-
demo_server.address = "127.0.0.1";
440-
demo_server.port = ao_app->demo_server->port();
444+
ServerInfo demo_server_connection;
445+
demo_server_connection.address = "127.0.0.1";
446+
demo_server_connection.port = ao_app->demo_server->port();
441447
ao_app->demo_server->set_demo_file(l_filepath);
442-
net_manager->connect_to_server(demo_server);
448+
net_manager->connect_to_server(demo_server_connection);
443449
}
444450

445451
void Lobby::onReloadThemeRequested()

src/packet_distribution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ void AOApplication::server_packet_received(AOPacket packet)
167167

168168
QString server_name_stripped = server_name;
169169
static QRegularExpression illegal_filename_chars("[\\\\/:*?\"<>|\']");
170-
if (Options::getInstance().logToDemoFileEnabled() && !demo_server)
170+
if (Options::getInstance().logToDemoFileEnabled() || !demo_server)
171171
{
172172
this->log_filename = QDateTime::currentDateTime().toUTC().toString("'logs/" + server_name_stripped.remove(illegal_filename_chars) + "/'yyyy-MM-dd hh-mm-ss t'.log'");
173173
this->write_to_file("Joined server " + server_name_stripped + " hosted on address " + server_address + " on " + QDateTime::currentDateTime().toUTC().toString(), log_filename, true);

0 commit comments

Comments
 (0)