diff options
-rw-r--r-- | src/common/Debugging/WheatyExceptionReport.cpp | 46 | ||||
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 8 | ||||
-rw-r--r-- | src/tools/mmaps_generator/IntermediateValues.cpp | 81 | ||||
-rw-r--r-- | src/tools/mmaps_generator/MapBuilder.cpp | 23 | ||||
-rw-r--r-- | src/tools/mmaps_generator/TerrainBuilder.cpp | 12 | ||||
-rw-r--r-- | src/tools/vmap4_extractor/model.cpp | 36 | ||||
-rw-r--r-- | src/tools/vmap4_extractor/vmapexport.cpp | 11 | ||||
-rw-r--r-- | src/tools/vmap4_extractor/wmo.cpp | 7 |
8 files changed, 93 insertions, 131 deletions
diff --git a/src/common/Debugging/WheatyExceptionReport.cpp b/src/common/Debugging/WheatyExceptionReport.cpp index ab851a7d2e5..434d9cd1e07 100644 --- a/src/common/Debugging/WheatyExceptionReport.cpp +++ b/src/common/Debugging/WheatyExceptionReport.cpp @@ -41,7 +41,7 @@ inline LPTSTR ErrorMessage(DWORD dw) else { LPTSTR msgBuf = (LPTSTR)LocalAlloc(LPTR, 30); - sprintf(msgBuf, "Unknown error: %u", dw); + snprintf(msgBuf, 30, "Unknown error: %u", dw); return msgBuf; } @@ -125,7 +125,7 @@ PEXCEPTION_POINTERS pExceptionInfo) ++pos; TCHAR crash_folder_path[MAX_PATH]; - sprintf_s(crash_folder_path, "%s\\%s", module_folder_name, CrashFolder); + _stprintf_s(crash_folder_path, "%s\\%s", module_folder_name, CrashFolder); if (!CreateDirectory(crash_folder_path, nullptr)) { if (GetLastError() != ERROR_ALREADY_EXISTS) @@ -134,10 +134,10 @@ PEXCEPTION_POINTERS pExceptionInfo) SYSTEMTIME systime; GetLocalTime(&systime); - sprintf(m_szDumpFileName, "%s\\%s_%s_[%u-%u_%u-%u-%u].dmp", + _stprintf_s(m_szDumpFileName, "%s\\%s_%s_[%u-%u_%u-%u-%u].dmp", crash_folder_path, GitRevision::GetHash(), pos, systime.wDay, systime.wMonth, systime.wHour, systime.wMinute, systime.wSecond); - _stprintf(m_szLogFileName, _T("%s\\%s_%s_[%u-%u_%u-%u-%u].txt"), + _stprintf_s(m_szLogFileName, _T("%s\\%s_%s_[%u-%u_%u-%u-%u].txt"), crash_folder_path, GitRevision::GetHash(), pos, systime.wDay, systime.wMonth, systime.wHour, systime.wMinute, systime.wSecond); m_hDumpFile = CreateFile(m_szDumpFileName, @@ -375,13 +375,13 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax) lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009"), 0, KEY_QUERY_VALUE, &hKey); if (lRet == ERROR_SUCCESS) { - _stprintf(wszTmp, _T("Service Pack 6a (Version %d.%d, Build %d)"), + _stprintf_s(wszTmp, _T("Service Pack 6a (Version %d.%d, Build %d)"), osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); _tcsncat(szVersion, wszTmp, cntMax); } else // Windows NT 4.0 prior to SP6a { - _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"), + _stprintf_s(wszTmp, _T("%s (Version %d.%d, Build %d)"), szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); _tcsncat(szVersion, wszTmp, cntMax); } @@ -390,17 +390,17 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax) else // Windows NT 3.51 and earlier or Windows 2000 and later { if (!_tcslen(szCSDVersion)) - _stprintf(wszTmp, _T("(Version %d.%d, Build %d)"), + _stprintf_s(wszTmp, _T("(Version %d.%d, Build %d)"), osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); else - _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"), + _stprintf_s(wszTmp, _T("%s (Version %d.%d, Build %d)"), szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); _tcsncat(szVersion, wszTmp, cntMax); } break; } default: - _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"), + _stprintf_s(wszTmp, _T("%s (Version %d.%d, Build %d)"), szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); _tcsncat(szVersion, wszTmp, cntMax); break; @@ -1736,50 +1736,50 @@ size_t countOverride) else length = strlen((char*)pAddress); if (length > bufferSize - 6) - pszCurrBuffer += sprintf(pszCurrBuffer, "\"%.*s...\"", (DWORD)(bufferSize - 6), (char*)pAddress); + pszCurrBuffer += snprintf(pszCurrBuffer, bufferSize, "\"%.*s...\"", (int)(bufferSize - 6), (char*)pAddress); else - pszCurrBuffer += sprintf(pszCurrBuffer, "\"%.*s\"", (DWORD)length, (char*)pAddress); + pszCurrBuffer += snprintf(pszCurrBuffer, bufferSize, "\"%.*s\"", (int)length, (char*)pAddress); break; } case btStdString: { std::string* value = static_cast<std::string*>(pAddress); if (value->length() > bufferSize - 6) - pszCurrBuffer += sprintf(pszCurrBuffer, "\"%.*s...\"", (DWORD)(bufferSize - 6), value->c_str()); + pszCurrBuffer += snprintf(pszCurrBuffer, bufferSize, "\"%.*s...\"", (int)(bufferSize - 6), value->c_str()); else - pszCurrBuffer += sprintf(pszCurrBuffer, "\"%s\"", value->c_str()); + pszCurrBuffer += snprintf(pszCurrBuffer, bufferSize, "\"%s\"", value->c_str()); break; } default: // Format appropriately (assuming it's a 1, 2, or 4 bytes (!!!) if (length == 1) - pszCurrBuffer += sprintf(pszCurrBuffer, "0x%X", *(PBYTE)pAddress); + pszCurrBuffer += snprintf(pszCurrBuffer, bufferSize, "0x%X", *(PBYTE)pAddress); else if (length == 2) - pszCurrBuffer += sprintf(pszCurrBuffer, "0x%X", *(PWORD)pAddress); + pszCurrBuffer += snprintf(pszCurrBuffer, bufferSize, "0x%X", *(PWORD)pAddress); else if (length == 4) { if (basicType == btFloat) - pszCurrBuffer += sprintf(pszCurrBuffer, "%f", *(PFLOAT)pAddress); + pszCurrBuffer += snprintf(pszCurrBuffer, bufferSize, "%f", *(PFLOAT)pAddress); else - pszCurrBuffer += sprintf(pszCurrBuffer, "0x%X", *(PDWORD)pAddress); + pszCurrBuffer += snprintf(pszCurrBuffer, bufferSize, "0x%X", *(PDWORD)pAddress); } else if (length == 8) { if (basicType == btFloat) { - pszCurrBuffer += sprintf(pszCurrBuffer, "%f", + pszCurrBuffer += snprintf(pszCurrBuffer, bufferSize, "%f", *(double *)pAddress); } else - pszCurrBuffer += sprintf(pszCurrBuffer, "0x%I64X", + pszCurrBuffer += snprintf(pszCurrBuffer, bufferSize, "0x%I64X", *(DWORD64*)pAddress); } else { #if _WIN64 - pszCurrBuffer += sprintf(pszCurrBuffer, "0x%I64X", (DWORD64)pAddress); + pszCurrBuffer += snprintf(pszCurrBuffer, bufferSize, "0x%I64X", (DWORD64)pAddress); #else - pszCurrBuffer += sprintf(pszCurrBuffer, "0x%X", (DWORD)pAddress); + pszCurrBuffer += snprintf(pszCurrBuffer, bufferSize, "0x%X", (DWORD)pAddress); #endif } break; @@ -1788,9 +1788,9 @@ size_t countOverride) __except (EXCEPTION_EXECUTE_HANDLER) { #if _WIN64 - pszCurrBuffer += sprintf(pszCurrBuffer, "0x%I64X <Unable to read memory>", (DWORD64)pAddress); + pszCurrBuffer += snprintf(pszCurrBuffer, bufferSize, "0x%I64X <Unable to read memory>", (DWORD64)pAddress); #else - pszCurrBuffer += sprintf(pszCurrBuffer, "0x%X <Unable to read memory>", (DWORD)pAddress); + pszCurrBuffer += snprintf(pszCurrBuffer, bufferSize, "0x%X <Unable to read memory>", (DWORD)pAddress); #endif } } diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 44ed1ca4109..53ea653ca73 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -139,9 +139,7 @@ std::string GetScriptCommandName(ScriptCommands command) case SCRIPT_COMMAND_PLAY_ANIMKIT: res = "SCRIPT_COMMAND_PLAY_ANIMKIT"; break; default: { - char sz[32]; - sprintf(sz, "Unknown command: %d", command); - res = sz; + res = Trinity::StringFormat("Unknown command: {}", command); break; } } @@ -150,9 +148,7 @@ std::string GetScriptCommandName(ScriptCommands command) std::string ScriptInfo::GetDebugInfo() const { - char sz[256]; - sprintf(sz, "%s ('%s' script id: %u)", GetScriptCommandName(command).c_str(), GetScriptsTableNameByType(type).c_str(), id); - return std::string(sz); + return Trinity::StringFormat("{} ('{}' script id: {})", GetScriptCommandName(command), GetScriptsTableNameByType(type), id); } bool normalizePlayerName(std::string& name) diff --git a/src/tools/mmaps_generator/IntermediateValues.cpp b/src/tools/mmaps_generator/IntermediateValues.cpp index 10e2bff30f0..068ae951c46 100644 --- a/src/tools/mmaps_generator/IntermediateValues.cpp +++ b/src/tools/mmaps_generator/IntermediateValues.cpp @@ -16,6 +16,7 @@ */ #include "IntermediateValues.h" +#include "StringFormat.h" namespace MMAP { @@ -30,42 +31,32 @@ namespace MMAP void IntermediateValues::writeIV(uint32 mapID, uint32 tileX, uint32 tileY) { - char fileName[255]; - char tileString[25]; - sprintf(tileString, "[%02u,%02u]: ", tileX, tileY); - - printf("%sWriting debug output... \r", tileString); - - std::string name("meshes/%04u%02i%02i."); - -#define DEBUG_WRITE(fileExtension,data) \ - do { \ - sprintf(fileName, (name + fileExtension).c_str(), mapID, tileY, tileX); \ - FILE* file = fopen(fileName, "wb"); \ - if (!file) \ - { \ - char message[1024]; \ - sprintf(message, "%sFailed to open %s for writing!\n", tileString, fileName); \ - perror(message); \ - } \ - else \ - debugWrite(file, data); \ - if (file) fclose(file); \ - printf("%sWriting debug output... \r", tileString); \ - } while (false) + std::string tileString = Trinity::StringFormat("[{:02},{:02}]: ", tileX, tileY); + + printf("%sWriting debug output... \r", tileString.c_str()); + + auto debugWrite = [&](char const* extension, auto const* data) + { + std::string fileName = Trinity::StringFormat("meshes/{:04}{:02}{:02}.{}", mapID, tileY, tileX, extension); + if (FILE* file = fopen(fileName.c_str(), "wb")) + { + this->debugWrite(file, data); + fclose(file); + } + else + perror(Trinity::StringFormat("{}Failed to open {} for writing!\n", tileString, fileName).c_str()); + }; if (heightfield) - DEBUG_WRITE("hf", heightfield); + debugWrite("hf", heightfield); if (compactHeightfield) - DEBUG_WRITE("chf", compactHeightfield); + debugWrite("chf", compactHeightfield); if (contours) - DEBUG_WRITE("cs", contours); + debugWrite("cs", contours); if (polyMesh) - DEBUG_WRITE("pmesh", polyMesh); + debugWrite("pmesh", polyMesh); if (polyMeshDetail) - DEBUG_WRITE("dmesh", polyMeshDetail); - -#undef DEBUG_WRITE + debugWrite("dmesh", polyMeshDetail); } void IntermediateValues::debugWrite(FILE* file, rcHeightfield const* mesh) @@ -200,15 +191,13 @@ namespace MMAP void IntermediateValues::generateObjFile(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData) { - char objFileName[255]; - sprintf(objFileName, "meshes/map%04u%02u%02u.obj", mapID, tileY, tileX); + std::string objFileName; + objFileName = Trinity::StringFormat("meshes/map{:04}{:02}{:02}.obj", mapID, tileY, tileX); - FILE* objFile = fopen(objFileName, "wb"); + FILE* objFile = fopen(objFileName.c_str(), "wb"); if (!objFile) { - char message[1024]; - sprintf(message, "Failed to open %s for writing!\n", objFileName); - perror(message); + perror(Trinity::StringFormat("Failed to open {} for writing!\n", objFileName).c_str()); return; } @@ -233,18 +222,14 @@ namespace MMAP fclose(objFile); - char tileString[25]; - sprintf(tileString, "[%02u,%02u]: ", tileY, tileX); - printf("%sWriting debug output... \r", tileString); + printf("[%02u,%02u]: Writing debug output... \r", tileY, tileX); - sprintf(objFileName, "meshes/%04u.map", mapID); + objFileName = Trinity::StringFormat("meshes/map{:04}.map", mapID); - objFile = fopen(objFileName, "wb"); + objFile = fopen(objFileName.c_str(), "wb"); if (!objFile) { - char message[1024]; - sprintf(message, "Failed to open %s for writing!\n", objFileName); - perror(message); + perror(Trinity::StringFormat("Failed to open {} for writing!\n", objFileName).c_str()); return; } @@ -252,13 +237,11 @@ namespace MMAP fwrite(&b, sizeof(char), 1, objFile); fclose(objFile); - sprintf(objFileName, "meshes/%04u%02u%02u.mesh", mapID, tileY, tileX); - objFile = fopen(objFileName, "wb"); + objFileName = Trinity::StringFormat("meshes/map{:04}{:02}{:02}.mesh", mapID, tileY, tileX); + objFile = fopen(objFileName.c_str(), "wb"); if (!objFile) { - char message[1024]; - sprintf(message, "Failed to open %s for writing!\n", objFileName); - perror(message); + perror(Trinity::StringFormat("Failed to open {} for writing!\n", objFileName).c_str()); return; } diff --git a/src/tools/mmaps_generator/MapBuilder.cpp b/src/tools/mmaps_generator/MapBuilder.cpp index 778377e2af1..7af217acc9b 100644 --- a/src/tools/mmaps_generator/MapBuilder.cpp +++ b/src/tools/mmaps_generator/MapBuilder.cpp @@ -615,17 +615,14 @@ namespace MMAP return; } - char fileName[25]; - sprintf(fileName, "mmaps/%04u.mmap", mapID); + std::string fileName = Trinity::StringFormat("mmaps/{:04}.mmap", mapID); - FILE* file = fopen(fileName, "wb"); + FILE* file = fopen(fileName.c_str(), "wb"); if (!file) { dtFreeNavMesh(navMesh); navMesh = nullptr; - char message[1024]; - sprintf(message, "[Map %04u] Failed to open %s for writing!\n", mapID, fileName); - perror(message); + perror(Trinity::StringFormat("[Map {:04}] Failed to open {} for writing!\n", mapID, fileName).c_str()); return; } @@ -929,14 +926,11 @@ namespace MMAP } // file output - char fileName[255]; - sprintf(fileName, "mmaps/%04u%02i%02i.mmtile", mapID, tileY, tileX); - FILE* file = fopen(fileName, "wb"); + std::string fileName = Trinity::StringFormat("mmaps/{:04}{:02}{:02}.mmtile", mapID, tileY, tileX); + FILE* file = fopen(fileName.c_str(), "wb"); if (!file) { - char message[1024]; - sprintf(message, "[Map %04u] Failed to open %s for writing!\n", mapID, fileName); - perror(message); + perror(Trinity::StringFormat("[Map {:04}] Failed to open {} for writing!\n", mapID, fileName).c_str()); navMesh->removeTile(tileRef, nullptr, nullptr); break; } @@ -1073,9 +1067,8 @@ namespace MMAP /**************************************************************************/ bool TileBuilder::shouldSkipTile(uint32 mapID, uint32 tileX, uint32 tileY) const { - char fileName[255]; - sprintf(fileName, "mmaps/%04u%02i%02i.mmtile", mapID, tileY, tileX); - FILE* file = fopen(fileName, "rb"); + std::string fileName = Trinity::StringFormat("mmaps/{:04}{:02}{:02}.mmtile", mapID, tileY, tileX); + FILE* file = fopen(fileName.c_str(), "rb"); if (!file) return false; diff --git a/src/tools/mmaps_generator/TerrainBuilder.cpp b/src/tools/mmaps_generator/TerrainBuilder.cpp index fd2a6d862fa..e501af2099c 100644 --- a/src/tools/mmaps_generator/TerrainBuilder.cpp +++ b/src/tools/mmaps_generator/TerrainBuilder.cpp @@ -21,6 +21,7 @@ #include "MapTree.h" #include "MMapDefines.h" #include "ModelInstance.h" +#include "StringFormat.h" #include "Util.h" #include "VMapManager2.h" #include <map> @@ -78,17 +79,16 @@ namespace MMAP /**************************************************************************/ bool TerrainBuilder::loadMap(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData, Spot portion) { - char mapFileName[255]; - sprintf(mapFileName, "maps/%04u_%02u_%02u.map", mapID, tileY, tileX); + std::string mapFileName = Trinity::StringFormat("maps/{:04}_{:02}_{:02}.map", mapID, tileY, tileX); - FILE* mapFile = fopen(mapFileName, "rb"); + FILE* mapFile = fopen(mapFileName.c_str(), "rb"); if (!mapFile) { int32 parentMapId = sMapStore[mapID].ParentMapID; while (!mapFile && parentMapId != -1) { - sprintf(mapFileName, "maps/%04d_%02u_%02u.map", parentMapId, tileY, tileX); - mapFile = fopen(mapFileName, "rb"); + mapFileName = Trinity::StringFormat("maps/{:04}_{:02}_{:02}.map", parentMapId, tileY, tileX); + mapFile = fopen(mapFileName.c_str(), "rb"); parentMapId = sMapStore[parentMapId].ParentMapID; } } @@ -101,7 +101,7 @@ namespace MMAP fheader.versionMagic != MapVersionMagic) { fclose(mapFile); - printf("%s is the wrong version, please extract new .map files\n", mapFileName); + printf("%s is the wrong version, please extract new .map files\n", mapFileName.c_str()); return false; } diff --git a/src/tools/vmap4_extractor/model.cpp b/src/tools/vmap4_extractor/model.cpp index a2608c6c6e7..9c8d3f5ac6b 100644 --- a/src/tools/vmap4_extractor/model.cpp +++ b/src/tools/vmap4_extractor/model.cpp @@ -18,6 +18,7 @@ #include "vmapexport.h" #include "Errors.h" #include "model.h" +#include "StringFormat.h" #include "wmo.h" #include "adtfile.h" #include "cascfile.h" @@ -155,9 +156,8 @@ Vec3D fixCoordSystem(Vec3D const& v) void Doodad::Extract(ADT::MDDF const& doodadDef, char const* ModelInstName, uint32 mapID, uint32 originalMapId, FILE* pDirfile, std::vector<ADTOutputCache>* dirfileCache) { - char tempname[1036]; - sprintf(tempname, "%s/%s", szWorkDirWmo, ModelInstName); - FILE* input = fopen(tempname, "r+b"); + std::string tempname = Trinity::StringFormat("{}/{}", szWorkDirWmo, ModelInstName); + FILE* input = fopen(tempname.c_str(), "r+b"); if (!input) return; @@ -243,29 +243,21 @@ void Doodad::ExtractSet(WMODoodadData const& doodadData, ADT::MODF const& wmo, b WMO::MODD const& doodad = doodadData.Spawns[doodadIndex]; - char ModelInstName[1024]; + std::string ModelInstName; if (doodadData.Paths) - sprintf(ModelInstName, "%s", GetPlainName(&doodadData.Paths[doodad.NameIndex])); + ModelInstName = GetPlainName(&doodadData.Paths[doodad.NameIndex]); else if (doodadData.FileDataIds) - sprintf(ModelInstName, "FILE%08X.xxx", doodadData.FileDataIds[doodad.NameIndex]); + ModelInstName = Trinity::StringFormat("FILE{:08X}.xxx", doodadData.FileDataIds[doodad.NameIndex]); else ASSERT(false); - uint32 nlen = strlen(ModelInstName); - NormalizeFileName(ModelInstName, nlen); - if (nlen > 3) - { - char const* extension = &ModelInstName[nlen - 4]; - if (!strcmp(extension, ".mdx") || !strcmp(extension, ".mdl")) - { - ModelInstName[nlen - 2] = '2'; - ModelInstName[nlen - 1] = '\0'; - } - } + uint32 nlen = ModelInstName.length(); + NormalizeFileName(ModelInstName.data(), nlen); + if (ModelInstName.ends_with(".mdx") || ModelInstName.ends_with(".mdl")) + ModelInstName.replace(ModelInstName.length() - 2, 2, "2"); - char tempname[1036]; - sprintf(tempname, "%s/%s", szWorkDirWmo, ModelInstName); - FILE* input = fopen(tempname, "r+b"); + std::string tempname = Trinity::StringFormat("{}/{}", szWorkDirWmo, ModelInstName); + FILE* input = fopen(tempname.c_str(), "r+b"); if (!input) continue; @@ -306,7 +298,7 @@ void Doodad::ExtractSet(WMODoodadData const& doodadData, ADT::MODF const& wmo, b fwrite(&rotation, sizeof(Vec3D), 1, pDirfile); fwrite(&doodad.Scale, sizeof(float), 1, pDirfile); fwrite(&nlen, sizeof(uint32), 1, pDirfile); - fwrite(ModelInstName, sizeof(char), nlen, pDirfile); + fwrite(ModelInstName.c_str(), sizeof(char), nlen, pDirfile); if (dirfileCache) { @@ -329,7 +321,7 @@ void Doodad::ExtractSet(WMODoodadData const& doodadData, ADT::MODF const& wmo, b CACHE_WRITE(&rotation, sizeof(Vec3D), 1, cacheData); CACHE_WRITE(&doodad.Scale, sizeof(float), 1, cacheData); CACHE_WRITE(&nlen, sizeof(uint32), 1, cacheData); - CACHE_WRITE(ModelInstName, sizeof(char), nlen, cacheData); + CACHE_WRITE(ModelInstName.c_str(), sizeof(char), nlen, cacheData); } } }; diff --git a/src/tools/vmap4_extractor/vmapexport.cpp b/src/tools/vmap4_extractor/vmapexport.cpp index 503170ec7f1..759750bcfd0 100644 --- a/src/tools/vmap4_extractor/vmapexport.cpp +++ b/src/tools/vmap4_extractor/vmapexport.cpp @@ -187,12 +187,11 @@ bool ExtractSingleWmo(std::string& fname) // Copy files from archive std::string originalName = fname; - char szLocalFile[1024]; char* plain_name = GetPlainName(&fname[0]); NormalizeFileName(plain_name, strlen(plain_name)); - sprintf(szLocalFile, "%s/%s", szWorkDirWmo, plain_name); + std::string szLocalFile = Trinity::StringFormat("{}/{}", szWorkDirWmo, plain_name); - if (FileExists(szLocalFile)) + if (FileExists(szLocalFile.c_str())) return true; int p = 0; @@ -213,10 +212,10 @@ bool ExtractSingleWmo(std::string& fname) printf("Couldn't open RootWmo!!!\n"); return true; } - FILE *output = fopen(szLocalFile,"wb"); + FILE *output = fopen(szLocalFile.c_str(),"wb"); if(!output) { - printf("couldn't open %s for writing!\n", szLocalFile); + printf("couldn't open %s for writing!\n", szLocalFile.c_str()); return false; } froot.ConvertToVMAPRootWmo(output); @@ -262,7 +261,7 @@ bool ExtractSingleWmo(std::string& fname) // Delete the extracted file in the case of an error if (!file_ok) - remove(szLocalFile); + remove(szLocalFile.c_str()); return true; } diff --git a/src/tools/vmap4_extractor/wmo.cpp b/src/tools/vmap4_extractor/wmo.cpp index c8621d08da7..555559cfb95 100644 --- a/src/tools/vmap4_extractor/wmo.cpp +++ b/src/tools/vmap4_extractor/wmo.cpp @@ -586,13 +586,12 @@ void MapObject::Extract(ADT::MODF const& mapObjDef, char const* WmoInstName, boo //-----------add_in _dir_file---------------- - char tempname[512]; - sprintf(tempname, "%s/%s", szWorkDirWmo, WmoInstName); - FILE* input = fopen(tempname, "r+b"); + std::string tempname = Trinity::StringFormat("{}/{}", szWorkDirWmo, WmoInstName); + FILE* input = fopen(tempname.c_str(), "r+b"); if (!input) { - printf("WMOInstance::WMOInstance: couldn't open %s\n", tempname); + printf("WMOInstance::WMOInstance: couldn't open %s\n", tempname.c_str()); return; } |