--- deliantra/server/random_maps/treasure.C 2007/01/18 19:42:10 1.21 +++ deliantra/server/random_maps/treasure.C 2007/01/19 21:49:58 1.22 @@ -76,6 +76,7 @@ if (treasure_style) if (!strcmp (treasure_style, "none")) return; + if (treasureoptions <= 0) treasureoptions = RANDOM () % (2 * LAST_OPTION); @@ -662,13 +663,12 @@ } } - void remove_monsters (int x, int y, maptile *map) { object *tmp; - for (tmp = GET_MAP_OB (map, x, y); tmp != NULL; tmp = tmp->above) + for (tmp = GET_MAP_OB (map, x, y); tmp; tmp = tmp->above) if (QUERY_FLAG (tmp, FLAG_ALIVE)) { if (tmp->head) @@ -681,11 +681,9 @@ }; } - /* surrounds the point x,y by doors, so as to enclose something, like a chest. It only goes as far as the 8 squares surrounding, and it'll remove any monsters it finds.*/ - object ** surround_by_doors (maptile *map, char **layout, int x, int y, int opts) { @@ -712,18 +710,17 @@ { int x1 = x + freearr_x[i], y1 = y + freearr_y[i]; - if (!wall_blocked (map, x1, y1) || layout[x1][y1] == '>') + if (!wall_blocked (map, x1, y1) && layout[x1][y1] == '>') { /* place a door */ - object *new_door = get_archetype ((freearr_x[i] == 0) ? doors[1] : doors[0]); + remove_monsters (x1, y1, map); - new_door->x = x + freearr_x[i]; - new_door->y = y + freearr_y[i]; - remove_monsters (new_door->x, new_door->y, map); - insert_ob_in_map (new_door, map, NULL, 0); + object *new_door = get_archetype (freearr_x[i] == 0 ? doors[1] : doors[0]); + map->insert (new_door, x1, y1); doorlist[ndoors_made] = new_door; ndoors_made++; } } + return doorlist; }