Advertisement
Guest User

Untitled

a guest
Jun 7th, 2022
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. public function smartsearch($whbin,$itemX,$itemY) {
  2. $ver = 32; //item lenght, s6 e3
  3. if (substr($whbin,0,2)=='0x') $whbin=substr($whbin,2);
  4. $items = str_repeat('0', 120);
  5. $itemsm = str_repeat('1', 120);
  6. $i = 0;
  7. while ($i<120) {
  8. $_item = substr($whbin,($ver*$i), $ver);
  9. $check_ref = hexdec(substr($_item, 19,1))/16;
  10. if($check_ref == 0.5)
  11. $type = floor(hexdec(substr($_item,18,2))/16);
  12. else
  13. $type = round(hexdec(substr($_item,18,2))/16);
  14.  
  15. $query = $this->db->query('SELECT size_x, size_y FROM mucore_shop_items WHERE i_id = '.hexdec(substr($_item,0,2)).' AND i_type = '.$type.'');
  16. if(hexdec(substr($_item,0,2)) != 255 && $type != 16){
  17. if($query->rowCount() < 1){
  18. $not_found = true;
  19. }
  20. else{
  21. $not_found = false;
  22. }
  23. }
  24. $res = $query->fetch(PDO::FETCH_ASSOC);
  25. $y = 0;
  26. while($y<$res['size_y']) {
  27. $y++;$x=0;
  28. while($x<$res['size_x']) {
  29. $items = substr_replace($items, '1', ($i+$x)+(($y-1)*8), 1);
  30. $x++;
  31. }
  32. }
  33. $i++;
  34. }
  35. $y = 0;
  36. while($y<$itemY) {
  37. $y++;$x=0;
  38. while($x<$itemX) {
  39. $x++;
  40. $spacerq[$x+(8*($y-1))] = true;
  41. }
  42. }
  43. $walked = 0;
  44. $i = 0;
  45. while($i<120) {
  46. if (isset($spacerq[$i])) {
  47. $itemsm = substr_replace($itemsm, '0', $i-1, 1);
  48. $last = $i;
  49. $walked++;
  50. }
  51. if ($walked==count($spacerq)) $i=119;
  52. $i++;
  53. }
  54. $useforlength = substr($itemsm,0,$last);
  55. $findslotlikethis='^'.str_replace('++','+',str_replace('1','+[0-1]+', $useforlength));
  56. ///echo '<pre>'.$useforlength.'</pre>';
  57. $i=0;$nx=0;$ny=0;
  58. while ($i<120) {
  59. if ($nx==8) { $ny++; $nx=0; }
  60. if ((@ereg($findslotlikethis, substr($items, $i, strlen($useforlength)))) && ($itemX+$nx<9) && ($itemY+$ny<16))
  61. return $i;
  62. $i++;
  63. $nx++;
  64. }
  65. if($not_found == true){
  66. return 1338;
  67. }
  68. return 1337;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement