1 | <?php |
||
34 | class Cs2d extends Protocol |
||
35 | { |
||
36 | |||
37 | /** |
||
38 | * Array of packets we want to query. |
||
39 | * |
||
40 | * @type array |
||
41 | */ |
||
42 | protected $packets = [ |
||
43 | self::PACKET_STATUS => "\x01\x00\xFB\x01", |
||
44 | //self::PACKET_STATUS => "\x01\x00\x03\x10\x21\xFB\x01\x75\x00", |
||
45 | self::PACKET_PLAYERS => "\x01\x00\xFB\x05", |
||
46 | ]; |
||
47 | |||
48 | /** |
||
49 | * Use the response flag to figure out what method to run |
||
50 | * |
||
51 | * @type array |
||
52 | */ |
||
53 | protected $responses = [ |
||
54 | "\x01\x00\xFB\x01" => "processDetails", |
||
55 | "\x01\x00\xFB\x05" => "processPlayers", |
||
56 | ]; |
||
57 | |||
58 | /** |
||
59 | * The query protocol used to make the call |
||
60 | * |
||
61 | * @type string |
||
62 | */ |
||
63 | protected $protocol = 'cs2d'; |
||
64 | |||
65 | /** |
||
66 | * String name of this protocol class |
||
67 | * |
||
68 | * @type string |
||
69 | */ |
||
70 | protected $name = 'cs2d'; |
||
71 | |||
72 | /** |
||
73 | * Longer string name of this protocol class |
||
74 | * |
||
75 | * @type string |
||
76 | */ |
||
77 | protected $name_long = "Counter-Strike 2d"; |
||
78 | |||
79 | /** |
||
80 | * The client join link |
||
81 | * |
||
82 | * @type string |
||
83 | */ |
||
84 | protected $join_link = "cs2d://%s:%d/"; |
||
85 | |||
86 | /** |
||
87 | * Normalize settings for this protocol |
||
88 | * |
||
89 | * @type array |
||
90 | */ |
||
91 | protected $normalize = [ |
||
92 | // General |
||
93 | 'general' => [ |
||
94 | // target => source |
||
95 | 'dedicated' => 'dedicated', |
||
96 | 'gametype' => 'game_mode', |
||
97 | 'hostname' => 'hostname', |
||
98 | 'mapname' => 'mapname', |
||
99 | 'maxplayers' => 'max_players', |
||
100 | 'mod' => 'game_dir', |
||
101 | 'numplayers' => 'num_players', |
||
102 | 'password' => 'password', |
||
103 | ], |
||
104 | // Individual |
||
105 | 'player' => [ |
||
106 | 'name' => 'name', |
||
107 | 'deaths' => 'deaths', |
||
108 | 'score' => 'score', |
||
109 | ], |
||
110 | ]; |
||
111 | |||
112 | /** |
||
113 | * Process the response for the Tibia server |
||
114 | * |
||
115 | * @return array |
||
116 | * @throws \GameQ\Exception\Protocol |
||
117 | */ |
||
118 | 2 | public function processResponse() |
|
177 | |||
178 | /** |
||
179 | * Handles processing the details data into a usable format |
||
180 | * |
||
181 | * @param Buffer $buffer |
||
182 | * |
||
183 | * @return array |
||
184 | * @throws Exception |
||
185 | */ |
||
186 | protected function processDetails(Buffer $buffer) |
||
215 | |||
216 | /** |
||
217 | * Handles processing the player data into a usable format |
||
218 | * |
||
219 | * @param Buffer $buffer |
||
220 | * |
||
221 | * @return array |
||
222 | * @throws Exception |
||
223 | */ |
||
224 | protected function processPlayers(Buffer $buffer) |
||
250 | |||
251 | /** |
||
252 | * Read flags from stored value |
||
253 | * |
||
254 | * @param $flags |
||
255 | * @param $offset |
||
256 | * |
||
257 | * @return bool |
||
258 | */ |
||
259 | protected function readFlag($flags, $offset) |
||
263 | } |
||
264 |