def write(self, data: ScnDataWriter):
     data.string16(self.field1)
     data.float32(self.field2)
     data.float32(self.field3)
     data.uint16(self.field4)
     data.uint16(self.field5)
     data.uint8(self.field6)
     data.uint16(self.field7)
     for j in range(0, 9):
         data.uint8(self.field8[j])
     for j in range(0, 9):
         data.uint32(self.field9[j])
     data.float32(self.field10)  # 1.00
     data.float32(self.field11)
     for j in range(0, 9):
         data.uint8(self.field12[j])
Beispiel #2
0
 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()
    def write_classic(self, data: ScnDataWriter):
        # TODO actually use stored values for this stuff
        data.float32(self.rge_version)
        if self.rge_version > 1.13:
            for i in range(0, 16):
                # player names
                data.string_fixed('', size=256)

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

        if self.rge_version > 1.13:
            for i in range(0, 16):
                player_active = 1 if i < 2 else 0
                player_type = 1 if i == 0 else 0
                player_civ_id = i + 1
                player_base = ScnPlayerBaseProperties(
                    active=player_active,
                    player_type=player_type,
                    civilization=player_civ_id,
                    posture=4)
                player_base.write(data)

        if self.rge_version > 1.07:
            is_conquest = True
            data.boolean8(is_conquest)

        # Some check values?
        data.uint16(0)
        data.uint16(0)
        data.float32(0)

        filename = 'scenario.scx'
        data.string16(filename)

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

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

        description = "description"
        data.string16(description)

        if self.rge_version >= 1.11:
            hints_message = ""
            data.string16(hints_message)
            win_message = ""
            data.string16(win_message)
            loss_message = ""
            data.string16(loss_message)
            history_message = ""
            data.string16(history_message)

        if self.rge_version > 1.22:
            raise Exception("Not implemented: scout data not understood")

        pregame_cinematic = ' <None> '
        data.string16(pregame_cinematic)
        victory_cinematic = ' <None> '
        data.string16(victory_cinematic)
        loss_cinematic = ' <None> '
        data.string16(loss_cinematic)

        if self.rge_version >= 1.09:
            mission_bmp = ' <None> '
            data.string16(mission_bmp)

        if self.rge_version >= 1.10:
             mission_image = 0
             data.uint32(mission_image)
             width = 0
             data.uint32(width)
             height = 0
             data.uint32(height)
             orientation = 1
             data.uint16(orientation)

        for i in range(0, 16):
            player_build_list = "Random"
            data.string16(player_build_list)

        for i in range(0, 16):
            player_city_plan = ' <None> '
            data.string16(player_city_plan)

        if self.rge_version >= 1.08:
            for i in range(0, 16):
                player_personality = "Random"
                data.string16(player_personality)

        for i in range(0, 16):
            """ Embedded files """
            build_list_length = 0
            data.uint32(build_list_length)
            city_plan_length = 0
            data.uint32(city_plan_length)
            if self.rge_version >= 1.08:
                ai_rules_length = 0
                data.uint32(ai_rules_length)
            else:
                data.uint32(0)
            # Would write build_list, city plan, AI rules if len() wasn't 0

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

        if self.rge_version >= 1.02:
            data.int32(-99)  # Check value