1 | <?php |
||
18 | class Quake3 extends Protocol |
||
19 | { |
||
20 | /** |
||
21 | * Array of packets we want to look up. |
||
22 | * Each key should correspond to a defined method in this or a parent class |
||
23 | * |
||
24 | * @type array |
||
25 | */ |
||
26 | protected $packets = [ |
||
27 | self::PACKET_STATUS => "\xFF\xFF\xFF\xFF\x67\x65\x74\x73\x74\x61\x74\x75\x73\x0A", |
||
28 | ]; |
||
29 | |||
30 | /** |
||
31 | * Use the response flag to figure out what method to run |
||
32 | * |
||
33 | * @type array |
||
34 | */ |
||
35 | protected $responses = [ |
||
36 | "\xFF\xFF\xFF\xFFstatusResponse" => 'processStatus', |
||
37 | ]; |
||
38 | |||
39 | /** |
||
40 | * The query protocol used to make the call |
||
41 | * |
||
42 | * @type string |
||
43 | */ |
||
44 | protected $protocol = 'quake3'; |
||
45 | |||
46 | /** |
||
47 | * String name of this protocol class |
||
48 | * |
||
49 | * @type string |
||
50 | */ |
||
51 | protected $name = 'quake3'; |
||
52 | |||
53 | /** |
||
54 | * Longer string name of this protocol class |
||
55 | * |
||
56 | * @type string |
||
57 | */ |
||
58 | protected $name_long = "Quake 3 Server"; |
||
59 | |||
60 | /** |
||
61 | * The client join link |
||
62 | * |
||
63 | * @type string |
||
64 | */ |
||
65 | protected $join_link = null; |
||
66 | |||
67 | /** |
||
68 | * Normalize settings for this protocol |
||
69 | * |
||
70 | * @type array |
||
71 | */ |
||
72 | protected $normalize = [ |
||
73 | // General |
||
74 | 'general' => [ |
||
75 | // target => source |
||
76 | 'gametype' => 'gamename', |
||
77 | 'hostname' => 'sv_hostname', |
||
78 | 'mapname' => 'mapname', |
||
79 | 'maxplayers' => 'sv_maxclients', |
||
80 | 'mod' => 'g_gametype', |
||
81 | 'numplayers' => 'clients', |
||
82 | 'password' => ['g_needpass', 'pswrd'], |
||
83 | ], |
||
84 | // Individual |
||
85 | 'player' => [ |
||
86 | 'name' => 'name', |
||
87 | 'ping' => 'ping', |
||
88 | 'score' => 'frags', |
||
89 | ], |
||
90 | ]; |
||
91 | |||
92 | /** |
||
93 | * Handle response from the server |
||
94 | * |
||
95 | * @return mixed |
||
96 | * @throws Exception |
||
97 | */ |
||
98 | 18 | public function processResponse() |
|
113 | |||
114 | 16 | protected function processStatus(Buffer $buffer) |
|
129 | |||
130 | /** |
||
131 | * Handle processing the server information |
||
132 | * |
||
133 | * @param Buffer $buffer |
||
134 | * |
||
135 | * @return array |
||
136 | */ |
||
137 | 16 | protected function processServerInfo(Buffer $buffer) |
|
158 | |||
159 | /** |
||
160 | * Handle processing of player data |
||
161 | * |
||
162 | * @param Buffer $buffer |
||
163 | * |
||
164 | * @return array |
||
165 | * @throws Exception |
||
166 | */ |
||
167 | 14 | protected function processPlayers(Buffer $buffer) |
|
214 | } |
||
215 |