diff -r f1da4126a61c -r 3a65fcd7c335 hedgewars/uFLNet.pas --- a/hedgewars/uFLNet.pas Sun May 17 00:14:30 2015 +0300 +++ b/hedgewars/uFLNet.pas Mon May 18 00:07:52 2015 +0300 @@ -7,9 +7,9 @@ procedure freeModule; implementation -uses SDLh; +uses SDLh, uFLIPC; -const endCmd: array[0..1] of char = (#10, #10); +const endCmd: string = #10 + #10; function getNextChar: char; forward; function getCurrChar: char; forward; @@ -256,8 +256,13 @@ procedure sendNet(s: shortstring); begin writeln('[NET] Send: ', s); - SDLNet_TCP_Send(sock, @s[1], byte(s[0])); - SDLNet_TCP_Send(sock, @endCmd, 2); + ipcToNet(s + endCmd); +end; + +procedure netSendCallback(p: pointer; msg: PChar; len: Longword); +begin + // W A R N I N G: totally thread-unsafe due to use of sock variable + SDLNet_TCP_Send(sock, msg, len); end; procedure connectOfficialServer; @@ -279,6 +284,8 @@ sock:= nil; SDLNet_Init; + + registerNetCallback(nil, @netSendCallback); end; procedure freeModule;