Skip to content

Commit 60daac3

Browse files
committed
Move other duplicate reset calls to their own method
1 parent de4115e commit 60daac3

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
{
@@ -327,8 +315,12 @@ void DemoServer::load_demo(QString filename)
327315
}
328316
}
329317

330-
void DemoServer::reset_all_timers()
318+
void DemoServer::reset_state()
331319
{
320+
// Reset evidence list
321+
client_sock->write("LE##%");
322+
323+
// Reset timers
332324
client_sock->write("TI#0#3#0#%");
333325
client_sock->write("TI#0#1#0#%");
334326
client_sock->write("TI#1#1#0#%");
@@ -339,6 +331,12 @@ void DemoServer::reset_all_timers()
339331
client_sock->write("TI#3#3#0#%");
340332
client_sock->write("TI#4#1#0#%");
341333
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();
342340
}
343341

344342
void DemoServer::playback()

0 commit comments

Comments
 (0)