@@ -25,6 +25,15 @@ class Flatout2(ProtocolBase):
25
25
COMMAND_QUERY = b"\x18 \x0c "
26
26
PACKET_END = b"\x2e \x55 \x19 \xb4 \xe1 \x4f \x81 \x4a "
27
27
28
+ # Car Type Identifiers (byte at position -8 from end)
29
+ CAR_TYPE_IDENTIFIERS = {
30
+ 0x08 : "Jeder" , # Alle Wagentypen erlaubt
31
+ 0x18 : "Derby" , # Derby-Wagen
32
+ 0x28 : "Rennen" , # Rennwagen
33
+ 0x38 : "Strasse" , # Straßenwagen
34
+ 0xE8 : "Wie Host" , # Wagentyp wie Host-Einstellung
35
+ }
36
+
28
37
# Game Mode Identifiers (byte at position -7 from end)
29
38
GAME_MODE_IDENTIFIERS = {
30
39
0x61 : "Race" , # Rennen
@@ -218,6 +227,24 @@ def _read_utf16_string(self, br: BinaryReader) -> str:
218
227
219
228
return bytes (bytes_list ).decode ('utf-16-le' ).strip ()
220
229
230
+ def _extract_car_type (self , data : bytes ) -> str :
231
+ """
232
+ Extracts the car type from the payload data.
233
+ Car type identifier is located at offset -8 (8 bytes from end).
234
+
235
+ :param data: The complete response data
236
+ :return: The car type name or "Unknown" if not found
237
+ """
238
+ try :
239
+ if len (data ) >= 8 :
240
+ car_type_id = data [- 8 ] # 8 bytes from end
241
+ return self .CAR_TYPE_IDENTIFIERS .get (car_type_id , f"Unknown (0x{ car_type_id :02X} )" )
242
+ else :
243
+ return "Unknown"
244
+ except Exception as e :
245
+ print (f"Error extracting car type: { e } " )
246
+ return "Unknown"
247
+
221
248
def _extract_game_mode (self , data : bytes ) -> str :
222
249
"""
223
250
Extracts the game mode from the payload data.
@@ -344,6 +371,11 @@ def _parse_response(self, br: BinaryReader, original_data: bytes) -> Status:
344
371
server_name = self ._read_utf16_string (br )
345
372
info ["hostname" ] = server_name
346
373
374
+ # Extract car type from the payload
375
+ # Car type identifier at offset -8
376
+ car_type = self ._extract_car_type (original_data )
377
+ info ["car_type" ] = car_type
378
+
347
379
# Extract game mode from the payload
348
380
# Game mode identifier at offset -7
349
381
game_mode = self ._extract_game_mode (original_data )
@@ -416,6 +448,7 @@ def _parse_response(self, br: BinaryReader, original_data: bytes) -> Status:
416
448
print (f"Error parsing response: { e } " )
417
449
# Set defaults on error
418
450
info .setdefault ("hostname" , "Unknown Server" )
451
+ info .setdefault ("car_type" , "Unknown" )
419
452
info .setdefault ("game_mode" , "Unknown" )
420
453
info .setdefault ("map" , "Unknown Map" )
421
454
info .setdefault ("lap_count" , None )
0 commit comments