1 | <?php |
||
31 | class Etqw 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_STATUS => "\xFF\xFFgetInfoEx\x00\x00\x00\x00", |
||
42 | //self::PACKET_STATUS => "\xFF\xFFgetInfo\x00\x00\x00\x00\x00", |
||
43 | ]; |
||
44 | |||
45 | /** |
||
46 | * Use the response flag to figure out what method to run |
||
47 | * |
||
48 | * @type array |
||
49 | */ |
||
50 | protected $responses = [ |
||
51 | "\xFF\xFFinfoExResponse" => "processStatus", |
||
52 | ]; |
||
53 | |||
54 | /** |
||
55 | * The query protocol used to make the call |
||
56 | * |
||
57 | * @type string |
||
58 | */ |
||
59 | protected $protocol = 'etqw'; |
||
60 | |||
61 | /** |
||
62 | * String name of this protocol class |
||
63 | * |
||
64 | * @type string |
||
65 | */ |
||
66 | protected $name = 'etqw'; |
||
67 | |||
68 | /** |
||
69 | * Longer string name of this protocol class |
||
70 | * |
||
71 | * @type string |
||
72 | */ |
||
73 | protected $name_long = "Enemy Territory Quake Wars"; |
||
74 | |||
75 | /** |
||
76 | * Normalize settings for this protocol |
||
77 | * |
||
78 | * @type array |
||
79 | */ |
||
80 | protected $normalize = [ |
||
81 | // General |
||
82 | 'general' => [ |
||
83 | // target => source |
||
84 | 'gametype' => 'campaign', |
||
85 | 'hostname' => 'name', |
||
86 | 'mapname' => 'map', |
||
87 | 'maxplayers' => 'maxPlayers', |
||
88 | 'mod' => 'gamename', |
||
89 | 'numplayers' => 'numplayers', |
||
90 | 'password' => 'privateClients', |
||
91 | ], |
||
92 | // Individual |
||
93 | 'player' => [ |
||
94 | 'name' => 'name', |
||
95 | 'score' => 'score', |
||
96 | 'time' => 'time', |
||
97 | ], |
||
98 | ]; |
||
99 | |||
100 | /** |
||
101 | * Process the response |
||
102 | * |
||
103 | * @return array |
||
104 | * @throws \GameQ\Exception\Protocol |
||
105 | */ |
||
106 | 3 | public function processResponse() |
|
124 | |||
125 | /* |
||
126 | * Internal methods |
||
127 | */ |
||
128 | |||
129 | /** |
||
130 | * Handle processing the status response |
||
131 | * |
||
132 | * @param Buffer $buffer |
||
133 | * |
||
134 | * @return array |
||
135 | */ |
||
136 | 3 | protected function processStatus(Buffer $buffer) |
|
183 | |||
184 | /** |
||
185 | * Parse players out of the status ex response |
||
186 | * |
||
187 | * @param Buffer $buffer |
||
188 | * @param Result $result |
||
189 | */ |
||
190 | 3 | protected function parsePlayers(Buffer &$buffer, Result &$result) |
|
212 | |||
213 | /** |
||
214 | * Handle parsing extra player data |
||
215 | * |
||
216 | * @param Buffer $buffer |
||
217 | * @param Result $result |
||
218 | */ |
||
219 | 3 | protected function parsePlayersExtra(Buffer &$buffer, Result &$result) |
|
234 | } |
||
235 |