Skip to content

Commit f1d6ee8

Browse files
Merge remote-tracking branch 'origin/crystalwarrior/demo-reload' into 2.9.1-ea
2 parents 1bafb7d + 60daac3 commit f1d6ee8

2 files changed

Lines changed: 14 additions & 16 deletions

File tree

include/demoserver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class DemoServer : public QObject
2525
private:
2626
void handle_packet(AOPacket packet);
2727
void load_demo(QString filename);
28-
void reset_all_timers();
28+
void reset_state();
2929

3030
QTcpServer* tcp_server;
3131
QTcpSocket* client_sock = nullptr;

src/demoserver.cpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +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 evidence list
166-
client_sock->write("LE##%");
167-
reset_all_timers();
168-
// Set the BG to default (also breaks up the message queue)
169-
client_sock->write("BN#default#wit#%");
170-
// Stop the wait packet timer
171-
timer->stop();
165+
reset_state();
172166
}
173167
else if (contents[1].startsWith("/play") || contents[1] == ">")
174168
{
@@ -232,13 +226,7 @@ void DemoServer::handle_packet(AOPacket packet)
232226
load_demo(p_path);
233227
QString packet = "CT#DEMO#" + tr("Current demo file reloaded. Send /play or > in OOC to begin playback.") + "#1#%";
234228
client_sock->write(packet.toUtf8());
235-
// Reset evidence list
236-
client_sock->write("LE##%");
237-
reset_all_timers();
238-
// Set the BG to default (also breaks up the message queue)
239-
client_sock->write("BN#default#wit#%");
240-
// Stop the wait packet timer
241-
timer->stop();
229+
reset_state();
242230
}
243231
else if (contents[1].startsWith("/min_wait"))
244232
{
@@ -324,8 +312,12 @@ void DemoServer::load_demo(QString filename)
324312
}
325313
}
326314

327-
void DemoServer::reset_all_timers()
315+
void DemoServer::reset_state()
328316
{
317+
// Reset evidence list
318+
client_sock->write("LE##%");
319+
320+
// Reset timers
329321
client_sock->write("TI#0#3#0#%");
330322
client_sock->write("TI#0#1#0#%");
331323
client_sock->write("TI#1#1#0#%");
@@ -336,6 +328,12 @@ void DemoServer::reset_all_timers()
336328
client_sock->write("TI#3#3#0#%");
337329
client_sock->write("TI#4#1#0#%");
338330
client_sock->write("TI#4#3#0#%");
331+
332+
// Set the BG to default (also breaks up the message queue)
333+
client_sock->write("BN#default#wit#%");
334+
335+
// Stop the wait packet timer
336+
timer->stop();
339337
}
340338

341339
void DemoServer::playback()

0 commit comments

Comments
 (0)