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.192 by root, Fri Oct 12 19:13:25 2007 UTC

305 { 305 {
306 ob1->optimise (); 306 ob1->optimise ();
307 ob2->optimise (); 307 ob2->optimise ();
308 308
309 if (ob1->self || ob2->self) 309 if (ob1->self || ob2->self)
310 if (!cfperl_can_merge (ob1, ob2)) 310 {
311 int k1 = ob1->self ? HvTOTALKEYS (SvRV (ob1->self)) : 0;
312 int k2 = ob2->self ? HvTOTALKEYS (SvRV (ob2->self)) : 0;
313
314 if (k1 != k2)
311 return 0; 315 return 0;
316 else if (k1 == 0)
317 return 1;
318 else if (!cfperl_can_merge (ob1, ob2))
319 return 0;
320 }
312 } 321 }
313 322
314 /* Everything passes, must be OK. */ 323 /* Everything passes, must be OK. */
315 return 1; 324 return 1;
316} 325}
1290 else 1299 else
1291 { 1300 {
1292 top = ms.bot; 1301 top = ms.bot;
1293 1302
1294 /* If there are other objects, then */ 1303 /* If there are other objects, then */
1295 if ((!(flag & INS_MAP_LOAD)) && top) 1304 if (top)
1296 { 1305 {
1297 object *last = 0; 1306 object *last = 0;
1298 1307
1299 /* 1308 /*
1300 * If there are multiple objects on this space, we do some trickier handling. 1309 * If there are multiple objects on this space, we do some trickier handling.
1352 */ 1361 */
1353 if (last && last->below && last != floor) 1362 if (last && last->below && last != floor)
1354 top = last->below; 1363 top = last->below;
1355 } 1364 }
1356 } /* If objects on this space */ 1365 } /* If objects on this space */
1357 if (flag & INS_MAP_LOAD)
1358 top = ms.top;
1359 1366
1360 if (flag & INS_ABOVE_FLOOR_ONLY) 1367 if (flag & INS_ABOVE_FLOOR_ONLY)
1361 top = floor; 1368 top = floor;
1362 1369
1363 /* Top is the object that our object (op) is going to get inserted above. 1370 /* Top is the object that our object (op) is going to get inserted above.
1396 op->map->touch (); 1403 op->map->touch ();
1397 } 1404 }
1398 1405
1399 op->map->dirty = true; 1406 op->map->dirty = true;
1400 1407
1401 if (!(flag & INS_MAP_LOAD))
1402 if (object *pl = ms.player ()) 1408 if (object *pl = ms.player ())
1403 pl->contr->ns->floorbox_update (); 1409 pl->contr->ns->floorbox_update ();
1404 1410
1405 /* If this object glows, it may affect lighting conditions that are 1411 /* If this object glows, it may affect lighting conditions that are
1406 * visible to others on this map. But update_all_los is really 1412 * visible to others on this map. But update_all_los is really
1407 * an inefficient way to do this, as it means los for all players 1413 * an inefficient way to do this, as it means los for all players
1408 * on the map will get recalculated. The players could very well 1414 * on the map will get recalculated. The players could very well
1991 * customized, changed states, etc. 1997 * customized, changed states, etc.
1992 */ 1998 */
1993int 1999int
1994find_free_spot (const object *ob, maptile *m, int x, int y, int start, int stop) 2000find_free_spot (const object *ob, maptile *m, int x, int y, int start, int stop)
1995{ 2001{
2002 int altern[SIZEOFFREE];
1996 int index = 0, flag; 2003 int index = 0, flag;
1997 int altern[SIZEOFFREE];
1998 2004
1999 for (int i = start; i < stop; i++) 2005 for (int i = start; i < stop; i++)
2000 { 2006 {
2001 flag = ob_blocked (ob, m, x + freearr_x[i], y + freearr_y[i]); 2007 mapxy pos (m, x, y); pos.move (i);
2002 if (!flag) 2008
2009 if (!pos.normalise ())
2010 continue;
2011
2012 mapspace &ms = *pos;
2013
2014 if (ms.flags () & P_IS_ALIVE)
2015 continue;
2016
2017 /* However, often
2018 * ob doesn't have any move type (when used to place exits)
2019 * so the AND operation in OB_TYPE_MOVE_BLOCK doesn't work.
2020 */
2021 if (ob->move_type == 0 && ms.move_block != MOVE_ALL)
2022 {
2003 altern [index++] = i; 2023 altern [index++] = i;
2024 continue;
2025 }
2004 2026
2005 /* Basically, if we find a wall on a space, we cut down the search size. 2027 /* 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. 2028 * 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 - 2029 * 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 2030 * 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 2031 * spaces in all the other directions, this will reduce the search space
2010 * to only the spaces immediately surrounding the target area, and 2032 * to only the spaces immediately surrounding the target area, and
2011 * won't look 2 spaces south of the target space. 2033 * won't look 2 spaces south of the target space.
2012 */ 2034 */
2013 else if ((flag & P_NO_PASS) && maxfree[i] < stop) 2035 if (ms.move_block == MOVE_ALL && maxfree[i] < stop)
2036 {
2014 stop = maxfree[i]; 2037 stop = maxfree[i];
2038 continue;
2039 }
2040
2041 /* Note it is intentional that we check ob - the movement type of the
2042 * head of the object should correspond for the entire object.
2043 */
2044 if (OB_TYPE_MOVE_BLOCK (ob, ms.move_block))
2045 continue;
2046
2047 altern [index++] = i;
2015 } 2048 }
2016 2049
2017 if (!index) 2050 if (!index)
2018 return -1; 2051 return -1;
2019 2052
2028 */ 2061 */
2029int 2062int
2030find_first_free_spot (const object *ob, maptile *m, int x, int y) 2063find_first_free_spot (const object *ob, maptile *m, int x, int y)
2031{ 2064{
2032 for (int i = 0; i < SIZEOFFREE; i++) 2065 for (int i = 0; i < SIZEOFFREE; i++)
2033 if (!ob_blocked (ob, m, x + freearr_x[i], y + freearr_y[i])) 2066 if (!ob->blocked (m, x + freearr_x[i], y + freearr_y[i]))
2034 return i; 2067 return i;
2035 2068
2036 return -1; 2069 return -1;
2037} 2070}
2038 2071

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines