(svn r2343) - Fix (regression): dedicated server caused desyncs with its commands, because the player sent over the network is OWNER_SPECTATOR as well, which on clients cannot execute anything. So *hack*hack* it into temporarily player 0.
authorDarkvater
Tue, 17 May 2005 20:52:52 +0000
changeset 1838 522076c550c0
parent 1837 ebd6a1395d03
child 1839 6c0c19719fb2
(svn r2343) - Fix (regression): dedicated server caused desyncs with its commands, because the player sent over the network is OWNER_SPECTATOR as well, which on clients cannot execute anything. So *hack*hack* it into temporarily player 0.
command.c
--- a/command.c	Tue May 17 19:36:36 2005 +0000
+++ b/command.c	Tue May 17 20:52:52 2005 +0000
@@ -476,10 +476,16 @@
 	}
 
 #ifdef ENABLE_NETWORK
-	// If we are in network, and the command is not from the network
-	//   send it to the command-queue and abort execution
+	/** If we are in network, and the command is not from the network
+	 * send it to the command-queue and abort execution
+	 * If we are a dedicated server temporarily switch local player, otherwise
+	 * the other parties won't be able to execute our command and will desync.
+	 * @todo Rewrite dedicated server to something more than a dirty hack!
+	 */
 	if (_networking && !(cmd & CMD_NETWORK_COMMAND)) {
+		if (_network_dedicated) _local_player = 0;
 		NetworkSend_Command(tile, p1, p2, cmd, callback);
+		if (_network_dedicated) _local_player = OWNER_SPECTATOR;
 		_docommand_recursive = 0;
 		_cmd_text = NULL;
 		return true;