Class: SteamCondenser::Servers::Packets::S2A_RULES_Packet

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

Overview

This class represents a S2A_RULES response sent by a game server

It is used to transfer a list of server rules (a.k.a. CVARs) with their active values.

See Also:

  • GameServer#update_rules_info

Author:

  • Sebastian Staudt

Constant Summary

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 Attribute Summary collapse

Instance Method Summary collapse

Methods included from BasePacket

#to_s

Constructor Details

#initialize(content_data) ⇒ S2A_RULES_Packet

Creates a new S2A_RULES response object based on the given data

Parameters:

  • content_data (String)

    The raw packet data sent by the server


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/steam-condenser/servers/packets/s2a_rules_packet.rb', line 29

def initialize(content_data)
  if content_data.nil?
    raise SteamCondenser::Error::PacketFormat, 'Wrong formatted S2A_RULES response packet.'
  end

  super BasePacket::S2A_RULES_HEADER, content_data

  rules_count = @content_data.short

  @rules_hash = {}

  rules_count.times do
    rule  = @content_data.cstring
    value = @content_data.cstring

    break if rule.empty?

    @rules_hash[rule] = value
  end
end

Instance Attribute Details

#rules_hashHash<String, String> (readonly)

Returns the list of server rules (a.k.a. CVars) with the current values

Returns:

  • (Hash<String, String>)

    A list of server rules


24
25
26
# File 'lib/steam-condenser/servers/packets/s2a_rules_packet.rb', line 24

def rules_hash
  @rules_hash
end