Exemple #1
0
def TalkAscii(text, type=0, hue=0x34, font=1):
    p = PacketWriter(0x03)
    p.byte(type)
    p.ushort(hue)
    p.ushort(font)
    p.cstring(text)
    return p.finish()
Exemple #2
0
def VendorSellReply(vendor_serial, item_serial, amount=1):
    p = PacketWriter(0x9f)
    p.uint(vendor_serial)
    p.ushort(1)
    p.uint(item_serial)
    p.ushort(amount)
    return p.finish()
Exemple #3
0
    def data_received(self, data: bytes):
        """Called when some data is received.

        :param data: is  a bytes object.
        """
        self.log.debug("Received {} bytes".format(len(data)))

        if self._packets_compression:
            # TODO Compression is not working at the moment
            original_data = data[:]
            compressed_data = data[:]
            uncompressed_data = self._compression.decompress(compressed_data)
            self._input += uncompressed_data
            new_compressed_data = self._compression.compress(uncompressed_data)

            self.log.debug("Uncompressed data is {} bytes".format(len(data)))

        else:
            self._input += data

        while True and not self._packets_compression:
            packet: PacketReader = self._packet_from_buffer()

            if packet is None:
                break

            if packet.cmd in self.auto_answer:
                self.log.debug('Auto answering packet {:#4x}'.format(packet.cmd))
                # answer = self.auto_answer[cmd](data=data)

            if packet.cmd in self.rewriters:
                self.log.debug('Rewriting packet {:#4x}'.format(packet.cmd))
                rewriter = self.rewriters[packet.cmd](packet=packet)
                packet_data = rewriter.to_data()
            else:
                new_packet = PacketWriter(packet.cmd, self.packet_table[packet.cmd])
                new_packet.data(packet.raw_data)
                packet_data = new_packet.finish()

            self.log.debug('UOClient data_received: packet {:#4X} len {}'.format(packet.cmd, len(packet_data)))

            # when we connect to the relay we turn decompression on
            if packet.cmd == 0x8C:
                self.loop.client_decompress = True

            # forward data to the client
            if not self._packets_compression:
                try:
                    self.server.transport.write(packet_data)
                    self.log.debug('UOClient serv transport write: packet {:#4X}'.format(packet.cmd))
                except Exception as e:
                    print("EXC {}".format(e))

        if self._packets_compression:
            try:
                self.server.transport.write(original_data)
                self.log.debug('UOClient serv transport write: compressed data')
            except Exception as e:
                print("EXC {}".format(e))
Exemple #4
0
def MenuResponse(serial, index):
    p = PacketWriter(0x7d)
    p.uint(serial)
    p.ushort(0) # menu id
    p.ushort(index)
    p.ushort(0) # item id
    p.ushort(0) # hue
    return p.finish()
Exemple #5
0
def Drop(serial, x, y, z, dest_serial):
    p = PacketWriter(0x08)
    p.uint(serial)
    p.ushort(x)
    p.ushort(y)
    p.sbyte(z)
    p.uint(dest_serial)
    return p.finish()
Exemple #6
0
def VendorBuyReply(vendor_serial, item_serial, amount=1):
    p = PacketWriter(0x3b)
    p.uint(vendor_serial)
    p.byte(2) # flags
    p.byte(0) # layer
    p.uint(item_serial)
    p.ushort(amount)
    return p.finish()
Exemple #7
0
def WarMode(warmode):
    p = PacketWriter(0x72)
    p.boolean(warmode)
    p.byte(0)
    p.byte(0)
    p.byte(0)
    return p.finish()
Exemple #8
0
    def to_data(self):
        packet = PacketWriter(0x8C, self.packet_length)
        packet.ipv4(self.relay.ip)
        packet.ushort(self.relay.port)
        packet.uint(self.relay.auth_id)

        return packet.finish()
Exemple #9
0
def WarMode(warmode):
    p = PacketWriter(0x72)
    p.boolean(warmode)
    p.byte(0)
    p.byte(0)
    p.byte(0)
    return p.finish()
Exemple #10
0
    def __init__(self, data: bytes, transport: asyncio.WriteTransport, packet_length: int):
        self.data: bytes = data[:]
        self.p: uo.packets.UOPacket = uo.packets.UOPacket(self.data, packet_length)
        self.packet_length = packet_length
        self.razor_features = uo.packets.RazorFeatures(self.p.from_buffer())

        if self.razor_features.features == 0xFE:
            packet = PacketWriter(0xF0, packet_length)
            packet.ushort(0x0004)
            packet.byte(0xFF)
            transport.write(packet.finish())
Exemple #11
0
def MobileQuery(type, serial):
    p = PacketWriter(0x34)
    p.uint(0xedededed)
    p.byte(type)
    p.uint(serial)
    return p.finish()
Exemple #12
0
def EquipRequest(item_serial, layer, target_serial):
    p = PacketWriter(0x13)
    p.uint(item_serial)
    p.byte(layer)
    p.uint(target_serial)
    return p.finish()
Exemple #13
0
def Click(serial):
    p = PacketWriter(0x09)
    p.uint(serial)
    return p.finish()
Exemple #14
0
def LiftRequest(serial, amount=0xffff):
    p = PacketWriter(0x07)
    p.uint(serial)
    p.ushort(amount)
    return p.finish()
Exemple #15
0
def CheckSecureTrade(serial):
    p = PacketWriter(0x6f)
    p.byte(0x02)
    p.uint(serial)
    p.uint(1)
    return p.finish()
Exemple #16
0
def RazorHandshakeResponse():
    p = PacketWriter(0xf0)
    p.byte(0xff)
    return p.finish()
Exemple #17
0
def TargetResponse(type, target_id, flags, serial, x, y, z, graphic):
    p = PacketWriter(0x6c)
    p.byte(type)
    p.uint(target_id)
    p.byte(flags)
    p.uint(serial)
    p.ushort(x)
    p.ushort(y)
    p.sshort(z)
    p.ushort(graphic)
    return p.finish()
Exemple #18
0
def CancelSecureTrade(serial):
    p = PacketWriter(0x6f)
    p.byte(0x01)
    p.uint(serial)
    return p.finish()
Exemple #19
0
def VendorBuyReply(vendor_serial, item_serial, amount=1):
    p = PacketWriter(0x3b)
    p.uint(vendor_serial)
    p.byte(2)  # flags
    p.byte(0)  # layer
    p.uint(item_serial)
    p.ushort(amount)
    return p.finish()
Exemple #20
0
def PlayCharacter(slot):
    p = PacketWriter(0x5d)
    p.uint(0)
    p.fixstring("", 30)
    p.ushort(0)
    p.uint(0)
    p.fixstring("", 24)
    p.uint(slot)
    p.uint(0xdeadbeef)
    return p.finish()
Exemple #21
0
def SkillLock(skill, lock):
    p = PacketWriter(0x3a)
    p.ushort(skill)
    p.byte(lock)
    return p.finish()
Exemple #22
0
def MobileQuery(type, serial):
    p = PacketWriter(0x34)
    p.uint(0xedededed)
    p.byte(type)
    p.uint(serial)
    return p.finish()
Exemple #23
0
def Resync():
    p = PacketWriter(0x22)
    p.byte(0)
    p.byte(0)
    return p.finish()
Exemple #24
0
def Use(serial):
    p = PacketWriter(0x06)
    p.uint(serial)
    return p.finish()
Exemple #25
0
def CheckSecureTrade(serial):
    p = PacketWriter(0x6f)
    p.byte(0x02)
    p.uint(serial)
    p.uint(1)
    return p.finish()
Exemple #26
0
def TargetResponse(type, target_id, flags, serial, x, y, z, graphic):
    p = PacketWriter(0x6c)
    p.byte(type)
    p.uint(target_id)
    p.byte(flags)
    p.uint(serial)
    p.ushort(x)
    p.ushort(y)
    p.sshort(z)
    p.ushort(graphic)
    return p.finish()
Exemple #27
0
def Click(serial):
    p = PacketWriter(0x09)
    p.uint(serial)
    return p.finish()
Exemple #28
0
def EquipRequest(item_serial, layer, target_serial):
    p = PacketWriter(0x13)
    p.uint(item_serial)
    p.byte(layer)
    p.uint(target_serial)
    return p.finish()
Exemple #29
0
def MenuResponse(serial, index):
    p = PacketWriter(0x7d)
    p.uint(serial)
    p.ushort(0)  # menu id
    p.ushort(index)
    p.ushort(0)  # item id
    p.ushort(0)  # hue
    return p.finish()
Exemple #30
0
def WalkRequest(direction, seq):
    p = PacketWriter(0x02)
    p.byte(direction)
    p.byte(seq)
    p.uint(0)
    return p.finish()
Exemple #31
0
def AccountLogin(username, password):
    p = PacketWriter(0x80)
    p.fixstring(username, 30)
    p.fixstring(password, 30)
    p.byte(0)
    return p.finish()
Exemple #32
0
def Use(serial):
    p = PacketWriter(0x06)
    p.uint(serial)
    return p.finish()
Exemple #33
0
def GameLogin(username, password, auth_id):
    p = PacketWriter(0x91)
    p.uint(auth_id)
    p.fixstring(username, 30)
    p.fixstring(password, 30)
    return p.finish()
Exemple #34
0
def LiftRequest(serial, amount=0xffff):
    p = PacketWriter(0x07)
    p.uint(serial)
    p.ushort(amount)
    return p.finish()
Exemple #35
0
def VendorSellReply(vendor_serial, item_serial, amount=1):
    p = PacketWriter(0x9f)
    p.uint(vendor_serial)
    p.ushort(1)
    p.uint(item_serial)
    p.ushort(amount)
    return p.finish()
Exemple #36
0
def TextCommand(type, command):
    p = PacketWriter(0x12)
    p.byte(type)
    p.cstring(command)
    return p.finish()
Exemple #37
0
def PlayServer(index):
    p = PacketWriter(0xa0)
    p.ushort(index)
    return p.finish()
Exemple #38
0
def Resync():
    p = PacketWriter(0x22)
    p.byte(0)
    p.byte(0)
    return p.finish()
Exemple #39
0
def Drop(serial, x, y, z, dest_serial):
    p = PacketWriter(0x08)
    p.uint(serial)
    p.ushort(x)
    p.ushort(y)
    p.sbyte(z)
    p.uint(dest_serial)
    return p.finish()
Exemple #40
0
def SkillLock(skill, lock):
    p = PacketWriter(0x3a)
    p.ushort(skill)
    p.byte(lock)
    return p.finish()
Exemple #41
0
def GameLogin(username, password, auth_id):
    p = PacketWriter(0x91)
    p.uint(auth_id)
    p.fixstring(username, 30)
    p.fixstring(password, 30)
    return p.finish()
Exemple #42
0
def PlayCharacter(slot):
    p = PacketWriter(0x5d)
    p.uint(0)
    p.fixstring("", 30)
    p.ushort(0)
    p.uint(0)
    p.fixstring("", 24)
    p.uint(slot)
    p.uint(0xdeadbeef)
    return p.finish()
Exemple #43
0
def TalkAscii(text, type=0, hue=0x34, font=1):
    p = PacketWriter(0x03)
    p.byte(type)
    p.ushort(hue)
    p.ushort(font)
    p.cstring(text)
    return p.finish()
Exemple #44
0
def CancelSecureTrade(serial):
    p = PacketWriter(0x6f)
    p.byte(0x01)
    p.uint(serial)
    return p.finish()
Exemple #45
0
def StatLock(stat, lock):
    p = PacketWriter(0xbf)
    p.ushort(0x001a)
    p.byte(stat)
    p.byte(lock)
    return p.finish()
Exemple #46
0
def PlayServer(index):
    p = PacketWriter(0xa0)
    p.ushort(index)
    return p.finish()
Exemple #47
0
def TextCommand(type, command):
    p = PacketWriter(0x12)
    p.byte(type)
    p.cstring(command)
    return p.finish()
Exemple #48
0
def AccountLogin(username, password):
    p = PacketWriter(0x80)
    p.fixstring(username, 30)
    p.fixstring(password, 30)
    p.byte(0)
    return p.finish()
Exemple #49
0
def ClientVersion(version):
    p = PacketWriter(0xbd)
    p.ucstring(version)
    return p.finish()
Exemple #50
0
def TalkUnicode(text, keyword=None, type=0, hue=0x34, font=1):
    assert (type & 0xc0) == 0

    if keyword is not None:
        type |= 0xc0

    p = PacketWriter(0xad)
    p.byte(type)
    p.ushort(hue)
    p.ushort(font)
    p.fixstring('Eng', 4)

    if keyword is not None:
        p.byte(0x00)
        p.byte(0x10 | (keyword >> 8))
        p.byte(keyword)

    p.ucstring(text)
    return p.finish()
Exemple #51
0
def WalkRequest(direction, seq):
    p = PacketWriter(0x02)
    p.byte(direction)
    p.byte(seq)
    p.uint(0)
    return p.finish()
Exemple #52
0
def TalkUnicode(text, keyword, type=0xc0, hue=0x34, font=1):
    p = PacketWriter(0xad)
    p.byte(type)
    p.ushort(hue)
    p.ushort(font)
    p.fixstring('Eng', 4)
    p.byte(0x00)
    p.byte(0x10)
    p.byte(keyword)
    p.cstring(text)
    return p.finish()
Exemple #53
0
def GumpResponse(serial, gump_id, button_id=1, switches=[]):
    p = PacketWriter(0xb1)
    p.uint(serial)
    p.uint(gump_id)
    p.uint(button_id)
    p.uint(len(switches))
    for x in switches:
        p.uint(x)
    p.uint(0)  # number of text responses
    return p.finish()
Exemple #54
0
def StatLock(stat, lock):
    p = PacketWriter(0xbf)
    p.ushort(0x001a)
    p.byte(stat)
    p.byte(lock)
    return p.finish()
Exemple #55
0
def ClientVersion(version):
    p = PacketWriter(0xbd)
    p.cstring(version)
    return p.finish()