# HG changeset patch # User unc0rr # Date 1429994769 -10800 # Node ID 6a805e82207412607f2e1c5f11081bb860ba572e # Parent f373838129c2a027687b81594e2f55a69bce63e9 Some hedgewars coding a week keeps doctor away diff -r f373838129c2 -r 6a805e822074 hedgewars/uFLNet.pas --- a/hedgewars/uFLNet.pas Wed Apr 22 23:33:16 2015 +0300 +++ b/hedgewars/uFLNet.pas Sat Apr 25 23:46:09 2015 +0300 @@ -11,7 +11,32 @@ var sock: PTCPSocket; fds: PSDLNet_SocketSet; - buf: shortstring; + netReaderThread: PSDL_Thread; + sockbuf: shortstring; + sockbufpos: byte; + +function getNextChar: char; +var r: byte; +begin + if sockbufpos < byte(sockbuf[0]) then + begin + inc(sockbufpos); + getNextChar:= sockbuf[sockbufpos]; + end else + begin + r:= SDLNet_TCP_Recv(sock, @sockbuf[1], 255); + if r > 0 then + begin + sockbufpos:= 1; + sockbuf[0]:= char(i); + getNextChar:= sockbuf[1]; + end else + begin + sockbufpos:= 0; + sockbuf[0]:= #0; + getNextChar:= #0 + end; +end; function netReader(data: pointer): LongInt; cdecl; export; begin @@ -26,7 +51,9 @@ if SDLNet_ResolveHost(ipaddr, PChar('netserver.hedgewars.org'), 46631) = 0 then sock:= SDLNet_TCP_Open(ipaddr); - callbackListenerThread:= SDL_CreateThread(@listener{$IFDEF SDL2}, 'ipcListener'{$ENDIF}, nil); + sockbufpos:= 0; + sockbuf:= ''; + netReaderThread:= SDL_CreateThread(@netReader{$IFDEF SDL2}, 'netReader'{$ENDIF}, nil); end; procedure initModule; diff -r f373838129c2 -r 6a805e822074 tools/protocolParser.hs --- a/tools/protocolParser.hs Wed Apr 22 23:33:16 2015 +0300 +++ b/tools/protocolParser.hs Sat Apr 25 23:46:09 2015 +0300 @@ -1,6 +1,7 @@ module Main where import Text.PrettyPrint.HughesPJ +import Data.Tree data HWProtocol = Command String [CmdParam] data CmdParam = Skip @@ -26,4 +27,6 @@ , cmd1 "LOBBY:JOINED" $ Many [SS] ] -main = undefined +pas = + +main = putStrLn $ render pas