Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/steam-condenser/community/css/css_stats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def initialize(steam_id)
:weapons_donated => lifetime_data['wpndonated'].to_i,
:windows_broken => lifetime_data['winbroken'].to_i,
:zoomed_sniper_kills => lifetime_data['zsniperkills'].to_i,
:kdratio => (@total_stats[:deaths] > 0) ? @last_match_stats[:kills].to_f / @last_match_stats[:deaths] : 0,
:accuracy => (@total_stats[:shots] > 0) ? @total_stats[:hits].to_f / @total_stats[:shots] : 0,
:kdratio => (@total_stats[:deaths] > 0) ? @total_stats[:kills].to_f / @total_stats[:deaths] : 0,
:rounds_lost => @total_stats[:rounds_played] - @total_stats[:rounds_won]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ module SteamCondenser::Servers::Packets
#
# @author Sebastian Staudt
# @see MasterServer#servers
class A2M_GET_SERVERS_BATCH2_Packet
class A2M_GET_SERVERS_BATCH2_Packet < BasePacket

include BasePacket
HEADER = 0x31

# Creates a master server request, filtering by the given paramters
#
Expand All @@ -45,7 +45,7 @@ class A2M_GET_SERVERS_BATCH2_Packet
# @param [String] filter The filters to apply in the form
# "\filtername\value..."
def initialize(region_code = Servers::MasterServer::REGION_ALL, start_ip = '0.0.0.0:0', filter = '')
super A2M_GET_SERVERS_BATCH2_HEADER
super HEADER

@filter = filter
@region_code = region_code
Expand Down
6 changes: 3 additions & 3 deletions lib/steam-condenser/servers/packets/a2s_info_packet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ module SteamCondenser::Servers::Packets
#
# @author Sebastian Staudt
# @see GameServer#update_server_info
class A2S_INFO_Packet
class A2S_INFO_Packet < BasePacket

include BasePacket
HEADER = 0x54

# Creates a new A2S_INFO request object
def initialize
super A2S_INFO_HEADER, "Source Engine Query\0"
super HEADER, "Source Engine Query\0"
end

end
Expand Down
8 changes: 4 additions & 4 deletions lib/steam-condenser/servers/packets/a2s_player_packet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ module SteamCondenser::Servers::Packets
#
# @author Sebastian Staudt
# @see GameServer#update_player_info
class A2S_PLAYER_Packet

include BasePacket
class A2S_PLAYER_Packet < BasePacket
include RequestWithChallenge

HEADER = 0x55

# Creates a new A2S_PLAYER request object including the challenge number
#
# @param [Numeric] challenge_number The challenge number received from the
# server
def initialize(challenge_number = -1)
super A2S_PLAYER_HEADER, challenge_number
super HEADER, challenge_number
end

end
Expand Down
8 changes: 4 additions & 4 deletions lib/steam-condenser/servers/packets/a2s_rules_packet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ module SteamCondenser::Servers::Packets
#
# @author Sebastian Staudt
# @see GameServer#update_rules_info
class A2S_RULES_Packet

include BasePacket
class A2S_RULES_Packet < BasePacket
include RequestWithChallenge

HEADER = 0x56

# Creates a new A2S_RULES request object including the challenge number
#
# @param [Numeric] challenge_number The challenge number received from the
# server
def initialize(challenge_number = -1)
super A2S_RULES_HEADER, challenge_number
super HEADER, challenge_number
end

end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ module SteamCondenser::Servers::Packets
#
# @author Sebastian Staudt
# @see GameServer#update_challenge_number
class A2S_SERVERQUERY_GETCHALLENGE_Packet
class A2S_SERVERQUERY_GETCHALLENGE_Packet < BasePacket

include BasePacket
HEADER = 0x57

# Creates a new A2S_SERVERQUERY_GETCHALLENGE request object
def initialize
super A2S_SERVERQUERY_GETCHALLENGE_HEADER
super HEADER
end

end
Expand Down
21 changes: 2 additions & 19 deletions lib/steam-condenser/servers/packets/base_packet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,12 @@ module SteamCondenser::Servers

module Packets

# This module implements the basic functionality used by most of the packets
# This class implements the basic functionality used by most of the packets
# used in communication with master, Source or GoldSrc servers.
#
# @author Sebastian Staudt
# @see SteamPacketFactory
module BasePacket

A2M_GET_SERVERS_BATCH2_HEADER = 0x31
A2S_INFO_HEADER = 0x54
A2S_PLAYER_HEADER = 0x55
A2S_RULES_HEADER = 0x56
A2S_SERVERQUERY_GETCHALLENGE_HEADER = 0x57
C2M_CHECKMD5_HEADER = 0x4D
M2A_SERVER_BATCH_HEADER = 0x66
RCON_GOLDSRC_CHALLENGE_HEADER = 0x63
RCON_GOLDSRC_NO_CHALLENGE_HEADER = 0x39
RCON_GOLDSRC_RESPONSE_HEADER = 0x6c
S2A_INFO_DETAILED_HEADER = 0x6D
S2A_INFO2_HEADER = 0x49
S2A_PLAYER_HEADER = 0x44
S2A_RULES_HEADER = 0x45
S2C_CONNREJECT_HEADER = 0x39
S2C_CHALLENGE_HEADER = 0x41
class BasePacket

# Creates a new packet object based on the given data
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ module SteamCondenser::Servers::Packets
#
# @author Sebastian Staudt
# @see MasterServer#servers
class M2A_SERVER_BATCH_Packet
class M2A_SERVER_BATCH_Packet < BasePacket

include BasePacket
HEADER = 0x66

# Returns the list of servers returned from the server in this packet
#
Expand All @@ -31,7 +31,7 @@ class M2A_SERVER_BATCH_Packet
# @param [String] data The raw packet data replied from the server
# @raise [Error::PacketFormat] if the packet data is not well formatted
def initialize(data)
super M2A_SERVER_BATCH_HEADER, data
super HEADER, data

unless @content_data.getbyte == 0x0A
raise SteamCondenser::Error::PacketFormat, 'Master query response is missing additional 0x0A byte.'
Expand Down
22 changes: 4 additions & 18 deletions lib/steam-condenser/servers/packets/rcon/base_packet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,7 @@ module RCON
#
# @author Sebastian Staudt
# @see RCONPacketFactory
module BasePacket

include SteamCondenser::Servers::Packets::BasePacket

# Header for authentication requests
SERVERDATA_AUTH = 3

# Header for replies to authentication attempts
SERVERDATA_AUTH_RESPONSE = 2

# Header for command execution requests
SERVERDATA_EXECCOMMAND = 2

# Header for packets with the output of a command execution
SERVERDATA_RESPONSE_VALUE = 0
class BasePacket

# Returns the request ID used to identify the RCON communication
#
Expand All @@ -46,9 +32,9 @@ module BasePacket
# @param [Fixnum] rcon_header The header for the packet type
# @param [String] rcon_data The raw packet data
def initialize(request_id, rcon_header, rcon_data)
super rcon_header, "#{rcon_data}\0\0"

@request_id = request_id
@request_id = request_id
@header_data = rcon_header
@content_data = StringIO.new "#{rcon_data}\0\0"
end

# Returns the raw data representing this packet
Expand Down
39 changes: 21 additions & 18 deletions lib/steam-condenser/servers/packets/rcon/rcon_auth_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,30 @@

require 'steam-condenser/servers/packets/rcon/base_packet'

module SteamCondenser::Servers::Packets::RCON
module SteamCondenser::Servers::Packets
module RCON

# This packet class represents a SERVERDATA_AUTH request sent to a Source
# server
#
# It is used to authenticate the client for RCON communication.
#
# @author Sebastian Staudt
# @see SourceServer#rcon_auth
class RCONAuthRequest
# This packet class represents a HEADER request sent to a Source
# server
#
# It is used to authenticate the client for RCON communication.
#
# @author Sebastian Staudt
# @see SourceServer#rcon_auth
class RCONAuthRequest < BasePacket

include BasePacket
# Header for authentication requests
HEADER = 3

# Creates a RCON authentication request for the given request ID and RCON
# password
#
# @param [Fixnum] request_id The request ID of the RCON connection
# @param [String] rcon_password The RCON password of the server
def initialize(request_id, rcon_password)
super request_id, SERVERDATA_AUTH, rcon_password
end
# Creates a RCON authentication request for the given request ID and RCON
# password
#
# @param [Fixnum] request_id The request ID of the RCON connection
# @param [String] rcon_password The RCON password of the server
def initialize(request_id, rcon_password)
super request_id, HEADER, rcon_password
end

end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@

module SteamCondenser::Servers::Packets::RCON

# This packet class represents a SERVERDATA_AUTH_RESPONSE packet sent by a
# This packet class represents a HEADER packet sent by a
# Source server
#
# It is used to indicate the success or failure of an authentication attempt
# of a client for RCON communication.
#
# @author Sebastian Staudt
# @see SourceServer#rcon_auth
class RCONAuthResponse
class RCONAuthResponse < BasePacket

include BasePacket
# Header for replies to authentication attempts
HEADER = 2

# Creates a RCON authentication response for the given request ID
#
Expand All @@ -26,7 +27,7 @@ class RCONAuthResponse
#
# @param [Fixnum] request_id The request ID of the RCON connection
def initialize(request_id)
super request_id, SERVERDATA_AUTH_RESPONSE, ''
super request_id, HEADER, ''
end

end
Expand Down
7 changes: 4 additions & 3 deletions lib/steam-condenser/servers/packets/rcon/rcon_exec_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@ module SteamCondenser::Servers::Packets::RCON
#
# @author Sebastian Staudt
# @see SourceServer#rcon_exec
class RCONExecRequest
class RCONExecRequest < BasePacket

include BasePacket
# Header for command execution requests
EXECCOMMAND = 2

# Creates a RCON command execution request for the given request ID and
# command
#
# @param [Fixnum] request_id The request ID of the RCON connection
# @param [String] rcon_command The command to execute on the server
def initialize(request_id, rcon_command)
super request_id, SERVERDATA_EXECCOMMAND, rcon_command
super request_id, EXECCOMMAND, rcon_command
end

end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@

module SteamCondenser::Servers::Packets::RCON

# This packet class represents a SERVERDATA_RESPONSE_VALUE packet sent by a
# This packet class represents a HEADER packet sent by a
# Source server
#
# It is used to transport the output of a command from the server to the
# client which requested the command execution.
#
# @author Sebastian Staudt
# @see SourceServer#rcon_exec
class RCONExecResponse
class RCONExecResponse < BasePacket

include BasePacket
# Header for packets with the output of a command execution
HEADER = 0

# Creates a RCON command response for the given request ID and command
# output
Expand All @@ -26,7 +27,7 @@ class RCONExecResponse
# @param [String] command_response The output of the command executed on
# the server
def initialize(request_id, command_response)
super request_id, SERVERDATA_RESPONSE_VALUE, command_response
super request_id, HEADER, command_response
end

# Returns the output of the command execution
Expand Down
48 changes: 24 additions & 24 deletions lib/steam-condenser/servers/packets/rcon/rcon_goldsrc_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@

require 'steam-condenser/servers/packets/base_packet'

module SteamCondenser::Servers::Packets::RCON
module SteamCondenser::Servers::Packets
module RCON

# This packet class represents a RCON request packet sent to a GoldSrc server
#
# It is used to request a command execution on the server.
#
# @author Sebastian Staudt
# @see GoldSrcServer#rcon_exec
class RCONGoldSrcRequest

include SteamCondenser::Servers::Packets::BasePacket

# Creates a request for the given request string
# This packet class represents a RCON request packet sent to a GoldSrc server
#
# The request string has the form `rcon {challenge number} {RCON password}
# {command}`.
# It is used to request a command execution on the server.
#
# @param [String] request The request string to send to the server
def initialize(request)
super 0x00, request
end
# @author Sebastian Staudt
# @see GoldSrcServer#rcon_exec
class RCONGoldSrcRequest < BasePacket

# Returns the raw data representing this packet
#
# @return [String] A string containing the raw data of this request packet
def to_s
[0xFFFFFFFF, @content_data.string].pack('Va*')
end
# Creates a request for the given request string
#
# The request string has the form `rcon {challenge number} {RCON password}
# {command}`.
#
# @param [String] request The request string to send to the server
def initialize(request)
super 0x00, request
end

# Returns the raw data representing this packet
#
# @return [String] A string containing the raw data of this request packet
def to_s
[0xFFFFFFFF, @content_data.string].pack('Va*')
end

end
end
end
Loading