| | 5042 | * Clear the dungeon, ready for generation to begin. |
|---|
| | 5043 | */ |
|---|
| | 5044 | static void clear_cave(void) |
|---|
| | 5045 | { |
|---|
| | 5046 | int x, y; |
|---|
| | 5047 | |
|---|
| | 5048 | wipe_o_list(); |
|---|
| | 5049 | o_max = 1; |
|---|
| | 5050 | |
|---|
| | 5051 | wipe_mon_list(); |
|---|
| | 5052 | mon_max = 1; |
|---|
| | 5053 | |
|---|
| | 5054 | |
|---|
| | 5055 | /* Clear flags and flow information. */ |
|---|
| | 5056 | for (y = 0; y < DUNGEON_HGT; y++) |
|---|
| | 5057 | { |
|---|
| | 5058 | for (x = 0; x < DUNGEON_WID; x++) |
|---|
| | 5059 | { |
|---|
| | 5060 | /* No features */ |
|---|
| | 5061 | cave_feat[y][x] = 0; |
|---|
| | 5062 | |
|---|
| | 5063 | /* No flags */ |
|---|
| | 5064 | cave_info[y][x] = 0; |
|---|
| | 5065 | cave_info2[y][x] = 0; |
|---|
| | 5066 | |
|---|
| | 5067 | /* No flow */ |
|---|
| | 5068 | cave_cost[y][x] = 0; |
|---|
| | 5069 | cave_when[y][x] = 0; |
|---|
| | 5070 | } |
|---|
| | 5071 | } |
|---|
| | 5072 | |
|---|
| | 5073 | /* Mega-Hack -- no player in dungeon yet */ |
|---|
| | 5074 | cave_m_idx[p_ptr->py][p_ptr->px] = 0; |
|---|
| | 5075 | p_ptr->px = p_ptr->py = 0; |
|---|
| | 5076 | |
|---|
| | 5077 | /* Hack -- illegal panel */ |
|---|
| | 5078 | Term->offset_y = DUNGEON_HGT; |
|---|
| | 5079 | Term->offset_x = DUNGEON_WID; |
|---|
| | 5080 | |
|---|
| | 5081 | |
|---|
| | 5082 | /* Nothing special here yet */ |
|---|
| | 5083 | good_item_flag = FALSE; |
|---|
| | 5084 | |
|---|
| | 5085 | /* Nothing good here yet */ |
|---|
| | 5086 | rating = 0; |
|---|
| | 5087 | } |
|---|
| | 5088 | |
|---|
| | 5089 | |
|---|
| | 5090 | /* |
|---|
| | 5091 | * Calculate the level feeling, using a "rating" and the player's depth. |
|---|
| | 5092 | */ |
|---|
| | 5093 | static int calculate_feeling(int rating, int depth) |
|---|
| | 5094 | { |
|---|
| | 5095 | int feeling; |
|---|
| | 5096 | |
|---|
| | 5097 | /* Town gets no feeling */ |
|---|
| | 5098 | if (!depth == 0) return 0; |
|---|
| | 5099 | |
|---|
| | 5100 | |
|---|
| | 5101 | /* Extract the feeling */ |
|---|
| | 5102 | if (rating > 50 + depth ) feeling = 2; |
|---|
| | 5103 | else if (rating > 40 + 4 * depth / 5) feeling = 3; |
|---|
| | 5104 | else if (rating > 30 + 3 * depth / 5) feeling = 4; |
|---|
| | 5105 | else if (rating > 20 + 2 * depth / 5) feeling = 5; |
|---|
| | 5106 | else if (rating > 15 + 1 * depth / 3) feeling = 6; |
|---|
| | 5107 | else if (rating > 10 + 1 * depth / 5) feeling = 7; |
|---|
| | 5108 | else if (rating > 5 + 1 * depth /10) feeling = 8; |
|---|
| | 5109 | else if (rating > 0) feeling = 9; |
|---|
| | 5110 | else feeling = 10; |
|---|
| | 5111 | |
|---|
| | 5112 | /* Hack -- Have a special feeling sometimes */ |
|---|
| | 5113 | if (good_item_flag && OPT(adult_no_preserve)) feeling = 1; |
|---|
| | 5114 | |
|---|
| | 5115 | return feeling; |
|---|
| | 5116 | } |
|---|
| | 5117 | |
|---|
| | 5118 | |
|---|
| | 5119 | /* |
|---|
| 5060 | | /* Generate */ |
|---|
| 5061 | | for (num = 0; TRUE; num++) |
|---|
| 5062 | | { |
|---|
| 5063 | | bool okay = TRUE; |
|---|
| 5064 | | cptr why = NULL; |
|---|
| 5065 | | |
|---|
| 5066 | | /* Reset monsters and objects */ |
|---|
| 5067 | | o_max = 1; |
|---|
| 5068 | | mon_max = 1; |
|---|
| 5069 | | |
|---|
| 5070 | | |
|---|
| 5071 | | /* Clear flags and flow information. */ |
|---|
| 5072 | | for (y = 0; y < DUNGEON_HGT; y++) |
|---|
| 5073 | | { |
|---|
| 5074 | | for (x = 0; x < DUNGEON_WID; x++) |
|---|
| 5075 | | { |
|---|
| 5076 | | /* No flags */ |
|---|
| 5077 | | cave_info[y][x] = 0; |
|---|
| 5078 | | cave_info2[y][x] = 0; |
|---|
| 5079 | | |
|---|
| 5080 | | /* No flow */ |
|---|
| 5081 | | cave_cost[y][x] = 0; |
|---|
| 5082 | | cave_when[y][x] = 0; |
|---|
| 5083 | | } |
|---|
| 5084 | | } |
|---|
| 5085 | | |
|---|
| 5086 | | |
|---|
| 5087 | | /* Mega-Hack -- no player in dungeon yet */ |
|---|
| 5088 | | cave_m_idx[p_ptr->py][p_ptr->px] = 0; |
|---|
| 5089 | | p_ptr->px = p_ptr->py = 0; |
|---|
| 5090 | | |
|---|
| 5091 | | /* Hack -- illegal panel */ |
|---|
| 5092 | | Term->offset_y = DUNGEON_HGT; |
|---|
| 5093 | | Term->offset_x = DUNGEON_WID; |
|---|
| 5094 | | |
|---|
| 5095 | | |
|---|
| 5096 | | /* Nothing special here yet */ |
|---|
| 5097 | | good_item_flag = FALSE; |
|---|
| 5098 | | |
|---|
| 5099 | | /* Nothing good here yet */ |
|---|
| 5100 | | rating = 0; |
|---|
| 5101 | | |
|---|
| 5102 | | /* Build the town */ |
|---|
| 5103 | | if (!p_ptr->depth) |
|---|
| 5104 | | { |
|---|
| 5105 | | /* Make a town */ |
|---|
| | 5129 | while (error) |
|---|
| | 5130 | { |
|---|
| | 5131 | error = NULL; |
|---|
| | 5132 | clear_cave(); |
|---|
| | 5133 | |
|---|
| | 5134 | if (p_ptr->depth == 0) |
|---|
| 5114 | | } |
|---|
| 5115 | | |
|---|
| 5116 | | okay = TRUE; |
|---|
| 5117 | | |
|---|
| 5118 | | |
|---|
| 5119 | | /* Extract the feeling */ |
|---|
| 5120 | | if (rating > 50 + p_ptr->depth ) feeling = 2; |
|---|
| 5121 | | else if (rating > 40 + 4 * p_ptr->depth / 5) feeling = 3; |
|---|
| 5122 | | else if (rating > 30 + 3 * p_ptr->depth / 5) feeling = 4; |
|---|
| 5123 | | else if (rating > 20 + 2 * p_ptr->depth / 5) feeling = 5; |
|---|
| 5124 | | else if (rating > 15 + 1 * p_ptr->depth / 3) feeling = 6; |
|---|
| 5125 | | else if (rating > 10 + 1 * p_ptr->depth / 5) feeling = 7; |
|---|
| 5126 | | else if (rating > 5 + 1 * p_ptr->depth /10) feeling = 8; |
|---|
| 5127 | | else if (rating > 0) feeling = 9; |
|---|
| 5128 | | else feeling = 10; |
|---|
| 5129 | | |
|---|
| 5130 | | /* Hack -- Have a special feeling sometimes */ |
|---|
| 5131 | | if (good_item_flag && adult_no_preserve) feeling = 1; |
|---|