Example #1
0
    def parse_heroes(self):
        HEROES_DATA_OFFSET	= 0x19a9b
        HERO_RECORD_SIZE	= 0x3b 		# = 59
        heroes = {}
        for i in range(67):
            hero_id = i
            offset = HEROES_DATA_OFFSET + (HERO_RECORD_SIZE * i)

#            print "hero @ %x" % offset

            type            = lbx.read_byte(self.__data, offset + 0x23)
            common_skills   = lbx.read_long_int(self.__data, offset + 0x26)
            special_skills  = lbx.read_long_int(self.__data, offset + 0x2a)

            heroes[hero_id] = {
                'id':               i,
#                'name':             data[offset:offset + 0x0f].rstrip(chr(0)).split(chr(0))[0],
                'name':             lbx.read_string(self.__data, offset, 15),
#                'title':            data[offset + 0x0f:offset + 0x23].rstrip(chr(0)).split(chr(0))[0],
                'title':            lbx.read_string(self.__data, offset, 35),
                'type':             type,
                'experience':       lbx.read_short_int(self.__data, offset + 0x24),
                'tech1':            lbx.read_byte(self.__data, offset + 0x2e),
                'tech2':            lbx.read_byte(self.__data, offset + 0x2f),
                'tech3':            lbx.read_byte(self.__data, offset + 0x30),
                'picture':          lbx.read_byte(self.__data, offset + 0x31),
                'skill_value':      lbx.read_short_int(self.__data, offset + 0x32),
                'level':            lbx.read_byte(self.__data, offset + 0x34),
                'location':         lbx.read_short_int(self.__data, offset + 0x35),
                'eta':              lbx.read_byte(self.__data, offset + 0x37),
                'level_up':         lbx.read_byte(self.__data, offset + 0x38),
                'status':           lbx.read_byte(self.__data, offset + 0x39),
                'player':           lbx.read_byte(self.__data, offset + 0x3a),
                'skills':           self.parse_hero_skills(type, common_skills, special_skills),
                'common_skills':    common_skills,
                'special_skills':   special_skills,
            }
#            if heroes[hero_id]['player'] == 0:
#                print "Moo2Savegame::parse_heroes ... hero_id = %i, name = %s" % (hero_id, heroes[hero_id]['name'])
#                print " * level = %i" % heroes[hero_id]['level']
#                print " * skill_value = %i" % heroes[hero_id]['skill_value']
#                print " * experience = %i" % heroes[hero_id]['experience']
#                print " * status = %i" % heroes[hero_id]['status']
            
#        i += 1
#        offset = 0x19a9b + (59 * i)
#        print "STOP hero @ %x" % offset
        return heroes
Example #2
0
 def parse_game(self):
     return {
         'name':
         lbx.read_string(self.__data, 0x04,
                         23).lstrip(chr(0) + chr(1) + chr(2) + chr(3)),
         'end_of_turn_summary':
         lbx.read_byte(self.__data, 0x2E),
         'end_of_turn_wait':
         lbx.read_byte(self.__data, 0x2F),
         'random_events':
         lbx.read_byte(self.__data, 0x30),
         'enemy_moves':
         lbx.read_byte(self.__data, 0x31),
         'expanding_help':
         lbx.read_byte(self.__data, 0x32),
         'auto_select_ships':
         lbx.read_byte(self.__data, 0x33),
         'animations':
         lbx.read_byte(self.__data, 0x34),
         'auto_select_colony':
         lbx.read_byte(self.__data, 0x35),
         'show_relocation_lines':
         lbx.read_byte(self.__data, 0x36),
         'show_gnn_report':
         lbx.read_byte(self.__data, 0x37),
         'auto_delete_trade_good_housing':
         lbx.read_byte(self.__data, 0x38),
         'auto_save_game':
         lbx.read_byte(self.__data, 0x39),
         'show_only_serious_turn_summary':
         lbx.read_byte(self.__data, 0x3A),
         'ship_initiative':
         lbx.read_byte(self.__data, 0x3B),
     }
Example #3
0
    def parse_ship_design(self, offset):
        MAX_WEAPONS = 8
        weapons = []
        for i in range(MAX_WEAPONS):
            offset2 = offset + 0x1C + (8 * i)
            weapon = lbx.read_byte(self.__data, offset2)
            if (weapon > 0):
                weapons.append({
                    'weapon':		weapon,
                    'count':		lbx.read_byte(self.__data, offset2 + 0x02),
                    'current_count':	lbx.read_byte(self.__data, offset2 + 0x03),
                    'arc':		lbx.read_byte(self.__data, offset2 + 0x04),
                    'beam_mods':	lbx.read_byte(self.__data, offset2 + 0x05),
                    'missile_mods':	lbx.read_byte(self.__data, offset2 + 0x06),
                    'ammo':		lbx.read_byte(self.__data, offset2 + 0x07)
                })
        return {
                'name':                 lbx.read_string(self.__data, offset, 16),
                'size':         	lbx.read_byte(self.__data, offset + 0x10),
                'type':                 lbx.read_byte(self.__data, offset + 0x11),      # 0 = combat ship, 1 = colony ship, 2 = transport ship, 3 = guardian, 4 = outpost ship
                'shield':		lbx.read_byte(self.__data, offset + 0x12),
                'drive':		lbx.read_byte(self.__data, offset + 0x13),
                'speed':		lbx.read_byte(self.__data, offset + 0x14),
                'computer':		lbx.read_byte(self.__data, offset + 0x15),
                'armor':		lbx.read_byte(self.__data, offset + 0x16),
#                'special_devices':	self.__data[offset + 0x17:offset + 0x1C],	# char  special_device_flags[(MAX_SPECIALS+7)/8];
                'special_devices':	bitarray(bytearray(self.__data[offset + 0x17:offset + 0x1C])),	# char  special_device_flags[(MAX_SPECIALS+7)/8];
                'weapons':		weapons,
                'picture':		lbx.read_byte(self.__data, offset + 0x5C),
                'builder':		lbx.read_byte(self.__data, offset + 0x5D),		# or previous owner?
                'cost':                 lbx.read_short_int(self.__data, offset + 0x5E),
                'combat_speed':         lbx.read_byte(self.__data, offset + 0x60),
                'build_date':           lbx.read_short_int(self.__data, offset + 0x61)
        }
Example #4
0
 def parse_ship_design(self, offset):
     MAX_WEAPONS = 8
     weapons = []
     for i in range(MAX_WEAPONS):
         offset2 = offset + 0x1C + (8 * i)
         weapon = lbx.read_byte(self.__data, offset2)
         if (weapon > 0):
             weapons.append({
                 'weapon':
                 weapon,
                 'count':
                 lbx.read_byte(self.__data, offset2 + 0x02),
                 'current_count':
                 lbx.read_byte(self.__data, offset2 + 0x03),
                 'arc':
                 lbx.read_byte(self.__data, offset2 + 0x04),
                 'beam_mods':
                 lbx.read_byte(self.__data, offset2 + 0x05),
                 'missile_mods':
                 lbx.read_byte(self.__data, offset2 + 0x06),
                 'ammo':
                 lbx.read_byte(self.__data, offset2 + 0x07)
             })
     return {
         'name':
         lbx.read_string(self.__data, offset, 16),
         'size':
         lbx.read_byte(self.__data, offset + 0x10),
         'type':
         lbx.read_byte(
             self.__data, offset + 0x11
         ),  # 0 = combat ship, 1 = colony ship, 2 = transport ship, 3 = guardian, 4 = outpost ship
         'shield':
         lbx.read_byte(self.__data, offset + 0x12),
         'drive':
         lbx.read_byte(self.__data, offset + 0x13),
         'speed':
         lbx.read_byte(self.__data, offset + 0x14),
         'computer':
         lbx.read_byte(self.__data, offset + 0x15),
         'armor':
         lbx.read_byte(self.__data, offset + 0x16),
         #                'special_devices':	self.__data[offset + 0x17:offset + 0x1C],	# char  special_device_flags[(MAX_SPECIALS+7)/8];
         'special_devices':
         bitarray(bytearray(self.__data[offset + 0x17:offset + 0x1C])
                  ),  # char  special_device_flags[(MAX_SPECIALS+7)/8];
         'weapons':
         weapons,
         'picture':
         lbx.read_byte(self.__data, offset + 0x5C),
         'builder':
         lbx.read_byte(self.__data, offset + 0x5D),  # or previous owner?
         'cost':
         lbx.read_short_int(self.__data, offset + 0x5E),
         'combat_speed':
         lbx.read_byte(self.__data, offset + 0x60),
         'build_date':
         lbx.read_short_int(self.__data, offset + 0x61)
     }
Example #5
0
    def import_from_moo2(self, data):

        self.__moo2data = data

        self.set_name(lbx.read_string(data, 0, 15))
        self.set_x(lbx.read_short_int(data, 0x0f))
        self.set_y(lbx.read_short_int(data, 0x11))
        self.set_size(lbx.read_byte(data, 0x13))
        self.__owner = lbx.read_byte(data, 0x14)		# primary owner
        self.set_pict_type(lbx.read_byte(data, 0x15))
        self.set_class(lbx.read_byte(data, 0x16))
        self.__last_planet_selected = [
            lbx.read_byte(data, 0x17),
            lbx.read_byte(data, 0x18),
            lbx.read_byte(data, 0x19),
            lbx.read_byte(data, 0x1A),
            lbx.read_byte(data, 0x1B),
            lbx.read_byte(data, 0x1C),
            lbx.read_byte(data, 0x1D),
            lbx.read_byte(data, 0x1E)
        ]

        self.__special = lbx.read_byte(data, 0x28)
        self.__wormhole = lbx.read_byte(data, 0x29)
        self.__blockaded_players = bitmask_to_player_id_list(ord(data[0x2a]))
        self.__blockaded_by_bitmask = [ord(data[0x2b]), ord(data[0x2c]), ord(data[0x2d]), ord(data[0x2e]), ord(data[0x2f]), ord(data[0x30]), ord(data[0x31]), ord(data[0x32])]
        self.__visited = ord(data[0x33])                # bitmask as boleans for each player
        self.__just_visited_bitmask = ord(data[0x34])           # players bitmask to track first visit of this star -> user should get report
        self.__ignore_colony_ship_bitmask = ord(data[0x35])     # players bitmask to track if player chose to not use a colony ship, cleared on every new colony ship here?
        self.__ignore_combat_bitmask = ord(data[0x36])  # players bitmask to track if player chose to ignore combat ships = perform blockade only do not fight here?
        self.__colonize_player = ord(data[0x37])        # 0..7 or -1
        self.__colonies_bitmask = ord(data[0x38])       # has colony / players bitmask / redundant info?
        self.__interdictors_bitmask = ord(data[0x39])   # has warp interdictor / players bitmask
        self.__next_wfi_in_list = ord(data[0x3a])       # bookeeping ???
        self.__tachyon_com_bitmask = ord(data[0x3b])    # has tachyon communicator / players bitmask
        self.__subspace_com_bitmask = ord(data[0x3c])   # has subspace communicator / players bitmask
        self.__stargates_bitmask = ord(data[0x3d])      # has stargate / players bitmask
        self.__jumpgates_bitmask = ord(data[0x3e])      # has jumpgate / players bitmask
        self.__artemis_bitmask = ord(data[0x3f])        # has artemis net players bitmask
        self.__portals_bitmask = ord(data[0x40])	# has dimension portal / players bitmask
        self.__stagepoint_bitmask = ord(data[0x41])	# bitvector tells whether star is stagepoint for each AI
        self.__players_officers = [ord(data[0x42]), ord(data[0x43]), ord(data[0x44]), ord(data[0x45]), ord(data[0x46]), ord(data[0x47]), ord(data[0x48]), ord(data[0x49])]
        self.set_objects([
                         lbx.read_short_int(data, 0x4a),
                         lbx.read_short_int(data, 0x4c),
                         lbx.read_short_int(data, 0x4e),
                         lbx.read_short_int(data, 0x50),
                         lbx.read_short_int(data, 0x52)
                         ])
        self.__surrender_to = [ord(data[0x67]), ord(data[0x68]), ord(data[0x69]), ord(data[0x6a]), ord(data[0x6b]), ord(data[0x6c]), ord(data[0x6d]), ord(data[0x6e])]
        self.__is_in_nebula = (ord(data[0x6f]) == 1)
Example #6
0
 def parse_game(self):
     return {
         'name':				lbx.read_string(self.__data, 0x04, 23).lstrip(chr(0) + chr(1) + chr(2) + chr(3)),
         'end_of_turn_summary':		lbx.read_byte(self.__data, 0x2E),
         'end_of_turn_wait':			lbx.read_byte(self.__data, 0x2F),
         'random_events':			lbx.read_byte(self.__data, 0x30),
         'enemy_moves':			lbx.read_byte(self.__data, 0x31),
         'expanding_help':			lbx.read_byte(self.__data, 0x32),
         'auto_select_ships':		lbx.read_byte(self.__data, 0x33),
         'animations':			lbx.read_byte(self.__data, 0x34),
         'auto_select_colony':		lbx.read_byte(self.__data, 0x35),
         'show_relocation_lines':		lbx.read_byte(self.__data, 0x36),
         'show_gnn_report':			lbx.read_byte(self.__data, 0x37),
         'auto_delete_trade_good_housing':	lbx.read_byte(self.__data, 0x38),
         'auto_save_game':			lbx.read_byte(self.__data, 0x39),
         'show_only_serious_turn_summary':	lbx.read_byte(self.__data, 0x3A),
         'ship_initiative':			lbx.read_byte(self.__data, 0x3B),
     }
Example #7
0
    def __old__parse_stars(self):

        for i in range(c):
            offset = SOLAR_SYSTEMS_DATA_OFFSET + (SOLAR_SYSTEM_RECORD_SIZE * i)
            systems = {}
            #            print "system @ %x" % offset
            star_id = i
            #            systems.append({
            systems[star_id] = {
                'id':
                i,
                'name':
                lbx.read_string(self.__data, offset, 15),
                'x':
                lbx.read_short_int(self.__data, offset + 0x0f),
                'y':
                lbx.read_short_int(self.__data, offset + 0x11),
                'size':
                lbx.read_byte(self.__data, offset + 0x13),
                'owner':
                lbx.read_byte(self.__data, offset + 0x14),  # primary owner
                'pict_type':
                lbx.read_byte(self.__data, offset + 0x15),
                'class':
                lbx.read_byte(self.__data, offset + 0x16),
                'last_planet_selected': [
                    lbx.read_byte(self.__data, offset + 0x17),
                    lbx.read_byte(self.__data, offset + 0x18),
                    lbx.read_byte(self.__data, offset + 0x19),
                    lbx.read_byte(self.__data, offset + 0x1A),
                    lbx.read_byte(self.__data, offset + 0x1B),
                    lbx.read_byte(self.__data, offset + 0x1C),
                    lbx.read_byte(self.__data, offset + 0x1D),
                    lbx.read_byte(self.__data, offset + 0x1E)
                ],
                'black_hole_blocks': [],
                '0x1f':
                ord(self.__data[offset + 0x1f]),
                '0x20':
                ord(self.__data[offset + 0x20]),
                '0x21':
                ord(self.__data[offset + 0x21]),
                '0x22':
                ord(self.__data[offset + 0x22]),
                '0x23':
                ord(self.__data[offset + 0x23]),
                '0x24':
                ord(self.__data[offset + 0x24]),
                '0x25':
                ord(self.__data[offset + 0x25]),
                '0x26':
                ord(self.__data[offset + 0x26]),
                '0x27':
                ord(self.__data[offset + 0x27]),
                'special':
                ord(self.__data[offset + 0x28]),
                'wormhole':
                ord(self.__data[offset + 0x29]),
                '0x2a':
                ord(self.__data[offset + 0x2a]),  # blockaded? ( 0 | 1 )
                '0x2b':
                ord(self.__data[offset + 0x2b]),
                '0x2c':
                ord(self.__data[offset + 0x2c]),
                '0x2d':
                ord(self.__data[offset + 0x2d]),
                '0x2e':
                ord(self.__data[offset + 0x2e]),
                '0x2f':
                ord(self.__data[offset + 0x2f]),
                '0x30':
                ord(self.__data[offset + 0x30]),
                '0x31':
                ord(self.__data[offset + 0x31]),
                '0x32':
                ord(self.__data[offset + 0x32]),
                'visited':
                ord(self.__data[offset +
                                0x33]),  # bitmask as boleans for each player
                '0x34':
                ord(self.__data[offset + 0x34]),
                '0x35':
                ord(self.__data[offset + 0x35]),
                '0x36':
                ord(self.__data[offset + 0x36]),
                '0x37':
                ord(self.__data[offset + 0x37]),
                '0x38':
                ord(self.__data[offset + 0x38]),
                'indictor':
                ord(
                    self.__data[offset + 0x39]
                ),  # 0 = none, 1-8 = owner player 0-7  ( http://code.google.com/p/moo2x/wiki/star )
                '0x3a':
                ord(self.__data[offset + 0x3a]),
                '0x3b':
                ord(self.__data[offset + 0x3b]),
                '0x3c':
                ord(self.__data[offset + 0x3c]),
                '0x3d':
                ord(self.__data[offset + 0x3d]),
                '0x3e':
                ord(self.__data[offset + 0x3e]),
                'artemis':
                ord(
                    self.__data[offset + 0x3f]
                ),  # 0 = none, 1-8=owner player 0-7 ( http://code.google.com/p/moo2x/wiki/star )
                '0x40':
                ord(self.__data[offset +
                                0x40]),  # Star has dimensional portal ?
                '0x41':
                ord(self.__data[offset + 0x41]),
                '0x42':
                ord(self.__data[offset + 0x42]),
                '0x43':
                ord(self.__data[offset + 0x43]),
                '0x44':
                ord(self.__data[offset + 0x44]),
                '0x45':
                ord(self.__data[offset + 0x45]),
                '0x46':
                ord(self.__data[offset + 0x46]),
                '0x47':
                ord(self.__data[offset + 0x47]),
                '0x48':
                ord(self.__data[offset + 0x48]),
                '0x49':
                ord(self.__data[offset + 0x49]),
                'objects': [
                    compose_int(ord(self.__data[offset + 0x4a]),
                                ord(self.__data[offset + 0x4b])),
                    compose_int(ord(self.__data[offset + 0x4c]),
                                ord(self.__data[offset + 0x4d])),
                    compose_int(ord(self.__data[offset + 0x4e]),
                                ord(self.__data[offset + 0x4f])),
                    compose_int(ord(self.__data[offset + 0x50]),
                                ord(self.__data[offset + 0x51])),
                    compose_int(ord(self.__data[offset + 0x52]),
                                ord(self.__data[offset + 0x53]))
                ],
                #		??? Relocation star id (0-7 player #, not sure about size of array. )
                '0x54':
                ord(self.__data[offset + 0x54]),
                '0x55':
                ord(self.__data[offset + 0x55]),
                '0x56':
                ord(self.__data[offset + 0x56]),
                '0x57':
                ord(self.__data[offset + 0x57]),
                '0x58':
                ord(self.__data[offset + 0x58]),
                '0x59':
                ord(self.__data[offset + 0x59]),
                '0x5a':
                ord(self.__data[offset + 0x5a]),
                '0x5b':
                ord(self.__data[offset + 0x5b]),
                '0x5c':
                ord(self.__data[offset + 0x5c]),
                '0x5d':
                ord(self.__data[offset + 0x5d]),
                '0x5e':
                ord(self.__data[offset + 0x5e]),
                '0x5f':
                ord(self.__data[offset + 0x5f]),
                '0x60':
                ord(self.__data[offset + 0x60]),
                '0x61':
                ord(self.__data[offset + 0x61]),
                '0x62':
                ord(self.__data[offset + 0x62]),
                '0x63':
                ord(self.__data[offset + 0x63]),
                #		unknown:
                '0x64':
                ord(self.__data[offset + 0x64]),
                '0x65':
                ord(self.__data[offset + 0x65]),
                '0x66':
                ord(self.__data[offset + 0x66]),
                '0x67':
                ord(self.__data[offset + 0x67]),
                '0x68':
                ord(self.__data[offset + 0x68]),
                '0x69':
                ord(self.__data[offset + 0x69]),
                '0x6a':
                ord(self.__data[offset + 0x6a]),
                '0x6b':
                ord(self.__data[offset + 0x6b]),
                '0x6c':
                ord(self.__data[offset + 0x6c]),
                '0x6d':
                ord(self.__data[offset + 0x6d]),
                '0x6e':
                ord(self.__data[offset + 0x6e]),
                '0x6f':
                ord(self.__data[offset + 0x6f]),
                '0x70':
                ord(self.__data[offset + 0x70])
            }
#        i += 1
#        offset = 0x17ad3 + (SOLAR_SYSTEM_RECORD_SIZE * i)
#        print "STOP system @ %x" % offset
#    blah
        return systems
Example #8
0
    def parse_players(self):
        #
        # Players
        #
        PLAYERS_DATA_OFFSET = 0x01aa0f
        PLAYER_RECORD_SIZE = 3753

        pl = {}
        players = {}

        #        print
        #        print "=== Players ==="

        for i in range(8):

            player_id = i
            offset = PLAYERS_DATA_OFFSET + (PLAYER_RECORD_SIZE * i)
            #            print "player @ %x" % offset

            #            players.append({
            players[player_id] = universe.Player(player_id)
            #            pl[player_id].import_from_moo2(self.__data[offset:offset + PLAYER_RECORD_SIZE])
            players[player_id].set_emperor_name(
                lbx.read_string(self.__data, offset, 15))
            players[player_id].set_race_name(
                lbx.read_string(self.__data, offset + 0x14, 36))
            players[player_id].set_picture(
                lbx.read_byte(self.__data, offset + 0x24))
            players[player_id].set_color(
                lbx.read_byte(self.__data, offset + 0x25))
            players[player_id].set_personality(ord(self.__data[offset + 0x26]))
            players[player_id].set_objective(ord(self.__data[offset + 0x27]))
            players[player_id].set_tax_rate(ord(self.__data[offset + 0x30]))
            players[player_id].set_bc(
                compose_int(ord(self.__data[offset + 0x31]),
                            ord(self.__data[offset + 0x32]),
                            ord(self.__data[offset + 0x33]),
                            ord(self.__data[offset + 0x34])))
            players[player_id].set_total_frighters(
                compose_int(ord(self.__data[offset + 0x35]),
                            ord(self.__data[offset + 0x36])))
            players[player_id].set_used_frighters(
                compose_int(ord(self.__data[offset + 0x37]),
                            ord(self.__data[offset + 0x38])))
            players[player_id].set_command_points(
                compose_int(ord(self.__data[offset + 0x39]),
                            ord(self.__data[offset + 0x3A])))
            players[player_id].set_industry(
                compose_int(ord(self.__data[offset + 0xA9]),
                            ord(self.__data[offset + 0xAA])))
            players[player_id].set_research(
                compose_int(ord(self.__data[offset + 0xAB]),
                            ord(self.__data[offset + 0xAC])))
            players[player_id].set_food(
                compose_int(ord(self.__data[offset + 0x0AF]),
                            ord(self.__data[offset + 0x0B0])))
            #            players[player_id].set_bc_income(compose_int(ord(self.__data[offset + 0x0B1]), ord(self.__data[offset + 0x0B2])))
            players[player_id].set_bc_income(
                lbx.read_signed_short_int(self.__data, offset + 0xB1))
            players[player_id].set_research_progress(
                compose_int(ord(self.__data[offset + 0x1EA]),
                            ord(self.__data[offset + 0x1EB])))
            players[player_id].set_research_area(
                ord(self.__data[offset + 0x320]))
            players[player_id].set_research_item(
                ord(self.__data[offset + 0x321]))
            players[player_id].set_research_costs(0)
            players[player_id].set_racepicks({
                'goverment':
                ord(self.__data[offset + 0x89E]),
                'population':
                lbx.read_signed_byte(self.__data, offset + 0x89F),
                'farming':
                lbx.read_signed_byte(self.__data, offset + 0x8A0),
                'industry':
                lbx.read_signed_byte(self.__data, offset + 0x8A1),
                'science':
                lbx.read_signed_byte(self.__data, offset + 0x8A2),
                'money':
                lbx.read_signed_byte(self.__data, offset + 0x8A3),
                'ship_defense':
                lbx.read_signed_byte(self.__data, offset + 0x8A4),
                'ship_attack':
                lbx.read_signed_byte(self.__data, offset + 0x8A5),
                'ground_combat':
                lbx.read_signed_byte(self.__data, offset + 0x8A6),
                'spying':
                lbx.read_signed_byte(self.__data, offset + 0x8A7),
                'low_g':
                ord(self.__data[offset + 0x8A8]),
                'high_g':
                ord(self.__data[offset + 0x8A9]),
                'aquatic':
                ord(self.__data[offset + 0x8AA]),
                'subterranean':
                ord(self.__data[offset + 0x8AB]),
                'large_home_world':
                ord(self.__data[offset + 0x8AC]),
                'rich_home_world':
                ord(self.__data[offset + 0x8AD]),
                # where is poor_home_worlds?
                'artifacts_home_world':
                ord(self.__data[offset + 0x8AE]),
                'cybernetic':
                ord(self.__data[offset + 0x8AF]),
                'lithovore':
                ord(self.__data[offset + 0x8B0]),
                'repulsive':
                ord(self.__data[offset + 0x8B1]),
                'charismatic':
                ord(self.__data[offset + 0x8B2]),
                'uncreative':
                ord(self.__data[offset + 0x8B3]),
                'creative':
                ord(self.__data[offset + 0x8B4]),
                'tolerant':
                ord(self.__data[offset + 0x8B5]),
                'fantastic_traders':
                ord(self.__data[offset + 0x8B6]),
                'telepathic':
                ord(self.__data[offset + 0x8B7]),
                'lucky':
                ord(self.__data[offset + 0x8B8]),
                'omniscience':
                ord(self.__data[offset + 0x8B9]),
                'stealthy_ships':
                ord(self.__data[offset + 0x8BA]),
                'trans_dimensional':
                ord(self.__data[offset + 0x8BB]),
                'warlord':
                ord(self.__data[offset + 0x8BC]),
            })
            players[player_id].set_known_techs(
                self.parse_known_techs(offset + 0x117))
            players[player_id].set_prototypes([])
            players[player_id].set_tributes([])
            for ii in range(6):
                offset2 = offset + 0x325 + (ii * 0x63)
                players[player_id].add_prototype(
                    self.parse_ship_design(offset2))

            for ii in range(7):
                offset2 = offset + 0x649 + (ii)
                players[player_id].add_tribute(ord(self.__data[offset2]))
#            players[player_id].set_()
            players[8] = universe.Player(8)
            players[8].set_race_name("Antareans")
            players[8].set_emperor_name("Antarean")

            players[9] = universe.Player(8)
            players[9].set_race_name("Orion")
            players[9].set_emperor_name("Loknar")

            players[10] = universe.Player(10)
            players[10].set_race_name("Space Amoeba")
            players[10].set_emperor_name("Amoeba")

            players[11] = universe.Player(11)
            players[11].set_race_name("Space Crystal")
            players[11].set_emperor_name("Crystal")

            players[12] = universe.Player(12)
            players[12].set_race_name("Space Dragon")
            players[12].set_emperor_name("Dragon")

            players[13] = universe.Player(13)
            players[13].set_race_name("Space Eeel")
            players[13].set_emperor_name("Eel")

            players[14] = universe.Player(14)
            players[14].set_race_name("Space Hydra")
            players[14].set_emperor_name("Hydra")

            for player_id in range(8, 15):
                players[player_id].set_bc(0)
                players[player_id].set_bc_income(0)
                players[player_id].set_research_area(0)
                players[player_id].set_research_item(0)
                players[player_id].set_food(0)
                players[player_id].set_research_costs(0)
                players[player_id].set_research_progress(0)
        return players
        """
Example #9
0
    def parse_heroes(self):
        HEROES_DATA_OFFSET = 0x19a9b
        HERO_RECORD_SIZE = 0x3b  # = 59
        heroes = {}
        for i in range(67):
            hero_id = i
            offset = HEROES_DATA_OFFSET + (HERO_RECORD_SIZE * i)

            #            print "hero @ %x" % offset

            type = lbx.read_byte(self.__data, offset + 0x23)
            common_skills = lbx.read_long_int(self.__data, offset + 0x26)
            special_skills = lbx.read_long_int(self.__data, offset + 0x2a)

            heroes[hero_id] = {
                'id':
                i,
                #                'name':             data[offset:offset + 0x0f].rstrip(chr(0)).split(chr(0))[0],
                'name':
                lbx.read_string(self.__data, offset, 15),
                #                'title':            data[offset + 0x0f:offset + 0x23].rstrip(chr(0)).split(chr(0))[0],
                'title':
                lbx.read_string(self.__data, offset, 35),
                'type':
                type,
                'experience':
                lbx.read_short_int(self.__data, offset + 0x24),
                'tech1':
                lbx.read_byte(self.__data, offset + 0x2e),
                'tech2':
                lbx.read_byte(self.__data, offset + 0x2f),
                'tech3':
                lbx.read_byte(self.__data, offset + 0x30),
                'picture':
                lbx.read_byte(self.__data, offset + 0x31),
                'skill_value':
                lbx.read_short_int(self.__data, offset + 0x32),
                'level':
                lbx.read_byte(self.__data, offset + 0x34),
                'location':
                lbx.read_short_int(self.__data, offset + 0x35),
                'eta':
                lbx.read_byte(self.__data, offset + 0x37),
                'level_up':
                lbx.read_byte(self.__data, offset + 0x38),
                'status':
                lbx.read_byte(self.__data, offset + 0x39),
                'player':
                lbx.read_byte(self.__data, offset + 0x3a),
                'skills':
                self.parse_hero_skills(type, common_skills, special_skills),
                'common_skills':
                common_skills,
                'special_skills':
                special_skills,
            }
#            if heroes[hero_id]['player'] == 0:
#                print "Moo2Savegame::parse_heroes ... hero_id = %i, name = %s" % (hero_id, heroes[hero_id]['name'])
#                print " * level = %i" % heroes[hero_id]['level']
#                print " * skill_value = %i" % heroes[hero_id]['skill_value']
#                print " * experience = %i" % heroes[hero_id]['experience']
#                print " * status = %i" % heroes[hero_id]['status']

#        i += 1
#        offset = 0x19a9b + (59 * i)
#        print "STOP hero @ %x" % offset
        return heroes
Example #10
0
    def __old__parse_stars(self):

        for i in range(c):
            offset = SOLAR_SYSTEMS_DATA_OFFSET + (SOLAR_SYSTEM_RECORD_SIZE * i)
            systems = {}
#            print "system @ %x" % offset
            star_id = i
#            systems.append({
            systems[star_id] = {
                'id':			i,
                'name':     		lbx.read_string(self.__data, offset, 15),
                'x':        		lbx.read_short_int(self.__data, offset + 0x0f),
                'y':        		lbx.read_short_int(self.__data, offset + 0x11),
                'size':     		lbx.read_byte(self.__data, offset + 0x13),
                'owner':			lbx.read_byte(self.__data, offset + 0x14),		# primary owner
                'pict_type':		lbx.read_byte(self.__data, offset + 0x15),
                'class':    		lbx.read_byte(self.__data, offset + 0x16),
                'last_planet_selected':	[
                                                lbx.read_byte(self.__data, offset + 0x17),
                                                lbx.read_byte(self.__data, offset + 0x18),
                                                lbx.read_byte(self.__data, offset + 0x19),
                                                lbx.read_byte(self.__data, offset + 0x1A),
                                                lbx.read_byte(self.__data, offset + 0x1B),
                                                lbx.read_byte(self.__data, offset + 0x1C),
                                                lbx.read_byte(self.__data, offset + 0x1D),
                                                lbx.read_byte(self.__data, offset + 0x1E)
                                            ],
                'black_hole_blocks':	[
                                            ],
                '0x1f':		ord(self.__data[offset + 0x1f]),
                '0x20':		ord(self.__data[offset + 0x20]),
                '0x21':		ord(self.__data[offset + 0x21]),
                '0x22':		ord(self.__data[offset + 0x22]),
                '0x23':		ord(self.__data[offset + 0x23]),
                '0x24':		ord(self.__data[offset + 0x24]),
                '0x25':		ord(self.__data[offset + 0x25]),
                '0x26':		ord(self.__data[offset + 0x26]),
                '0x27':		ord(self.__data[offset + 0x27]),
                'special':  	ord(self.__data[offset + 0x28]),
                'wormhole': 	ord(self.__data[offset + 0x29]),
                '0x2a':		ord(self.__data[offset + 0x2a]),	# blockaded? ( 0 | 1 )
                '0x2b':		ord(self.__data[offset + 0x2b]),
                '0x2c':		ord(self.__data[offset + 0x2c]),
                '0x2d':		ord(self.__data[offset + 0x2d]),
                '0x2e':		ord(self.__data[offset + 0x2e]),
                '0x2f':		ord(self.__data[offset + 0x2f]),
                '0x30':		ord(self.__data[offset + 0x30]),
                '0x31':		ord(self.__data[offset + 0x31]),
                '0x32':		ord(self.__data[offset + 0x32]),
                'visited':		ord(self.__data[offset + 0x33]),	# bitmask as boleans for each player
                '0x34':		ord(self.__data[offset + 0x34]),
                '0x35':		ord(self.__data[offset + 0x35]),
                '0x36':		ord(self.__data[offset + 0x36]),
                '0x37':		ord(self.__data[offset + 0x37]),
                '0x38':		ord(self.__data[offset + 0x38]),
                'indictor': 	ord(self.__data[offset + 0x39]),	# 0 = none, 1-8 = owner player 0-7  ( http://code.google.com/p/moo2x/wiki/star )
                '0x3a':		ord(self.__data[offset + 0x3a]),
                '0x3b':		ord(self.__data[offset + 0x3b]),
                '0x3c':		ord(self.__data[offset + 0x3c]),
                '0x3d':		ord(self.__data[offset + 0x3d]),
                '0x3e':		ord(self.__data[offset + 0x3e]),
                'artemis':  	ord(self.__data[offset + 0x3f]),	# 0 = none, 1-8=owner player 0-7 ( http://code.google.com/p/moo2x/wiki/star )
                '0x40':		ord(self.__data[offset + 0x40]),	# Star has dimensional portal ?
                '0x41':		ord(self.__data[offset + 0x41]),
                '0x42':		ord(self.__data[offset + 0x42]),
                '0x43':		ord(self.__data[offset + 0x43]),
                '0x44':		ord(self.__data[offset + 0x44]),
                '0x45':		ord(self.__data[offset + 0x45]),
                '0x46':		ord(self.__data[offset + 0x46]),
                '0x47':		ord(self.__data[offset + 0x47]),
                '0x48':		ord(self.__data[offset + 0x48]),
                '0x49':		ord(self.__data[offset + 0x49]),
                'objects':   	[
                                        compose_int(ord(self.__data[offset + 0x4a]), ord(self.__data[offset + 0x4b])),
                                        compose_int(ord(self.__data[offset + 0x4c]), ord(self.__data[offset + 0x4d])),
                                        compose_int(ord(self.__data[offset + 0x4e]), ord(self.__data[offset + 0x4f])),
                                        compose_int(ord(self.__data[offset + 0x50]), ord(self.__data[offset + 0x51])),
                                        compose_int(ord(self.__data[offset + 0x52]), ord(self.__data[offset + 0x53]))
                                    ],
    #		??? Relocation star id (0-7 player #, not sure about size of array. )
                '0x54':		ord(self.__data[offset + 0x54]),
                '0x55':		ord(self.__data[offset + 0x55]),
                '0x56':		ord(self.__data[offset + 0x56]),
                '0x57':		ord(self.__data[offset + 0x57]),
                '0x58':		ord(self.__data[offset + 0x58]),
                '0x59':		ord(self.__data[offset + 0x59]),
                '0x5a':		ord(self.__data[offset + 0x5a]),
                '0x5b':		ord(self.__data[offset + 0x5b]),
                '0x5c':		ord(self.__data[offset + 0x5c]),
                '0x5d':		ord(self.__data[offset + 0x5d]),
                '0x5e':		ord(self.__data[offset + 0x5e]),
                '0x5f':		ord(self.__data[offset + 0x5f]),
                '0x60':		ord(self.__data[offset + 0x60]),
                '0x61':		ord(self.__data[offset + 0x61]),
                '0x62':		ord(self.__data[offset + 0x62]),
                '0x63':		ord(self.__data[offset + 0x63]),
    #		unknown:
                '0x64':		ord(self.__data[offset + 0x64]),
                '0x65':		ord(self.__data[offset + 0x65]),
                '0x66':		ord(self.__data[offset + 0x66]),
                '0x67':		ord(self.__data[offset + 0x67]),
                '0x68':		ord(self.__data[offset + 0x68]),
                '0x69':		ord(self.__data[offset + 0x69]),
                '0x6a':		ord(self.__data[offset + 0x6a]),
                '0x6b':		ord(self.__data[offset + 0x6b]),
                '0x6c':		ord(self.__data[offset + 0x6c]),
                '0x6d':		ord(self.__data[offset + 0x6d]),
                '0x6e':		ord(self.__data[offset + 0x6e]),
                '0x6f':		ord(self.__data[offset + 0x6f]),
                '0x70':		ord(self.__data[offset + 0x70])
                }
#        i += 1
#        offset = 0x17ad3 + (SOLAR_SYSTEM_RECORD_SIZE * i)
#        print "STOP system @ %x" % offset
    #    blah
        return systems
Example #11
0
    def parse_players(self):
        #
        # Players
        #
        PLAYERS_DATA_OFFSET	= 0x01aa0f
        PLAYER_RECORD_SIZE	= 3753

        pl = {}
        players = {}

#        print
#        print "=== Players ==="

        for i in range(8):

            player_id = i
            offset		= PLAYERS_DATA_OFFSET + (PLAYER_RECORD_SIZE * i)
#            print "player @ %x" % offset

#            players.append({
            players[player_id] = universe.Player(player_id)
#            pl[player_id].import_from_moo2(self.__data[offset:offset + PLAYER_RECORD_SIZE])
            players[player_id].set_emperor_name(lbx.read_string(self.__data, offset, 15))
            players[player_id].set_race_name(lbx.read_string(self.__data, offset + 0x14, 36))
            players[player_id].set_picture(lbx.read_byte(self.__data, offset + 0x24))
            players[player_id].set_color(lbx.read_byte(self.__data, offset + 0x25))
            players[player_id].set_personality(ord(self.__data[offset + 0x26]))
            players[player_id].set_objective(ord(self.__data[offset + 0x27]))
            players[player_id].set_tax_rate(ord(self.__data[offset + 0x30]))
            players[player_id].set_bc(compose_int(ord(self.__data[offset + 0x31]), ord(self.__data[offset + 0x32]), ord(self.__data[offset + 0x33]), ord(self.__data[offset + 0x34])))
            players[player_id].set_total_frighters(compose_int(ord(self.__data[offset + 0x35]), ord(self.__data[offset + 0x36])))
            players[player_id].set_used_frighters(compose_int(ord(self.__data[offset + 0x37]), ord(self.__data[offset + 0x38])))
            players[player_id].set_command_points(compose_int(ord(self.__data[offset + 0x39]), ord(self.__data[offset + 0x3A])))
            players[player_id].set_industry(compose_int(ord(self.__data[offset + 0xA9]), ord(self.__data[offset + 0xAA])))
            players[player_id].set_research(compose_int(ord(self.__data[offset + 0xAB]), ord(self.__data[offset + 0xAC])))
            players[player_id].set_food(compose_int(ord(self.__data[offset + 0x0AF]), ord(self.__data[offset + 0x0B0])))
#            players[player_id].set_bc_income(compose_int(ord(self.__data[offset + 0x0B1]), ord(self.__data[offset + 0x0B2])))
            players[player_id].set_bc_income(lbx.read_signed_short_int(self.__data, offset + 0xB1))
            players[player_id].set_research_progress(compose_int(ord(self.__data[offset + 0x1EA]), ord(self.__data[offset + 0x1EB])))
            players[player_id].set_research_area(ord(self.__data[offset + 0x320]))
            players[player_id].set_research_item(ord(self.__data[offset + 0x321]))
            players[player_id].set_research_costs(0)
            players[player_id].set_racepicks({
                                        'goverment':		ord(self.__data[offset + 0x89E]),
                                        'population':		lbx.read_signed_byte(self.__data, offset + 0x89F),
                                        'farming':		lbx.read_signed_byte(self.__data, offset + 0x8A0),
                                        'industry':		lbx.read_signed_byte(self.__data, offset + 0x8A1),
                                        'science':		lbx.read_signed_byte(self.__data, offset + 0x8A2),
                                        'money':		lbx.read_signed_byte(self.__data, offset + 0x8A3),
                                        'ship_defense':		lbx.read_signed_byte(self.__data, offset + 0x8A4),
                                        'ship_attack':		lbx.read_signed_byte(self.__data, offset + 0x8A5),
                                        'ground_combat':	lbx.read_signed_byte(self.__data, offset + 0x8A6),
                                        'spying':		lbx.read_signed_byte(self.__data, offset + 0x8A7),
                                        'low_g':		ord(self.__data[offset + 0x8A8]),
                                        'high_g':		ord(self.__data[offset + 0x8A9]),
                                        'aquatic':		ord(self.__data[offset + 0x8AA]),
                                        'subterranean':		ord(self.__data[offset + 0x8AB]),
                                        'large_home_world':	ord(self.__data[offset + 0x8AC]),
                                        'rich_home_world':	ord(self.__data[offset + 0x8AD]),
                                        # where is poor_home_worlds?
                                        'artifacts_home_world':	ord(self.__data[offset + 0x8AE]),
                                        'cybernetic':		ord(self.__data[offset + 0x8AF]),
                                        'lithovore':		ord(self.__data[offset + 0x8B0]),
                                        'repulsive':		ord(self.__data[offset + 0x8B1]),
                                        'charismatic':		ord(self.__data[offset + 0x8B2]),
                                        'uncreative':		ord(self.__data[offset + 0x8B3]),
                                        'creative':		ord(self.__data[offset + 0x8B4]),
                                        'tolerant':		ord(self.__data[offset + 0x8B5]),
                                        'fantastic_traders':	ord(self.__data[offset + 0x8B6]),
                                        'telepathic':		ord(self.__data[offset + 0x8B7]),
                                        'lucky':		ord(self.__data[offset + 0x8B8]),
                                        'omniscience':		ord(self.__data[offset + 0x8B9]),
                                        'stealthy_ships':	ord(self.__data[offset + 0x8BA]),
                                        'trans_dimensional':	ord(self.__data[offset + 0x8BB]),
                                        'warlord':		ord(self.__data[offset + 0x8BC]),
                                    })
            players[player_id].set_known_techs(self.parse_known_techs(offset + 0x117))
            players[player_id].set_prototypes([])
            players[player_id].set_tributes([])
            for ii in range(6):
                offset2 = offset + 0x325 + (ii * 0x63)
                players[player_id].add_prototype(self.parse_ship_design(offset2))

            for ii in range(7):
                offset2 = offset + 0x649 + (ii)
                players[player_id].add_tribute(ord(self.__data[offset2]))
#            players[player_id].set_()
            players[8] = universe.Player(8)
            players[8].set_race_name("Antareans")
            players[8].set_emperor_name("Antarean")

            players[9] = universe.Player(8)
            players[9].set_race_name("Orion")
            players[9].set_emperor_name("Loknar")

            players[10] = universe.Player(10)
            players[10].set_race_name("Space Amoeba")
            players[10].set_emperor_name("Amoeba")

            players[11] = universe.Player(11)
            players[11].set_race_name("Space Crystal")
            players[11].set_emperor_name("Crystal")

            players[12] = universe.Player(12)
            players[12].set_race_name("Space Dragon")
            players[12].set_emperor_name("Dragon")

            players[13] = universe.Player(13)
            players[13].set_race_name("Space Eeel")
            players[13].set_emperor_name("Eel")

            players[14] = universe.Player(14)
            players[14].set_race_name("Space Hydra")
            players[14].set_emperor_name("Hydra")

            for player_id in range(8, 15):
                players[player_id].set_bc(0)
                players[player_id].set_bc_income(0)
                players[player_id].set_research_area(0)
                players[player_id].set_research_item(0)
                players[player_id].set_food(0)
                players[player_id].set_research_costs(0)
                players[player_id].set_research_progress(0)
        return players
        """
Example #12
0
    def import_from_moo2(self, data):

        self.__moo2data = data

        self.set_name(lbx.read_string(data, 0, 15))
        self.set_x(lbx.read_short_int(data, 0x0f))
        self.set_y(lbx.read_short_int(data, 0x11))
        self.set_size(lbx.read_byte(data, 0x13))
        self.__owner = lbx.read_byte(data, 0x14)  # primary owner
        self.set_pict_type(lbx.read_byte(data, 0x15))
        self.set_class(lbx.read_byte(data, 0x16))
        self.__last_planet_selected = [
            lbx.read_byte(data, 0x17),
            lbx.read_byte(data, 0x18),
            lbx.read_byte(data, 0x19),
            lbx.read_byte(data, 0x1A),
            lbx.read_byte(data, 0x1B),
            lbx.read_byte(data, 0x1C),
            lbx.read_byte(data, 0x1D),
            lbx.read_byte(data, 0x1E)
        ]

        self.__special = lbx.read_byte(data, 0x28)
        self.__wormhole = lbx.read_byte(data, 0x29)
        self.__blockaded_players = bitmask_to_player_id_list(ord(data[0x2a]))
        self.__blockaded_by_bitmask = [
            ord(data[0x2b]),
            ord(data[0x2c]),
            ord(data[0x2d]),
            ord(data[0x2e]),
            ord(data[0x2f]),
            ord(data[0x30]),
            ord(data[0x31]),
            ord(data[0x32])
        ]
        self.__visited = ord(data[0x33])  # bitmask as boleans for each player
        self.__just_visited_bitmask = ord(
            data[0x34]
        )  # players bitmask to track first visit of this star -> user should get report
        self.__ignore_colony_ship_bitmask = ord(
            data[0x35]
        )  # players bitmask to track if player chose to not use a colony ship, cleared on every new colony ship here?
        self.__ignore_combat_bitmask = ord(
            data[0x36]
        )  # players bitmask to track if player chose to ignore combat ships = perform blockade only do not fight here?
        self.__colonize_player = ord(data[0x37])  # 0..7 or -1
        self.__colonies_bitmask = ord(
            data[0x38])  # has colony / players bitmask / redundant info?
        self.__interdictors_bitmask = ord(
            data[0x39])  # has warp interdictor / players bitmask
        self.__next_wfi_in_list = ord(data[0x3a])  # bookeeping ???
        self.__tachyon_com_bitmask = ord(
            data[0x3b])  # has tachyon communicator / players bitmask
        self.__subspace_com_bitmask = ord(
            data[0x3c])  # has subspace communicator / players bitmask
        self.__stargates_bitmask = ord(
            data[0x3d])  # has stargate / players bitmask
        self.__jumpgates_bitmask = ord(
            data[0x3e])  # has jumpgate / players bitmask
        self.__artemis_bitmask = ord(
            data[0x3f])  # has artemis net players bitmask
        self.__portals_bitmask = ord(
            data[0x40])  # has dimension portal / players bitmask
        self.__stagepoint_bitmask = ord(
            data[0x41]
        )  # bitvector tells whether star is stagepoint for each AI
        self.__players_officers = [
            ord(data[0x42]),
            ord(data[0x43]),
            ord(data[0x44]),
            ord(data[0x45]),
            ord(data[0x46]),
            ord(data[0x47]),
            ord(data[0x48]),
            ord(data[0x49])
        ]
        self.set_objects([
            lbx.read_short_int(data, 0x4a),
            lbx.read_short_int(data, 0x4c),
            lbx.read_short_int(data, 0x4e),
            lbx.read_short_int(data, 0x50),
            lbx.read_short_int(data, 0x52)
        ])
        self.__surrender_to = [
            ord(data[0x67]),
            ord(data[0x68]),
            ord(data[0x69]),
            ord(data[0x6a]),
            ord(data[0x6b]),
            ord(data[0x6c]),
            ord(data[0x6d]),
            ord(data[0x6e])
        ]
        self.__is_in_nebula = (ord(data[0x6f]) == 1)