Thema: Delphi Query an Gameserver

Einzelnen Beitrag anzeigen

Flodding

Registriert seit: 26. Dez 2007
Ort: Kiel
121 Beiträge
 
Turbo Delphi für Win32
 
#116

AW: Query an Gameserver

  Alt 31. Okt 2015, 22:44
Irgendwie hab ich meinen aktuellen Code vergessen:

Delphi-Quellcode:
procedure Get_SERVER_LIST(a1: byte; a2: byte; a3: byte; a4: byte; a5: Word);
var
// request : TA2S_InfoRequest;
  request : TServerListRequest;
  response : TServerListResponse;
  buffer : TBufferArray;
  i : Integer;
  y : Integer;
  endoflist : Boolean;
  endofpartlist : Boolean;

  new_a1 : byte;
  new_a2 : byte;
  new_a3 : byte;
  new_a4 : byte;
  new_a5 : word;

  old_a1 : byte;
  old_a2 : byte;
  old_a3 : byte;
  old_a4 : byte;
  old_a5 : word;

  old_seed : String;
  new_seed : String;

  newport_plain: Integer;
  oldport_plain: Integer;

begin

old_a1 := $30;
old_a2 := $30;
old_a3 := $30;
old_a4 := $30;
old_a5 := $3030;

// \gamedir\arma2arrowpc
// 31 FF 30 2e 30 2e 30 2e 30 3a 30 00 5c 67 61 6d 65 64 69 72 5c 61 72 6d 61 32 61 72 72 6f 77 70 63 00

// \gamedir\arma3
// 31 ff 30 2e 30 2e 30 2e 30 3a 30 00 5c 67 61 6d 65 64 69 72 5c 61 72 6d 61 33

  request.RequestHeader := $31;
  request.PacketHeader := $FF;
  request.First := $30;
  request.First_dot := $2E;
  request.Second := $30;
  request.Second_dot := $2E;
  request.Third := $30;
  request.Third_dot := $2E;
  request.Fourth := $30;
  request.double_dot := $3A;
  request.Port := $3030;
  request.Payload[0] := $00;
  request.Payload[1] := $5C;
  request.Payload[2] := $67;
  request.Payload[3] := $61;
  request.Payload[4] := $6D;
  request.Payload[5] := $65;
  request.Payload[6] := $64;
  request.Payload[7] := $69;
  request.Payload[8] := $72;
  request.Payload[9] := $5C;
  request.Payload[10] := $61;
  request.Payload[11] := $72;
  request.Payload[12] := $6D;
  request.Payload[13] := $61;
  request.Payload[14] := $33;
  request.Payload[15] := $00;


  Form1.udp1.BlockMode := bmNonBlocking;
  Form1.udp1.RemoteHost := 'hl2master.steampowered.com';
  Form1.udp1.RemotePort := '27011';

  if Form1.udp1.Active = false then
  begin
  form1.udp1.Active := true;
  form1.ListBox1.Clear;
  endoflist := false;
  end;

  if (Form1.udp1.Connected) then
    begin

    y := 0;
        repeat
               i := 0;
        form1.udp1.CleanupInstance;
        Form1.Udp1.SendBuf(request, SizeOf(request));
        Form1.udp1.WaitForData(250);
        Form1.Udp1.ReceiveBuf(buffer, SizeOf(buffer));
        Move(buffer[i], response.ResponseHeader, SizeOf(response.ResponseHeader)); inc(i, SizeOf(response.ResponseHeader));
        Move(buffer[i], response.PacketHeader, SizeOf(response.PacketHeader)); inc(i, SizeOf(response.PacketHeader));
// form1.Caption := chr(response.ResponseHeader) + chr(response.PacketHeader) + IntToStr(i);
        form1.Memo1.Text := bintostr((buffer));
          repeat
            Move(buffer[i], response.First, SizeOf(response.First)); inc(i, SizeOf(response.First));
            Move(buffer[i], response.Second, SizeOf(response.Second)); inc(i, SizeOf(response.Second));
            Move(buffer[i], response.Third, SizeOf(response.Third)); inc(i, SizeOf(response.Third));
            Move(buffer[i], response.Fourth, SizeOf(response.Fourth)); inc(i, SizeOf(response.Fourth));
// Response.Port := Buffer[i] * 256 + Buffer[i+1]; Inc(i, SizeOf(Response.Port)); // Weil die Bytes vertauscht sind, müssen sie umgedreht werden für ein richtiges
            newport_plain := Buffer[i] * 256 + Buffer[i+1]; Inc(i, SizeOf(Response.Port)); // Weil die Bytes vertauscht sind, müssen sie umgedreht werden für ein richtiges

            new_a1 := response.First;
            new_a2 := response.Second;
            new_a3 := response.Third;
            new_a4 := response.Fourth;
            new_a5 := response.Port;

            new_seed := IntToStr(new_a1) + IntToStr(new_a2) + IntToStr(new_a3) + IntToStr(new_a4) + IntToStr(new_a5);

        if (response.First <> 00) AND (response.Second <> 00) AND (response.Third <> 00) AND (response.Fourth <> 00) then
              begin
                form1.duplicatcounter := 0;

               Form1.ListBox1.Items.Add ((IntToStr(new_a1)) + '.' +
                                          (IntToStr(new_a2)) + '.' +
                                          (IntToStr(new_a3)) + '.' +
                                          (IntToStr(new_a4)) + ':' +
                                           IntToStr((newport_plain)) );

                old_a1 := response.First;
                old_a2 := response.Second;
                old_a3 := response.Third;
                old_a4 := response.Fourth;
                old_a5 := newport_plain;
                old_seed := IntToStr(old_a1) + IntToStr(old_a2) + IntToStr(old_a3) + IntToStr(old_a4) + IntToStr(newport_plain);

                Application.ProcessMessages;
              end
            else
              begin
                Form1.duplicatcounter := form1.duplicatcounter + 1;
                request.First := strtoint( StringToHex(inttostr(old_a1)));
                request.Second := strtoint( StringToHex(inttostr(old_a2)));
                request.Third := strtoint( StringToHex(inttostr(old_a3)));
                request.Fourth := strtoint( StringToHex(inttostr(old_a4)));
                request.Port := strtoint( StringToHex(inttostr(old_a5)));
                Form1.Edit3.Text := StringToHex(inttostr(old_a1) + inttostr(old_a2) + inttostr(old_a3) + inttostr(old_a4) + inttostr(old_a5)) ;
              end;
              y := y + 1;
              form1.Caption := inttostr(y);
// until (IntToStr(response.First)) + '.' + (IntToStr(response.Second)) + '.' + (IntToStr(response.Third)) + '.' + (IntToStr(response.Fourth)) + ':' + IntToStr((response.Port)) = '0.0.0.0:0';
          until form1.duplicatcounter = 2;

        Form1.ListBox1.Items.Add ('---------------');
        Form1.ListBox1.Items.Add ('---------------');
        Form1.ListBox1.Items.Add ('NewSeed: ' + new_seed);
        Form1.ListBox1.Items.Add ('OldSeed: ' + old_seed);
        Form1.ListBox1.Items.Add ('---------------');
        Form1.ListBox1.Items.Add ('---------------');

        until y > 500;

      end;

Form1.udp1.Active := false;
form1.Caption := 'Servers: ' + inttostr(Form1.ListBox1.Items.Count -1);
end;
irgendwie bekomme ich 4 mal die selbe liste.
Flo
  Mit Zitat antworten Zitat