NAME

    Game::Tibia::Packet - Session layer support for the MMORPG Tibia

SYNOPSIS

        use Game::Tibia::Packet;
    
        # decrypt Tibia packet
        my $read; my $ret = $sock->recv($read, 1024);
        my $res = Game::Tibia::Packet->new($read, $xtea_key);
        $packet_type = unpack('C', $res->payload);
    
    
        # encrypt a Tibia speech packet
        my $p = Game::Tibia::Packet->new;
        $p->payload .= pack("C S S S/A S C SSC S/A", #  V Talk mode?
            0xAA, 0x1, 0x0, "Perl", 0, 1, 1, 1, 8,
            "Game::Tibia::Packet says Hi!\n:-)");
        $sock->send($p->finalize($xtea_key}))

DESCRIPTION

    Methods for constructing Tibia packets. Doesn't handle the XTEA key
    exchange yet, only what comes after it. i.e. It doesn't do that much
    besides calculating Adler32 digest and XTEA encryption.

    Tested working with Tibia 8.6, but will probably work with later
    protocol versions too.

METHODS AND ARGUMENTS

    new([$payload, $xtea])

      Constructs a new Game::Tibia::Packet instance. If payload and XTEA
      are given, the payload will be decrypted and trimmed to correct size.

    isValid($packet)

      Checks if packet's adler32 digest matches (A totally unnecessary
      thing on Cipsoft's part, as we already have TCP checksum. Why hash
      again?)

    payload() : lvalue

      returns the payload as lvalue (so you can concat on it)

    finalize([$XTEA_KEY])

      Finalizes the packet. XTEA encrypts, prepends checksum and length.

GIT REPOSITORY

    http://github.com/athreef/Game-Tibia-Packet

SEE ALSO

    http://tpforums.org/forum/forum.php http://tibia.com

AUTHOR

    Ahmad Fatoum <athreef@cpan.org>, http://a3f.at

DISCLAIMER

    Tibia is copyrighted by Cipsoft GmbH.

COPYRIGHT AND LICENSE

    Copyright (C) 2016 Ahmad Fatoum

    This library is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself.

