当前位置: 首页>>代码示例>>Python>>正文


Python ByteReader.read方法代码示例

本文整理汇总了Python中cuwo.bytes.ByteReader.read方法的典型用法代码示例。如果您正苦于以下问题:Python ByteReader.read方法的具体用法?Python ByteReader.read怎么用?Python ByteReader.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cuwo.bytes.ByteReader的用法示例。


在下文中一共展示了ByteReader.read方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: read

# 需要导入模块: from cuwo.bytes import ByteReader [as 别名]
# 或者: from cuwo.bytes.ByteReader import read [as 别名]
    def read(self, reader):
        size = reader.read_uint32()
        decompressed_data = zlib.decompress(reader.read(size))
        reader = ByteReader(decompressed_data)

        self.items_1 = read_list(reader, Packet4Struct1)
        self.player_hits = read_list(reader, HitPacket)

        self.items_3 = []
        for _ in xrange(reader.read_uint32()):
            self.items_3.append(reader.read(72))

        self.sound_actions = read_list(reader, SoundAction)
        self.shoot_actions = read_list(reader, ShootPacket)

        self.items_6 = []
        for _ in xrange(reader.read_uint32()):
            self.items_6.append(reader.read(88))

        self.chunk_items = read_list(reader, ChunkItems)

        self.items_8 = []
        for _ in xrange(reader.read_uint32()):
            something = reader.read_uint64()
            sub_items = []
            for _ in xrange(reader.read_uint32()):
                sub_items.append(reader.read(16))
            self.items_8.append((something, sub_items))

        self.pickups = read_list(reader, PickupAction)
        self.kill_actions = read_list(reader, KillAction)
        self.damage_actions = read_list(reader, DamageAction)

        self.items_12 = []
        for _ in xrange(reader.read_uint32()):
            self.items_12.append(reader.read(40))

        # objective/quests? not sure
        self.items_13 = read_list(reader, Item13)

        debug = True
        if debug:
            v = vars(self).copy()
            del v['pickups']
            # del v['kill_actions']
            del v['damage_actions']
            del v['sound_actions']
            del v['shoot_actions']
            # del v['player_hits']
            del v['chunk_items']
            for k, v in v.iteritems():
                if not v:
                    continue
                print k, v

        if len(decompressed_data) != reader.tell():
            raise NotImplementedError()
开发者ID:IFraserAu,项目名称:cuwo,代码行数:59,代码来源:packet.py

示例2: read

# 需要导入模块: from cuwo.bytes import ByteReader [as 别名]
# 或者: from cuwo.bytes.ByteReader import read [as 别名]
    def read(self, reader):
        size = reader.read_uint32()
        decompressed_data = zlib.decompress(reader.read(size))
        reader = ByteReader(decompressed_data)

        self.items_1 = read_list(reader, Packet4Struct1)
        self.player_hits = read_list(reader, HitPacket)
        self.particles = read_list(reader, ParticleData)
        self.sound_actions = read_list(reader, SoundAction)
        self.shoot_actions = read_list(reader, ShootPacket)
        self.static_entities = read_list(reader, StaticEntityData)
        self.chunk_items = read_list(reader, ChunkItems)

        self.items_8 = []
        for _ in xrange(reader.read_uint32()):
            something = reader.read_uint64()
            sub_items = []
            for _ in xrange(reader.read_uint32()):
                sub_items.append(reader.read(16))
            self.items_8.append((something, sub_items))

        self.pickups = read_list(reader, PickupAction)
        self.kill_actions = read_list(reader, KillAction)
        self.damage_actions = read_list(reader, DamageAction)

        self.items_12 = []
        for _ in xrange(reader.read_uint32()):
            self.items_12.append(reader.read(40))

        # objective/quests? not sure
        self.missions = read_list(reader, MissionData)

        debug = False
        if debug:
            v = vars(self).copy()
            # del v['kill_actions']
            # del v['player_hits']
            del v["pickups"]
            del v["damage_actions"]
            del v["sound_actions"]
            del v["shoot_actions"]
            del v["chunk_items"]
            for k, v in v.iteritems():
                if not v:
                    continue
                print k, v

        if len(decompressed_data) != reader.tell():
            raise NotImplementedError()
开发者ID:Jakky89,项目名称:cuwo-mitm,代码行数:51,代码来源:packet.py

示例3: convert_qmo

# 需要导入模块: from cuwo.bytes import ByteReader [as 别名]
# 或者: from cuwo.bytes.ByteReader import read [as 别名]
def convert_qmo(path):
    data = ByteReader(open(path, 'rb').read())

    qmo_file = QubicleFile()
    qmo_model = QubicleModel()
    x_size, y_size, z_size = 256, 256, 256
    qmo_model.x_size = x_size
    qmo_model.y_size = y_size
    qmo_model.z_size = z_size
    qmo_model.x_offset = -x_size / 2
    qmo_model.y_offset = 0
    qmo_model.z_offset = -z_size / 2

    min_z = None
    max_z = None

    for i in xrange(256*256):
        something = data.read_float()
        something2 = data.read_float()
        something3 = data.read_float()
        something4 = data.read_uint32()
        something5 = data.read_uint32()
        size = data.read_uint32()*4
        chunk_data = data.read(size)

        x = i % 256
        y = i / 256

        z = something4

        if min_z is None or max_z is None:
            min_z = z
            max_z = z + len(chunk_data) / 4
        else:
            min_z = min(z, min_z)
            max_z = max(max_z, len(chunk_data) / 4)

        for i in xrange(len(chunk_data) / 4):
            r = ord(chunk_data[i*4])
            g = ord(chunk_data[i*4+1])
            b = ord(chunk_data[i*4+2])
            a = ord(chunk_data[i*4+3])
            if a == 0:
                z += 1
                continue
            qmo_model.blocks[switch_axes(x, y, z)] = (r, g, b)
            z += 1

    qmo_model.y_offset

    qmo_file.models.append(qmo_model)
    writer = ByteWriter()
    qmo_file.write(writer)
    name = os.path.splitext(os.path.basename(path))[0]
    out_path = os.path.join('genqmo', name + '.qmo')
    open(out_path, 'wb').write(writer.get())

    print 'Converted', path
开发者ID:waoler,项目名称:cuwo,代码行数:60,代码来源:convertchunk.py

示例4: read

# 需要导入模块: from cuwo.bytes import ByteReader [as 别名]
# 或者: from cuwo.bytes.ByteReader import read [as 别名]
    def read(self, reader):
        size = reader.read_uint32()
        decompressed_data = zlib.decompress(reader.read(size))
        reader = ByteReader(decompressed_data)

        self.block_actions = read_list(reader, BlockAction)
        self.player_hits = read_list(reader, HitPacket)
        self.particles = read_list(reader, ParticleData)
        self.sound_actions = read_list(reader, SoundAction)
        self.shoot_actions = read_list(reader, ShootPacket)
        self.static_entities = read_list(reader, StaticEntityPacket)
        self.chunk_items = read_list(reader, ChunkItems)

        self.items_8 = []
        for _ in range(reader.read_uint32()):
            something = reader.read_uint64()
            sub_items = []
            for _ in range(reader.read_uint32()):
                sub_items.append(reader.read(16))
            self.items_8.append((something, sub_items))

        self.pickups = read_list(reader, PickupAction)
        self.kill_actions = read_list(reader, KillAction)
        self.damage_actions = read_list(reader, DamageAction)

        # EXT: used when NPC wizards/creatures use a right-click targeted
        # action such as a spell cast. (NPC rclick action?)
        self.passive_actions = read_list(reader, PassivePacket)

        self.missions = read_list(reader, MissionPacket)

        debug = False
        if debug:
            v = vars(self).copy()
            # del v['kill_actions']
            # del v['player_hits']
            del v['pickups']
            del v['damage_actions']
            del v['sound_actions']
            del v['shoot_actions']
            del v['chunk_items']
            for k, v in v.items():
                if not v:
                    continue
                print(k, v)

        if len(decompressed_data) != reader.tell():
            raise NotImplementedError()
开发者ID:matpow2,项目名称:cuwo,代码行数:50,代码来源:packet.py


注:本文中的cuwo.bytes.ByteReader.read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。