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

Function load_level

crawl-ref/source/files.cc:2087–2536  ·  view source on GitHub ↗

* Load the current level. * * @param stair_taken The means used to enter the level. * @param load_mode Whether the level is being entered, examined, etc. * @return Whether a new level was created. */

Source from the content-addressed store, hash-verified

2085 * @return Whether a new level was created.
2086 */
2087bool load_level(dungeon_feature_type stair_taken, load_mode_type load_mode,
2088 const level_id& old_level)
2089{
2090 const string level_name = level_id::current().describe();
2091 if (!you.save->has_chunk(level_name) && load_mode == LOAD_VISITOR)
2092 return false;
2093
2094 const bool make_changes =
2095 (load_mode == LOAD_START_GAME || load_mode == LOAD_ENTER_LEVEL);
2096
2097#if TAG_MAJOR_VERSION == 34
2098 // fixup saves that don't have this prop initialized.
2099 if (load_mode == LOAD_RESTART_GAME)
2100 _fixup_visited_from_package();
2101#endif
2102
2103 coord_def return_pos; //TODO: initialize to null
2104
2105 string hatch_name = "";
2106 if (feat_is_escape_hatch(stair_taken))
2107 hatch_name = _get_hatch_name();
2108
2109 // Did we get here by popping the level stack?
2110 bool popped = false;
2111 if (load_mode != LOAD_VISITOR)
2112 popped = _leave_level(stair_taken, old_level, &return_pos);
2113
2114 unwind_var<dungeon_feature_type> stair(
2115 you.transit_stair, stair_taken, DNGN_UNSEEN);
2116 unwind_bool ylev(you.entering_level, load_mode != LOAD_VISITOR, false);
2117
2118#ifdef DEBUG_LEVEL_LOAD
2119 mprf(MSGCH_DIAGNOSTICS, "Loading... branch: %d, level: %d",
2120 you.where_are_you, you.depth);
2121#endif
2122
2123 // Save position for hatches to place a marker on the destination level.
2124 coord_def dest_pos = you.pos();
2125
2126 _generic_level_reset();
2127
2128 // We clear twice - on save and on load.
2129 // Once would be enough...
2130 if (make_changes)
2131 delete_all_clouds();
2132
2133 // This block is to grab followers and save the old level to disk.
2134 if (load_mode == LOAD_ENTER_LEVEL)
2135 {
2136 dprf("stair_taken = %s", dungeon_feature_name(stair_taken));
2137 // Not the case normally, but can happen during recovery of damaged
2138 // games.
2139 if (old_level.depth != -1)
2140 {
2141 if (!crawl_state.game_is_descent())
2142 _grab_followers_and_expire_summons();
2143
2144 if (env.level_state & LSTATE_DELETED)

Callers 6

floor_transitionFunction · 0.85
_wizard_go_to_levelFunction · 0.85
wizard_recreate_levelFunction · 0.85
_load_levelFunction · 0.85
LUAFNFunction · 0.85
_post_initFunction · 0.85

Calls 15

feat_is_escape_hatchFunction · 0.85
_get_hatch_nameFunction · 0.85
_leave_levelFunction · 0.85
mprfFunction · 0.85
_generic_level_resetFunction · 0.85
delete_all_cloudsFunction · 0.85
dprfFunction · 0.85
dungeon_feature_nameFunction · 0.85
delete_levelFunction · 0.85
save_levelFunction · 0.85

Tested by

no test coverage detected