aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/Banner.cpp22
-rw-r--r--src/common/Collision/Management/MMapManager.cpp58
-rw-r--r--src/common/Collision/Management/VMapManager2.cpp8
-rw-r--r--src/common/Collision/Maps/MapTree.cpp22
-rw-r--r--src/common/Collision/Models/GameObjectModel.cpp14
-rw-r--r--src/common/Configuration/Config.cpp26
-rw-r--r--src/common/DataStores/DB2FileLoader.cpp52
-rw-r--r--src/common/Debugging/Errors.cpp14
-rw-r--r--src/common/IPLocation/IPLocation.cpp6
-rw-r--r--src/common/Logging/Appender.cpp2
-rw-r--r--src/common/Logging/AppenderConsole.cpp8
-rw-r--r--src/common/Logging/AppenderFile.cpp4
-rw-r--r--src/common/Logging/Log.cpp2
-rw-r--r--src/common/Logging/Log.h11
-rw-r--r--src/common/Logging/LogMessage.cpp2
-rw-r--r--src/common/Metric/Metric.cpp10
-rw-r--r--src/common/Platform/ServiceWin32.cpp2
-rw-r--r--src/common/Threading/ProcessPriority.cpp14
-rw-r--r--src/common/Utilities/StartProcess.cpp8
-rw-r--r--src/common/Utilities/StringFormat.h16
-rw-r--r--src/common/Utilities/Util.cpp10
21 files changed, 153 insertions, 158 deletions
diff --git a/src/common/Banner.cpp b/src/common/Banner.cpp
index 640b4b248a9..9b19ea78bf4 100644
--- a/src/common/Banner.cpp
+++ b/src/common/Banner.cpp
@@ -21,17 +21,17 @@
void Trinity::Banner::Show(char const* applicationName, void(*log)(char const* text), void(*logExtraInfo)())
{
- log(Trinity::StringFormat("%s (%s)", GitRevision::GetFullVersion(), applicationName).c_str());
- log("<Ctrl-C> to stop.\n");
- log(" ______ __");
- log("/\\__ _\\ __ __/\\ \\__");
- log("\\/_/\\ \\/ _ __ /\\_\\ ___ /\\_\\ \\, _\\ __ __");
- log(" \\ \\ \\/\\`'__\\/\\ \\ /' _ `\\/\\ \\ \\ \\/ /\\ \\/\\ \\");
- log(" \\ \\ \\ \\ \\/ \\ \\ \\/\\ \\/\\ \\ \\ \\ \\ \\_\\ \\ \\_\\ \\");
- log(" \\ \\_\\ \\_\\ \\ \\_\\ \\_\\ \\_\\ \\_\\ \\__\\\\/`____ \\");
- log(" \\/_/\\/_/ \\/_/\\/_/\\/_/\\/_/\\/__/ `/___/> \\");
- log(" C O R E /\\___/");
- log("http://TrinityCore.org \\/__/\n");
+ log(Trinity::StringFormat("{} ({})", GitRevision::GetFullVersion(), applicationName).c_str());
+ log(R"(<Ctrl-C> to stop.\n)");
+ log(R"( ______ __)");
+ log(R"(/\__ _\ __ __/\ \__)");
+ log(R"(\/_/\ \/ _ __ /\_\ ___ /\_\ \, _\ __ __)");
+ log(R"( \ \ \/\`'__\/\ \ /' _ `\/\ \ \ \/ /\ \/\ \)");
+ log(R"( \ \ \ \ \/ \ \ \/\ \/\ \ \ \ \ \_\ \ \_\ \)");
+ log(R"( \ \_\ \_\ \ \_\ \_\ \_\ \_\ \__\\/`____ \)");
+ log(R"( \/_/\/_/ \/_/\/_/\/_/\/_/\/__/ `/___/> \)");
+ log(R"( C O R E /\\___/)");
+ log(R"(http://TrinityCore.org \\/__/\n)");
if (logExtraInfo)
logExtraInfo();
diff --git a/src/common/Collision/Management/MMapManager.cpp b/src/common/Collision/Management/MMapManager.cpp
index ab51cd3e7ba..dc1bd1fe060 100644
--- a/src/common/Collision/Management/MMapManager.cpp
+++ b/src/common/Collision/Management/MMapManager.cpp
@@ -22,8 +22,8 @@
namespace MMAP
{
- static char const* const MAP_FILE_NAME_FORMAT = "%smmaps/%04i.mmap";
- static char const* const TILE_FILE_NAME_FORMAT = "%smmaps/%04i%02i%02i.mmtile";
+ constexpr char MAP_FILE_NAME_FORMAT[] = "{}mmaps/{:04}.mmap";
+ constexpr char TILE_FILE_NAME_FORMAT[] = "{}mmaps/{:04}{:02}{:02}.mmtile";
// ######################## MMapManager ########################
MMapManager::~MMapManager()
@@ -76,11 +76,11 @@ namespace MMAP
}
// load and init dtNavMesh - read parameters from file
- std::string fileName = Trinity::StringFormat(MAP_FILE_NAME_FORMAT, basePath.c_str(), mapId);
+ std::string fileName = Trinity::StringFormat(MAP_FILE_NAME_FORMAT, basePath, mapId);
FILE* file = fopen(fileName.c_str(), "rb");
if (!file)
{
- TC_LOG_DEBUG("maps", "MMAP:loadMapData: Error: Could not open mmap file '%s'", fileName.c_str());
+ TC_LOG_DEBUG("maps", "MMAP:loadMapData: Error: Could not open mmap file '{}'", fileName);
return false;
}
@@ -89,7 +89,7 @@ namespace MMAP
fclose(file);
if (count != 1)
{
- TC_LOG_DEBUG("maps", "MMAP:loadMapData: Error: Could not read params from file '%s'", fileName.c_str());
+ TC_LOG_DEBUG("maps", "MMAP:loadMapData: Error: Could not read params from file '{}'", fileName);
return false;
}
@@ -98,11 +98,11 @@ namespace MMAP
if (dtStatusFailed(mesh->init(&params)))
{
dtFreeNavMesh(mesh);
- TC_LOG_ERROR("maps", "MMAP:loadMapData: Failed to initialize dtNavMesh for mmap %04u from file %s", mapId, fileName.c_str());
+ TC_LOG_ERROR("maps", "MMAP:loadMapData: Failed to initialize dtNavMesh for mmap {:04} from file {}", mapId, fileName);
return false;
}
- TC_LOG_DEBUG("maps", "MMAP:loadMapData: Loaded %04i.mmap", mapId);
+ TC_LOG_DEBUG("maps", "MMAP:loadMapData: Loaded {:04}.mmap", mapId);
// store inside our map list
MMapData* mmap_data = new MMapData(mesh);
@@ -132,21 +132,21 @@ namespace MMAP
return false;
// load this tile :: mmaps/MMMMXXYY.mmtile
- std::string fileName = Trinity::StringFormat(TILE_FILE_NAME_FORMAT, basePath.c_str(), mapId, x, y);
+ std::string fileName = Trinity::StringFormat(TILE_FILE_NAME_FORMAT, basePath, mapId, x, y);
FILE* file = fopen(fileName.c_str(), "rb");
if (!file)
{
auto parentMapItr = parentMapData.find(mapId);
if (parentMapItr != parentMapData.end())
{
- fileName = Trinity::StringFormat(TILE_FILE_NAME_FORMAT, basePath.c_str(), parentMapItr->second, x, y);
+ fileName = Trinity::StringFormat(TILE_FILE_NAME_FORMAT, basePath, parentMapItr->second, x, y);
file = fopen(fileName.c_str(), "rb");
}
}
if (!file)
{
- TC_LOG_DEBUG("maps", "MMAP:loadMap: Could not open mmtile file '%s'", fileName.c_str());
+ TC_LOG_DEBUG("maps", "MMAP:loadMap: Could not open mmtile file '{}'", fileName);
return false;
}
@@ -154,14 +154,14 @@ namespace MMAP
MmapTileHeader fileHeader;
if (fread(&fileHeader, sizeof(MmapTileHeader), 1, file) != 1 || fileHeader.mmapMagic != MMAP_MAGIC)
{
- TC_LOG_ERROR("maps", "MMAP:loadMap: Bad header in mmap %04u%02i%02i.mmtile", mapId, x, y);
+ TC_LOG_ERROR("maps", "MMAP:loadMap: Bad header in mmap {:04}{:02}{:02}.mmtile", mapId, x, y);
fclose(file);
return false;
}
if (fileHeader.mmapVersion != MMAP_VERSION)
{
- TC_LOG_ERROR("maps", "MMAP:loadMap: %04u%02i%02i.mmtile was built with generator v%i, expected v%i",
+ TC_LOG_ERROR("maps", "MMAP:loadMap: {:04}{:02}{:02}.mmtile was built with generator v{}, expected v{}",
mapId, x, y, fileHeader.mmapVersion, MMAP_VERSION);
fclose(file);
return false;
@@ -171,7 +171,7 @@ namespace MMAP
fseek(file, 0, SEEK_END);
if (pos < 0 || static_cast<int32>(fileHeader.size) > ftell(file) - pos)
{
- TC_LOG_ERROR("maps", "MMAP:loadMap: %04u%02i%02i.mmtile has corrupted data size", mapId, x, y);
+ TC_LOG_ERROR("maps", "MMAP:loadMap: {:04}{:02}{:02}.mmtile has corrupted data size", mapId, x, y);
fclose(file);
return false;
}
@@ -184,7 +184,7 @@ namespace MMAP
size_t result = fread(data, fileHeader.size, 1, file);
if (!result)
{
- TC_LOG_ERROR("maps", "MMAP:loadMap: Bad header or data in mmap %04u%02i%02i.mmtile", mapId, x, y);
+ TC_LOG_ERROR("maps", "MMAP:loadMap: Bad header or data in mmap {:04}{:02}{:02}.mmtile", mapId, x, y);
fclose(file);
return false;
}
@@ -199,12 +199,12 @@ namespace MMAP
{
mmap->loadedTileRefs.insert(std::pair<uint32, dtTileRef>(packedGridPos, tileRef));
++loadedTiles;
- TC_LOG_DEBUG("maps", "MMAP:loadMap: Loaded mmtile %04i[%02i, %02i] into %04i[%02i, %02i]", mapId, x, y, mapId, header->x, header->y);
+ TC_LOG_DEBUG("maps", "MMAP:loadMap: Loaded mmtile {:04}[{:02}, {:02}] into {:04}[{:02}, {:02}]", mapId, x, y, mapId, header->x, header->y);
return true;
}
else
{
- TC_LOG_ERROR("maps", "MMAP:loadMap: Could not load %04u%02i%02i.mmtile into navmesh", mapId, x, y);
+ TC_LOG_ERROR("maps", "MMAP:loadMap: Could not load {:04}{:02}{:02}.mmtile into navmesh", mapId, x, y);
dtFree(data);
return false;
}
@@ -225,11 +225,11 @@ namespace MMAP
if (dtStatusFailed(query->init(mmap->navMesh, 1024)))
{
dtFreeNavMeshQuery(query);
- TC_LOG_ERROR("maps", "MMAP:GetNavMeshQuery: Failed to initialize dtNavMeshQuery for mapId %04u instanceId %u", mapId, instanceId);
+ TC_LOG_ERROR("maps", "MMAP:GetNavMeshQuery: Failed to initialize dtNavMeshQuery for mapId {:04} instanceId {}", mapId, instanceId);
return false;
}
- TC_LOG_DEBUG("maps", "MMAP:GetNavMeshQuery: created dtNavMeshQuery for mapId %04u instanceId %u", mapId, instanceId);
+ TC_LOG_DEBUG("maps", "MMAP:GetNavMeshQuery: created dtNavMeshQuery for mapId {:04} instanceId {}", mapId, instanceId);
mmap->navMeshQueries.insert(std::pair<uint32, dtNavMeshQuery*>(instanceId, query));
return true;
}
@@ -241,7 +241,7 @@ namespace MMAP
if (itr == loadedMMaps.end())
{
// file may not exist, therefore not loaded
- TC_LOG_DEBUG("maps", "MMAP:unloadMap: Asked to unload not loaded navmesh map. %04u%02i%02i.mmtile", mapId, x, y);
+ TC_LOG_DEBUG("maps", "MMAP:unloadMap: Asked to unload not loaded navmesh map. {:04}{:02}{:02}.mmtile", mapId, x, y);
return false;
}
@@ -253,7 +253,7 @@ namespace MMAP
if (tileRefItr == mmap->loadedTileRefs.end())
{
// file may not exist, therefore not loaded
- TC_LOG_DEBUG("maps", "MMAP:unloadMap: Asked to unload not loaded navmesh tile. %04u%02i%02i.mmtile", mapId, x, y);
+ TC_LOG_DEBUG("maps", "MMAP:unloadMap: Asked to unload not loaded navmesh tile. {:04}{:02}{:02}.mmtile", mapId, x, y);
return false;
}
@@ -263,14 +263,14 @@ namespace MMAP
// this is technically a memory leak
// if the grid is later reloaded, dtNavMesh::addTile will return error but no extra memory is used
// we cannot recover from this error - assert out
- TC_LOG_ERROR("maps", "MMAP:unloadMap: Could not unload %04u%02i%02i.mmtile from navmesh", mapId, x, y);
+ TC_LOG_ERROR("maps", "MMAP:unloadMap: Could not unload {:04}{:02}{:02}.mmtile from navmesh", mapId, x, y);
ABORT();
}
else
{
mmap->loadedTileRefs.erase(tileRefItr);
--loadedTiles;
- TC_LOG_DEBUG("maps", "MMAP:unloadMap: Unloaded mmtile %04i[%02i, %02i] from %03i", mapId, x, y, mapId);
+ TC_LOG_DEBUG("maps", "MMAP:unloadMap: Unloaded mmtile {:04}[{:02}, {:02}] from {:03}", mapId, x, y, mapId);
return true;
}
@@ -283,7 +283,7 @@ namespace MMAP
if (itr == loadedMMaps.end() || !itr->second)
{
// file may not exist, therefore not loaded
- TC_LOG_DEBUG("maps", "MMAP:unloadMap: Asked to unload not loaded navmesh map %04u", mapId);
+ TC_LOG_DEBUG("maps", "MMAP:unloadMap: Asked to unload not loaded navmesh map {:04}", mapId);
return false;
}
@@ -294,17 +294,17 @@ namespace MMAP
uint32 x = (i->first >> 16);
uint32 y = (i->first & 0x0000FFFF);
if (dtStatusFailed(mmap->navMesh->removeTile(i->second, nullptr, nullptr)))
- TC_LOG_ERROR("maps", "MMAP:unloadMap: Could not unload %04u%02i%02i.mmtile from navmesh", mapId, x, y);
+ TC_LOG_ERROR("maps", "MMAP:unloadMap: Could not unload {:04}{:02}{:02}.mmtile from navmesh", mapId, x, y);
else
{
--loadedTiles;
- TC_LOG_DEBUG("maps", "MMAP:unloadMap: Unloaded mmtile %04i[%02i, %02i] from %04i", mapId, x, y, mapId);
+ TC_LOG_DEBUG("maps", "MMAP:unloadMap: Unloaded mmtile {:04}[{:02}, {:02}] from {:04}", mapId, x, y, mapId);
}
}
delete mmap;
itr->second = nullptr;
- TC_LOG_DEBUG("maps", "MMAP:unloadMap: Unloaded %04i.mmap", mapId);
+ TC_LOG_DEBUG("maps", "MMAP:unloadMap: Unloaded {:04}.mmap", mapId);
return true;
}
@@ -316,14 +316,14 @@ namespace MMAP
if (itr == loadedMMaps.end())
{
// file may not exist, therefore not loaded
- TC_LOG_DEBUG("maps", "MMAP:unloadMapInstance: Asked to unload not loaded navmesh map %04u", mapId);
+ TC_LOG_DEBUG("maps", "MMAP:unloadMapInstance: Asked to unload not loaded navmesh map {:04}", mapId);
return false;
}
MMapData* mmap = itr->second;
if (mmap->navMeshQueries.find(instanceId) == mmap->navMeshQueries.end())
{
- TC_LOG_DEBUG("maps", "MMAP:unloadMapInstance: Asked to unload not loaded dtNavMeshQuery mapId %04u instanceId %u", mapId, instanceId);
+ TC_LOG_DEBUG("maps", "MMAP:unloadMapInstance: Asked to unload not loaded dtNavMeshQuery mapId {:04} instanceId {}", mapId, instanceId);
return false;
}
@@ -331,7 +331,7 @@ namespace MMAP
dtFreeNavMeshQuery(query);
mmap->navMeshQueries.erase(instanceId);
- TC_LOG_DEBUG("maps", "MMAP:unloadMapInstance: Unloaded mapId %04u instanceId %u", mapId, instanceId);
+ TC_LOG_DEBUG("maps", "MMAP:unloadMapInstance: Unloaded mapId {:04} instanceId {}", mapId, instanceId);
return true;
}
diff --git a/src/common/Collision/Management/VMapManager2.cpp b/src/common/Collision/Management/VMapManager2.cpp
index 8afd4449dce..5ae50115486 100644
--- a/src/common/Collision/Management/VMapManager2.cpp
+++ b/src/common/Collision/Management/VMapManager2.cpp
@@ -326,11 +326,11 @@ namespace VMAP
ManagedModel* worldmodel = new ManagedModel();
if (!worldmodel->getModel()->readFile(basepath + filename + ".vmo"))
{
- TC_LOG_ERROR("misc", "VMapManager2: could not load '%s%s.vmo'", basepath.c_str(), filename.c_str());
+ TC_LOG_ERROR("misc", "VMapManager2: could not load '{}{}.vmo'", basepath, filename);
delete worldmodel;
return nullptr;
}
- TC_LOG_DEBUG("maps", "VMapManager2: loading file '%s%s'", basepath.c_str(), filename.c_str());
+ TC_LOG_DEBUG("maps", "VMapManager2: loading file '{}{}'", basepath, filename);
worldmodel->getModel()->SetName(filename);
worldmodel->getModel()->Flags = flags;
@@ -349,12 +349,12 @@ namespace VMAP
auto model = iLoadedModelFiles.find(filename);
if (model == iLoadedModelFiles.end())
{
- TC_LOG_ERROR("misc", "VMapManager2: trying to unload non-loaded file '%s'", filename.c_str());
+ TC_LOG_ERROR("misc", "VMapManager2: trying to unload non-loaded file '{}'", filename);
return;
}
if (model->second->decRefCount() == 0)
{
- TC_LOG_DEBUG("maps", "VMapManager2: unloading file '%s'", filename.c_str());
+ TC_LOG_DEBUG("maps", "VMapManager2: unloading file '{}'", filename);
delete model->second;
iLoadedModelFiles.erase(model);
}
diff --git a/src/common/Collision/Maps/MapTree.cpp b/src/common/Collision/Maps/MapTree.cpp
index 8aca904092f..0ff4dfff4b9 100644
--- a/src/common/Collision/Maps/MapTree.cpp
+++ b/src/common/Collision/Maps/MapTree.cpp
@@ -57,7 +57,7 @@ namespace VMAP
void operator()(Vector3 const& point, uint32 entry)
{
#ifdef VMAP_DEBUG
- TC_LOG_DEBUG("maps", "AreaInfoCallback: trying to intersect '%s'", prims[entry].name.c_str());
+ TC_LOG_DEBUG("maps", "AreaInfoCallback: trying to intersect '{}'", prims[entry].name);
#endif
prims[entry].intersectPoint(point, aInfo);
}
@@ -73,7 +73,7 @@ namespace VMAP
void operator()(Vector3 const& point, uint32 entry)
{
#ifdef VMAP_DEBUG
- TC_LOG_DEBUG("maps", "LocationInfoCallback: trying to intersect '%s'", prims[entry].name.c_str());
+ TC_LOG_DEBUG("maps", "LocationInfoCallback: trying to intersect '{}'", prims[entry].name);
#endif
if (prims[entry].GetLocationInfo(point, locInfo))
result = true;
@@ -306,7 +306,7 @@ namespace VMAP
LoadResult StaticMapTree::InitMap(std::string const& fname)
{
- TC_LOG_DEBUG("maps", "StaticMapTree::InitMap() : initializing StaticMapTree '%s'", fname.c_str());
+ TC_LOG_DEBUG("maps", "StaticMapTree::InitMap() : initializing StaticMapTree '{}'", fname);
std::string fullname = iBasePath + fname;
FILE* rf = fopen(fullname.c_str(), "rb");
if (!rf)
@@ -368,7 +368,7 @@ namespace VMAP
{
if (!iTreeValues)
{
- TC_LOG_ERROR("misc", "StaticMapTree::LoadMapTile() : tree has not been initialized [%u, %u]", tileX, tileY);
+ TC_LOG_ERROR("misc", "StaticMapTree::LoadMapTile() : tree has not been initialized [{}, {}]", tileX, tileY);
return LoadResult::ReadFromFileFailed;
}
LoadResult result = LoadResult::FileNotFound;
@@ -393,7 +393,7 @@ namespace VMAP
// acquire model instance
WorldModel* model = vm->acquireModelInstance(iBasePath, spawn.name, spawn.flags);
if (!model)
- TC_LOG_ERROR("misc", "StaticMapTree::LoadMapTile() : could not acquire WorldModel pointer [%u, %u]", tileX, tileY);
+ TC_LOG_ERROR("misc", "StaticMapTree::LoadMapTile() : could not acquire WorldModel pointer [{}, {}]", tileX, tileY);
// update tree
auto spawnIndex = iSpawnIndices.find(spawn.ID);
@@ -404,7 +404,7 @@ namespace VMAP
{
if (referencedVal >= iNTreeValues)
{
- TC_LOG_ERROR("maps", "StaticMapTree::LoadMapTile() : invalid tree element (%u/%u) referenced in tile %s", referencedVal, iNTreeValues, fileResult.Name.c_str());
+ TC_LOG_ERROR("maps", "StaticMapTree::LoadMapTile() : invalid tree element ({}/{}) referenced in tile {}", referencedVal, iNTreeValues, fileResult.Name);
continue;
}
@@ -418,7 +418,7 @@ namespace VMAP
if (iTreeValues[referencedVal].ID != spawn.ID)
TC_LOG_DEBUG("maps", "StaticMapTree::LoadMapTile() : trying to load wrong spawn in node");
else if (iTreeValues[referencedVal].name != spawn.name)
- TC_LOG_DEBUG("maps", "StaticMapTree::LoadMapTile() : name collision on GUID=%u", spawn.ID);
+ TC_LOG_DEBUG("maps", "StaticMapTree::LoadMapTile() : name collision on GUID={}", spawn.ID);
#endif
}
}
@@ -427,13 +427,13 @@ namespace VMAP
// unknown parent spawn might appear in because it overlaps multiple tiles
// in case the original tile is swapped but its neighbour is now (adding this spawn)
// we want to not mark it as loading error and just skip that model
- TC_LOG_ERROR("maps", "StaticMapTree::LoadMapTile() : invalid tree element (spawn %u) referenced in tile %s by map %u", spawn.ID, fileResult.Name.c_str(), iMapID);
+ TC_LOG_ERROR("maps", "StaticMapTree::LoadMapTile() : invalid tree element (spawn {}) referenced in tile {} by map {}", spawn.ID, fileResult.Name, iMapID);
result = LoadResult::ReadFromFileFailed;
}
}
else
{
- TC_LOG_ERROR("maps", "StaticMapTree::LoadMapTile() : cannot read model from file (spawn index %u) referenced in tile %s by map %u", i, fileResult.Name.c_str(), iMapID);
+ TC_LOG_ERROR("maps", "StaticMapTree::LoadMapTile() : cannot read model from file (spawn index {}) referenced in tile {} by map {}", i, fileResult.Name, iMapID);
result = LoadResult::ReadFromFileFailed;
}
}
@@ -455,7 +455,7 @@ namespace VMAP
loadedTileMap::iterator tile = iLoadedTiles.find(tileID);
if (tile == iLoadedTiles.end())
{
- TC_LOG_ERROR("misc", "StaticMapTree::UnloadMapTile() : trying to unload non-loaded tile - Map:%u X:%u Y:%u", iMapID, tileX, tileY);
+ TC_LOG_ERROR("misc", "StaticMapTree::UnloadMapTile() : trying to unload non-loaded tile - Map:{} X:{} Y:{}", iMapID, tileX, tileY);
return;
}
if (tile->second) // file associated with tile
@@ -486,7 +486,7 @@ namespace VMAP
{
uint32 referencedNode = spawnIndex->second;
if (!iLoadedSpawns.count(referencedNode))
- TC_LOG_ERROR("misc", "StaticMapTree::UnloadMapTile() : trying to unload non-referenced model '%s' (ID:%u)", spawn.name.c_str(), spawn.ID);
+ TC_LOG_ERROR("misc", "StaticMapTree::UnloadMapTile() : trying to unload non-referenced model '{}' (ID:{})", spawn.name, spawn.ID);
else if (--iLoadedSpawns[referencedNode] == 0)
{
iTreeValues[referencedNode].setUnloaded();
diff --git a/src/common/Collision/Models/GameObjectModel.cpp b/src/common/Collision/Models/GameObjectModel.cpp
index 43d6808e0d3..946fe5b3e8b 100644
--- a/src/common/Collision/Models/GameObjectModel.cpp
+++ b/src/common/Collision/Models/GameObjectModel.cpp
@@ -50,7 +50,7 @@ bool LoadGameObjectModelList(std::string const& dataPath)
auto model_list_file = Trinity::make_unique_ptr_with_deleter(fopen((dataPath + "vmaps/" + VMAP::GAMEOBJECT_MODELS).c_str(), "rb"), &::fclose);
if (!model_list_file)
{
- TC_LOG_ERROR("misc", "Unable to open '%s' file.", VMAP::GAMEOBJECT_MODELS);
+ TC_LOG_ERROR("misc", "Unable to open '{}' file.", VMAP::GAMEOBJECT_MODELS);
return false;
}
@@ -58,7 +58,7 @@ bool LoadGameObjectModelList(std::string const& dataPath)
if (fread(magic, 1, 8, model_list_file.get()) != 8
|| memcmp(magic, VMAP::VMAP_MAGIC, 8) != 0)
{
- TC_LOG_ERROR("misc", "File '%s' has wrong header, expected %s.", VMAP::GAMEOBJECT_MODELS, VMAP::VMAP_MAGIC);
+ TC_LOG_ERROR("misc", "File '{}' has wrong header, expected {}.", VMAP::GAMEOBJECT_MODELS, VMAP::VMAP_MAGIC);
return false;
}
@@ -79,20 +79,20 @@ bool LoadGameObjectModelList(std::string const& dataPath)
|| fread(&v1, sizeof(Vector3), 1, model_list_file.get()) != 1
|| fread(&v2, sizeof(Vector3), 1, model_list_file.get()) != 1)
{
- TC_LOG_ERROR("misc", "File '%s' seems to be corrupted!", VMAP::GAMEOBJECT_MODELS);
+ TC_LOG_ERROR("misc", "File '{}' seems to be corrupted!", VMAP::GAMEOBJECT_MODELS);
break;
}
if (v1.isNaN() || v2.isNaN())
{
- TC_LOG_ERROR("misc", "File '%s' Model '%s' has invalid v1%s v2%s values!", VMAP::GAMEOBJECT_MODELS, std::string(buff, name_length).c_str(), v1.toString().c_str(), v2.toString().c_str());
+ TC_LOG_ERROR("misc", "File '{}' Model '{}' has invalid v1{} v2{} values!", VMAP::GAMEOBJECT_MODELS, std::string(buff, name_length), v1.toString(), v2.toString());
continue;
}
model_list.emplace(std::piecewise_construct, std::forward_as_tuple(displayId), std::forward_as_tuple(&buff[0], name_length, v1, v2, isWmo != 0));
}
- TC_LOG_INFO("server.loading", ">> Loaded %u GameObject models in %u ms", uint32(model_list.size()), GetMSTimeDiffToNow(oldMSTime));
+ TC_LOG_INFO("server.loading", ">> Loaded {} GameObject models in {} ms", uint32(model_list.size()), GetMSTimeDiffToNow(oldMSTime));
return true;
}
@@ -112,7 +112,7 @@ bool GameObjectModel::initialize(std::unique_ptr<GameObjectModelOwnerBase> model
// ignore models with no bounds
if (mdl_box == G3D::AABox::zero())
{
- TC_LOG_ERROR("misc", "GameObject model %s has zero bounds, loading skipped", it->second.name.c_str());
+ TC_LOG_ERROR("misc", "GameObject model {} has zero bounds, loading skipped", it->second.name);
return false;
}
@@ -272,7 +272,7 @@ bool GameObjectModel::UpdatePosition()
// ignore models with no bounds
if (mdl_box == G3D::AABox::zero())
{
- TC_LOG_ERROR("misc", "GameObject model %s has zero bounds, loading skipped", it->second.name.c_str());
+ TC_LOG_ERROR("misc", "GameObject model {} has zero bounds, loading skipped", it->second.name);
return false;
}
diff --git a/src/common/Configuration/Config.cpp b/src/common/Configuration/Config.cpp
index 9a02627d2b7..93f7d367730 100644
--- a/src/common/Configuration/Config.cpp
+++ b/src/common/Configuration/Config.cpp
@@ -226,25 +226,25 @@ T ConfigMgr::GetValueDefault(std::string const& name, T def, bool quiet) const
Optional<T> castedVar = Trinity::StringTo<T>(*envVar);
if (!castedVar)
{
- TC_LOG_ERROR("server.loading", "Bad value defined for name %s in environment variables, going to use default instead", name.c_str());
+ TC_LOG_ERROR("server.loading", "Bad value defined for name {} in environment variables, going to use default instead", name);
return def;
}
if (!quiet)
- TC_LOG_WARN("server.loading", "Missing name %s in config file %s, recovered with environment '%s' value.", name.c_str(), _filename.c_str(), envVar->c_str());
+ TC_LOG_WARN("server.loading", "Missing name {} in config file {}, recovered with environment '{}' value.", name, _filename, *envVar);
return *castedVar;
}
else if (!quiet)
{
- TC_LOG_WARN("server.loading", "Missing name %s in config file %s, add \"%s = %s\" to this file",
- name.c_str(), _filename.c_str(), name.c_str(), std::to_string(def).c_str());
+ TC_LOG_WARN("server.loading", "Missing name {} in config file {}, add \"{} = {}\" to this file",
+ name, _filename, name, def);
}
}
catch (bpt::ptree_bad_data const&)
{
- TC_LOG_ERROR("server.loading", "Bad value defined for name %s in config file %s, going to use %s instead",
- name.c_str(), _filename.c_str(), std::to_string(def).c_str());
+ TC_LOG_ERROR("server.loading", "Bad value defined for name {} in config file {}, going to use {} instead",
+ name, _filename, def);
}
return def;
@@ -263,20 +263,20 @@ std::string ConfigMgr::GetValueDefault<std::string>(std::string const& name, std
if (envVar)
{
if (!quiet)
- TC_LOG_WARN("server.loading", "Missing name %s in config file %s, recovered with environment '%s' value.", name.c_str(), _filename.c_str(), envVar->c_str());
+ TC_LOG_WARN("server.loading", "Missing name {} in config file {}, recovered with environment '{}' value.", name, _filename, *envVar);
return *envVar;
}
else if (!quiet)
{
- TC_LOG_WARN("server.loading", "Missing name %s in config file %s, add \"%s = %s\" to this file",
- name.c_str(), _filename.c_str(), name.c_str(), def.c_str());
+ TC_LOG_WARN("server.loading", "Missing name {} in config file {}, add \"{} = {}\" to this file",
+ name, _filename, name, def);
}
}
catch (bpt::ptree_bad_data const&)
{
- TC_LOG_ERROR("server.loading", "Bad value defined for name %s in config file %s, going to use %s instead",
- name.c_str(), _filename.c_str(), def.c_str());
+ TC_LOG_ERROR("server.loading", "Bad value defined for name {} in config file {}, going to use {} instead",
+ name, _filename, def);
}
return def;
@@ -298,8 +298,8 @@ bool ConfigMgr::GetBoolDefault(std::string const& name, bool def, bool quiet) co
return *boolVal;
else
{
- TC_LOG_ERROR("server.loading", "Bad value defined for name %s in config file %s, going to use '%s' instead",
- name.c_str(), _filename.c_str(), def ? "true" : "false");
+ TC_LOG_ERROR("server.loading", "Bad value defined for name {} in config file {}, going to use '{}' instead",
+ name, _filename, def ? "true" : "false");
return def;
}
}
diff --git a/src/common/DataStores/DB2FileLoader.cpp b/src/common/DataStores/DB2FileLoader.cpp
index 9216389f346..f9bf392bdfd 100644
--- a/src/common/DataStores/DB2FileLoader.cpp
+++ b/src/common/DataStores/DB2FileLoader.cpp
@@ -511,7 +511,7 @@ char* DB2FileLoaderRegularImpl::AutoProduceStrings(char** indexTable, uint32 ind
}
}
- TC_LOG_ERROR("", "Attempted to load %s which has locales %s as %s. Check if you placed your localized db2 files in correct directory.", _fileName, str.str().c_str(), localeNames[locale]);
+ TC_LOG_ERROR("", "Attempted to load {} which has locales {} as {}. Check if you placed your localized db2 files in correct directory.", _fileName, str.str(), localeNames[locale]);
return nullptr;
}
@@ -1059,7 +1059,7 @@ void DB2FileLoaderSparseImpl::SetAdditionalData(std::vector<uint32> /*idTable*/,
char* DB2FileLoaderSparseImpl::AutoProduceData(uint32& indexTableSize, char**& indexTable)
{
if (_loadInfo->Meta->FieldCount != _header->FieldCount)
- throw DB2FileLoadException(Trinity::StringFormat("Found unsupported parent index in sparse db2 %s", _fileName));
+ throw DB2FileLoadException(Trinity::StringFormat("Found unsupported parent index in sparse db2 {}", _fileName));
//get struct size and index pos
uint32 recordsize = _loadInfo->Meta->GetRecordSize();
@@ -1187,7 +1187,7 @@ char* DB2FileLoaderSparseImpl::AutoProduceData(uint32& indexTableSize, char**& i
char* DB2FileLoaderSparseImpl::AutoProduceStrings(char** indexTable, uint32 indexTableSize, uint32 locale)
{
if (_loadInfo->Meta->FieldCount != _header->FieldCount)
- throw DB2FileLoadException(Trinity::StringFormat("Found unsupported parent index in sparse db2 %s", _fileName));
+ throw DB2FileLoadException(Trinity::StringFormat("Found unsupported parent index in sparse db2 {}", _fileName));
if (!(_header->Locale & (1 << locale)))
{
@@ -1202,7 +1202,7 @@ char* DB2FileLoaderSparseImpl::AutoProduceStrings(char** indexTable, uint32 inde
}
}
- TC_LOG_ERROR("", "Attempted to load %s which has locales %s as %s. Check if you placed your localized db2 files in correct directory.", _fileName, str.str().c_str(), localeNames[locale]);
+ TC_LOG_ERROR("", "Attempted to load {} which has locales {} as {}. Check if you placed your localized db2 files in correct directory.", _fileName, str.str(), localeNames[locale]);
return nullptr;
}
@@ -1756,27 +1756,27 @@ void DB2FileLoader::LoadHeaders(DB2FileSource* source, DB2FileLoadInfo const* lo
EndianConvert(_header.SectionCount);
if (_header.Signature != 0x33434457) //'WDC3'
- throw DB2FileLoadException(Trinity::StringFormat("Incorrect file signature in %s, expected 'WDC3', got %c%c%c%c", source->GetFileName(),
+ throw DB2FileLoadException(Trinity::StringFormat("Incorrect file signature in {}, expected 'WDC3', got %c%c%c%c", source->GetFileName(),
char(_header.Signature & 0xFF), char((_header.Signature >> 8) & 0xFF), char((_header.Signature >> 16) & 0xFF), char((_header.Signature >> 24) & 0xFF)));
if (loadInfo && _header.LayoutHash != loadInfo->Meta->LayoutHash)
- throw DB2FileLoadException(Trinity::StringFormat("Incorrect layout hash in %s, expected 0x%08X, got 0x%08X (possibly wrong client version)",
+ throw DB2FileLoadException(Trinity::StringFormat("Incorrect layout hash in {}, expected 0x{:08X}, got 0x{:08X} (possibly wrong client version)",
source->GetFileName(), loadInfo->Meta->LayoutHash, _header.LayoutHash));
if (_header.ParentLookupCount > 1)
- throw DB2FileLoadException(Trinity::StringFormat("Too many parent lookups in %s, only one is allowed, got %u",
+ throw DB2FileLoadException(Trinity::StringFormat("Too many parent lookups in {}, only one is allowed, got {}",
source->GetFileName(), _header.ParentLookupCount));
if (loadInfo && (_header.TotalFieldCount + (loadInfo->Meta->ParentIndexField >= int32(_header.TotalFieldCount) ? 1 : 0) != loadInfo->Meta->FieldCount))
- throw DB2FileLoadException(Trinity::StringFormat("Incorrect number of fields in %s, expected %u, got %u",
+ throw DB2FileLoadException(Trinity::StringFormat("Incorrect number of fields in {}, expected {}, got {}",
source->GetFileName(), loadInfo->Meta->FieldCount, _header.TotalFieldCount + (loadInfo->Meta->ParentIndexField >= int32(_header.TotalFieldCount) ? 1 : 0)));
if (loadInfo && (_header.ParentLookupCount && loadInfo->Meta->ParentIndexField == -1))
- throw DB2FileLoadException(Trinity::StringFormat("Unexpected parent lookup found in %s", source->GetFileName()));
+ throw DB2FileLoadException(Trinity::StringFormat("Unexpected parent lookup found in {}", source->GetFileName()));
std::unique_ptr<DB2SectionHeader[]> sections = std::make_unique<DB2SectionHeader[]>(_header.SectionCount);
if (_header.SectionCount && !source->Read(sections.get(), sizeof(DB2SectionHeader) * _header.SectionCount))
- throw DB2FileLoadException(Trinity::StringFormat("Unable to read section headers from %s", source->GetFileName()));
+ throw DB2FileLoadException(Trinity::StringFormat("Unable to read section headers from {}", source->GetFileName()));
uint32 totalCopyTableSize = 0;
uint32 totalParentLookupDataSize = 0;
@@ -1802,12 +1802,12 @@ void DB2FileLoader::LoadHeaders(DB2FileSource* source, DB2FileLoadInfo const* lo
totalParentLookupDataSize;
if (source->GetFileSize() != expectedFileSize)
- throw DB2FileLoadException(Trinity::StringFormat("%s failed size consistency check, expected " SZFMTD ", got " SZFMTD, expectedFileSize, source->GetFileSize()));
+ throw DB2FileLoadException(Trinity::StringFormat("{} failed size consistency check, expected {}, got {}", source->GetFileName(), expectedFileSize, source->GetFileSize()));
}
std::unique_ptr<DB2FieldEntry[]> fieldData = std::make_unique<DB2FieldEntry[]>(_header.FieldCount);
if (!source->Read(fieldData.get(), sizeof(DB2FieldEntry) * _header.FieldCount))
- throw DB2FileLoadException(Trinity::StringFormat("Unable to read field information from %s", source->GetFileName()));
+ throw DB2FileLoadException(Trinity::StringFormat("Unable to read field information from {}", source->GetFileName()));
std::unique_ptr<DB2ColumnMeta[]> columnMeta;
std::unique_ptr<std::unique_ptr<DB2PalletValue[]>[]> palletValues;
@@ -1817,14 +1817,14 @@ void DB2FileLoader::LoadHeaders(DB2FileSource* source, DB2FileLoadInfo const* lo
{
columnMeta = std::make_unique<DB2ColumnMeta[]>(_header.TotalFieldCount);
if (!source->Read(columnMeta.get(), _header.ColumnMetaSize))
- throw DB2FileLoadException(Trinity::StringFormat("Unable to read field metadata from %s", source->GetFileName()));
+ throw DB2FileLoadException(Trinity::StringFormat("Unable to read field metadata from {}", source->GetFileName()));
if (loadInfo && loadInfo->Meta->HasIndexFieldInData())
{
if (columnMeta[loadInfo->Meta->IndexField].CompressionType != DB2ColumnCompression::None
&& columnMeta[loadInfo->Meta->IndexField].CompressionType != DB2ColumnCompression::Immediate
&& columnMeta[loadInfo->Meta->IndexField].CompressionType != DB2ColumnCompression::SignedImmediate)
- throw DB2FileLoadException(Trinity::StringFormat("Invalid compression type for index field in %s, expected one of None (0), Immediate (1), SignedImmediate (5), got %u",
+ throw DB2FileLoadException(Trinity::StringFormat("Invalid compression type for index field in {}, expected one of None (0), Immediate (1), SignedImmediate (5), got {}",
source->GetFileName(), uint32(columnMeta[loadInfo->Meta->IndexField].CompressionType)));
}
@@ -1836,7 +1836,7 @@ void DB2FileLoader::LoadHeaders(DB2FileSource* source, DB2FileLoadInfo const* lo
palletValues[i] = std::make_unique<DB2PalletValue[]>(columnMeta[i].AdditionalDataSize / sizeof(DB2PalletValue));
if (!source->Read(palletValues[i].get(), columnMeta[i].AdditionalDataSize))
- throw DB2FileLoadException(Trinity::StringFormat("Unable to read field pallet values from %s for field %u", source->GetFileName(), i));
+ throw DB2FileLoadException(Trinity::StringFormat("Unable to read field pallet values from {} for field {}", source->GetFileName(), i));
}
palletArrayValues = std::make_unique<std::unique_ptr<DB2PalletValue[]>[]>(_header.TotalFieldCount);
@@ -1847,7 +1847,7 @@ void DB2FileLoader::LoadHeaders(DB2FileSource* source, DB2FileLoadInfo const* lo
palletArrayValues[i] = std::make_unique<DB2PalletValue[]>(columnMeta[i].AdditionalDataSize / sizeof(DB2PalletValue));
if (!source->Read(palletArrayValues[i].get(), columnMeta[i].AdditionalDataSize))
- throw DB2FileLoadException(Trinity::StringFormat("Unable to read field pallet array values from %s for field %u", source->GetFileName(), i));
+ throw DB2FileLoadException(Trinity::StringFormat("Unable to read field pallet array values from {} for field {}", source->GetFileName(), i));
}
std::unique_ptr<std::unique_ptr<DB2CommonValue[]>[]> commonData = std::make_unique<std::unique_ptr<DB2CommonValue[]>[]>(_header.TotalFieldCount);
@@ -1862,7 +1862,7 @@ void DB2FileLoader::LoadHeaders(DB2FileSource* source, DB2FileLoadInfo const* lo
commonData[i] = std::make_unique<DB2CommonValue[]>(columnMeta[i].AdditionalDataSize / sizeof(DB2CommonValue));
if (!source->Read(commonData[i].get(), columnMeta[i].AdditionalDataSize))
- throw DB2FileLoadException(Trinity::StringFormat("Unable to read field common values from %s for field %u", source->GetFileName(), i));
+ throw DB2FileLoadException(Trinity::StringFormat("Unable to read field common values from {} for field {}", source->GetFileName(), i));
uint32 numExtraValuesForField = columnMeta[i].AdditionalDataSize / sizeof(DB2CommonValue);
for (uint32 record = 0; record < numExtraValuesForField; ++record)
@@ -1921,23 +1921,23 @@ void DB2FileLoader::Load(DB2FileSource* source, DB2FileLoadInfo const* loadInfo)
}
if (!source->SetPosition(section.FileOffset))
- throw DB2FileLoadException(Trinity::StringFormat("Unable to change %s read position for section %u", source->GetFileName(), i));
+ throw DB2FileLoadException(Trinity::StringFormat("Unable to change {} read position for section {}", source->GetFileName(), i));
if (!_impl->LoadTableData(source, i))
- throw DB2FileLoadException(Trinity::StringFormat("Unable to read section table data from %s for section %u", source->GetFileName(), i));
+ throw DB2FileLoadException(Trinity::StringFormat("Unable to read section table data from {} for section {}", source->GetFileName(), i));
if (!_impl->LoadCatalogData(source, i))
- throw DB2FileLoadException(Trinity::StringFormat("Unable to read section catalog data from %s for section %u", source->GetFileName(), i));
+ throw DB2FileLoadException(Trinity::StringFormat("Unable to read section catalog data from {} for section {}", source->GetFileName(), i));
if (loadInfo)
{
if (loadInfo->Meta->HasIndexFieldInData())
{
if (section.IdTableSize != 0)
- throw DB2FileLoadException(Trinity::StringFormat("Unexpected id table found in %s for section %u", source->GetFileName(), i));
+ throw DB2FileLoadException(Trinity::StringFormat("Unexpected id table found in {} for section {}", source->GetFileName(), i));
}
else if (section.IdTableSize != 4 * section.RecordCount)
- throw DB2FileLoadException(Trinity::StringFormat("Unexpected id table size in %s for section %u, expected %u, got %u",
+ throw DB2FileLoadException(Trinity::StringFormat("Unexpected id table size in {} for section {}, expected {}, got {}",
source->GetFileName(), i, 4 * section.RecordCount, section.IdTableSize));
}
@@ -1946,7 +1946,7 @@ void DB2FileLoader::Load(DB2FileSource* source, DB2FileLoadInfo const* loadInfo)
std::size_t idTableSize = idTable.size();
idTable.resize(idTableSize + section.IdTableSize / sizeof(uint32));
if (!source->Read(&idTable[idTableSize], section.IdTableSize))
- throw DB2FileLoadException(Trinity::StringFormat("Unable to read non-inline record ids from %s for section %u", source->GetFileName(), i));
+ throw DB2FileLoadException(Trinity::StringFormat("Unable to read non-inline record ids from {} for section {}", source->GetFileName(), i));
// This is a hack fix for broken db2 files that have invalid id tables
for (std::size_t i = idTableSize; i < idTable.size(); ++i)
@@ -1959,7 +1959,7 @@ void DB2FileLoader::Load(DB2FileSource* source, DB2FileLoadInfo const* loadInfo)
std::size_t copyTableSize = copyTable.size();
copyTable.resize(copyTableSize + section.CopyTableCount);
if (!source->Read(&copyTable[copyTableSize], section.CopyTableCount * sizeof(DB2RecordCopy)))
- throw DB2FileLoadException(Trinity::StringFormat("Unable to read record copies from %s for section %u", source->GetFileName(), i));
+ throw DB2FileLoadException(Trinity::StringFormat("Unable to read record copies from {} for section {}", source->GetFileName(), i));
}
if (_header.ParentLookupCount)
@@ -1969,14 +1969,14 @@ void DB2FileLoader::Load(DB2FileSource* source, DB2FileLoadInfo const* loadInfo)
{
DB2IndexDataInfo indexInfo;
if (!source->Read(&indexInfo, sizeof(DB2IndexDataInfo)))
- throw DB2FileLoadException(Trinity::StringFormat("Unable to read parent lookup info from %s for section %u", source->GetFileName(), i));
+ throw DB2FileLoadException(Trinity::StringFormat("Unable to read parent lookup info from {} for section {}", source->GetFileName(), i));
if (!indexInfo.NumEntries)
continue;
parentIndexesForSection[j].Entries.resize(indexInfo.NumEntries);
if (!source->Read(parentIndexesForSection[j].Entries.data(), sizeof(DB2IndexEntry) * indexInfo.NumEntries))
- throw DB2FileLoadException(Trinity::StringFormat("Unable to read parent lookup content from %s for section %u", source->GetFileName(), i));
+ throw DB2FileLoadException(Trinity::StringFormat("Unable to read parent lookup content from {} for section {}", source->GetFileName(), i));
}
}
}
diff --git a/src/common/Debugging/Errors.cpp b/src/common/Debugging/Errors.cpp
index 6bb22c567de..162b613e12e 100644
--- a/src/common/Debugging/Errors.cpp
+++ b/src/common/Debugging/Errors.cpp
@@ -72,7 +72,7 @@ namespace Trinity
void Assert(char const* file, int line, char const* function, std::string debugInfo, char const* message)
{
- std::string formattedMessage = StringFormat("\n%s:%i in %s ASSERTION FAILED:\n %s\n", file, line, function, message) + debugInfo + '\n';
+ std::string formattedMessage = StringFormat("\n{}:{} in {} ASSERTION FAILED:\n {}\n", file, line, function, message) + debugInfo + '\n';
fprintf(stderr, "%s", formattedMessage.c_str());
fflush(stderr);
Crash(formattedMessage.c_str());
@@ -83,7 +83,7 @@ void Assert(char const* file, int line, char const* function, std::string debugI
va_list args;
va_start(args, format);
- std::string formattedMessage = StringFormat("\n%s:%i in %s ASSERTION FAILED:\n %s\n", file, line, function, message) + FormatAssertionMessage(format, args) + '\n' + debugInfo + '\n';
+ std::string formattedMessage = StringFormat("\n{}:{} in {} ASSERTION FAILED:\n {}\n", file, line, function, message) + FormatAssertionMessage(format, args) + '\n' + debugInfo + '\n';
va_end(args);
fprintf(stderr, "%s", formattedMessage.c_str());
@@ -97,7 +97,7 @@ void Fatal(char const* file, int line, char const* function, char const* message
va_list args;
va_start(args, message);
- std::string formattedMessage = StringFormat("\n%s:%i in %s FATAL ERROR:\n", file, line, function) + FormatAssertionMessage(message, args) + '\n';
+ std::string formattedMessage = StringFormat("\n{}:{} in {} FATAL ERROR:\n", file, line, function) + FormatAssertionMessage(message, args) + '\n';
va_end(args);
fprintf(stderr, "%s", formattedMessage.c_str());
@@ -109,7 +109,7 @@ void Fatal(char const* file, int line, char const* function, char const* message
void Error(char const* file, int line, char const* function, char const* message)
{
- std::string formattedMessage = StringFormat("\n%s:%i in %s ERROR:\n %s\n", file, line, function, message);
+ std::string formattedMessage = StringFormat("\n{}:{} in {} ERROR:\n {}\n", file, line, function, message);
fprintf(stderr, "%s", formattedMessage.c_str());
fflush(stderr);
Crash(formattedMessage.c_str());
@@ -123,7 +123,7 @@ void Warning(char const* file, int line, char const* function, char const* messa
void Abort(char const* file, int line, char const* function)
{
- std::string formattedMessage = StringFormat("\n%s:%i in %s ABORTED.\n", file, line, function);
+ std::string formattedMessage = StringFormat("\n{}:{} in {} ABORTED.\n", file, line, function);
fprintf(stderr, "%s", formattedMessage.c_str());
fflush(stderr);
Crash(formattedMessage.c_str());
@@ -134,7 +134,7 @@ void Abort(char const* file, int line, char const* function, char const* message
va_list args;
va_start(args, message);
- std::string formattedMessage = StringFormat("\n%s:%i in %s ABORTED:\n", file, line, function) + FormatAssertionMessage(message, args) + '\n';
+ std::string formattedMessage = StringFormat("\n{}:{} in {} ABORTED:\n", file, line, function) + FormatAssertionMessage(message, args) + '\n';
va_end(args);
fprintf(stderr, "%s", formattedMessage.c_str());
@@ -146,7 +146,7 @@ void Abort(char const* file, int line, char const* function, char const* message
void AbortHandler(int sigval)
{
// nothing useful to log here, no way to pass args
- std::string formattedMessage = StringFormat("Caught signal %i\n", sigval);
+ std::string formattedMessage = StringFormat("Caught signal {}\n", sigval);
fprintf(stderr, "%s", formattedMessage.c_str());
fflush(stderr);
Crash(formattedMessage.c_str());
diff --git a/src/common/IPLocation/IPLocation.cpp b/src/common/IPLocation/IPLocation.cpp
index 5d6343da95b..6d9dd409763 100644
--- a/src/common/IPLocation/IPLocation.cpp
+++ b/src/common/IPLocation/IPLocation.cpp
@@ -44,13 +44,13 @@ void IpLocationStore::Load()
std::ifstream databaseFile(databaseFilePath);
if (!databaseFile)
{
- TC_LOG_ERROR("server.loading", "IPLocation: No ip database file exists (%s).", databaseFilePath.c_str());
+ TC_LOG_ERROR("server.loading", "IPLocation: No ip database file exists ({}).", databaseFilePath);
return;
}
if (!databaseFile.is_open())
{
- TC_LOG_ERROR("server.loading", "IPLocation: Ip database file (%s) can not be opened.", databaseFilePath.c_str());
+ TC_LOG_ERROR("server.loading", "IPLocation: Ip database file ({}) can not be opened.", databaseFilePath);
return;
}
@@ -93,7 +93,7 @@ void IpLocationStore::Load()
databaseFile.close();
- TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " ip location entries.", _ipLocationStore.size());
+ TC_LOG_INFO("server.loading", ">> Loaded {} ip location entries.", _ipLocationStore.size());
}
IpLocationRecord const* IpLocationStore::GetLocationRecord(std::string const& ipAddress) const
diff --git a/src/common/Logging/Appender.cpp b/src/common/Logging/Appender.cpp
index 77c4352b469..12e441b2ed8 100644
--- a/src/common/Logging/Appender.cpp
+++ b/src/common/Logging/Appender.cpp
@@ -61,7 +61,7 @@ void Appender::write(LogMessage* message)
ss << message->getTimeStr() << ' ';
if (flags & APPENDER_FLAGS_PREFIX_LOGLEVEL)
- ss << Trinity::StringFormat("%-5s ", Appender::getLogLevelString(message->level));
+ ss << Trinity::StringFormat("{:<5} ", Appender::getLogLevelString(message->level));
if (flags & APPENDER_FLAGS_PREFIX_LOGFILTERTYPE)
ss << '[' << message->type << "] ";
diff --git a/src/common/Logging/AppenderConsole.cpp b/src/common/Logging/AppenderConsole.cpp
index fa146dc6960..460f2b6f500 100644
--- a/src/common/Logging/AppenderConsole.cpp
+++ b/src/common/Logging/AppenderConsole.cpp
@@ -47,8 +47,8 @@ void AppenderConsole::InitColors(std::string const& name, std::string_view str)
std::vector<std::string_view> colorStrs = Trinity::Tokenize(str, ' ', false);
if (colorStrs.size() != NUM_ENABLED_LOG_LEVELS)
{
- throw InvalidAppenderArgsException(Trinity::StringFormat("Log::CreateAppenderFromConfig: Invalid color data '%s' for console appender %s (expected %u entries, got %zu)",
- std::string(str).c_str(), name.c_str(), NUM_ENABLED_LOG_LEVELS, colorStrs.size()));
+ throw InvalidAppenderArgsException(Trinity::StringFormat("Log::CreateAppenderFromConfig: Invalid color data '{}' for console appender {} (expected {} entries, got {})",
+ str, name, NUM_ENABLED_LOG_LEVELS, colorStrs.size()));
}
for (uint8 i = 0; i < NUM_ENABLED_LOG_LEVELS; ++i)
@@ -57,8 +57,8 @@ void AppenderConsole::InitColors(std::string const& name, std::string_view str)
_colors[i] = static_cast<ColorTypes>(*color);
else
{
- throw InvalidAppenderArgsException(Trinity::StringFormat("Log::CreateAppenderFromConfig: Invalid color '%s' for log level %s on console appender %s",
- std::string(colorStrs[i]).c_str(), EnumUtils::ToTitle(static_cast<LogLevel>(i)), name.c_str()));
+ throw InvalidAppenderArgsException(Trinity::StringFormat("Log::CreateAppenderFromConfig: Invalid color '{}' for log level {} on console appender {}",
+ colorStrs[i], EnumUtils::ToTitle(static_cast<LogLevel>(i)), name));
}
}
diff --git a/src/common/Logging/AppenderFile.cpp b/src/common/Logging/AppenderFile.cpp
index f249f652a47..cf1aa0b7013 100644
--- a/src/common/Logging/AppenderFile.cpp
+++ b/src/common/Logging/AppenderFile.cpp
@@ -29,7 +29,7 @@ AppenderFile::AppenderFile(uint8 id, std::string const& name, LogLevel level, Ap
_fileSize(0)
{
if (args.size() < 4)
- throw InvalidAppenderArgsException(Trinity::StringFormat("Log::CreateAppenderFromConfig: Missing file name for appender %s", name.c_str()));
+ throw InvalidAppenderArgsException(Trinity::StringFormat("Log::CreateAppenderFromConfig: Missing file name for appender {}", name));
_fileName.assign(args[3]);
@@ -51,7 +51,7 @@ AppenderFile::AppenderFile(uint8 id, std::string const& name, LogLevel level, Ap
if (Optional<uint32> size = Trinity::StringTo<uint32>(args[5]))
_maxFileSize = *size;
else
- throw InvalidAppenderArgsException(Trinity::StringFormat("Log::CreateAppenderFromConfig: Invalid size '%s' for appender %s", std::string(args[5]).c_str(), name.c_str()));
+ throw InvalidAppenderArgsException(Trinity::StringFormat("Log::CreateAppenderFromConfig: Invalid size '{}' for appender {}", args[5], name));
}
_dynamicName = std::string::npos != _fileName.find("%s");
diff --git a/src/common/Logging/Log.cpp b/src/common/Logging/Log.cpp
index d0cc289780d..19523e60cc7 100644
--- a/src/common/Logging/Log.cpp
+++ b/src/common/Logging/Log.cpp
@@ -276,7 +276,7 @@ std::string Log::GetTimestampStr()
// SS seconds (2 digits 00-59)
try
{
- return Trinity::StringFormat("%04d-%02d-%02d_%02d-%02d-%02d",
+ return Trinity::StringFormat("{:04}-{:02}-{:02}_{:02}-{:02}-{:02}",
aTm.tm_year + 1900, aTm.tm_mon + 1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec);
}
catch (std::exception const& ex)
diff --git a/src/common/Logging/Log.h b/src/common/Logging/Log.h
index cb4a0a61b74..f835031aa2f 100644
--- a/src/common/Logging/Log.h
+++ b/src/common/Logging/Log.h
@@ -69,13 +69,13 @@ class TC_COMMON_API Log
bool SetLogLevel(std::string const& name, int32 level, bool isLogger = true);
template<typename... Args>
- void OutMessage(std::string_view filter, LogLevel const level, std::string_view fmt, Args&&... args)
+ void OutMessage(std::string_view filter, LogLevel const level, Trinity::FormatString<Args...> fmt, Args&&... args)
{
OutMessageImpl(filter, level, Trinity::StringFormat(fmt, std::forward<Args>(args)...));
}
template<typename... Args>
- void OutCommand(uint32 account, std::string_view fmt, Args&&... args)
+ void OutCommand(uint32 account, Trinity::FormatString<Args...> fmt, Args&&... args)
{
if (!ShouldLog("commands.gm", LOG_LEVEL_INFO))
return;
@@ -132,19 +132,12 @@ class TC_COMMON_API Log
#ifdef PERFORMANCE_PROFILING
#define TC_LOG_MESSAGE_BODY(filterType__, level__, ...) ((void)0)
#elif TRINITY_PLATFORM != TRINITY_PLATFORM_WINDOWS
-void check_args(char const*, ...) ATTR_PRINTF(1, 2);
-void check_args(std::string const&, ...);
// This will catch format errors on build time
#define TC_LOG_MESSAGE_BODY(filterType__, level__, ...) \
do { \
if (sLog->ShouldLog(filterType__, level__)) \
- { \
- if (false) \
- check_args(__VA_ARGS__); \
- \
sLog->OutMessage(filterType__, level__, __VA_ARGS__); \
- } \
} while (0)
#else
#define TC_LOG_MESSAGE_BODY(filterType__, level__, ...) \
diff --git a/src/common/Logging/LogMessage.cpp b/src/common/Logging/LogMessage.cpp
index 5f10087d1f0..a9a99312db1 100644
--- a/src/common/Logging/LogMessage.cpp
+++ b/src/common/Logging/LogMessage.cpp
@@ -33,7 +33,7 @@ std::string LogMessage::getTimeStr(time_t time)
{
tm aTm;
localtime_r(&time, &aTm);
- return Trinity::StringFormat("%04d-%02d-%02d_%02d:%02d:%02d", aTm.tm_year + 1900, aTm.tm_mon + 1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec);
+ return Trinity::StringFormat("{:04}-{:02}-{:02}_{:02}:{:02}:{:02}", aTm.tm_year + 1900, aTm.tm_mon + 1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec);
}
std::string LogMessage::getTimeStr() const
diff --git a/src/common/Metric/Metric.cpp b/src/common/Metric/Metric.cpp
index c924c233e02..7cd4f56fba5 100644
--- a/src/common/Metric/Metric.cpp
+++ b/src/common/Metric/Metric.cpp
@@ -41,8 +41,8 @@ bool Metric::Connect()
auto error = stream.error();
if (error)
{
- TC_LOG_ERROR("metric", "Error connecting to '%s:%s', disabling Metric. Error message : %s",
- _hostname.c_str(), _port.c_str(), error.message().c_str());
+ TC_LOG_ERROR("metric", "Error connecting to '{}:{}', disabling Metric. Error message : {}",
+ _hostname, _port, error.message());
_enabled = false;
return false;
}
@@ -57,14 +57,14 @@ void Metric::LoadFromConfigs()
_updateInterval = sConfigMgr->GetIntDefault("Metric.Interval", 1);
if (_updateInterval < 1)
{
- TC_LOG_ERROR("metric", "'Metric.Interval' config set to %d, overriding to 1.", _updateInterval);
+ TC_LOG_ERROR("metric", "'Metric.Interval' config set to {}, overriding to 1.", _updateInterval);
_updateInterval = 1;
}
_overallStatusTimerInterval = sConfigMgr->GetIntDefault("Metric.OverallStatusInterval", 1);
if (_overallStatusTimerInterval < 1)
{
- TC_LOG_ERROR("metric", "'Metric.OverallStatusInterval' config set to %d, overriding to 1.", _overallStatusTimerInterval);
+ TC_LOG_ERROR("metric", "'Metric.OverallStatusInterval' config set to {}, overriding to 1.", _overallStatusTimerInterval);
_overallStatusTimerInterval = 1;
}
@@ -206,7 +206,7 @@ void Metric::SendBatch()
GetDataStream() >> status_code;
if (status_code != 204)
{
- TC_LOG_ERROR("metric", "Error sending data, returned HTTP code: %u", status_code);
+ TC_LOG_ERROR("metric", "Error sending data, returned HTTP code: {}", status_code);
}
// Read and ignore the status description
diff --git a/src/common/Platform/ServiceWin32.cpp b/src/common/Platform/ServiceWin32.cpp
index 54ebbf5ec33..be827a8308a 100644
--- a/src/common/Platform/ServiceWin32.cpp
+++ b/src/common/Platform/ServiceWin32.cpp
@@ -253,7 +253,7 @@ bool WinServiceRun()
if (!StartServiceCtrlDispatcher(serviceTable))
{
- TC_LOG_ERROR("server.worldserver", "StartService Failed. Error [%u]", uint32(::GetLastError()));
+ TC_LOG_ERROR("server.worldserver", "StartService Failed. Error [{}]", uint32(::GetLastError()));
return false;
}
return true;
diff --git a/src/common/Threading/ProcessPriority.cpp b/src/common/Threading/ProcessPriority.cpp
index aafc1c49b04..135c6396d67 100644
--- a/src/common/Threading/ProcessPriority.cpp
+++ b/src/common/Threading/ProcessPriority.cpp
@@ -44,11 +44,11 @@ void SetProcessPriority(std::string const& logChannel, uint32 affinity, bool hig
ULONG_PTR currentAffinity = affinity & appAff;
if (!currentAffinity)
- TC_LOG_ERROR(logChannel, "Processors marked in UseProcessors bitmask (hex) %x are not accessible. Accessible processors bitmask (hex): %x", affinity, appAff);
+ TC_LOG_ERROR(logChannel, "Processors marked in UseProcessors bitmask (hex) {:x} are not accessible. Accessible processors bitmask (hex): {:x}", affinity, appAff);
else if (SetProcessAffinityMask(hProcess, currentAffinity))
- TC_LOG_INFO(logChannel, "Using processors (bitmask, hex): %x", currentAffinity);
+ TC_LOG_INFO(logChannel, "Using processors (bitmask, hex): {:x}", currentAffinity);
else
- TC_LOG_ERROR(logChannel, "Can't set used processors (hex): %x", currentAffinity);
+ TC_LOG_ERROR(logChannel, "Can't set used processors (hex): {:x}", currentAffinity);
}
}
@@ -72,21 +72,21 @@ void SetProcessPriority(std::string const& logChannel, uint32 affinity, bool hig
CPU_SET(i, &mask);
if (sched_setaffinity(0, sizeof(mask), &mask))
- TC_LOG_ERROR(logChannel, "Can't set used processors (hex): %x, error: %s", affinity, strerror(errno));
+ TC_LOG_ERROR(logChannel, "Can't set used processors (hex): {:x}, error: {}", affinity, strerror(errno));
else
{
CPU_ZERO(&mask);
sched_getaffinity(0, sizeof(mask), &mask);
- TC_LOG_INFO(logChannel, "Using processors (bitmask, hex): %lx", *(__cpu_mask*)(&mask));
+ TC_LOG_INFO(logChannel, "Using processors (bitmask, hex): {:x}", *(__cpu_mask*)(&mask));
}
}
if (highPriority)
{
if (setpriority(PRIO_PROCESS, 0, PROCESS_HIGH_PRIORITY))
- TC_LOG_ERROR(logChannel, "Can't set process priority class, error: %s", strerror(errno));
+ TC_LOG_ERROR(logChannel, "Can't set process priority class, error: {}", strerror(errno));
else
- TC_LOG_INFO(logChannel, "Process priority class set to %i", getpriority(PRIO_PROCESS, 0));
+ TC_LOG_INFO(logChannel, "Process priority class set to {}", getpriority(PRIO_PROCESS, 0));
}
#else
diff --git a/src/common/Utilities/StartProcess.cpp b/src/common/Utilities/StartProcess.cpp
index 00e5bc0bfe7..fc0dd54557f 100644
--- a/src/common/Utilities/StartProcess.cpp
+++ b/src/common/Utilities/StartProcess.cpp
@@ -87,8 +87,8 @@ static int CreateChildProcess(T waiter, std::string const& executable,
if (!secure)
{
- TC_LOG_TRACE(logger, "Starting process \"%s\" with arguments: \"%s\".",
- executable.c_str(), boost::algorithm::join(argsVector, " ").c_str());
+ TC_LOG_TRACE(logger, "Starting process \"{}\" with arguments: \"{}\".",
+ executable, boost::algorithm::join(argsVector, " "));
}
// prepare file with only read permission (boost process opens with read_write)
@@ -146,8 +146,8 @@ static int CreateChildProcess(T waiter, std::string const& executable,
if (!secure)
{
- TC_LOG_TRACE(logger, ">> Process \"%s\" finished with return value %i.",
- executable.c_str(), result);
+ TC_LOG_TRACE(logger, ">> Process \"{}\" finished with return value {}.",
+ executable, result);
}
return result;
diff --git a/src/common/Utilities/StringFormat.h b/src/common/Utilities/StringFormat.h
index 1de56097851..5802ae8d617 100644
--- a/src/common/Utilities/StringFormat.h
+++ b/src/common/Utilities/StringFormat.h
@@ -18,22 +18,24 @@
#ifndef TRINITYCORE_STRING_FORMAT_H
#define TRINITYCORE_STRING_FORMAT_H
-#include "fmt/printf.h"
+#include "fmt/core.h"
namespace Trinity
{
+ template<typename... Args>
+ using FormatString = std::string_view;
+
/// Default TC string format function.
template<typename... Args>
- std::string StringFormat(std::string_view fmt, Args&&... args)
+ inline std::string StringFormat(FormatString<Args...> fmt, Args&&... args)
{
try
{
- return fmt::sprintf(fmt, std::forward<Args>(args)...);
+ return fmt::format(fmt, std::forward<Args>(args)...);
}
- catch (fmt::format_error const& formatError)
+ catch (std::exception const& formatError)
{
- std::string error = "An error occurred formatting string \"" + std::string(fmt) + "\" : " + formatError.what();
- return error;
+ return fmt::format("An error occurred formatting string \"{}\" : {}", fmt, formatError.what());
}
}
@@ -50,7 +52,7 @@ namespace Trinity
}
/// Returns true if the given std::string_view is empty.
- inline bool IsFormatEmptyOrNull(std::string_view const& fmt)
+ inline constexpr bool IsFormatEmptyOrNull(std::string_view fmt)
{
return fmt.empty();
}
diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp
index 269784a0bfd..fdd49b49855 100644
--- a/src/common/Utilities/Util.cpp
+++ b/src/common/Utilities/Util.cpp
@@ -106,13 +106,13 @@ std::string secsToTimeString(uint64 timeInSecs, TimeFormat timeFormat, bool hour
if (timeFormat == TimeFormat::Numeric)
{
if (days)
- return Trinity::StringFormat("%u:%02u:%02u:%02u", days, hours, minutes, secs);
+ return Trinity::StringFormat("{}:{:02}:{:02}:{:02}", days, hours, minutes, secs);
else if (hours)
- return Trinity::StringFormat("%u:%02u:%02u", hours, minutes, secs);
+ return Trinity::StringFormat("{}:{:02}:{:02}", hours, minutes, secs);
else if (minutes)
- return Trinity::StringFormat("%u:%02u", minutes, secs);
+ return Trinity::StringFormat("{}:{:02}", minutes, secs);
else
- return Trinity::StringFormat("0:%02u", secs);
+ return Trinity::StringFormat("0:{:02}", secs);
}
std::ostringstream ss;
@@ -281,7 +281,7 @@ std::string TimeToTimestampStr(time_t t)
// HH hour (2 digits 00-23)
// MM minutes (2 digits 00-59)
// SS seconds (2 digits 00-59)
- return Trinity::StringFormat("%04d-%02d-%02d_%02d-%02d-%02d", aTm.tm_year + 1900, aTm.tm_mon + 1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec);
+ return Trinity::StringFormat("{:04}-{:02}-{:02}_{:02}-{:02}-{:02}", aTm.tm_year + 1900, aTm.tm_mon + 1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec);
}
std::string TimeToHumanReadable(time_t t)