Browse Source

fixed first run issues

fixed issues that would occur when generated.yml did not exist yet
master
poikilos 9 years ago
committed by Jacob Gustafson
parent
commit
f409c35a5a
  1. 86
      chunkymap-regen.py

86
chunkymap-regen.py

@ -364,6 +364,8 @@ class MTChunks:
backend_string = None backend_string = None
#region_separators = None #region_separators = None
is_backend_detected = None is_backend_detected = None
chunkymap_players_name = None
chunkymap_players_path = None
def __init__(self): #formerly checkpaths() in global scope def __init__(self): #formerly checkpaths() in global scope
self.is_backend_detected = False self.is_backend_detected = False
@ -528,6 +530,24 @@ class MTChunks:
print("Set website_root to "+self.website_root) print("Set website_root to "+self.website_root)
self.mapvars["chunkymap_data_path"]=os.path.join(self.website_root,"chunkymapdata") self.mapvars["chunkymap_data_path"]=os.path.join(self.website_root,"chunkymapdata")
print("Using chunkymap_data_path '"+self.mapvars["chunkymap_data_path"]+"'")
#if not os.path.isdir(self.mapvars["chunkymap_data_path"]):
# os.mkdir(self.mapvars["chunkymap_data_path"])
htaccess_path = os.path.join(self.mapvars["chunkymap_data_path"],".htaccess")
if not os.path.isdir(self.mapvars["chunkymap_data_path"]):
os.makedirs(self.mapvars["chunkymap_data_path"])
if not os.path.isfile(htaccess_path):
self.deny_http_access(self.mapvars["chunkymap_data_path"])
self.chunkymap_players_name = "players"
self.chunkymap_players_path = os.path.join(self.mapvars["chunkymap_data_path"], self.chunkymap_players_name)
htaccess_path = os.path.join(self.chunkymap_players_path,".htaccess")
if not os.path.isdir(self.chunkymap_players_path):
os.makedirs(self.chunkymap_players_path)
if not os.path.isfile(htaccess_path):
self.deny_http_access(self.chunkymap_players_path)
self.yaml_name = "generated.yml" self.yaml_name = "generated.yml"
self.world_yaml_path = os.path.join(self.mapvars["chunkymap_data_path"], self.yaml_name) self.world_yaml_path = os.path.join(self.mapvars["chunkymap_data_path"], self.yaml_name)
@ -540,6 +560,8 @@ class MTChunks:
self.mapvars["minheight"] = -32 self.mapvars["minheight"] = -32
self.mapvars["pixelspernode"] = 1 self.mapvars["pixelspernode"] = 1
self.saved_mapvars = get_dict_from_conf_file(self.world_yaml_path,":") self.saved_mapvars = get_dict_from_conf_file(self.world_yaml_path,":")
if self.saved_mapvars is None:
self.save_mapvars_if_changed()
#self.mapvars = get_dict_from_conf_file(self.world_yaml_path,":") #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 #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 self.saved_mapvars is not None:
@ -838,14 +860,8 @@ class MTChunks:
def check_players(self): def check_players(self):
# NOT NEEDED: if os.path.isfile(self.minetestmapper_py_path) and os.path.isfile(self.colors_path): # NOT NEEDED: if os.path.isfile(self.minetestmapper_py_path) and os.path.isfile(self.colors_path):
print("PROCESSING PLAYERS") print("PROCESSING PLAYERS")
self.mapvars["chunkymap_data_path"]=os.path.join(self.website_root,"chunkymapdata") #self.mapvars["chunkymap_data_path"]=os.path.join(self.website_root,"chunkymapdata")
chunkymap_players_name = "players" #chunkymap_players_path = os.path.join(self.mapvars["chunkymap_data_path"], chunkymap_players_name)
chunkymap_players_path = os.path.join(self.mapvars["chunkymap_data_path"], chunkymap_players_name)
htaccess_path = os.path.join(chunkymap_players_path,".htaccess")
if not os.path.isdir(chunkymap_players_path):
os.makedirs(chunkymap_players_path)
if not os.path.isfile(htaccess_path):
self.deny_http_access(chunkymap_players_path)
players_path = os.path.join(self.mapvars["world_path"], "players") players_path = os.path.join(self.mapvars["world_path"], "players")
player_count = 0 player_count = 0
@ -880,7 +896,7 @@ class MTChunks:
is_enough_data = True is_enough_data = True
break break
ins.close() ins.close()
player_dest_path = os.path.join(chunkymap_players_path,filename+".yml") player_dest_path = os.path.join(self.chunkymap_players_path,filename+".yml")
player_x = None player_x = None
player_y = None player_y = None
player_z = None player_z = None
@ -1209,26 +1225,29 @@ class MTChunks:
print("") print("")
print ("Removing ALL map data since from WORLD NAME is different (map '"+str(self.mapvars["world_name"])+"' is not '"+str(self.mapvars["world_name"])+"')...") print ("Removing ALL map data since from WORLD NAME is different (map '"+str(self.mapvars["world_name"])+"' is not '"+str(self.mapvars["world_name"])+"')...")
print("") print("")
for dirname, dirnames, filenames in os.walk(self.mapvars["chunkymap_data_path"]): if os.path.isdir(self.mapvars["chunkymap_data_path"]):
for filename in filenames: for dirname, dirnames, filenames in os.walk(self.mapvars["chunkymap_data_path"]):
if filename[0] != ".": for filename in filenames:
file_fullname = os.path.join(self.mapvars["chunkymap_data_path"],filename) if filename[0] != ".":
if self.verbose_enable: file_fullname = os.path.join(self.mapvars["chunkymap_data_path"],filename)
print (" EXAMINING "+filename) if self.verbose_enable:
badstart_string = "chunk" print (" EXAMINING "+filename)
if (len(filename) >= len(badstart_string)) and (filename[:len(badstart_string)]==badstart_string): badstart_string = "chunk"
os.remove(file_fullname) if (len(filename) >= len(badstart_string)) and (filename[:len(badstart_string)]==badstart_string):
elif filename==self.yaml_name: os.remove(file_fullname)
os.remove(file_fullname) elif filename==self.yaml_name:
for dirname, dirnames, filenames in os.walk(os.path.join(self.mapvars["chunkymap_data_path"], "players")): os.remove(file_fullname)
for filename in filenames: players_path = os.path.join(self.mapvars["chunkymap_data_path"], "players")
if filename[0] != ".": if os.path.isdir(players_path):
file_fullname = os.path.join(self.mapvars["chunkymap_data_path"],filename) for dirname, dirnames, filenames in os.walk(players_path):
if self.verbose_enable: for filename in filenames:
print (" EXAMINING "+filename) if filename[0] != ".":
badend_string = ".yml" file_fullname = os.path.join(self.mapvars["chunkymap_data_path"],filename)
if (len(filename) >= len(badend_string)) and (filename[len(filename)-len(badend_string):]==badend_string): if self.verbose_enable:
os.remove(file_fullname) print (" EXAMINING "+filename)
badend_string = ".yml"
if (len(filename) >= len(badend_string)) and (filename[len(filename)-len(badend_string):]==badend_string):
os.remove(file_fullname)
self.mapvars["chunkx_min"]=0 self.mapvars["chunkx_min"]=0
self.mapvars["chunkx_max"]=0 self.mapvars["chunkx_max"]=0
self.mapvars["chunkz_min"]=0 self.mapvars["chunkz_min"]=0
@ -1264,14 +1283,7 @@ class MTChunks:
def check_map_inefficient_squarepattern(self): def check_map_inefficient_squarepattern(self):
if os.path.isfile(self.minetestmapper_py_path) and os.path.isfile(self.colors_path): if os.path.isfile(self.minetestmapper_py_path) and os.path.isfile(self.colors_path):
self.rendered_count = 0 self.rendered_count = 0
if not os.path.isdir(self.mapvars["chunkymap_data_path"]):
os.mkdir(self.mapvars["chunkymap_data_path"])
htaccess_path = os.path.join(self.mapvars["chunkymap_data_path"],".htaccess")
if not os.path.isdir(self.mapvars["chunkymap_data_path"]):
os.makedirs(self.mapvars["chunkymap_data_path"])
if not os.path.isfile(htaccess_path):
self.deny_http_access(self.mapvars["chunkymap_data_path"])
self.mapvars = get_dict_from_conf_file(self.world_yaml_path,":") self.mapvars = get_dict_from_conf_file(self.world_yaml_path,":")
#is_testonly == (self.os_name=="windows") #is_testonly == (self.os_name=="windows")

Loading…
Cancel
Save