From 850f4fcf7d0b7f611b6b7abba7228c54709e14ac Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Sun, 23 Jan 2011 21:21:36 -0500 Subject: [PATCH 01/12] Removed debugging statement --- web_assets/functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_assets/functions.js b/web_assets/functions.js index ff8da92..b7a8697 100644 --- a/web_assets/functions.js +++ b/web_assets/functions.js @@ -184,7 +184,7 @@ function initMarkers() { if (item.type == 'sign') { iconURL = 'signpost_icon.png';} - console.log(signGroup.icon); + //console.log(signGroup.icon); if (signGroup.icon) { iconURL = signGroup.icon; } From d1e3f660c9592ce6b527debfee32f27bcefa65b3 Mon Sep 17 00:00:00 2001 From: aheadley Date: Thu, 27 Jan 2011 10:45:53 -0500 Subject: [PATCH 02/12] cdn support --- config.js | 4 +++- web_assets/functions.js | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/config.js b/config.js index ac301cc..23416d0 100644 --- a/config.js +++ b/config.js @@ -36,12 +36,14 @@ var signGroups = [ * Required: * label : string. Displayed on the control. * path : string. Location of the rendered tiles. + * Optional: + * base : string. Base of the url path for tile locations, useful for serving tiles from a different server than the js/html server. */ var mapTypeData=[ {'label': 'Unlit', 'path': 'tiles'}, // {'label': 'Day', 'path': 'lighting/tiles'}, // {'label': 'Night', 'path': 'night/tiles'}, -// {'label': 'Spawn', 'path': 'spawn/tiles'} +// {'label': 'Spawn', 'path': 'spawn/tiles', 'base': 'http://example.cdn.amazon.com/'} ]; // Please leave the following variables here: diff --git a/web_assets/functions.js b/web_assets/functions.js index b7a8697..768a5c3 100644 --- a/web_assets/functions.js +++ b/web_assets/functions.js @@ -383,9 +383,10 @@ function initialize() { return new google.maps.LatLng(lat, lng); } -function getTileUrlGenerator(path) { +function getTileUrlGenerator(path, path_base) { return function(tile, zoom) { var url = path; + var url_base = ( path_base ? path_base : '' ); if(tile.x < 0 || tile.x >= Math.pow(2, zoom) || tile.y < 0 || tile.y >= Math.pow(2, zoom)) { url += '/blank'; } else if(zoom == 0) { @@ -402,7 +403,7 @@ function getTileUrlGenerator(path) { var d = new Date(); url += '?c=' + Math.floor(d.getTime() / (1000 * 60 * config.cacheMinutes)); } - return(url); + return(path_base + url); } } @@ -414,7 +415,7 @@ for (idx in mapTypeData) { var view = mapTypeData[idx]; MCMapOptions[view.label] = { - getTileUrl: getTileUrlGenerator(view.path), + getTileUrl: getTileUrlGenerator(view.path, view.base), tileSize: new google.maps.Size(config.tileSize, config.tileSize), maxZoom: config.maxZoom, minZoom: 0, From 4a6d7f76ea44129c92aa47df4bf2e399da6c8ebd Mon Sep 17 00:00:00 2001 From: aheadley Date: Thu, 27 Jan 2011 10:59:07 -0500 Subject: [PATCH 03/12] background color support --- config.js | 1 + web_assets/functions.js | 1 + 2 files changed, 2 insertions(+) diff --git a/config.js b/config.js index 23416d0..c841130 100644 --- a/config.js +++ b/config.js @@ -5,6 +5,7 @@ defaultZoom: 1, maxZoom: {maxzoom}, cacheMinutes: 0, // Change this to have browsers automatically request new images every x minutes + bg_color: '#1A1A1A', debug: false }; diff --git a/web_assets/functions.js b/web_assets/functions.js index 768a5c3..478b04f 100644 --- a/web_assets/functions.js +++ b/web_assets/functions.js @@ -280,6 +280,7 @@ function initialize() { }, mapTypeId: mapTypeIdDefault, streetViewControl: false, + backgroundColor: config.bg_color, }; map = new google.maps.Map(document.getElementById('mcmap'), mapOptions); From 62aab91f13989257283b58cbaab7179cabbe3766 Mon Sep 17 00:00:00 2001 From: aheadley Date: Wed, 2 Feb 2011 10:59:27 -0500 Subject: [PATCH 04/12] fixed typo --- web_assets/functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_assets/functions.js b/web_assets/functions.js index 478b04f..9b42fda 100644 --- a/web_assets/functions.js +++ b/web_assets/functions.js @@ -404,7 +404,7 @@ function getTileUrlGenerator(path, path_base) { var d = new Date(); url += '?c=' + Math.floor(d.getTime() / (1000 * 60 * config.cacheMinutes)); } - return(path_base + url); + return(url_base + url); } } From 5bf705dfe953a3eb304b60d17757560579ce68ae Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Wed, 12 Jan 2011 23:42:43 +0100 Subject: [PATCH 05/12] Improving the function generate pseudo_ancildata. (first part) --- chunk.py | 180 ++++++++++++++++++------------------------------------- 1 file changed, 57 insertions(+), 123 deletions(-) diff --git a/chunk.py b/chunk.py index 1e13326..aa0dcb7 100644 --- a/chunk.py +++ b/chunk.py @@ -365,139 +365,73 @@ class ChunkRenderer(object): return self._up_left_blocks up_left_blocks = property(_load_up_left_blocks) - def generate_pseudo_ancildata(self,x,y,z,blockid): + def generate_pseudo_ancildata(self,x,y,z,blockid, north_position = ll ): """ Generates a pseudo ancillary data for blocks that depend of - what are surrounded and don't have ancillary data""" + what are surrounded and don't have ancillary data + + This uses a binary number of 4 digits to encode the info. + The encode is: + + Bit: 1 2 3 4 + Side: x y -x -y + Values: bit = 0 -> The corresponding side block is not blockid + bit = 1 -> The corresponding side block is not blockid + Example: if the bit1 is 1 that means that there is a block with + blockid in the side of the +x direction. + + Once generate the pseudo_ancildata + """ blocks = self.blocks up_left_blocks = self.up_left_blocks up_right_blocks = self.up_right_blocks left_blocks = self.left_blocks right_blocks = self.right_blocks - - if ( # The block is surrounded by 0 blocks with same blockid - (up_right_blocks[0,y,z] != blockid if x == 15 else blocks[x+1,y,z] != blockid) and - (left_blocks[15,y,z] != blockid if x == 0 else blocks[x - 1,y,z] != blockid) and - (right_blocks[x,0,z] != blockid if y == 15 else blocks[x,y + 1,z] != blockid) and - (up_left_blocks[x,15,z] != blockid if y == 0 else blocks[x,y - 1,z] != blockid) - ): return 1 - # Now 3 in line, they should be more common: + pseudo_data = 0 - elif ( # The block is surrounded by 2 blocks with same blockid, along x axis - (up_right_blocks[0,y,z] == blockid if x == 15 else blocks[x+1,y,z] == blockid) and - (left_blocks[15,y,z] == blockid if x == 0 else blocks[x - 1,y,z] == blockid) and - (right_blocks[x,0,z] != blockid if y == 15 else blocks[x,y + 1,z] != blockid) and - (up_left_blocks[x,15,z] != blockid if y == 0 else blocks[x,y - 1,z] != blockid) - ): return 2 + # check if we are in the border of a chunk and the chunk + # is in the border of the map + + if up_right_blocks[0,0,0] == None and x == 15 or + right_blocks[0,0,0] == None and y == 15 or + left_blocks[0,0,0] == None and x == 0 or + up_left_blocks[0,0,0] == None and y == 0: + return None + + if up_right_blocks[0,y,z] == blockid if x == 15 else blocks[x+1,y,z] == blockid: + pseudo_data |= 0b1000 + + if right_blocks[x,0,z] == blockid if y == 15 else blocks[x,y + 1,z] == blockid: + pseudo_data |= 0b0100 + + if left_blocks[15,y,z] == blockid if x == 0 else blocks[x - 1,y,z] == blockid: + pseudo_data |= 0b0010 + + if up_left_blocks[x,15,z] == blockid if y == 0 else blocks[x,y - 1,z] == blockid: + pseudo_data |= 0b0001 + + if north_position == ll: + return pseudo_data + + elif north_position == ul: + pseudo_data *= 2 + if pseudo_data > 15: + pseudo_data -= 15 + pseudo_data +=1 + return pseudo_data + + elif north_position == ul: + pseudo_data *= 2 + if pseudo_data > 15: + pseudo_data -= 15 + pseudo_data +=1 - elif ( # The block is surrounded by 2 blocks with same blockid, along y axis - (up_right_blocks[0,y,z] != blockid if x == 15 else blocks[x+1,y,z] != blockid) and - (left_blocks[15,y,z] != blockid if x == 0 else blocks[x - 1,y,z] != blockid) and - (right_blocks[x,0,z] == blockid if y == 15 else blocks[x,y + 1,z] == blockid) and - (up_left_blocks[x,15,z] == blockid if y == 0 else blocks[x,y - 1,z] == blockid) - ): return 3 - - # Now 3 in corner: - - elif ( # The block is surrounded by 2 blocks with same blockid, in a -y to x corner - (up_right_blocks[0,y,z] == blockid if x == 15 else blocks[x+1,y,z] == blockid) and - (left_blocks[15,y,z] != blockid if x == 0 else blocks[x - 1,y,z] != blockid) and - (right_blocks[x,0,z] != blockid if y == 15 else blocks[x,y + 1,z] != blockid) and - (up_left_blocks[x,15,z] == blockid if y == 0 else blocks[x,y - 1,z] == blockid) - ): return 4 - - elif ( # The block is surrounded by 2 blocks with same blockid, in a -y to -x corner - (up_right_blocks[0,y,z] != blockid if x == 15 else blocks[x+1,y,z] != blockid) and - (left_blocks[15,y,z] == blockid if x == 0 else blocks[x - 1,y,z] == blockid) and - (right_blocks[x,0,z] != blockid if y == 15 else blocks[x,y + 1,z] != blockid) and - (up_left_blocks[x,15,z] == blockid if y == 0 else blocks[x,y - 1,z] == blockid) - ): return 5 - - elif ( # The block is surrounded by 2 blocks with same blockid, in a y to -x corner - (up_right_blocks[0,y,z] != blockid if x == 15 else blocks[x+1,y,z] != blockid) and - (left_blocks[15,y,z] == blockid if x == 0 else blocks[x - 1,y,z] == blockid) and - (right_blocks[x,0,z] == blockid if y == 15 else blocks[x,y + 1,z] == blockid) and - (up_left_blocks[x,15,z] != blockid if y == 0 else blocks[x,y - 1,z] != blockid) - ): return 6 - - elif ( # The block is surrounded by 2 blocks with same blockid, in a y to x corner - (up_right_blocks[0,y,z] == blockid if x == 15 else blocks[x+1,y,z] == blockid) and - (left_blocks[15,y,z] != blockid if x == 0 else blocks[x - 1,y,z] != blockid) and - (right_blocks[x,0,z] == blockid if y == 15 else blocks[x,y + 1,z] == blockid) and - (up_left_blocks[x,15,z] != blockid if y == 0 else blocks[x,y - 1,z] != blockid) - ): return 7 - - # Now 1 in dead end: - - elif ( # The block is surrounded by 1 blocks with same blockid, in +x - (up_right_blocks[0,y,z] == blockid if x == 15 else blocks[x+1,y,z] == blockid) and - (left_blocks[15,y,z] != blockid if x == 0 else blocks[x - 1,y,z] != blockid) and - (right_blocks[x,0,z] != blockid if y == 15 else blocks[x,y + 1,z] != blockid) and - (up_left_blocks[x,15,z] != blockid if y == 0 else blocks[x,y - 1,z] != blockid) - ): return 8 - - elif ( # The block is surrounded by 1 blocks with same blockid, in -y - (up_right_blocks[0,y,z] != blockid if x == 15 else blocks[x+1,y,z] != blockid) and - (left_blocks[15,y,z] != blockid if x == 0 else blocks[x - 1,y,z] != blockid) and - (right_blocks[x,0,z] != blockid if y == 15 else blocks[x,y + 1,z] != blockid) and - (up_left_blocks[x,15,z] == blockid if y == 0 else blocks[x,y - 1,z] == blockid) - ): return 9 - - elif ( # The block is surrounded by 1 blocks with same blockid, in -x - (up_right_blocks[0,y,z] != blockid if x == 15 else blocks[x+1,y,z] != blockid) and - (left_blocks[15,y,z] == blockid if x == 0 else blocks[x - 1,y,z] == blockid) and - (right_blocks[x,0,z] != blockid if y == 15 else blocks[x,y + 1,z] != blockid) and - (up_left_blocks[x,15,z] != blockid if y == 0 else blocks[x,y - 1,z] != blockid) - ): return 10 - - elif ( # The block is surrounded by 1 blocks with same blockid, in +y - (up_right_blocks[0,y,z] != blockid if x == 15 else blocks[x+1,y,z] != blockid) and - (left_blocks[15,y,z] != blockid if x == 0 else blocks[x - 1,y,z] != blockid) and - (right_blocks[x,0,z] == blockid if y == 15 else blocks[x,y + 1,z] == blockid) and - (up_left_blocks[x,15,z] != blockid if y == 0 else blocks[x,y - 1,z] != blockid) - ): return 11 - - # Now surrounded by 3 identical blocks: - - elif ( # The block is surrounded by 3 blocks with same blockid, in postiions -x, -y, +x - (up_right_blocks[0,y,z] == blockid if x == 15 else blocks[x+1,y,z] == blockid) and - (left_blocks[15,y,z] == blockid if x == 0 else blocks[x - 1,y,z] == blockid) and - (right_blocks[x,0,z] != blockid if y == 15 else blocks[x,y + 1,z] != blockid) and - (up_left_blocks[x,15,z] == blockid if y == 0 else blocks[x,y - 1,z] == blockid) - ): return 12 - - elif ( # The block is surrounded by 3 blocks with same blockid, in postiions +y, -y, -x - (up_right_blocks[0,y,z] != blockid if x == 15 else blocks[x+1,y,z] != blockid) and - (left_blocks[15,y,z] == blockid if x == 0 else blocks[x - 1,y,z] == blockid) and - (right_blocks[x,0,z] == blockid if y == 15 else blocks[x,y + 1,z] == blockid) and - (up_left_blocks[x,15,z] == blockid if y == 0 else blocks[x,y - 1,z] == blockid) - ): return 13 - - elif ( # The block is surrounded by 3 blocks with same blockid, in postiions -x, +y, +x - (up_right_blocks[0,y,z] == blockid if x == 15 else blocks[x+1,y,z] == blockid) and - (left_blocks[15,y,z] == blockid if x == 0 else blocks[x - 1,y,z] == blockid) and - (right_blocks[x,0,z] == blockid if y == 15 else blocks[x,y + 1,z] == blockid) and - (up_left_blocks[x,15,z] != blockid if y == 0 else blocks[x,y - 1,z] != blockid) - ): return 14 - - elif ( # The block is surrounded by 3 blocks with same blockid, in postiions +y, -y, +x - (up_right_blocks[0,y,z] == blockid if x == 15 else blocks[x+1,y,z] == blockid) and - (left_blocks[15,y,z] != blockid if x == 0 else blocks[x - 1,y,z] != blockid) and - (right_blocks[x,0,z] == blockid if y == 15 else blocks[x,y + 1,z] == blockid) and - (up_left_blocks[x,15,z] == blockid if y == 0 else blocks[x,y - 1,z] == blockid) - ): return 15 - - # Block completely sourrounded by 4 blocks: - - elif ( # The block is surrounded completely - (up_right_blocks[0,y,z] == blockid if x == 15 else blocks[x+1,y,z] == blockid) and - (left_blocks[15,y,z] == blockid if x == 0 else blocks[x - 1,y,z] == blockid) and - (right_blocks[x,0,z] == blockid if y == 15 else blocks[x,y + 1,z] == blockid) and - (up_left_blocks[x,15,z] == blockid if y == 0 else blocks[x,y - 1,z] == blockid) - ): return 16 - - else: return None + elif north_position == ul: + pseudo_data *= 2 + if pseudo_data > 15: + pseudo_data -= 15 + pseudo_data +=1 def _hash_blockarray(self): """Finds a hash of the block array""" From 448733dd442f4fa70a48e2f8bf8bda332d956a5c Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Thu, 13 Jan 2011 17:46:13 +0100 Subject: [PATCH 06/12] Improvements for generate_pseudo_andcildata in chunk.py, and necessary changes to fences case in textures.py This changes will help to properly render redstonewire. --- chunk.py | 68 +++++++++++++++---------------- textures.py | 112 +++++----------------------------------------------- 2 files changed, 43 insertions(+), 137 deletions(-) diff --git a/chunk.py b/chunk.py index aa0dcb7..1f07f7f 100644 --- a/chunk.py +++ b/chunk.py @@ -365,7 +365,7 @@ class ChunkRenderer(object): return self._up_left_blocks up_left_blocks = property(_load_up_left_blocks) - def generate_pseudo_ancildata(self,x,y,z,blockid, north_position = ll ): + def generate_pseudo_ancildata(self,x,y,z,blockid, north_position = 0 ): """ Generates a pseudo ancillary data for blocks that depend of what are surrounded and don't have ancillary data @@ -374,12 +374,22 @@ class ChunkRenderer(object): Bit: 1 2 3 4 Side: x y -x -y - Values: bit = 0 -> The corresponding side block is not blockid - bit = 1 -> The corresponding side block is not blockid + Values: bit = 0 -> The corresponding side block has different blockid + bit = 1 -> The corresponding side block has same blockid Example: if the bit1 is 1 that means that there is a block with blockid in the side of the +x direction. - Once generate the pseudo_ancildata + You can rotate the pseudo data multiplying by 2 and + if it is > 15 subtracting 15 and adding 1. (moving bits + in the left direction is like rotate 90 degree in anticlockwise + direction). In this way can be used for maps with other + north orientation. + + North position can have the values 0, 1, 2, 3, corresponding to + north in bottom-left, bottom-right, top-right and top-left of + the screen. + + The rotation feature is not used anywhere yet. """ blocks = self.blocks @@ -389,50 +399,40 @@ class ChunkRenderer(object): right_blocks = self.right_blocks pseudo_data = 0 + # ll, ul, ur, lr stands for lower-left, upper-left, upper-right + # and lower-right # check if we are in the border of a chunk and the chunk # is in the border of the map - if up_right_blocks[0,0,0] == None and x == 15 or - right_blocks[0,0,0] == None and y == 15 or - left_blocks[0,0,0] == None and x == 0 or - up_left_blocks[0,0,0] == None and y == 0: + if ((up_right_blocks[0,0,0] == None and x == 15) or + (right_blocks[0,0,0] == None and y == 15) or + (left_blocks[0,0,0] == None and x == 0) or + (up_left_blocks[0,0,0] == None and y == 0)): return None if up_right_blocks[0,y,z] == blockid if x == 15 else blocks[x+1,y,z] == blockid: - pseudo_data |= 0b1000 + pseudo_data = pseudo_data | 0b1000 if right_blocks[x,0,z] == blockid if y == 15 else blocks[x,y + 1,z] == blockid: - pseudo_data |= 0b0100 + pseudo_data = pseudo_data | 0b0100 if left_blocks[15,y,z] == blockid if x == 0 else blocks[x - 1,y,z] == blockid: - pseudo_data |= 0b0010 + pseudo_data = pseudo_data | 0b0010 if up_left_blocks[x,15,z] == blockid if y == 0 else blocks[x,y - 1,z] == blockid: - pseudo_data |= 0b0001 - - if north_position == ll: - return pseudo_data + pseudo_data = pseudo_data | 0b0001 + + + while north_position > 0: + pseudo_data *= 2 + if pseudo_data > 15: + pseudo_data -= 16 + pseudo_data +=1 + north_position -= 1 - elif north_position == ul: - pseudo_data *= 2 - if pseudo_data > 15: - pseudo_data -= 15 - pseudo_data +=1 - return pseudo_data - - elif north_position == ul: - pseudo_data *= 2 - if pseudo_data > 15: - pseudo_data -= 15 - pseudo_data +=1 - - elif north_position == ul: - pseudo_data *= 2 - if pseudo_data > 15: - pseudo_data -= 15 - pseudo_data +=1 - + return pseudo_data + def _hash_blockarray(self): """Finds a hash of the block array""" if hasattr(self, "_digest"): diff --git a/textures.py b/textures.py index 5efb889..bc2eb41 100644 --- a/textures.py +++ b/textures.py @@ -761,115 +761,21 @@ def generate_special_texture(blockID, data): # +y axis points bottom right direction # First compose small sticks in the back of the image, # then big stick and thecn small sticks in the front. - if data == 1: - img = fence_big - return (img.convert("RGB"),img.split()[3]) - - elif data == 2: #fence in line with x axis + + if (data & 0b0001) == 1: + composite.alpha_over(img,fence_small_side, pos_top_left,fence_small_side) # top left + if (data & 0b1000) == 8: composite.alpha_over(img,fence_small_other_side, pos_top_right,fence_small_other_side) # top right - composite.alpha_over(img,fence_big,(0,0),fence_big) - composite.alpha_over(img,fence_small_other_side, pos_bottom_left,fence_small_other_side) # bottom left - return (img.convert("RGB"),img.split()[3]) - elif data == 3: #fence in line with y axis - composite.alpha_over(img,fence_small_side, pos_top_left,fence_small_side) # top left - composite.alpha_over(img,fence_big,(0,0),fence_big) - composite.alpha_over(img,fence_small_side, pos_bottom_right,fence_small_side) # bottom right - return (img.convert("RGB"),img.split()[3]) - - - elif data == 4: #fence corner +x, -y - composite.alpha_over(img,fence_small_other_side, pos_top_right,fence_small_other_side) # top right - composite.alpha_over(img,fence_small_side, pos_top_left,fence_small_side) # top left - composite.alpha_over(img,fence_big,(0,0),fence_big) - return (img.convert("RGB"),img.split()[3]) - - elif data == 5: #fence corner -x, -y - composite.alpha_over(img,fence_small_side, pos_top_left,fence_small_side) # top left - composite.alpha_over(img,fence_big,(0,0),fence_big) - composite.alpha_over(img,fence_small_other_side, pos_bottom_left,fence_small_other_side) # bottom left - return (img.convert("RGB"),img.split()[3]) - - elif data == 6: #fence corner -x, +y - composite.alpha_over(img,fence_big,(0,0),fence_big) - composite.alpha_over(img,fence_small_side, pos_bottom_right,fence_small_side) # bottom right - composite.alpha_over(img,fence_small_other_side, pos_bottom_left,fence_small_other_side) # bottom left - return (img.convert("RGB"),img.split()[3]) + composite.alpha_over(img,fence_big,(0,0),fence_big) - elif data == 7: #fence corner +x, +y - composite.alpha_over(img,fence_small_other_side, pos_top_right,fence_small_other_side) # top right - composite.alpha_over(img,fence_big,(0,0),fence_big) - composite.alpha_over(img,fence_small_side, pos_bottom_right,fence_small_side) # bottom right - return (img.convert("RGB"),img.split()[3]) - - - elif data == 8: #fence dead end +x - composite.alpha_over(img,fence_small_other_side, pos_top_right,fence_small_other_side) # top right - composite.alpha_over(img,fence_big,(0,0),fence_big) - return (img.convert("RGB"),img.split()[3]) - - elif data == 9: #fence dead end -y - composite.alpha_over(img,fence_small_side, pos_top_left,fence_small_side) # top left - composite.alpha_over(img,fence_big,(0,0),fence_big) - return (img.convert("RGB"),img.split()[3]) - - elif data == 10: #fence dead end -x - composite.alpha_over(img,fence_big,(0,0),fence_big) - composite.alpha_over(img,fence_small_other_side, pos_bottom_left,fence_small_other_side) # bottom left - return (img.convert("RGB"),img.split()[3]) - - elif data == 11: #fence dead end +y - composite.alpha_over(img,fence_big,(0,0),fence_big) - composite.alpha_over(img,fence_small_side, pos_bottom_right,fence_small_side) # bottom right - return (img.convert("RGB"),img.split()[3]) - - - elif data == 12: #fence cross with +y missing - composite.alpha_over(img,fence_small_side, pos_top_left,fence_small_side) # top left - composite.alpha_over(img,fence_small_other_side, pos_top_right,fence_small_other_side) # top right - composite.alpha_over(img,fence_big,(0,0),fence_big) - composite.alpha_over(img,fence_small_other_side, pos_bottom_left,fence_small_other_side) # bottom left - return (img.convert("RGB"),img.split()[3]) - - elif data == 13: #fence cross with +x missing - composite.alpha_over(img,fence_small_side, pos_top_left,fence_small_side) # top left - composite.alpha_over(img,fence_big,(0,0),fence_big) + if (data & 0b0010) == 2: composite.alpha_over(img,fence_small_other_side, pos_bottom_left,fence_small_other_side) # bottom left + if (data & 0b0100) == 4: composite.alpha_over(img,fence_small_side, pos_bottom_right,fence_small_side) # bottom right - return (img.convert("RGB"),img.split()[3]) - - elif data == 14: #fence cross with -y missing - composite.alpha_over(img,fence_small_other_side, pos_top_right,fence_small_other_side) # top right - composite.alpha_over(img,fence_big,(0,0),fence_big) - composite.alpha_over(img,fence_small_other_side, pos_bottom_left,fence_small_other_side) # bottom left - composite.alpha_over(img,fence_small_side, pos_bottom_right,fence_small_side) # bottom right - return (img.convert("RGB"),img.split()[3]) - - elif data == 15: #fence cross with -x missing - composite.alpha_over(img,fence_small_side, pos_top_left,fence_small_side) # top left - composite.alpha_over(img,fence_small_other_side, pos_top_right,fence_small_other_side) # top right - composite.alpha_over(img,fence_big,(0,0),fence_big) - composite.alpha_over(img,fence_small_side, pos_bottom_right,fence_small_side) # bottom right - return (img.convert("RGB"),img.split()[3]) - - - elif data == 16: #fence cross - composite.alpha_over(img,fence_small_side, pos_top_left,fence_small_side) # top left - composite.alpha_over(img,fence_small_other_side, pos_top_right,fence_small_other_side) # top right - composite.alpha_over(img,fence_big,(0,0),fence_big) - composite.alpha_over(img,fence_small_other_side, pos_bottom_left,fence_small_other_side) # bottom left - composite.alpha_over(img,fence_small_side, pos_bottom_right,fence_small_side) # bottom right - return (img.convert("RGB"),img.split()[3]) - - elif data == None: # This can happend if a fence is in the border - # of a chunk and the chunk is in the border of the map. - composite.alpha_over(img,fence_big,(0,0),) - return (img.convert("RGB"), img.split()[3]) - - else: # just in case - composite.alpha_over(img,fence_big,(0,0),) - return (img.convert("RGB"), img.split()[3]) + return (img.convert("RGB"),img.split()[3]) + return None From 15e0e9210f837186a59af9d7cacb87e57bb91f31 Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Mon, 31 Jan 2011 16:32:33 +0100 Subject: [PATCH 07/12] Finish and comment. --- chunk.py | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/chunk.py b/chunk.py index 1f07f7f..a082bf0 100644 --- a/chunk.py +++ b/chunk.py @@ -399,31 +399,24 @@ class ChunkRenderer(object): right_blocks = self.right_blocks pseudo_data = 0 - # ll, ul, ur, lr stands for lower-left, upper-left, upper-right - # and lower-right + + # first check if we are in the border of a chunk, next check for chunks adjacent to this + # and finally check for a block with same blockid. I we aren't in the border of a chunk, + # check for the block having the sme blockid. - # check if we are in the border of a chunk and the chunk - # is in the border of the map - - if ((up_right_blocks[0,0,0] == None and x == 15) or - (right_blocks[0,0,0] == None and y == 15) or - (left_blocks[0,0,0] == None and x == 0) or - (up_left_blocks[0,0,0] == None and y == 0)): - return None - - if up_right_blocks[0,y,z] == blockid if x == 15 else blocks[x+1,y,z] == blockid: + if (up_right_blocks.any() and up_right_blocks[0,y,z] == blockid) if x == 15 else blocks[x+1,y,z] == blockid: pseudo_data = pseudo_data | 0b1000 - if right_blocks[x,0,z] == blockid if y == 15 else blocks[x,y + 1,z] == blockid: + if (right_blocks.any() and right_blocks[x,0,z] == blockid) if y == 15 else blocks[x,y + 1,z] == blockid: pseudo_data = pseudo_data | 0b0100 - if left_blocks[15,y,z] == blockid if x == 0 else blocks[x - 1,y,z] == blockid: + if (left_blocks.any() and left_blocks[15,y,z] == blockid) if x == 0 else blocks[x - 1,y,z] == blockid: pseudo_data = pseudo_data | 0b0010 - if up_left_blocks[x,15,z] == blockid if y == 0 else blocks[x,y - 1,z] == blockid: + if (up_left_blocks.any() and up_left_blocks[x,15,z] == blockid) if y == 0 else blocks[x,y - 1,z] == blockid: pseudo_data = pseudo_data | 0b0001 - + # rotate the bits for other north orientations while north_position > 0: pseudo_data *= 2 if pseudo_data > 15: From d90a3666dd2985f3853220f74d4c415285f25e12 Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Thu, 3 Feb 2011 00:36:02 +0100 Subject: [PATCH 08/12] Fix .any() not working as expected. --- chunk.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chunk.py b/chunk.py index a082bf0..a5bddf8 100644 --- a/chunk.py +++ b/chunk.py @@ -404,16 +404,16 @@ class ChunkRenderer(object): # and finally check for a block with same blockid. I we aren't in the border of a chunk, # check for the block having the sme blockid. - if (up_right_blocks.any() and up_right_blocks[0,y,z] == blockid) if x == 15 else blocks[x+1,y,z] == blockid: + if (up_right_blocks != None and up_right_blocks[0,y,z] == blockid) if x == 15 else blocks[x+1,y,z] == blockid: pseudo_data = pseudo_data | 0b1000 - if (right_blocks.any() and right_blocks[x,0,z] == blockid) if y == 15 else blocks[x,y + 1,z] == blockid: + if (right_blocks != None and right_blocks[x,0,z] == blockid) if y == 15 else blocks[x,y + 1,z] == blockid: pseudo_data = pseudo_data | 0b0100 - if (left_blocks.any() and left_blocks[15,y,z] == blockid) if x == 0 else blocks[x - 1,y,z] == blockid: + if (left_blocks != None and left_blocks[15,y,z] == blockid) if x == 0 else blocks[x - 1,y,z] == blockid: pseudo_data = pseudo_data | 0b0010 - if (up_left_blocks.any() and up_left_blocks[x,15,z] == blockid) if y == 0 else blocks[x,y - 1,z] == blockid: + if (up_left_blocks != None and up_left_blocks[x,15,z] == blockid) if y == 0 else blocks[x,y - 1,z] == blockid: pseudo_data = pseudo_data | 0b0001 # rotate the bits for other north orientations From 27f722c3bd09591617e5aa2a6aa06dbbeef036f9 Mon Sep 17 00:00:00 2001 From: timwolla Date: Mon, 7 Feb 2011 22:06:06 +0100 Subject: [PATCH 09/12] The date is written into the {time} variable in index.html --- quadtree.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/quadtree.py b/quadtree.py index ead65e8..95ba8e2 100644 --- a/quadtree.py +++ b/quadtree.py @@ -26,6 +26,7 @@ import json import logging import util import cPickle +from time import gmtime, strftime from PIL import Image @@ -151,6 +152,16 @@ class QuadtreeGen(object): for f in files: shutil.copy(os.path.join(root, f), self.destdir) + # Add time in index.html + indexpath = os.path.join(self.destdir, "index.html") + + index = open(indexpath, 'r').read() + index = index.replace( + "{time}", str(strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime()))) + + with open(os.path.join(self.destdir, "index.html"), 'w') as output: + output.write(index) + if skipjs: return From 6b083bccef2b6401f47527da601524145c75c8c5 Mon Sep 17 00:00:00 2001 From: timwolla Date: Mon, 7 Feb 2011 22:06:59 +0100 Subject: [PATCH 10/12] Added variable into index.html --- web_assets/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/web_assets/index.html b/web_assets/index.html index e77fee7..89554e8 100644 --- a/web_assets/index.html +++ b/web_assets/index.html @@ -12,6 +12,7 @@ +
From 8e87e5571fa4b1519ed87cb6f49d5a53f8fe5b2f Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Tue, 8 Feb 2011 19:45:34 -0500 Subject: [PATCH 11/12] Added new fire.png to the nightly kits --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index bc4ca85..55ee8bb 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ setup_kwargs['cmdclass'] = {} if py2exe != None: setup_kwargs['console'] = ['gmap.py'] - setup_kwargs['data_files'] = [('textures', ['textures/lava.png', 'textures/water.png']), + setup_kwargs['data_files'] = [('textures', ['textures/lava.png', 'textures/water.png', 'textures/fire.png']), ('', ['config.js', 'COPYING.txt', 'README.rst']), ('web_assets', glob.glob('web_assets/*'))] setup_kwargs['zipfile'] = None From c9722af8a43e0423dbb3353a6411b017b453f3e4 Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Fri, 18 Feb 2011 20:02:42 -0500 Subject: [PATCH 12/12] modified method to copy web_assets --- quadtree.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/quadtree.py b/quadtree.py index ead65e8..f1bd1d1 100644 --- a/quadtree.py +++ b/quadtree.py @@ -26,6 +26,7 @@ import json import logging import util import cPickle +import stat from PIL import Image @@ -38,6 +39,26 @@ This module has routines related to generating a quadtree of tiles """ +def mirror_dir(src, dst, entities=None): + '''copies all of the entities from src to dst''' + if not os.path.exists(dst): + os.mkdir(dst) + if entities and type(entities) != list: raise Exception("Expected a list, got a %r instead" % type(entities)) + + for entry in os.listdir(src): + if entities and entry not in entities: continue + if os.path.isdir(os.path.join(src,entry)): + mirror_dir(os.path.join(src, entry), os.path.join(dst, entry)) + elif os.path.isfile(os.path.join(src,entry)): + try: + shutil.copy(os.path.join(src, entry), os.path.join(dst, entry)) + except IOError: + # maybe permission problems? + os.chmod(os.path.join(src, entry), stat.S_IRUSR) + os.chmod(os.path.join(dst, entry), stat.S_IWUSR) + shutil.copy(os.path.join(src, entry), os.path.join(dst, entry)) + # if this stills throws an error, let it propagate up + def iterate_base4(d): """Iterates over a base 4 number with d digits""" return itertools.product(xrange(4), repeat=d) @@ -147,9 +168,7 @@ class QuadtreeGen(object): blank.save(os.path.join(tileDir, "blank."+self.imgformat)) # copy web assets into destdir: - for root, dirs, files in os.walk(os.path.join(util.get_program_path(), "web_assets")): - for f in files: - shutil.copy(os.path.join(root, f), self.destdir) + mirror_dir(os.path.join(util.get_program_path(), "web_assets"), self.destdir) if skipjs: return