Fix loading from save desync
authorunc0rr
Thu, 08 Sep 2011 17:59:19 +0400
changeset 5810 552371cc69cc
parent 5809 5883d62b648b
child 5811 2a9438e8adbf
Fix loading from save desync
hedgewars/uGears.pas
hedgewars/uIO.pas
--- a/hedgewars/uGears.pas	Thu Sep 08 15:39:30 2011 +0400
+++ b/hedgewars/uGears.pas	Thu Sep 08 17:59:19 2011 +0400
@@ -991,7 +991,10 @@
 if ((GameTicks and $FFFF) = $FFFF) then
     begin
     if (not CurrentTeam^.ExtDriven) then
-        SendIPCTimeInc;
+        begin
+        SendIPC('#');
+        AddFileLog('hiTicks increment message sent')
+        end;
 
     if (not CurrentTeam^.ExtDriven) or CurrentTeam^.hasGone then
         inc(hiTicks) // we do not recieve a message for this
--- a/hedgewars/uIO.pas	Thu Sep 08 15:39:30 2011 +0400
+++ b/hedgewars/uIO.pas	Thu Sep 08 17:59:19 2011 +0400
@@ -29,7 +29,6 @@
 procedure SendIPCXY(cmd: char; X, Y: SmallInt);
 procedure SendIPCRaw(p: pointer; len: Longword);
 procedure SendIPCAndWaitReply(s: shortstring);
-procedure SendIPCTimeInc;
 procedure SendKeepAliveMessage(Lag: Longword);
 procedure LoadRecordFromFile(fileName: shortstring);
 procedure SendStat(sit: TStatInfoType; s: shortstring);
@@ -246,13 +245,6 @@
 SendIPC(s)
 end;
 
-procedure SendIPCTimeInc;
-const timeinc: shortstring = '#';
-begin
-AddFileLog('[IPC out] <time increment>');
-SendIPCRaw(@timeinc, 2)
-end;
-
 procedure IPCWaitPongEvent;
 begin
 isPonged:= false;
@@ -288,13 +280,16 @@
     and ((GameTicks = hiTicks shl 16 + headcmd^.loTime)
         or (headcmd^.cmd = 's') // for these commands time is not specified
         or (headcmd^.cmd = 'h') // seems the hedgewars protocol does not allow remote synced commands
-        or (headcmd^.cmd = '#')
+        or (headcmd^.cmd = '#') // must be synced for saves to work
         or (headcmd^.cmd = 'b')
         or (headcmd^.cmd = 'F')) do
     begin
     case headcmd^.cmd of
         '+': ; // do nothing - it is just an empty packet
-        '#': inc(hiTicks);
+        '#': begin
+            AddFileLog('hiTicks increment by remote message');
+            inc(hiTicks);
+            end;
         'L': ParseCommand('+left', true);
         'l': ParseCommand('-left', true);
         'R': ParseCommand('+right', true);