Skip to content

Commit 1cbfa04

Browse files
Handle drawing and server commands in lockstep
Instead of first handling all server commands in one go and then passing it on to the command handler, since that can cause desync for streamed resets. Now they get handled in the order that they arrive.
1 parent 4b7f3ff commit 1cbfa04

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/libclient/net/client.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,19 @@ void Client::handleMessages(int count, net::Message *msgs)
324324
m_catchupTimer->stop();
325325
}
326326

327+
int handled = 0;
327328
for(int i = 0; i < count; ++i) {
328329
net::Message &msg = msgs[i];
329330
switch(msg.type()) {
330-
case DP_MSG_SERVER_COMMAND:
331+
case DP_MSG_SERVER_COMMAND: {
332+
int handleCount = i - handled;
333+
if(handleCount > 0) {
334+
m_commandHandler->handleCommands(handleCount, msgs + handled);
335+
}
336+
handled = i;
331337
handleServerReply(ServerReply::fromMessage(msg), i);
332338
break;
339+
}
333340
case DP_MSG_DATA:
334341
handleData(msg);
335342
break;
@@ -344,7 +351,11 @@ void Client::handleMessages(int count, net::Message *msgs)
344351
break;
345352
}
346353
}
347-
m_commandHandler->handleCommands(count, msgs);
354+
355+
int handleCount = count - handled;
356+
if(handleCount > 0) {
357+
m_commandHandler->handleCommands(handleCount, msgs + handled);
358+
}
348359

349360
// The server can send a "catchup" message when there is a significant
350361
// number of messages queued. During login, we can show a progress bar and

0 commit comments

Comments
 (0)