… | |
… | |
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 | */ |
1993 | int |
1999 | int |
1994 | find_free_spot (const object *ob, maptile *m, int x, int y, int start, int stop) |
2000 | find_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 | mapxy pos (m, x, y); pos.move (i); |
2007 | mapxy pos (m, x, y); pos.move (i); |
2002 | |
2008 | |
2003 | if (!pos.normalise ()) |
2009 | if (!pos.normalise ()) |
2004 | continue; |
2010 | continue; |
2005 | |
2011 | |
2006 | mapspace &ms = *pos; |
2012 | mapspace &ms = *pos; |
2007 | ms.update (); |
2013 | |
|
|
2014 | if (ms.flags () & P_IS_ALIVE) |
|
|
2015 | continue; |
2008 | |
2016 | |
2009 | /* However, often |
2017 | /* However, often |
2010 | * ob doesn't have any move type (when used to place exits) |
2018 | * 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. |
2019 | * so the AND operation in OB_TYPE_MOVE_BLOCK doesn't work. |
2012 | */ |
2020 | */ |
2013 | if (ob->move_type == 0 && ms.move_block != MOVE_ALL) |
2021 | if (ob->move_type == 0 && ms.move_block != MOVE_ALL) |
|
|
2022 | { |
|
|
2023 | altern [index++] = i; |
2014 | continue; |
2024 | continue; |
|
|
2025 | } |
2015 | |
2026 | |
2016 | /* 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. |
2017 | * 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. |
2018 | * 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 - |
2019 | * 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 |