… | |
… | |
209 | |
209 | |
210 | /* first, find a place to put the chest. */ |
210 | /* first, find a place to put the chest. */ |
211 | i = find_first_free_spot (the_chest, map, x, y); |
211 | i = find_first_free_spot (the_chest, map, x, y); |
212 | if (i == -1) |
212 | if (i == -1) |
213 | { |
213 | { |
214 | the_chest->destroy (0); |
214 | the_chest->destroy (); |
215 | return NULL; |
215 | return NULL; |
216 | } |
216 | } |
217 | xl = x + freearr_x[i]; |
217 | xl = x + freearr_x[i]; |
218 | yl = y + freearr_y[i]; |
218 | yl = y + freearr_y[i]; |
219 | |
219 | |
… | |
… | |
265 | if (the_trap) |
265 | if (the_trap) |
266 | { |
266 | { |
267 | object *new_trap; |
267 | object *new_trap; |
268 | |
268 | |
269 | new_trap = arch_to_object (the_trap->arch); |
269 | new_trap = arch_to_object (the_trap->arch); |
270 | copy_object (new_trap, the_trap); |
270 | new_trap->copy_to (the_trap); |
271 | new_trap->x = x; |
271 | new_trap->x = x; |
272 | new_trap->y = y; |
272 | new_trap->y = y; |
273 | insert_ob_in_ob (new_trap, the_chest); |
273 | insert_ob_in_ob (new_trap, the_chest); |
274 | } |
274 | } |
275 | } |
275 | } |
… | |
… | |
312 | /* boundscheck */ |
312 | /* boundscheck */ |
313 | if (lx >= 0 && ly >= 0 && lx < RP->Xsize && ly < RP->Ysize) |
313 | if (lx >= 0 && ly >= 0 && lx < RP->Xsize && ly < RP->Ysize) |
314 | /* don't bother searching this square unless the map says life exists. */ |
314 | /* don't bother searching this square unless the map says life exists. */ |
315 | if (GET_MAP_FLAGS (map, lx, ly) & P_IS_ALIVE) |
315 | if (GET_MAP_FLAGS (map, lx, ly) & P_IS_ALIVE) |
316 | { |
316 | { |
317 | object *the_monster = get_map_ob (map, lx, ly); |
317 | object *the_monster = GET_MAP_OB (map, lx, ly); |
318 | |
318 | |
319 | for (; the_monster != NULL && (!QUERY_FLAG (the_monster, FLAG_MONSTER)); the_monster = the_monster->above); |
319 | for (; the_monster != NULL && (!QUERY_FLAG (the_monster, FLAG_MONSTER)); the_monster = the_monster->above); |
320 | if (the_monster && QUERY_FLAG (the_monster, FLAG_MONSTER)) |
320 | if (the_monster && QUERY_FLAG (the_monster, FLAG_MONSTER)) |
321 | return the_monster; |
321 | return the_monster; |
322 | } |
322 | } |
… | |
… | |
453 | /* check the current square for a monster. If there is one, |
453 | /* check the current square for a monster. If there is one, |
454 | set theMonsterToFind and return it. */ |
454 | set theMonsterToFind and return it. */ |
455 | layout[x][y] = 1; |
455 | layout[x][y] = 1; |
456 | if (GET_MAP_FLAGS (map, x, y) & P_IS_ALIVE) |
456 | if (GET_MAP_FLAGS (map, x, y) & P_IS_ALIVE) |
457 | { |
457 | { |
458 | object *the_monster = get_map_ob (map, x, y); |
458 | object *the_monster = GET_MAP_OB (map, x, y); |
459 | |
459 | |
460 | /* check off this point */ |
460 | /* check off this point */ |
461 | for (; the_monster != NULL && (!QUERY_FLAG (the_monster, FLAG_ALIVE)); the_monster = the_monster->above); |
461 | for (; the_monster != NULL && (!QUERY_FLAG (the_monster, FLAG_ALIVE)); the_monster = the_monster->above); |
462 | if (the_monster && QUERY_FLAG (the_monster, FLAG_ALIVE)) |
462 | if (the_monster && QUERY_FLAG (the_monster, FLAG_ALIVE)) |
463 | { |
463 | { |
… | |
… | |
673 | void |
673 | void |
674 | remove_monsters (int x, int y, maptile *map) |
674 | remove_monsters (int x, int y, maptile *map) |
675 | { |
675 | { |
676 | object *tmp; |
676 | object *tmp; |
677 | |
677 | |
678 | for (tmp = get_map_ob (map, x, y); tmp != NULL; tmp = tmp->above) |
678 | for (tmp = GET_MAP_OB (map, x, y); tmp != NULL; tmp = tmp->above) |
679 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
679 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
680 | { |
680 | { |
681 | if (tmp->head) |
681 | if (tmp->head) |
682 | tmp = tmp->head; |
682 | tmp = tmp->head; |
683 | tmp->remove (); |
683 | tmp->remove (); |
684 | tmp->destroy (0); |
684 | tmp->destroy (); |
685 | tmp = get_map_ob (map, x, y); |
685 | tmp = GET_MAP_OB (map, x, y); |
686 | if (tmp == NULL) |
686 | if (tmp == NULL) |
687 | break; |
687 | break; |
688 | }; |
688 | }; |
689 | } |
689 | } |
690 | |
690 | |
… | |
… | |
739 | object * |
739 | object * |
740 | door_in_square (maptile *map, int x, int y) |
740 | door_in_square (maptile *map, int x, int y) |
741 | { |
741 | { |
742 | object *tmp; |
742 | object *tmp; |
743 | |
743 | |
744 | for (tmp = get_map_ob (map, x, y); tmp != NULL; tmp = tmp->above) |
744 | for (tmp = GET_MAP_OB (map, x, y); tmp != NULL; tmp = tmp->above) |
745 | if (tmp->type == DOOR || tmp->type == LOCKED_DOOR) |
745 | if (tmp->type == DOOR || tmp->type == LOCKED_DOOR) |
746 | return tmp; |
746 | return tmp; |
747 | return NULL; |
747 | return NULL; |
748 | } |
748 | } |
749 | |
749 | |
… | |
… | |
849 | door = doorlist[i]; |
849 | door = doorlist[i]; |
850 | new_door->face = door->face; |
850 | new_door->face = door->face; |
851 | new_door->x = door->x; |
851 | new_door->x = door->x; |
852 | new_door->y = door->y; |
852 | new_door->y = door->y; |
853 | door->remove (); |
853 | door->remove (); |
854 | door->destroy (0); |
854 | door->destroy (); |
855 | doorlist[i] = new_door; |
855 | doorlist[i] = new_door; |
856 | insert_ob_in_map (new_door, map, NULL, 0); |
856 | insert_ob_in_map (new_door, map, NULL, 0); |
857 | sprintf (keybuf, "%d", (int) RANDOM ()); |
857 | sprintf (keybuf, "%d", (int) RANDOM ()); |
858 | new_door->slaying = keybuf; |
858 | new_door->slaying = keybuf; |
859 | keyplace (map, new_door->x, new_door->y, keybuf, NO_PASS_DOORS, 2, RP); |
859 | keyplace (map, new_door->x, new_door->y, keybuf, NO_PASS_DOORS, 2, RP); |
… | |
… | |
876 | retrofit_joined_wall (map, door->x, door->y - 1, 0, RP); |
876 | retrofit_joined_wall (map, door->x, door->y - 1, 0, RP); |
877 | retrofit_joined_wall (map, door->x, door->y + 1, 0, RP); |
877 | retrofit_joined_wall (map, door->x, door->y + 1, 0, RP); |
878 | door->face = wallface->face; |
878 | door->face = wallface->face; |
879 | if (!QUERY_FLAG (wallface, FLAG_REMOVED)) |
879 | if (!QUERY_FLAG (wallface, FLAG_REMOVED)) |
880 | wallface->remove (); |
880 | wallface->remove (); |
881 | wallface->destroy (0); |
881 | wallface->destroy (); |
882 | } |
882 | } |
883 | } |
883 | } |
884 | } |
884 | } |
885 | } |
885 | } |