Merge pull request #46 from VE-FORBRYDERNE/wi-patch

Fix a bug where WI entries sometimes can't be deleted if the current story was loaded from a save
This commit is contained in:
henk717 2021-12-20 04:31:32 +01:00 committed by GitHub
commit 8ee250e422
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 0 deletions

View File

@ -3488,6 +3488,12 @@ def loadRequest(loadpath, filename=None):
for uid in vars.wifolders_l + [None]:
vars.worldinfo.append({"key": "", "keysecondary": "", "content": "", "comment": "", "folder": uid, "num": None, "init": False, "selective": False, "constant": False, "uid": None})
while(True):
uid = int.from_bytes(os.urandom(4), "little", signed=True)
if(uid not in vars.worldinfo_u):
break
vars.worldinfo_u[uid] = vars.worldinfo[-1]
vars.worldinfo[-1]["uid"] = uid
stablesortwi()
vars.worldinfo_i = [wi for wi in vars.worldinfo if wi["init"]]
@ -3677,6 +3683,12 @@ def importgame():
for uid in vars.wifolders_l + [None]:
vars.worldinfo.append({"key": "", "keysecondary": "", "content": "", "comment": "", "folder": uid, "num": None, "init": False, "selective": False, "constant": False, "uid": None})
while(True):
uid = int.from_bytes(os.urandom(4), "little", signed=True)
if(uid not in vars.worldinfo_u):
break
vars.worldinfo_u[uid] = vars.worldinfo[-1]
vars.worldinfo[-1]["uid"] = uid
stablesortwi()
vars.worldinfo_i = [wi for wi in vars.worldinfo if wi["init"]]
@ -3748,6 +3760,12 @@ def importAidgRequest(id):
for uid in vars.wifolders_l + [None]:
vars.worldinfo.append({"key": "", "keysecondary": "", "content": "", "comment": "", "folder": uid, "num": None, "init": False, "selective": False, "constant": False, "uid": None})
while(True):
uid = int.from_bytes(os.urandom(4), "little", signed=True)
if(uid not in vars.worldinfo_u):
break
vars.worldinfo_u[uid] = vars.worldinfo[-1]
vars.worldinfo[-1]["uid"] = uid
stablesortwi()
vars.worldinfo_i = [wi for wi in vars.worldinfo if wi["init"]]
@ -3797,6 +3815,14 @@ def wiimportrequest():
vars.worldinfo_u[uid] = vars.worldinfo[-1]
vars.worldinfo[-1]["uid"] = uid
num += 1
for uid in [None]:
vars.worldinfo.append({"key": "", "keysecondary": "", "content": "", "comment": "", "folder": uid, "num": None, "init": False, "selective": False, "constant": False, "uid": None})
while(True):
uid = int.from_bytes(os.urandom(4), "little", signed=True)
if(uid not in vars.worldinfo_u):
break
vars.worldinfo_u[uid] = vars.worldinfo[-1]
vars.worldinfo[-1]["uid"] = uid
print("{0}".format(vars.worldinfo[0]))