Ejemplo n.º 1
0
    def __init__(self, sonic2, name, c_id, data, primary_collision_index, secondary_collision_index):
        self.name = name
        self.c_id = c_id
        self.sonic2 = sonic2
        self.primary_collision_index = primary_collision_index
        self.secondary_collision_index = secondary_collision_index

        bm = kosinski.decompress_string(data).tostring()

        if((len(bm) % 128) != 0):
            logging.error("Inappropriately sized level map: %d" % bmfs)
            exit(-1)

        blocks = len(bm) / 128

        logging.debug("There are %d blocks in this ChunkArray." % blocks)

        self.chunks = []
        chunk_no = 0
        for block in range(0, blocks):
            logging.debug("... chunk %d: " % chunk_no)
            chunk_no += 1
            block_data = bm[block*128:(block*128) + 128]
            self.chunks.append(chunk.Chunk(self, block_data, chunk_no))
Ejemplo n.º 2
0
    def __init__(self, chunk_array, data):
        self.chunk_array = chunk_array
        bytemap = kosinski.decompress_string(data).tostring()

        if((len(bytemap) % 128) != 0):
            logging.error("Inappropriately sized level map: %d" % mfs)
            exit(-1)

        self.foreground = []
        self.background = []

        for y in range(0, len(bytemap) / 128):
            row_data = bytemap[y*128:(y*128)+128]
            if(len(row_data) != 128):
                logging.error("Level layout row with length not 128?!: %d" % len(row_data))
                exit(-1)
            block_ids = array.array('B', row_data)
            row = []
            for block_id in block_ids:
                row.append(self.chunk_array.chunks[block_id])
            if((y % 2) == 0):
                self.foreground.append(row)
            else:
                self.background.append(row)
Ejemplo n.º 3
0
 def __init__(self, sonic2, data):
     self.sonic2 = sonic2
     self.ids = kosinski.decompress_string(data)
     if(len(self.ids) != 768):
         logging.error("Sonic 2 collision indexes are always 768 records (bytes) long.")
         exit(-1)