From bf528b9dbae44a78734f83217413a5951d7fe0db Mon Sep 17 00:00:00 2001 From: Emiel Rombouts Date: Mon, 17 Dec 2012 01:31:17 +0400 Subject: [PATCH] Added check for negative i values --- chunk.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/chunk.h b/chunk.h index 4c4764c..2b67e71 100755 --- a/chunk.h +++ b/chunk.h @@ -56,6 +56,8 @@ struct ChunkData if (!anvil) return (bo.y > 127) ? 0 : blockIDs[(bo.x * 16 + bo.z) * 128 + bo.y]; int i = (bo.y * 16 + bo.z) * 16 + bo.x; + if (i < 0) + i = 0; if ((i % 2) == 0) return ((blockAdd[i/2] & 0xf) << 8) | blockIDs[i]; return ((blockAdd[i/2] & 0xf0) << 4) | blockIDs[i]; @@ -156,4 +158,4 @@ struct ChunkCache : private nocopy -#endif // CHUNK_H \ No newline at end of file +#endif // CHUNK_H