… | |
… | |
204 | book = book->above; |
204 | book = book->above; |
205 | return book; |
205 | return book; |
206 | } |
206 | } |
207 | |
207 | |
208 | /** |
208 | /** |
209 | * Returns first item of type WALL. |
209 | * Returns first item of type BUILDABLE_WALL. |
210 | */ |
210 | */ |
211 | object * |
211 | object * |
212 | get_wall (maptile *map, int x, int y) |
212 | get_wall (maptile *map, int x, int y) |
213 | { |
213 | { |
214 | object *wall; |
214 | object *wall; |
215 | |
215 | |
216 | wall = GET_MAP_OB (map, x, y); |
216 | wall = GET_MAP_OB (map, x, y); |
217 | while (wall && (WALL != wall->type)) |
217 | while (wall && (BUILDABLE_WALL != wall->type)) |
218 | wall = wall->above; |
218 | wall = wall->above; |
219 | |
219 | |
220 | return wall; |
220 | return wall; |
221 | } |
221 | } |
222 | |
222 | |
… | |
… | |
361 | old_flags[flag] = wall->flags[flag]; |
361 | old_flags[flag] = wall->flags[flag]; |
362 | |
362 | |
363 | wall->destroy (); |
363 | wall->destroy (); |
364 | |
364 | |
365 | wall = arch_to_object (new_arch); |
365 | wall = arch_to_object (new_arch); |
366 | wall->type = WALL; |
366 | wall->type = BUILDABLE_WALL; |
367 | insert_ob_in_map_at (wall, map, NULL, INS_ABOVE_FLOOR_ONLY, x, y); |
367 | insert_ob_in_map_at (wall, map, NULL, INS_ABOVE_FLOOR_ONLY, x, y); |
368 | for (flag = 0; flag < 4; flag++) |
368 | for (flag = 0; flag < 4; flag++) |
369 | wall->flags[flag] = old_flags[flag]; |
369 | wall->flags[flag] = old_flags[flag]; |
370 | } |
370 | } |
371 | |
371 | |
… | |
… | |
402 | if (tmp) |
402 | if (tmp) |
403 | { |
403 | { |
404 | while (tmp) |
404 | while (tmp) |
405 | { |
405 | { |
406 | above = tmp->above; |
406 | above = tmp->above; |
407 | if (WALL == tmp->type) |
407 | if (BUILDABLE_WALL == tmp->type) |
408 | { |
408 | { |
409 | /* There was a wall, remove it & keep its archetype to make new walls */ |
409 | /* There was a wall, remove it & keep its archetype to make new walls */ |
410 | new_wall = tmp->arch; |
410 | new_wall = tmp->arch; |
411 | tmp->destroy (); |
411 | tmp->destroy (); |
412 | sprintf (message, "You destroy the wall and redo the floor."); |
412 | sprintf (message, "You destroy the wall and redo the floor."); |
… | |
… | |
463 | /* Insert wall if exists. Note: if it doesn't, the map is weird... */ |
463 | /* Insert wall if exists. Note: if it doesn't, the map is weird... */ |
464 | if (new_wall) |
464 | if (new_wall) |
465 | { |
465 | { |
466 | tmp = arch_to_object (new_wall); |
466 | tmp = arch_to_object (new_wall); |
467 | SET_FLAG (tmp, FLAG_IS_BUILDABLE); |
467 | SET_FLAG (tmp, FLAG_IS_BUILDABLE); |
468 | tmp->type = WALL; |
468 | tmp->type = BUILDABLE_WALL; |
469 | insert_ob_in_map_at (tmp, pl->map, 0, 0, xt, yt); |
469 | insert_ob_in_map_at (tmp, pl->map, 0, 0, xt, yt); |
470 | } |
470 | } |
471 | } |
471 | } |
472 | } |
472 | } |
473 | |
473 | |
… | |
… | |
525 | /* Grab existing wall, if any */ |
525 | /* Grab existing wall, if any */ |
526 | current_wall = NULL; |
526 | current_wall = NULL; |
527 | tmp = GET_MAP_OB (pl->map, x, y); |
527 | tmp = GET_MAP_OB (pl->map, x, y); |
528 | while (tmp && !current_wall) |
528 | while (tmp && !current_wall) |
529 | { |
529 | { |
530 | if (WALL == tmp->type) |
530 | if (BUILDABLE_WALL == tmp->type) |
531 | current_wall = tmp; |
531 | current_wall = tmp; |
532 | |
532 | |
533 | tmp = tmp->above; |
533 | tmp = tmp->above; |
534 | } |
534 | } |
535 | |
535 | |
… | |
… | |
543 | LOG (llevError, "apply_builder_wall: unable to find archetype %s\n", &material->slaying); |
543 | LOG (llevError, "apply_builder_wall: unable to find archetype %s\n", &material->slaying); |
544 | return; |
544 | return; |
545 | } |
545 | } |
546 | |
546 | |
547 | tmp = arch_to_object (new_wall); |
547 | tmp = arch_to_object (new_wall); |
548 | tmp->type = WALL; |
548 | tmp->type = BUILDABLE_WALL; |
549 | SET_FLAG (tmp, FLAG_IS_BUILDABLE); |
549 | SET_FLAG (tmp, FLAG_IS_BUILDABLE); |
550 | insert_ob_in_map_at (tmp, pl->map, 0, INS_ABOVE_FLOOR_ONLY, x, y); |
550 | insert_ob_in_map_at (tmp, pl->map, 0, INS_ABOVE_FLOOR_ONLY, x, y); |
551 | |
551 | |
552 | /* If existing wall, remove it, no need to fix other walls */ |
552 | /* If existing wall, remove it, no need to fix other walls */ |
553 | if (current_wall) |
553 | if (current_wall) |
… | |
… | |
712 | } |
712 | } |
713 | |
713 | |
714 | /* Now remove object, with special cases (buttons & such) */ |
714 | /* Now remove object, with special cases (buttons & such) */ |
715 | switch (item->type) |
715 | switch (item->type) |
716 | { |
716 | { |
717 | case WALL: |
717 | case BUILDABLE_WALL: |
718 | new_draw_info (NDI_UNIQUE, 0, pl, "Can't remove a wall with that, build a floor."); |
718 | new_draw_info (NDI_UNIQUE, 0, pl, "Can't remove a wall with that, build a floor."); |
719 | return; |
719 | return; |
720 | |
720 | |
721 | case DOOR: |
721 | case DOOR: |
722 | case BUTTON: |
722 | case BUTTON: |
… | |
… | |
733 | |
733 | |
734 | /* Fall through */ |
734 | /* Fall through */ |
735 | |
735 | |
736 | default: |
736 | default: |
737 | /* Remove generic item */ |
737 | /* Remove generic item */ |
|
|
738 | if (!QUERY_FLAG (item, FLAG_IS_BUILDABLE)) |
|
|
739 | { |
|
|
740 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't remove the %s, it's not buildable!", query_name (item)); |
|
|
741 | return; |
|
|
742 | } |
|
|
743 | |
738 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You remove the %s", query_name (item)); |
744 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You remove the %s", query_name (item)); |
739 | item->destroy (); |
745 | item->destroy (); |
740 | } |
746 | } |
741 | } |
747 | } |
742 | |
748 | |