1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
… | |
… | |
83 | rune = GET_MAP_OB (map, x, y); |
83 | rune = GET_MAP_OB (map, x, y); |
84 | while (rune) |
84 | while (rune) |
85 | { |
85 | { |
86 | next = rune->above; |
86 | next = rune->above; |
87 | |
87 | |
88 | if ((rune->type == SIGN) && (!strcmp (rune->arch->archname, "rune_mark"))) |
88 | if (rune->type == SIGN && !strcmp (rune->arch->archname, "rune_mark")) |
89 | rune->destroy (); |
89 | rune->destroy (true); |
90 | |
90 | |
91 | rune = next; |
91 | rune = next; |
92 | } |
92 | } |
93 | } |
93 | } |
94 | |
94 | |
… | |
… | |
351 | /* Now delete current wall, and insert new one |
351 | /* Now delete current wall, and insert new one |
352 | * We save flags to avoid any trouble with buildable/non buildable, and so on |
352 | * We save flags to avoid any trouble with buildable/non buildable, and so on |
353 | */ |
353 | */ |
354 | object::flags_t old_flags = wall->flag; // elmex: this is where C++ pays off |
354 | object::flags_t old_flags = wall->flag; // elmex: this is where C++ pays off |
355 | |
355 | |
356 | wall->destroy (); |
356 | wall->destroy (true); |
357 | |
357 | |
358 | wall = arch_to_object (new_arch); |
358 | wall = arch_to_object (new_arch); |
359 | wall->type = BUILDABLE_WALL; |
359 | wall->type = BUILDABLE_WALL; |
360 | insert_ob_in_map_at (wall, map, NULL, INS_ABOVE_FLOOR_ONLY, x, y); |
360 | insert_ob_in_map_at (wall, map, NULL, INS_ABOVE_FLOOR_ONLY, x, y); |
361 | wall->flag = old_flags; |
361 | wall->flag = old_flags; |
… | |
… | |
398 | above = tmp->above; |
398 | above = tmp->above; |
399 | if (BUILDABLE_WALL == tmp->type) |
399 | if (BUILDABLE_WALL == tmp->type) |
400 | { |
400 | { |
401 | /* There was a wall, remove it & keep its archetype to make new walls */ |
401 | /* There was a wall, remove it & keep its archetype to make new walls */ |
402 | new_wall = tmp->arch; |
402 | new_wall = tmp->arch; |
403 | tmp->destroy (); |
403 | tmp->destroy (true); |
404 | sprintf (message, "You destroy the wall and redo the floor."); |
404 | sprintf (message, "You destroy the wall and redo the floor."); |
405 | } |
405 | } |
406 | else if ((FLOOR == tmp->type) || (QUERY_FLAG (tmp, FLAG_IS_FLOOR))) |
406 | else if ((FLOOR == tmp->type) || (QUERY_FLAG (tmp, FLAG_IS_FLOOR))) |
407 | { |
407 | { |
408 | tmp->destroy (); |
408 | tmp->destroy (true); |
409 | floor_removed = 1; |
409 | floor_removed = 1; |
410 | } |
410 | } |
411 | else |
411 | else |
412 | { |
412 | { |
413 | if (floor_removed) |
413 | if (floor_removed) |
… | |
… | |
473 | if (!OUT_OF_REAL_MAP (pl->map, xt, yt)) |
473 | if (!OUT_OF_REAL_MAP (pl->map, xt, yt)) |
474 | fix_walls (pl->map, xt, yt); |
474 | fix_walls (pl->map, xt, yt); |
475 | } |
475 | } |
476 | |
476 | |
477 | /* Now remove raw item from inventory */ |
477 | /* Now remove raw item from inventory */ |
478 | decrease_ob (material); |
478 | material->decrease (); |
479 | |
479 | |
480 | /* And tell player about the fix */ |
480 | /* And tell player about the fix */ |
481 | new_draw_info (NDI_UNIQUE, 0, pl, message); |
481 | new_draw_info (NDI_UNIQUE, 0, pl, message); |
482 | } |
482 | } |
483 | |
483 | |
… | |
… | |
542 | insert_ob_in_map_at (tmp, pl->map, 0, INS_ABOVE_FLOOR_ONLY, x, y); |
542 | insert_ob_in_map_at (tmp, pl->map, 0, INS_ABOVE_FLOOR_ONLY, x, y); |
543 | |
543 | |
544 | /* If existing wall, remove it, no need to fix other walls */ |
544 | /* If existing wall, remove it, no need to fix other walls */ |
545 | if (current_wall) |
545 | if (current_wall) |
546 | { |
546 | { |
547 | current_wall->destroy (); |
547 | current_wall->destroy (true); |
548 | fix_walls (pl->map, x, y); |
548 | fix_walls (pl->map, x, y); |
549 | sprintf (message, "You redecorate the wall to better suit your tastes."); |
549 | sprintf (message, "You redecorate the wall to better suit your tastes."); |
550 | } |
550 | } |
551 | else |
551 | else |
552 | { |
552 | { |
… | |
… | |
560 | fix_walls (pl->map, xt, yt); |
560 | fix_walls (pl->map, xt, yt); |
561 | } |
561 | } |
562 | } |
562 | } |
563 | |
563 | |
564 | /* Now remove item from inventory */ |
564 | /* Now remove item from inventory */ |
565 | decrease_ob (material); |
565 | material->decrease (); |
566 | |
566 | |
567 | /* And tell player what happened */ |
567 | /* And tell player what happened */ |
568 | new_draw_info (NDI_UNIQUE, 0, pl, message); |
568 | new_draw_info (NDI_UNIQUE, 0, pl, message); |
569 | } |
569 | } |
570 | |
570 | |
… | |
… | |
638 | case MAGIC_EAR: |
638 | case MAGIC_EAR: |
639 | case SIGN: |
639 | case SIGN: |
640 | /* Signs don't need a connection, but but magic mouths do. */ |
640 | /* Signs don't need a connection, but but magic mouths do. */ |
641 | if (tmp->type == SIGN && strcmp (tmp->arch->archname, "magic_mouth")) |
641 | if (tmp->type == SIGN && strcmp (tmp->arch->archname, "magic_mouth")) |
642 | break; |
642 | break; |
|
|
643 | |
643 | con_rune = get_connection_rune (pl, x, y); |
644 | con_rune = get_connection_rune (pl, x, y); |
644 | connected = find_or_create_connection_for_map (pl, x, y, con_rune); |
645 | connected = find_or_create_connection_for_map (pl, x, y, con_rune); |
645 | if (connected == -1) |
646 | if (connected == -1) |
646 | { |
647 | { |
647 | /* Player already informed of failure by the previous function */ |
648 | /* Player already informed of failure by the previous function */ |
648 | tmp->destroy (); |
649 | tmp->destroy (true); |
649 | return; |
650 | return; |
650 | } |
651 | } |
|
|
652 | |
651 | /* Remove marking rune */ |
653 | /* Remove marking rune */ |
652 | con_rune->destroy (); |
654 | con_rune->destroy (true); |
653 | } |
655 | } |
654 | |
656 | |
655 | /* For magic mouths/ears, and signs, take the msg from a book of scroll */ |
657 | /* For magic mouths/ears, and signs, take the msg from a book of scroll */ |
656 | if ((tmp->type == SIGN) || (tmp->type == MAGIC_EAR)) |
658 | if ((tmp->type == SIGN) || (tmp->type == MAGIC_EAR)) |
657 | { |
659 | { |
658 | if (adjust_sign_msg (pl, x, y, tmp) == -1) |
660 | if (adjust_sign_msg (pl, x, y, tmp) == -1) |
659 | { |
661 | { |
660 | tmp->destroy (); |
662 | tmp->destroy (true); |
661 | return; |
663 | return; |
662 | } |
664 | } |
663 | } |
665 | } |
664 | |
666 | |
665 | insert_ob_in_map_at (tmp, pl->map, floor, insert_flag, x, y); |
667 | insert_ob_in_map_at (tmp, pl->map, floor, insert_flag, x, y); |
666 | if (connected != 0) |
668 | if (connected != 0) |
667 | add_button_link (tmp, pl->map, connected); |
669 | add_button_link (tmp, pl->map, connected); |
668 | |
670 | |
669 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You build the %s", query_name (tmp)); |
671 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You build the %s", query_name (tmp)); |
670 | decrease_ob_nr (item, 1); |
672 | item->decrease (); |
671 | } |
673 | } |
672 | |
674 | |
673 | /** |
675 | /** |
674 | * Item remover. |
676 | * Item remover. |
675 | * |
677 | * |
… | |
… | |
704 | else if (!item->flag [FLAG_IS_BUILDABLE]) |
706 | else if (!item->flag [FLAG_IS_BUILDABLE]) |
705 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't remove the %s, it's not buildable!", query_name (item)); |
707 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't remove the %s, it's not buildable!", query_name (item)); |
706 | else |
708 | else |
707 | { |
709 | { |
708 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You remove the %s", query_name (item)); |
710 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You remove the %s", query_name (item)); |
709 | item->destroy (); |
711 | item->destroy (true); |
710 | } |
712 | } |
711 | } |
713 | } |
712 | |
714 | |
713 | /** |
715 | /** |
714 | * Global building function |
716 | * Global building function |
… | |
… | |
858 | tmp->msg = book->msg; |
860 | tmp->msg = book->msg; |
859 | |
861 | |
860 | if (tmp->invisible) |
862 | if (tmp->invisible) |
861 | { |
863 | { |
862 | if (book->custom_name != NULL) |
864 | if (book->custom_name != NULL) |
863 | { |
|
|
864 | snprintf (buf, sizeof (buf), "talking %s", &book->custom_name); |
865 | snprintf (buf, sizeof (buf), "talking %s", &book->custom_name); |
865 | } |
|
|
866 | else |
866 | else |
867 | { |
|
|
868 | snprintf (buf, sizeof (buf), "talking %s", &book->name); |
867 | snprintf (buf, sizeof (buf), "talking %s", &book->name); |
869 | } |
868 | |
870 | tmp->name = buf; |
869 | tmp->name = buf; |
871 | |
870 | |
872 | if (book->name_pl != NULL) |
871 | if (book->name_pl != NULL) |
873 | { |
872 | { |
874 | snprintf (buf2, sizeof (buf2), "talking %s", &book->name_pl); |
873 | snprintf (buf2, sizeof (buf2), "talking %s", &book->name_pl); |
… | |
… | |
877 | |
876 | |
878 | tmp->face = book->face; |
877 | tmp->face = book->face; |
879 | tmp->invisible = 0; |
878 | tmp->invisible = 0; |
880 | } |
879 | } |
881 | |
880 | |
882 | book->destroy (); |
881 | book->destroy (true); |
883 | return 0; |
882 | return 0; |
884 | } |
883 | } |