From b832a202ab052b0544ca26225c4fe771cf31ede7 Mon Sep 17 00:00:00 2001 From: worktycho Date: Thu, 26 Jun 2014 18:30:02 +0100 Subject: Add Null check to SendBlockTo Fixes CID 43611 --- src/ChunkMap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index d2ccca94e..f0222c0f5 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -1530,7 +1530,7 @@ void cChunkMap::SendBlockTo(int a_X, int a_Y, int a_Z, cPlayer * a_Player) cCSLock Lock(m_CSLayers); cChunkPtr Chunk = GetChunk(ChunkX, ZERO_CHUNK_Y, ChunkZ); - if (Chunk->IsValid()) + if (Chunk != NULL && Chunk->IsValid()) { Chunk->SendBlockTo(a_X, a_Y, a_Z, a_Player->GetClientHandle()); } -- cgit v1.2.3 From 25a0264cc46d97f52bd836280fa5d2908846ac02 Mon Sep 17 00:00:00 2001 From: worktycho Date: Thu, 26 Jun 2014 19:04:56 +0100 Subject: Check GridSize for 0 Fixes CID 68226 and CID 66437 --- src/Generating/GridStructGen.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/Generating/GridStructGen.cpp b/src/Generating/GridStructGen.cpp index 95f8c38bc..a3578de6f 100644 --- a/src/Generating/GridStructGen.cpp +++ b/src/Generating/GridStructGen.cpp @@ -53,6 +53,16 @@ cGridStructGen::cGridStructGen( m_MaxStructureSizeZ(a_MaxStructureSizeZ), m_MaxCacheSize(a_MaxCacheSize) { + if (m_GridSizeX == 0) + { + LOG("Grid Size cannot be zero, setting to 1"); + m_GridSizeX = 1; + } + if (m_GridSizeZ == 0) + { + LOG("Grid Size cannot be zero, setting to 1"); + m_GridSizeZ = 1; + } size_t NumStructuresPerQuery = (size_t)(((m_MaxStructureSizeX + m_MaxOffsetX) / m_GridSizeX + 1) * ((m_MaxStructureSizeZ + m_MaxOffsetZ) / m_GridSizeZ + 1)); if (NumStructuresPerQuery > m_MaxCacheSize) { -- cgit v1.2.3 From bfc485bfe2093dde665bc17588ea53218f964312 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 13 Jul 2014 15:05:54 +0100 Subject: Fix CopyPaste error that ment a_MaxRelX wasdn't checked Fixes CID 70464 --- src/Generating/ChunkDesc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Generating/ChunkDesc.cpp b/src/Generating/ChunkDesc.cpp index 7711723fc..570332615 100644 --- a/src/Generating/ChunkDesc.cpp +++ b/src/Generating/ChunkDesc.cpp @@ -290,7 +290,7 @@ void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX LOGWARNING("%s: MaxRelX less than zero, adjusting to zero", __FUNCTION__); a_MaxRelX = 0; } - else if (a_MinRelX >= cChunkDef::Width) + else if (a_MaxRelX >= cChunkDef::Width) { LOGWARNING("%s: MaxRelX more than chunk width, adjusting to chunk width", __FUNCTION__); a_MaxRelX = cChunkDef::Width - 1; -- cgit v1.2.3 From 64697f0cabeeadf1d50717892f0815d8309f8b8a Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 13 Jul 2014 15:29:43 +0100 Subject: Another COpyPaste Error Fixes CID 70461 --- src/Generating/ChunkDesc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Generating/ChunkDesc.cpp b/src/Generating/ChunkDesc.cpp index 570332615..c63ca6689 100644 --- a/src/Generating/ChunkDesc.cpp +++ b/src/Generating/ChunkDesc.cpp @@ -332,7 +332,7 @@ void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX LOGWARNING("%s: MaxRelZ less than zero, adjusting to zero", __FUNCTION__); a_MaxRelZ = 0; } - else if (a_MinRelZ >= cChunkDef::Width) + else if (a_MaxRelZ >= cChunkDef::Width) { LOGWARNING("%s: MaxRelZ more than chunk width, adjusting to chunk width", __FUNCTION__); a_MaxRelZ = cChunkDef::Width - 1; -- cgit v1.2.3 From 132b367316b2723ef573476a9fb78bcba6f09294 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 13 Jul 2014 15:32:44 +0100 Subject: CopyPaste Error Fixes CID 70460. --- src/Generating/ChunkDesc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Generating/ChunkDesc.cpp b/src/Generating/ChunkDesc.cpp index c63ca6689..e4b305022 100644 --- a/src/Generating/ChunkDesc.cpp +++ b/src/Generating/ChunkDesc.cpp @@ -311,7 +311,7 @@ void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX LOGWARNING("%s: MaxRelY less than zero, adjusting to zero", __FUNCTION__); a_MaxRelY = 0; } - else if (a_MinRelY >= cChunkDef::Height) + else if (a_MaxRelY >= cChunkDef::Height) { LOGWARNING("%s: MaxRelY more than chunk height, adjusting to chunk height", __FUNCTION__); a_MaxRelY = cChunkDef::Height - 1; -- cgit v1.2.3 From 4315deb90b62a40a07bf4f3427b52a613738c102 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 13 Jul 2014 16:07:35 +0100 Subject: Added parenthasies --- src/ChunkMap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index f0222c0f5..164b7d37a 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -1530,7 +1530,7 @@ void cChunkMap::SendBlockTo(int a_X, int a_Y, int a_Z, cPlayer * a_Player) cCSLock Lock(m_CSLayers); cChunkPtr Chunk = GetChunk(ChunkX, ZERO_CHUNK_Y, ChunkZ); - if (Chunk != NULL && Chunk->IsValid()) + if ((Chunk != NULL) && (Chunk->IsValid())) { Chunk->SendBlockTo(a_X, a_Y, a_Z, a_Player->GetClientHandle()); } -- cgit v1.2.3