hedgewars/uIO.pas
changeset 70 82d93eeecebe
parent 53 0e27949850e3
child 72 aeb2ac1878dc
equal deleted inserted replaced
69:d8a526934b9f 70:82d93eeecebe
    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);
       
    48 
    47 
    49 implementation
    48 implementation
    50 uses uConsole, uConsts, uWorld, uMisc, uRandom, uLand;
    49 uses uConsole, uConsts, uWorld, uMisc, uRandom, uLand;
    51 const isPonged: boolean = false;
    50 const isPonged: boolean = false;
    52 var  IPCSock: PTCPSocket = nil;
    51 var  IPCSock: PTCPSocket = nil;
   164       AddCaption('> ' + copy(extcmd[cmdcurpos].str, 2, Pred(extcmd[cmdcurpos].len)), $FFFFFF, capgrpNetSay);
   163       AddCaption('> ' + copy(extcmd[cmdcurpos].str, 2, Pred(extcmd[cmdcurpos].len)), $FFFFFF, capgrpNetSay);
   165       inc(cmdcurpos)
   164       inc(cmdcurpos)
   166       end;
   165       end;
   167          
   166          
   168 if cmdcurpos <= cmdendpos then
   167 if cmdcurpos <= cmdendpos then
   169    if GameTicks > extcmd[cmdcurpos].Time then
   168    TryDo(GameTicks <= extcmd[cmdcurpos].Time,
   170       outerror('oops, queue error. in buffer: '+extcmd[cmdcurpos].cmd+' ('+inttostr(GameTicks)+' > '+inttostr(extcmd[cmdcurpos].Time)+')', true);
   169          'oops, queue error. in buffer: ' + extcmd[cmdcurpos].cmd +
       
   170          ' (' + inttostr(GameTicks) + ' > ' +
       
   171          inttostr(extcmd[cmdcurpos].Time) + ')',
       
   172          true);
   171 
   173 
   172 tmpflag:= true;
   174 tmpflag:= true;
   173 while (cmdcurpos <= cmdendpos)and(GameTicks = extcmd[cmdcurpos].Time) do
   175 while (cmdcurpos <= cmdendpos)and(GameTicks = extcmd[cmdcurpos].Time) do
   174    begin
   176    begin
   175    case extcmd[cmdcurpos].cmd of
   177    case extcmd[cmdcurpos].cmd of
   206    inc(cmdcurpos)
   208    inc(cmdcurpos)
   207    end;
   209    end;
   208 isInLag:= (cmdcurpos > cmdendpos) and tmpflag
   210 isInLag:= (cmdcurpos > cmdendpos) and tmpflag
   209 end;
   211 end;
   210 
   212 
   211 procedure LoadFortPoints(Fort: shortstring; isRight: boolean; Count: Longword);
       
   212 const cMAXFORTPOINTS = 20;
       
   213 var f: textfile;
       
   214     i, t: integer;
       
   215     cnt: Longword;
       
   216     ar: array[0..Pred(cMAXFORTPOINTS)] of TPoint;
       
   217     p: TPoint;
       
   218 begin
       
   219 if isRight then Fort:= Pathz[ptForts] + '/' + Fort + 'R.txt'
       
   220            else Fort:= Pathz[ptForts] + '/' + Fort + 'L.txt';
       
   221 WriteToConsole(msgLoading + Fort + ' ');
       
   222 {$I-}
       
   223 AssignFile(f, Fort);
       
   224 Reset(f);
       
   225 cnt:= 0;
       
   226 while not (eof(f) or (cnt = cMAXFORTPOINTS)) do
       
   227       begin
       
   228       Readln(f, ar[cnt].x, ar[cnt].y);
       
   229       if isRight then inc(ar[cnt].x, 1024);
       
   230       inc(cnt);
       
   231       end;
       
   232 Closefile(f);
       
   233 {$I+}
       
   234 TryDo(IOResult = 0, msgFailed, true);
       
   235 WriteLnToConsole(msgOK);
       
   236 TryDo(Count < cnt, 'Fort doesn''t contain needed amount of spawn points', true);
       
   237 for i:= 0 to Pred(cnt) do
       
   238     begin
       
   239     t:= GetRandom(cnt);
       
   240     if i <> t then
       
   241        begin
       
   242        p:= ar[i];
       
   243        ar[i]:= ar[t];
       
   244        ar[t]:= p
       
   245        end
       
   246     end;
       
   247 for i:= 0 to Pred(Count) do
       
   248     AddHHPoint(ar[i].x, ar[i].y);
       
   249 end;
       
   250 
       
   251 end.
   213 end.