more packet readers in there.
This commit is contained in:
parent
a1fd8bc6cc
commit
8bb0cd655e
1 changed files with 19 additions and 0 deletions
|
@ -39,6 +39,25 @@ sub _read_login_request {
|
||||||
return [$player_ent_id, $map_seed, $mode, $dimen, $diff, $max_players];
|
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 = {
|
my $read_dispatch = {
|
||||||
0x00 => \&_read_keep_alive,
|
0x00 => \&_read_keep_alive,
|
||||||
0x01 => \&_read_login_request,
|
0x01 => \&_read_login_request,
|
||||||
|
|
Loading…
Add table
Reference in a new issue