| 78 | } |
| 79 | |
| 80 | bool ExtractTrackTextures(const std::string &track_path, const ::std::string track_name, NFSVer nfs_version) { |
| 81 | std::stringstream output_dir, tex_archive_path; |
| 82 | std::string psh_path = track_path; |
| 83 | std::string full_track_path = track_path + "/" + track_name; |
| 84 | output_dir << TRACK_PATH << ToString(nfs_version) << "/"; |
| 85 | |
| 86 | switch (nfs_version) { |
| 87 | case NFS_2: |
| 88 | tex_archive_path << track_path << "0.qfs"; |
| 89 | break; |
| 90 | case NFS_2_SE: |
| 91 | tex_archive_path << track_path << "0M.qfs"; |
| 92 | break; |
| 93 | case NFS_3: |
| 94 | tex_archive_path << full_track_path << "0.qfs"; |
| 95 | break; |
| 96 | case NFS_3_PS1: |
| 97 | psh_path.replace(psh_path.find("ZZ"), 2, ""); |
| 98 | tex_archive_path << psh_path << "0.PSH"; |
| 99 | break; |
| 100 | case NFS_4: |
| 101 | tex_archive_path << track_path << "/TR0.qfs"; |
| 102 | break; |
| 103 | case UNKNOWN: |
| 104 | default: |
| 105 | ASSERT(false, "Trying to extract track textures from unknown NFS version"); |
| 106 | break; |
| 107 | } |
| 108 | output_dir << track_name; |
| 109 | |
| 110 | if (boost::filesystem::exists(output_dir.str())) { |
| 111 | return true; |
| 112 | } else { |
| 113 | boost::filesystem::create_directories(output_dir.str()); |
| 114 | } |
| 115 | |
| 116 | LOG(INFO) << "Extracting track textures"; |
| 117 | |
| 118 | if (nfs_version == NFS_3_PS1) { |
| 119 | output_dir << "/textures/"; |
| 120 | return Utils::ExtractPSH(tex_archive_path.str(), output_dir.str()); |
| 121 | } else if (nfs_version == NFS_3) { |
| 122 | std::stringstream sky_fsh_path; |
| 123 | sky_fsh_path << full_track_path.substr(0, full_track_path.find_last_of('/')) << "/sky.fsh"; |
| 124 | if (boost::filesystem::exists(sky_fsh_path.str())) { |
| 125 | std::stringstream sky_textures_path; |
| 126 | sky_textures_path << output_dir.str() << "/sky_textures/"; |
| 127 | ASSERT(Utils::ExtractQFS(sky_fsh_path.str(), sky_textures_path.str()), "Unable to extract sky textures from " << sky_fsh_path.str()); |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | output_dir << "/textures/"; |
| 132 | return (Utils::ExtractQFS(tex_archive_path.str(), output_dir.str())); |
| 133 | } |
| 134 | |
| 135 | int hsStockTextureIndexRemap(int textureIndex) { |
| 136 | int remappedIndex = textureIndex; |
no test coverage detected