hedgewars/uIO.pas
branchwebgl
changeset 9972 feb4b031b52e
parent 9521 8054d9d775fd
child 9974 fb84e878111d
equal deleted inserted replaced
9970:88353250ad7d 9972:feb4b031b52e
    49      TCmd = packed record
    49      TCmd = packed record
    50             Next: PCmd;
    50             Next: PCmd;
    51             loTime: Word;
    51             loTime: Word;
    52             case byte of
    52             case byte of
    53             1: (len: byte;
    53             1: (len: byte;
    54                 cmd: Char;
    54                 cmd: Char);
    55                 X, Y: LongInt);
       
    56             2: (str: shortstring);
    55             2: (str: shortstring);
    57             end;
    56             end;
    58 
    57 
    59 var IPCSock: PTCPSocket;
    58 var IPCSock: PTCPSocket;
    60     fds: PSDLNet_SocketSet;
    59     fds: PSDLNet_SocketSet;
   370             tmpflag:= false;
   369             tmpflag:= false;
   371             lastTurnChecksum:= SDLNet_Read32(@headcmd^.str[2]);
   370             lastTurnChecksum:= SDLNet_Read32(@headcmd^.str[2]);
   372             AddFileLog('got cmd "N": time '+IntToStr(hiTicks shl 16 + headcmd^.loTime))
   371             AddFileLog('got cmd "N": time '+IntToStr(hiTicks shl 16 + headcmd^.loTime))
   373              end;
   372              end;
   374         'p': begin
   373         'p': begin
   375             x32:= SDLNet_Read32(@(headcmd^.X));
   374             x32:= SDLNet_Read32(@(headcmd^.str[2]));
   376             y32:= SDLNet_Read32(@(headcmd^.Y));
   375             y32:= SDLNet_Read32(@(headcmd^.str[4]));
   377             doPut(x32, y32, false)
   376             doPut(x32, y32, false)
   378              end;
   377              end;
   379         'P': begin
   378         'P': begin
   380             // these are equations solved for CursorPoint
   379             // these are equations solved for CursorPoint
   381             // SDLNet_Read16(@(headcmd^.X)) == CursorPoint.X - WorldDx;
   380             // SDLNet_Read16(@(headcmd^.X)) == CursorPoint.X - WorldDx;
   382             // SDLNet_Read16(@(headcmd^.Y)) == cScreenHeight - CursorPoint.Y - WorldDy;
   381             // SDLNet_Read16(@(headcmd^.Y)) == cScreenHeight - CursorPoint.Y - WorldDy;
   383             if CurrentTeam^.ExtDriven then
   382             if CurrentTeam^.ExtDriven then
   384                begin
   383                begin
   385                TargetCursorPoint.X:= LongInt(SDLNet_Read32(@(headcmd^.X))) + WorldDx;
   384                TargetCursorPoint.X:= LongInt(SDLNet_Read32(@(headcmd^.str[2]))) + WorldDx;
   386                TargetCursorPoint.Y:= cScreenHeight - LongInt(SDLNet_Read32(@(headcmd^.Y))) - WorldDy;
   385                TargetCursorPoint.Y:= cScreenHeight - LongInt(SDLNet_Read32(@(headcmd^.str[4]))) - WorldDy;
   387                if not bShowAmmoMenu and autoCameraOn then
   386                if not bShowAmmoMenu and autoCameraOn then
   388                     CursorPoint:= TargetCursorPoint
   387                     CursorPoint:= TargetCursorPoint
   389                end
   388                end
   390              end;
   389              end;
   391         'w': ParseCommand('setweap ' + headcmd^.str[2], true);
   390         'w': ParseCommand('setweap ' + headcmd^.str[2], true);
   392         't': ParseCommand('taunt ' + headcmd^.str[2], true);
   391         't': ParseCommand('taunt ' + headcmd^.str[2], true);
   393         'h': ParseCommand('hogsay ' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true);
   392         'h': ParseCommand('hogsay ' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true);
   394         '1'..'5': ParseCommand('timer ' + headcmd^.cmd, true);
   393         '1'..'5': ParseCommand('timer ' + headcmd^.cmd, true);
   395         else
   394         else
   396             if (headcmd^.cmd >= #128) and (headcmd^.cmd <= char(128 + cMaxSlotIndex)) then
   395             if (byte(headcmd^.cmd) >= 128) and (byte(headcmd^.cmd) <= 128 + cMaxSlotIndex) then
   397                 ParseCommand('slot ' + char(byte(headcmd^.cmd) - 79), true)
   396                 ParseCommand('slot ' + char(byte(headcmd^.cmd) - 79), true)
   398                 else
   397                 else
   399                 OutError('Unexpected protocol command: ' + headcmd^.cmd, True)
   398                 OutError('Unexpected protocol command: ' + headcmd^.cmd, True)
   400         end;
   399         end;
   401     RemoveCmd
   400     RemoveCmd