Browse Source

working on fixing decachunk generation

master
poikilos 9 years ago
committed by Jacob Gustafson
parent
commit
51e0e2b456
  1. 23
      chunkymap-regen.py
  2. 15
      install-chunkymap-on-windows.py

23
chunkymap-regen.py

@ -60,7 +60,7 @@ class InstalledFile:
self.source_dir_path=source_dir_path self.source_dir_path=source_dir_path
self.dest_dir_path=dest_dir_path self.dest_dir_path=dest_dir_path
def get_dict_deepcopy(old_dict): def get_dict_deepcopy(old_dict):
new_dict = None new_dict = None
if type(old_dict) is dict: if type(old_dict) is dict:
@ -391,6 +391,7 @@ class MTChunks:
chunks = None chunks = None
decachunks = None decachunks = None
rendered_this_session_count = None rendered_this_session_count = None
#force_rerender_decachunks_enable = None
#region values for subprocess arguments: #region values for subprocess arguments:
pixelspernode = 1 pixelspernode = 1
@ -434,6 +435,7 @@ class MTChunks:
min_indent = None min_indent = None
def __init__(self): #formerly checkpaths() in global scope def __init__(self): #formerly checkpaths() in global scope
#self.force_rerender_decachunks_enable = True
self.min_indent = " " self.min_indent = " "
self.decachunks = {} self.decachunks = {}
self.rendered_this_session_count = 0 self.rendered_this_session_count = 0
@ -904,7 +906,7 @@ class MTChunks:
decachunk_image_path = self.get_decachunk_image_path_from_decachunk(decachunky_x, decachunky_z) decachunk_image_path = self.get_decachunk_image_path_from_decachunk(decachunky_x, decachunky_z)
combined_count = 0 combined_count = 0
contains_chunk_luids = list() contains_chunk_luids = list()
for coord in chunk16_coord_list: for coord in chunk16_coord_list:
chunky_x, chunky_z = coord chunky_x, chunky_z = coord
chunky_offset_x = chunky_x - chunk16x_min chunky_offset_x = chunky_x - chunk16x_min
@ -1563,8 +1565,9 @@ class MTChunks:
prev_len = len(self.todo_positions) prev_len = len(self.todo_positions)
self._check_map_pseudorecursion_branchfrom(chunky_x, chunky_z) self._check_map_pseudorecursion_branchfrom(chunky_x, chunky_z)
#must check_decachunk_containing_chunk AFTER _check_map_pseudorecursion_branchfrom so check_decachunk_containing_chunk can see if there are more to do before rendering superchunk #must check_decachunk_containing_chunk AFTER _check_map_pseudorecursion_branchfrom so check_decachunk_containing_chunk can see if there are more to do before rendering superchunk
if self.rendered_this_session_count>prev_rendered_this_session_count: #always check since already checks queue and doesn't render decachunk on last rendered chunk, but instead on last queued chunk in decachunk
self.check_decachunk_containing_chunk(chunky_x, chunky_z) #if self.rendered_this_session_count>prev_rendered_this_session_count or self.force_rerender_decachunks_enable:
self.check_decachunk_containing_chunk(chunky_x, chunky_z)
if self.verbose_enable: if self.verbose_enable:
print(min_indent+"["+str(self.todo_index)+"] branching from "+str((chunky_x, chunky_z))+" (added "+str(len(self.todo_positions)-prev_len)+")") print(min_indent+"["+str(self.todo_index)+"] branching from "+str((chunky_x, chunky_z))+" (added "+str(len(self.todo_positions)-prev_len)+")")
else: else:
@ -1596,7 +1599,7 @@ class MTChunks:
except: except:
pass pass
return result return result
def apply_auto_tags_by_worldgen_mods(self, chunky_x, chunky_z): def apply_auto_tags_by_worldgen_mods(self, chunky_x, chunky_z):
worldgen_mod_list = list() worldgen_mod_list = list()
worldgen_mod_list.append("technic_worldgen") worldgen_mod_list.append("technic_worldgen")
@ -1608,7 +1611,7 @@ class MTChunks:
worldgen_mod_list.append("caverealms") worldgen_mod_list.append("caverealms")
#worldgen_mod_list.append("nature_classic") # NOTE: plantlife_modpack has this and other stuff, but just mention this one in tags since it is unique to the modpack #worldgen_mod_list.append("nature_classic") # NOTE: plantlife_modpack has this and other stuff, but just mention this one in tags since it is unique to the modpack
worldgen_mod_list.append("plantlife_modpack") #ok if installed as modpack instead of putting individual mods in mods folder worldgen_mod_list.append("plantlife_modpack") #ok if installed as modpack instead of putting individual mods in mods folder
chunk_luid = self.get_chunk_luid(chunky_x, chunky_z) chunk_luid = self.get_chunk_luid(chunky_x, chunky_z)
if chunk_luid not in self.chunks.keys(): if chunk_luid not in self.chunks.keys():
self.prepare_chunk_meta(chunky_x, chunky_z) self.prepare_chunk_meta(chunky_x, chunky_z)
@ -1625,10 +1628,10 @@ class MTChunks:
#TODO: finish this #TODO: finish this
#for mod_name in worldgen_mod_list: #for mod_name in worldgen_mod_list:
#mod_path = self.asdf #mod_path = self.asdf
#if os.path.isdir( #if os.path.isdir(
#if is_changed: #if is_changed:
# self.save_chunk_meta(chunky_x, chunky_z) # self.save_chunk_meta(chunky_x, chunky_z)
def correct_genresults_paths(self): def correct_genresults_paths(self):
count = 0 count = 0
folder_path = self.get_chunk_genresults_base_path() folder_path = self.get_chunk_genresults_base_path()
@ -1670,7 +1673,7 @@ class MTChunks:
print("MOVED "+str(count)+" genresult file(s)") print("MOVED "+str(count)+" genresult file(s)")
print("") print("")
print("") print("")
def check_map_pseudorecursion_start(self): def check_map_pseudorecursion_start(self):
if self.todo_index<0: if self.todo_index<0:
@ -1717,7 +1720,7 @@ class MTChunks:
break break
print("Checking chunk "+str(coords)+" *"+str(self.mapvars["chunk_size"])+"") print("Checking chunk "+str(coords)+" *"+str(self.mapvars["chunk_size"])+"")
self.prepare_chunk_meta(chunky_x, chunky_z) self.prepare_chunk_meta(chunky_x, chunky_z)
#if ("tags" not in self.chunks[chunk_luid].metadata): #if ("tags" not in self.chunks[chunk_luid].metadata):
#self.chunks[chunk_luid].metadata["tags"] = "moreores,caverealms" #self.chunks[chunk_luid].metadata["tags"] = "moreores,caverealms"
#self.save_chunk_meta(chunky_x, chunky_z) #self.save_chunk_meta(chunky_x, chunky_z)

15
install-chunkymap-on-windows.py

@ -12,7 +12,7 @@ def view_traceback():
traceback.print_tb(tb) traceback.print_tb(tb)
del tb del tb
#as per Pedro Lobito on http://stackoverflow.com/questions/802134/changing-user-agent-on-urllib2-urlopen #as per Pedro Lobito on http://stackoverflow.com/questions/802134/changing-user-agent-on-urllib2-urlopen
from urllib import FancyURLopener from urllib import FancyURLopener
class MyOpener(FancyURLopener, object): class MyOpener(FancyURLopener, object):
version = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11' version = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11'
@ -21,16 +21,17 @@ def web_get(url, file_name):
myopener = MyOpener() myopener = MyOpener()
print("Downloading "+url+"...") print("Downloading "+url+"...")
myopener.retrieve(url, file_name) myopener.retrieve(url, file_name)
#as per http://stackoverflow.com/questions/22676/how-do-i-download-a-file-over-http-using-python
#as per http://stackoverflow.com/questions/22676/how-do-i-download-a-file-over-http-using-python but FAILS (404 Error) since user agent is not recognized, and setting user agent string does not fix it. use web_get above instead.
def web_get_BADUSERAGENT(url, file_name): def web_get_BADUSERAGENT(url, file_name):
print("This function probably will not work since settings user agent doesn't work with urllib2 request object (user agent is not recognized, and 404 error is usually the result). Try web_get instead.")
file_name = None file_name = None
try: try:
#url = "http://download.thinkbroadband.com/10MB.zip" #url = "http://download.thinkbroadband.com/10MB.zip"
#file_name = url.split('/')[-1] #file_name = url.split('/')[-1]
u = urllib2.urlopen(url) u = urllib2.urlopen(url)
f = open(file_name, 'wb') f = open(file_name, 'wb')
meta = u.info() meta = u.info()
@ -148,7 +149,7 @@ if python_folder_name.lower()[:7]!="python3":
python_Lib_path = os.path.join(python_folder_path,"Lib") python_Lib_path = os.path.join(python_folder_path,"Lib")
python_Lib_site_packages_path = os.path.join(python_Lib_path, "site-packages") python_Lib_site_packages_path = os.path.join(python_Lib_path, "site-packages")
if os.path.isdir(python_Lib_site_packages_path): if os.path.isdir(python_Lib_site_packages_path):
installed_numpy_path = os.path.join(python_Lib_site_packages_path, "numpy") installed_numpy_path = os.path.join(python_Lib_site_packages_path, "numpy")
if not os.path.isdir(installed_numpy_path): if not os.path.isdir(installed_numpy_path):
#downloaded_numpy_path = os.path.join(downloads_path, downloaded_numpy_name) #downloaded_numpy_path = os.path.join(downloads_path, downloaded_numpy_name)
@ -161,7 +162,7 @@ if python_folder_name.lower()[:7]!="python3":
if os.path.isfile(downloaded_numpy_path): if os.path.isfile(downloaded_numpy_path):
subprocess.call(install_numpy_cmd_string) subprocess.call(install_numpy_cmd_string)
if os.path.isdir(installed_numpy_path): if os.path.isdir(installed_numpy_path):
print("Numpy was detected at '"+installed_numpy_path+"'") print("Numpy was detected at '"+installed_numpy_path+"'")
installed_pillow_path = os.path.join(python_Lib_site_packages_path, "PIL") installed_pillow_path = os.path.join(python_Lib_site_packages_path, "PIL")
@ -207,4 +208,4 @@ if python_folder_name.lower()[:7]!="python3":
else: else:
raw_input("Cannot detect a site-packages folder in python installation of current python executable "+sys.executable+" so installation cannot continue. Press enter to exit.") raw_input("Cannot detect a site-packages folder in python installation of current python executable "+sys.executable+" so installation cannot continue. Press enter to exit.")
else: else:
raw_input("This installer does not know the correct wheels for python 3 (detected at "+python_folder_path+"). Please run this script with python 2 instead. Please see README.md for manual installation, but download python 3 wheels instead of the example wheels listed in README.md. Press enter to exit.") raw_input("This installer does not know the correct wheels for python 3 (detected at "+python_folder_path+"). Please run this script with python 2 instead. Please see README.md for manual installation, but download and install Python 3 wheels instead of the example wheels listed in README.md. Press enter to exit.")

Loading…
Cancel
Save