From 13144a08e496b89b34093ffd3d810d3442df3c44 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Thu, 14 May 2020 23:15:35 +0100 Subject: Enable some more clang-tidy linter checks (#4738) * Avoid inefficient AString -> c_str() -> AString round trip * Avoid redundant string init expressions * Avoid unnecessary return, continue, etc. * Add .clang-format to help with clang-tidy fix-its * Avoid unnecessary passing by value * Avoid unnecessary local copying * Avoid copying in range-for loops * Avoid over-complicated boolean expressions * Some violations missed by my local clang-tidy * Allow unnecessary continue statements * Add brackets * Another expression missed locally * Move BindingsProcessor call into clang-tidy.sh and add space * Fix pushd not found error * Different grouping of CheckBlockInteractionRate --- src/Generating/BioGen.cpp | 6 ++-- src/Generating/BioGen.h | 2 +- src/Generating/CompoGen.cpp | 2 +- src/Generating/ComposableGenerator.cpp | 4 +-- src/Generating/ComposableGenerator.h | 8 +++--- src/Generating/CompositedHeiGen.h | 6 ++-- src/Generating/DistortedHeightmap.cpp | 2 +- src/Generating/DistortedHeightmap.h | 2 +- src/Generating/DungeonRoomsFinisher.cpp | 2 +- src/Generating/FinishGen.cpp | 2 +- src/Generating/FinishGen.h | 4 +-- src/Generating/HeiGen.cpp | 8 +++--- src/Generating/HeiGen.h | 4 +-- src/Generating/Noise3DGenerator.cpp | 2 +- src/Generating/PiecePool.h | 2 +- src/Generating/PieceStructuresGen.cpp | 6 ++-- src/Generating/PieceStructuresGen.h | 2 +- src/Generating/PrefabStructure.cpp | 2 +- src/Generating/ProtIntGen.h | 50 ++++++++++++++++----------------- src/Generating/ShapeGen.cpp | 4 +-- src/Generating/StructGen.h | 8 +++--- src/Generating/Trees.cpp | 2 +- src/Generating/TwoHeights.cpp | 4 +-- src/Generating/TwoHeights.h | 2 +- src/Generating/VillageGen.cpp | 6 ++-- 25 files changed, 71 insertions(+), 71 deletions(-) (limited to 'src/Generating') diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp index f6122244b..99ed54cbd 100644 --- a/src/Generating/BioGen.cpp +++ b/src/Generating/BioGen.cpp @@ -58,7 +58,7 @@ void cBioGenConstant::InitializeBiomeGen(cIniFile & a_IniFile) // cBioGenCache: cBioGenCache::cBioGenCache(cBiomeGenPtr a_BioGenToCache, size_t a_CacheSize) : - m_BioGenToCache(a_BioGenToCache), + m_BioGenToCache(std::move(a_BioGenToCache)), m_CacheSize(a_CacheSize), m_NumHits(0), m_NumMisses(0), @@ -139,7 +139,7 @@ void cBioGenCache::InitializeBiomeGen(cIniFile & a_IniFile) //////////////////////////////////////////////////////////////////////////////// // cBioGenMulticache: -cBioGenMulticache::cBioGenMulticache(cBiomeGenPtr a_BioGenToCache, size_t a_SubCacheSize, size_t a_NumSubCaches) : +cBioGenMulticache::cBioGenMulticache(const cBiomeGenPtr & a_BioGenToCache, size_t a_SubCacheSize, size_t a_NumSubCaches) : m_NumSubCaches(a_NumSubCaches) { m_Caches.reserve(a_NumSubCaches); @@ -167,7 +167,7 @@ void cBioGenMulticache::GenBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMa void cBioGenMulticache::InitializeBiomeGen(cIniFile & a_IniFile) { - for (auto itr : m_Caches) + for (const auto & itr : m_Caches) { itr->InitializeBiomeGen(a_IniFile); } diff --git a/src/Generating/BioGen.h b/src/Generating/BioGen.h index ee297adb2..c23c8ac46 100644 --- a/src/Generating/BioGen.h +++ b/src/Generating/BioGen.h @@ -97,7 +97,7 @@ public: This allows us to use shorter cache depths with faster lookups for more covered area. (#381) a_SubCacheSize defines the size of each sub-cache a_NumSubCaches defines how many sub-caches are used for the multicache. */ - cBioGenMulticache(cBiomeGenPtr a_BioGenToCache, size_t a_SubCacheSize, size_t a_NumSubCaches); + cBioGenMulticache(const cBiomeGenPtr & a_BioGenToCache, size_t a_SubCacheSize, size_t a_NumSubCaches); protected: typedef std::vector cBiomeGenPtrs; diff --git a/src/Generating/CompoGen.cpp b/src/Generating/CompoGen.cpp index 13b05222c..f17846359 100644 --- a/src/Generating/CompoGen.cpp +++ b/src/Generating/CompoGen.cpp @@ -330,7 +330,7 @@ void cCompoGenNether::InitializeCompoGen(cIniFile & a_IniFile) // cCompoGenCache: cCompoGenCache::cCompoGenCache(cTerrainCompositionGenPtr a_Underlying, int a_CacheSize) : - m_Underlying(a_Underlying), + m_Underlying(std::move(a_Underlying)), m_CacheSize(a_CacheSize), m_CacheOrder(new int[ToUnsigned(a_CacheSize)]), m_CacheData(new sCacheData[ToUnsigned(a_CacheSize)]), diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index f87d63493..5dd54a497 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -39,8 +39,8 @@ cTerrainCompositionGenPtr cTerrainCompositionGen::CreateCompositionGen( cIniFile & a_IniFile, - cBiomeGenPtr a_BiomeGen, - cTerrainShapeGenPtr a_ShapeGen, + const cBiomeGenPtr & a_BiomeGen, + const cTerrainShapeGenPtr & a_ShapeGen, int a_Seed ) { diff --git a/src/Generating/ComposableGenerator.h b/src/Generating/ComposableGenerator.h index f0960f1d3..661a7276b 100644 --- a/src/Generating/ComposableGenerator.h +++ b/src/Generating/ComposableGenerator.h @@ -98,7 +98,7 @@ public: */ static cTerrainShapeGenPtr CreateShapeGen( cIniFile & a_IniFile, - cBiomeGenPtr a_BiomeGen, + const cBiomeGenPtr & a_BiomeGen, int a_Seed, bool & a_CacheOffByDefault ); @@ -137,7 +137,7 @@ public: /** Creates a cTerrainHeightGen descendant based on the INI file settings. */ static cTerrainHeightGenPtr CreateHeightGen( cIniFile & a_IniFile, - cBiomeGenPtr a_BiomeGen, + const cBiomeGenPtr & a_BiomeGen, int a_Seed, bool & a_CacheOffByDefault ); @@ -169,8 +169,8 @@ public: a_ShapeGen is the underlying shape generator, some composition generators may depend on it providing additional shape around the chunk. */ static cTerrainCompositionGenPtr CreateCompositionGen( cIniFile & a_IniFile, - cBiomeGenPtr a_BiomeGen, - cTerrainShapeGenPtr a_ShapeGen, + const cBiomeGenPtr & a_BiomeGen, + const cTerrainShapeGenPtr & a_ShapeGen, int a_Seed ); } ; diff --git a/src/Generating/CompositedHeiGen.h b/src/Generating/CompositedHeiGen.h index 4c1d4b783..400008d88 100644 --- a/src/Generating/CompositedHeiGen.h +++ b/src/Generating/CompositedHeiGen.h @@ -21,9 +21,9 @@ class cCompositedHeiGen: { public: cCompositedHeiGen(cBiomeGenPtr a_BiomeGen, cTerrainShapeGenPtr a_ShapeGen, cTerrainCompositionGenPtr a_CompositionGen): - m_BiomeGen(a_BiomeGen), - m_ShapeGen(a_ShapeGen), - m_CompositionGen(a_CompositionGen) + m_BiomeGen(std::move(a_BiomeGen)), + m_ShapeGen(std::move(a_ShapeGen)), + m_CompositionGen(std::move(a_CompositionGen)) { } diff --git a/src/Generating/DistortedHeightmap.cpp b/src/Generating/DistortedHeightmap.cpp index 1b1737e8c..11c873967 100644 --- a/src/Generating/DistortedHeightmap.cpp +++ b/src/Generating/DistortedHeightmap.cpp @@ -118,7 +118,7 @@ const cDistortedHeightmap::sGenParam cDistortedHeightmap::m_GenParam[256] = -cDistortedHeightmap::cDistortedHeightmap(int a_Seed, cBiomeGenPtr a_BiomeGen) : +cDistortedHeightmap::cDistortedHeightmap(int a_Seed, const cBiomeGenPtr & a_BiomeGen) : m_NoiseDistortX(a_Seed + 1000), m_NoiseDistortZ(a_Seed + 2000), m_CurChunkCoords(0x7fffffff, 0x7fffffff), // Set impossible coords for the chunk so that it's always considered stale diff --git a/src/Generating/DistortedHeightmap.h b/src/Generating/DistortedHeightmap.h index d27ad098b..bc6d079ba 100644 --- a/src/Generating/DistortedHeightmap.h +++ b/src/Generating/DistortedHeightmap.h @@ -26,7 +26,7 @@ class cDistortedHeightmap : public cTerrainShapeGen { public: - cDistortedHeightmap(int a_Seed, cBiomeGenPtr a_BiomeGen); + cDistortedHeightmap(int a_Seed, const cBiomeGenPtr & a_BiomeGen); protected: typedef cChunkDef::BiomeMap BiomeNeighbors[3][3]; diff --git a/src/Generating/DungeonRoomsFinisher.cpp b/src/Generating/DungeonRoomsFinisher.cpp index 4299f71a7..4196e16ee 100644 --- a/src/Generating/DungeonRoomsFinisher.cpp +++ b/src/Generating/DungeonRoomsFinisher.cpp @@ -289,7 +289,7 @@ protected: cDungeonRoomsFinisher::cDungeonRoomsFinisher(cTerrainShapeGenPtr a_ShapeGen, int a_Seed, int a_GridSize, int a_MaxSize, int a_MinSize, const AString & a_HeightDistrib) : Super(a_Seed + 100, a_GridSize, a_GridSize, a_GridSize, a_GridSize, a_MaxSize, a_MaxSize, 1024), - m_ShapeGen(a_ShapeGen), + m_ShapeGen(std::move(a_ShapeGen)), m_MaxHalfSize((a_MaxSize + 1) / 2), m_MinHalfSize((a_MinSize + 1) / 2), m_HeightProbability(cChunkDef::Height) diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 5b328ec49..1593c6928 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -275,7 +275,7 @@ void cFinishGenClumpTopBlock::TryPlaceFoliageClump(cChunkDesc & a_ChunkDesc, int -void cFinishGenClumpTopBlock::ParseConfigurationString(AString a_RawClumpInfo, std::vector & a_Output) +void cFinishGenClumpTopBlock::ParseConfigurationString(const AString & a_RawClumpInfo, std::vector & a_Output) { // Initialize the vector for all biomes. for (int i = static_cast(a_Output.size()); i < static_cast(biMaxVariantBiome); i++) diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index 4dfd35a7c..22292d924 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -104,7 +104,7 @@ public: BiomeInfo(int a_MinNumClumpsPerChunk, int a_MaxNumClumpsPerChunk, std::vector a_Blocks) : m_MinNumClumpsPerChunk(a_MinNumClumpsPerChunk), m_MaxNumClumpsPerChunk(a_MaxNumClumpsPerChunk), - m_Blocks(a_Blocks) + m_Blocks(std::move(a_Blocks)) {} }; @@ -118,7 +118,7 @@ public: /** Parses a string and puts a vector with a length of biMaxVariantBiome in a_Output. The format of the string is ";". This can also be repeated with a | */ - static void ParseConfigurationString(AString a_String, std::vector & a_Output); + static void ParseConfigurationString(const AString & a_String, std::vector & a_Output); /** Parses an inifile in search for all clumps */ static std::vector ParseIniFile(cIniFile & a_IniFile, AString a_ClumpPrefix); diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp index 515fdf4ba..e60f20a03 100644 --- a/src/Generating/HeiGen.cpp +++ b/src/Generating/HeiGen.cpp @@ -107,7 +107,7 @@ void cHeiGenFlat::InitializeHeightGen(cIniFile & a_IniFile) // cHeiGenCache: cHeiGenCache::cHeiGenCache(cTerrainHeightGenPtr a_HeiGenToCache, size_t a_CacheSize) : - m_HeiGenToCache(a_HeiGenToCache), + m_HeiGenToCache(std::move(a_HeiGenToCache)), m_CacheSize(a_CacheSize), m_NumHits(0), m_NumMisses(0), @@ -219,7 +219,7 @@ bool cHeiGenCache::GetHeightAt(int a_ChunkX, int a_ChunkZ, int a_RelX, int a_Rel //////////////////////////////////////////////////////////////////////////////// // cHeiGenMultiCache: -cHeiGenMultiCache::cHeiGenMultiCache(cTerrainHeightGenPtr a_HeiGenToCache, size_t a_SubCacheSize, size_t a_NumSubCaches): +cHeiGenMultiCache::cHeiGenMultiCache(const cTerrainHeightGenPtr & a_HeiGenToCache, size_t a_SubCacheSize, size_t a_NumSubCaches): m_NumSubCaches(a_NumSubCaches) { // Create the individual sub-caches: @@ -638,7 +638,7 @@ public: cHeiGenMinMax(int a_Seed, cBiomeGenPtr a_BiomeGen): m_Noise(a_Seed), - m_BiomeGen(a_BiomeGen), + m_BiomeGen(std::move(a_BiomeGen)), m_TotalWeight(0) { // Initialize the weights: @@ -831,7 +831,7 @@ protected: //////////////////////////////////////////////////////////////////////////////// // cTerrainHeightGen: -cTerrainHeightGenPtr cTerrainHeightGen::CreateHeightGen(cIniFile & a_IniFile, cBiomeGenPtr a_BiomeGen, int a_Seed, bool & a_CacheOffByDefault) +cTerrainHeightGenPtr cTerrainHeightGen::CreateHeightGen(cIniFile & a_IniFile, const cBiomeGenPtr & a_BiomeGen, int a_Seed, bool & a_CacheOffByDefault) { AString HeightGenName = a_IniFile.GetValueSet("Generator", "HeightGen", ""); if (HeightGenName.empty()) diff --git a/src/Generating/HeiGen.h b/src/Generating/HeiGen.h index c8118860e..ebdfef70f 100644 --- a/src/Generating/HeiGen.h +++ b/src/Generating/HeiGen.h @@ -73,7 +73,7 @@ class cHeiGenMultiCache: public cTerrainHeightGen { public: - cHeiGenMultiCache(cTerrainHeightGenPtr a_HeightGenToCache, size_t a_SubCacheSize, size_t a_NumSubCaches); + cHeiGenMultiCache(const cTerrainHeightGenPtr & a_HeightGenToCache, size_t a_SubCacheSize, size_t a_NumSubCaches); // cTerrainHeightGen overrides: virtual void GenHeightMap(cChunkCoords a_ChunkCoords, cChunkDef::HeightMap & a_HeightMap) override; @@ -176,7 +176,7 @@ public: cHeiGenBiomal(int a_Seed, cBiomeGenPtr a_BiomeGen): m_Noise(a_Seed), - m_BiomeGen(a_BiomeGen) + m_BiomeGen(std::move(a_BiomeGen)) { } diff --git a/src/Generating/Noise3DGenerator.cpp b/src/Generating/Noise3DGenerator.cpp index 0826ca764..362c6d9a2 100644 --- a/src/Generating/Noise3DGenerator.cpp +++ b/src/Generating/Noise3DGenerator.cpp @@ -511,7 +511,7 @@ cBiomalNoise3DComposable::cBiomalNoise3DComposable(int a_Seed, cBiomeGenPtr a_Bi m_DensityNoiseA(a_Seed + 1), m_DensityNoiseB(a_Seed + 2), m_BaseNoise(a_Seed + 3), - m_BiomeGen(a_BiomeGen), + m_BiomeGen(std::move(a_BiomeGen)), m_LastChunkCoords(0x7fffffff, 0x7fffffff) // Set impossible coords for the chunk so that it's always considered stale { // Generate the weight distribution for summing up neighboring biomes: diff --git a/src/Generating/PiecePool.h b/src/Generating/PiecePool.h index 0c1a701f9..0849f4ebc 100644 --- a/src/Generating/PiecePool.h +++ b/src/Generating/PiecePool.h @@ -183,7 +183,7 @@ public: void SetVerticalStrategy(cVerticalStrategyPtr a_VerticalStrategy) { - m_VerticalStrategy = a_VerticalStrategy; + m_VerticalStrategy = std::move(a_VerticalStrategy); } cVerticalStrategyPtr GetVerticalStrategy(void) const diff --git a/src/Generating/PieceStructuresGen.cpp b/src/Generating/PieceStructuresGen.cpp index 343771a43..b6e605a7b 100644 --- a/src/Generating/PieceStructuresGen.cpp +++ b/src/Generating/PieceStructuresGen.cpp @@ -23,8 +23,8 @@ public: cGen(int a_Seed, cBiomeGenPtr a_BiomeGen, cTerrainHeightGenPtr a_HeightGen, int a_SeaLevel, const AString & a_Name): Super(a_Seed), - m_BiomeGen(a_BiomeGen), - m_HeightGen(a_HeightGen), + m_BiomeGen(std::move(a_BiomeGen)), + m_HeightGen(std::move(a_HeightGen)), m_SeaLevel(a_SeaLevel), m_Name(a_Name), m_MaxDepth(5) @@ -131,7 +131,7 @@ cPieceStructuresGen::cPieceStructuresGen(int a_Seed): -bool cPieceStructuresGen::Initialize(const AString & a_Prefabs, int a_SeaLevel, cBiomeGenPtr a_BiomeGen, cTerrainHeightGenPtr a_HeightGen) +bool cPieceStructuresGen::Initialize(const AString & a_Prefabs, int a_SeaLevel, const cBiomeGenPtr & a_BiomeGen, const cTerrainHeightGenPtr & a_HeightGen) { // Load each piecepool: auto structures = StringSplitAndTrim(a_Prefabs, "|"); diff --git a/src/Generating/PieceStructuresGen.h b/src/Generating/PieceStructuresGen.h index f0449a9b3..c3d7c4ee3 100644 --- a/src/Generating/PieceStructuresGen.h +++ b/src/Generating/PieceStructuresGen.h @@ -34,7 +34,7 @@ public: a_Prefabs contains the list of prefab sets that should be activated, "|"-separated. All problems are logged to the console and the generator skips over them. Returns true if at least one prefab set is valid (the generator should be kept). */ - bool Initialize(const AString & a_Prefabs, int a_SeaLevel, cBiomeGenPtr a_BiomeGen, cTerrainHeightGenPtr a_HeightGen); + bool Initialize(const AString & a_Prefabs, int a_SeaLevel, const cBiomeGenPtr & a_BiomeGen, const cTerrainHeightGenPtr & a_HeightGen); // cFinishGen override: virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; diff --git a/src/Generating/PrefabStructure.cpp b/src/Generating/PrefabStructure.cpp index 0474a3962..127cd0018 100644 --- a/src/Generating/PrefabStructure.cpp +++ b/src/Generating/PrefabStructure.cpp @@ -19,7 +19,7 @@ cPrefabStructure::cPrefabStructure( ): Super(a_GridX, a_GridZ, a_OriginX, a_OriginZ), m_Pieces(std::move(a_Pieces)), - m_HeightGen(a_HeightGen) + m_HeightGen(std::move(a_HeightGen)) { } diff --git a/src/Generating/ProtIntGen.h b/src/Generating/ProtIntGen.h index 22cd35c53..4672b4209 100644 --- a/src/Generating/ProtIntGen.h +++ b/src/Generating/ProtIntGen.h @@ -198,7 +198,7 @@ public: cProtIntGenZoom(int a_Seed, Underlying a_UnderlyingGen): Super(a_Seed), - m_UnderlyingGen(a_UnderlyingGen) + m_UnderlyingGen(std::move(a_UnderlyingGen)) { } @@ -269,7 +269,7 @@ public: cProtIntGenSmooth(int a_Seed, Underlying a_Underlying): Super(a_Seed), - m_Underlying(a_Underlying) + m_Underlying(std::move(a_Underlying)) { } @@ -342,7 +342,7 @@ class cProtIntGenAvgValues: public: cProtIntGenAvgValues(Underlying a_Underlying): - m_Underlying(a_Underlying) + m_Underlying(std::move(a_Underlying)) { } @@ -387,7 +387,7 @@ class cProtIntGenAvg4Values: public: cProtIntGenAvg4Values(Underlying a_Underlying): - m_Underlying(a_Underlying) + m_Underlying(std::move(a_Underlying)) { } @@ -438,7 +438,7 @@ class cProtIntGenWeightAvg: public: cProtIntGenWeightAvg(Underlying a_Underlying): - m_Underlying(a_Underlying) + m_Underlying(std::move(a_Underlying)) { } @@ -490,7 +490,7 @@ public: m_ChancePct(a_ChancePct), m_Min(a_Min), m_Range(a_Range), - m_Underlying(a_Underlying) + m_Underlying(std::move(a_Underlying)) { } @@ -537,7 +537,7 @@ public: Super(a_Seed), m_Range(a_HalfRange * 2 + 1), m_HalfRange(a_HalfRange), - m_Underlying(a_Underlying) + m_Underlying(std::move(a_Underlying)) { } @@ -580,7 +580,7 @@ public: cProtIntGenRndAvg(int a_Seed, int a_AvgChancePct, Underlying a_Underlying): Super(a_Seed), m_AvgChancePct(a_AvgChancePct), - m_Underlying(a_Underlying) + m_Underlying(std::move(a_Underlying)) { } @@ -638,7 +638,7 @@ public: cProtIntGenRndBetween(int a_Seed, int a_AvgChancePct, Underlying a_Underlying): Super(a_Seed), m_AvgChancePct(a_AvgChancePct), - m_Underlying(a_Underlying) + m_Underlying(std::move(a_Underlying)) { } @@ -693,7 +693,7 @@ class cProtIntGenBeaches: public: cProtIntGenBeaches(Underlying a_Underlying): - m_Underlying(a_Underlying) + m_Underlying(std::move(a_Underlying)) { } @@ -798,7 +798,7 @@ public: cProtIntGenAddIslands(int a_Seed, int a_Chance, Underlying a_Underlying): Super(a_Seed), m_Chance(a_Chance), - m_Underlying(a_Underlying) + m_Underlying(std::move(a_Underlying)) { } @@ -842,7 +842,7 @@ class cProtIntGenBiomeGroupEdges: public: cProtIntGenBiomeGroupEdges(Underlying a_Underlying): - m_Underlying(a_Underlying) + m_Underlying(std::move(a_Underlying)) { } @@ -941,7 +941,7 @@ public: cProtIntGenBiomes(int a_Seed, Underlying a_Underlying): Super(a_Seed), - m_Underlying(a_Underlying) + m_Underlying(std::move(a_Underlying)) { } @@ -1072,7 +1072,7 @@ public: m_From(a_From), m_To(a_To), m_Chance(a_Chance), - m_Underlying(a_Underlying) + m_Underlying(std::move(a_Underlying)) { } @@ -1131,8 +1131,8 @@ class cProtIntGenMixRivers: public: cProtIntGenMixRivers(Underlying a_Biomes, Underlying a_Rivers): - m_Biomes(a_Biomes), - m_Rivers(a_Rivers) + m_Biomes(std::move(a_Biomes)), + m_Rivers(std::move(a_Rivers)) { } @@ -1197,7 +1197,7 @@ public: cProtIntGenRiver(int a_Seed, Underlying a_Underlying): Super(a_Seed), - m_Underlying(a_Underlying) + m_Underlying(std::move(a_Underlying)) { } @@ -1256,7 +1256,7 @@ public: Super(a_Seed), m_Chance(a_Chance), m_ToValue(a_ToValue), - m_Underlying(a_Underlying) + m_Underlying(std::move(a_Underlying)) { } @@ -1347,7 +1347,7 @@ public: Super(a_Seed), m_Chance(a_Chance), m_ToValue(a_ToValue), - m_Underlying(a_Underlying) + m_Underlying(std::move(a_Underlying)) { } @@ -1396,7 +1396,7 @@ public: cProtIntGenRareBiomeGroups(int a_Seed, int a_Chance, Underlying a_Underlying): Super(a_Seed), m_Chance(a_Chance), - m_Underlying(a_Underlying) + m_Underlying(std::move(a_Underlying)) { } @@ -1444,8 +1444,8 @@ public: cProtIntGenAlternateBiomes(int a_Seed, Underlying a_Alterations, Underlying a_BaseBiomes): Super(a_Seed), - m_Alterations(a_Alterations), - m_BaseBiomes(a_BaseBiomes) + m_Alterations(std::move(a_Alterations)), + m_BaseBiomes(std::move(a_BaseBiomes)) { } @@ -1510,7 +1510,7 @@ public: cProtIntGenBiomeEdges(int a_Seed, Underlying a_Underlying): Super(a_Seed), - m_Underlying(a_Underlying) + m_Underlying(std::move(a_Underlying)) { } @@ -1670,8 +1670,8 @@ public: cProtIntGenMBiomes(int a_Seed, Underlying a_Alteration, Underlying a_Underlying): Super(a_Seed), - m_Underlying(a_Underlying), - m_Alteration(a_Alteration) + m_Underlying(std::move(a_Underlying)), + m_Alteration(std::move(a_Alteration)) { } diff --git a/src/Generating/ShapeGen.cpp b/src/Generating/ShapeGen.cpp index 28f3478ba..1efbf1010 100644 --- a/src/Generating/ShapeGen.cpp +++ b/src/Generating/ShapeGen.cpp @@ -24,7 +24,7 @@ class cTerrainHeightToShapeGen: { public: cTerrainHeightToShapeGen(cTerrainHeightGenPtr a_HeightGen): - m_HeightGen(a_HeightGen) + m_HeightGen(std::move(a_HeightGen)) { } @@ -77,7 +77,7 @@ typedef std::shared_ptr cTerrainHeightToShapeGenPtr; cTerrainShapeGenPtr cTerrainShapeGen::CreateShapeGen( cIniFile & a_IniFile, - cBiomeGenPtr a_BiomeGen, + const cBiomeGenPtr & a_BiomeGen, int a_Seed, bool & a_CacheOffByDefault ) diff --git a/src/Generating/StructGen.h b/src/Generating/StructGen.h index bbbdf9651..ae7626873 100644 --- a/src/Generating/StructGen.h +++ b/src/Generating/StructGen.h @@ -25,9 +25,9 @@ public: cStructGenTrees(int a_Seed, cBiomeGenPtr a_BiomeGen, cTerrainShapeGenPtr a_ShapeGen, cTerrainCompositionGenPtr a_CompositionGen) : m_Seed(a_Seed), m_Noise(a_Seed), - m_BiomeGen(a_BiomeGen), - m_ShapeGen(a_ShapeGen), - m_CompositionGen(a_CompositionGen) + m_BiomeGen(std::move(a_BiomeGen)), + m_ShapeGen(std::move(a_ShapeGen)), + m_CompositionGen(std::move(a_CompositionGen)) {} protected: @@ -82,7 +82,7 @@ public: m_Noise(a_Seed), m_Seed(a_Seed), m_Fluid(a_Fluid), - m_ShapeGen(a_ShapeGen), + m_ShapeGen(std::move(a_ShapeGen)), m_Probability(a_Probability) { } diff --git a/src/Generating/Trees.cpp b/src/Generating/Trees.cpp index bdc5325eb..90f9ec4b0 100644 --- a/src/Generating/Trees.cpp +++ b/src/Generating/Trees.cpp @@ -615,7 +615,7 @@ void GetAcaciaTreeImage(Vector3i a_BlockPos, cNoise & a_Noise, int a_Seq, sSetBl a_OtherBlocks.push_back(sSetBlock(BranchPos.x, BranchPos.y + 1, BranchPos.z, E_BLOCK_NEW_LEAVES, E_META_NEWLEAVES_ACACIA)); // Choose if we have to add another branch - bool TwoTop = (a_Noise.IntNoise3D(a_BlockPos) < 0 ? true : false); + bool TwoTop = (a_Noise.IntNoise3D(a_BlockPos) < 0); if (!TwoTop) { return; diff --git a/src/Generating/TwoHeights.cpp b/src/Generating/TwoHeights.cpp index 15c48eb26..377127c00 100644 --- a/src/Generating/TwoHeights.cpp +++ b/src/Generating/TwoHeights.cpp @@ -21,7 +21,7 @@ class cTwoHeights: public: - cTwoHeights(int a_Seed, cBiomeGenPtr a_BiomeGen): + cTwoHeights(int a_Seed, const cBiomeGenPtr & a_BiomeGen): m_Seed(a_Seed), m_Choice(a_Seed), m_HeightA(a_Seed + 1, a_BiomeGen), @@ -113,7 +113,7 @@ protected: -cTerrainShapeGenPtr CreateShapeGenTwoHeights(int a_Seed, cBiomeGenPtr a_BiomeGen) +cTerrainShapeGenPtr CreateShapeGenTwoHeights(int a_Seed, const cBiomeGenPtr & a_BiomeGen) { return std::make_shared(a_Seed, a_BiomeGen); } diff --git a/src/Generating/TwoHeights.h b/src/Generating/TwoHeights.h index 353598011..7dcf47c77 100644 --- a/src/Generating/TwoHeights.h +++ b/src/Generating/TwoHeights.h @@ -16,7 +16,7 @@ /** Creates and returns a new instance of the cTwoHeights terrain shape generator. The instance must be Initialize()-d before it is used. */ -extern cTerrainShapeGenPtr CreateShapeGenTwoHeights(int a_Seed, cBiomeGenPtr a_BiomeGen); +extern cTerrainShapeGenPtr CreateShapeGenTwoHeights(int a_Seed, const cBiomeGenPtr & a_BiomeGen); diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp index 21d6e30d4..d46c0d64a 100644 --- a/src/Generating/VillageGen.cpp +++ b/src/Generating/VillageGen.cpp @@ -137,7 +137,7 @@ public: {a_OriginX + a_MaxSize, cChunkDef::Height - 1, a_OriginZ + a_MaxSize} ), m_Prefabs(a_Prefabs), - m_HeightGen(a_HeightGen) + m_HeightGen(std::move(a_HeightGen)) { // Generate the pieces for this village; don't care about the Y coord: cPieceGeneratorBFSTree pg(*this, a_Seed); @@ -348,8 +348,8 @@ cVillageGen::cVillageGen( m_MaxSize(a_MaxSize), m_MinDensity(a_MinDensity), m_MaxDensity(a_MaxDensity), - m_BiomeGen(a_BiomeGen), - m_HeightGen(a_HeightGen) + m_BiomeGen(std::move(a_BiomeGen)), + m_HeightGen(std::move(a_HeightGen)) { for (const auto & toLoad: a_PrefabsToLoad) { -- cgit v1.2.3