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.189 by root, Thu Sep 13 16:23:01 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
2008 if (ms.flags () & P_IS_ALIVE)
2009 continue;
2010
2011 /* However, often
2012 * ob doesn't have any move type (when used to place exits)
2013 * so the AND operation in OB_TYPE_MOVE_BLOCK doesn't work.
2014 */
2015 if (ob->move_type == 0 && ms.move_block != MOVE_ALL)
2016 continue;
2004 2017
2005 /* Basically, if we find a wall on a space, we cut down the search size. 2018 /* 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. 2019 * 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 - 2020 * 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 2021 * 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 2022 * spaces in all the other directions, this will reduce the search space
2010 * to only the spaces immediately surrounding the target area, and 2023 * to only the spaces immediately surrounding the target area, and
2011 * won't look 2 spaces south of the target space. 2024 * won't look 2 spaces south of the target space.
2012 */ 2025 */
2013 else if ((flag & P_NO_PASS) && maxfree[i] < stop) 2026 if (ms.move_block == MOVE_ALL && maxfree[i] < stop)
2027 {
2014 stop = maxfree[i]; 2028 stop = maxfree[i];
2029 continue;
2030 }
2031
2032 /* Note it is intentional that we check ob - the movement type of the
2033 * head of the object should correspond for the entire object.
2034 */
2035 if (OB_TYPE_MOVE_BLOCK (ob, ms.move_block))
2036 continue;
2037
2038 altern [index++] = i;
2015 } 2039 }
2016 2040
2017 if (!index) 2041 if (!index)
2018 return -1; 2042 return -1;
2019 2043
2028 */ 2052 */
2029int 2053int
2030find_first_free_spot (const object *ob, maptile *m, int x, int y) 2054find_first_free_spot (const object *ob, maptile *m, int x, int y)
2031{ 2055{
2032 for (int i = 0; i < SIZEOFFREE; i++) 2056 for (int i = 0; i < SIZEOFFREE; i++)
2033 if (!ob_blocked (ob, m, x + freearr_x[i], y + freearr_y[i])) 2057 if (!ob->blocked (m, x + freearr_x[i], y + freearr_y[i]))
2034 return i; 2058 return i;
2035 2059
2036 return -1; 2060 return -1;
2037} 2061}
2038 2062

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines