gamespy_query 0.0.2 → 0.0.3
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.rb +4 -4
- data/lib/gamespy_query/base.rb +6 -2
- data/lib/gamespy_query/parser.rb +2 -3
- data/lib/gamespy_query/socket.rb +4 -6
- data/lib/gamespy_query/version.rb +1 -1
- metadata +2 -2
data/lib/gamespy_query.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require_relative "gamespy_query/version"
|
2
|
+
require_relative "gamespy_query/base"
|
3
|
+
require_relative "gamespy_query/socket"
|
4
|
+
require_relative "gamespy_query/master"
|
5
5
|
|
6
6
|
module GamespyQuery
|
7
7
|
# Your code goes here...
|
data/lib/gamespy_query/base.rb
CHANGED
@@ -3,6 +3,11 @@ require 'action_controller'
|
|
3
3
|
require 'logger'
|
4
4
|
|
5
5
|
module GamespyQuery
|
6
|
+
STR_X0, STR_X1, STR_X2 = "\x00", "\x01", "\x02"
|
7
|
+
RX_X0, RX_X0_S, RX_X0_E = /\x00/, /^\x00/, /\x00$/
|
8
|
+
RX_X0_SPEC = /^\x00|[^\x00]+\x00?/
|
9
|
+
STR_EMPTY = ""
|
10
|
+
|
6
11
|
module Tools
|
7
12
|
STR_EMPTY = ""
|
8
13
|
|
@@ -22,14 +27,13 @@ module GamespyQuery
|
|
22
27
|
str
|
23
28
|
end
|
24
29
|
|
25
|
-
STR_X00 = "\x00"
|
26
30
|
RX_F = /\A\-?[0-9][0-9]*\.[0-9]*\Z/
|
27
31
|
RX_I = /\A\-?[0-9][0-9]*\Z/
|
28
32
|
RX_S = /\A\-?0[0-9]+.*\Z/
|
29
33
|
|
30
34
|
def clean(value) # TODO: Force String, Integer, Float etc?
|
31
35
|
case value
|
32
|
-
when
|
36
|
+
when STR_X0
|
33
37
|
nil
|
34
38
|
when RX_F
|
35
39
|
value =~ RX_S ? strip_tags(value) : value.to_f
|
data/lib/gamespy_query/parser.rb
CHANGED
@@ -11,13 +11,10 @@ require_relative 'base'
|
|
11
11
|
|
12
12
|
module GamespyQuery
|
13
13
|
class Parser
|
14
|
-
STR_X0 = "\x00"
|
15
14
|
STR_SPLIT = STR_X0
|
16
|
-
STR_EMPTY = ""
|
17
15
|
STR_ID = "\x00\x04\x05\x06\a"
|
18
16
|
|
19
17
|
RX_SPLITNUM = /^splitnum\x00(.)/i
|
20
|
-
RX_X0_E = /\x00$/
|
21
18
|
RX_PLAYER_HEADER = /\x01/
|
22
19
|
RX_END = /\x00\x02$/
|
23
20
|
|
@@ -125,6 +122,8 @@ module GamespyQuery
|
|
125
122
|
STR_PLAYER = "player_\x00\x00"
|
126
123
|
STR_TEAM = "team_\x00\x00"
|
127
124
|
STR_SCORE = "score_\x00\x00"
|
125
|
+
STR_SIX = "$SIX_OVERWRITE_PREVIOUS$"
|
126
|
+
STR_SIX_X0 = "\x00#{STR_SIX}\x00"
|
128
127
|
|
129
128
|
# TODO: Cleanup
|
130
129
|
def parse_player_data(packet)
|
data/lib/gamespy_query/socket.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
# GameSpy query class by Sickboy [Patrick Roza] (sb_at_dev-heaven.net)
|
3
3
|
|
4
|
+
|
5
|
+
|
4
6
|
require 'yaml'
|
5
7
|
require_relative 'base'
|
6
8
|
require_relative 'parser'
|
@@ -25,19 +27,15 @@ module GamespyQuery
|
|
25
27
|
STR_PLAYER = "player_\x00\x00"
|
26
28
|
STR_TEAM = "team_\x00\x00"
|
27
29
|
STR_SCORE = "score_\x00\x00"
|
28
|
-
|
30
|
+
|
29
31
|
SPLIT = STR_X0
|
30
32
|
STR_END = "\x00\x02"
|
31
33
|
STR_EMPTY = Tools::STR_EMPTY
|
32
34
|
STR_BLA = "%c%c%c%c".encode("ASCII-8BIT")
|
33
35
|
STR_GARBAGE = "\x00\x04\x05\x06\a"
|
34
|
-
STR_SIX = "$SIX_OVERWRITE_PREVIOUS$"
|
35
|
-
STR_SIX_X0 = "\x00#{STR_SIX}\x00"
|
36
36
|
|
37
37
|
RX_PLAYER_EMPTY = /^player_\x00\x00\x00/
|
38
38
|
RX_PLAYER_INFO = /\x01(team|player|score|deaths)_.(.)/ # \x00 from previous packet, \x01 from continueing player info, (.) - should it overwrite previous value?
|
39
|
-
RX_X0, RX_X0_S, RX_X0_E = /\x00/, /^\x00/, /\x00$/
|
40
|
-
RX_X0_SPEC = /^\x00|[^\x00]+\x00?/
|
41
39
|
|
42
40
|
RX_NO_CHALLENGE = /0@0$/
|
43
41
|
RX_CHALLENGE = /0@/
|
@@ -261,7 +259,7 @@ end
|
|
261
259
|
if $0 == __FILE__
|
262
260
|
host = ARGV[0]
|
263
261
|
port = ARGV[1]
|
264
|
-
g =
|
262
|
+
g = GamespyQuery::Socket.new(host, port)
|
265
263
|
r = g.sync
|
266
264
|
exit unless r
|
267
265
|
puts r.to_yaml
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gamespy_query
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -49,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
49
|
version: '0'
|
50
50
|
requirements: []
|
51
51
|
rubyforge_project: gamespy_query
|
52
|
-
rubygems_version: 1.8.
|
52
|
+
rubygems_version: 1.8.14
|
53
53
|
signing_key:
|
54
54
|
specification_version: 3
|
55
55
|
summary: Ruby library for accessing Gamespy services
|