small bugfix

This commit is contained in:
Ryan Voots 2011-10-24 18:05:35 -04:00
parent 8bb0cd655e
commit 417c3d8539
2 changed files with 46 additions and 0 deletions

View file

@ -58,6 +58,45 @@ sub _read_handshake {
return [$hash];
}
sub _read_chat {
my $self = shift;
my $data = $self->_buf_read(2);
# Packet data:
# 0-1 int16: hash string length
my ($str_len) = unpack("n!", $data);
die "Chat: message 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 "Chat: 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];
}
sub _read_time {
my $self = shift;
my $data = $self->_buf_read(8);
# Packet data:
# 0-1 int16: hash string length
my ($str_len) = unpack("n!", $data);
die "Chat: message 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 "Chat: 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,

7
test_filter.pl Normal file
View file

@ -0,0 +1,7 @@
#!/usr/bin/perl
use lib './lib';
use strict;
use warnings;
use POE::Component::Minecraft::Client::Filter;