hedgewars/uIO.pas
changeset 4 bcbd7adb4e4b
parent 1 30f2d1037d5d
child 16 b6f4b413dd41
equal deleted inserted replaced
3:ffe4ad26a64c 4:bcbd7adb4e4b
    42 procedure SendIPCAndWaitReply(s: shortstring);
    42 procedure SendIPCAndWaitReply(s: shortstring);
    43 procedure IPCCheckSock;
    43 procedure IPCCheckSock;
    44 procedure InitIPC;
    44 procedure InitIPC;
    45 procedure CloseIPC;
    45 procedure CloseIPC;
    46 procedure NetGetNextCmd;
    46 procedure NetGetNextCmd;
       
    47 procedure LoadFortPoints(Fort: shortstring; isRight: boolean; Count: Longword);
    47 
    48 
    48 implementation
    49 implementation
    49 uses uConsole, uConsts, uWorld, uMisc;
    50 uses uConsole, uConsts, uWorld, uMisc, uRandom, uLand;
    50 const isPonged: boolean = false;
    51 const isPonged: boolean = false;
    51 var  IPCSock: PTCPSocket;
    52 var  IPCSock: PTCPSocket;
    52      fds: PSDLNet_SocketSet;
    53      fds: PSDLNet_SocketSet;
    53 
    54 
    54      extcmd: array[word] of packed record
    55      extcmd: array[word] of packed record
   203    inc(cmdcurpos)
   204    inc(cmdcurpos)
   204    end;
   205    end;
   205 isInLag:= (cmdcurpos > cmdendpos) and tmpflag
   206 isInLag:= (cmdcurpos > cmdendpos) and tmpflag
   206 end;
   207 end;
   207 
   208 
       
   209 procedure LoadFortPoints(Fort: shortstring; isRight: boolean; Count: Longword);
       
   210 const cMAXFORTPOINTS = 20;
       
   211 var f: textfile;
       
   212     i, t: integer;
       
   213     cnt: Longword;
       
   214     ar: array[0..Pred(cMAXFORTPOINTS)] of TPoint;
       
   215     p: TPoint;
       
   216 begin
       
   217 if isRight then Fort:= Pathz[ptForts] + Fort + 'R.txt'
       
   218            else Fort:= Pathz[ptForts] + Fort + 'L.txt';
       
   219 WriteToConsole(msgLoading + Fort + ' ');
       
   220 {$I-}
       
   221 AssignFile(f, Fort);
       
   222 Reset(f);
       
   223 cnt:= 0;
       
   224 while not (eof(f) or (cnt = cMAXFORTPOINTS)) do
       
   225       begin
       
   226       Readln(f, ar[cnt].x, ar[cnt].y);
       
   227       if isRight then inc(ar[cnt].x, 1024);
       
   228       inc(cnt);
       
   229       end;
       
   230 Closefile(f);
       
   231 {$I+}
       
   232 TryDo(IOResult = 0, msgFailed, true);
       
   233 WriteLnToConsole(msgOK);
       
   234 TryDo(Count < cnt, 'Fort doesn''t contain needed spawn points', true);
       
   235 for i:= 0 to Pred(cnt) do
       
   236     begin
       
   237     t:= GetRandom(cnt);
       
   238     if i <> t then
       
   239        begin
       
   240        p:= ar[i];
       
   241        ar[i]:= ar[t];
       
   242        ar[t]:= p
       
   243        end
       
   244     end;
       
   245 for i:= 0 to Pred(Count) do
       
   246     AddHHPoint(ar[i].x, ar[i].y);
       
   247 end;
       
   248 
   208 end.
   249 end.