From 7b25aacf8c33a5cb8fe61752558ac7854423ae3c Mon Sep 17 00:00:00 2001 From: Fierelier Date: Fri, 13 May 2022 11:43:24 +0200 Subject: [PATCH] Use deep copies instead of copies --- offline-minecraft-launcher.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/offline-minecraft-launcher.py b/offline-minecraft-launcher.py index 645b643..b4f51fc 100644 --- a/offline-minecraft-launcher.py +++ b/offline-minecraft-launcher.py @@ -24,6 +24,7 @@ import hashlib import platform import urllib.request import re +import copy class coloramaFallback: class Fore: @@ -121,7 +122,7 @@ def findArgument(args,searchFor): def findInChain(versionsPath,version,path): versionPath = p(versionsPath,version) clientJson = readJsonFile(p(versionPath,version + ".json")) - curPath = clientJson.copy() + curPath = copy.deepcopy(clientJson) success = True for dir in path: if dir in curPath: @@ -139,7 +140,7 @@ def findInChainDeepest(versionsPath,version,path): while True: versionPath = p(versionsPath,version) clientJson = readJsonFile(p(versionPath,version + ".json")) - curPath = clientJson.copy() + curPath = copy.deepcopy(clientJson) for dir in path: if dir in curPath: curPath = curPath[dir] @@ -240,7 +241,7 @@ def processVersion(versionsPath,libraryPath,nativePath,version): if "downloads" in library: # not dumb if "classifiers" in library["downloads"]: # classifiers (usually for natives, their sources and their documentation) for classifier in library["downloads"]["classifiers"]: - l = lBase.copy() + l = copy.deepcopy(lBase) native = library["downloads"]["classifiers"][classifier] if classifier.startswith("natives-"): l["type"] = "native" @@ -255,7 +256,7 @@ def processVersion(versionsPath,libraryPath,nativePath,version): libraries.append(l) if "artifact" in library["downloads"]: # artifact (usually for libraries) - l = lBase.copy() + l = copy.deepcopy(lBase) if "path" in library["downloads"]["artifact"]: l["filePathOS"] = p(libraryPath,library["downloads"]["artifact"]["path"].replace("/",os.path.sep)) @@ -266,7 +267,7 @@ def processVersion(versionsPath,libraryPath,nativePath,version): else: # dumb lBase["dumb"] = True if "natives" in library: # natives - lBaseTwo = lBase.copy() + lBaseTwo = copy.deepcopy(lBase) lBaseTwo["type"] = "native" if not "url" in library: lBaseTwo["url"] = "https://libraries.minecraft.net" @@ -277,7 +278,7 @@ def processVersion(versionsPath,libraryPath,nativePath,version): lBaseTwo["url"] = lBaseTwo["url"] + "/" + lBaseTwo["filePath"] for native in library["natives"]: - l = lBaseTwo.copy() + l = copy.deepcopy(lBaseTwo) l["nativeOS"] = native native = "natives-" + native l["filePath"] = l["filePath"][:-4] + "-" + native + ".jar" @@ -285,7 +286,7 @@ def processVersion(versionsPath,libraryPath,nativePath,version): l["filePathOS"] = p(nativePath,l["filePath"].replace("/",os.path.sep)) libraries.append(l) else: # libraries - l = lBase.copy() + l = copy.deepcopy(lBase) if not "url" in library: l["url"] = "https://libraries.minecraft.net" else: