donadigo/pygbx

[ManiaPlanet4] Replay Issue

w1lla opened this issue · 3 comments

w1lla commented

Some issue with reading ManiaPlanet 4 Replays, Its in the gbx.py as it has no full support for all .Gbx Files it seems?

Processing:     Old fashioned tech - 026_da¢SP´Niwes(00'22''05).Replay.Gbx
ERROR:root:unpack requires a buffer of 4 bytes
ERROR:root:unpack requires a buffer of 4 bytes
ERROR:root:unpack requires a buffer of 4 bytes
ERROR:root:unpack requires a buffer of 4 bytes
ERROR:root:Failed to read string: 'utf-8' codec can't decode byte 0x90 in position 1: invalid start byte
ERROR:root:unpack requires a buffer of 16777216 bytes
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "c:\users\w1lla\appdata\local\programs\python\python38\lib\multiprocessing\pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "c:\users\w1lla\appdata\local\programs\python\python38\lib\multiprocessing\pool.py", line 51, in starmapstar
    return list(itertools.starmap(args[0], args[1]))
  File "C:\tmn\pyplanet\tmtrackNN\preprocessing.py", line 99, in process_fname
    replay_file = Gbx(fname)
  File "C:\tmn\pyplanet\tmtrackNN\tmnnenv\lib\site-packages\pygbx\gbx.py", line 136, in __init__
    self._read_node(self.class_id, -1, bp)
  File "C:\tmn\pyplanet\tmtrackNN\tmnnenv\lib\site-packages\pygbx\gbx.py", line 590, in _read_node
    game_class.track = Gbx(data)
  File "C:\tmn\pyplanet\tmtrackNN\tmnnenv\lib\site-packages\pygbx\gbx.py", line 136, in __init__
    self._read_node(self.class_id, -1, bp)
  File "C:\tmn\pyplanet\tmtrackNN\tmnnenv\lib\site-packages\pygbx\gbx.py", line 431, in _read_node
    block.name = bp.read_string_lookback()
  File "C:\tmn\pyplanet\tmtrackNN\tmnnenv\lib\site-packages\pygbx\bytereader.py", line 212, in read_string_lookback
    s = self.read_string()
  File "C:\tmn\pyplanet\tmtrackNN\tmnnenv\lib\site-packages\pygbx\bytereader.py", line 167, in read_string
    return self.read(strlen, str(strlen) + 's').decode('utf-8')
AttributeError: 'int' object has no attribute 'decode'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "preprocessing.py", line 143, in <module>
    entries = p.starmap(process_fname, it)
  File "c:\users\w1lla\appdata\local\programs\python\python38\lib\multiprocessing\pool.py", line 372, in starmap
    return self._map_async(func, iterable, starmapstar, chunksize).get()
  File "c:\users\w1lla\appdata\local\programs\python\python38\lib\multiprocessing\pool.py", line 768, in get
    raise self._value
AttributeError: 'int' object has no attribute 'decode'
```

Nope, the lib has mostly support for TMNF/TMUF files. Anything up MP4, 2020 doesn't work. It's entirely possible to add support for these though, there's other parsers like Gbx NET and ManiaPlanetSharp which successfully parse these.

w1lla commented

Okay, well as anything up ManiaPlanet is also TrackMania in a way and parsing replays from other parsers is a bit worry some as you can't get data from it. Its because the way Replay/Map files are written has changed some bit.

https://github.com/PyPlanet/PyPlanet/blob/c491a9265c53a47c3bd2867537003bf59c9a0357/pyplanet/utils/gbxparser.py GBX Parser for python in a way that works for TM2020 and also Maniaplanet4.

I didn't know about that parser, that'll definitely be useful. TMTrackNN is quite special in that it needs all replay and all map data to be available, but I think fixing the current parser to work for new titles is managable with some deeper work.