… | |
… | |
74 | |
74 | |
75 | /* bail out if treasure isn't wanted. */ |
75 | /* bail out if treasure isn't wanted. */ |
76 | if (treasure_style) |
76 | if (treasure_style) |
77 | if (!strcmp (treasure_style, "none")) |
77 | if (!strcmp (treasure_style, "none")) |
78 | return; |
78 | return; |
|
|
79 | |
79 | if (treasureoptions <= 0) |
80 | if (treasureoptions <= 0) |
80 | treasureoptions = RANDOM () % (2 * LAST_OPTION); |
81 | treasureoptions = RANDOM () % (2 * LAST_OPTION); |
81 | |
82 | |
82 | /* filter out the mutually exclusive options */ |
83 | /* filter out the mutually exclusive options */ |
83 | if ((treasureoptions & RICH) && (treasureoptions & SPARSE)) |
84 | if ((treasureoptions & RICH) && (treasureoptions & SPARSE)) |
… | |
… | |
101 | |
102 | |
102 | /* get the style map */ |
103 | /* get the style map */ |
103 | sprintf (styledirname, "%s", "/styles/treasurestyles"); |
104 | sprintf (styledirname, "%s", "/styles/treasurestyles"); |
104 | sprintf (stylefilepath, "%s/%s", styledirname, treasure_style); |
105 | sprintf (stylefilepath, "%s/%s", styledirname, treasure_style); |
105 | style_map = find_style (styledirname, treasure_style, -1); |
106 | style_map = find_style (styledirname, treasure_style, -1); |
|
|
107 | |
|
|
108 | if (!style_map) |
|
|
109 | { |
|
|
110 | LOG (llevError, "unable to load style map %s %s.\n", styledirname, treasure_style); |
|
|
111 | return; |
|
|
112 | } |
106 | |
113 | |
107 | /* all the treasure at one spot in the map. */ |
114 | /* all the treasure at one spot in the map. */ |
108 | if (treasureoptions & CONCENTRATED) |
115 | if (treasureoptions & CONCENTRATED) |
109 | { |
116 | { |
110 | |
117 | |
… | |
… | |
660 | *cx = -1; |
667 | *cx = -1; |
661 | *cy = -1; |
668 | *cy = -1; |
662 | } |
669 | } |
663 | } |
670 | } |
664 | |
671 | |
665 | |
|
|
666 | void |
672 | void |
667 | remove_monsters (int x, int y, maptile *map) |
673 | remove_monsters (int x, int y, maptile *map) |
668 | { |
674 | { |
669 | object *tmp; |
675 | object *tmp; |
670 | |
676 | |
671 | for (tmp = GET_MAP_OB (map, x, y); tmp != NULL; tmp = tmp->above) |
677 | for (tmp = GET_MAP_OB (map, x, y); tmp; tmp = tmp->above) |
672 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
678 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
673 | { |
679 | { |
674 | if (tmp->head) |
680 | if (tmp->head) |
675 | tmp = tmp->head; |
681 | tmp = tmp->head; |
676 | tmp->remove (); |
682 | tmp->remove (); |
… | |
… | |
679 | if (tmp == NULL) |
685 | if (tmp == NULL) |
680 | break; |
686 | break; |
681 | }; |
687 | }; |
682 | } |
688 | } |
683 | |
689 | |
684 | |
|
|
685 | /* surrounds the point x,y by doors, so as to enclose something, like |
690 | /* surrounds the point x,y by doors, so as to enclose something, like |
686 | a chest. It only goes as far as the 8 squares surrounding, and |
691 | a chest. It only goes as far as the 8 squares surrounding, and |
687 | it'll remove any monsters it finds.*/ |
692 | it'll remove any monsters it finds.*/ |
688 | |
|
|
689 | object ** |
693 | object ** |
690 | surround_by_doors (maptile *map, char **layout, int x, int y, int opts) |
694 | surround_by_doors (maptile *map, char **layout, int x, int y, int opts) |
691 | { |
695 | { |
692 | int i; |
696 | int i; |
693 | char *doors[2]; |
697 | char *doors[2]; |
… | |
… | |
710 | /* place doors in all the 8 adjacent unblocked squares. */ |
714 | /* place doors in all the 8 adjacent unblocked squares. */ |
711 | for (i = 1; i < 9; i++) |
715 | for (i = 1; i < 9; i++) |
712 | { |
716 | { |
713 | int x1 = x + freearr_x[i], y1 = y + freearr_y[i]; |
717 | int x1 = x + freearr_x[i], y1 = y + freearr_y[i]; |
714 | |
718 | |
715 | if (!wall_blocked (map, x1, y1) || layout[x1][y1] == '>') |
719 | if (!wall_blocked (map, x1, y1) && layout[x1][y1] == '>') |
716 | { /* place a door */ |
720 | { /* place a door */ |
|
|
721 | remove_monsters (x1, y1, map); |
|
|
722 | |
717 | object *new_door = get_archetype ((freearr_x[i] == 0) ? doors[1] : doors[0]); |
723 | object *new_door = get_archetype (freearr_x[i] == 0 ? doors[1] : doors[0]); |
718 | |
724 | map->insert (new_door, x1, y1); |
719 | new_door->x = x + freearr_x[i]; |
|
|
720 | new_door->y = y + freearr_y[i]; |
|
|
721 | remove_monsters (new_door->x, new_door->y, map); |
|
|
722 | insert_ob_in_map (new_door, map, NULL, 0); |
|
|
723 | doorlist[ndoors_made] = new_door; |
725 | doorlist[ndoors_made] = new_door; |
724 | ndoors_made++; |
726 | ndoors_made++; |
725 | } |
727 | } |
726 | } |
728 | } |
|
|
729 | |
727 | return doorlist; |
730 | return doorlist; |
728 | } |
731 | } |
729 | |
732 | |
730 | |
733 | |
731 | /* returns the first door in this square, or NULL if there isn't a door. */ |
734 | /* returns the first door in this square, or NULL if there isn't a door. */ |