1 | <?php |
||
37 | class Bfbc2 extends Protocol |
||
38 | { |
||
39 | |||
40 | /** |
||
41 | * Array of packets we want to query. |
||
42 | * |
||
43 | * @type array |
||
44 | */ |
||
45 | protected $packets = [ |
||
46 | self::PACKET_VERSION => "\x00\x00\x00\x00\x18\x00\x00\x00\x01\x00\x00\x00\x07\x00\x00\x00version\x00", |
||
47 | self::PACKET_STATUS => "\x00\x00\x00\x00\x1b\x00\x00\x00\x01\x00\x00\x00\x0a\x00\x00\x00serverInfo\x00", |
||
48 | self::PACKET_PLAYERS => "\x00\x00\x00\x00\x24\x00\x00\x00\x02\x00\x00\x00\x0b\x00\x00\x00listPlayers\x00\x03\x00\x00\x00\x61ll\x00", |
||
49 | ]; |
||
50 | |||
51 | /** |
||
52 | * Use the response flag to figure out what method to run |
||
53 | * |
||
54 | * @type array |
||
55 | */ |
||
56 | protected $responses = [ |
||
57 | "processVersion", |
||
58 | "processDetails", |
||
59 | "processPlayers", |
||
60 | ]; |
||
61 | |||
62 | /** |
||
63 | * The transport mode for this protocol is TCP |
||
64 | * |
||
65 | * @type string |
||
66 | */ |
||
67 | protected $transport = self::TRANSPORT_TCP; |
||
68 | |||
69 | /** |
||
70 | * The query protocol used to make the call |
||
71 | * |
||
72 | * @type string |
||
73 | */ |
||
74 | protected $protocol = 'bfbc2'; |
||
75 | |||
76 | /** |
||
77 | * String name of this protocol class |
||
78 | * |
||
79 | * @type string |
||
80 | */ |
||
81 | protected $name = 'bfbc2'; |
||
82 | |||
83 | /** |
||
84 | * Longer string name of this protocol class |
||
85 | * |
||
86 | * @type string |
||
87 | */ |
||
88 | protected $name_long = "Battlefield Bad Company 2"; |
||
89 | |||
90 | /** |
||
91 | * The client join link |
||
92 | * |
||
93 | * @type string |
||
94 | */ |
||
95 | protected $join_link = null; |
||
96 | |||
97 | /** |
||
98 | * query_port = client_port + 29321 |
||
99 | * 48888 = 19567 + 29321 |
||
100 | * |
||
101 | * @type int |
||
102 | */ |
||
103 | protected $port_diff = 29321; |
||
104 | |||
105 | /** |
||
106 | * Normalize settings for this protocol |
||
107 | * |
||
108 | * @type array |
||
109 | */ |
||
110 | protected $normalize = [ |
||
111 | // General |
||
112 | 'general' => [ |
||
113 | // target => source |
||
114 | 'dedicated' => 'dedicated', |
||
115 | 'hostname' => 'hostname', |
||
116 | 'mapname' => 'map', |
||
117 | 'maxplayers' => 'max_players', |
||
118 | 'numplayers' => 'num_players', |
||
119 | 'password' => 'password', |
||
120 | ], |
||
121 | 'player' => [ |
||
122 | 'name' => 'name', |
||
123 | 'score' => 'score', |
||
124 | 'ping' => 'ping', |
||
125 | ], |
||
126 | 'team' => [ |
||
127 | 'score' => 'tickets', |
||
128 | ], |
||
129 | ]; |
||
130 | |||
131 | /** |
||
132 | * Process the response for the StarMade server |
||
133 | * |
||
134 | * @return array |
||
135 | * @throws \GameQ\Exception\Protocol |
||
136 | */ |
||
137 | 4 | public function processResponse() |
|
174 | |||
175 | /* |
||
176 | * Internal Methods |
||
177 | */ |
||
178 | |||
179 | /** |
||
180 | * Decode the buffer into a usable format |
||
181 | * |
||
182 | * @param \GameQ\Buffer $buffer |
||
183 | * |
||
184 | * @return array |
||
185 | */ |
||
186 | 3 | protected function decode(Buffer $buffer) |
|
205 | |||
206 | /** |
||
207 | * Process the server details |
||
208 | * |
||
209 | * @param \GameQ\Buffer $buffer |
||
210 | * |
||
211 | * @return array |
||
212 | */ |
||
213 | 3 | protected function processDetails(Buffer $buffer) |
|
268 | |||
269 | /** |
||
270 | * Process the server version |
||
271 | * |
||
272 | * @param \GameQ\Buffer $buffer |
||
273 | * |
||
274 | * @return array |
||
275 | */ |
||
276 | 3 | protected function processVersion(Buffer $buffer) |
|
290 | |||
291 | /** |
||
292 | * Process the players |
||
293 | * |
||
294 | * @param \GameQ\Buffer $buffer |
||
295 | * |
||
296 | * @return array |
||
297 | */ |
||
298 | 3 | protected function processPlayers(Buffer $buffer) |
|
326 | } |
||
327 |
A high number of execution paths generally suggests many nested conditional statements and make the code less readible. This can usually be fixed by splitting the method into several smaller methods.
You can also find more information in the “Code” section of your repository.