1: | <?php |
2: | |
3: | |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: | |
12: | |
13: | |
14: | |
15: | |
16: | |
17: | |
18: | |
19: | namespace GameQ\Protocols; |
20: | |
21: | |
22: | |
23: | |
24: | |
25: | |
26: | |
27: | |
28: | |
29: | |
30: | class Ut3 extends Gamespy3 |
31: | { |
32: | |
33: | |
34: | |
35: | |
36: | |
37: | protected $name = 'ut3'; |
38: | |
39: | |
40: | |
41: | |
42: | |
43: | |
44: | protected $name_long = "Unreal Tournament 3"; |
45: | |
46: | |
47: | |
48: | |
49: | |
50: | |
51: | protected $normalize = [ |
52: | |
53: | 'general' => [ |
54: | 'dedicated' => 'bIsDedicated', |
55: | 'hostname' => 'hostname', |
56: | 'numplayers' => 'numplayers', |
57: | ], |
58: | ]; |
59: | |
60: | |
61: | |
62: | |
63: | |
64: | |
65: | |
66: | public function processResponse() |
67: | { |
68: | |
69: | |
70: | $result = parent::processResponse(); |
71: | |
72: | |
73: | $this->renameResult($result, 'OwningPlayerName', 'hostname'); |
74: | $this->renameResult($result, 'p1073741825', 'mapname'); |
75: | $this->renameResult($result, 'p1073741826', 'gametype'); |
76: | $this->renameResult($result, 'p1073741827', 'servername'); |
77: | $this->renameResult($result, 'p1073741828', 'custom_mutators'); |
78: | $this->renameResult($result, 'gamemode', 'open'); |
79: | $this->renameResult($result, 's32779', 'gamemode'); |
80: | $this->renameResult($result, 's0', 'bot_skill'); |
81: | $this->renameResult($result, 's6', 'pure_server'); |
82: | $this->renameResult($result, 's7', 'password'); |
83: | $this->renameResult($result, 's8', 'vs_bots'); |
84: | $this->renameResult($result, 's10', 'force_respawn'); |
85: | $this->renameResult($result, 'p268435704', 'frag_limit'); |
86: | $this->renameResult($result, 'p268435705', 'time_limit'); |
87: | $this->renameResult($result, 'p268435703', 'numbots'); |
88: | $this->renameResult($result, 'p268435717', 'stock_mutators'); |
89: | |
90: | |
91: | if (isset($result['custom_mutators'])) { |
92: | $result['custom_mutators'] = explode("\x1c", $result['custom_mutators']); |
93: | } |
94: | |
95: | |
96: | $this->deleteResult($result, ['s1', 's9', 's11', 's12', 's13', 's14']); |
97: | |
98: | |
99: | return $result; |
100: | } |
101: | |
102: | |
103: | |
104: | |
105: | |
106: | |
107: | |
108: | |
109: | protected function renameResult(array &$result, $old, $new) |
110: | { |
111: | |
112: | if (isset($result[$old])) { |
113: | $result[$new] = $result[$old]; |
114: | unset($result[$old]); |
115: | } |
116: | } |
117: | |
118: | |
119: | |
120: | |
121: | |
122: | |
123: | |
124: | protected function deleteResult(array &$result, array $array) |
125: | { |
126: | foreach ($array as $key) { |
127: | unset($result[$key]); |
128: | } |
129: | } |
130: | } |
131: | |