gamespy_query 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/gamespy_query/master.rb +8 -8
- data/lib/gamespy_query/version.rb +1 -1
- metadata +1 -1
data/lib/gamespy_query/master.rb
CHANGED
@@ -5,7 +5,7 @@ module GamespyQuery
|
|
5
5
|
PARAMS = [:hostname, :gamever, :gametype, :gamemode, :numplayers, :maxplayers, :password, :equalModRequired, :mission, :mapname,
|
6
6
|
:mod, :signatures, :verifysignatures, :gamestate, :dedicated, :platform, :sv_battleeye, :language, :difficulty]
|
7
7
|
|
8
|
-
RX_ADDR_LINE =
|
8
|
+
RX_ADDR_LINE = /^[\s\t]*([\d\.]+)[\s\t:]*(\d+)[\s\t]*(.*)$/
|
9
9
|
|
10
10
|
DELIMIT = case RUBY_PLATFORM
|
11
11
|
when /-mingw32$/, /-mswin32$/
|
@@ -29,9 +29,8 @@ module GamespyQuery
|
|
29
29
|
@geo, @game = geo, game
|
30
30
|
end
|
31
31
|
|
32
|
-
def process
|
33
|
-
|
34
|
-
self.to_hash(self.read)
|
32
|
+
def process list = self.read
|
33
|
+
self.to_hash list
|
35
34
|
end
|
36
35
|
|
37
36
|
def get_params
|
@@ -68,6 +67,7 @@ module GamespyQuery
|
|
68
67
|
RX_H = /\A([\.0-9]*):([0-9]*) *\\(.*)/
|
69
68
|
STR_SPLIT = "\\"
|
70
69
|
def to_hash(ar)
|
70
|
+
list = Hash.new
|
71
71
|
ar.each_with_index do |entry, index|
|
72
72
|
str = entry[RX_H]
|
73
73
|
next unless str
|
@@ -80,13 +80,13 @@ module GamespyQuery
|
|
80
80
|
i % 2 == 0 ? e : clean_string(e)
|
81
81
|
end
|
82
82
|
addr = "#{ip}:#{port}"
|
83
|
-
if
|
84
|
-
e =
|
83
|
+
if list.has_key?(addr)
|
84
|
+
e = list[addr]
|
85
85
|
else
|
86
86
|
e = Hash.new
|
87
87
|
e[:ip] = ip
|
88
88
|
e[:port] = port
|
89
|
-
|
89
|
+
list[addr] = e
|
90
90
|
end
|
91
91
|
if e[:gamedata]
|
92
92
|
e[:gamedata].merge!(Hash[*content])
|
@@ -94,7 +94,7 @@ module GamespyQuery
|
|
94
94
|
e[:gamedata] = Hash[*content]
|
95
95
|
end
|
96
96
|
end
|
97
|
-
|
97
|
+
list
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|