hedgewars/uIO.pas
changeset 8003 7d8bce524daf
parent 7628 bc7b1d228a2c
child 8024 1d5baba66cb6
child 8026 4a4f21070479
equal deleted inserted replaced
8000:cd007c1780e7 8003:7d8bce524daf
    25 procedure initModule;
    25 procedure initModule;
    26 procedure freeModule;
    26 procedure freeModule;
    27 
    27 
    28 procedure InitIPC;
    28 procedure InitIPC;
    29 procedure SendIPC(s: shortstring);
    29 procedure SendIPC(s: shortstring);
    30 procedure SendIPCXY(cmd: char; X, Y: SmallInt);
    30 procedure SendIPCXY(cmd: char; X, Y: LongInt);
    31 procedure SendIPCRaw(p: pointer; len: Longword);
    31 procedure SendIPCRaw(p: pointer; len: Longword);
    32 procedure SendIPCAndWaitReply(s: shortstring);
    32 procedure SendIPCAndWaitReply(s: shortstring);
    33 procedure SendKeepAliveMessage(Lag: Longword);
    33 procedure SendKeepAliveMessage(Lag: Longword);
    34 procedure LoadRecordFromFile(fileName: shortstring);
    34 procedure LoadRecordFromFile(fileName: shortstring);
    35 procedure SendStat(sit: TStatInfoType; s: shortstring);
    35 procedure SendStat(sit: TStatInfoType; s: shortstring);
    46             Next: PCmd;
    46             Next: PCmd;
    47             loTime: Word;
    47             loTime: Word;
    48             case byte of
    48             case byte of
    49             1: (len: byte;
    49             1: (len: byte;
    50                 cmd: Char;
    50                 cmd: Char;
    51                 X, Y: SmallInt);
    51                 X, Y: LongInt);
    52             2: (str: shortstring);
    52             2: (str: shortstring);
    53             end;
    53             end;
    54 
    54 
    55 var IPCSock: PTCPSocket;
    55 var IPCSock: PTCPSocket;
    56     fds: PSDLNet_SocketSet;
    56     fds: PSDLNet_SocketSet;
   232     begin
   232     begin
   233     SDLNet_TCP_Send(IPCSock, p, len)
   233     SDLNet_TCP_Send(IPCSock, p, len)
   234     end
   234     end
   235 end;
   235 end;
   236 
   236 
   237 procedure SendIPCXY(cmd: char; X, Y: SmallInt);
   237 procedure SendIPCXY(cmd: char; X, Y: LongInt);
   238 var s: shortstring;
   238 var s: shortstring;
   239 begin
   239 begin
   240 s[0]:= #5;
   240 s[0]:= #5;
   241 s[1]:= cmd;
   241 s[1]:= cmd;
   242 SDLNet_Write16(X, @s[2]);
   242 SDLNet_Write32(X, @s[2]);
   243 SDLNet_Write16(Y, @s[4]);
   243 SDLNet_Write32(Y, @s[4]);
   244 SendIPC(s)
   244 SendIPC(s)
   245 end;
   245 end;
   246 
   246 
   247 procedure IPCWaitPongEvent;
   247 procedure IPCWaitPongEvent;
   248 begin
   248 begin
   268 end;
   268 end;
   269 
   269 
   270 procedure NetGetNextCmd;
   270 procedure NetGetNextCmd;
   271 var tmpflag: boolean;
   271 var tmpflag: boolean;
   272     s: shortstring;
   272     s: shortstring;
   273     x16, y16: SmallInt;
   273     x32, y32: LongInt;
   274 begin
   274 begin
   275 tmpflag:= true;
   275 tmpflag:= true;
   276 
   276 
   277 while (headcmd <> nil)
   277 while (headcmd <> nil)
   278     and (tmpflag or (headcmd^.cmd = '#')) // '#' is the only cmd which can be sent within same tick after 'N'
   278     and (tmpflag or (headcmd^.cmd = '#')) // '#' is the only cmd which can be sent within same tick after 'N'
   325             tmpflag:= false;
   325             tmpflag:= false;
   326             lastTurnChecksum:= SDLNet_Read32(@headcmd^.str[2]);
   326             lastTurnChecksum:= SDLNet_Read32(@headcmd^.str[2]);
   327             AddFileLog('got cmd "N": time '+IntToStr(hiTicks shl 16 + headcmd^.loTime))
   327             AddFileLog('got cmd "N": time '+IntToStr(hiTicks shl 16 + headcmd^.loTime))
   328              end;
   328              end;
   329         'p': begin
   329         'p': begin
   330             x16:= SDLNet_Read16(@(headcmd^.X));
   330             x32:= SDLNet_Read32(@(headcmd^.X));
   331             y16:= SDLNet_Read16(@(headcmd^.Y));
   331             y32:= SDLNet_Read32(@(headcmd^.Y));
   332             doPut(x16, y16, false)
   332             doPut(x32, y32, false)
   333              end;
   333              end;
   334         'P': begin
   334         'P': begin
   335             // these are equations solved for CursorPoint
   335             // these are equations solved for CursorPoint
   336             // SDLNet_Read16(@(headcmd^.X)) == CursorPoint.X - WorldDx;
   336             // SDLNet_Read16(@(headcmd^.X)) == CursorPoint.X - WorldDx;
   337             // SDLNet_Read16(@(headcmd^.Y)) == cScreenHeight - CursorPoint.Y - WorldDy;
   337             // SDLNet_Read16(@(headcmd^.Y)) == cScreenHeight - CursorPoint.Y - WorldDy;
   338             if not (CurrentTeam^.ExtDriven and bShowAmmoMenu) then
   338             if not (CurrentTeam^.ExtDriven and bShowAmmoMenu) then
   339                begin
   339                begin
   340                CursorPoint.X:= SmallInt(SDLNet_Read16(@(headcmd^.X))) + WorldDx;
   340                CursorPoint.X:= LongInt(SDLNet_Read32(@(headcmd^.X))) + WorldDx;
   341                CursorPoint.Y:= cScreenHeight - SmallInt(SDLNet_Read16(@(headcmd^.Y))) - WorldDy
   341                CursorPoint.Y:= cScreenHeight - LongInt(SDLNet_Read32(@(headcmd^.Y))) - WorldDy
   342                end
   342                end
   343              end;
   343              end;
   344         'w': ParseCommand('setweap ' + headcmd^.str[2], true);
   344         'w': ParseCommand('setweap ' + headcmd^.str[2], true);
   345         't': ParseCommand('taunt ' + headcmd^.str[2], true);
   345         't': ParseCommand('taunt ' + headcmd^.str[2], true);
   346         'h': ParseCommand('hogsay ' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true);
   346         'h': ParseCommand('hogsay ' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true);