From 56a2e1f8340cc955435f88189169715118003a0a Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Thu, 9 Jun 2011 11:45:36 -0400 Subject: [PATCH 1/3] Move decl to top of block --- src/rendermode-normal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rendermode-normal.c b/src/rendermode-normal.c index b112192..c6a7ab9 100644 --- a/src/rendermode-normal.c +++ b/src/rendermode-normal.c @@ -126,6 +126,7 @@ static void rendermode_normal_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObject *mask_light) { RenderModeNormal *self = (RenderModeNormal *)data; int randx = 0,randy = 0; + unsigned char data; /* first, check to see if we should use biome-compatible src, mask */ if (self->biome_data) { @@ -137,7 +138,7 @@ rendermode_normal_draw(void *data, RenderState *state, PyObject *src, PyObject * randy = rand() % 6 + 1 - 3; state->imgx = state->imgx + randx; state->imgy = state->imgy + randy; - unsigned char data = getArrayByte3D(state->blockdata_expanded, state->x, state->y, state->z); + data = getArrayByte3D(state->blockdata_expanded, state->x, state->y, state->z); if (data == 1) { src = mask = self->tall_grass_texture; } else if (data == 2) { From b1ee31bffa777a8ccc3b24358cf6ed7a64410a1d Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Thu, 9 Jun 2011 11:47:51 -0400 Subject: [PATCH 2/3] Proper fix for build issue (Fixes #395) --- src/rendermode-normal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rendermode-normal.c b/src/rendermode-normal.c index c6a7ab9..cee7431 100644 --- a/src/rendermode-normal.c +++ b/src/rendermode-normal.c @@ -126,7 +126,7 @@ static void rendermode_normal_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObject *mask_light) { RenderModeNormal *self = (RenderModeNormal *)data; int randx = 0,randy = 0; - unsigned char data; + unsigned char data_byte; /* first, check to see if we should use biome-compatible src, mask */ if (self->biome_data) { @@ -138,10 +138,10 @@ rendermode_normal_draw(void *data, RenderState *state, PyObject *src, PyObject * randy = rand() % 6 + 1 - 3; state->imgx = state->imgx + randx; state->imgy = state->imgy + randy; - data = getArrayByte3D(state->blockdata_expanded, state->x, state->y, state->z); - if (data == 1) { + data_byte = getArrayByte3D(state->blockdata_expanded, state->x, state->y, state->z); + if (data_byte == 1) { src = mask = self->tall_grass_texture; - } else if (data == 2) { + } else if (data_byte == 2) { src = mask = self->tall_fern_texture; } } From 13c9750a43f2cb84e79a94e73a0d3ae3b64f6fa4 Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Sat, 11 Jun 2011 04:58:51 -0400 Subject: [PATCH 3/3] fixed crash when spawn point does not have an associated region file (closes issue #399) --- world.py | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/world.py b/world.py index f02098c..564d193 100644 --- a/world.py +++ b/world.py @@ -208,23 +208,25 @@ class World(object): ## The filename of this chunk chunkFile = self.get_region_path(chunkX, chunkY) - - data=nbt.load_from_region(chunkFile, chunkX, chunkY)[1] - level = data['Level'] - blockArray = numpy.frombuffer(level['Blocks'], dtype=numpy.uint8).reshape((16,16,128)) - - ## The block for spawn *within* the chunk - inChunkX = spawnX - (chunkX*16) - inChunkZ = spawnZ - (chunkY*16) - - ## find the first air block - while (blockArray[inChunkX, inChunkZ, spawnY] != 0): - spawnY += 1 - if spawnY == 128: - break + + if chunkFile is not None: + data = nbt.load_from_region(chunkFile, chunkX, chunkY)[1] + if data is not None: + level = data['Level'] + blockArray = numpy.frombuffer(level['Blocks'], dtype=numpy.uint8).reshape((16,16,128)) + + ## The block for spawn *within* the chunk + inChunkX = spawnX - (chunkX*16) + inChunkZ = spawnZ - (chunkY*16) + + ## find the first air block + while (blockArray[inChunkX, inChunkZ, spawnY] != 0): + spawnY += 1 + if spawnY == 128: + break self.POI.append( dict(x=spawnX, y=spawnY, z=spawnZ, - msg="Spawn", type="spawn", chunk=(inChunkX,inChunkZ))) + msg="Spawn", type="spawn", chunk=(chunkX, chunkY))) self.spawn = (spawnX, spawnY, spawnZ) def go(self, procs):