Optimizations
* Disabled detection of orphaned scripts for non-devs * Added cache to renpy.list_files to reduce IO overhead (~14s -> ~0.01s per 10k calls) * Fixed wrong module call in weather.
This commit is contained in:
parent
43d18f0de1
commit
2c35c2d5df
@ -59,7 +59,7 @@ init python:
|
|||||||
@weather.setter
|
@weather.setter
|
||||||
def weather(self, value):
|
def weather(self, value):
|
||||||
if value == "random":
|
if value == "random":
|
||||||
value = renpy.python.random.choices(self.weather_types, weights=self.weather_weights)[0]
|
value = renpy.random.choices(self.weather_types, weights=self.weather_weights)[0]
|
||||||
|
|
||||||
if not value in self.weather_types:
|
if not value in self.weather_types:
|
||||||
raise ValueError("Unsupported weather type: '{}'".format(value))
|
raise ValueError("Unsupported weather type: '{}'".format(value))
|
||||||
|
@ -14,22 +14,25 @@ init -1000 python early:
|
|||||||
def get_renderer():
|
def get_renderer():
|
||||||
return "DirectX" if preferences.renderer == "angle2" else "OpenGL"
|
return "DirectX" if preferences.renderer == "angle2" else "OpenGL"
|
||||||
|
|
||||||
def detect_orphaned_rpyc_files():
|
if config.developer:
|
||||||
excluded = ["tl/"]
|
# Debug
|
||||||
|
|
||||||
files = renpy.list_files(common=True)
|
def detect_orphaned_rpyc_files():
|
||||||
compiled = [x for x in files if x.endswith(".rpyc") if not any(x.startswith(i) for i in excluded)]
|
excluded = ["tl/"]
|
||||||
scripts = [x for x in files if x.endswith(".rpy")]
|
|
||||||
orphaned = []
|
|
||||||
|
|
||||||
for i in compiled:
|
files = renpy.list_files(common=True)
|
||||||
if not i[:-1] in scripts:
|
compiled = [x for x in files if x.endswith(".rpyc") if not any(x.startswith(i) for i in excluded)]
|
||||||
orphaned.append(i)
|
scripts = [x for x in files if x.endswith(".rpy")]
|
||||||
|
orphaned = []
|
||||||
|
|
||||||
if orphaned:
|
for i in compiled:
|
||||||
raise Exception("Orphaned compiled scripts detected, please delete them before continuing:\n{}".format(orphaned))
|
if not i[:-1] in scripts:
|
||||||
|
orphaned.append(i)
|
||||||
|
|
||||||
detect_orphaned_rpyc_files()
|
if orphaned:
|
||||||
|
raise Exception("Orphaned compiled scripts detected, please delete them before continuing:\n{}".format(orphaned))
|
||||||
|
|
||||||
|
detect_orphaned_rpyc_files()
|
||||||
|
|
||||||
init python:
|
init python:
|
||||||
config.missing_image_callback = missing_image_func
|
config.missing_image_callback = missing_image_func
|
||||||
|
@ -60,7 +60,7 @@ init python:
|
|||||||
|
|
||||||
config.statement_callbacks.append(crashdefender)
|
config.statement_callbacks.append(crashdefender)
|
||||||
|
|
||||||
init -10 python:
|
init python early:
|
||||||
|
|
||||||
if renpy.windows:
|
if renpy.windows:
|
||||||
# On windows, Renpy does not support backslashes in some of its functions,
|
# On windows, Renpy does not support backslashes in some of its functions,
|
||||||
@ -75,3 +75,19 @@ init -10 python:
|
|||||||
return renpy.loader.loadable(filename)
|
return renpy.loader.loadable(filename)
|
||||||
|
|
||||||
renpy.loadable = _loadable
|
renpy.loadable = _loadable
|
||||||
|
|
||||||
|
# renpy.list_files does not use cached results, let's fix that.
|
||||||
|
|
||||||
|
def _list_files(common=False, quick=True):
|
||||||
|
cache = "_list_files_common_cache" if common else "_list_files_cache"
|
||||||
|
files = getattr(renpy.store, cache, [])
|
||||||
|
|
||||||
|
if not quick or not files:
|
||||||
|
rv = [fn for dir, fn in renpy.loader.listdirfiles(common) if not fn.startswith("saves/")]
|
||||||
|
rv.sort()
|
||||||
|
|
||||||
|
setattr(renpy.store, cache, rv)
|
||||||
|
|
||||||
|
return files
|
||||||
|
|
||||||
|
renpy.list_files = _list_files
|
||||||
|
Loading…
Reference in New Issue
Block a user