MCPcopy Create free account
hub / github.com/crawl/crawl / _resolve_map_lua

Function _resolve_map_lua

crawl-ref/source/maps.cc:179–221  ·  view source on GitHub ↗

Execute the map's Lua, perform substitutions and other transformations, and validate the map

Source from the content-addressed store, hash-verified

177// Execute the map's Lua, perform substitutions and other transformations,
178// and validate the map
179static bool _resolve_map_lua(map_def &map)
180{
181 _dgn_flush_map_environment_for(map.name);
182 map.reinit();
183
184 string err = map.run_lua(true);
185 if (!err.empty())
186 {
187#ifdef DEBUG_STATISTICS
188 if (crawl_state.map_stat_gen)
189 mapstat_report_error(map, err);
190#endif
191 crawl_state.last_builder_error = err;
192 crawl_state.last_builder_error_fatal = true;
193
194 // Modes like mapstat/objstat that put errors on stderr need to see the
195 // per-iteration seed.
196 string seed_inf = "";
197 if (msg::uses_stderr(MSGCH_ERROR))
198 seed_inf = make_stringf(" in seed %" PRIu64, crawl_state.seed);
199 mprf(MSGCH_ERROR, "Fatal lua error%s: %s", seed_inf.c_str(),
200 err.c_str());
201 // If we're using stderr, we don't have a morgue, so any dlua stack
202 // trace should also go to stderr.
203 if (msg::uses_stderr(MSGCH_ERROR) && !dlua_errors.empty())
204 mprf(MSGCH_ERROR, "\n%s", dlua_errors.back().stack_trace.c_str());
205 return false;
206 }
207
208 map.fixup();
209
210 // this is non-fatal: maps use validation to enforce basic placement
211 // constraints, and a failure here should mean retrying
212 if (!map.test_lua_validate(false))
213 {
214 crawl_state.last_builder_error = make_stringf(
215 "Lua validation for map %s failed.", map.name.c_str());
216 dprf("%s", crawl_state.last_builder_error.c_str());
217 return false;
218 }
219
220 return true;
221}
222
223// Resolve Lua and transformation directives, then mirror and rotate the
224// map if allowed

Callers 2

_resolve_mapFunction · 0.85
resolve_subvaultFunction · 0.85

Calls 11

mapstat_report_errorFunction · 0.85
uses_stderrFunction · 0.85
make_stringfFunction · 0.85
mprfFunction · 0.85
dprfFunction · 0.85
reinitMethod · 0.80
run_luaMethod · 0.80
test_lua_validateMethod · 0.80
emptyMethod · 0.45
fixupMethod · 0.45

Tested by

no test coverage detected