From 757231cc6e777b8f4717d1467ef7efa01c7fde15 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Wed, 3 Jan 2018 17:41:16 +0000 Subject: Add the fmt library (#4065) * Replaces AppendVPrintf with fmt::sprintf * fmt::ArgList now used as a type safe alternative to varargs. * Removed SIZE_T_FMT compatibility macros. fmt::sprintf is fully portable and supports %zu. * Adds FLOG functions to log with fmt's native formatting style. --- src/WorldStorage/CMakeLists.txt | 3 +-- src/WorldStorage/MapSerializer.cpp | 8 ++++---- src/WorldStorage/ScoreboardSerializer.cpp | 4 ++-- src/WorldStorage/StatSerializer.cpp | 2 +- src/WorldStorage/WSSAnvil.cpp | 8 ++++---- 5 files changed, 12 insertions(+), 13 deletions(-) (limited to 'src/WorldStorage') diff --git a/src/WorldStorage/CMakeLists.txt b/src/WorldStorage/CMakeLists.txt index d9e066b32..afb3ef179 100644 --- a/src/WorldStorage/CMakeLists.txt +++ b/src/WorldStorage/CMakeLists.txt @@ -30,6 +30,5 @@ SET (HDRS if(NOT MSVC) add_library(WorldStorage ${SRCS} ${HDRS}) - - target_link_libraries(WorldStorage OSSupport) + target_link_libraries(WorldStorage fmt::fmt OSSupport) endif() diff --git a/src/WorldStorage/MapSerializer.cpp b/src/WorldStorage/MapSerializer.cpp index c34efe507..381ef19fa 100644 --- a/src/WorldStorage/MapSerializer.cpp +++ b/src/WorldStorage/MapSerializer.cpp @@ -19,9 +19,9 @@ cMapSerializer::cMapSerializer(const AString & a_WorldName, cMap * a_Map): m_Map(a_Map) { AString DataPath; - Printf(DataPath, "%s%cdata", a_WorldName.c_str(), cFile::PathSeparator); + Printf(DataPath, "%s%cdata", a_WorldName.c_str(), cFile::PathSeparator()); - Printf(m_Path, "%s%cmap_%i.dat", DataPath.c_str(), cFile::PathSeparator, a_Map->GetID()); + Printf(m_Path, "%s%cmap_%i.dat", DataPath.c_str(), cFile::PathSeparator(), a_Map->GetID()); cFile::CreateFolder(FILE_IO_PREFIX + DataPath); } @@ -203,9 +203,9 @@ bool cMapSerializer::LoadMapFromNBT(const cParsedNBT & a_NBT) cIDCountSerializer::cIDCountSerializer(const AString & a_WorldName) : m_MapCount(0) { AString DataPath; - Printf(DataPath, "%s%cdata", a_WorldName.c_str(), cFile::PathSeparator); + Printf(DataPath, "%s%cdata", a_WorldName.c_str(), cFile::PathSeparator()); - Printf(m_Path, "%s%cidcounts.dat", DataPath.c_str(), cFile::PathSeparator); + Printf(m_Path, "%s%cidcounts.dat", DataPath.c_str(), cFile::PathSeparator()); cFile::CreateFolder(FILE_IO_PREFIX + DataPath); } diff --git a/src/WorldStorage/ScoreboardSerializer.cpp b/src/WorldStorage/ScoreboardSerializer.cpp index 27ce36455..367b88c0d 100644 --- a/src/WorldStorage/ScoreboardSerializer.cpp +++ b/src/WorldStorage/ScoreboardSerializer.cpp @@ -18,9 +18,9 @@ cScoreboardSerializer::cScoreboardSerializer(const AString & a_WorldName, cScore m_ScoreBoard(a_ScoreBoard) { AString DataPath; - Printf(DataPath, "%s%cdata", a_WorldName.c_str(), cFile::PathSeparator); + Printf(DataPath, "%s%cdata", a_WorldName.c_str(), cFile::PathSeparator()); - m_Path = DataPath + cFile::PathSeparator + "scoreboard.dat"; + m_Path = DataPath + cFile::PathSeparator() + "scoreboard.dat"; cFile::CreateFolder(FILE_IO_PREFIX + DataPath); } diff --git a/src/WorldStorage/StatSerializer.cpp b/src/WorldStorage/StatSerializer.cpp index c8a4c0951..ecedd87ce 100644 --- a/src/WorldStorage/StatSerializer.cpp +++ b/src/WorldStorage/StatSerializer.cpp @@ -18,7 +18,7 @@ cStatSerializer::cStatSerializer(const AString & a_WorldName, const AString & a_ // inside the folder of the default world. AString StatsPath; - Printf(StatsPath, "%s%cstats", a_WorldName.c_str(), cFile::PathSeparator); + Printf(StatsPath, "%s%cstats", a_WorldName.c_str(), cFile::PathSeparator()); m_LegacyPath = StatsPath + "/" + a_PlayerName + ".json"; m_Path = StatsPath + "/" + a_FileName + ".json"; diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 35fdaa8d8..048220a31 100755 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -85,7 +85,7 @@ cWSSAnvil::cWSSAnvil(cWorld * a_World, int a_CompressionFactor) : { // Create a level.dat file for mapping tools, if it doesn't already exist: AString fnam; - Printf(fnam, "%s%clevel.dat", a_World->GetDataPath().c_str(), cFile::PathSeparator); + Printf(fnam, "%s%clevel.dat", a_World->GetDataPath().c_str(), cFile::PathSeparator()); if (!cFile::Exists(fnam)) { cFastNBTWriter Writer; @@ -180,7 +180,7 @@ void cWSSAnvil::ChunkLoadFailed(int a_ChunkX, int a_ChunkZ, const AString & a_Re { // Construct the filename for offloading: AString OffloadFileName; - Printf(OffloadFileName, "%s%cregion%cbadchunks", m_World->GetDataPath().c_str(), cFile::PathSeparator, cFile::PathSeparator); + Printf(OffloadFileName, "%s%cregion%cbadchunks", m_World->GetDataPath().c_str(), cFile::PathSeparator(), cFile::PathSeparator()); cFile::CreateFolder(FILE_IO_PREFIX + OffloadFileName); auto t = time(nullptr); struct tm stm; @@ -190,7 +190,7 @@ void cWSSAnvil::ChunkLoadFailed(int a_ChunkX, int a_ChunkZ, const AString & a_Re localtime_r(&t, &stm); #endif AppendPrintf(OffloadFileName, "%cch.%d.%d.%d-%02d-%02d-%02d-%02d-%02d.dat", - cFile::PathSeparator, a_ChunkX, a_ChunkZ, + cFile::PathSeparator(), a_ChunkX, a_ChunkZ, stm.tm_year + 1900, stm.tm_mon + 1, stm.tm_mday, stm.tm_hour, stm.tm_min, stm.tm_sec ); @@ -286,7 +286,7 @@ cWSSAnvil::cMCAFile * cWSSAnvil::LoadMCAFile(const cChunkCoords & a_Chunk) // Load it anew: AString FileName; - Printf(FileName, "%s%cregion", m_World->GetDataPath().c_str(), cFile::PathSeparator); + Printf(FileName, "%s%cregion", m_World->GetDataPath().c_str(), cFile::PathSeparator()); cFile::CreateFolder(FILE_IO_PREFIX + FileName); AppendPrintf(FileName, "/r.%d.%d.mca", RegionX, RegionZ); cMCAFile * f = new cMCAFile(*this, FileName, RegionX, RegionZ); -- cgit v1.2.3