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
|
|
|
/** |
22
|
|
|
* Unreal Tournament 3 Protocol Class |
23
|
|
|
* |
24
|
|
|
* Note: The response from UT3 appears to not be consistent. Many times packets are incomplete or there are extra |
25
|
|
|
* "echoes" in the responses. This may cause issues like odd characters showing up in the keys for the player and team |
26
|
|
|
* array responses. Not sure much can be done about it. |
27
|
|
|
* |
28
|
|
|
* @author Austin Bischoff <[email protected]> |
29
|
|
|
*/ |
30
|
|
|
class Ut3 extends Gamespy3 |
31
|
|
|
{ |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* String name of this protocol class |
35
|
|
|
* |
36
|
|
|
* @type string |
37
|
|
|
*/ |
38
|
|
|
protected $name = 'ut3'; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Longer string name of this protocol class |
42
|
|
|
* |
43
|
|
|
* @type string |
44
|
|
|
*/ |
45
|
|
|
protected $name_long = "Unreal Tournament 3"; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Normalize settings for this protocol |
49
|
|
|
* |
50
|
|
|
* @type array |
51
|
|
|
*/ |
52
|
|
|
protected $normalize = [ |
53
|
|
|
// General |
54
|
|
|
'general' => [ |
55
|
|
|
'dedicated' => 'bIsDedicated', |
56
|
|
|
'hostname' => 'hostname', |
57
|
|
|
'numplayers' => 'numplayers', |
58
|
|
|
], |
59
|
|
|
]; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Overload the response process so we can make some changes |
63
|
|
|
* |
64
|
|
|
* @return array |
65
|
|
|
*/ |
66
|
|
|
public function processResponse() |
67
|
|
|
{ |
68
|
|
|
|
69
|
|
|
// Grab the result from the parent |
70
|
|
|
/** @type array $result */ |
71
|
|
|
$result = parent::processResponse(); |
72
|
|
|
|
73
|
|
|
// Move some stuff around |
74
|
|
|
$this->renameResult($result, 'OwningPlayerName', 'hostname'); |
75
|
|
|
$this->renameResult($result, 'p1073741825', 'mapname'); |
76
|
|
|
$this->renameResult($result, 'p1073741826', 'gametype'); |
77
|
|
|
$this->renameResult($result, 'p1073741827', 'servername'); |
78
|
|
|
$this->renameResult($result, 'p1073741828', 'custom_mutators'); |
79
|
|
|
$this->renameResult($result, 'gamemode', 'open'); |
80
|
|
|
$this->renameResult($result, 's32779', 'gamemode'); |
81
|
|
|
$this->renameResult($result, 's0', 'bot_skill'); |
82
|
|
|
$this->renameResult($result, 's6', 'pure_server'); |
83
|
|
|
$this->renameResult($result, 's7', 'password'); |
84
|
|
|
$this->renameResult($result, 's8', 'vs_bots'); |
85
|
|
|
$this->renameResult($result, 's10', 'force_respawn'); |
86
|
|
|
$this->renameResult($result, 'p268435704', 'frag_limit'); |
87
|
|
|
$this->renameResult($result, 'p268435705', 'time_limit'); |
88
|
|
|
$this->renameResult($result, 'p268435703', 'numbots'); |
89
|
|
|
$this->renameResult($result, 'p268435717', 'stock_mutators'); |
90
|
|
|
|
91
|
|
|
// Put custom mutators into an array |
92
|
|
|
if (isset($result['custom_mutators'])) { |
93
|
|
|
$result['custom_mutators'] = explode("\x1c", $result['custom_mutators']); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
// Delete some unknown stuff |
97
|
|
|
$this->deleteResult($result, ['s1', 's9', 's11', 's12', 's13', 's14']); |
98
|
|
|
|
99
|
|
|
// Return the result |
100
|
|
|
return $result; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Dirty hack to rename result entries into something more useful |
105
|
|
|
* |
106
|
|
|
* @param array $result |
107
|
|
|
* @param string $old |
108
|
|
|
* @param string $new |
109
|
|
|
*/ |
110
|
|
|
protected function renameResult(array &$result, $old, $new) |
111
|
|
|
{ |
112
|
|
|
|
113
|
|
|
// Check to see if the old item is there |
114
|
|
|
if (isset($result[$old])) { |
115
|
|
|
$result[$new] = $result[$old]; |
116
|
|
|
unset($result[$old]); |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Dirty hack to delete result items |
122
|
|
|
* |
123
|
|
|
* @param array $result |
124
|
|
|
* @param array $array |
125
|
|
|
*/ |
126
|
|
|
protected function deleteResult(array &$result, array $array) |
127
|
|
|
{ |
128
|
|
|
|
129
|
|
|
foreach ($array as $key) { |
130
|
|
|
unset($result[$key]); |
131
|
|
|
} |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
|