aboutsummaryrefslogtreecommitdiff
path: root/src/courtroom.cpp
diff options
context:
space:
mode:
authoroldmud0 <oldmud0@users.noreply.github.com>2021-01-09 01:18:19 -0600
committeroldmud0 <oldmud0@users.noreply.github.com>2021-01-09 01:18:19 -0600
commitde3533fbf2615a40efc60c9ed2e96f1a3b5da3c1 (patch)
tree484c45a32b32a87cfa8874d53b17f00c030bab6c /src/courtroom.cpp
parent610510eb7b13475f0625d69e9a8e2b1d14669198 (diff)
Rework timer and ping logic
The timer's time as received by the server is clarified to be the actual numerical time, in milliseconds, to be shown on the clock.
Diffstat (limited to 'src/courtroom.cpp')
-rw-r--r--src/courtroom.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/courtroom.cpp b/src/courtroom.cpp
index f4e31647..c2fcf9b8 100644
--- a/src/courtroom.cpp
+++ b/src/courtroom.cpp
@@ -8,7 +8,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
qsrand(static_cast<uint>(QDateTime::currentMSecsSinceEpoch() / 1000));
keepalive_timer = new QTimer(this);
- keepalive_timer->start(1000);
+ keepalive_timer->start(45000);
chat_tick_timer = new QTimer(this);
@@ -114,6 +114,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_clock = new AOClockLabel(this);
ui_clock->setAttribute(Qt::WA_TransparentForMouseEvents);
+ ui_clock->hide();
ui_ic_chat_name = new QLineEdit(this);
ui_ic_chat_name->setFrame(false);
@@ -4672,10 +4673,20 @@ void Courtroom::on_switch_area_music_clicked()
void Courtroom::ping_server()
{
ping_timer.start();
+ is_pinging = true;
ao_app->send_server_packet(
new AOPacket("CH#" + QString::number(m_cid) + "#%"));
}
+qint64 Courtroom::pong()
+{
+ if (!is_pinging)
+ return -1;
+
+ is_pinging = false;
+ return ping_timer.elapsed();
+}
+
void Courtroom::on_casing_clicked()
{
if (ao_app->casing_alerts_enabled) {
@@ -4740,6 +4751,11 @@ void Courtroom::stop_clock()
ui_clock->stop();
}
+void Courtroom::set_clock_visibility(bool visible)
+{
+ ui_clock->setVisible(visible);
+}
+
Courtroom::~Courtroom()
{
delete music_player;