1 | <?php |
||
33 | class Lhmp extends Protocol |
||
34 | { |
||
35 | |||
36 | /** |
||
37 | * Array of packets we want to look up. |
||
38 | * Each key should correspond to a defined method in this or a parent class |
||
39 | * |
||
40 | * @type array |
||
41 | */ |
||
42 | protected $packets = [ |
||
43 | self::PACKET_DETAILS => "LHMPo", |
||
44 | self::PACKET_PLAYERS => "LHMPp", |
||
45 | ]; |
||
46 | |||
47 | /** |
||
48 | * Use the response flag to figure out what method to run |
||
49 | * |
||
50 | * @type array |
||
51 | */ |
||
52 | protected $responses = [ |
||
53 | "LHMPo" => "processDetails", |
||
54 | "LHMPp" => "processPlayers", |
||
55 | ]; |
||
56 | |||
57 | /** |
||
58 | * The query protocol used to make the call |
||
59 | * |
||
60 | * @type string |
||
61 | */ |
||
62 | protected $protocol = 'lhmp'; |
||
63 | |||
64 | /** |
||
65 | * String name of this protocol class |
||
66 | * |
||
67 | * @type string |
||
68 | */ |
||
69 | protected $name = 'lhmp'; |
||
70 | |||
71 | /** |
||
72 | * Longer string name of this protocol class |
||
73 | * |
||
74 | * @type string |
||
75 | */ |
||
76 | protected $name_long = "Lost Heaven"; |
||
77 | |||
78 | /** |
||
79 | * query_port = client_port + 1 |
||
80 | * |
||
81 | * @type int |
||
82 | */ |
||
83 | protected $port_diff = 1; |
||
84 | |||
85 | /** |
||
86 | * Normalize settings for this protocol |
||
87 | * |
||
88 | * @type array |
||
89 | */ |
||
90 | protected $normalize = [ |
||
91 | // General |
||
92 | 'general' => [ |
||
93 | // target => source |
||
94 | 'gametype' => 'gamemode', |
||
95 | 'hostname' => 'servername', |
||
96 | 'mapname' => 'mapname', |
||
97 | 'maxplayers' => 'maxplayers', |
||
98 | 'numplayers' => 'numplayers', |
||
99 | 'password' => 'password', |
||
100 | ], |
||
101 | // Individual |
||
102 | 'player' => [ |
||
103 | 'name' => 'name', |
||
104 | ], |
||
105 | ]; |
||
106 | |||
107 | /** |
||
108 | * Process the response |
||
109 | * |
||
110 | * @return array |
||
111 | * @throws \GameQ\Exception\Protocol |
||
112 | */ |
||
113 | 2 | public function processResponse() |
|
151 | |||
152 | /* |
||
153 | * Internal methods |
||
154 | */ |
||
155 | |||
156 | /** |
||
157 | * Handles processing the details data into a usable format |
||
158 | * |
||
159 | * @param Buffer $buffer |
||
160 | * |
||
161 | * @return array |
||
162 | * @throws Exception |
||
163 | */ |
||
164 | protected function processDetails(Buffer $buffer) |
||
183 | |||
184 | /** |
||
185 | * Handles processing the player data into a usable format |
||
186 | * |
||
187 | * @param Buffer $buffer |
||
188 | * |
||
189 | * @return array |
||
190 | */ |
||
191 | 2 | protected function processPlayers(Buffer $buffer) |
|
214 | } |
||
215 |