Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- woe_linker/src/Network/Receive/ServerType0.pm 2012-12-22 15:55:36.000000000 -0600
- +++ ServerType0.pm 2012-12-25 02:39:14.000000000 -0600
- @@ -507,6 +507,12 @@
- '08C7' => ['area_spell', 'x2 a4 a4 v2 C3', [qw(ID sourceID x y type range fail)]], # -1
- '08C8' => ['actor_action', 'a4 a4 a4 V3 x v C V', [qw(sourceID targetID tick src_speed dst_speed damage div type dual_wield_damage)]],
- '08CB' => ['rates_info', 's4 a*', [qw(len exp death drop detail)]],
- + '0900' => ['inventory_items_stackable', 'x2 a*', [qw(itemInfo)]],
- + '0901' => ['inventory_items_nonstackable', 'x2 a*', [qw(itemInfo)]],
- + '0902' => ['cart_items_stackable'],
- + '0903' => ['cart_items_nonstackable'],
- + '0975' => ['storage_items_stackable', 'a26 a*', [qw(unknown1 itemInfo)]],
- + '0976' => ['storage_items_nonstackable', 'a26 a*', [qw(unknown1 itemInfo)]],
- };
- # Item RECORD Struct's
- @@ -532,6 +538,11 @@
- types => 'v2 C2 v2 C2 a8 l v2',
- keys => [qw(index nameID type identified type_equip equipped broken upgrade cards expire bindOnEquipType sprite_id)],
- },
- + type5 => {
- + len => 27,
- + types => 'v2 C v2 C a8 l v2 C',
- + keys => [qw(index nameID type type_equip equipped upgrade cards expire bindOnEquipType sprite_id identified)],
- + },
- },
- items_stackable => {
- type1 => {
- @@ -549,6 +560,11 @@
- types => 'v2 C2 v2 a8 l',
- keys => [qw(index nameID type identified amount type_equip cards expire)],
- },
- + type5 => {
- + len => 22,
- + types => 'v2 C v2 a8 l C',
- + keys => [qw(index nameID type amount type_equip cards expire identified)],
- + },
- },
- };
- @@ -847,6 +863,11 @@
- $args->{switch} eq '02D2' # cart
- ) {
- return $items->{$rpackets{'00AA'} == 7 ? 'type3' : 'type4'};
- + } elsif ($args->{switch} eq '0901' || # inventory
- + $args->{switch} eq '0976' || # storage
- + $args->{switch} eq '0903' # cart
- + ) {
- + return $items->{type5};
- } else {
- warning "items_nonstackable: unsupported packet ($args->{switch})!\n";
- }
- @@ -875,11 +896,57 @@
- $args->{switch} eq '02E9' # cart
- ) {
- return $items->{type3};
- +
- + } elsif ($args->{switch} eq '0900' || # inventory
- + $args->{switch} eq '0975' || # storage
- + $args->{switch} eq '0902' # cart
- + ) {
- + return $items->{type5};
- +
- } else {
- warning "items_stackable: unsupported packet ($args->{switch})!\n";
- }
- }
- +sub parse_items_nonstackable {
- + my ($self, $args, $info) = @_;
- + my @itemKeys;
- +
- + my $unpack = $self->items_nonstackable($args);
- + my $length = length $info;
- + for (my $i = 0; $i < $length; $i += $unpack->{len}) {
- + my $item;
- + @{$item}{@{$unpack->{keys}}} = unpack($unpack->{types}, substr($info, $i, $unpack->{len}));
- +
- + $item->{placeEtcTab} = $item->{identified} & (1 << 2);
- + $item->{broken} = $item->{identified} & (1 << 1) unless exists $item->{broken};
- + $item->{idenfitied} = $item->{identified} & (1 << 0);
- +
- + push @itemKeys, $item;
- + }
- +
- + @itemKeys
- +}
- +
- +sub parse_items_stackable {
- + my ($self, $args, $info) = @_;
- + my @itemKeys;
- +
- + my $unpack = $self->items_stackable($args);
- + my $length = length $info;
- + for (my $i = 0; $i < $length; $i += $unpack->{len}) {
- + my $item;
- + @{$item}{@{$unpack->{keys}}} = unpack($unpack->{types}, substr($info, $i, $unpack->{len}));
- +
- + $item->{placeEtcTab} = $item->{identified} & (1 << 1);
- + $item->{idenfitied} = $item->{identified} & (1 << 0);
- +
- + push @itemKeys, $item;
- + }
- +
- + @itemKeys
- +}
- +
- #######################################
- ###### Packet handling callbacks ######
- #######################################
- @@ -1266,7 +1333,7 @@
- }
- $local_item->{name} = itemName($local_item);
- - debug "Stackable Cart Item: $local_item->{name} ($local_item->{index}) x $local_item->{amount}\n", "parseMsg";
- + debug "Stackable Cart Item: switch = $args->{switch}, $local_item->{name} ($local_item->{index}) x $local_item->{amount}\n", "parseMsg";
- Plugins::callHook('packet_cart', {index => $local_item->{index}});
- }
- @@ -2846,19 +2913,17 @@
- $self->decrypt(\$newmsg, substr($args->{RAW_MSG}, 4));
- my $msg = substr($args->{RAW_MSG}, 0, 4) . $newmsg;
- - my $unpack = $self->items_nonstackable($args);
- + my @itemKeys = $self->parse_items_nonstackable($args, substr $msg, 4);
- - for (my $i = 4; $i < $args->{RAW_MSG_SIZE}; $i += $unpack->{len}) {
- - my ($item, $local_item, $add);
- -
- - @{$item}{@{$unpack->{keys}}} = unpack($unpack->{types}, substr($msg, $i, $unpack->{len}));
- + for my $item (@itemKeys) {
- + my ($local_item, $add);
- unless($local_item = $char->inventory->getByServerIndex($item->{index})) {
- $local_item = new Actor::Item();
- $add = 1;
- }
- - foreach (@{$unpack->{keys}}) {
- + for (keys %$item) {
- $local_item->{$_} = $item->{$_};
- }
- $local_item->{name} = itemName($local_item);
- @@ -2891,19 +2956,17 @@
- $self->decrypt(\$newmsg, substr($args->{RAW_MSG}, 4));
- my $msg = substr($args->{RAW_MSG}, 0, 4).$newmsg;
- - my $unpack = $self->items_stackable($args);
- + my @itemKeys = $self->parse_items_stackable($args, substr $msg, 4);
- - for (my $i = 4; $i < $args->{RAW_MSG_SIZE}; $i += $unpack->{len}) {
- - my ($item, $local_item, $add);
- -
- - @{$item}{@{$unpack->{keys}}} = unpack($unpack->{types}, substr($msg, $i, $unpack->{len}));
- + for my $item (@itemKeys) {
- + my ($local_item, $add);
- unless($local_item = $char->inventory->getByServerIndex($item->{index})) {
- $local_item = new Actor::Item();
- $add = 1;
- }
- - foreach (@{$unpack->{keys}}) {
- + for (keys %$item) {
- $local_item->{$_} = $item->{$_};
- }
- @@ -5650,62 +5713,59 @@
- }
- sub storage_items_nonstackable {
- - my ($self, $args) = @_;
- + my ($self, $args) = @_;
- - my $newmsg;
- - $self->decrypt(\$newmsg, substr($args->{RAW_MSG}, 4));
- - my $msg = substr($args->{RAW_MSG}, 0, 4).$newmsg;
- + my $newmsg;
- + $self->decrypt(\$newmsg, substr($args->{RAW_MSG}, 4));
- + my $msg = substr($args->{RAW_MSG}, 0, 4).$newmsg;
- - my $unpack = $self->items_nonstackable($args);
- + my @itemKeys = $self->parse_items_nonstackable($args, $args->{itemInfo});
- - for (my $i = 4; $i < $args->{RAW_MSG_SIZE}; $i += $unpack->{len}) {
- - my ($item, $local_item);
- -
- - @{$item}{@{$unpack->{keys}}} = unpack($unpack->{types}, substr($msg, $i, $unpack->{len}));
- + for my $item (@itemKeys) {
- + my ($local_item, $add);
- - binAdd(\@storageID, $item->{index});
- - $local_item = $storage{$item->{index}} = Actor::Item->new;
- + binAdd(\@storageID, $item->{index});
- + $local_item = $storage{$item->{index}} = Actor::Item->new;
- - foreach (@{$unpack->{keys}}) {
- - $local_item->{$_} = $item->{$_};
- - }
- - $local_item->{name} = itemName($local_item);
- - $local_item->{amount} = 1;
- - $local_item->{binID} = binFind(\@storageID, $item->{index});
- + for (keys %$item) {
- + $local_item->{$_} = $item->{$_};
- + }
- + $local_item->{name} = itemName($local_item);
- + $local_item->{amount} = 1;
- + $local_item->{binID} = binFind(\@storageID, $item->{index});
- - debug "Storage: $local_item->{name} ($local_item->{binID})\n", "parseMsg";
- - }
- + debug "Storage: $local_item->{name} ($local_item->{binID})\n", "parseMsg";
- + }
- }
- sub storage_items_stackable {
- - my ($self, $args) = @_;
- + my ($self, $args) = @_;
- - my $newmsg;
- - $self->decrypt(\$newmsg, substr($args->{RAW_MSG}, 4));
- - my $msg = substr($args->{RAW_MSG}, 0, 4).$newmsg;
- + my $newmsg;
- + $self->decrypt(\$newmsg, substr($args->{RAW_MSG}, 4));
- + my $msg = substr($args->{RAW_MSG}, 0, 4).$newmsg;
- - undef %storage;
- - undef @storageID;
- + undef %storage;
- + undef @storageID;
- - my $unpack = $self->items_stackable($args);
- + my @itemKeys = $self->parse_items_stackable($args, $args->{itemInfo});
- - for (my $i = 4; $i < $args->{RAW_MSG_SIZE}; $i += $unpack->{len}) {
- - my ($item, $local_item);
- + for my $item (@itemKeys) {
- + my ($local_item, $add);
- - @{$item}{@{$unpack->{keys}}} = unpack($unpack->{types}, substr($msg, $i, $unpack->{len}));
- + binAdd(\@storageID, $item->{index});
- + $local_item = $storage{$item->{index}} = Actor::Item->new;
- - binAdd(\@storageID, $item->{index});
- - $local_item = $storage{$item->{index}} = Actor::Item->new;
- + for (keys %$item) {
- + $local_item->{$_} = $item->{$_};
- + }
- + $local_item->{amount} = $local_item->{amount} & ~0x80000000;
- + $local_item->{name} = itemName($local_item);
- + $local_item->{binID} = binFind(\@storageID, $local_item->{index});
- + $local_item->{identified} = 1;
- - foreach (@{$unpack->{keys}}) {
- - $local_item->{$_} = $item->{$_};
- - }
- - $local_item->{amount} = $local_item->{amount} & ~0x80000000;
- - $local_item->{name} = itemName($local_item);
- - $local_item->{binID} = binFind(\@storageID, $local_item->{index});
- - $local_item->{identified} = 1;
- - debug "Storage: $local_item->{name} ($local_item->{binID}) x $local_item->{amount}\n", "parseMsg";
- - }
- + debug "Storage: $local_item->{name} ($local_item->{binID}) x $local_item->{amount}\n", "parseMsg";
- + }
- }
- sub storage_opened {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement