コード例 #1
0
ファイル: demo.py プロジェクト: Danmer/qldemo-python
    def read_delta_entity(self, frm, num):
        ## Check for server order to remove a baseline
        if huffman.readbits(1) == 1:
            # Don't know how we should handle this, it does mean no
            # new data; skipping for now
            return
        ## Check for 'no delta' flag
        if huffman.readbits(1) == 0:
            ## No changes, we should make 'from' a copy of
            ## 'to'... skipping for now
            return

        last_field = huffman.readbyte()
        entity = EntityState()
        netf = EntityStateNETF(entity)

        for i in range(0, last_field):
            if huffman.readbits(1) :
                if not netf.bits[i] :
                    if huffman.readbits(1) != 0:
                        if huffman.readbits(1) == 0:
                            netf.fields[i] = huffman.readbits(FLOAT_INT_BITS)
                        else :
                            netf.fields[i] = huffman.readfloat()
                else:
                    if huffman.readbits(1) != 0:
                        netf.fields[i] = huffman.readbits(netf.bits[i])

        netf.update()
        return entity
コード例 #2
0
ファイル: demo.py プロジェクト: Danmer/qldemo-python
    def parse_playerstate(self):
        last_field=huffman.readbyte()
        player=PlayerState()
        netf=PlayerStateNETF(player)

        playerStateFieldsNum  = len( netf.bits )

        if last_field > playerStateFieldsNum :
            return None

        for i in range( 0, last_field) :
            if huffman.readbits( 1 ) :
                if netf.bits[ i ] == 0 :
                    if huffman.readbits( 1 ) == 0 :
                        netf.fields[ i ] = huffman.readbits( FLOAT_INT_BITS ) - FLOAT_INT_BIAS
                    else :
                        netf.fields[ i ] = huffman.readfloat()
                else :
                    bits = netf.bits[ i ]
                    netf.fields[ i ] = huffman.readbits( bits )
        netf.update()

        if huffman.readbits( 1 ) :
            if huffman.readbits( 1 ) :
                c = huffman.readshort()
                for i in range( MAX_STATS ) :
                    if c & ( 1 << i ) :
                        player.stats[ i ] = huffman.readshort()

            if huffman.readbits( 1 ) :
                c = huffman.readshort()
                for i in range( MAX_PERSISTANT ) :
                    if c & ( 1 << i ) :
                        player.persistant[ i ] = huffman.readshort()

            if huffman.readbits( 1 ) :
                c = huffman.readshort()
                for i in range( MAX_WEAPONS ) :
                    if c & ( 1 << i ) :
                        player.ammo[ i ] = huffman.readshort()

            if huffman.readbits( 1 ) :
                c = huffman.readshort()
                for i in range( MAX_POWERUPS ) :
                    if c & ( 1 << i ) :
                        player.powerups[ i ] = huffman.readlong()

        return player
コード例 #3
0
ファイル: demo.py プロジェクト: Danmer/qldemo-python
 def parse_baseline(self):
     newnum = huffman.readbits(GENTITYNUM_BITS)
     null_state=EntityState()
     baseline = self.read_delta_entity(null_state, newnum)