예제 #1
0
    def read(self, filecontents, replay):
        replay.messages = list()
        bytes, time = ByteStream(filecontents), 0

        while(bytes.remaining!=0):
            time += bytes.get_timestamp()
            player_id = bytes.get_big_8() & 0x0F
            flags = bytes.get_big_8()
            
            if flags & 0xF0 == 0x80:
            
                #ping or something?
                if flags & 0x0F == 3:
                    bytes.skip(8)

                #some sort of header code
                elif flags & 0x0F == 0:
                    bytes.skip(4)
                    replay.other_people.add(player_id)
            
            elif flags & 0x80 == 0:
                target = flags & 0x03
                length = bytes.get_big_8()
                
                if flags & 0x08:
                    length += 64
                    
                if flags & 0x10:
                    length += 128
                    
                text = bytes.get_string(length)
                replay.messages.append(Message(time, player_id, target, text))
예제 #2
0
파일: readers.py 프로젝트: pieps/sc2reader
    def read(self, filecontents, replay):
        bytes = ByteStream(filecontents)

        self.load_header(replay, bytes)

        replay.attributes = list()
        data = defaultdict(dict)
        for i in range(0, bytes.get_little_32()):
            replay.attributes.append(self.load_attribute(replay, bytes))
예제 #3
0
    def read(self, filecontents, replay):
        bytes = ByteStream(filecontents)
		
        self.load_header(replay, bytes)
        
        replay.attributes = list()
        data = defaultdict(dict)
        for i in range(0, bytes.get_little_32()):
            replay.attributes.append(self.load_attribute(replay, bytes))
예제 #4
0
파일: readers.py 프로젝트: pieps/sc2reader
    def read(self, filecontents, replay):
        #set up an event list, start the timer, and process the file contents
        replay.events, frames, bytes = list(), 0, ByteStream(filecontents)

        while bytes.remaining > 0:
            #Save the start so we can trace for debug purposes
            start = bytes.cursor

            #First section is always a timestamp marking the elapsed time
            #since the last eventObjectlisted
            new_frames = bytes.get_timestamp()
            frames += new_frames

            #Next is a compound byte where the first 3 bits XXX00000 mark the
            #event_type, the 4th bit 000X0000 marks the eventObjectas local or global,
            #and the remaining bits 0000XXXX mark the player id number.
            #The following byte completes the unique eventObjectidentifier
            first, event_code = bytes.get_big_8(), bytes.get_big_8()
            event_type, pid = first >> 5, first & 0x1F

            if event_type not in self.parsers.keys():
                msg = "Unknown event_type: %s at location %s"
                raise TypeError(msg % (hex(event_type), hex(start)))

            for parser, loads in self.parsers[event_type]:
                if loads(event_code):
                    event = parser.load(bytes, frames, event_type, event_code,
                                        pid)
                    event.bytes = bytes.get_range(start, bytes.cursor)
                    replay.events.append(event)
                    break
            else:
                raise TypeError("Unknown event: %s - %s at %s" %
                                (hex(event_type), hex(event_code), hex(start)))
예제 #5
0
    def read(self, filecontents, replay):
        data =  ByteStream(filecontents).parse_serialized_data()

        for pid, pdata in enumerate(data[0]):
            replay.players.append(Player(pid+1, pdata, replay.realm)) #pid's start @ 1
            
        replay.map = data[1].decode("hex")
        replay.file_time = data[5]

        # TODO: This doesn't seem to produce exactly correct results, ie. often off by one
        # second compared to file timestamps reported by Windows.
        # This might be due to wrong value of the magic constant 116444735995904000
        # or rounding errors. Ceiling or Rounding the result didn't produce consistent
        # results either.
        replay.date = datetime.fromtimestamp((replay.file_time-116444735995904000)/10000000)
        replay.utc_date = datetime.utcfromtimestamp((replay.file_time-116444735995904000)/10000000)
        
        replay.details_data = data
예제 #6
0
파일: readers.py 프로젝트: pieps/sc2reader
    def read(self, filecontents, replay):
        bytes = ByteStream(filecontents)
        num_people = bytes.get_big_8()
        for p in range(1, num_people + 1):
            name = bytes.get_string(bytes.get_big_8())

            if len(name) > 0:
                replay.player_names.append(name)

            bytes.skip(5)  #Always all zeros

        bytes.skip(5)  # Unknown
        bytes.get_string(4)  # Always Dflt
        bytes.skip(15)  #Unknown
        id_length = bytes.get_big_8()
        sc_account_id = bytes.get_string(id_length)
        bytes.skip(684)  # Fixed Length data for unknown purpose
        while (bytes.get_string(4).lower() == 's2ma'):
            bytes.skip(2)
            replay.realm = bytes.get_string(2).lower()
            unknown_map_hash = bytes.get_bytes(32)
예제 #7
0
파일: readers.py 프로젝트: pieps/sc2reader
    def read(self, filecontents, replay):
        replay.messages = list()
        bytes, time = ByteStream(filecontents), 0

        while (bytes.remaining != 0):
            time += bytes.get_timestamp()
            player_id = bytes.get_big_8() & 0x0F
            flags = bytes.get_big_8()

            if flags & 0xF0 == 0x80:

                #ping or something?
                if flags & 0x0F == 3:
                    bytes.skip(8)

                #some sort of header code
                elif flags & 0x0F == 0:
                    bytes.skip(4)
                    replay.other_people.add(player_id)

            elif flags & 0x80 == 0:
                target = flags & 0x03
                length = bytes.get_big_8()

                if flags & 0x08:
                    length += 64

                if flags & 0x10:
                    length += 128

                text = bytes.get_string(length)
                replay.messages.append(Message(time, player_id, target, text))
예제 #8
0
 def read(self, filecontents, replay):
     bytes = ByteStream(filecontents)
     num_people = bytes.get_big_8()
     for p in range(1, num_people+1):
         name = bytes.get_string(bytes.get_big_8())
         
         if len(name) > 0:
             replay.player_names.append(name)
             
         bytes.skip(5) #Always all zeros
     
     bytes.skip(5) # Unknown
     bytes.get_string(4) # Always Dflt
     bytes.skip(15) #Unknown
     id_length = bytes.get_big_8()
     sc_account_id = bytes.get_string(id_length)
     bytes.skip(684) # Fixed Length data for unknown purpose
     while( bytes.get_string(4).lower() == 's2ma' ):
         bytes.skip(2)
         replay.realm = bytes.get_string(2).lower()
         unknown_map_hash = bytes.get_bytes(32)