ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/random_maps/treasure.C
(Generate patch)

Comparing deliantra/server/random_maps/treasure.C (file contents):
Revision 1.21 by root, Thu Jan 18 19:42:10 2007 UTC vs.
Revision 1.22 by root, Fri Jan 19 21:49:58 2007 UTC

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))
660 *cx = -1; 661 *cx = -1;
661 *cy = -1; 662 *cy = -1;
662 } 663 }
663} 664}
664 665
665
666void 666void
667remove_monsters (int x, int y, maptile *map) 667remove_monsters (int x, int y, maptile *map)
668{ 668{
669 object *tmp; 669 object *tmp;
670 670
671 for (tmp = GET_MAP_OB (map, x, y); tmp != NULL; tmp = tmp->above) 671 for (tmp = GET_MAP_OB (map, x, y); tmp; tmp = tmp->above)
672 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 672 if (QUERY_FLAG (tmp, FLAG_ALIVE))
673 { 673 {
674 if (tmp->head) 674 if (tmp->head)
675 tmp = tmp->head; 675 tmp = tmp->head;
676 tmp->remove (); 676 tmp->remove ();
679 if (tmp == NULL) 679 if (tmp == NULL)
680 break; 680 break;
681 }; 681 };
682} 682}
683 683
684
685/* surrounds the point x,y by doors, so as to enclose something, like 684/* 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 685 a chest. It only goes as far as the 8 squares surrounding, and
687 it'll remove any monsters it finds.*/ 686 it'll remove any monsters it finds.*/
688
689object ** 687object **
690surround_by_doors (maptile *map, char **layout, int x, int y, int opts) 688surround_by_doors (maptile *map, char **layout, int x, int y, int opts)
691{ 689{
692 int i; 690 int i;
693 char *doors[2]; 691 char *doors[2];
710 /* place doors in all the 8 adjacent unblocked squares. */ 708 /* place doors in all the 8 adjacent unblocked squares. */
711 for (i = 1; i < 9; i++) 709 for (i = 1; i < 9; i++)
712 { 710 {
713 int x1 = x + freearr_x[i], y1 = y + freearr_y[i]; 711 int x1 = x + freearr_x[i], y1 = y + freearr_y[i];
714 712
715 if (!wall_blocked (map, x1, y1) || layout[x1][y1] == '>') 713 if (!wall_blocked (map, x1, y1) && layout[x1][y1] == '>')
716 { /* place a door */ 714 { /* place a door */
715 remove_monsters (x1, y1, map);
716
717 object *new_door = get_archetype ((freearr_x[i] == 0) ? doors[1] : doors[0]); 717 object *new_door = get_archetype (freearr_x[i] == 0 ? doors[1] : doors[0]);
718 718 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; 719 doorlist[ndoors_made] = new_door;
724 ndoors_made++; 720 ndoors_made++;
725 } 721 }
726 } 722 }
723
727 return doorlist; 724 return doorlist;
728} 725}
729 726
730 727
731/* returns the first door in this square, or NULL if there isn't a door. */ 728/* returns the first door in this square, or NULL if there isn't a door. */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines