ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/object.C
(Generate patch)

Comparing deliantra/server/common/object.C (file contents):
Revision 1.187 by root, Tue Sep 4 08:42:55 2007 UTC vs.
Revision 1.188 by root, Wed Sep 12 11:10:09 2007 UTC

1996 int index = 0, flag; 1996 int index = 0, flag;
1997 int altern[SIZEOFFREE]; 1997 int altern[SIZEOFFREE];
1998 1998
1999 for (int i = start; i < stop; i++) 1999 for (int i = start; i < stop; i++)
2000 { 2000 {
2001 flag = ob_blocked (ob, m, x + freearr_x[i], y + freearr_y[i]); 2001 mapxy pos (m, x, y); pos.move (i);
2002 if (!flag) 2002
2003 altern [index++] = i; 2003 if (!pos.normalise ())
2004 continue;
2005
2006 mapspace &ms = *pos;
2007 ms.update ();
2008
2009 /* However, often
2010 * ob doesn't have any move type (when used to place exits)
2011 * so the AND operation in OB_TYPE_MOVE_BLOCK doesn't work.
2012 */
2013 if (ob->move_type == 0 && ms.move_block != MOVE_ALL)
2014 continue;
2004 2015
2005 /* Basically, if we find a wall on a space, we cut down the search size. 2016 /* Basically, if we find a wall on a space, we cut down the search size.
2006 * In this way, we won't return spaces that are on another side of a wall. 2017 * In this way, we won't return spaces that are on another side of a wall.
2007 * This mostly work, but it cuts down the search size in all directions - 2018 * This mostly work, but it cuts down the search size in all directions -
2008 * if the space being examined only has a wall to the north and empty 2019 * if the space being examined only has a wall to the north and empty
2009 * spaces in all the other directions, this will reduce the search space 2020 * spaces in all the other directions, this will reduce the search space
2010 * to only the spaces immediately surrounding the target area, and 2021 * to only the spaces immediately surrounding the target area, and
2011 * won't look 2 spaces south of the target space. 2022 * won't look 2 spaces south of the target space.
2012 */ 2023 */
2013 else if ((flag & P_NO_PASS) && maxfree[i] < stop) 2024 if (ms.move_block == MOVE_ALL && maxfree[i] < stop)
2025 {
2014 stop = maxfree[i]; 2026 stop = maxfree[i];
2027 continue;
2028 }
2029
2030 /* Note it is intentional that we check ob - the movement type of the
2031 * head of the object should correspond for the entire object.
2032 */
2033 if (OB_TYPE_MOVE_BLOCK (ob, ms.move_block))
2034 continue;
2035
2036 altern [index++] = i;
2015 } 2037 }
2016 2038
2017 if (!index) 2039 if (!index)
2018 return -1; 2040 return -1;
2019 2041
2028 */ 2050 */
2029int 2051int
2030find_first_free_spot (const object *ob, maptile *m, int x, int y) 2052find_first_free_spot (const object *ob, maptile *m, int x, int y)
2031{ 2053{
2032 for (int i = 0; i < SIZEOFFREE; i++) 2054 for (int i = 0; i < SIZEOFFREE; i++)
2033 if (!ob_blocked (ob, m, x + freearr_x[i], y + freearr_y[i])) 2055 if (!ob->blocked (m, x + freearr_x[i], y + freearr_y[i]))
2034 return i; 2056 return i;
2035 2057
2036 return -1; 2058 return -1;
2037} 2059}
2038 2060

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines