コード例 #1
0
ファイル: scn_header.py プロジェクト: mike42/age-tools
 def write(self, data: ScnDataWriter):
     data.string_fixed("{:.2f}".format(self.file_version), size=4)
     if self.header_version >= 3 and self.player_count > 0:
         header_size = 12 + len(self.description) + 1
     else:
         header_size = 20 + len(self.description) + 1
     data.uint32(header_size)
     data.uint32(self.header_version)
     if self.header_version >= 3:
         data.uint32(self.timestamp)
         data.uint16(2656)  # string marker
         data.string16(self.description)
         if self.player_count > 0:
             # Last 8 bytes not always seen for DE scenarios
             data.boolean32(self.has_singleplayer_victory_condition)
             data.uint32(self.player_count)
     else:
         data.uint32(self.timestamp)
         data.string32(self.description)
         data.boolean32(self.has_singleplayer_victory_condition)
         data.uint32(self.player_count)
     data.compress()
コード例 #2
0
    def write_classic(self, data: ScnDataWriter):
        self.base.write_classic(data)
        version = self.base.rge_version
        if version <= 1.13:
            for i in range(0, 16):
                # Not based on real info at the moment
                data.string_fixed('Player name {}'.format(i), size=256)
            raise Exception(
                "Not implemented: Don't know how to read player base properties from <1.13 file"
            )
        else:
            for i in range(0, 16):
                # Not based on real info at the moment
                res = ScnPlayerStartResources(
                    gold=0,
                    food=200,
                    wood=200,
                    stone=150,
                    ore=0,
                    goods=0,
                    color=0,
                )
                res.write(data, version)

        if version >= 1.02:
            data.int32(-99)  # check

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

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

        for i in range(0, 16):
            for j in range(0, 16):
                # stance from player i to j
                diplomatic_stance = 3  # 3 is enemy ?
                data.uint32(diplomatic_stance)

        # 12 victory conditions for each player
        for i in range(0, 16):
            for j in range(0, 12):
                # TODO write these ???
                # all 0's on blank map.
                data.string_fixed('', size=60)

        if version >= 1.02:
            data.int32(-99)  # check value

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

        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 player i, position j
                    disabled_tech_id = 1
                    data.uint32(disabled_tech_id)

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

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

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

        if version >= 1.02:
            data.int32(-99)  # check value

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

        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"
            )