* Update the level upon the player's return. * * @param elapsedTime how long the player was away. */
| 605 | * @param elapsedTime how long the player was away. |
| 606 | */ |
| 607 | void update_level(int elapsedTime) |
| 608 | { |
| 609 | ASSERT(!crawl_state.game_is_arena()); |
| 610 | |
| 611 | // Simulate up to 10 turns on the floor, then merely update durations and |
| 612 | // effects for the remaining time. |
| 613 | const int sim_turns = min(10, elapsedTime / 10); |
| 614 | elapsedTime -= sim_turns * 10; |
| 615 | const int quick_turns = (elapsedTime - (sim_turns * 10)) / 10; |
| 616 | |
| 617 | delete_all_clouds(); |
| 618 | |
| 619 | // First, simulate up to 10 turns of monster movement and activity. |
| 620 | simulate_time_passing(sim_turns); |
| 621 | |
| 622 | // Then simply time out effects for the remaining time. |
| 623 | rot_corpses(elapsedTime); |
| 624 | shoals_apply_tides(quick_turns, true); |
| 625 | timeout_tombs(elapsedTime); |
| 626 | timeout_terrain_changes(elapsedTime); |
| 627 | |
| 628 | if (env.sanctuary_time) |
| 629 | { |
| 630 | // XX this doesn't guarantee that the final FPROP will be removed? |
| 631 | if (quick_turns >= env.sanctuary_time) |
| 632 | remove_sanctuary(); |
| 633 | else |
| 634 | env.sanctuary_time -= quick_turns; |
| 635 | } |
| 636 | |
| 637 | dungeon_events.fire_event( |
| 638 | dgn_event(DET_TURN_ELAPSED, coord_def(0, 0), (sim_turns + quick_turns) * 10)); |
| 639 | |
| 640 | for (monster_iterator mi; mi; ++mi) |
| 641 | if (!update_monster(**mi, elapsedTime)) |
| 642 | continue; |
| 643 | } |
| 644 | |
| 645 | /** |
| 646 | * Update the monster upon the player's return |
no test coverage detected