summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/network/network_command.cpp18
-rw-r--r--src/network/network_internal.h1
-rw-r--r--src/network/network_server.cpp1
3 files changed, 20 insertions, 0 deletions
diff --git a/src/network/network_command.cpp b/src/network/network_command.cpp
index 111ee7e3f..725b034d0 100644
--- a/src/network/network_command.cpp
+++ b/src/network/network_command.cpp
@@ -130,6 +130,24 @@ void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, Comma
}
/**
+ * Sync our local command queue to the command queue of the given
+ * socket. This is needed for the case where we receive a command
+ * before saving the game for a joining client, but without the
+ * execution of those commands. Not syncing those commands means
+ * that the client will never get them and as such will be in a
+ * desynced state from the time it started with joining.
+ * @param cs The client to sync the queue to.
+ */
+void NetworkSyncCommandQueue(NetworkClientSocket *cs)
+{
+ for (CommandPacket *p = _local_command_queue; p != NULL; p = p->next) {
+ CommandPacket c = *p;
+ c.callback = 0;
+ NetworkAddCommandQueue(c, cs);
+ }
+}
+
+/**
* Execute all commands on the local command queue that ought to be executed this frame.
*/
void NetworkExecuteLocalCommandQueue()
diff --git a/src/network/network_internal.h b/src/network/network_internal.h
index ef1030a9e..3131cc10e 100644
--- a/src/network/network_internal.h
+++ b/src/network/network_internal.h
@@ -163,6 +163,7 @@ struct CommandPacket : CommandContainer {
void NetworkAddCommandQueue(CommandPacket cp, NetworkClientSocket *cs = NULL);
void NetworkExecuteLocalCommandQueue();
void NetworkFreeLocalCommandQueue();
+void NetworkSyncCommandQueue(NetworkClientSocket *cs);
/* from network.c */
NetworkRecvStatus NetworkCloseClient(NetworkClientSocket *cs, NetworkRecvStatus status);
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index a3cd53954..f4db459cb 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -353,6 +353,7 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_MAP)
sent_packets = 4; // We start with trying 4 packets
+ NetworkSyncCommandQueue(cs);
cs->status = STATUS_MAP;
/* Mark the start of download */
cs->last_frame = _frame_counter;