Advertisement
Guest User

Untitled

a guest
Dec 25th, 2012
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.35 KB | None | 0 0
  1. --- woe_linker/src/Network/Receive/ServerType0.pm 2012-12-22 15:55:36.000000000 -0600
  2. +++ ServerType0.pm 2012-12-25 02:39:14.000000000 -0600
  3. @@ -507,6 +507,12 @@
  4. '08C7' => ['area_spell', 'x2 a4 a4 v2 C3', [qw(ID sourceID x y type range fail)]], # -1
  5. '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)]],
  6. '08CB' => ['rates_info', 's4 a*', [qw(len exp death drop detail)]],
  7. + '0900' => ['inventory_items_stackable', 'x2 a*', [qw(itemInfo)]],
  8. + '0901' => ['inventory_items_nonstackable', 'x2 a*', [qw(itemInfo)]],
  9. + '0902' => ['cart_items_stackable'],
  10. + '0903' => ['cart_items_nonstackable'],
  11. + '0975' => ['storage_items_stackable', 'a26 a*', [qw(unknown1 itemInfo)]],
  12. + '0976' => ['storage_items_nonstackable', 'a26 a*', [qw(unknown1 itemInfo)]],
  13. };
  14.  
  15. # Item RECORD Struct's
  16. @@ -532,6 +538,11 @@
  17. types => 'v2 C2 v2 C2 a8 l v2',
  18. keys => [qw(index nameID type identified type_equip equipped broken upgrade cards expire bindOnEquipType sprite_id)],
  19. },
  20. + type5 => {
  21. + len => 27,
  22. + types => 'v2 C v2 C a8 l v2 C',
  23. + keys => [qw(index nameID type type_equip equipped upgrade cards expire bindOnEquipType sprite_id identified)],
  24. + },
  25. },
  26. items_stackable => {
  27. type1 => {
  28. @@ -549,6 +560,11 @@
  29. types => 'v2 C2 v2 a8 l',
  30. keys => [qw(index nameID type identified amount type_equip cards expire)],
  31. },
  32. + type5 => {
  33. + len => 22,
  34. + types => 'v2 C v2 a8 l C',
  35. + keys => [qw(index nameID type amount type_equip cards expire identified)],
  36. + },
  37. },
  38. };
  39.  
  40. @@ -847,6 +863,11 @@
  41. $args->{switch} eq '02D2' # cart
  42. ) {
  43. return $items->{$rpackets{'00AA'} == 7 ? 'type3' : 'type4'};
  44. + } elsif ($args->{switch} eq '0901' || # inventory
  45. + $args->{switch} eq '0976' || # storage
  46. + $args->{switch} eq '0903' # cart
  47. + ) {
  48. + return $items->{type5};
  49. } else {
  50. warning "items_nonstackable: unsupported packet ($args->{switch})!\n";
  51. }
  52. @@ -875,11 +896,57 @@
  53. $args->{switch} eq '02E9' # cart
  54. ) {
  55. return $items->{type3};
  56. +
  57. + } elsif ($args->{switch} eq '0900' || # inventory
  58. + $args->{switch} eq '0975' || # storage
  59. + $args->{switch} eq '0902' # cart
  60. + ) {
  61. + return $items->{type5};
  62. +
  63. } else {
  64. warning "items_stackable: unsupported packet ($args->{switch})!\n";
  65. }
  66. }
  67.  
  68. +sub parse_items_nonstackable {
  69. + my ($self, $args, $info) = @_;
  70. + my @itemKeys;
  71. +
  72. + my $unpack = $self->items_nonstackable($args);
  73. + my $length = length $info;
  74. + for (my $i = 0; $i < $length; $i += $unpack->{len}) {
  75. + my $item;
  76. + @{$item}{@{$unpack->{keys}}} = unpack($unpack->{types}, substr($info, $i, $unpack->{len}));
  77. +
  78. + $item->{placeEtcTab} = $item->{identified} & (1 << 2);
  79. + $item->{broken} = $item->{identified} & (1 << 1) unless exists $item->{broken};
  80. + $item->{idenfitied} = $item->{identified} & (1 << 0);
  81. +
  82. + push @itemKeys, $item;
  83. + }
  84. +
  85. + @itemKeys
  86. +}
  87. +
  88. +sub parse_items_stackable {
  89. + my ($self, $args, $info) = @_;
  90. + my @itemKeys;
  91. +
  92. + my $unpack = $self->items_stackable($args);
  93. + my $length = length $info;
  94. + for (my $i = 0; $i < $length; $i += $unpack->{len}) {
  95. + my $item;
  96. + @{$item}{@{$unpack->{keys}}} = unpack($unpack->{types}, substr($info, $i, $unpack->{len}));
  97. +
  98. + $item->{placeEtcTab} = $item->{identified} & (1 << 1);
  99. + $item->{idenfitied} = $item->{identified} & (1 << 0);
  100. +
  101. + push @itemKeys, $item;
  102. + }
  103. +
  104. + @itemKeys
  105. +}
  106. +
  107. #######################################
  108. ###### Packet handling callbacks ######
  109. #######################################
  110. @@ -1266,7 +1333,7 @@
  111. }
  112. $local_item->{name} = itemName($local_item);
  113.  
  114. - debug "Stackable Cart Item: $local_item->{name} ($local_item->{index}) x $local_item->{amount}\n", "parseMsg";
  115. + debug "Stackable Cart Item: switch = $args->{switch}, $local_item->{name} ($local_item->{index}) x $local_item->{amount}\n", "parseMsg";
  116. Plugins::callHook('packet_cart', {index => $local_item->{index}});
  117. }
  118.  
  119. @@ -2846,19 +2913,17 @@
  120. $self->decrypt(\$newmsg, substr($args->{RAW_MSG}, 4));
  121. my $msg = substr($args->{RAW_MSG}, 0, 4) . $newmsg;
  122.  
  123. - my $unpack = $self->items_nonstackable($args);
  124. + my @itemKeys = $self->parse_items_nonstackable($args, substr $msg, 4);
  125.  
  126. - for (my $i = 4; $i < $args->{RAW_MSG_SIZE}; $i += $unpack->{len}) {
  127. - my ($item, $local_item, $add);
  128. -
  129. - @{$item}{@{$unpack->{keys}}} = unpack($unpack->{types}, substr($msg, $i, $unpack->{len}));
  130. + for my $item (@itemKeys) {
  131. + my ($local_item, $add);
  132.  
  133. unless($local_item = $char->inventory->getByServerIndex($item->{index})) {
  134. $local_item = new Actor::Item();
  135. $add = 1;
  136. }
  137.  
  138. - foreach (@{$unpack->{keys}}) {
  139. + for (keys %$item) {
  140. $local_item->{$_} = $item->{$_};
  141. }
  142. $local_item->{name} = itemName($local_item);
  143. @@ -2891,19 +2956,17 @@
  144. $self->decrypt(\$newmsg, substr($args->{RAW_MSG}, 4));
  145. my $msg = substr($args->{RAW_MSG}, 0, 4).$newmsg;
  146.  
  147. - my $unpack = $self->items_stackable($args);
  148. + my @itemKeys = $self->parse_items_stackable($args, substr $msg, 4);
  149.  
  150. - for (my $i = 4; $i < $args->{RAW_MSG_SIZE}; $i += $unpack->{len}) {
  151. - my ($item, $local_item, $add);
  152. -
  153. - @{$item}{@{$unpack->{keys}}} = unpack($unpack->{types}, substr($msg, $i, $unpack->{len}));
  154. + for my $item (@itemKeys) {
  155. + my ($local_item, $add);
  156.  
  157. unless($local_item = $char->inventory->getByServerIndex($item->{index})) {
  158. $local_item = new Actor::Item();
  159. $add = 1;
  160. }
  161.  
  162. - foreach (@{$unpack->{keys}}) {
  163. + for (keys %$item) {
  164. $local_item->{$_} = $item->{$_};
  165. }
  166.  
  167. @@ -5650,62 +5713,59 @@
  168. }
  169.  
  170. sub storage_items_nonstackable {
  171. - my ($self, $args) = @_;
  172. + my ($self, $args) = @_;
  173.  
  174. - my $newmsg;
  175. - $self->decrypt(\$newmsg, substr($args->{RAW_MSG}, 4));
  176. - my $msg = substr($args->{RAW_MSG}, 0, 4).$newmsg;
  177. + my $newmsg;
  178. + $self->decrypt(\$newmsg, substr($args->{RAW_MSG}, 4));
  179. + my $msg = substr($args->{RAW_MSG}, 0, 4).$newmsg;
  180.  
  181. - my $unpack = $self->items_nonstackable($args);
  182. + my @itemKeys = $self->parse_items_nonstackable($args, $args->{itemInfo});
  183.  
  184. - for (my $i = 4; $i < $args->{RAW_MSG_SIZE}; $i += $unpack->{len}) {
  185. - my ($item, $local_item);
  186. -
  187. - @{$item}{@{$unpack->{keys}}} = unpack($unpack->{types}, substr($msg, $i, $unpack->{len}));
  188. + for my $item (@itemKeys) {
  189. + my ($local_item, $add);
  190.  
  191. - binAdd(\@storageID, $item->{index});
  192. - $local_item = $storage{$item->{index}} = Actor::Item->new;
  193. + binAdd(\@storageID, $item->{index});
  194. + $local_item = $storage{$item->{index}} = Actor::Item->new;
  195.  
  196. - foreach (@{$unpack->{keys}}) {
  197. - $local_item->{$_} = $item->{$_};
  198. - }
  199. - $local_item->{name} = itemName($local_item);
  200. - $local_item->{amount} = 1;
  201. - $local_item->{binID} = binFind(\@storageID, $item->{index});
  202. + for (keys %$item) {
  203. + $local_item->{$_} = $item->{$_};
  204. + }
  205. + $local_item->{name} = itemName($local_item);
  206. + $local_item->{amount} = 1;
  207. + $local_item->{binID} = binFind(\@storageID, $item->{index});
  208.  
  209. - debug "Storage: $local_item->{name} ($local_item->{binID})\n", "parseMsg";
  210. - }
  211. + debug "Storage: $local_item->{name} ($local_item->{binID})\n", "parseMsg";
  212. + }
  213. }
  214.  
  215. sub storage_items_stackable {
  216. - my ($self, $args) = @_;
  217. + my ($self, $args) = @_;
  218.  
  219. - my $newmsg;
  220. - $self->decrypt(\$newmsg, substr($args->{RAW_MSG}, 4));
  221. - my $msg = substr($args->{RAW_MSG}, 0, 4).$newmsg;
  222. + my $newmsg;
  223. + $self->decrypt(\$newmsg, substr($args->{RAW_MSG}, 4));
  224. + my $msg = substr($args->{RAW_MSG}, 0, 4).$newmsg;
  225.  
  226. - undef %storage;
  227. - undef @storageID;
  228. + undef %storage;
  229. + undef @storageID;
  230.  
  231. - my $unpack = $self->items_stackable($args);
  232. + my @itemKeys = $self->parse_items_stackable($args, $args->{itemInfo});
  233.  
  234. - for (my $i = 4; $i < $args->{RAW_MSG_SIZE}; $i += $unpack->{len}) {
  235. - my ($item, $local_item);
  236. + for my $item (@itemKeys) {
  237. + my ($local_item, $add);
  238.  
  239. - @{$item}{@{$unpack->{keys}}} = unpack($unpack->{types}, substr($msg, $i, $unpack->{len}));
  240. + binAdd(\@storageID, $item->{index});
  241. + $local_item = $storage{$item->{index}} = Actor::Item->new;
  242.  
  243. - binAdd(\@storageID, $item->{index});
  244. - $local_item = $storage{$item->{index}} = Actor::Item->new;
  245. + for (keys %$item) {
  246. + $local_item->{$_} = $item->{$_};
  247. + }
  248. + $local_item->{amount} = $local_item->{amount} & ~0x80000000;
  249. + $local_item->{name} = itemName($local_item);
  250. + $local_item->{binID} = binFind(\@storageID, $local_item->{index});
  251. + $local_item->{identified} = 1;
  252.  
  253. - foreach (@{$unpack->{keys}}) {
  254. - $local_item->{$_} = $item->{$_};
  255. - }
  256. - $local_item->{amount} = $local_item->{amount} & ~0x80000000;
  257. - $local_item->{name} = itemName($local_item);
  258. - $local_item->{binID} = binFind(\@storageID, $local_item->{index});
  259. - $local_item->{identified} = 1;
  260. - debug "Storage: $local_item->{name} ($local_item->{binID}) x $local_item->{amount}\n", "parseMsg";
  261. - }
  262. + debug "Storage: $local_item->{name} ($local_item->{binID}) x $local_item->{amount}\n", "parseMsg";
  263. + }
  264. }
  265.  
  266. sub storage_opened {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement