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\Helpers\Str; |
23: | use GameQ\Result; |
24: | |
25: | /** |
26: | * Class Killing floor |
27: | * |
28: | * @package GameQ\Protocols |
29: | * @author Austin Bischoff <austin@codebeard.com> |
30: | */ |
31: | class Killingfloor extends Unreal2 |
32: | { |
33: | /** |
34: | * String name of this protocol class |
35: | * |
36: | * @var string |
37: | */ |
38: | protected $name = 'killing floor'; |
39: | |
40: | /** |
41: | * Longer string name of this protocol class |
42: | * |
43: | * @var string |
44: | */ |
45: | protected $name_long = "Killing Floor"; |
46: | |
47: | /** |
48: | * query_port = client_port + 1 |
49: | * |
50: | * @var int |
51: | */ |
52: | protected $port_diff = 1; |
53: | |
54: | /** |
55: | * The client join link |
56: | * |
57: | * @var string |
58: | */ |
59: | protected $join_link = "steam://connect/%s:%d/"; |
60: | |
61: | /** |
62: | * Overload the default detail process since this version is different |
63: | * |
64: | * @param \GameQ\Buffer $buffer |
65: | * |
66: | * @return array |
67: | * @throws \GameQ\Exception\Protocol |
68: | */ |
69: | protected function processDetails(Buffer $buffer) |
70: | { |
71: | // Set the result to a new result instance |
72: | $result = new Result(); |
73: | |
74: | $result->add('serverid', $buffer->readInt32()); // 0 |
75: | $result->add('serverip', $buffer->readPascalString(1)); // empty |
76: | $result->add('gameport', $buffer->readInt32()); |
77: | $result->add('queryport', $buffer->readInt32()); // 0 |
78: | |
79: | // We burn the first char since it is not always correct with the hostname |
80: | $buffer->skip(1); |
81: | |
82: | // Read as a regular string since the length is incorrect (what we skipped earlier) |
83: | $result->add('servername', Str::isoToUtf8($buffer->readString())); |
84: | |
85: | // The rest is read as normal |
86: | $result->add('mapname', Str::isoToUtf8($buffer->readPascalString(1))); |
87: | $result->add('gametype', $buffer->readPascalString(1)); |
88: | $result->add('numplayers', $buffer->readInt32()); |
89: | $result->add('maxplayers', $buffer->readInt32()); |
90: | $result->add('currentwave', $buffer->readInt32()); |
91: | |
92: | unset($buffer); |
93: | |
94: | return $result->fetch(); |
95: | } |
96: | } |
97: |