| 488 | // TRACK |
| 489 | template<typename Platform> |
| 490 | shared_ptr<typename Platform::TRACK> NFS2<Platform>::LoadTrack(const std::string &track_base_path) { |
| 491 | LOG(INFO) << "Loading Track located at " << track_base_path; |
| 492 | shared_ptr<typename Platform::TRACK> track(new typename Platform::TRACK()); |
| 493 | |
| 494 | boost::filesystem::path p(track_base_path); |
| 495 | track->name = p.filename().string(); |
| 496 | stringstream trk_path, col_path, can_path; |
| 497 | |
| 498 | trk_path << track_base_path << ".TRK"; |
| 499 | col_path << track_base_path << ".COL"; |
| 500 | |
| 501 | NFSVer nfs_version = UNKNOWN; |
| 502 | |
| 503 | if (std::is_same<Platform, PC>::value) { |
| 504 | if (track_base_path.find(ToString(NFS_2_SE)) != std::string::npos) { |
| 505 | nfs_version = NFS_2_SE; |
| 506 | } else { |
| 507 | nfs_version = NFS_2; |
| 508 | } |
| 509 | can_path << RESOURCE_PATH << ToString(nfs_version) << "/GAMEDATA/TRACKS/DATA/PC/" << track->name << "00.CAN"; |
| 510 | ASSERT(TrackUtils::LoadCAN(can_path.str(), track->cameraAnimation), "Could not load CAN file (camera animation): " << can_path.str()); // Load camera intro/outro animation data |
| 511 | } else if (std::is_same<Platform, PS1>::value) { |
| 512 | nfs_version = NFS_3_PS1; |
| 513 | std::string ps1_col_path = col_path.str(); |
| 514 | ps1_col_path.replace(ps1_col_path.find("ZZ"), 2, ""); |
| 515 | col_path.str(std::string()); |
| 516 | col_path << ps1_col_path; |
| 517 | } |
| 518 | |
| 519 | ASSERT(LoadTRK(trk_path.str(), track), "Could not load TRK file: " << trk_path.str()); // Load TRK file to get track block specific data |
| 520 | ASSERT(LoadCOL(col_path.str(), track), "Could not load COL file: " << col_path.str()); // Load Catalogue file to get global (non trkblock specific) data |
| 521 | ASSERT(TrackUtils::ExtractTrackTextures(track_base_path, track->name, nfs_version), "Could not extract " << track->name << " texture pack."); |
| 522 | |
| 523 | // Load up the textures |
| 524 | for (uint32_t tex_Idx = 0; tex_Idx < track->nTextures; tex_Idx++) { |
| 525 | track->textures[track->polyToQFStexTable[tex_Idx].texNumber] = LoadTexture(track->polyToQFStexTable[tex_Idx], track->name, nfs_version); |
| 526 | } |
| 527 | |
| 528 | track->textureArrayID = TrackUtils::MakeTextureArray(track->textures, false); |
| 529 | ParseTRKModels(track); |
| 530 | track->global_objects = ParseCOLModels(track); |
| 531 | |
| 532 | LOG(INFO) << "Track loaded successfully"; |
| 533 | return track; |
| 534 | } |
| 535 | |
| 536 | template<typename Platform> |
| 537 | bool NFS2<Platform>::LoadTRK(std::string trk_path, const shared_ptr<typename Platform::TRACK> &track) { |
nothing calls this directly
no test coverage detected