# Path: mgz/util.py
# def get_version(game_version, save_version, log_version):
#     """Get version based on version fields."""
#     if game_version == 'VER 9.3':
#         return Version.AOK
#     if game_version == 'VER 9.4':
#         if log_version == 3:
#             return Version.AOC10
#         if log_version == 5 or save_version >= 12.97:
#             return Version.DE
#         if save_version >= 12.36:
#             return Version.HD
#         if log_version == 4:
#             return Version.AOC10C
#         return Version.AOC
#     if game_version == 'VER 9.8':
#         return Version.USERPATCH12
#     if game_version == 'VER 9.9':
#         return Version.USERPATCH13
#     if game_version == 'VER 9.A':
#         return Version.USERPATCH14RC2
#     if game_version in ['VER 9.B', 'VER 9.C', 'VER 9.D']:
#         return Version.USERPATCH14
#     if game_version in ['VER 9.E', 'VER 9.F']:
#         return Version.USERPATCH15
#     if game_version == 'MCP 9.F':
#         return Version.MCP
#     if log_version is not None or game_version != 'VER 9.4':
#         raise ValueError('unsupported version: {}, {}, {}'.format(game_version, save_version, log_version))
# 
# class Version(Enum):
#     """Version enumeration.
# 
#     Using consts from https://github.com/goto-bus-stop/recanalyst/blob/master/src/Model/Version.php
#     for consistency.
#     """
#     AOK = 1
#     AOC = 4
#     AOC10 = 5
#     AOC10C = 8
#     USERPATCH12 = 12
#     USERPATCH13 = 13
#     USERPATCH14 = 11
#     USERPATCH15 = 20
#     DE = 21
#     USERPATCH14RC2 = 22
#     MCP = 30
#     HD = 19


import io
import hashlib
import re
import struct
import uuid
import zlib
from mgz.util import get_version, Version
        if not offset:
            match = REGEXES[player_number].search(data, pos)
            end = data.find(BLOCK_END, pos) - pos + len(BLOCK_END)
            if match is None:
                break
            offset = match.start() - pos
            while end + 8 < offset:
                end += data.find(BLOCK_END, pos + end) - (pos + end) + len(BLOCK_END)
        if end + 8 == offset:
            break
        pos += offset
        # Speed optimization: Skip specified fixed-length objects.
        test = data[pos:pos + 4]
        for fingerprint, offset in SKIP_OBJECTS:
            if test == fingerprint:
                break
        else:
            objects.append(dict(parse_object(data, pos), index=index))
        offset = None
        pos += 31
    return objects, pos + end


def parse_mod(header, num_players, version):
    """Parse Userpatch mod version."""
    cur = header.tell()
    name_length = unpack(f'<xx{num_players}x36x5xh', header)
    resources = unpack(f'<{name_length + 1}xIx', header)
    values = unpack(f'<{resources}f', header)
    header.seek(cur)

# Path: mgz/util.py
# def get_version(game_version, save_version, log_version):
#     """Get version based on version fields."""
#     if game_version == 'VER 9.3':
#         return Version.AOK
#     if game_version == 'VER 9.4':
#         if log_version == 3:
#             return Version.AOC10
#         if log_version == 5 or save_version >= 12.97:
#             return Version.DE
#         if save_version >= 12.36:
#             return Version.HD
#         if log_version == 4:
#             return Version.AOC10C
#         return Version.AOC
#     if game_version == 'VER 9.8':
#         return Version.USERPATCH12
#     if game_version == 'VER 9.9':
#         return Version.USERPATCH13
#     if game_version == 'VER 9.A':
#         return Version.USERPATCH14RC2
#     if game_version in ['VER 9.B', 'VER 9.C', 'VER 9.D']:
#         return Version.USERPATCH14
#     if game_version in ['VER 9.E', 'VER 9.F']:
#         return Version.USERPATCH15
#     if game_version == 'MCP 9.F':
#         return Version.MCP
#     if log_version is not None or game_version != 'VER 9.4':
#         raise ValueError('unsupported version: {}, {}, {}'.format(game_version, save_version, log_version))
# 
# class Version(Enum):
#     """Version enumeration.
# 
#     Using consts from https://github.com/goto-bus-stop/recanalyst/blob/master/src/Model/Version.php
#     for consistency.
#     """
#     AOK = 1
#     AOC = 4
#     AOC10 = 5
#     AOC10C = 8
#     USERPATCH12 = 12
#     USERPATCH13 = 13
#     USERPATCH14 = 11
#     USERPATCH15 = 20
#     DE = 21
#     USERPATCH14RC2 = 22
#     MCP = 30
#     HD = 19


# Path: mgz/fast/header.py
import io
import hashlib
import re
import struct
import uuid
import zlib
from mgz.util import get_version, Version

        if not offset:
            match = REGEXES[player_number].search(data, pos)
            end = data.find(BLOCK_END, pos) - pos + len(BLOCK_END)
            if match is None:
                break
            offset = match.start() - pos
            while end + 8 < offset:
                end += data.find(BLOCK_END, pos + end) - (pos + end) + len(BLOCK_END)
        if end + 8 == offset:
            break
        pos += offset
        # Speed optimization: Skip specified fixed-length objects.
        test = data[pos:pos + 4]
        for fingerprint, offset in SKIP_OBJECTS:
            if test == fingerprint:
                break
        else:
            objects.append(dict(parse_object(data, pos), index=index))
        offset = None
        pos += 31
    return objects, pos + end


def parse_mod(header, num_players, version):
    """Parse Userpatch mod version."""
    cur = header.tell()
    name_length = unpack(f'<xx{num_players}x36x5xh', header)
    resources = unpack(f'<{name_length + 1}xIx', header)
    values = unpack(f'<{resources}f', header)
    header.seek(cur)

    if version is Version.USERPATCH15: