Class: SteamCondenser::Servers::Packets::S2A_INFO2_Packet

Inherits:
Object
  • Object
show all
Includes:
S2A_INFO_BasePacket
Defined in:
lib/steam-condenser/servers/packets/s2a_info2_packet.rb

Overview

This class represents a S2A_INFO_DETAILED response packet sent by a Source or GoldSrc server

Out-of-date (before 10/24/2008) GoldSrc servers use an older format (see S2A_INFO_DETAILED_Packet).

See Also:

Author:

  • Sebastian Staudt

Constant Summary collapse

EDF_GAME_ID =
0x01
EDF_GAME_PORT =
0x80
EDF_SERVER_ID =
0x10
EDF_SERVER_TAGS =
0x20
EDF_SOURCE_TV =
0x40

Constants included from BasePacket

BasePacket::A2M_GET_SERVERS_BATCH2_HEADER, BasePacket::A2S_INFO_HEADER, BasePacket::A2S_PLAYER_HEADER, BasePacket::A2S_RULES_HEADER, BasePacket::A2S_SERVERQUERY_GETCHALLENGE_HEADER, BasePacket::C2M_CHECKMD5_HEADER, BasePacket::M2A_SERVER_BATCH_HEADER, BasePacket::RCON_GOLDSRC_CHALLENGE_HEADER, BasePacket::RCON_GOLDSRC_NO_CHALLENGE_HEADER, BasePacket::RCON_GOLDSRC_RESPONSE_HEADER, BasePacket::S2A_INFO2_HEADER, BasePacket::S2A_INFO_DETAILED_HEADER, BasePacket::S2A_PLAYER_HEADER, BasePacket::S2A_RULES_HEADER, BasePacket::S2C_CHALLENGE_HEADER, BasePacket::S2C_CONNREJECT_HEADER

Instance Method Summary collapse

Methods included from S2A_INFO_BasePacket

#info

Methods included from BasePacket

#to_s

Constructor Details

#initialize(data) ⇒ S2A_INFO2_Packet

Creates a new S2A_INFO2 response object based on the given data

See Also:

  • S2A_INFO_BasePacket#generate_info_hash

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/steam-condenser/servers/packets/s2a_info2_packet.rb', line 32

def initialize(data)
  super S2A_INFO2_HEADER, data

  info.merge!({
    :protocol_version => @content_data.getbyte,
    :server_name => @content_data.cstring,
    :map_name => @content_data.cstring,
    :game_directory => @content_data.cstring,
    :game_description => @content_data.cstring,
    :app_id => @content_data.short,
    :number_of_players => @content_data.getbyte,
    :max_players => @content_data.getbyte,
    :number_of_bots => @content_data.getbyte,
    :dedicated => @content_data.getc,
    :operating_system => @content_data.getc,
    :password_needed => @content_data.getbyte == 1,
    :secure => @content_data.getbyte == 1,
    :game_version => @content_data.cstring
  })

  if @content_data.remaining > 0
    extra_data_flag = @content_data.getbyte

    if extra_data_flag & EDF_GAME_PORT != 0
      info[:server_port] = @content_data.short
    end

    if extra_data_flag & EDF_SERVER_ID != 0
      info[:server_id] = @content_data.long | (@content_data.long << 32)
    end

    if extra_data_flag & EDF_SOURCE_TV != 0
      info[:tv_port] = @content_data.short
      info[:tv_name] = @content_data.cstring
    end

    if extra_data_flag & EDF_SERVER_TAGS != 0
      info[:server_tags] = @content_data.cstring
    end

    if extra_data_flag & EDF_GAME_ID != 0
      info[:game_id] = @content_data.long | (@content_data.long << 32)
    end
  end
end