From 4727ed20846bb3d1a9eabb27aaaa9c5524129556 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Mon, 24 Sep 2018 21:33:39 +0100 Subject: Add a formatting function for Vector3 (#4282) * Vector3: Add custom fmt compatible formatter. * cLuaState: Add fmt version of ApiParamError * Use vector formatting in manual bindings * Always log vectors with FLOG --- src/Generating/FinishGen.cpp | 4 ++-- src/Generating/PieceGeneratorBFSTree.cpp | 14 ++++++-------- src/Generating/PrefabPiecePool.cpp | 9 ++++++--- 3 files changed, 14 insertions(+), 13 deletions(-) (limited to 'src/Generating') diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index ec5c0c144..3c608e026 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -1548,7 +1548,7 @@ bool cFinishGenPassiveMobs::TrySpawnAnimals(cChunkDesc & a_ChunkDesc, int a_RelX auto NewMob = cMonster::NewMonsterFromType(AnimalToSpawn); NewMob->SetHealth(NewMob->GetMaxHealth()); NewMob->SetPosition(AnimalX, AnimalY, AnimalZ); - LOGD("Spawning %s #%i at {%.02f, %.02f, %.02f}", NewMob->GetClass(), NewMob->GetUniqueID(), AnimalX, AnimalY, AnimalZ); + FLOGD("Spawning {0} #{1} at {2:.02f}", NewMob->GetClass(), NewMob->GetUniqueID(), NewMob->GetPosition()); a_ChunkDesc.GetEntities().emplace_back(std::move(NewMob)); return true; @@ -1988,7 +1988,7 @@ void cFinishGenOrePockets::imprintSphere( (blockZ >= baseZ) && (blockZ < baseZ + cChunkDef::Width) ) { - // LOGD("Imprinting a sphere center at {%d, %d, %d}", blockX, blockY, blockZ); + // FLOGD("Imprinting a sphere center at {0}", Vector3i{blockX, blockY, blockZ}); a_ChunkDesc.SetBlockTypeMeta(blockX - baseX, blockY, blockZ - baseZ, a_OreType, a_OreMeta); } return; diff --git a/src/Generating/PieceGeneratorBFSTree.cpp b/src/Generating/PieceGeneratorBFSTree.cpp index 1d0be3482..b6929d4b0 100644 --- a/src/Generating/PieceGeneratorBFSTree.cpp +++ b/src/Generating/PieceGeneratorBFSTree.cpp @@ -235,12 +235,11 @@ void cPieceGeneratorBFSTree::PlacePieces(int a_BlockX, int a_BlockZ, int a_MaxDe /* // DEBUG: - printf("Placed the starting piece at {%d, %d, %d}\n", a_BlockX, a_BlockY, a_BlockZ); + FLOGD("Placed the starting piece at {0}", Vector3i{a_BlockX, a_BlockY, a_BlockZ}); cCuboid Hitbox = a_OutPieces[0]->GetHitBox(); Hitbox.Sort(); - printf(" Hitbox: {%d, %d, %d} - {%d, %d, %d} (%d * %d * %d)\n", - Hitbox.p1.x, Hitbox.p1.y, Hitbox.p1.z, - Hitbox.p2.x, Hitbox.p2.y, Hitbox.p2.z, + FLOGD(" Hitbox: {0} - {1} ({2} * {3} * {4})\n", + Hitbox.p1, Hitbox.p2, Hitbox.DifX() + 1, Hitbox.DifY() + 1, Hitbox.DifZ() + 1 ); DebugConnectorPool(ConnectorPool, 0); @@ -264,12 +263,11 @@ void cPieceGeneratorBFSTree::PlacePieces(int a_BlockX, int a_BlockZ, int a_MaxDe // DEBUG: const cPlacedPiece * NewPiece = a_OutPieces.back(); const Vector3i & Coords = NewPiece->GetCoords(); - printf("Placed a new piece at {%d, %d, %d}, rotation %d\n", Coords.x, Coords.y, Coords.z, NewPiece->GetNumCCWRotations()); + FLOGD("Placed a new piece at {0}, rotation {1}\n", Coords, NewPiece->GetNumCCWRotations()); cCuboid Hitbox = NewPiece->GetHitBox(); Hitbox.Sort(); - printf(" Hitbox: {%d, %d, %d} - {%d, %d, %d} (%d * %d * %d)\n", - Hitbox.p1.x, Hitbox.p1.y, Hitbox.p1.z, - Hitbox.p2.x, Hitbox.p2.y, Hitbox.p2.z, + FLOGD(" Hitbox: {0} - {1} ({2} * {3} * {4})\n", + Hitbox.p1, Hitbox.p2, Hitbox.DifX() + 1, Hitbox.DifY() + 1, Hitbox.DifZ() + 1 ); DebugConnectorPool(ConnectorPool, NumProcessed + 1); diff --git a/src/Generating/PrefabPiecePool.cpp b/src/Generating/PrefabPiecePool.cpp index 16d1f3440..ed5283dec 100644 --- a/src/Generating/PrefabPiecePool.cpp +++ b/src/Generating/PrefabPiecePool.cpp @@ -498,9 +498,12 @@ bool cPrefabPiecePool::ReadConnectorsCubesetVer1( !cPiece::cConnector::StringToDirection(DirectionStr, Direction) ) { - CONDWARNING(a_LogWarnings, "Piece %s in file %s has a malformed Connector at index %d ({%d, %d, %d}, type %d, direction %s). Skipping the connector.", - a_PieceName.c_str(), a_FileName.c_str(), idx, RelX, RelY, RelZ, Type, DirectionStr.c_str() - ); + if (a_LogWarnings) + { + FLOGWARNING("Piece {0} in file {1} has a malformed Connector at index {2} ({3}, type {4}, direction {5}). Skipping the connector.", + a_PieceName, a_FileName, idx, Vector3i{RelX, RelY, RelZ}, Type, DirectionStr + ); + } res = false; lua_pop(a_LuaState, 1); // stk: [Connectors] idx += 1; -- cgit v1.2.3