aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCrystalwarrior <varsash@gmail.com>2021-04-21 02:14:49 +0300
committerCrystalwarrior <varsash@gmail.com>2021-04-21 02:14:49 +0300
commit7b058d1401ddc1721304516f5cc7cdbdb15fee5d (patch)
tree655e04ee69accb6623a0044f4c9a09b234060377
parentd0ef4831de8cf3e3645343d477fefb17da24d125 (diff)
Fix last line in the .demo file not being processed
Fix timings for OOC being really busted if max_wait is -1 (dunno at which point this bug was introduced)
-rw-r--r--src/demoserver.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/demoserver.cpp b/src/demoserver.cpp
index 764cf225..09741fd4 100644
--- a/src/demoserver.cpp
+++ b/src/demoserver.cpp
@@ -264,22 +264,26 @@ void DemoServer::playback()
if (current_packet.startsWith("MS#"))
elapsed_time = 0;
- while (!current_packet.startsWith("wait") && !demo_data.isEmpty()) {
+ while (!current_packet.startsWith("wait#")) {
client_sock->write(current_packet.toUtf8());
+ if (demo_data.isEmpty())
+ break;
current_packet = demo_data.dequeue();
}
if (!demo_data.isEmpty()) {
AOPacket wait_packet = AOPacket(current_packet);
int duration = wait_packet.get_contents().at(0).toInt();
- if (max_wait != -1 && duration + elapsed_time > max_wait) {
- duration = qMax(0, max_wait - elapsed_time);
- // Skip the difference on the timers
- emit skip_timers(wait_packet.get_contents().at(0).toInt() - duration);
- }
- else if (timer->interval() != 0 && duration + elapsed_time > timer->interval()) {
- duration = qMax(0, timer->interval() - elapsed_time);
+ if (max_wait != -1) {
+ if (duration + elapsed_time > max_wait) {
+ duration = qMax(0, max_wait - elapsed_time);
+ // Skip the difference on the timers
emit skip_timers(wait_packet.get_contents().at(0).toInt() - duration);
+ }
+ else if (timer->interval() != 0 && duration + elapsed_time > timer->interval()) {
+ duration = qMax(0, timer->interval() - elapsed_time);
+ emit skip_timers(wait_packet.get_contents().at(0).toInt() - duration);
+ }
}
elapsed_time += duration;
timer->start(duration);