summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2023-05-11 22:05:17 +0200
committerMattes D <github@xoft.cz>2023-05-16 23:50:37 +0200
commitc9522fb740200ccef6230cec452c48efb31e5394 (patch)
tree7e74d70699e13dd0a92444a1a0add7a3059ac7ca /Tools
parentTry a timeout for jobs. (diff)
downloadcuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar
cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.gz
cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.bz2
cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.lz
cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.xz
cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.zst
cuberite-c9522fb740200ccef6230cec452c48efb31e5394.zip
Diffstat (limited to 'Tools')
-rw-r--r--Tools/GrownBiomeGenVisualiser/GrownBiomeGenVisualiser.cpp10
-rw-r--r--Tools/ProtoProxy/Connection.cpp40
2 files changed, 24 insertions, 26 deletions
diff --git a/Tools/GrownBiomeGenVisualiser/GrownBiomeGenVisualiser.cpp b/Tools/GrownBiomeGenVisualiser/GrownBiomeGenVisualiser.cpp
index 31418b008..5201c28bf 100644
--- a/Tools/GrownBiomeGenVisualiser/GrownBiomeGenVisualiser.cpp
+++ b/Tools/GrownBiomeGenVisualiser/GrownBiomeGenVisualiser.cpp
@@ -38,7 +38,6 @@ void generateExamples(int a_Seed);
-
/** Color palette used for algorithm examples.
No relevance to biomes whatsoever. */
static const Color spectrumColors[] =
@@ -82,8 +81,7 @@ static const struct
{
EMCSBiome biome;
Color color;
-}
-biomeColorMap[] =
+} biomeColorMap[] =
{
{ biOcean, { 0x00, 0x00, 0x70 }, },
{ biPlains, { 0x8d, 0xb3, 0x60 }, },
@@ -271,7 +269,7 @@ void generateZoomLevels(int a_Seed)
gen->GetInts(0, 0, arrSize, arrSize, workspace);
// Output to a bitmap file:
- AString fnam = Printf("zoomedgrown_%u.pbm", i);
+ AString fnam = fmt::format(FMT_STRING("zoomedgrown_{}.pbm"), i);
outputBitmapFile(fnam, 257, 257, workspace, arrSize, arrSize, spectrumColors, ARRAYCOUNT(spectrumColors));
log(" zoom level %u complete", i);
} // for i - Image
@@ -309,7 +307,7 @@ void generateSmoothLevels(int a_Seed)
gen->GetInts(static_cast<int>(i), static_cast<int>(i), arrSize, arrSize, workspace);
// Output to a bitmap file:
- AString fnam = Printf("smoothedgrown_%u.ppm", i);
+ AString fnam = fmt::format(FMT_STRING("smoothedgrown_{}.ppm"), i);
outputBitmapFile(fnam, 257, 257, workspace, arrSize, arrSize, spectrumColors, ARRAYCOUNT(spectrumColors));
log(" smooth level %u complete", i);
} // for i - Image
@@ -404,7 +402,7 @@ void generateExamples(int a_Seed)
for (const auto & gen: gens)
{
gen.gen->GetInts(gen.offset, gen.offset, gen.size, gen.size, workspace);
- AString fnam = Printf("grownexample_%s.ppm", gen.name);
+ AString fnam = fmt::format(FMT_STRING("grownexample_{}.ppm"), gen.name);
outputBitmapFile(fnam, 256, 256, workspace, gen.size, gen.size, gen.colormap.colors, gen.colormap.count);
log(" Created example \"%s\"", gen.name);
} // for gen - gens[]
diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp
index 2bb6c9a43..2e8428058 100644
--- a/Tools/ProtoProxy/Connection.cpp
+++ b/Tools/ProtoProxy/Connection.cpp
@@ -43,7 +43,7 @@
{ \
return false; \
} \
- } while(false)
+ } while (false)
#define HANDLE_SERVER_PACKET_READ(Proc, Type, Var) \
Type Var; \
@@ -52,7 +52,7 @@
{ \
return false; \
} \
- } while(false)
+ } while (false)
#define CLIENTSEND(...) SendData(m_ClientSocket, __VA_ARGS__, "Client")
#define SERVERSEND(...) SendData(m_ServerSocket, __VA_ARGS__, "Server")
@@ -151,7 +151,8 @@ AString PrintableAbsIntTriplet(int a_X, int a_Y, int a_Z, double a_Divisor = 32)
AString PrintableAbsIntTriplet(int a_X, int a_Y, int a_Z, double a_Divisor)
{
- return Printf("<%d, %d, %d> ~ {%.02f, %.02f, %.02f}",
+ return fmt::format(
+ FMT_STRING("<{}, {}, {}> ~ {{{}, {}, {}}}"),
a_X, a_Y, a_Z,
static_cast<double>(a_X) / a_Divisor, static_cast<double>(a_Y) / a_Divisor, static_cast<double>(a_Z) / a_Divisor
);
@@ -214,7 +215,7 @@ cConnection::cConnection(SOCKET a_ClientSocket, cServer & a_Server) :
mkdir("Logs", 0777);
#endif
- Printf(m_LogNameBase, "Logs/Log_%d_%d", static_cast<int>(time(nullptr)), static_cast<int>(a_ClientSocket));
+ m_LogNameBase = fmt::format(FMT_STRING("Logs/Log_{}_{}"), time(nullptr), a_ClientSocket);
AString fnam(m_LogNameBase);
fnam.append(".log");
#ifdef _WIN32
@@ -223,7 +224,7 @@ cConnection::cConnection(SOCKET a_ClientSocket, cServer & a_Server) :
m_LogFile = fopen(fnam.c_str(), "w");
#endif
Log("Log file created");
- printf("Connection is logged to file \"%s\"\n", fnam.c_str());
+ fmt::print(FMT_STRING("Connection is logged to file \"{}\"\n"), fnam);
}
@@ -1795,12 +1796,12 @@ bool cConnection::HandleServerKick(void)
if (Split.size() == 6)
{
- Log(" Preamble: \"%s\"", Split[0].c_str());
- Log(" Protocol version: \"%s\"", Split[1].c_str());
- Log(" Server version: \"%s\"", Split[2].c_str());
- Log(" MOTD: \"%s\"", Split[3].c_str());
- Log(" Cur players: \"%s\"", Split[4].c_str());
- Log(" Max players: \"%s\"", Split[5].c_str());
+ Log(" Preamble: \"%s\"", Split[0]);
+ Log(" Protocol version: \"%s\"", Split[1]);
+ Log(" Server version: \"%s\"", Split[2]);
+ Log(" MOTD: \"%s\"", Split[3]);
+ Log(" Cur players: \"%s\"", Split[4]);
+ Log(" Max players: \"%s\"", Split[5]);
// Modify the MOTD to show that it's being ProtoProxied:
Reason.assign(Split[0]);
@@ -1809,7 +1810,7 @@ bool cConnection::HandleServerKick(void)
Reason.push_back(0);
Reason.append(Split[2]);
Reason.push_back(0);
- Reason.append(Printf("ProtoProxy: %s", Split[3].c_str()));
+ Reason.append(fmt::format(FMT_STRING("ProtoProxy: {}"), Split[3]));
Reason.push_back(0);
Reason.append(Split[4]);
Reason.push_back(0);
@@ -1829,7 +1830,7 @@ bool cConnection::HandleServerKick(void)
}
else
{
- Log(" Reason = \"%s\"", Reason.c_str());
+ Log(" Reason = \"%s\"", Reason);
}
COPY_TO_CLIENT();
return true;
@@ -2407,6 +2408,7 @@ bool cConnection::HandleServerStatistics(void)
+
bool cConnection::HandleServerStatusPing(void)
{
HANDLE_SERVER_PACKET_READ(ReadBEInt64, Int64, Time);
@@ -2548,8 +2550,7 @@ bool cConnection::HandleServerUpdateTileEntity(void)
DataLog(Data.data(), Data.size(), " Data (%u bytes)", DataLength);
// Save metadata to a file:
- AString fnam;
- Printf(fnam, "%s_tile_%08x.nbt", m_LogNameBase.c_str(), m_ItemIdx++);
+ auto fnam = fmt::format(FMT_STRING("{}_tile_{:08x}.nbt"), m_LogNameBase, m_ItemIdx++);
FILE * f = fopen(fnam.c_str(), "wb");
if (f != nullptr)
{
@@ -2691,7 +2692,7 @@ bool cConnection::ParseSlot(cByteBuffer & a_Buffer, AString & a_ItemDesc)
a_Buffer.ReadBEInt8(ItemCount); // We already know we can read these bytes - we checked before.
a_Buffer.ReadBEInt16(ItemDamage);
a_Buffer.ReadBEUInt16(MetadataLength);
- Printf(a_ItemDesc, "%d:%d * %d", ItemType, ItemDamage, ItemCount);
+ a_ItemDesc = fmt::format(FMT_STRING("{}:{} * {}"), ItemType, ItemDamage, ItemCount);
if (MetadataLength <= 0)
{
return true;
@@ -2704,17 +2705,16 @@ bool cConnection::ParseSlot(cByteBuffer & a_Buffer, AString & a_ItemDesc)
}
AString MetaHex;
CreateHexDump(MetaHex, Metadata.data(), Metadata.size(), 16);
- AppendPrintf(a_ItemDesc, "; %u bytes of meta:\n%s", MetadataLength, MetaHex.c_str());
+ a_ItemDesc.append(fmt::format(FMT_STRING("; {} bytes of meta:\n{}"), MetadataLength, MetaHex));
// Save metadata to a file:
- AString fnam;
- Printf(fnam, "%s_item_%08x.nbt", m_LogNameBase.c_str(), m_ItemIdx++);
+ auto fnam = fmt::format(FMT_STRING("{}_item_{:08x}.nbt"), m_LogNameBase, m_ItemIdx++);
FILE * f = fopen(fnam.c_str(), "wb");
if (f != nullptr)
{
fwrite(Metadata.data(), 1, Metadata.size(), f);
fclose(f);
- AppendPrintf(a_ItemDesc, "\n (saved to file \"%s\")", fnam.c_str());
+ a_ItemDesc.append(fmt::format(FMT_STRING("\n (saved to file \"{}\")"), fnam));
}
return true;