Browse Source

working on test suite

still fixing decachunk generation
master
poikilos 9 years ago
committed by Jacob Gustafson
parent
commit
371dc4a2e1
  1. BIN
      chunk_x-2z4.png
  2. 219
      chunkymap-regen.py
  3. 411
      expertmmregressionsuite.py
  4. 10
      expertmmregressiontmp.py
  5. 124
      web/chunkymap.php

BIN
chunk_x-2z4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

219
chunkymap-regen.py

@ -696,10 +696,10 @@ class MTChunks:
self.yaml_name = "generated.yml"
self.world_yaml_path = os.path.join(self.chunkymap_thisworld_data_path, self.yaml_name)
self.mapvars["chunkx_min"] = 0
self.mapvars["chunkz_min"] = 0
self.mapvars["chunkx_max"] = 0
self.mapvars["chunkz_max"] = 0
self.mapvars["min_chunkx"] = 0
self.mapvars["min_chunkz"] = 0
self.mapvars["max_chunkx"] = 0
self.mapvars["max_chunkz"] = 0
self.mapvars["chunk_size"] = 16
self.mapvars["maxheight"] = 96
self.mapvars["minheight"] = -32
@ -712,40 +712,40 @@ class MTChunks:
#self.mapvars = get_dict_from_conf_file(self.world_yaml_path,":")
#NOTE: do not save or load self.mapvars yet, because if world name is different than saved, chunks must all be redone
if self.saved_mapvars is not None:
if "chunkx_min" in self.saved_mapvars.keys():
self.mapvars["chunkx_min"] = self.saved_mapvars["chunkx_min"]
if "chunkx_max" in self.saved_mapvars.keys():
self.mapvars["chunkx_max"] = self.saved_mapvars["chunkx_max"]
if "chunkz_min" in self.saved_mapvars.keys():
self.mapvars["chunkz_min"] = self.saved_mapvars["chunkz_min"]
if "chunkz_max" in self.saved_mapvars.keys():
self.mapvars["chunkz_max"] = self.saved_mapvars["chunkz_max"]
if "min_chunkx" in self.saved_mapvars.keys():
self.mapvars["min_chunkx"] = self.saved_mapvars["min_chunkx"]
if "max_chunkx" in self.saved_mapvars.keys():
self.mapvars["max_chunkx"] = self.saved_mapvars["max_chunkx"]
if "min_chunkz" in self.saved_mapvars.keys():
self.mapvars["min_chunkz"] = self.saved_mapvars["min_chunkz"]
if "max_chunkz" in self.saved_mapvars.keys():
self.mapvars["max_chunkz"] = self.saved_mapvars["max_chunkz"]
if self.mapvars is not None:
if "chunkx_min" in self.mapvars.keys():
if "min_chunkx" in self.mapvars.keys():
try:
self.mapvars["chunkx_min"] = int(self.mapvars["chunkx_min"])
self.mapvars["min_chunkx"] = int(self.mapvars["min_chunkx"])
except:
print("WARNING: chunkx_min was not int so set to 0")
self.mapvars["chunkx_min"] = 0
if "chunkx_max" in self.mapvars.keys():
print("WARNING: min_chunkx was not int so set to 0")
self.mapvars["min_chunkx"] = 0
if "max_chunkx" in self.mapvars.keys():
try:
self.mapvars["chunkx_max"] = int(self.mapvars["chunkx_max"])
self.mapvars["max_chunkx"] = int(self.mapvars["max_chunkx"])
except:
print("WARNING: chunkx_max was not int so set to 0")
self.mapvars["chunkx_max"] = 0
if "chunkz_min" in self.mapvars.keys():
print("WARNING: max_chunkx was not int so set to 0")
self.mapvars["max_chunkx"] = 0
if "min_chunkz" in self.mapvars.keys():
try:
self.mapvars["chunkz_min"] = int(self.mapvars["chunkz_min"])
self.mapvars["min_chunkz"] = int(self.mapvars["min_chunkz"])
except:
print("WARNING: chunkz_min was not int so set to 0")
self.mapvars["chunkz_min"] = 0
if "chunkz_max" in self.mapvars.keys():
print("WARNING: min_chunkz was not int so set to 0")
self.mapvars["min_chunkz"] = 0
if "max_chunkz" in self.mapvars.keys():
try:
self.mapvars["chunkz_max"] = int(self.mapvars["chunkz_max"])
self.mapvars["max_chunkz"] = int(self.mapvars["max_chunkz"])
except:
print("WARNING: chunkz_max was not int so set to 0")
self.mapvars["chunkz_max"] = 0
print("WARNING: max_chunkz was not int so set to 0")
self.mapvars["max_chunkz"] = 0
if is_mapvars_changed:
self.save_mapvars_if_changed()
if is_config_changed:
@ -859,27 +859,41 @@ class MTChunks:
return os.path.join(os.path.dirname(os.path.abspath(__file__)), self.get_signal_name())
def get_decachunky_coord_from_chunky_coord(self, chunky_x):
# 15 becomes 1
# 10 becomes 1
# 5 becomes 0
# -5 becomes -1
#-10 becomes -1
#-15 becomes -2
return int(math.floor(float(chunky_x)/10.0))
def get_chunky_coord_from_decachunky_coord(self, decachunky_x):
# 1 becomes 10
# 0 becomes 0
#-1 becomes -10
return int(decachunky_x*10)
def check_decachunk_containing_chunk(self, chunky_x, chunky_z):
chunk16_coord_list = list()
chunky_coord_list = list()
decachunky_x = self.get_decachunky_coord_from_chunky_coord(chunky_x)
decachunky_z = self.get_decachunky_coord_from_chunky_coord(chunky_z)
chunk16x_min = decachunky_x*10
chunk16x_max = chunk16x_min + 15 # NOTE: + 15 even if negative since originally, floor was used
chunk16z_min = decachunky_z*10
chunk16z_max = chunk16z_min + 15 # NOTE: + 15 even if negative since originally, floor was used
chunky_x_count=chunk16x_max-chunk16x_min+1
chunky_z_count=chunk16z_max-chunk16z_min+1
chunky_x_min = decachunky_x*10
chunky_max_x = chunky_x_min + 15 # NOTE: + 15 even if negative since originally, floor was used
chunky_z_min = decachunky_z*10
chunky_max_z = chunky_z_min + 15 # NOTE: + 15 even if negative since originally, floor was used
x_chunky_count = chunky_max_x-chunky_x_min+1
z_chunky_count = chunky_max_z-chunky_z_min+1
is_any_part_queued = False
chunky_z = chunk16z_min
preview_strings = list()
while chunky_z <= chunk16z_max:
preview_strings.append("")
chunky_x = chunk16x_min
while chunky_x <= chunk16x_max:
preview_strings = list(z_chunky_count)
queued_chunk_coords = None
chunky_offset_z = 0
chunky_z = chunky_z_min
while chunky_z <= chunky_max_z:
preview_strings[chunky_offset_z] = ""
chunky_x = chunky_x_min
while chunky_x <= chunky_max_x:
coords = (chunky_x, chunky_z)
chunk16_coord_list.append( coords )
chunky_coord_list.append( coords )
if self.todo_index<len(self.todo_positions):
for index in range(self.todo_index,len(self.todo_positions)):
if ivec2_equals(self.todo_positions[index], coords):
@ -891,15 +905,17 @@ class MTChunks:
if is_any_part_queued:
break
chunky_z += 1
if not is_any_part_queued:
chunky_offset_z += 1
#if not is_any_part_queued:
if queued_chunk_coords is None:
print("")
print("")
print(" Rendering 160px decachunk "+str((decachunky_x, decachunky_z)))
if self.verbose_enable:
print(" USING ("+str(len(chunk16_coord_list))+") chunks: "+str(chunk16_coord_list))
print(" USING ("+str(len(chunky_coord_list))+") chunks: "+str(chunky_coord_list))
print("")
else:
print(" USING ("+str(len(chunk16_coord_list))+") chunks")
print(" USING ("+str(len(chunky_coord_list))+") chunks")
decachunk_global_coords = decachunky_x*160, decachunky_z*160
im = Image.new("RGB", (160, 160), self.FLAG_EMPTY_HEXCOLOR)
decachunk_yaml_path = self.get_decachunk_yaml_path_from_decachunk(decachunky_x, decachunky_z)
@ -907,10 +923,10 @@ class MTChunks:
combined_count = 0
contains_chunk_luids = list()
for coord in chunk16_coord_list:
for coord in chunky_coord_list:
chunky_x, chunky_z = coord
chunky_offset_x = chunky_x - chunk16x_min
chunky_offset_z = chunky_z - chunk16x_min
chunky_offset_x = chunky_x - chunky_x_min
chunky_offset_z = chunky_z - chunky_z_min
chunk_image_path = self.get_chunk_image_path(chunky_x, chunky_z)
if os.path.isfile(chunk_image_path):
preview_strings[chunky_offset_z] += "1"
@ -933,11 +949,21 @@ class MTChunks:
view_traceback()
else:
preview_strings[chunky_offset_z] += "0"
chunky_offset_z = chunky_z_count - 1
print(self.min_indent+"Usable chunk images mask:")
while chunky_offset_z>=0:
print(self.min_indent+" "+preview_strings[chunky_offset_z])
chunky_offset_z -= 1
chunky_offset_z = z_chunky_count - 1
try:
print(self.min_indent+"Usable chunk images mask:")
while chunky_offset_z>=0:
print(self.min_indent+" "+preview_strings[chunky_offset_z])
chunky_offset_z -= 1
except:
print(self.min_indent+"Could not finish showing mask (this should never happen)")
print(self.min_indent+" z_chunky_count:"+str(z_chunky_count))
print(self.min_indent+" len(preview_strings):"+str(len(preview_strings)))
print(self.min_indent+" chunky_x_min:"+str(chunky_x_min))
print(self.min_indent+" chunky_max_x:"+str(chunky_max_x))
print(self.min_indent+" chunky_z_min:"+str(chunky_z_min))
print(self.min_indent+" chunky_max_z:"+str(chunky_max_z))
view_traceback()
print("")
decachunk_folder_path = self.get_decachunk_folder_path_from_decachunk(decachunky_x, decachunky_z)
if not os.path.isdir(decachunk_folder_path):
@ -957,6 +983,8 @@ class MTChunks:
else:
self.decachunks[decachunk_luid].metadata["contains_chunk_luids"] = None
self.decachunks[decachunk_luid].save_yaml(decachunk_yaml_path)
else:
print("Not rendering decachunk "+str((decachunky_x,decachunky_z))+" yet since contains queued chunk "+str(queued_chunk_coords)+".")
def get_chunk_folder_path(self, chunky_x, chunky_z):
result = None
@ -1143,17 +1171,17 @@ class MTChunks:
if not os.path.isdir(genresult_tmp_folder_path):
os.makedirs(genresult_tmp_folder_path)
genresult_path = self.get_chunk_genresult_tmp_path(chunky_x, chunky_z)
x_min = chunky_x * self.mapvars["chunk_size"]
x_max = chunky_x * self.mapvars["chunk_size"] + self.mapvars["chunk_size"] - 1
z_min = chunky_z * self.mapvars["chunk_size"]
z_max = chunky_z * self.mapvars["chunk_size"] + self.mapvars["chunk_size"] - 1
min_x = chunky_x * self.mapvars["chunk_size"]
max_x = chunky_x * self.mapvars["chunk_size"] + self.mapvars["chunk_size"] - 1
min_z = chunky_z * self.mapvars["chunk_size"]
max_z = chunky_z * self.mapvars["chunk_size"] + self.mapvars["chunk_size"] - 1
#print (min_indent+"generating chunky_x = " + str(x_min) + " to " + str(x_max) + " , chunky_z = " + str(z_min) + " to " + str(z_max))
geometry_value_string = str(x_min)+":"+str(z_min)+"+"+str(int(x_max)-int(x_min)+1)+"+"+str(int(z_max)-int(z_min)+1) # +1 since max-min is exclusive and width must be inclusive for minetestmapper.py
#print (min_indent+"generating chunky_x = " + str(min_x) + " to " + str(max_x) + " , chunky_z = " + str(min_z) + " to " + str(max_z))
geometry_value_string = str(min_x)+":"+str(min_z)+"+"+str(int(max_x)-int(min_x)+1)+"+"+str(int(max_z)-int(min_z)+1) # +1 since max-min is exclusive and width must be inclusive for minetestmapper.py
cmd_suffix = ""
cmd_suffix = " > \""+genresult_path+"\""
#self.mapper_id = "minetestmapper-region"
cmd_no_out_string = self.python_exe_path + " \""+self.minetestmapper_py_path + "\" --region " + str(x_min) + " " + str(x_max) + " " + str(z_min) + " " + str(z_max) + " --maxheight "+str(self.mapvars["maxheight"])+" --minheight "+str(self.mapvars["minheight"])+" --pixelspernode "+str(self.mapvars["pixelspernode"])+" \""+self.config["world_path"]+"\" \""+tmp_png_path+"\""
cmd_no_out_string = self.python_exe_path + " \""+self.minetestmapper_py_path + "\" --region " + str(min_x) + " " + str(max_x) + " " + str(min_z) + " " + str(max_z) + " --maxheight "+str(self.mapvars["maxheight"])+" --minheight "+str(self.mapvars["minheight"])+" --pixelspernode "+str(self.mapvars["pixelspernode"])+" \""+self.config["world_path"]+"\" \""+tmp_png_path+"\""
cmd_string = cmd_no_out_string + cmd_suffix
if self.minetestmapper_py_path==self.minetestmapper_custom_path:#if self.backend_string!="sqlite3": #if self.mapper_id=="minetestmapper-region":
@ -1173,8 +1201,8 @@ class MTChunks:
# script_path=region_capable_script_path
#if os.path.isfile(region_capable_script_path):
#script_path = region_capable_script_path
geometry_string = str(x_min)+":"+str(z_min)+"+"+str(int(x_max)-int(x_min)+1)+"+"+str(int(z_max)-int(z_min)+1) # +1 since max-min is exclusive and width must be inclusive for minetestmapper.py
#expertmm_region_string = str(x_min) + ":" + str(x_max) + "," + str(z_min) + ":" + str(z_max)
geometry_string = str(min_x)+":"+str(min_z)+"+"+str(int(max_x)-int(min_x)+1)+"+"+str(int(max_z)-int(min_z)+1) # +1 since max-min is exclusive and width must be inclusive for minetestmapper.py
#expertmm_region_string = str(min_x) + ":" + str(max_x) + "," + str(min_z) + ":" + str(max_z)
#cmd_string="sudo python "+script_path+" --input \""+self.config["world_path"]+"\" --geometry "+geometry_value_string+" --output \""+tmp_png_path+"\""+cmd_suffix
cmd_no_out_string = self.python_exe_path+" "+self.minetestmapper_py_path+" --bgcolor '"+self.FLAG_EMPTY_HEXCOLOR+"' --input \""+self.config["world_path"]+"\" --geometry "+geometry_string+" --output \""+tmp_png_path+"\""
cmd_string = cmd_no_out_string + cmd_suffix
@ -1552,14 +1580,14 @@ class MTChunks:
if is_present:
self.mapvars["total_generated_count"] += 1
if chunky_x<self.mapvars["chunkx_min"]:
self.mapvars["chunkx_min"]=chunky_x
if chunky_x>self.mapvars["chunkx_max"]:
self.mapvars["chunkx_max"]=chunky_x
if chunky_z<self.mapvars["chunkz_min"]:
self.mapvars["chunkz_min"]=chunky_z
if chunky_z>self.mapvars["chunkz_max"]:
self.mapvars["chunkz_max"]=chunky_z
if chunky_x<self.mapvars["min_chunkx"]:
self.mapvars["min_chunkx"]=chunky_x
if chunky_x>self.mapvars["max_chunkx"]:
self.mapvars["max_chunkx"]=chunky_x
if chunky_z<self.mapvars["min_chunkz"]:
self.mapvars["min_chunkz"]=chunky_z
if chunky_z>self.mapvars["max_chunkz"]:
self.mapvars["max_chunkz"]=chunky_z
#end while square outline (1-chunk-thick outline) generated any png files
self.save_mapvars_if_changed()
prev_len = len(self.todo_positions)
@ -1729,9 +1757,10 @@ class MTChunks:
coords = self.get_coords_from_luid(decachunk_luid)
if coords is not None:
decachunky_x, decachunky_z = coords
chunky_x = decachunky_x*10
chunky_z = decachunky_z*10
chunky_x = self.get_chunky_coord_from_decachunky_coord(decachunky_x)
chunky_z = self.get_chunky_coord_from_decachunky_coord(decachunky_z)
if not os.path.isfile(self.get_decachunk_image_path_from_chunk(chunky_x, chunky_z)):
print("Checking decachunk "+str(decachunky_x)+","+str(decachunky_z))
self.check_decachunk_containing_chunk(chunky_x, chunky_z)
else:
print("ERROR: could not get coords from decachunk luid "+decachunk_luid)
@ -1795,10 +1824,10 @@ class MTChunks:
#badend_string = ".yml"
#if (len(file_name) >= len(badend_string)) and (file_name[len(file_name)-len(badend_string):]==badend_string):
#os.remove(file_path)
#self.mapvars["chunkx_min"]=0
#self.mapvars["chunkx_max"]=0
#self.mapvars["chunkz_min"]=0
#self.mapvars["chunkz_max"]=0
#self.mapvars["min_chunkx"]=0
#self.mapvars["max_chunkx"]=0
#self.mapvars["min_chunkz"]=0
#self.mapvars["max_chunkz"]=0
#self.save_mapvars_if_changed()
##do not neet to run self.save_mapvars_if_changed() since already removed the yml
@ -1837,19 +1866,19 @@ class MTChunks:
self.verify_correct_map()
self.mapvars["chunkx_min"] = 0
self.mapvars["chunkz_min"] = 0
self.mapvars["chunkx_max"] = 0
self.mapvars["chunkz_max"] = 0
self.mapvars["min_chunkx"] = 0
self.mapvars["min_chunkz"] = 0
self.mapvars["max_chunkx"] = 0
self.mapvars["max_chunkz"] = 0
if self.saved_mapvars is not None:
if "chunkx_min" in self.saved_mapvars.keys():
self.mapvars["chunkx_min"] = self.saved_mapvars["chunkx_min"]
if "chunkx_max" in self.saved_mapvars.keys():
self.mapvars["chunkx_max"] = self.saved_mapvars["chunkx_max"]
if "chunkz_min" in self.saved_mapvars.keys():
self.mapvars["chunkz_min"] = self.saved_mapvars["chunkz_min"]
if "chunkz_max" in self.saved_mapvars.keys():
self.mapvars["chunkz_max"] = self.saved_mapvars["chunkz_max"]
if "min_chunkx" in self.saved_mapvars.keys():
self.mapvars["min_chunkx"] = self.saved_mapvars["min_chunkx"]
if "max_chunkx" in self.saved_mapvars.keys():
self.mapvars["max_chunkx"] = self.saved_mapvars["max_chunkx"]
if "min_chunkz" in self.saved_mapvars.keys():
self.mapvars["min_chunkz"] = self.saved_mapvars["min_chunkz"]
if "max_chunkz" in self.saved_mapvars.keys():
self.mapvars["max_chunkz"] = self.saved_mapvars["max_chunkz"]
self.mapvars["total_generated_count"] = 0
@ -1864,11 +1893,11 @@ class MTChunks:
self.read_then_remove_signals()
if not self.refresh_map_enable:
break
for chunky_z in range (self.mapvars["chunkz_min"],self.mapvars["chunkz_max"]+1):
for chunky_z in range (self.mapvars["min_chunkz"],self.mapvars["max_chunkz"]+1):
self.read_then_remove_signals()
if not self.refresh_map_enable:
break
for chunky_x in range(self.mapvars["chunkx_min"],self.mapvars["chunkx_max"]+1):
for chunky_x in range(self.mapvars["min_chunkx"],self.mapvars["max_chunkx"]+1):
self.read_then_remove_signals()
if not self.refresh_map_enable:
break
@ -1876,7 +1905,7 @@ class MTChunks:
#sudo mv ~/map.png /var/www/html/minetest/images/map.png
#only generate the edges (since started with region 0 0 0 0) and expanding from there until no png is created:
is_outline = (chunky_x==self.mapvars["chunkx_min"]) or (chunky_x==self.mapvars["chunkx_max"]) or (chunky_z==self.mapvars["chunkz_min"]) or (chunky_z==self.mapvars["chunkz_max"])
is_outline = (chunky_x==self.mapvars["min_chunkx"]) or (chunky_x==self.mapvars["max_chunkx"]) or (chunky_z==self.mapvars["min_chunkz"]) or (chunky_z==self.mapvars["max_chunkz"])
if is_outline:
is_present, reason_string = self.check_chunk(chunky_x, chunky_z)
if is_present:
@ -1884,10 +1913,10 @@ class MTChunks:
self.mapvars["total_generated_count"] += 1
if self.verbose_enable:
print ("") # blank line before next chunky_z so output is more readable
self.mapvars["chunkx_min"] -= 1
self.mapvars["chunkz_min"] -= 1
self.mapvars["chunkx_max"] += 1
self.mapvars["chunkz_max"] += 1
self.mapvars["min_chunkx"] -= 1
self.mapvars["min_chunkz"] -= 1
self.mapvars["max_chunkx"] += 1
self.mapvars["max_chunkz"] += 1
#end while square outline (1-chunk-thick outline) generated any png files
self.save_mapvars_if_changed()
if not self.verbose_enable:

411
expertmmregressionsuite.py

@ -0,0 +1,411 @@
import os
import sys
import keyword
#import types
import inspect
import traceback
module_list = list()
module_list.append("os")
module_list.append("sys")
module_list.append("keyword")
module_list.append("inspect")
module_list.append("traceback")
def view_traceback():
ex_type, ex, tb = sys.exc_info()
print(str(ex_type))
print(str(ex))
traceback.print_tb(tb)
del tb
class RegressionMismatch:
side_a_string = None
side_b_string = None
endswith_enable = None
startswith_enable = None
def __init__(self, side_a_string, side_b_string, startswith_enable, endswith_enable):
self.side_a_string = side_a_string
self.side_b_string = side_b_string
self.endswith_enable = endswith_enable
self.startswith_enable = startswith_enable
global_case_sensitive_enable = None
y_enable = False
print("Initializing...")
regression_mismatches = list()
independent_list = ["index","suffix","prefix","decachunk_x_path"]
print(" (Ignoring the following independent variables:")
print(','.join(independent_list)+")")
#NOTE: "for decachunk_z_name in os.listdir(decachunk_x_path):" is ok since z folders are in x folder
independent_endswith_list = list()
for word in independent_list:
independent_endswith_list.append("_"+word)
regression_mismatches.append(RegressionMismatch("_x","_z",False,True))
if y_enable:
regression_mismatches.append(RegressionMismatch("_x","_y",False,True))
regression_mismatches.append(RegressionMismatch("_y","_z",False,True))
regression_mismatches.append(RegressionMismatch("_x_","_z_",False,False))
if y_enable:
regression_mismatches.append(RegressionMismatch("_x_","_y_",False,False))
regression_mismatches.append(RegressionMismatch("_y_","_z_",False,False))
regression_mismatches.append(RegressionMismatch("x","z",False,True))
if y_enable:
regression_mismatches.append(RegressionMismatch("x","y",False,True))
regression_mismatches.append(RegressionMismatch("y","z",False,True))
regression_mismatches.append(RegressionMismatch("x_","z_",True,False))
if y_enable:
regression_mismatches.append(RegressionMismatch("x_","y_",True,False))
regression_mismatches.append(RegressionMismatch("y_","z_",True,False))
if global_case_sensitive_enable is True:
regression_mismatches.append(RegressionMismatch("_X_","_Z_",False,False))
if y_enable:
regression_mismatches.append(RegressionMismatch("_X_","_Y_",False,False))
regression_mismatches.append(RegressionMismatch("_Y_","_Z_",False,False))
regression_mismatches.append(RegressionMismatch("_X","_Z",False,True))
if y_enable:
regression_mismatches.append(RegressionMismatch("_X","_Y",False,True))
regression_mismatches.append(RegressionMismatch("_Y","_Z",False,True))
regression_mismatches.append(RegressionMismatch("X","Z",False,True))
if y_enable:
regression_mismatches.append(RegressionMismatch("X","Y",False,True))
regression_mismatches.append(RegressionMismatch("Y","Z",False,True))
regression_mismatches.append(RegressionMismatch("X_","Z_",True,False))
if y_enable:
regression_mismatches.append(RegressionMismatch("X_","Y_",True,False))
regression_mismatches.append(RegressionMismatch("Y_","Z_",True,False))
#splits by any non-alphanumeric characters
#print(keyword.kwlist)
# DOESN'T WORK (from linuxbochs on http://stackoverflow.com/questions/6315496/display-a-list-of-user-defined-functions-in-the-python-idle-session ):
#function_list = [f for f in globals().values() if type(f) == types.FunctionType]
# DOESN'T WORK
#def dummy(): pass
#function_list = [f.__name__ for f in globals().values() if type(f) == type(dummy)]
function_list = list()
for module_string in module_list:
exec ("function_list += inspect.getmembers("+module_string+", inspect.isroutine)")
# NOTE: isfunction does NOT include c-defined functions such as those in math
function_names = list()
for function_tuple in function_list:
function_names.append(function_tuple[0])
print(" (Ignoring known routines:")
print(','.join(function_names)+")")
print("")
print("")
def split_non_alnum(haystack, strip_enable=True, skip_keywords_enable=True):
results = list()
index = 0
start_index = 0
while index <= len(haystack):
if index==len(haystack) or not haystack[index].isalnum():
word = haystack[start_index:index]
if (not skip_keywords_enable) or (word not in keyword.kwlist and word not in function_names):
if strip_enable:
results.append(word.strip())
else:
results.append(word)
start_index = index+1
index += 1
return results
alpha_upper_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
alpha_lower_chars = alpha_upper_chars.lower()
alpha_chars = alpha_upper_chars+alpha_lower_chars
numeric_chars = "1234567890"
alnum_chars = alpha_chars+numeric_chars
identifier_chars = alnum_chars+"_"
issue_count = 0
file_list = list()
def is_identifier(needle):
result = True
for index in range(0,len(needle)):
if needle[index] not in identifier_chars:
result = False
break
return result
def split_non_identifier(haystack, strip_enable=True, skip_keywords_enable=True, skip_disoriented_enable=True):
results = list()
index = 0
start_index = 0
while index <= len(haystack):
if index==len(haystack) or not is_identifier(haystack[index]):
word = haystack[start_index:index]
if (not skip_keywords_enable) or word not in keyword.kwlist:
if (not skip_disoriented_enable) or (word not in independent_list and not endswith_any(word, independent_endswith_list)):
if strip_enable:
results.append(word.strip())
else:
results.append(word)
start_index = index+1
index += 1
return results
def endswith(haystack, needle, case_sensitive_enable=False):
if global_case_sensitive_enable is not None:
case_sensitive_enable = global_case_sensitive_enable
result = False
if haystack is not None and needle is not None and len(needle)>0 and len(haystack)>=len(needle):
if case_sensitive_enable:
if haystack[-len(needle):] == needle:
#print("haystack[-len(needle):] = "+haystack[-len(needle):]+" in "+haystack)
result = True
else:
if haystack[-len(needle):].lower() == needle.lower():
#print("haystack[-len(needle):].lower() = "+haystack[-len(needle):].lower()+" in "+haystack)
result = True
return result
def startswith(haystack, needle, case_sensitive_enable=False):
if global_case_sensitive_enable is not None:
case_sensitive_enable = global_case_sensitive_enable
result = False
if haystack is not None and needle is not None and len(needle)>0 and len(haystack)>=len(needle):
if case_sensitive_enable:
if haystack[:len(needle)] == needle:
result = True
else:
if haystack[:len(needle)].lower() == needle.lower():
result = True
return result
def any_endswith(haystacks, needle, case_sensitive_enable=False):
if global_case_sensitive_enable is not None:
case_sensitive_enable = global_case_sensitive_enable
result = False
for haystack in haystacks:
if endswith(haystack, needle, case_sensitive_enable):
result = True
break
return result
def endswith_any(haystack, needles, case_sensitive_enable=False):
if global_case_sensitive_enable is not None:
case_sensitive_enable = global_case_sensitive_enable
result = False
for needle in needles:
if endswith(haystack, needle, case_sensitive_enable):
result = True
break
return result
def any_startswith(haystacks, needle, case_sensitive_enable=False):
if global_case_sensitive_enable is not None:
case_sensitive_enable = global_case_sensitive_enable
result = False
for haystack in haystacks:
if startswith(haystack, needle, case_sensitive_enable):
result = True
break
return result
#only works on strings IF case_sensitive_enable, since then would do lower() on each element of haystacks
def in_any_string(needle, haystacks, case_sensitive_enable=False):
if global_case_sensitive_enable is not None:
case_sensitive_enable = global_case_sensitive_enable
result = False
if needle is not None and len(needle)>0:
for haystack in haystacks:
if haystack is not None and len(haystack)>0:
if case_sensitive_enable:
if needle in haystack:
result = True
break
else:
if needle.lower() in haystack.lower():
result = True
break
return result
min_indent = ""
def increase_indent():
global min_indent
min_indent+=" "
def decrease_indent():
global min_indent
if len(min_indent)>=2:
min_indent = min_indent[:-2]
def check_coord_mismatch(file_path):
global file_list
global issue_count
global module_list
print("Running check_coord_mismatch on "+file_path+"...")
global function_list
if (file_path not in file_list):
file_list.append(file_path)
line_counting_number = 1
ins = open(file_path, 'r')
line = True
global min_indent
while line:
line = ins.readline()
if line:
line_strip = line.strip()
if (len(line_strip)>0) and (line_strip[0]!="#"):
ao_index = line_strip.find("=")
import_string = "import "
from_string = "from "
import_index = -1
if line_strip[:len(import_string)]==import_string:
import_index = 0
elif line_strip[:len(from_string)]==from_string:
import_string = from_string
import_index = line_strip.find(import_string)
if import_index>=0:
module_string = line_strip[import_index+len(import_string):].strip()
space_index = module_string.find(" ")
if space_index>-1:
module_string = module_string[:space_index]
if module_string not in module_list:
module_list.append(module_string)
try:
#tmp_tuples = list()
import_string = "import "+module_string
exec_string = "tmp_tuples = inspect.getmembers("+module_string+", inspect.isroutine)"
#exec exec_string
try_enable = False
outs = open('expertmmregressiontmp.py','w')
outs.write("def get_module_contents():"+"\n")
outs_indent = " "
outs.write(outs_indent+"results = None"+"\n")
if try_enable:
outs.write(outs_indent+"try:"+"\n")
outs_indent = " "
outs.write(outs_indent+"import inspect"+"\n")
outs.write(outs_indent+import_string+"\n")
outs.write(outs_indent+exec_string+"\n")
outs.write(outs_indent+"results = list()"+"\n")
outs.write(outs_indent+"for function_tuple in tmp_tuples:"+"\n")
outs.write(outs_indent+" results.append(function_tuple[0])"+"\n")
outs_indent = " "
if try_enable:
outs.write(outs_indent+"except:"+"\n")
outs_indent = " "
outs.write(outs_indent+"print(\"Could not finish get_module_contents\")"+"\n")
outs_indent = " "
outs.write(outs_indent+"return results"+"\n")
outs.write("\n")
outs.close()
import expertmmregressiontmp
tmp_list = expertmmregressiontmp.get_module_contents()
new_list = None
if tmp_list is not None:
new_list = list()
for routine_string in tmp_list:
if routine_string not in function_list:
new_list.append(routine_string)
if new_list is not None:
function_list += new_list
print("Found "+str(len(new_list))+" new method(s) from '"+module_string+"' to ignore: "+','.join(new_list))
else:
print("unable to import module named '"+module_string+"', so some routines may not be successfully ignored:")
except:
print("Could not finish importing module named '"+module_string+"', so some routines may not be successfully ignored:")
view_traceback()
if ao_index<0:
ao_index = line_strip.find(">")
if ao_index<0:
ao_index = line_strip.find("<")
if ao_index<0:
ao_index = line_strip.find(" in ")
if ao_index>0: # intentionally >0 instead of =
increase_indent()
names_string = line_strip[:ao_index].strip()
values_string = line_strip[ao_index+1:].strip()
name_list = split_non_identifier(names_string)
value_list = split_non_identifier(values_string)
message = None
is_line_problematic = False
for regression_mismatch in regression_mismatches:
both_present = False
message_prefix = " WARNING: "
only_mismatched_coord_is_present_string = " ERROR (only has mismatch): "
if regression_mismatch.startswith_enable:
if (any_startswith(name_list,regression_mismatch.side_a_string) and not any_startswith(name_list,regression_mismatch.side_b_string)) and any_startswith(value_list,regression_mismatch.side_b_string):
name_index = line.find(regression_mismatch.side_a_string) + 1
if not both_present:
both_present = any_startswith(value_list,regression_mismatch.side_a_string)
message_prefix = only_mismatched_coord_is_present_string
if message is None:
message = (file_path+" ("+str(line_counting_number)+","+str(name_index)+")"+message_prefix+"name starts with "+regression_mismatch.side_a_string+", but "+regression_mismatch.side_b_string+" on right in check/assignment")
is_line_problematic = True
break
elif (any_startswith(name_list,regression_mismatch.side_b_string) and not any_startswith(name_list,regression_mismatch.side_a_string)) and any_startswith(value_list,regression_mismatch.side_a_string):
name_index = line.find(regression_mismatch.side_b_string) + 1
if not both_present:
both_present = any_startswith(value_list,regression_mismatch.side_b_string)
message_prefix = only_mismatched_coord_is_present_string
if message is None:
message = (file_path+" ("+str(line_counting_number)+","+str(name_index)+")"+message_prefix+"name starts with "+regression_mismatch.side_b_string+", but "+regression_mismatch.side_a_string+" on right in check/assignment")
is_line_problematic = True
break
elif regression_mismatch.endswith_enable:
if (any_endswith(name_list,regression_mismatch.side_a_string) and not any_endswith(name_list,regression_mismatch.side_b_string)) and any_endswith(value_list,regression_mismatch.side_b_string):
name_index = line.find(regression_mismatch.side_a_string) + 1
if not both_present:
both_present = any_endswith(value_list,regression_mismatch.side_a_string)
message_prefix = only_mismatched_coord_is_present_string
if message is None:
message = (file_path+" ("+str(line_counting_number)+","+str(name_index)+")"+message_prefix+"name ends with "+regression_mismatch.side_a_string+", but "+regression_mismatch.side_b_string+" on right in check/assignment")
is_line_problematic = True
break
elif (any_endswith(name_list,regression_mismatch.side_b_string) and not any_endswith(name_list,regression_mismatch.side_a_string)) and any_endswith(value_list,regression_mismatch.side_a_string):
name_index = line.find(regression_mismatch.side_b_string) + 1
if not both_present:
both_present = any_endswith(value_list,regression_mismatch.side_b_string)
message_prefix = only_mismatched_coord_is_present_string
if message is None:
message = (file_path+" ("+str(line_counting_number)+","+str(name_index)+")"+message_prefix+"name ends with "+regression_mismatch.side_b_string+", but "+regression_mismatch.side_a_string+" on right in check/assignment")
is_line_problematic = True
break
else:
if (in_any_string(regression_mismatch.side_a_string, name_list) and not in_any_string(regression_mismatch.side_b_string, name_list)) and in_any_string(regression_mismatch.side_b_string, value_list):
value_index = line.find(regression_mismatch.side_a_string) + 1
if not both_present:
both_present = in_any_string(regression_mismatch.side_a_string, value_list)
message_prefix = only_mismatched_coord_is_present_string
if message is None:
message = (file_path+" ("+str(line_counting_number)+","+str(value_index)+")"+message_prefix+"name contains "+regression_mismatch.side_a_string+", but "+regression_mismatch.side_b_string+" on right in check/assignment")
is_line_problematic = True
break
elif (in_any_string(regression_mismatch.side_b_string, name_list) and not in_any_string(regression_mismatch.side_a_string, name_list)) and in_any_string(regression_mismatch.side_a_string, value_list):
value_index = line.find(regression_mismatch.side_b_string) + 1
if not both_present:
both_present = in_any_string(regression_mismatch.side_b_string, value_list)
message_prefix = only_mismatched_coord_is_present_string
if message is None:
message = (file_path+" ("+str(line_counting_number)+","+str(value_index)+")"+message_prefix+"name contains "+regression_mismatch.side_b_string+", but "+regression_mismatch.side_a_string+" on right side of check/assignment")
is_line_problematic = True
break
if message is not None:
print("")
print(message)
print(line_strip)
if is_line_problematic:
issue_count += 1
line_counting_number += 1
ins.close()
check_coord_mismatch("chunkymap-regen.py")
check_coord_mismatch(os.path.join("web","chunkymap.php"))
print("Found "+str(issue_count)+" issue(s) in "+str(len(file_list))+" file(s)")
raw_input("Press enter to exit...")

10
expertmmregressiontmp.py

@ -0,0 +1,10 @@
def get_module_contents():
results = None
import inspect
import PIL
tmp_tuples = inspect.getmembers(PIL, inspect.isroutine)
results = list()
for function_tuple in tmp_tuples:
results.append(function_tuple[0])
return results

124
web/chunkymap.php

@ -49,8 +49,8 @@ $chunkymap_tile_original_h=16;
$chunk_dimension_min=$chunkymap_tile_original_w;
if ($chunkymap_tile_original_h<$chunk_dimension_min) $chunk_dimension_min=$chunkymap_tile_original_h;
$chunkymap_view_zoom_min=1.0/$chunk_dimension_min; //should be a number that would get to exactly 100 eventually if multiplied by 2 repeatedly (such as 0.09765625); 0.005 was avoided since tiles used to be 80x80 pixels
$chunkymap_view_zoom_max=13107200.0;
$chunkymap_view_min_zoom=1.0/$chunk_dimension_min; //should be a number that would get to exactly 100 eventually if multiplied by 2 repeatedly (such as 0.09765625); 0.005 was avoided since tiles used to be 80x80 pixels
$chunkymap_view_max_zoom=13107200.0;
function echo_error($val) {
if (!isset($val)) {
@ -132,8 +132,8 @@ function echo_chunkymap_controls() {
global $chunkymap_view_x;
global $chunkymap_view_z;
global $chunkymap_view_zoom_multiplier;
global $chunkymap_view_zoom_max;
global $chunkymap_view_zoom_min;
global $chunkymap_view_max_zoom;
global $chunkymap_view_min_zoom;
global $chunkymap_anchor_name;
$is_in=false;
$is_out=false;
@ -141,7 +141,7 @@ function echo_chunkymap_controls() {
$out_img_name = "zoom-out.png";
$in_zoom = $chunkymap_view_zoom_multiplier;
if ($in_zoom<$chunkymap_view_zoom_max) {
if ($in_zoom<$chunkymap_view_max_zoom) {
$is_in=true;
$in_zoom = $chunkymap_view_zoom_multiplier*2.0;
//echo "in:$in_zoom ";
@ -149,15 +149,15 @@ function echo_chunkymap_controls() {
else $in_img_name = "zoom-in_disabled.png";
$out_zoom = $chunkymap_view_zoom_multiplier;
if ($out_zoom>$chunkymap_view_zoom_min) {
if ($out_zoom>$chunkymap_view_min_zoom) {
$is_out=true;
$out_zoom = ($chunkymap_view_zoom_multiplier/2.0);
}
else $out_img_name = "zoom-out_disabled.png";
$zoom_clip = $chunkymap_view_zoom_max;
$zoom_clip = $chunkymap_view_max_zoom;
$found=false;
while ($zoom_clip>=$chunkymap_view_zoom_min) {
while ($zoom_clip>=$chunkymap_view_min_zoom) {
if ($out_zoom>$zoom_clip) {
$out_zoom=$zoom_clip*2;
$found=true;
@ -166,11 +166,11 @@ function echo_chunkymap_controls() {
$zoom_clip = $zoom_clip/2;
}
if (!$found) {
$out_zoom=$chunkymap_view_zoom_min;
$out_zoom=$chunkymap_view_min_zoom;
}
//if ($in_zoom>$chunkymap_view_zoom_max) {
// $in_zoom=$chunkymap_view_zoom_max;
// echo "<!--clipping to max $chunkymap_view_zoom_max-->";
//if ($in_zoom>$chunkymap_view_max_zoom) {
// $in_zoom=$chunkymap_view_max_zoom;
// echo "<!--clipping to max $chunkymap_view_max_zoom-->";
//}
//elseif ($in_zoom>200) $in_zoom=400;
//elseif ($in_zoom>100) $in_zoom=200;
@ -181,9 +181,9 @@ function echo_chunkymap_controls() {
//elseif ($in_zoom>4) $in_zoom=12;
//elseif ($in_zoom>2) $in_zoom=4;
//elseif ($in_zoom>1) $in_zoom=2;
//else $in_zoom=$chunkymap_view_zoom_min; // if ($in_zoom>1) $in_zoom=5;
//else $in_zoom=$chunkymap_view_min_zoom; // if ($in_zoom>1) $in_zoom=5;
//echo "in:$in_zoom ";
// if ($out_zoom<$chunkymap_view_zoom_min) $out_zoom=$chunkymap_view_zoom_min;
// if ($out_zoom<$chunkymap_view_min_zoom) $out_zoom=$chunkymap_view_min_zoom;
// elseif ($out_zoom<2) $out_zoom=1;
// elseif ($out_zoom<4) $out_zoom=2;
// elseif ($out_zoom<12) $out_zoom=4;
@ -192,11 +192,11 @@ function echo_chunkymap_controls() {
// elseif ($out_zoom<75) $out_zoom=50;
// elseif ($out_zoom<100) $out_zoom=75;
//elseif ($out_zoom<200) $out_zoom=100;
//elseif ($out_zoom<$chunkymap_view_zoom_max) $out_zoom=(int)($chunkymap_view_zoom_max/2);
//else $out_zoom=$chunkymap_view_zoom_max; //if ($out_zoom>76) $out_zoom=100;
$zoom_clip=$chunkymap_view_zoom_min;
//elseif ($out_zoom<$chunkymap_view_max_zoom) $out_zoom=(int)($chunkymap_view_max_zoom/2);
//else $out_zoom=$chunkymap_view_max_zoom; //if ($out_zoom>76) $out_zoom=100;
$zoom_clip=$chunkymap_view_min_zoom;
$found=false;
while ($zoom_clip<=$chunkymap_view_zoom_max) {
while ($zoom_clip<=$chunkymap_view_max_zoom) {
if ($in_zoom<($zoom_clip*2)) {
$in_zoom=$zoom_clip;
$found=true;
@ -204,7 +204,7 @@ function echo_chunkymap_controls() {
}
$zoom_clip = $zoom_clip * 2;
}
if (!$found) $in_zoom=$chunkymap_view_zoom_max;
if (!$found) $in_zoom=$chunkymap_view_max_zoom;
$in_html="<img src=\"chunkymapdata/images/$in_img_name\" style=\"width:16pt; height:16pt\" />";
$out_html="<img src=\"chunkymapdata/images/$out_img_name\" style=\"width:16pt; height:16pt\" />";
@ -312,8 +312,8 @@ function echo_chunkymap_canvas() {
global $chunkymap_view_x;
global $chunkymap_view_z;
global $chunkymap_view_zoom_multiplier;
global $chunkymap_view_zoom_max;
global $chunkymap_view_zoom_min;
global $chunkymap_view_max_zoom;
global $chunkymap_view_min_zoom;
global $showplayers;
check_world();
@ -325,8 +325,8 @@ function echo_chunkymap_canvas() {
$z_opener="z";
$dot_and_ext = ".jpg";
if ($chunkymap_view_zoom_multiplier<$chunkymap_view_zoom_min) $chunkymap_view_zoom_multiplier = $chunkymap_view_zoom_min;
if ($chunkymap_view_zoom_multiplier>$chunkymap_view_zoom_max) $chunkymap_view_zoom_multiplier = $chunkymap_view_zoom_max;
if ($chunkymap_view_zoom_multiplier<$chunkymap_view_min_zoom) $chunkymap_view_zoom_multiplier = $chunkymap_view_min_zoom;
if ($chunkymap_view_zoom_multiplier>$chunkymap_view_max_zoom) $chunkymap_view_zoom_multiplier = $chunkymap_view_max_zoom;
$decachunks_per_page = 1.0/$chunkymap_view_zoom_multiplier;
$view_w = (($decachunks_per_page*160.0));
@ -358,7 +358,7 @@ function echo_chunkymap_canvas() {
//echo "<br/>";
//echo "$decachunky_min_x:$decachunky_max_x,$decachunky_min_z:$decachunky_max_z<br/>";
$td_placeholder_content="<!--widening table--><img src=\"chunkymapdata/images/decachunk-blank.jpg\" style=\"width:100%; -webkit-filter: opacity(40%); filter: opacity(40%); background-color:black\"/>";
$td_placeholder_content_1px="<!--widening table--><img src=\"chunkymapdata/images/decachunk-blank.jpg\" style=\"width:1px; -webkit-filter: opacity(40%); filter: opacity(40%); background-color:black\"/>";
$td_1px_placeholder_content="<!--widening table--><img src=\"chunkymapdata/images/decachunk-blank.jpg\" style=\"width:1px; -webkit-filter: opacity(40%); filter: opacity(40%); background-color:black\"/>";
echo '<table id="chunkymap_table" cellspacing="0" cellpadding="0" style="width:100%">'."\r\n";
echo ' <tr>'."\r\n";
echo ' <td style="width:5%">'."$td_placeholder_content".'</td>'."\r\n";
@ -390,7 +390,7 @@ function echo_chunkymap_canvas() {
$decachunky_x+=1;
}
if ($cell_perc_remaining>0) {
$td_content=$td_placeholder_content_1px;
$td_content=$td_1px_placeholder_content;
echo " <td>$td_content</td>"."\r\n";
}
echo ' </tr>'."\r\n";
@ -443,33 +443,33 @@ function echo_chunkymap_as_chunk_table($show_all_enable) {
global $chunkymap_view_x;
global $chunkymap_view_z;
global $chunkymap_view_zoom_multiplier;
global $chunkymap_view_zoom_max;
global $chunkymap_view_zoom_min;
global $chunkymap_view_max_zoom;
global $chunkymap_view_min_zoom;
global $chunkymapdata_path;
global $chunkymapdata_worlds_path;
global $map_dict;
global $is_verbose;
global $chunkymap_tile_original_w;
global $chunkymap_tile_original_h;
global $chunkymap_view_zoom_max;
global $chunkymap_view_max_zoom;
global $world_name;
echo_chunkymap_anchor();
echo_chunkymap_controls();
echo " ".($chunkymap_view_zoom_multiplier*100.0)."%";//(string)((int)($chunkymap_view_zoom_multiplier*100+.5));
if ($chunkymap_view_zoom_multiplier<$chunkymap_view_zoom_min) $chunkymap_view_zoom_multiplier = $chunkymap_view_zoom_min;
if ($chunkymap_view_zoom_multiplier>$chunkymap_view_zoom_max) $chunkymap_view_zoom_multiplier = $chunkymap_view_zoom_max;
if ($chunkymap_view_zoom_multiplier<$chunkymap_view_min_zoom) $chunkymap_view_zoom_multiplier = $chunkymap_view_min_zoom;
if ($chunkymap_view_zoom_multiplier>$chunkymap_view_max_zoom) $chunkymap_view_zoom_multiplier = $chunkymap_view_max_zoom;
//$zoom_divisor = (int)(100/$chunkymap_view_zoom_multiplier);
$chunk_assoc = array(); // used for storing players; and used for determining which chunks are on the edge, since not all generated map tiles are the same size (edge tile images are smaller and corner ones are smaller yet)
$chunk_count = 0;
$x_opener="chunk_x";
$z_opener="z";
$dot_and_ext = ".png";
$chunkx_min = 0;
$chunkz_min = 0;
$chunkx_max = 0;
$chunkz_max = 0;
$min_chunkx = 0;
$min_chunkz = 0;
$max_chunkx = 0;
$max_chunkz = 0;
$chunks_per_page = (1.0/$chunkymap_view_zoom_multiplier)*10;
$view_w = (($chunks_per_page*16.0));
@ -481,10 +481,10 @@ function echo_chunkymap_as_chunk_table($show_all_enable) {
$view_bottom = $view_top - $view_h;
if (!$show_all_enable) {
$chunkx_min=intval($view_left/$chunkymap_tile_original_w);
$chunkx_max=intval($view_right/$chunkymap_tile_original_w);
$chunkz_min=intval($view_bottom/$chunkymap_tile_original_w);
$chunkz_max=intval($view_top/$chunkymap_tile_original_w);
$min_chunkx=intval($view_left/$chunkymap_tile_original_w);
$max_chunkx=intval($view_right/$chunkymap_tile_original_w);
$min_chunkz=intval($view_bottom/$chunkymap_tile_original_w);
$max_chunkz=intval($view_top/$chunkymap_tile_original_w);
}
global $showplayers;
$players = array();
@ -633,10 +633,10 @@ function echo_chunkymap_as_chunk_table($show_all_enable) {
//if ($map_dict != null) {
// $chunkx_min = $map_dict["chunkx_min"];
// $chunkz_min = $map_dict["chunkz_min"];
// $chunkx_max = $map_dict["chunkx_max"];
// $chunkz_max = $map_dict["chunkz_max"];
// $min_chunkx = $map_dict["min_chunkx"];
// $min_chunkz = $map_dict["min_chunkz"];
// $max_chunkx = $map_dict["max_chunkx"];
// $max_chunkz = $map_dict["max_chunkz"];
//}
//else {
//echo "calculating range...";
@ -648,18 +648,18 @@ function echo_chunkymap_as_chunk_table($show_all_enable) {
if ((substr($decachunk_x_name, 0, 1) != ".") and is_dir($decachunk_x_path)) {
$decachunk_x_handle = opendir($decachunk_x_path);
while (false !== ($decachunk_z_name = readdir($decachunk_x_handle))) {
$decachunk_z_path = $decachunk_x_path."/".$decachunk_z_name;
if ((substr($decachunk_z_name, 0, 1) != ".") and is_dir($decachunk_z_path)) {
$decachunk_z_handle = opendir($decachunk_z_path);
$decachunk_folder_path = $decachunk_x_path."/".$decachunk_z_name;
if ((substr($decachunk_z_name, 0, 1) != ".") and is_dir($decachunk_folder_path)) {
$decachunk_z_handle = opendir($decachunk_folder_path);
while (false !== ($chunk_name = readdir($decachunk_z_handle))) {
$file_lower = strtolower($chunk_name);
if (endsWith($file_lower, $dot_and_ext) and startsWith($file_lower, $x_opener)) {
$z_opener_index = strpos($file_lower, $z_opener, strlen($x_opener));
if ($z_opener_index !== false) {
$x_len = $z_opener_index - strlen($x_opener);
$z_len = strlen($file_lower) - strlen($x_opener) - $x_len - strlen($z_opener) - strlen($dot_and_ext);
$remaining_len = strlen($file_lower) - strlen($x_opener) - $x_len - strlen($z_opener) - strlen($dot_and_ext);
$x = substr($file_lower, strlen($x_opener), $x_len);
$z = substr($file_lower, $z_opener_index + strlen($z_opener), $z_len);
$z = substr($file_lower, $z_opener_index + strlen($z_opener), $remaining_len);
if (is_int_string($x) and is_int_string($z)) {
$chunk_luid = "x".$x."z".$z;
if (!isset($chunk_assoc[$chunk_luid])) {
@ -668,17 +668,17 @@ function echo_chunkymap_as_chunk_table($show_all_enable) {
$chunk_assoc[$chunk_luid]["is_rendered"] = true;
if ($is_verbose) echo "$chunk_luid,";
if ($show_all_enable) {
if ($x<$chunkx_min) {
$chunkx_min=(int)$x;
if ($x<$min_chunkx) {
$min_chunkx=(int)$x;
}
if ($x>$chunkx_max) {
$chunkx_max=(int)$x;
if ($x>$max_chunkx) {
$max_chunkx=(int)$x;
}
if ($z<$chunkz_min) {
$chunkz_min=(int)$z;
if ($z<$min_chunkz) {
$min_chunkz=(int)$z;
}
if ($z>$chunkz_max) {
$chunkz_max=(int)$z;
if ($z>$max_chunkz) {
$max_chunkz=(int)$z;
}
}
}
@ -695,7 +695,7 @@ function echo_chunkymap_as_chunk_table($show_all_enable) {
}
}
if ($is_verbose) echo "checked all chunks.";
echo "<!--found chunks in x $chunkx_min to $chunkx_max and z $chunkz_min to $chunkz_max.-->";
echo "<!--found chunks in x $min_chunkx to $max_chunkx and z $min_chunkz to $max_chunkz.-->";
closedir($chunks_16px_handle);
}
else {
@ -703,13 +703,13 @@ function echo_chunkymap_as_chunk_table($show_all_enable) {
}
//}
$x_count = $chunkx_max - $chunkx_min;
$z_count = $chunkz_max - $chunkz_min;
$x_count = $max_chunkx - $min_chunkx;
$z_count = $max_chunkz - $min_chunkz;
echo "\r\n";
echo "<center>\r\n";
//cellpadding="0" cellspacing="0" still needed for IE
echo_hold( " <table id=\"chunkymapstatictable\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-spacing: 0px; border-style:solid; border-color:gray; border-width:0px\">\r\n");
$z = (int)$chunkz_max;
$z = (int)$max_chunkz;
$scale=(float)$chunkymap_view_zoom_multiplier; // no longer /100
$zoomed_w=(int)((float)$chunkymap_tile_original_w*$scale+.5);
$zoomed_h=(int)((float)$chunkymap_tile_original_h*$scale+.5);
@ -719,10 +719,10 @@ function echo_chunkymap_as_chunk_table($show_all_enable) {
$player_file_age_expired_max_seconds=20*$minute-1;
$player_file_age_idle_max_seconds=5*$minute-1;
$chunks_16px_path = $chunkymapdata_thisworld_path.'/'."16px";
while ($z >= $chunkz_min) {
while ($z >= $min_chunkz) {
echo_hold( " <tr>\r\n");
$x = (int)$chunkx_min;
while ($x <= $chunkx_max) {
$x = (int)$min_chunkx;
while ($x <= $max_chunkx) {
$this_zoomed_w = $zoomed_w;
$this_zoomed_h = $zoomed_h;

Loading…
Cancel
Save