| 117 | } |
| 118 | |
| 119 | static map_section_type _write_vault(map_def &mdef, |
| 120 | vault_placement &place, |
| 121 | bool check_place) |
| 122 | { |
| 123 | mdef.load(); |
| 124 | |
| 125 | // Copy the map so we can monkey with it. |
| 126 | place.map = mdef; |
| 127 | place.map.original = &mdef; |
| 128 | |
| 129 | // Try so many times to place the map. This will always succeed |
| 130 | // unless there are conflicting map placements in 'avoid', or there |
| 131 | // is a map validate Lua hook that keeps rejecting the map. |
| 132 | int tries = 25; |
| 133 | |
| 134 | while (tries-- > 0) |
| 135 | { |
| 136 | // We're a regular vault, so clear the subvault stack. |
| 137 | clear_subvault_stack(); |
| 138 | |
| 139 | if (place.map.test_lua_veto()) |
| 140 | break; |
| 141 | |
| 142 | if (!_resolve_map(place.map)) |
| 143 | { |
| 144 | // for most fatal errors, there's no point in trying again. (This |
| 145 | // isn't 100% true, e.g. an error in an itemspec that's hidden |
| 146 | // behind a random roll may fix itself. But it's true enough that |
| 147 | // it's better on average to consider this map bugged and move |
| 148 | // on to another one in normal generation.) |
| 149 | if (crawl_state.last_builder_error_fatal) |
| 150 | break; |
| 151 | else |
| 152 | continue; |
| 153 | } |
| 154 | |
| 155 | // Must set size here, or minivaults will not be placed correctly. |
| 156 | place.size = place.map.size(); |
| 157 | place.orient = _apply_vault_definition(place.map, |
| 158 | place, check_place); |
| 159 | |
| 160 | if (place.orient != MAP_NONE) |
| 161 | return place.orient; |
| 162 | } |
| 163 | return MAP_NONE; |
| 164 | } |
| 165 | |
| 166 | static void _dgn_flush_map_environments() |
| 167 | { |
no test coverage detected