From c5d3269314e4907761e36532178b8726add53d03 Mon Sep 17 00:00:00 2001
From: poikilos <7557867+poikilos@users.noreply.github.com>
Date: Wed, 16 Mar 2016 01:28:23 -0400
Subject: [PATCH] BROKEN chunk generation border detect wip
---
chunkymap-regen.py | 2 +-
web/chunkymap.php | 195 +++++++++++++++++++++++++++++++++++-------
web/viewchunkymap.php | 4 +-
3 files changed, 168 insertions(+), 33 deletions(-)
diff --git a/chunkymap-regen.py b/chunkymap-regen.py
index 27d9271..16fc1d8 100644
--- a/chunkymap-regen.py
+++ b/chunkymap-regen.py
@@ -862,7 +862,7 @@ class MTChunks:
def get_chunk_genresults_base_path(self):
#formerly get_chunk_genresults_tmp_folder(self, chunk_luid)
- return os.path.join(os.path.dirname(os.path.abspath(__file__)), "chunkymap-genresults")
+ return os.path.join( os.path.join(os.path.dirname(os.path.abspath(__file__)), "chunkymap-genresults"), self.world_name)
def get_chunk_genresult_tmp_path(self, chunky_x, chunky_z):
return os.path.join(self.get_chunk_genresult_tmp_folder(chunky_x, chunky_z), self.get_chunk_genresult_name(chunky_x, chunky_z))
diff --git a/web/chunkymap.php b/web/chunkymap.php
index c5e6b38..6990423 100644
--- a/web/chunkymap.php
+++ b/web/chunkymap.php
@@ -54,6 +54,16 @@ $chunkymap_zoom_delta=1.5;
$chunkymap_view_min_zoom=0.0173415299; //1.0/$chunk_dimension_min; //should be a number that would get to exactly 100 eventually if multiplied by chunkymap_zoom_delta repeatedly (such as 0.09765625 if chunkymap_zoom_delta were 2); 0.005 was avoided since tiles used to be 80x80 pixels
$chunkymap_view_max_zoom=16585998.48141; //13107200.0;
+
+$decachunk_prefix_string="decachunk_";
+$decachunk_prefix_then_x_string=$decachunk_prefix_string."x";
+$chunk_prefix_string="chunk_";
+$chunk_prefix_then_x_string=$chunk_prefix_string."x";
+$z_opener="z";
+$dot_yaml=".yml";
+$decachunk_dot_and_ext=".jpg";
+$chunk_dot_and_ext = ".png";
+
function echo_error($val) {
if (!isset($val)) {
$val="Unknown Error";
@@ -302,11 +312,27 @@ function get_decachunky_coord_from_location($location_x) {
return $decachunk_x;
}
+function get_decachunk_image_path_from_decachunk($decachunky_x, $decachunky_z) {
+ return get_decachunk_folder_path_from_decachunk($decachunky_x, $decachunky_z)."/".get_decachunk_image_name_from_decachunk($decachunky_x, $decachunky_z);
+}
+
function get_decachunk_image_name_from_decachunk($x, $z) {
- return "decachunk_x"."$x"."z"."$z".".jpg";
+ global $decachunk_prefix_string;
+ global $decachunk_dot_and_ext;
+ return "$decachunk_prefix_string"."$x"."z"."$z"."$decachunk_dot_and_ext";
}
-function echo_chunk_debug_canvas() {
+function get_javascript_bool_value($this_bool) {
+ $result = "false";
+ if ($this_bool == true) {
+ $result = "true";
+ }
+ return $result;
+}
+
+//chunk_mode_enable: shows chunk png images instead of decachunk jpg images (slower)
+//debug_mode_enable: draws colored rectangles based on yml files instead of drawing images
+function echo_chunkymap_canvas($chunk_mode_enable, $debug_mode_enable) {
global $chunkymap_view_x;
global $chunkymap_view_z;
global $chunkymap_view_zoom;
@@ -314,25 +340,76 @@ function echo_chunk_debug_canvas() {
global $chunkymap_view_min_zoom;
global $showplayers;
global $chunkymap_zoom_delta;
+
+ check_world();
+
+ $chunks_per_tile_x_count = 10;
+ $chunks_per_tile_z_count = 10;
+
+ //use decachunk jpgs by default for speed:
$tile_w = 160;
$tile_h = 160;
+ if (isset($chunk_mode_enable) and ($chunk_mode_enable===true)) {
+ $tile_w = 16;
+ $tile_h = 16;
+ $chunks_per_tile_x_count = 1;
+ $chunks_per_tile_z_count = 1;
+ }
+ else {
+ $chunk_mode_enable=false;
+ }
+
+ $locations_per_tile_x_count = $chunks_per_tile_x_count*16;
+ $locations_per_tile_z_count = $chunks_per_tile_z_count*16;
+
if ($chunkymap_view_zoom<$chunkymap_view_min_zoom) $chunkymap_view_zoom = $chunkymap_view_min_zoom;
if ($chunkymap_view_zoom>$chunkymap_view_max_zoom) $chunkymap_view_zoom = $chunkymap_view_max_zoom;
- $world_camera_w = 6.0 * (1.0/$chunkymap_view_zoom);
- $world_camera_h = $world_camera_w; //start with square camera to make sure enough chunks are loaded
+ $world_camera_w = (800/$tile_w) * (1.0/$chunkymap_view_zoom); //screen should be 800pt wide always (so 12pt is similar on all screens and only varies with physical size of screen in inches, and since pt was invented to replace px)
+ $world_camera_left = $chunkymap_view_x-$world_camera_w/2.0;
+
+ $world_camera_h = $world_camera_w; //start with square camera to make sure enough chunks are loaded and since neither screen height nor ratio can be known from php since it is only run on server-side
+ $world_camera_top = $chunkymap_view_z+$world_camera_h/2.0; //plus since cartesian until drawn [then flipped]
$chunky_view_x = get_chunky_coord_from_location($chunkymap_view_x);
$chunky_view_z = get_chunky_coord_from_location($chunkymap_view_z);
- $chunky_min_x = 0;
- $chunky_max_x = 0;
- $chunky_min_z = 0;
- $chunky_max_z = 0;
+ #tile is either chunk or decachunk
+ $min_tiley_x = -1;
+ $max_tiley_x = 0;
+ $min_tiley_z = -1;
+ $max_tiley_z = 0;
+ $world_camera_right = $world_camera_left+$world_camera_w;
+ $world_camera_bottom = $world_camera_top-$world_camera_h; //minus since cartesian until drawn [then flipped]
+ //Only whether the near edges are in the canvas matters (get bottom of max since always cartesian until drawn [then inverted]):
+ $min_tiley_x__chunk_location_right = $min_tiley_x*$locations_per_tile_x_count+$locations_per_tile_x_count;
+ $max_tiley_x__chunk_location_left = $max_tiley_x*$locations_per_tile_x_count;
+ $min_tiley_z__chunk_location_top = $min_tiley_z*$locations_per_tile_z_count;
+ $max_tiley_z__chunk_location_bottom = $max_tiley_z*$locations_per_tile_z_count+$locations_per_tile_z_count;
+ while ($min_tiley_x__chunk_location_right>$world_camera_left) {
+ $min_tiley_x -= 1;
+ $min_tiley_x__chunk_location_right = $min_tiley_x*$locations_per_tile_x_count+$locations_per_tile_x_count;
+ }
+ while ($max_tiley_x__chunk_location_left<$world_camera_right) {
+ $max_tiley_x += 1;
+ $max_tiley_x__chunk_location_left = $max_tiley_x*$locations_per_tile_x_count;
+ }
+ while ($min_tiley_z__chunk_location_top>$world_camera_bottom) {
+ $min_tiley_z -= 1;
+ $min_tiley_z__chunk_location_top = $min_tiley_z*$locations_per_tile_z_count;
+ }
+ while ($max_tiley_z__chunk_location_bottom<$world_camera_top) {
+ $max_tiley_z += 1;
+ $max_tiley_z__chunk_location_bottom = $max_tiley_z*$locations_per_tile_z_count+$locations_per_tile_z_count;
+ }
+
+ //$tile_x_count = $max_tiley_x-$min_tiley_x+1;
+ //$tile_z_count = $max_tiley_z-$min_tiley_z+1;
+
echo ' ';
echo '