1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of GameQ. |
4
|
|
|
* |
5
|
|
|
* GameQ is free software; you can redistribute it and/or modify |
6
|
|
|
* it under the terms of the GNU Lesser General Public License as published by |
7
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
8
|
|
|
* (at your option) any later version. |
9
|
|
|
* |
10
|
|
|
* GameQ is distributed in the hope that it will be useful, |
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13
|
|
|
* GNU Lesser General Public License for more details. |
14
|
|
|
* |
15
|
|
|
* You should have received a copy of the GNU Lesser General Public License |
16
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace GameQ\Protocols; |
20
|
|
|
|
21
|
|
|
use GameQ\Buffer; |
22
|
|
|
use GameQ\Result; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Warsow Protocol Class |
26
|
|
|
* |
27
|
|
|
* @package GameQ\Protocols |
28
|
|
|
* @author Austin Bischoff <[email protected]> |
29
|
|
|
*/ |
30
|
|
|
class Warsow extends Quake3 |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* String name of this protocol class |
34
|
|
|
* |
35
|
|
|
* @type string |
36
|
|
|
*/ |
37
|
|
|
protected $name = 'warsow'; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Longer string name of this protocol class |
41
|
|
|
* |
42
|
|
|
* @type string |
43
|
|
|
*/ |
44
|
|
|
protected $name_long = "Warsow"; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* The client join link |
48
|
|
|
* |
49
|
|
|
* @type string |
50
|
|
|
*/ |
51
|
|
|
protected $join_link = "warsow://%s:%d/"; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Handle player info, different than quake3 base |
55
|
|
|
* |
56
|
|
|
* @param Buffer $buffer |
57
|
|
|
* |
58
|
|
|
* @return array |
59
|
|
|
* @throws \GameQ\Exception\Protocol |
60
|
|
|
*/ |
61
|
|
|
protected function processPlayers(Buffer $buffer) |
62
|
|
|
{ |
63
|
|
|
// Set the result to a new result instance |
64
|
|
|
$result = new Result(); |
65
|
|
|
|
66
|
|
|
// Loop until we are out of data |
67
|
|
|
while ($buffer->getLength()) { |
68
|
|
|
// Make a new buffer with this block |
69
|
|
|
$playerInfo = new Buffer($buffer->readString("\x0A")); |
70
|
|
|
|
71
|
|
|
// Add player info |
72
|
|
|
$result->addPlayer('frags', $playerInfo->readString("\x20")); |
73
|
|
|
$result->addPlayer('ping', $playerInfo->readString("\x20")); |
74
|
|
|
|
75
|
|
|
// Skip first " |
76
|
|
|
$playerInfo->skip(1); |
77
|
|
|
|
78
|
|
|
// Add player name, encoded |
79
|
|
|
$result->addPlayer('name', utf8_encode(trim(($playerInfo->readString('"'))))); |
80
|
|
|
|
81
|
|
|
// Skip space |
82
|
|
|
$playerInfo->skip(1); |
83
|
|
|
|
84
|
|
|
// Add team |
85
|
|
|
$result->addPlayer('team', $playerInfo->read()); |
86
|
|
|
|
87
|
|
|
// Clear |
88
|
|
|
unset($playerInfo); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
// Clear |
92
|
|
|
unset($buffer); |
93
|
|
|
|
94
|
|
|
return $result->fetch(); |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|