hedgewars/uIO.pas
branchqmlfrontend
changeset 11843 01f88c3b7b66
parent 11634 0af93f018701
child 12855 1b2b84315d27
--- a/hedgewars/uIO.pas	Tue Aug 02 23:08:17 2016 +0300
+++ b/hedgewars/uIO.pas	Thu Aug 11 23:05:14 2016 +0300
@@ -256,7 +256,9 @@
 
 procedure flushBuffer();
 begin
+    ipcToFrontendRaw(@sendBuffer.buf, sendBuffer.count);
     flushDelayTicks:= 0;
+    sendBuffer.count:= 0;
 end;
 
 procedure SendIPC(s: shortstring);
@@ -269,7 +271,20 @@
     AddFileLog('[IPC out] '+ sanitizeCharForLog(s[1]));
     inc(s[0], 2);
 
-    ipcToFrontend(s)
+    if isSyncedCommand(s[1]) then
+        begin
+        if sendBuffer.count + byte(s[0]) >= cSendBufferSize then
+            flushBuffer();
+
+        Move(s, sendBuffer.buf[sendBuffer.count], byte(s[0]) + 1);
+        inc(sendBuffer.count, byte(s[0]) + 1);
+
+        if (s[1] = 'N') or (s[1] = '#') then
+            flushBuffer();
+        end
+    else
+        ipcToFrontendRaw(@s, Succ(byte(s[0])))
+
 end;
 
 procedure SendIPCRaw(p: pointer; len: Longword);