Advertisement
Guest User

r15116

a guest
Jun 14th, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.56 KB | None | 0 0
  1. Index: map.c
  2. ===================================================================
  3. --- map.c   (revisão 16294)
  4. +++ map.c   (cópia de trabalho)
  5. @@ -265,7 +265,7 @@
  6.   * These pair of functions update the counter of how many objects
  7.   * lie on a tile.
  8.   *------------------------------------------*/
  9. -void map_addblcell(struct block_list *bl)
  10. +static void map_addblcell(struct block_list *bl)
  11.  {
  12.     if( bl->m<0 || bl->x<0 || bl->x>=map[bl->m].xs || bl->y<0 || bl->y>=map[bl->m].ys || !(bl->type&BL_CHAR) )
  13.         return;
  14. @@ -273,7 +273,7 @@
  15.     return;
  16.  }
  17.  
  18. -void map_delblcell(struct block_list *bl)
  19. +static void map_delblcell(struct block_list *bl)
  20.  {
  21.     if( bl->m <0 || bl->x<0 || bl->x>=map[bl->m].xs || bl->y<0 || bl->y>=map[bl->m].ys || !(bl->type&BL_CHAR) )
  22.         return;
  23. @@ -695,21 +695,16 @@
  24.         return 0;
  25.     if (x1 < x0)
  26.     {   //Swap range
  27. -       bx = x0;
  28. -       x0 = x1;
  29. -       x1 = bx;
  30. +       swap(x0, x1);
  31.     }
  32.     if (y1 < y0)
  33.     {
  34. -       bx = y0;
  35. -       y0 = y1;
  36. -       y1 = bx;
  37. +       swap(y0, y1);
  38.     }
  39. -   if (x0 < 0) x0 = 0;
  40. -   if (y0 < 0) y0 = 0;
  41. -   if (x1 >= map[m].xs) x1 = map[m].xs-1;
  42. -   if (y1 >= map[m].ys) y1 = map[m].ys-1;
  43. -  
  44. +   x0 = max(x0, 0);
  45. +   y0 = max(y0, 0);
  46. +   x1 = min(x1, map[m].xs-1);
  47. +   y1 = min(y1, map[m].ys-1);
  48.     if (type&~BL_MOB)
  49.         for(by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++)
  50.             for(bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++)
  51. @@ -822,21 +817,17 @@
  52.         return 0;
  53.     if (x1 < x0)
  54.     {   //Swap range
  55. -       bx = x0;
  56. -       x0 = x1;
  57. -       x1 = bx;
  58. +       swap(x0, x1);
  59.     }
  60.     if (y1 < y0)
  61.     {
  62. -       bx = y0;
  63. -       y0 = y1;
  64. -       y1 = bx;
  65. +       swap(y0, y1);
  66.     }
  67. -   if (x0 < 0) x0 = 0;
  68. -   if (y0 < 0) y0 = 0;
  69. -   if (x1 >= map[m].xs) x1 = map[m].xs-1;
  70. -   if (y1 >= map[m].ys) y1 = map[m].ys-1;
  71. -  
  72. +   x0 = max(x0, 0);
  73. +   y0 = max(y0, 0);
  74. +   x1 = min(x1, map[m].xs-1);
  75. +   y1 = min(y1, map[m].ys-1);
  76. +
  77.     if (type&~BL_MOB)
  78.         for(by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++)
  79.             for(bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++)
  80. @@ -899,15 +890,11 @@
  81.  
  82.     if (x1 < x0)
  83.     {   //Swap range
  84. -       bx = x0;
  85. -       x0 = x1;
  86. -       x1 = bx;
  87. +       swap(x0, x1);
  88.     }
  89.     if (y1 < y0)
  90.     {
  91. -       bx = y0;
  92. -       y0 = y1;
  93. -       y1 = bx;
  94. +       swap(y0, y1);
  95.     }
  96.     if(dx==0 || dy==0){
  97.         //Movement along one axis only.
  98. @@ -922,10 +909,10 @@
  99.             else //East
  100.                 x1=x0+dx-1;
  101.         }
  102. -       if(x0<0) x0=0;
  103. -       if(y0<0) y0=0;
  104. -       if(x1>=map[m].xs) x1=map[m].xs-1;
  105. -       if(y1>=map[m].ys) y1=map[m].ys-1;
  106. +       x0 = max(x0, 0);
  107. +       y0 = max(y0, 0);
  108. +       x1 = min(x1, map[m].xs-1);
  109. +       y1 = min(y1, map[m].ys-1);
  110.         for(by=y0/BLOCK_SIZE;by<=y1/BLOCK_SIZE;by++){
  111.             for(bx=x0/BLOCK_SIZE;bx<=x1/BLOCK_SIZE;bx++){
  112.                 if (type&~BL_MOB) {
  113. @@ -951,10 +938,10 @@
  114.         }
  115.     }else{
  116.         // Diagonal movement
  117. -       if(x0<0) x0=0;
  118. -       if(y0<0) y0=0;
  119. -       if(x1>=map[m].xs) x1=map[m].xs-1;
  120. -       if(y1>=map[m].ys) y1=map[m].ys-1;
  121. +       x0 = max(x0, 0);
  122. +       y0 = max(y0, 0);
  123. +       x1 = min(x1, map[m].xs-1);
  124. +       y1 = min(y1, map[m].ys-1);
  125.         for(by=y0/BLOCK_SIZE;by<=y1/BLOCK_SIZE;by++){
  126.             for(bx=x0/BLOCK_SIZE;bx<=x1/BLOCK_SIZE;bx++){
  127.                 if (type & ~BL_MOB) {
  128. @@ -1142,21 +1129,17 @@
  129.     //The two fors assume mx0 < mx1 && my0 < my1
  130.     if (mx0 > mx1)
  131.     {
  132. -       k = mx1;
  133. -       mx1 = mx0;
  134. -       mx0 = k;
  135. +       swap(mx0, mx1);
  136.     }
  137.     if (my0 > my1)
  138.     {
  139. -       k = my1;
  140. -       my1 = my0;
  141. -       my0 = k;
  142. +       swap(my0, my1);
  143.     }
  144.    
  145. -   if (mx0 < 0) mx0 = 0;
  146. -   if (my0 < 0) my0 = 0;
  147. -   if (mx1 >= map[m].xs) mx1 = map[m].xs-1;
  148. -   if (my1 >= map[m].ys) my1 = map[m].ys-1;
  149. +   mx0 = max(mx0, 0);
  150. +   my0 = max(my0, 0);
  151. +   mx1 = min(mx1, map[m].xs-1);
  152. +   my1 = min(my1, map[m].ys-1);
  153.    
  154.     range*=range<<8; //Values are shifted later on for higher precision using int math.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement