Browse Source

iterates without delay when appropriate

see README.md for details
master
poikilos 9 years ago
committed by Jacob Gustafson
parent
commit
5a9ec468d8
  1. 2
      README.md
  2. 2
      chunkymap erase png files in www minetest chunkymapdata.bat
  3. 20
      chunkymap-regen.py

2
README.md

@ -33,7 +33,7 @@ This program comes without any warranty, to the extent permitted by applicable l
refresh_map_enable:False refresh_map_enable:False
#rerenders chunks that were rendered in this run: #rerenders chunks that were rendered in this run:
recheck_rendered:True recheck_rendered:True
#where 1 is number of seconds: #where 1 is number of seconds (only delays first iteration--further iterations continue until refreshing player is needed):
refresh_map_seconds:1 refresh_map_seconds:1
#where 1 is number of seconds: #where 1 is number of seconds:
refresh_players_seconds:1 refresh_players_seconds:1

2
chunkymap erase png files in www minetest chunkymapdata.bat

@ -0,0 +1,2 @@
SET CHUNKYMAPDATA_PATH=C:\wamp\www\chunkymapdata
del "%CHUNKYMAPDATA_PATH%\*.png"

20
chunkymap-regen.py

@ -357,8 +357,8 @@ class MTChunks:
self.website_root="/var/www/html/minetest" self.website_root="/var/www/html/minetest"
self.world_name = "FCAGameAWorld" self.world_name = "FCAGameAWorld"
self.os_name="linux" self.os_name="linux"
self.refresh_map_seconds = 1 #does one chunk at a time so as not to interrupt player updates too often self.refresh_map_seconds = 30 #does one chunk at a time so as not to interrupt player updates too often
self.refresh_players_seconds = 1 self.refresh_players_seconds = 5
self.chunk_yaml_name_opener_string = "chunk_" self.chunk_yaml_name_opener_string = "chunk_"
self.chunk_yaml_name_dotext_string = ".yml" self.chunk_yaml_name_dotext_string = ".yml"
@ -1257,6 +1257,7 @@ class MTChunks:
#self.last_run_second = best_timer() #self.last_run_second = best_timer()
self.loop_enable = True self.loop_enable = True
self.verbose_enable = False self.verbose_enable = False
is_first_iteration = True
while self.loop_enable: while self.loop_enable:
before_second = best_timer() before_second = best_timer()
run_wait_seconds = self.refresh_map_seconds run_wait_seconds = self.refresh_map_seconds
@ -1277,23 +1278,30 @@ class MTChunks:
else: else:
print("player update is not enabled") print("player update is not enabled")
if self.refresh_map_enable: if self.refresh_map_enable:
if (self.last_map_refresh_second is None) or (best_timer()-self.last_map_refresh_second > self.refresh_map_seconds): is_first_run = True
map_render_latency = 0.3
if (not is_first_iteration) or (self.last_map_refresh_second is None) or (best_timer()-self.last_map_refresh_second > self.refresh_map_seconds):
while is_first_run or ( ((best_timer()+map_render_latency)-self.last_players_refresh_second) < self.refresh_players_seconds ):
is_first_run = False
is_first_iteration = self.todo_index<0
#if (self.last_map_refresh_second is None) or (best_timer()-self.last_map_refresh_second > self.refresh_map_seconds):
#if self.last_map_refresh_second is not None: #if self.last_map_refresh_second is not None:
#print ("waited "+str(best_timer()-self.last_map_refresh_second)+"s for map update") #print ("waited "+str(best_timer()-self.last_map_refresh_second)+"s for map update")
self.last_map_refresh_second = best_timer() self.last_map_refresh_second = best_timer()
self.check_map_pseudorecursion_iterate() self.check_map_pseudorecursion_iterate()
map_render_latency = best_timer() - self.last_map_refresh_second
#self.check_map_inefficient_squarepattern() #self.check_map_inefficient_squarepattern()
else: else:
print("waiting before doing map update") print("waiting before doing map update")
else: else:
print("map update is not enabled") print("map update is not enabled")
else:
self.verbose_enable = True
run_wait_seconds -= (best_timer()-before_second) run_wait_seconds -= (best_timer()-before_second)
if (int(float(run_wait_seconds)+.5)>0.0): if (float(run_wait_seconds)>0.0):
print ("sleeping for "+str(run_wait_seconds)+"s") print ("sleeping for "+str(run_wait_seconds)+"s")
time.sleep(run_wait_seconds) time.sleep(run_wait_seconds)
self.run_count += 1 self.run_count += 1
else:
self.verbose_enable = True
def run(self): def run(self):
if self.refresh_players_enable: if self.refresh_players_enable:

Loading…
Cancel
Save