hedgewars/uFLNet.pas
branchqmlfrontend
changeset 11444 91f8c6ff5bab
parent 11442 6b04a266feee
child 11446 321d0ce43568
--- a/hedgewars/uFLNet.pas	Sat Dec 05 16:14:59 2015 +0300
+++ b/hedgewars/uFLNet.pas	Sun Dec 06 19:56:33 2015 +0300
@@ -8,6 +8,8 @@
 procedure sendNet(s: shortstring);
 procedure sendNetLn(s: shortstring);
 
+var isConnected: boolean = false;
+
 implementation
 uses SDLh, uFLIPC, uFLTypes, uFLUICallback, uFLNetTypes, uFLUtils;
 
@@ -17,11 +19,9 @@
 function getCurrChar: char; forward;
 
 type
-    TNetState = (netDisconnected, netConnecting);
     TParserState = record
                        cmd: TCmdType;
                        l: LongInt;
-                       netState: TNetState;
                        buf: shortstring;
                        bufpos: byte;
                    end;
@@ -284,7 +284,7 @@
         c:= getNextChar;
         //writeln('>>>>> ', c, ' [', letters[state.l], '] ', commands[state.l], ' ', state.l);
         if c = #0 then
-            state.netState:= netDisconnected
+            isConnected:= false
         else
         begin
             while (letters[state.l] <> c) and (commands[state.l] > 0) do
@@ -305,7 +305,7 @@
                 handler__UNKNOWN_()
             end
         end
-    until state.netState = netDisconnected;
+    until not isConnected;
 
     SDLNet_TCP_Close(sock);
     sock:= nil;
@@ -383,7 +383,7 @@
     state.buf:= '';
 
     state.l:= 0;
-    state.netState:= netConnecting;
+    isConnected:= true;
 
     netReaderThread:= SDL_CreateThread(@netReader, 'netReader', nil);
     SDL_DetachThread(netReaderThread)
@@ -392,6 +392,7 @@
 procedure initModule;
 begin
     sock:= nil;
+    isConnected:= false;
 
     SDLNet_Init;