Bug fixes and improvements

* Added a separate entry for mods compatibility (saves and mods rarely follow the same upgrade rules anyway)
* Improved mods handling by automatically disabling incompatible mods
* Fixed a RuntimeError caused by changing set size during iteration
This commit is contained in:
LoafyLemon 2023-07-15 23:03:01 +01:00
parent ceb4678b36
commit 76cad4f443
2 changed files with 20 additions and 1 deletions

View File

@ -7,6 +7,8 @@ init -999:
persistent.mods_enabled = _set() persistent.mods_enabled = _set()
mods_list = _dict() mods_list = _dict()
mods_incompatible = _set()
mods_compatible = 1.45 # Hardcoded due to initalization offset
def mods_import(): def mods_import():
global mods_list global mods_list
@ -45,7 +47,16 @@ init -999:
return return
def mods_init(): def mods_init():
for i in persistent.mods_enabled: global mods_incompatible
for i in persistent.mods_enabled.copy():
control, major, *minor = mods_list[i]["GameVer"].split(" ")[0].split(".")
ver = float("{}.{}{}".format(control, major, "".join(minor)))
if ver < mods_compatible:
persistent.mods_enabled.remove(i)
mods_incompatible.add(i)
continue
for j in mods_list[i]["Scripts"]: for j in mods_list[i]["Scripts"]:
name = os.path.splitext(j)[0] name = os.path.splitext(j)[0]
@ -55,6 +66,8 @@ init -999:
if config.developer: if config.developer:
renpy.error(e) renpy.error(e)
persistent.mods_enabled.remove(i) persistent.mods_enabled.remove(i)
mods_incompatible.add(i)
mods_import() mods_import()
mods_init() mods_init()

View File

@ -370,4 +370,10 @@ label before_main_menu():
python: python:
if settings.get("updates") and not prerelease: if settings.get("updates") and not prerelease:
CheckUpdates(onetime=True, autostart=False)() CheckUpdates(onetime=True, autostart=False)()
if mods_incompatible:
$ mods = "\n".join(mods_incompatible)
call modal_popup("Attention!", "The listed mods are incompatible and have been deactivated:\n" + mods, "interface/warning.webp")
return return