From 18efacb8861f8ed0a700a20eadb1508de855d568 Mon Sep 17 00:00:00 2001 From: in1tiate Date: Sat, 6 Mar 2021 00:41:10 -0600 Subject: [PATCH] set timers when you join and change areas --- src/aoclient.cpp | 10 ++++++++++ src/commands.cpp | 2 +- src/packets.cpp | 17 +++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/aoclient.cpp b/src/aoclient.cpp index 344eebf..7d3a90c 100644 --- a/src/aoclient.cpp +++ b/src/aoclient.cpp @@ -130,6 +130,16 @@ void AOClient::changeArea(int new_area) server->areas[current_area]->characters_taken[current_char] = true; server->updateCharsTaken(server->areas[current_area]); } + for (QTimer* timer : server->areas[current_area]->timers) { + int timer_id = server->areas[current_area]->timers.indexOf(timer) + 1; + if (timer->isActive()) { + sendPacket("TI", {QString::number(timer_id), QString::number(2)}); + sendPacket("TI", {QString::number(timer_id), QString::number(0), QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(timer->remainingTime())))}); + } + else { + sendPacket("TI", {QString::number(timer_id), QString::number(3)}); + } + } sendServerMessage("You moved to area " + server->area_names[current_area]); if (server->areas[current_area]->locked == AreaData::LockStatus::SPECTATABLE) sendServerMessage("Area " + server->area_names[current_area] + " is spectate-only; to chat IC you will need to be invited by the CM."); diff --git a/src/commands.cpp b/src/commands.cpp index 7b6f7e0..6abee2f 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -563,7 +563,7 @@ void AOClient::cmdTimer(int argc, QStringList argv) timers.append("Currently active timers:"); QTimer* global_timer = server->timer; if (global_timer->isActive()) { - QTime current_time(0, 0, 0, global_timer->remainingTime()); + QTime current_time = QTime(0,0).addMSecs(global_timer->remainingTime()); timers.append("Global timer is at " + current_time.toString("hh:mm:ss.zzz")); } for (QTimer* timer : area->timers) { diff --git a/src/packets.cpp b/src/packets.cpp index 3bc7f30..619849d 100644 --- a/src/packets.cpp +++ b/src/packets.cpp @@ -143,6 +143,23 @@ void AOClient::pktSelectChar(AreaData* area, int argc, QStringList argv, AOPacke server->updateCharsTaken(area); sendPacket("PV", {QString::number(id), "CID", argv[1]}); fullArup(); + if (server->timer->isActive()) { + sendPacket("TI", {QString::number(0), QString::number(2)}); + sendPacket("TI", {QString::number(0), QString::number(0), QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(server->timer->remainingTime())))}); + } + else { + sendPacket("TI", {QString::number(0), QString::number(3)}); + } + for (QTimer* timer : area->timers) { + int timer_id = area->timers.indexOf(timer) + 1; + if (timer->isActive()) { + sendPacket("TI", {QString::number(timer_id), QString::number(2)}); + sendPacket("TI", {QString::number(timer_id), QString::number(0), QString::number(QTime(0,0).msecsTo(QTime(0,0).addMSecs(timer->remainingTime())))}); + } + else { + sendPacket("TI", {QString::number(timer_id), QString::number(3)}); + } + } } void AOClient::pktIcChat(AreaData* area, int argc, QStringList argv, AOPacket packet)