@@ -162,6 +162,7 @@ void DemoServer::handle_packet(AOPacket packet)
162162 load_demo (path);
163163 QString packet = " CT#DEMO#" + tr (" Demo file loaded. Send /play or > in OOC to begin playback." ) + " #1#%" ;
164164 client_sock->write (packet.toUtf8 ());
165+ reset_state ();
165166 }
166167 else if (contents[1 ].startsWith (" /play" ) || contents[1 ] == " >" )
167168 {
@@ -220,14 +221,21 @@ void DemoServer::handle_packet(AOPacket packet)
220221 client_sock->write (packet.toUtf8 ());
221222 }
222223 }
224+ else if (contents[1 ].startsWith (" /reload" ))
225+ {
226+ load_demo (p_path);
227+ QString packet = " CT#DEMO#" + tr (" Current demo file reloaded. Send /play or > in OOC to begin playback." ) + " #1#%" ;
228+ client_sock->write (packet.toUtf8 ());
229+ reset_state ();
230+ }
223231 else if (contents[1 ].startsWith (" /min_wait" ))
224232 {
225233 QString packet = " CT#DEMO#" + tr (" min_wait is deprecated. Use the client Settings for minimum wait instead!" ) + " #1#%" ;
226234 client_sock->write (packet.toUtf8 ());
227235 }
228236 else if (contents[1 ].startsWith (" /help" ))
229237 {
230- QString packet = " CT#DEMO#" + tr (" Available commands:\n load, play, pause, max_wait, help" ) + " #1#%" ;
238+ QString packet = " CT#DEMO#" + tr (" Available commands:\n load, reload, play, pause, max_wait, help" ) + " #1#%" ;
231239 client_sock->write (packet.toUtf8 ());
232240 }
233241 }
@@ -239,8 +247,11 @@ void DemoServer::load_demo(QString filename)
239247 demo_file.open (QIODevice::ReadOnly);
240248 if (!demo_file.isOpen ())
241249 return ;
250+ // Clear demo data
242251 demo_data.clear ();
252+ // Set the demo filepath
243253 p_path = filename;
254+ // Process the demo file
244255 QTextStream demo_stream (&demo_file);
245256 demo_stream.setCodec (" UTF-8" );
246257 QString line = demo_stream.readLine ();
@@ -304,6 +315,30 @@ void DemoServer::load_demo(QString filename)
304315 }
305316}
306317
318+ void DemoServer::reset_state ()
319+ {
320+ // Reset evidence list
321+ client_sock->write (" LE##%" );
322+
323+ // Reset timers
324+ client_sock->write (" TI#0#3#0#%" );
325+ client_sock->write (" TI#0#1#0#%" );
326+ client_sock->write (" TI#1#1#0#%" );
327+ client_sock->write (" TI#1#3#0#%" );
328+ client_sock->write (" TI#2#1#0#%" );
329+ client_sock->write (" TI#2#3#0#%" );
330+ client_sock->write (" TI#3#1#0#%" );
331+ client_sock->write (" TI#3#3#0#%" );
332+ client_sock->write (" TI#4#1#0#%" );
333+ client_sock->write (" TI#4#3#0#%" );
334+
335+ // Set the BG to default (also breaks up the message queue)
336+ client_sock->write (" BN#default#wit#%" );
337+
338+ // Stop the wait packet timer
339+ timer->stop ();
340+ }
341+
307342void DemoServer::playback ()
308343{
309344 if (demo_data.isEmpty ())
0 commit comments