Merge pull request #531 from AttorneyOnline/fix/broken-demos
Fix demo playback max_wait -1 incorrect behavior when non-IC is processed
This commit is contained in:
		
						commit
						3e4de5da62
					
				@ -264,22 +264,26 @@ void DemoServer::playback()
 | 
				
			|||||||
    if (current_packet.startsWith("MS#"))
 | 
					    if (current_packet.startsWith("MS#"))
 | 
				
			||||||
      elapsed_time = 0;
 | 
					      elapsed_time = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while (!current_packet.startsWith("wait") && !demo_data.isEmpty()) {
 | 
					    while (!current_packet.startsWith("wait#")) {
 | 
				
			||||||
        client_sock->write(current_packet.toUtf8());
 | 
					        client_sock->write(current_packet.toUtf8());
 | 
				
			||||||
 | 
					        if (demo_data.isEmpty())
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
        current_packet = demo_data.dequeue();
 | 
					        current_packet = demo_data.dequeue();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (!demo_data.isEmpty()) {
 | 
					    if (!demo_data.isEmpty()) {
 | 
				
			||||||
        AOPacket wait_packet = AOPacket(current_packet);
 | 
					        AOPacket wait_packet = AOPacket(current_packet);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        int duration = wait_packet.get_contents().at(0).toInt();
 | 
					        int duration = wait_packet.get_contents().at(0).toInt();
 | 
				
			||||||
        if (max_wait != -1 && duration + elapsed_time > max_wait) {
 | 
					        if (max_wait != -1) {
 | 
				
			||||||
          duration = qMax(0, max_wait - elapsed_time);
 | 
					          if (duration + elapsed_time > max_wait) {
 | 
				
			||||||
          // Skip the difference on the timers
 | 
					            duration = qMax(0, max_wait - elapsed_time);
 | 
				
			||||||
          emit skip_timers(wait_packet.get_contents().at(0).toInt() - duration);
 | 
					            // Skip the difference on the timers
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        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);
 | 
					            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;
 | 
					        elapsed_time += duration;
 | 
				
			||||||
        timer->start(duration);
 | 
					        timer->start(duration);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user