From c9697083e57e7062a68f61b5516b73c412e83004 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 21 Dec 2014 21:56:34 +0100 Subject: cNoise3DComposable: Fixed unitialized member variables. Fixes CID 43665. --- src/Generating/Noise3DGenerator.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/Generating') diff --git a/src/Generating/Noise3DGenerator.cpp b/src/Generating/Noise3DGenerator.cpp index b43a1a6de..29471f936 100644 --- a/src/Generating/Noise3DGenerator.cpp +++ b/src/Generating/Noise3DGenerator.cpp @@ -379,7 +379,9 @@ cNoise3DComposable::cNoise3DComposable(int a_Seed) : m_ChoiceNoise(a_Seed), m_DensityNoiseA(a_Seed + 1), m_DensityNoiseB(a_Seed + 2), - m_BaseNoise(a_Seed + 3) + m_BaseNoise(a_Seed + 3), + m_LastChunkX(0x7fffffff), // Use dummy coords that won't ever be used by real chunks + m_LastChunkZ(0x7fffffff) { } -- cgit v1.2.3 From fe00c99c9518be022f8faaa52899e68fc0738ce4 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 21 Dec 2014 21:59:44 +0100 Subject: cEndGen: Fixed unitialized member variables. Fixes CID 43671. --- src/Generating/EndGen.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/Generating') diff --git a/src/Generating/EndGen.cpp b/src/Generating/EndGen.cpp index 89d6117bb..bc26edb20 100644 --- a/src/Generating/EndGen.cpp +++ b/src/Generating/EndGen.cpp @@ -39,7 +39,9 @@ cEndGen::cEndGen(int a_Seed) : m_IslandSizeZ(256), m_FrequencyX(80), m_FrequencyY(80), - m_FrequencyZ(80) + m_FrequencyZ(80), + m_LastChunkX(0x7fffffff), // Use dummy coords that won't ever be used by real chunks + m_LastChunkZ(0x7fffffff) { m_Perlin.AddOctave(1, 1); m_Perlin.AddOctave(2, 0.5); -- cgit v1.2.3 From ccdf03daaf880dd0c89a03b50c11eb083ee1cfb0 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Wed, 24 Dec 2014 07:20:17 +0100 Subject: Refactored all player block placing to go through hooks. Fixes #1618. --- src/Generating/StructGen.cpp | 14 +++++++------- src/Generating/Trees.cpp | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src/Generating') diff --git a/src/Generating/StructGen.cpp b/src/Generating/StructGen.cpp index 2f685c808..2d5a73739 100644 --- a/src/Generating/StructGen.cpp +++ b/src/Generating/StructGen.cpp @@ -123,18 +123,18 @@ void cStructGenTrees::GenerateSingleTree( // Check if the generated image fits the terrain. Only the logs are checked: for (sSetBlockVector::const_iterator itr = TreeLogs.begin(); itr != TreeLogs.end(); ++itr) { - if ((itr->ChunkX != a_ChunkX) || (itr->ChunkZ != a_ChunkZ)) + if ((itr->m_ChunkX != a_ChunkX) || (itr->m_ChunkZ != a_ChunkZ)) { // Outside the chunk continue; } - if (itr->y >= cChunkDef::Height) + if (itr->m_RelY >= cChunkDef::Height) { // Above the chunk, cut off (this shouldn't happen too often, we're limiting trees to y < 230) continue; } - BLOCKTYPE Block = a_ChunkDesc.GetBlockType(itr->x, itr->y, itr->z); + BLOCKTYPE Block = a_ChunkDesc.GetBlockType(itr->m_RelX, itr->m_RelY, itr->m_RelZ); switch (Block) { CASE_TREE_ALLOWED_BLOCKS: @@ -167,14 +167,14 @@ void cStructGenTrees::ApplyTreeImage( // Put the generated image into a_BlockTypes, push things outside this chunk into a_Blocks for (sSetBlockVector::const_iterator itr = a_Image.begin(), end = a_Image.end(); itr != end; ++itr) { - if ((itr->ChunkX == a_ChunkX) && (itr->ChunkZ == a_ChunkZ) && (itr->y < cChunkDef::Height)) + if ((itr->m_ChunkX == a_ChunkX) && (itr->m_ChunkZ == a_ChunkZ) && (itr->m_RelY < cChunkDef::Height)) { // Inside this chunk, integrate into a_ChunkDesc: - switch (a_ChunkDesc.GetBlockType(itr->x, itr->y, itr->z)) + switch (a_ChunkDesc.GetBlockType(itr->m_RelX, itr->m_RelY, itr->m_RelZ)) { case E_BLOCK_LEAVES: { - if (itr->BlockType != E_BLOCK_LOG) + if (itr->m_BlockType != E_BLOCK_LOG) { break; } @@ -182,7 +182,7 @@ void cStructGenTrees::ApplyTreeImage( } CASE_TREE_OVERWRITTEN_BLOCKS: { - a_ChunkDesc.SetBlockTypeMeta(itr->x, itr->y, itr->z, itr->BlockType, itr->BlockMeta); + a_ChunkDesc.SetBlockTypeMeta(itr->m_RelX, itr->m_RelY, itr->m_RelZ, itr->m_BlockType, itr->m_BlockMeta); break; } diff --git a/src/Generating/Trees.cpp b/src/Generating/Trees.cpp index be8b0cd6b..a10e0f4f1 100644 --- a/src/Generating/Trees.cpp +++ b/src/Generating/Trees.cpp @@ -403,17 +403,17 @@ void GetLargeAppleTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a for (auto itr : a_LogBlocks) { // Get the log's X and Z coordinates - int X = itr.ChunkX * 16 + itr.x; - int Z = itr.ChunkZ * 16 + itr.z; + int X = itr.GetX(); + int Z = itr.GetZ(); - a_OtherBlocks.push_back(sSetBlock(X, itr.y - 2, Z, E_BLOCK_LEAVES, E_META_LEAVES_APPLE)); - PushCoordBlocks(X, itr.y - 2, Z, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_APPLE); + a_OtherBlocks.push_back(sSetBlock(X, itr.m_RelY - 2, Z, E_BLOCK_LEAVES, E_META_LEAVES_APPLE)); + PushCoordBlocks(X, itr.m_RelY - 2, Z, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_APPLE); for (int y = -1; y <= 1; y++) { - PushCoordBlocks (X, itr.y + y, Z, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_LEAVES_APPLE); + PushCoordBlocks (X, itr.m_RelY + y, Z, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_LEAVES_APPLE); } - PushCoordBlocks(X, itr.y + 2, Z, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_APPLE); - a_OtherBlocks.push_back(sSetBlock(X, itr.y + 2, Z, E_BLOCK_LEAVES, E_META_LEAVES_APPLE)); + PushCoordBlocks(X, itr.m_RelY + 2, Z, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_APPLE); + a_OtherBlocks.push_back(sSetBlock(X, itr.m_RelY + 2, Z, E_BLOCK_LEAVES, E_META_LEAVES_APPLE)); } // Trunk: -- cgit v1.2.3 From 2557eab95738128eb758f967c52ea977c3e486e0 Mon Sep 17 00:00:00 2001 From: Kirill Kirilenko Date: Fri, 23 Jan 2015 18:38:23 +0300 Subject: Fixed defect #43671 in Coverity list. --- src/Generating/EndGen.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/Generating') diff --git a/src/Generating/EndGen.cpp b/src/Generating/EndGen.cpp index bc26edb20..c559e765f 100644 --- a/src/Generating/EndGen.cpp +++ b/src/Generating/EndGen.cpp @@ -40,6 +40,10 @@ cEndGen::cEndGen(int a_Seed) : m_FrequencyX(80), m_FrequencyY(80), m_FrequencyZ(80), + m_MinChunkX(0), + m_MaxChunkX(0), + m_MinChunkZ(0), + m_MaxChunkZ(0), m_LastChunkX(0x7fffffff), // Use dummy coords that won't ever be used by real chunks m_LastChunkZ(0x7fffffff) { -- cgit v1.2.3 From 0288e90e0be394aa4498c0b97a0f3aad021048ac Mon Sep 17 00:00:00 2001 From: Kirill Kirilenko Date: Fri, 23 Jan 2015 18:42:54 +0300 Subject: Fixed defect #73101 in Coverity list. --- src/Generating/BioGen.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/Generating') diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp index 2a4dbe794..2cc810d3b 100644 --- a/src/Generating/BioGen.cpp +++ b/src/Generating/BioGen.cpp @@ -733,7 +733,19 @@ cBioGenTwoLevel::cBioGenTwoLevel(int a_Seed) : m_Noise3(a_Seed + 5003), m_Noise4(a_Seed + 5004), m_Noise5(a_Seed + 5005), - m_Noise6(a_Seed + 5006) + m_Noise6(a_Seed + 5006), + m_FreqX1(0.0), + m_AmpX1(0.0), + m_FreqX2(0.0), + m_AmpX2(0.0), + m_FreqX3(0.0), + m_AmpX3(0.0), + m_FreqZ1(0.0), + m_AmpZ1(0.0), + m_FreqZ2(0.0), + m_AmpZ2(0.0), + m_FreqZ3(0.0), + m_AmpZ3(0.0) { } -- cgit v1.2.3 From ce2d3280cabc486f136380db91ea903e866f9bfe Mon Sep 17 00:00:00 2001 From: Kirill Kirilenko Date: Fri, 23 Jan 2015 18:55:04 +0300 Subject: Fixed defect #43665 in Coverity list. --- src/Generating/Noise3DGenerator.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/Generating') diff --git a/src/Generating/Noise3DGenerator.cpp b/src/Generating/Noise3DGenerator.cpp index 29471f936..eadc66a4e 100644 --- a/src/Generating/Noise3DGenerator.cpp +++ b/src/Generating/Noise3DGenerator.cpp @@ -380,6 +380,17 @@ cNoise3DComposable::cNoise3DComposable(int a_Seed) : m_DensityNoiseA(a_Seed + 1), m_DensityNoiseB(a_Seed + 2), m_BaseNoise(a_Seed + 3), + m_HeightAmplification(0.0), + m_MidPoint(0.0), + m_FrequencyX(0.0), + m_FrequencyY(0.0), + m_FrequencyZ(0.0), + m_BaseFrequencyX(0.0), + m_BaseFrequencyZ(0.0), + m_ChoiceFrequencyX(0.0), + m_ChoiceFrequencyY(0.0), + m_ChoiceFrequencyZ(0.0), + m_AirThreshold(0.0), m_LastChunkX(0x7fffffff), // Use dummy coords that won't ever be used by real chunks m_LastChunkZ(0x7fffffff) { -- cgit v1.2.3