Package: xqf / 1.0.6-1

qstat_savage_EXTRA_DIST.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
Author: Jordi Mallach <jordi@debian.org>
Description: Add missing qstat_savage.sh script to sources and EXTRA_DIST.
 Cherry-picked from Git.
Forwarded: not-needed

Index: xqf-1.0.6/src/Makefile.am
===================================================================
--- xqf-1.0.6.orig/src/Makefile.am
+++ xqf-1.0.6/src/Makefile.am
@@ -19,7 +19,13 @@ qstatcfg_DATA = qstat.cfg
 qstatsavagedir = $(pkgdatadir)
 qstatsavage_DATA = qstat_savage.sh
 
-EXTRA_DIST = qstat.cfg games.xml games.c $(noinst_SCRIPTS) xqf.map
+EXTRA_DIST = \
+	games.c \
+	games.xml \
+	qstat.cfg \
+	qstat_savage.sh \
+	xqf.map \
+	$(noinst_SCRIPTS)
 
 bin_PROGRAMS = xqf
 if BUILD_XQFRCON
Index: xqf-1.0.6/src/qstat_savage.sh
===================================================================
--- /dev/null
+++ xqf-1.0.6/src/qstat_savage.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+
+#url="http://masterserver.savage.s2games.com/gamelist_full.dat"
+url="$1"
+
+if [ "x${url}" = 'x' ]
+then
+	exit
+fi
+
+http_helper="wget -t 1 -T 20 -q -e robots=off --user-agent=XQF -O -"
+server_type="SAS"
+header="7e4103"
+
+header_len="3"
+data_start="5"
+address_len="6"
+
+alias get_response="${http_helper} ${url}"
+alias get_header="get_response | od -N${header_len} -An -vtx1 | tr -d ' '"
+alias get_data="get_response | dd bs=1 skip=${data_start} 2>/dev/null"
+
+if [ "$(get_header)" = "${header}" ]
+then
+	data="$(get_data)"
+	data_size="$(($(echo "${data}" | wc -c) / 6 * 6))"
+
+	skip="0"
+	while [ "${skip}" -lt "${data_size}" ]
+	do
+		ipv4_1="$(echo "${data}" | od -j${skip} -N1 -An -vtu1 | tr -d ' ')"
+		ipv4_2="$(echo "${data}" | od -j$((${skip} + 1)) -N1 -An -vtu1 | tr -d ' ')"
+		ipv4_3="$(echo "${data}" | od -j$((${skip} + 2)) -N1 -An -vtu1 | tr -d ' ')"
+		ipv4_4="$(echo "${data}" | od -j$((${skip} + 3)) -N1 -An -vtu1 | tr -d ' ')"
+		port="$(echo "${data}" | od -j$((${skip} + 4)) -N2 -An -vtu2 | tr -d ' ')"
+
+		ipv4="${ipv4_1}.${ipv4_2}.${ipv4_3}.${ipv4_4}"
+		server_address="${ipv4}:${port}"
+
+		echo "${server_type} ${server_address}"
+
+		skip="$((${skip} + ${address_len}))"
+	done
+fi
+
+#EOF