| 72 | } |
| 73 | |
| 74 | void CAI_Space::load(LPCSTR level_name) |
| 75 | { |
| 76 | VERIFY(m_game_graph); |
| 77 | |
| 78 | unload(true); // перезагрузка на одной и тоже локации !!! |
| 79 | |
| 80 | #ifdef DEBUG |
| 81 | Memory.mem_compact(); |
| 82 | u32 mem_usage = Memory.mem_usage(); |
| 83 | CTimer timer; |
| 84 | timer.Start(); |
| 85 | #endif |
| 86 | |
| 87 | const CGameGraph::SLevel& current_level = game_graph().header().level(level_name); |
| 88 | |
| 89 | string_path file_name; |
| 90 | FS.update_path(file_name, "$level$", LEVEL_GRAPH_NAME); |
| 91 | |
| 92 | m_level_graph = xr_new<CLevelGraph>(file_name); |
| 93 | game_graph().set_current_level(current_level.id()); |
| 94 | auto& crossHeader = cross_table().header(); |
| 95 | auto& levelHeader = level_graph().header(); |
| 96 | auto& gameHeader = game_graph().header(); |
| 97 | R_ASSERT(crossHeader.level_guid() == levelHeader.guid(), "cross_table doesn't correspond to the AI-map"); |
| 98 | R_ASSERT(crossHeader.game_guid() == gameHeader.guid(), "graph doesn't correspond to the cross table"); |
| 99 | |
| 100 | u32 vertexCount = _max(gameHeader.vertex_count(), levelHeader.vertex_count()); |
| 101 | m_graph_engine = xr_new<CGraphEngine>(vertexCount); |
| 102 | R_ASSERT(current_level.guid() == levelHeader.guid(), "graph doesn't correspond to the AI-map"); |
| 103 | |
| 104 | #ifdef DEBUG |
| 105 | if (!xr_strcmp(current_level.name(), level_name)) |
| 106 | validate(current_level.id()); |
| 107 | #endif |
| 108 | |
| 109 | level_graph().level_id(current_level.id()); |
| 110 | |
| 111 | m_cover_manager->compute_static_cover(); |
| 112 | |
| 113 | #ifdef DEBUG |
| 114 | Msg("* Loading ai space is successfully completed (%.3fs, %7.3f Mb)", timer.GetElapsed_sec(), float(Memory.mem_usage() - mem_usage) / 1048576.0); |
| 115 | #endif |
| 116 | } |
| 117 | |
| 118 | void CAI_Space::unload(bool reload) |
| 119 | { |
no test coverage detected