Returns true if it succeeded.
| 432 | |
| 433 | // Returns true if it succeeded. |
| 434 | bool 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()) |
no test coverage detected