1 | <?php |
||
31 | class Unreal2 extends Protocol |
||
32 | { |
||
33 | |||
34 | /** |
||
35 | * Array of packets we want to look up. |
||
36 | * Each key should correspond to a defined method in this or a parent class |
||
37 | * |
||
38 | * @type array |
||
39 | */ |
||
40 | protected $packets = [ |
||
41 | self::PACKET_DETAILS => "\x79\x00\x00\x00\x00", |
||
42 | self::PACKET_RULES => "\x79\x00\x00\x00\x01", |
||
43 | self::PACKET_PLAYERS => "\x79\x00\x00\x00\x02", |
||
44 | ]; |
||
45 | |||
46 | /** |
||
47 | * Use the response flag to figure out what method to run |
||
48 | * |
||
49 | * @type array |
||
50 | */ |
||
51 | protected $responses = [ |
||
52 | "\x80\x00\x00\x00\x00" => "processDetails", // 0 |
||
53 | "\x80\x00\x00\x00\x01" => "processRules", // 1 |
||
54 | "\x80\x00\x00\x00\x02" => "processPlayers", // 2 |
||
55 | ]; |
||
56 | |||
57 | /** |
||
58 | * The query protocol used to make the call |
||
59 | * |
||
60 | * @type string |
||
61 | */ |
||
62 | protected $protocol = 'unreal2'; |
||
63 | |||
64 | /** |
||
65 | * String name of this protocol class |
||
66 | * |
||
67 | * @type string |
||
68 | */ |
||
69 | protected $name = 'unreal2'; |
||
70 | |||
71 | /** |
||
72 | * Longer string name of this protocol class |
||
73 | * |
||
74 | * @type string |
||
75 | */ |
||
76 | protected $name_long = "Unreal 2"; |
||
77 | |||
78 | /** |
||
79 | * Normalize settings for this protocol |
||
80 | * |
||
81 | * @type array |
||
82 | */ |
||
83 | protected $normalize = [ |
||
84 | // General |
||
85 | 'general' => [ |
||
86 | // target => source |
||
87 | 'dedicated' => 'ServerMode', |
||
88 | 'gametype' => 'gametype', |
||
89 | 'hostname' => 'servername', |
||
90 | 'mapname' => 'mapname', |
||
91 | 'maxplayers' => 'maxplayers', |
||
92 | 'numplayers' => 'numplayers', |
||
93 | 'password' => 'password', |
||
94 | ], |
||
95 | // Individual |
||
96 | 'player' => [ |
||
97 | 'name' => 'name', |
||
98 | 'score' => 'score', |
||
99 | ], |
||
100 | ]; |
||
101 | |||
102 | /** |
||
103 | * Process the response |
||
104 | * |
||
105 | * @return array |
||
106 | * @throws \GameQ\Exception\Protocol |
||
107 | */ |
||
108 | 6 | public function processResponse() |
|
147 | |||
148 | /* |
||
149 | * Internal methods |
||
150 | */ |
||
151 | |||
152 | /** |
||
153 | * Handles processing the details data into a usable format |
||
154 | * |
||
155 | * @param \GameQ\Buffer $buffer |
||
156 | * |
||
157 | * @return mixed |
||
158 | * @throws \GameQ\Exception\Protocol |
||
159 | */ |
||
160 | 2 | protected function processDetails(Buffer $buffer) |
|
181 | |||
182 | /** |
||
183 | * Handles processing the player data into a usable format |
||
184 | * |
||
185 | * @param \GameQ\Buffer $buffer |
||
186 | * |
||
187 | * @return mixed |
||
188 | */ |
||
189 | 4 | protected function processPlayers(Buffer $buffer) |
|
214 | |||
215 | /** |
||
216 | * Handles processing the rules data into a usable format |
||
217 | * |
||
218 | * @param \GameQ\Buffer $buffer |
||
219 | * |
||
220 | * @return mixed |
||
221 | */ |
||
222 | 4 | protected function processRules(Buffer $buffer) |
|
246 | } |
||
247 |