Ejemplo n.º 1
0
 def read(data: ScnDataReader):
     width = data.uint32()
     height = data.uint32()
     tiles = []
     for i in range(0, height * width):
         tiles.append(ScnMapTile.read(data))
     return ScnMap(width, height, tiles)
Ejemplo n.º 2
0
 def read(data: ScnDataReader):
     random_map_num_objects = data.uint32(debug='random_map_num_objects')
     pointer = data.uint32()
     items = [RandomMapObject.read(data) for _ in range(0, random_map_num_objects)]
     return RandomMapObjectListWrapper(
         pointer,
         items
     )
Ejemplo n.º 3
0
 def read(data: ScnDataReader):
     # Not present in AOE1 data file, a bit of a guess
     random_map_num_elevations = data.uint32(debug='random_map_num_elevations')
     pointer = data.uint32(debug='random_map_elevation_pointer')
     items = [RandomMapElevation.read(data) for _ in range(0, random_map_num_elevations)]
     return RandomMapElevationListWrapper(
         pointer,
         items
     )
Ejemplo n.º 4
0
 def read_classic(data: ScnDataReader, file_version: float):
     return ScenarioObject(
         (data.float32(), data.float32(), data.float32()),
         data.uint32(),
         data.uint16(),
         data.uint8(),
         data.float32(),
         # Not used in AOE1
         -1 if file_version < 1.15 else data.uint16(),
         -1 if file_version < 1.13 else data.uint32())
Ejemplo n.º 5
0
 def read(data: ScnDataReader, version: float):
     return ScnPlayerStartResources(
         gold=data.uint32(),
         wood=data.uint32(),
         food=data.uint32(),
         stone=data.uint32(),
         ore=data.uint32() if version >= 1.17 else 0,
         goods=data.uint32() if version >= 1.17 else 0,
         color=data.uint32() if version >= 1.24 else 0,
     )
Ejemplo n.º 6
0
 def read(data: ScnDataReader):
     data.mark('random maps')
     num_random_maps = data.uint32(debug='num_random_maps')
     random_maps_pointer = data.uint32(debug='random_maps_pointer')  # 39845000 in empires_up.dat
     random_map_meta = [RandomMapMeta.read(data) for _ in range(0, num_random_maps)]
     # Data from random_map_meta repeats here
     random_maps = [RandomMap.read(data) for _ in range(0, num_random_maps)]
     return RandomMapListWrapper(
         num_random_maps,
         random_maps_pointer,
         random_map_meta,
         random_maps
     )
Ejemplo n.º 7
0
 def read(data: ScnDataReader):
     id = data.uint16(debug='sound_id')
     play_delay = data.uint16(debug='sound_play_delay')
     num_items = data.uint16(debug='sound_num_items')
     cache_time = data.uint32()
     items = [SoundItem.read(data) for _ in range(0, num_items)]
     return Sound(id, play_delay, cache_time, items)
Ejemplo n.º 8
0
 def read(data: ScnDataReader):
     field1 = data.string16(debug='player_name_repeated')
     field2 = data.float32(debug='unknown field 1')
     field3 = data.float32(debug='unknown field 2')
     field4 = data.uint16(debug='unknown field 3')
     field5 = data.uint16(debug='unknown field 4')
     field6 = data.uint8(debug='unknown field 5')
     field7 = data.uint16(debug='unknown field 6')
     field8 = []
     for j in range(0, 9):
         something = data.uint8(debug='unknown field {}'.format(j))
         field8.append(something)
     field9 = []
     for j in range(0, 9):
         something = data.uint32(debug='unknown field {}'.format(j))
         field9.append(something)
     field10 = data.float32(debug="unknown field")  # 1.00
     field11 = data.float32(
         debug="unknown field"
     )  # only seen 0. guess this could be float as well ?
     field12 = []
     for j in range(
             0, 9
     ):  # all 0's. guessing it could hold another list of 9 values?
         something = data.uint8(debug='unknown field {}'.format(j))
         field12.append(something)
     return UnknownPlayerDataStructure(field1, field2, field3, field4,
                                       field5, field6, field7, field8,
                                       field9, field10, field11, field12)
Ejemplo n.º 9
0
def load(data: ScnDataReader) -> List[Effect]:
    """
    Read all effects from here
    """
    data.mark("effects")
    num_effects = data.uint32()
    return [Effect.read(data) for _ in range(0, num_effects)]
Ejemplo n.º 10
0
 def read(data: ScnDataReader):
     id = data.uint32(debug='random_map_id')
     terrain_type = data.uint8(debug='random_map_terrain_type')
     _padding1 = data.uint16(debug='random_map_padding1')
     _padding2 = data.uint8(debug='random_map_padding2')
     spacing = data.int32(debug='random_map_spacing')
     base_square_radius = data.int32(debug='random_map_base_square_radius')
     zone = data.int8(debug='random_map_zone')
     placement_type = data.int8(debug='random_map_placement_type')
     _padding3 = data.uint16(debug='random_map_padding3')
     land_x = data.int32(debug='random_map_land_x')
     land_y = data.int32(debug='random_map_land_y')
     amount_of_land_used_percent = data.int8(debug='random_map_amount_of_land_used_percent')
     land_by_player_flag = data.int8(debug='random_map_land_by_player_flag')
     _padding4 = data.uint16(debug='random_map_padding4')
     radius = data.int32(debug='random_map_radius')
     fade = data.int32(debug='random_map_fade')
     clumpiness_factor = data.int32(debug='random_map_clumpiness_factor')
     return RandomMapLand(
         id,
         terrain_type,
         spacing,
         base_square_radius,
         zone,
         placement_type,
         land_x,
         land_y,
         amount_of_land_used_percent,
         land_by_player_flag,
         radius,
         fade,
         clumpiness_factor
     )
Ejemplo n.º 11
0
 def read(data: ScnDataReader):
     required_techs = [
         data.int16(debug='required_tech1'),
         data.int16(debug='required_tech2'),
         data.int16(debug='required_tech3'),
         data.int16(debug='required_tech4')
     ]
     costs = [TechnologyCost.read(data) for _ in range(0, 3)]
     min_required_techs = data.int16(debug='min_required_techs')
     research_location = data.int16(debug='research_location')
     langauge_file_name = data.int16(debug='langauge_file_name')
     language_file_desc = data.int16(debug='language_file_desc')
     research_time = data.int16(debug='research_time')
     effect = data.int16(debug='effect')
     type = data.int16(debug='type')
     icon = data.int16(debug='icon')
     button = data.uint8(debug='button')
     lang_file_help = data.int32(debug='lang_file_help')
     lang_file_tech_tree = data.int32(debug='lang_file_tech_tree')
     hotkey = data.uint32(debug='hotkey')
     tech_name_len = data.uint16(debug='name_len')
     name = data.string_fixed(size=tech_name_len, debug='name')
     return Technology(required_techs, costs, min_required_techs,
                       research_location, langauge_file_name,
                       language_file_desc, research_time, effect, type,
                       icon, button, lang_file_help, lang_file_tech_tree,
                       hotkey, name)
Ejemplo n.º 12
0
 def read(data: ScnDataReader):
     unit_type = data.uint32()
     terrain_type = data.int32()
     group_flag = data.int8()
     scale_flag = data.int8()
     _padding5 = data.uint16()
     group_size = data.int32()
     group_size_variance = data.int32()
     group_count = data.int32()
     group_area = data.int32()
     player_id = data.int32()
     land_id = data.int32()
     min_distance_to_players = data.int32()
     max_distance_to_players = data.int32()
     return RandomMapObject(
         unit_type,
         terrain_type,
         group_flag,
         scale_flag,
         group_size,
         group_size_variance,
         group_count,
         group_area,
         player_id,
         land_id,
         min_distance_to_players,
         max_distance_to_players
     )
Ejemplo n.º 13
0
 def read(data: ScnDataReader):
     random_map_num_terrains = data.int32(debug='random_map_terrain_count')  # could be land ID??
     pointer = data.uint32(debug='random_map_terrain_pointer')
     items = [RandomMapTerrain.read(data) for _ in range(0, random_map_num_terrains)]
     return RandomMapTerrainListWrapper(
         pointer,
         items
     )
Ejemplo n.º 14
0
 def read(data: ScnDataReader):
     random_map_num_lands = data.int32(debug='random_map_land_count')
     pointer = data.uint32(debug='random_map_land_pointer')
     items = [RandomMapLand.read(data) for _ in range(0, random_map_num_lands)]
     return RandomMapLandListWrapper(
         pointer,
         items
     )
Ejemplo n.º 15
0
 def read(data: ScnDataReader):
     random_map_borders = (
         data.uint32(debug='random_map_border_1'),
         data.uint32(debug='random_map_border_2'),
         data.uint32(debug='random_map_border_3'),
         data.uint32(debug='random_map_border_4')
     )
     border_usage = data.uint32(debug='random_map_border_usage')
     water_shape = data.uint32(debug='random_map_water_shape')
     base_terrain = data.uint32(debug='random_map_base_terrain')
     land_cover = data.uint32(debug='random_map_land_cover')
     unused_id = data.uint32(debug='random_map_border_unused_id')
     lands = RandomMapLandListWrapper.read(data)
     terrains = RandomMapTerrainListWrapper.read(data)
     objects = RandomMapObjectListWrapper.read(data)
     elevations = RandomMapElevationListWrapper.read(data)
     return RandomMap(
         random_map_borders,
         border_usage,
         water_shape,
         base_terrain,
         land_cover,
         unused_id,
         lands,
         terrains,
         objects,
         elevations
     )
Ejemplo n.º 16
0
def load(data: ScnDataReader) -> List[Sprite]:
    """
    Read all the sprites
    """
    data.mark(name='sprites')
    num_sprites = data.uint16(debug='num_sprites')
    sprites_exist = [data.uint32() for _ in range(0, num_sprites)]
    sprites = []
    for sprite_id in range(0, num_sprites):
        if sprites_exist[sprite_id] == 0:
            continue
        sprite = Sprite.read(data, sprite_id)
        sprites.append(sprite)
    return sprites
Ejemplo n.º 17
0
    def read(data: ScnDataReader):
        # Not sure how to walk through this trailing data yet.
        # Fails on both of the Multiplayer Border Patrol maps bundled with ROR and DE.
        # This data seems to be either 1320 or 708 bytes long.

        # Some kind of per-player data structure here
        player_count = data.uint32(debug="unknown field")  # Only seen 9.
        player_unknown_structure_list = []
        for i in range(1, 9):
            player_unknown_structure = UnknownPlayerDataStructure.read(data)
            player_unknown_structure_list.append(player_unknown_structure)
        data.done()
        return UnknownDataStructure(player_count,
                                    player_unknown_structure_list)
Ejemplo n.º 18
0
 def read(data: ScnDataReader):
     percent = data.uint32()
     height = data.int32()
     clumps = data.int32()
     spacing = data.int32()
     base_terrain_type = data.int32()
     base_elevation_type = data.int32()
     return RandomMapElevation(
         percent,
         height,
         clumps,
         spacing,
         base_terrain_type,
         base_elevation_type
     )
Ejemplo n.º 19
0
def load(data: ScnDataReader) -> List[TerrainTable]:
    # Read the terrain tables
    data.mark(name='terrain tables')
    num_terrain_tables = data.uint16(debug='num_terrain_tables')
    num_terrains = data.uint16(debug='num_terrains')
    unknown_values = []
    for terrain_table_id in range(0, num_terrain_tables):
        unknown_value = data.uint32(
            debug="terrain table {} unknown value".format(terrain_table_id))
        unknown_values.append(unknown_value)
    terrain_tables = []
    for terrain_table_id in range(0, num_terrain_tables):
        passable = [
            data.float32("passability table={} terrain={}".format(
                terrain_table_id, terrain_id))
            for terrain_id in range(0, num_terrains)
        ]
        terrain_tables.append(
            TerrainTable(unknown_values[terrain_table_id], passable))
    return terrain_tables
Ejemplo n.º 20
0
 def read(data: ScnDataReader, sprite_id):
     sprite_name = data.string_fixed(21, debug='sprite_name')
     sprite_filename = data.string_fixed(13, debug='sprite_filename')
     sprite_slp_id = data.uint32(debug='sprite_slp_id')
     sprite_is_loaded = data.boolean8(debug='sprite_is_loaded')
     sprite_color_flag = data.boolean8(debug='sprite_color_flag')
     sprite_layer = data.uint8(debug='sprite_layer')
     sprite_color_table = data.int16(debug='sprite_color_table')
     sprite_transparent_selection = data.boolean8(
         debug='sprite_transparent_selection')
     sprite_bounding_box = (
         data.int16(),  # X1
         data.int16(),  # Y1
         data.int16(),  # X2
         data.int16())  # Y2
     sprite_num_deltas = data.uint16(debug='sprite_num_deltas')
     sprite_sound_id = data.int16(debug='sprite_sound_id')
     attack_sounds_used = data.boolean8()
     sprite_num_frames = data.uint16()
     sprite_num_facets = data.uint16()
     sprite_base_speed = data.float32()
     sprite_frame_rate = data.float32()
     sprite_replay_delay = data.float32()
     sprite_sequence_type = data.uint8()
     sprite_other_id = data.uint16(debug='sprite_other_id')
     sprite_mirror_flag = data.uint8()
     # sprite_other_flag = data.uint8() # Reading 1 byte too far here, one of these must not be in the AOE1 file.
     sprite_deltas = [
         SpriteDelta.read(data) for _ in range(0, sprite_num_deltas)
     ]
     facets = [SpriteFacet.read(data) for _ in range(0, sprite_num_facets)
               ] if attack_sounds_used else []
     return Sprite(sprite_id, sprite_name, sprite_filename, sprite_slp_id,
                   sprite_is_loaded, sprite_color_flag, sprite_layer,
                   sprite_color_table, sprite_transparent_selection,
                   sprite_bounding_box, sprite_sound_id, attack_sounds_used,
                   sprite_num_frames, sprite_num_facets, sprite_base_speed,
                   sprite_frame_rate, sprite_replay_delay,
                   sprite_sequence_type, sprite_other_id,
                   sprite_mirror_flag, sprite_deltas, facets)
Ejemplo n.º 21
0
    def read(data: ScnDataReader):
        # Load header
        file_version = data.string_fixed(size=4)
        file_version_float = float(file_version)
        header_size = data.uint32()
        data.mark(name='SCN header', limit=header_size)  # header size
        header_version = data.uint32(debug='header_version')

        if header_version >= 3:
            # DE scenario a bit different
            timestamp = data.uint32(debug='Timestamp maybe')
            string_marker = data.uint16(debug='string_marker')  # always 2656
            description = data.string16(debug='description')
            # Data sometimes here sometimes not. Need to check remaining bytes in header size to see if we can read it.
            if header_size - data.bytes_read_since_mark >= 8:
                # might not account for all possibilities for these fields
                has_single_player_victory_condition = data.boolean32()
                player_count = data.uint32()
            else:
                has_single_player_victory_condition = False
                player_count = -1
            scenario_header = ScnHeader(file_version=file_version_float,
                                        header_version=header_version,
                                        timestamp=timestamp,
                                        description=description,
                                        has_singleplayer_victory_condition=
                                        has_single_player_victory_condition,
                                        player_count=player_count)
        else:
            timestamp = data.uint32(debug='timestamp')
            scenario_header = ScnHeader(
                file_version=file_version_float,
                header_version=header_version,
                timestamp=timestamp,
                description=data.string32(),
                has_singleplayer_victory_condition=data.boolean32(),
                player_count=data.uint32())
        logging.debug(scenario_header)
        data.unmark()
        data.decompress()

        return scenario_header
Ejemplo n.º 22
0
    def read_classic(data: ScnDataReader):
        base = ScnEngineProperties.read_classic(data)
        version = base.rge_version
        if version <= 1.13:
            for i in range(0, 16):
                # skip past player names
                player_name = data.string_fixed(size=256)
            raise Exception(
                "Not implemented: Don't know how to read player base properties from <1.13 file"
            )
        else:
            player_start_resources = []
            for i in range(0, 16):
                # Ignoring at the moment
                this_player_start_resources = ScnPlayerStartResources.read(
                    data, version)
                player_start_resources.append(this_player_start_resources)

        if version >= 1.02:
            check5 = data.int32()
            if check5 != -99:
                raise Exception(
                    "Check value did not match in scenario data, giving up")

        victory_conquest = data.uint32()
        victory_ruins = data.uint32()
        victory_artifacts = data.uint32()
        victory_discoveries = data.uint32()
        victory_exploration = data.uint32()
        victory_gold = data.uint32()
        victory_all_flag = data.boolean32()

        if version >= 1.13:
            mp_victory_type = data.uint32()
            victory_score = data.uint32()
            victory_time = data.uint32()

        for i in range(0, 16):
            for j in range(0, 16):
                stance = data.uint32()
                logging.debug("Diplomacy from=%d to=%d stance=%d", i, j,
                              stance)

        # 12 victory conditions for each player
        for i in range(0, 16):
            for j in range(0, 12):
                # TODO read these ???
                individual_victory_blob = data.read(60)

        if version >= 1.02:
            check5 = data.int32()
            if check5 != -99:
                raise Exception(
                    "Check value did not match in scenario data, giving up")

        # Allied victory
        for i in range(0, 16):
            allied_victory = data.uint32()

        if version >= 1.24:
            raise Exception(
                "Not implemented: Don't know how to read team information from >=1.24 file"
            )

        if version >= 1.18:
            # Also has disabled units and building, where are they in older versions?
            raise Exception(
                "Not implemented: Don't know how to read tech tree from >=1.18 file"
            )
        elif version > 1.03:
            for i in range(0, 16):
                for j in range(0, 20):
                    disabled_tech_id = data.uint32()
                    logging.debug("Disabled tech player %d, position %d: %d",
                                  i, j, disabled_tech_id)

        if version > 1.04:
            data.uint32()  # No idea

        if version >= 1.12:
            data.uint32()  # No idea
            full_tech_tree = data.boolean32()

        if version > 1.05:
            for i in range(0, 16):
                player_start_age = data.uint32()

        if version >= 1.02:
            check6 = data.int32()
            if check6 != -99:
                raise Exception(
                    "Check value did not match in scenario data, giving up")

        if version >= 1.19:
            # 'view'??
            data.uint32()
            data.uint32()

        if version >= 1.21:
            raise Exception(
                "Not implemented: Don't know how to read map type from >=1.21 file"
            )

        if version >= 1.21:
            raise Exception(
                "Not implemented: Don't know how to read base priorities from >=1.21 file"
            )

        game_properties = ScnGameProperties(base)
        logging.debug(game_properties)
        return game_properties
Ejemplo n.º 23
0
    def read_de(data: ScnDataReader):
        base = ScnEngineProperties.read_de(data)

        # expecting global victory conditions around here somewhere
        for i in range(0, 8):
            data.uint32(debug='unknown value a {}'.format(i))
        data.uint32(debug='unknown value b')  # 900
        data.uint32(debug='unknown value c')  # 9000

        # expecting diplomacy
        for i in range(0, 16):
            for j in range(0, 16):
                val = data.uint32()
                logging.debug("Unknown value from=%d to=%d val=%d", i, j,
                              val)  # lots of '3'.

        # expecting 12 individual victory conditions for each player
        for i in range(0, 16):
            for j in range(0, 12):
                # TODO read these ???
                data.read(60)

        check3 = data.int32(debug='check value 3')
        if check3 != -99:
            raise Exception(
                "Check value did not match in scenario data, giving up")

        # Probably allied victory
        for i in range(0, 16):
            data.uint32(debug='allied victory player {}'.format(i))

        # disabled tech
        for i in range(0, 16):
            for j in range(0, 20):
                disabled_tech_id = data.uint32()
                logging.debug("Disabled tech player %d, position %d: %d", i, j,
                              disabled_tech_id)

        data.uint32(debug='unknown field 1')
        data.uint32(debug='unknown field 2')
        data.uint32(debug='unknown field 3')  # might be full tech tree

        for j in range(0, 16):  # maybe ?
            data.uint32(debug='starting age player {}'.format(j))

        check4 = data.int32(debug='check value 2')
        if check4 != -99:
            raise Exception(
                "Check value did not match in scenario data, giving up")

        # view ?
        data.float32()
        data.float32()

        game_properties = ScnGameProperties(base)
        logging.debug(game_properties)
        return game_properties
Ejemplo n.º 24
0
 def read(data: ScnDataReader):
     # Not complete yet!
     return SpriteDelta(data.uint16(), data.uint16(), data.uint32(),
                        data.int16(), data.int16(), data.int16(),
                        data.int16())
Ejemplo n.º 25
0
 def read(data: ScnDataReader):
     return SlpHeader(data.string_fixed(4), data.uint32(),
                      data.string_fixed(24))
Ejemplo n.º 26
0
 def read(data: ScnDataReader):
     return SlpFrameInfo(data.uint32(), data.uint32(), data.uint32(),
                         data.uint32(), data.int32(), data.int32(),
                         data.int32(), data.int32())
Ejemplo n.º 27
0
 def read(data: ScnDataReader):
     id = data.uint32(debug='random_map_id')
     borders = (
         data.uint32(debug='random_map_border_1'),
         data.uint32(debug='random_map_border_2'),
         data.uint32(debug='random_map_border_3'),
         data.uint32(debug='random_map_border_4')
     )
     border_usage = data.uint32(debug='random_map_border_usage')
     water_shape = data.uint32(debug='random_map_water_shape')
     base_terrain = data.uint32(debug='random_map_base_terrain')
     land_cover = data.uint32(debug='random_map_land_cover')
     unused_id = data.uint32(debug='random_map_border_unused_id')
     num_lands = data.uint32(debug='random_map_num_lands')
     pointer1 = data.uint32()
     num_terrains = data.uint32(debug='random_map_num_terrains')
     pointer2 = data.uint32()
     num_objects = data.uint32(debug='random_map_num_objects')
     pointer3 = data.uint32()
     num_elevations = data.uint32(debug='random_map_num_elevations')
     pointer4 = data.int32()
     return RandomMapMeta(
         id,
         borders,
         border_usage,
         water_shape,
         base_terrain,
         land_cover,
         unused_id,
         num_lands,
         pointer1,
         num_terrains,
         pointer2,
         num_objects,
         pointer3,
         num_elevations,
         pointer4
     )
Ejemplo n.º 28
0
 def read(data: ScnDataReader, count: int):
     rows = [data.uint32() for _ in range(0, count)]
     data.done()
     return SlpCommandOffset(rows)
Ejemplo n.º 29
0
    def read_de(data: ScnDataReader):
        version = data.float32(debug='version')

        for i in range(0, 16):
            data.uint16(debug='some number here')  # 2656
            data.string16(debug='player tribe name')

        if version >= 3.13:
            # These 16 bytes are not present in some DE scenarios bundled w/ the game, labelled version 3.125.
            for i in range(0, 16):
                # Guessing its a string ref, have not checked
                data.int32(debug="unknown_string_ref for player {}".format(i))

        for i in range(0, 16):
            player_base_props = ScnPlayerBaseProperties.read(data)
            logging.debug(player_base_props)

        data.boolean32(debug='conquest maybe')
        data.float32(debug='probable check field')

        data.uint8(debug='unknown field')

        data.uint16(debug='some number here')  # 2656
        data.string16(debug='scenario_name')

        data.uint16(debug='some number here')  # 2656
        data.string16(debug='scenario_instructions')

        data.uint16(debug='some number here')  # 2656
        data.string16(debug='history_string')

        data.uint16(debug='some number here')  # 2656
        data.string16(debug='victory_string')

        data.uint16(debug='some number here')  # 2656
        data.string16(debug='loss_string')

        data.uint16(debug='some number here')  # 2656
        data.string16(debug='history_string')

        data.int32(debug='instructions_string_reference')
        data.uint16(debug='some_number_here')  # 2656
        data.string16(debug='instructions_vox')

        data.int32(debug='hints_string_reference')
        data.uint16(debug='some_number_here')  # 2656
        data.string16(debug='hints_vox')

        data.int32(debug='victory_string_reference')
        data.uint16(debug='some_number_here')  # 2656
        data.string16(debug='victory_vox')

        data.int32(debug='loss_string_reference')
        data.uint16(debug='some_number_here')  # 2656
        data.string16(debug='loss_vox')

        data.int32(debug='history_string_reference')
        data.uint16(debug='some_number_here')  # 2656
        data.string16(debug='history_vox')

        # Not sure if cinematics or per-player personality, AI, city plans etc

        data.uint16(debug='some_number_here')  # 2656
        data.string16(debug='unidentified_string 1')  # ' <None> '

        data.uint16(debug='some_number_here')  # 2656
        data.string16(debug='unidentified_string 2')  # ' <None> '

        data.uint16(debug='some_number_here')  # 2656
        data.string16(debug='unidentified_string 3')  # ' <None> '

        data.uint16(debug='some_number_here')  # 2656
        data.string16(debug='unidentified_string 4')  # ' <None> '

        data.uint32(debug='unidentified number 1')  # 0
        data.uint32(debug='unidentified number 2')  # 0
        data.uint32(debug='unidentified number 3')  # 0
        data.uint16(debug='unidentified number 4')  # 1

        for i in range(0, 16):
            data.string16(debug="ai player {}".format(i))

        for i in range(0, 16):
            data.string16(debug="city plan player {}".format(i))

        for i in range(0, 16):
            data.string16(debug="personality player {}".format(i))

        for i in range(0, 16):
            some_length1 = data.uint32(debug='some length maybe')
            some_length2 = data.uint32(debug='some length maybe')
            some_length3 = data.uint32(debug='some length maybe')
            data.string_fixed(some_length1, debug='some string 1')
            data.string_fixed(some_length2, debug='some string 2')
            data.string_fixed(some_length3, debug='some string 3')

        check1 = data.int32(debug='check value 1')
        if check1 != -99:
            raise Exception("Check value did not match in scenario data, giving up")

        if version < 3.13:
            data.mark('extra data observed in 3.125 version')
            for i in range(0, 32):
                data.int32(debug='unknown value 1 {}'.format(i))  # 500
            for i in range(0, 32):
                data.int32(debug='unknown value 2 {}'.format(i))  # 0

        check2 = data.int32(debug='check value 2')
        if check2 != -99:
            raise Exception("Check value did not match in scenario data, giving up")

        rge_scen = ScnEngineProperties(
            version
        )
        logging.debug(rge_scen)
        return rge_scen
Ejemplo n.º 30
0
    def read_classic(data: ScnDataReader):
        # TODO actually store this stuff
        version = data.float32(debug='version')
        if version > 1.13:
            for i in range(0, 16):
                # skip past player names
                player_name = data.string_fixed(size=256)

        if version > 1.16:
            raise Exception("Not implemented: player string table not understood")

        if version > 1.13:
            for i in range(0, 16):
                player_base = ScnPlayerBaseProperties.read(data)
                logging.debug(player_base)

        is_conquest = False
        if version > 1.07:
            is_conquest = data.boolean8()

        # Something to do with timelines?
        check1 = data.uint16()
        check2 = data.uint16()
        check3 = data.float32()
        if check1 != 0 or check2 != 0 or check3 < -1 or check3 > 1:
            raise Exception("Unexpected values in scenario data, giving up")

        filename = data.string16(debug='filename')

        if version > 1.16:
            raise Exception("Not implemented: scenario instruction string table not understood")

        if version > 1.22:
            raise Exception("Not implemented: scout string table not understood")

        description = data.string16(debug='description')

        if version >= 1.11:
            hints_message = data.string16(debug='hints_message')
            win_message = data.string16(debug='win_message')
            loss_message = data.string16(debug='loss_message')
            history_message = data.string16(debug='history_message')

        if version > 1.22:
            raise Exception("Not implemented: scout data not understood")

        pregame_cinematic = data.string16(debug='pregame_cinematic')
        victory_cinematic = data.string16(debug='victory_cinematic')
        loss_cinematic = data.string16(debug='loss_cinematic')

        if version >= 1.09:
            mission_bmp = data.string16()
            logging.debug("mission_bmp='%s'", mission_bmp)

        if version >= 1.10:
            mission_image = data.uint32()
            width = data.uint32()
            height = data.uint32()
            orientation = data.uint16()
            if width > 0 or height > 0:
                raise Exception("Mission BMP data not understood")

        for i in range(0, 16):
            player_build_list = data.string16()
            logging.debug("Player %d build list %s", i, player_build_list)

        for i in range(0, 16):
            player_city_plan = data.string16()
            logging.debug("Player %d city plan %s", i, player_city_plan)

        if version >= 1.08:
            for i in range(0, 16):
                player_personality = data.string16()
                logging.debug("Player %d personality %s", i, player_personality)

        for i in range(0, 16):
            """ Embedded files """
            build_list_length = data.uint32()
            city_plan_length = data.uint32()
            ai_rules_length = data.uint32() if version >= 1.08 else 0
            data.read(build_list_length)
            data.read(city_plan_length)
            data.read(ai_rules_length)

        if version >= 1.20:
            raise Exception("Not implemented: AI rules not understood")

        if version >= 1.02:
            check4 = data.int32()
            if check4 != -99:
                raise Exception("Check value did not match in scenario data, giving up")

        rge_scen = ScnEngineProperties(
            version
        )
        logging.debug(rge_scen)
        return rge_scen