From 8bb0cd655e2cc7940d700d77b345548e3b87970c Mon Sep 17 00:00:00 2001 From: Ryan Voots Date: Sun, 23 Oct 2011 21:49:48 -0400 Subject: [PATCH] more packet readers in there. --- lib/POE/Component/Minecraft/Client/Filter.pm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/POE/Component/Minecraft/Client/Filter.pm b/lib/POE/Component/Minecraft/Client/Filter.pm index 14ed407..41f1c86 100644 --- a/lib/POE/Component/Minecraft/Client/Filter.pm +++ b/lib/POE/Component/Minecraft/Client/Filter.pm @@ -39,6 +39,25 @@ sub _read_login_request { return [$player_ent_id, $map_seed, $mode, $dimen, $diff, $max_players]; } +sub _read_handshake { + my $self = shift; + my $data = $self->_buf_read(2); + # Packet data: + # 0-1 int16: hash string length + + my ($str_len) = unpack("n!", $data); + die "Handshake: hash was negative length: ". $str_len if ($str_len < 0); # this could also be an unsigned, but i'm not entirely sure on it + + #I don't know if this is in characters or in bytes... + + # assume it's bytes + my $hash = $self->_buf_read($str_len); + warn "Handshake: buffer left is: ".$self->_buf_size()." read: ".$str_len+2; + + warn "Didn't convert from UCS-2!"; # This must be fixed! I need to decode it here, but i'm not. I'don't know when this will be used so this should be fine for now. + return [$hash]; +} + my $read_dispatch = { 0x00 => \&_read_keep_alive, 0x01 => \&_read_login_request,