From b268db4caae1b5612ae0f3adabf164efc06de368 Mon Sep 17 00:00:00 2001 From: Moritz Borcherding Date: Sun, 18 Sep 2016 21:43:30 +0200 Subject: [PATCH] Use cChunkDef::Height for Y coord comparison where applicable. --- src/Blocks/BlockLeaves.h | 2 +- src/ClientHandle.cpp | 4 ++-- src/Defines.h | 2 +- src/Entities/Entity.cpp | 4 ++-- src/Generating/FinishGen.cpp | 4 ++-- src/WorldStorage/MapSerializer.cpp | 2 +- src/WorldStorage/SchematicFileSerializer.cpp | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h index 84e186b4c..6c2905171 100644 --- a/src/Blocks/BlockLeaves.h +++ b/src/Blocks/BlockLeaves.h @@ -166,7 +166,7 @@ bool HasNearLog(cBlockArea & a_Area, int a_BlockX, int a_BlockY, int a_BlockZ) a_Area.SetBlockType(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_SPONGE); for (int i = 0; i < LEAVES_CHECK_DISTANCE; i++) { - for (int y = std::max(a_BlockY - i, 0); y <= std::min(a_BlockY + i, 255); y++) + for (int y = std::max(a_BlockY - i, 0); y <= std::min(a_BlockY + i, cChunkDef::Height - 1); y++) { for (int z = a_BlockZ - i; z <= a_BlockZ + i; z++) { diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 21947af13..8df60ad40 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -77,11 +77,11 @@ cClientHandle::cClientHandle(const AString & a_IPString, int a_ViewDistance) : m_BlockDigAnimStage(-1), m_BlockDigAnimSpeed(0), m_BlockDigAnimX(0), - m_BlockDigAnimY(256), // Invalid Y, so that the coords don't get picked up + m_BlockDigAnimY(cChunkDef::Height + 1), // Invalid Y, so that the coords don't get picked up m_BlockDigAnimZ(0), m_HasStartedDigging(false), m_LastDigBlockX(0), - m_LastDigBlockY(256), // Invalid Y, so that the coords don't get picked up + m_LastDigBlockY(cChunkDef::Height + 1), // Invalid Y, so that the coords don't get picked up m_LastDigBlockZ(0), m_State(csConnected), m_ShouldCheckDownloaded(false), diff --git a/src/Defines.h b/src/Defines.h index afd806c4e..b9a90cc81 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -557,7 +557,7 @@ inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_B { int Y = a_BlockY; AddFaceDirection(a_BlockX, Y, a_BlockZ, a_BlockFace, a_bInverse); - a_BlockY = Clamp(static_cast(Y), 0, 255); + a_BlockY = Clamp(static_cast(Y), 0, cChunkDef::Height - 1); } diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index b2fa56143..48d07fbbc 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1458,7 +1458,7 @@ bool cEntity::DetectPortal() cWorld * TargetWorld = cRoot::Get()->GetWorld(GetWorld()->GetLinkedOverworldName()); ASSERT(TargetWorld != nullptr); // The linkage checker should have prevented this at startup. See cWorld::start() LOGD("Jumping %s -> %s", DimensionToString(dimNether).c_str(), DimensionToString(DestionationDim).c_str()); - new cNetherPortalScanner(this, TargetWorld, TargetPos, 256); + new cNetherPortalScanner(this, TargetWorld, TargetPos, cChunkDef::Height); return true; } // Nether portal in the overworld @@ -1490,7 +1490,7 @@ bool cEntity::DetectPortal() cWorld * TargetWorld = cRoot::Get()->GetWorld(GetWorld()->GetLinkedNetherWorldName()); ASSERT(TargetWorld != nullptr); // The linkage checker should have prevented this at startup. See cWorld::start() LOGD("Jumping %s -> %s", DimensionToString(dimOverworld).c_str(), DimensionToString(DestionationDim).c_str()); - new cNetherPortalScanner(this, TargetWorld, TargetPos, 128); + new cNetherPortalScanner(this, TargetWorld, TargetPos, (cChunkDef::Height / 2)); return true; } } diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 3f6a1dc7a..4b2cafbca 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -517,7 +517,7 @@ void cFinishGenTallGrass::GenFinish(cChunkDesc & a_ChunkDesc) // Get the top block + 1. This is the place where the grass would finaly be placed: int y = a_ChunkDesc.GetHeight(x, z) + 1; - if (y >= 255) + if (y >= cChunkDef::Height - 1) { continue; } @@ -1221,7 +1221,7 @@ void cFinishGenPreSimulator::StationarizeFluid( cFinishGenFluidSprings::cFinishGenFluidSprings(int a_Seed, BLOCKTYPE a_Fluid, cIniFile & a_IniFile, eDimension a_Dimension) : m_Noise(a_Seed + a_Fluid * 100), // Need to take fluid into account, otherwise water and lava springs generate next to each other - m_HeightDistribution(255), + m_HeightDistribution(cChunkDef::Height - 1), m_Fluid(a_Fluid) { bool IsWater = (a_Fluid == E_BLOCK_WATER); diff --git a/src/WorldStorage/MapSerializer.cpp b/src/WorldStorage/MapSerializer.cpp index 3899ad505..c34efe507 100644 --- a/src/WorldStorage/MapSerializer.cpp +++ b/src/WorldStorage/MapSerializer.cpp @@ -163,7 +163,7 @@ bool cMapSerializer::LoadMapFromNBT(const cParsedNBT & a_NBT) if ((CurrLine >= 0) && (a_NBT.GetType(CurrLine) == TAG_Short)) { unsigned int Height = static_cast(a_NBT.GetShort(CurrLine)); - if (Height >= 256) + if (Height >= cChunkDef::Height) { return false; } diff --git a/src/WorldStorage/SchematicFileSerializer.cpp b/src/WorldStorage/SchematicFileSerializer.cpp index 3fc36e86c..d6bcf840f 100644 --- a/src/WorldStorage/SchematicFileSerializer.cpp +++ b/src/WorldStorage/SchematicFileSerializer.cpp @@ -164,7 +164,7 @@ bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, cP int SizeX = a_NBT.GetShort(TSizeX); int SizeY = a_NBT.GetShort(TSizeY); int SizeZ = a_NBT.GetShort(TSizeZ); - if ((SizeX < 1) || (SizeX > 65535) || (SizeY < 1) || (SizeY > 256) || (SizeZ < 1) || (SizeZ > 65535)) + if ((SizeX < 1) || (SizeX > 65535) || (SizeY < 1) || (SizeY > cChunkDef::Height) || (SizeZ < 1) || (SizeZ > 65535)) { LOG("Dimensions are invalid in the schematic file: %d, %d, %d", SizeX, SizeY, SizeZ); return false;