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

Function magic_mapping

crawl-ref/source/map-knowledge.cc:434–590  ·  view source on GitHub ↗

Returns true if it succeeded.

Source from the content-addressed store, hash-verified

432
433// Returns true if it succeeded.
434bool magic_mapping(int map_radius, int proportion, bool suppress_msg,
435 bool force, bool deterministic, bool full_info,
436 bool range_falloff, coord_def origin, bool respect_no_automap)
437{
438 if (!force && !is_map_persistent())
439 {
440 if (!suppress_msg)
441 canned_msg(MSG_DISORIENTED);
442
443 return false;
444 }
445
446 if (map_radius < 5)
447 map_radius = 5;
448
449 // now gradually weaker with distance:
450 const int pfar = map_radius * 7 / 10;
451 const int very_far = map_radius * 9 / 10;
452
453 bool did_map = false;
454 int num_altars = 0;
455 int num_shops_portals = 0;
456
457 const FixedArray<uint8_t, GXM, GYM>& difficulty =
458 _tile_difficulties(!deterministic);
459
460 for (radius_iterator ri(in_bounds(origin) ? origin : you.pos(),
461 map_radius, C_SQUARE);
462 ri; ++ri)
463 {
464 coord_def pos = *ri;
465
466 if (respect_no_automap && env.pgrid(pos) & FPROP_NO_AUTOMAP)
467 continue;
468
469 if (range_falloff)
470 {
471 int threshold = proportion;
472
473 const int dist = grid_distance(you.pos(), pos);
474
475 if (dist > very_far)
476 threshold = threshold / 3;
477 else if (dist > pfar)
478 threshold = threshold * 2 / 3;
479
480 if (difficulty(pos) > threshold)
481 continue;
482 }
483
484 map_cell& knowledge = env.map_knowledge(pos);
485
486 if (knowledge.changed())
487 {
488 // If the player has already seen the square, update map
489 // knowledge with the new terrain. Otherwise clear what we had
490 // before.
491 if (knowledge.seen())

Callers 7

_automap_fromFunction · 0.85
wizard_map_levelFunction · 0.85
_xom_divinationFunction · 0.85
readFunction · 0.85
ash_scryingFunction · 0.85
load_levelFunction · 0.85
_do_build_levelFunction · 0.85

Calls 15

is_map_persistentFunction · 0.85
canned_msgFunction · 0.85
in_boundsFunction · 0.85
grid_distanceFunction · 0.85
difficultyFunction · 0.85
feat_is_trapFunction · 0.85
get_trap_typeFunction · 0.85
magic_map_base_featFunction · 0.85
feat_is_solidFunction · 0.85
feat_is_closed_doorFunction · 0.85
map_boundsFunction · 0.85
feat_is_opaqueFunction · 0.85

Tested by

no test coverage detected