From 5a9ec468d8cc2a3001762f44dc1dba5ad80acf32 Mon Sep 17 00:00:00 2001 From: poikilos <7557867+poikilos@users.noreply.github.com> Date: Wed, 2 Mar 2016 09:14:10 -0500 Subject: [PATCH] iterates without delay when appropriate see README.md for details --- README.md | 2 +- ...ng files in www minetest chunkymapdata.bat | 2 ++ chunkymap-regen.py | 34 ++++++++++++------- 3 files changed, 24 insertions(+), 14 deletions(-) create mode 100644 chunkymap erase png files in www minetest chunkymapdata.bat diff --git a/README.md b/README.md index 188387f..7b910ab 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ This program comes without any warranty, to the extent permitted by applicable l refresh_map_enable:False #rerenders chunks that were rendered in this run: 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 #where 1 is number of seconds: refresh_players_seconds:1 diff --git a/chunkymap erase png files in www minetest chunkymapdata.bat b/chunkymap erase png files in www minetest chunkymapdata.bat new file mode 100644 index 0000000..fe8d0e7 --- /dev/null +++ b/chunkymap erase png files in www minetest chunkymapdata.bat @@ -0,0 +1,2 @@ +SET CHUNKYMAPDATA_PATH=C:\wamp\www\chunkymapdata +del "%CHUNKYMAPDATA_PATH%\*.png" \ No newline at end of file diff --git a/chunkymap-regen.py b/chunkymap-regen.py index 20ba2ce..47ed671 100644 --- a/chunkymap-regen.py +++ b/chunkymap-regen.py @@ -357,8 +357,8 @@ class MTChunks: self.website_root="/var/www/html/minetest" self.world_name = "FCAGameAWorld" 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_players_seconds = 1 + self.refresh_map_seconds = 30 #does one chunk at a time so as not to interrupt player updates too often + self.refresh_players_seconds = 5 self.chunk_yaml_name_opener_string = "chunk_" self.chunk_yaml_name_dotext_string = ".yml" @@ -1257,6 +1257,7 @@ class MTChunks: #self.last_run_second = best_timer() self.loop_enable = True self.verbose_enable = False + is_first_iteration = True while self.loop_enable: before_second = best_timer() run_wait_seconds = self.refresh_map_seconds @@ -1277,23 +1278,30 @@ class MTChunks: else: print("player update is not enabled") 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): - #if self.last_map_refresh_second is not None: - #print ("waited "+str(best_timer()-self.last_map_refresh_second)+"s for map update") - self.last_map_refresh_second = best_timer() - self.check_map_pseudorecursion_iterate() - #self.check_map_inefficient_squarepattern() + 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: + #print ("waited "+str(best_timer()-self.last_map_refresh_second)+"s for map update") + self.last_map_refresh_second = best_timer() + self.check_map_pseudorecursion_iterate() + map_render_latency = best_timer() - self.last_map_refresh_second + #self.check_map_inefficient_squarepattern() else: print("waiting before doing map update") else: print("map update is not enabled") + run_wait_seconds -= (best_timer()-before_second) + if (float(run_wait_seconds)>0.0): + print ("sleeping for "+str(run_wait_seconds)+"s") + time.sleep(run_wait_seconds) + self.run_count += 1 else: self.verbose_enable = True - run_wait_seconds -= (best_timer()-before_second) - if (int(float(run_wait_seconds)+.5)>0.0): - print ("sleeping for "+str(run_wait_seconds)+"s") - time.sleep(run_wait_seconds) - self.run_count += 1 def run(self): if self.refresh_players_enable: