diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/mesh_extractor/MPQManager.cpp | 1 | ||||
-rw-r--r-- | src/tools/mesh_extractor/MeshExtractor.cpp | 2 | ||||
-rw-r--r-- | src/tools/mesh_extractor/Utils.cpp | 22 |
3 files changed, 20 insertions, 5 deletions
diff --git a/src/tools/mesh_extractor/MPQManager.cpp b/src/tools/mesh_extractor/MPQManager.cpp index e1ce4b92bf9..facd96a28f0 100644 --- a/src/tools/mesh_extractor/MPQManager.cpp +++ b/src/tools/mesh_extractor/MPQManager.cpp @@ -109,5 +109,6 @@ FILE* MPQManager::GetFileFrom(const std::string& path, MPQArchive* file ) exit(1); } fwrite(buffer, sizeof(uint8), size, ret); + fseek(ret, 0, SEEK_SET); return ret; } diff --git a/src/tools/mesh_extractor/MeshExtractor.cpp b/src/tools/mesh_extractor/MeshExtractor.cpp index fe4716da326..0d9160a610b 100644 --- a/src/tools/mesh_extractor/MeshExtractor.cpp +++ b/src/tools/mesh_extractor/MeshExtractor.cpp @@ -76,7 +76,7 @@ void ExtractDBCs() std::string component = "component.wow-" + std::string(MPQManager::Languages[*itr]) + ".txt"; // Extract the component file - Utils::SaveToDisk(MPQHandler->GetFile(component), path + component); + Utils::SaveToDisk(MPQHandler->GetFileFrom(component, MPQHandler->LocaleFiles[*itr]), path + component); // Extract the DBC files for the given locale for (std::set<std::string>::iterator itr2 = DBCFiles.begin(); itr2 != DBCFiles.end(); ++itr2) Utils::SaveToDisk(MPQHandler->GetFileFrom(*itr2, MPQHandler->LocaleFiles[*itr]), path + (itr2->c_str() + folderLen)); diff --git a/src/tools/mesh_extractor/Utils.cpp b/src/tools/mesh_extractor/Utils.cpp index e7ffc0ed919..24cfb5cd1db 100644 --- a/src/tools/mesh_extractor/Utils.cpp +++ b/src/tools/mesh_extractor/Utils.cpp @@ -173,24 +173,38 @@ void Utils::SaveToDisk( FILE* stream, const std::string& path ) if (!disk) { printf("SaveToDisk: Could not save file %s to disk, please verify that you have write permissions on that directory\n", path.c_str()); + fclose(stream); return; } uint32 size = Utils::Size(stream); uint8* data = new uint8[size]; // Read the data to an array - if (fread(data, 1, size, stream) != 1) + size_t read = fread(data, size, 1, stream); + if (read != 1) { - printf("SaveToDisk: Error reading from Stream while trying to save file %s to disck.\n", path.c_str()); + printf("SaveToDisk: Error reading from Stream while trying to save file %s to disk.\n", path.c_str()); + fclose(disk); + fclose(stream); return; } + // And write it in the file - fwrite(data, 1, size, disk); + size_t wrote = fwrite(data, size, 1, disk); + if (wrote != 1) + { + printf("SaveToDisk: Error writing to the file while trying to save %s to disk.\n", path.c_str()); + fclose(stream); + fclose(disk); + return; + } // Close the filestream fclose(disk); + fclose(stream); + // Free the used memory - delete [] data; + delete[] data; } Vector3 Utils::ToWoWCoords(const Vector3& vec ) |