| 172 | {} |
| 173 | |
| 174 | MapDataConstPtr MapLoader::LoadMap( const unsigned int map_number ) |
| 175 | { |
| 176 | if( map_number >= 100 ) |
| 177 | return nullptr; |
| 178 | |
| 179 | if( last_loaded_map_ != nullptr && last_loaded_map_->number == map_number ) |
| 180 | return last_loaded_map_; |
| 181 | |
| 182 | Log::Info( "Loading map ", map_number ); |
| 183 | |
| 184 | char level_path[ MapData::c_max_file_path_size ]; |
| 185 | char map_file_name[ MapData::c_max_file_path_size ]; |
| 186 | char resource_file_name[ MapData::c_max_file_path_size ]; |
| 187 | char floors_file_name[ MapData::c_max_file_path_size ]; |
| 188 | char process_file_name[ MapData::c_max_file_path_size ]; |
| 189 | |
| 190 | std::snprintf( level_path, sizeof(level_path), "LEVEL%02u/", map_number ); |
| 191 | std::snprintf( map_file_name, sizeof(map_file_name), "%sMAP.%02u", level_path, map_number ); |
| 192 | std::snprintf( resource_file_name, sizeof(resource_file_name), "%sRESOURCE.%02u", level_path, map_number ); |
| 193 | std::snprintf( floors_file_name, sizeof(floors_file_name), "%sFLOORS.%02u", level_path, map_number ); |
| 194 | std::snprintf( process_file_name, sizeof(process_file_name), "%sPROCESS.%02u", level_path, map_number ); |
| 195 | |
| 196 | const Vfs::FileContent map_file_content= vfs_->ReadFile( map_file_name ); |
| 197 | const Vfs::FileContent resource_file_content= vfs_->ReadFile( resource_file_name ); |
| 198 | const Vfs::FileContent floors_file_content= vfs_->ReadFile( floors_file_name ); |
| 199 | const Vfs::FileContent process_file_content= vfs_->ReadFile( process_file_name ); |
| 200 | |
| 201 | if( map_file_content.empty() || |
| 202 | resource_file_content.empty() || |
| 203 | floors_file_content.empty() || |
| 204 | process_file_content.empty() ) |
| 205 | { |
| 206 | Log::Warning( "Map ", map_number, " not found" ); |
| 207 | return nullptr; |
| 208 | } |
| 209 | |
| 210 | std::snprintf( textures_path_, sizeof(textures_path_), "%sGFX/", level_path ); |
| 211 | std::snprintf( models_path_, sizeof(models_path_), "%s3D/", level_path ); |
| 212 | std::snprintf( animations_path_, sizeof(animations_path_), "%sANI/", level_path ); |
| 213 | |
| 214 | MapDataPtr result= std::make_shared<MapData>(); |
| 215 | |
| 216 | LoadLevelScripts( process_file_content, *result ); |
| 217 | |
| 218 | DynamicWallsMask dynamic_walls_mask; |
| 219 | MarkDynamicWalls( *result, dynamic_walls_mask ); |
| 220 | |
| 221 | for( MapData::IndexElement & el : result->map_index ) |
| 222 | el.type= MapData::IndexElement::None; |
| 223 | |
| 224 | // Scan map file |
| 225 | LoadLightmap( map_file_content, *result ); |
| 226 | const unsigned char* const walls_lightmaps_data= GetWallsLightmapData( map_file_content ); |
| 227 | LoadWalls( map_file_content, *result, dynamic_walls_mask, walls_lightmaps_data ); |
| 228 | LoadFloorsAndCeilings( map_file_content,*result ); |
| 229 | LoadAmbientLight( map_file_content,*result ); |
| 230 | LoadAmbientSoundsMap( map_file_content,*result ); |
| 231 | LoadMonstersAndLights( map_file_content, *result ); |
no test coverage detected