… | |
… | |
544 | |
544 | |
545 | while (@values) { |
545 | while (@values) { |
546 | my ($tag, $flags, $weight, $face, $names, $anim, $animspeed, $nrof, $type) = |
546 | my ($tag, $flags, $weight, $face, $names, $anim, $animspeed, $nrof, $type) = |
547 | splice @values, 0, 9, (); |
547 | splice @values, 0, 9, (); |
548 | |
548 | |
|
|
549 | $weight = unpack "l", pack "L", $weight; # weight can be -1 |
|
|
550 | |
549 | utf8::decode $names if utf8::valid $names; |
551 | utf8::decode $names if utf8::valid $names; |
550 | my ($name, $name_pl) = split /\x00/, $names; |
552 | my ($name, $name_pl) = split /\x00/, $names; |
551 | |
553 | |
552 | my $item = { |
554 | my $item = { |
553 | container => $location, |
555 | container => $location, |
… | |
… | |
597 | |
599 | |
598 | push @{ $self->{container}{$item->{container}} }, $item; |
600 | push @{ $self->{container}{$item->{container}} }, $item; |
599 | $self->container_add ($item->{location}, $item); |
601 | $self->container_add ($item->{location}, $item); |
600 | } |
602 | } |
601 | |
603 | |
602 | $item->{flags} = unpack "N", substr $data, 0, 4, "" if $flags & UPD_FLAGS; |
604 | $item->{flags} = unpack "N", substr $data, 0, 4, "" if $flags & UPD_FLAGS; |
603 | $item->{weight} = unpack "N", substr $data, 0, 4, "" if $flags & UPD_WEIGHT; |
605 | $item->{weight} = unpack "l", pack "L", unpack "N", substr $data, 0, 4, "" if $flags & UPD_WEIGHT; |
604 | $item->{face} = unpack "N", substr $data, 0, 4, "" if $flags & UPD_FACE; |
606 | $item->{face} = unpack "N", substr $data, 0, 4, "" if $flags & UPD_FACE; |
605 | |
607 | |
606 | if ($flags & UPD_NAME) { |
608 | if ($flags & UPD_NAME) { |
607 | my $len = unpack "C", substr $data, 0, 1, ""; |
609 | my $len = unpack "C", substr $data, 0, 1, ""; |
608 | |
610 | |
609 | my $names = substr $data, 0, $len, ""; |
611 | my $names = substr $data, 0, $len, ""; |