def applyEUDDraft(sfname): try: config = readconfig(sfname) mainSection = config["main"] ifname = mainSection["input"] ofname = mainSection["output"] if ifname == ofname: raise RuntimeError("input and output file should be different.") try: if mainSection["debug"]: ep.EPS_SetDebug(True) except KeyError: pass print("---------- Loading plugins... ----------") ep.LoadMap(ifname) pluginList, pluginFuncDict = loadPluginsFromConfig(ep, config) print("--------- Injecting plugins... ---------") payloadMain = createPayloadMain(pluginList, pluginFuncDict) ep.CompressPayload(True) ep.SaveMap(ofname, payloadMain) if isFreezeIssued(): if isPromptIssued(): print("Freeze - prompt enabled ") sys.stdout.flush() os.system("pause") print("[Stage 4/3] Applying freeze mpq modification...") ret = freezeMpq.applyFreezeMpqModification(ep.u2b(ofname), ep.u2b(ofname), isMpaqIssued()) if ret != 0: raise RuntimeError("Error on mpq protection (%d)" % ret) MessageBeep(MB_OK) return True except Exception as e: print("==========================================") MessageBeep(MB_ICONHAND) exc_type, exc_value, exc_traceback = sys.exc_info() excs = traceback.format_exception(exc_type, exc_value, exc_traceback) formatted_excs = [] for i, exc in enumerate(excs): if isEpExc(exc) and not all(isEpExc(e) for e in excs[i + 1:-1]): continue formatted_excs.append(exc) print("[Error] %s" % e, "".join(formatted_excs), file=sys.stderr) if msgbox.isWindows: msgbox.SetForegroundWindow(msgbox.GetConsoleWindow()) return False
def applyEUDDraft(sfname): try: config = readconfig(sfname) mainSection = config['main'] ifname = mainSection['input'] ofname = mainSection['output'] if ifname == ofname: raise RuntimeError('input and output file should be different.') try: if mainSection['debug']: ep.EPS_SetDebug(True) except KeyError: pass print('---------- Loading plugins... ----------') ep.LoadMap(ifname) pluginList, pluginFuncDict = loadPluginsFromConfig(ep, config) print('--------- Injecting plugins... ---------') payloadMain = createPayloadMain(pluginList, pluginFuncDict) ep.CompressPayload(True) ep.SaveMap(ofname, payloadMain) if isFreezeIssued(): print("[Stage 4/3] Applying freeze mpq modification...") if isMpaqIssued(): ret = subprocess.call([mpqFreezePath, ofname, 'mpaq']) else: ret = subprocess.call([mpqFreezePath, ofname]) if ret != 0: raise RuntimeError("Error on mpq protection (%d)" % ret) MessageBeep(MB_OK) except Exception as e: print("==========================================") MessageBeep(MB_ICONHAND) exc_type, exc_value, exc_traceback = sys.exc_info() excs = traceback.format_exception(exc_type, exc_value, exc_traceback) formatted_excs = [] for i, exc in enumerate(excs): if isEpExc(exc) and not all(isEpExc(e) for e in excs[i + 1:-1]): continue formatted_excs.append(exc) print("[Error] %s" % e, ''.join(formatted_excs)) if msgbox.isWindows: msgbox.SetForegroundWindow(msgbox.GetConsoleWindow())
print("Done!\n\n") lasttime = time.time() time.sleep(1) except KeyboardInterrupt: pass # Freeze protection elif sfname[-4:].lower() == '.scx': print(" - Freeze protector mode.") import applyeuddraft import pluginLoader import subprocess pluginLoader.freeze_enabled = True ep.LoadMap(sfname) payloadMain = applyeuddraft.createPayloadMain([], {}) ep.CompressPayload(True) ofname = sfname[:-4] + ' prt.scx' ep.SaveMap(ofname, payloadMain) print("[Stage 4/3] Applying freeze mpq modification...") ret = subprocess.call([applyeuddraft.mpqFreezePath, ofname]) if ret != 0: raise RuntimeError("Error on mpq protection") else: print("Invalid extension %s" % os.path.splitext(sfname)[1]) os.chdir(os.getcwd())
def applyEUDDraft(sfname): try: config = readconfig(sfname) mainSection = config["main"] ifname = mainSection["input"] ofname = mainSection["output"] if ifname == ofname: raise RuntimeError("input and output file should be different.") try: if mainSection["debug"]: ep.EPS_SetDebug(True) except KeyError: pass try: unitname_encoding = mainSection["decodeUnitName"] from eudplib.core.mapdata.tblformat import DecodeUnitNameAs DecodeUnitNameAs(unitname_encoding) except KeyError: pass try: if mainSection["objFieldN"]: from eudplib.eudlib.objpool import SetGlobalPoolFieldN field_n = int(mainSection["objFieldN"]) SetGlobalPoolFieldN(field_n) except KeyError: pass sectorSize = 15 try: if mainSection["sectorSize"]: sectorSize = int(mainSection["sectorSize"]) except KeyError: pass except: sectorSize = None print("---------- Loading plugins... ----------") ep.LoadMap(ifname) pluginList, pluginFuncDict = loadPluginsFromConfig(ep, config) print("--------- Injecting plugins... ---------") payloadMain = createPayloadMain(pluginList, pluginFuncDict) ep.CompressPayload(True) if ep.IsSCDBMap(): if isFreezeIssued(): raise RuntimeError( "Can't use freeze protection on SCDB map!\nDisable freeze by following plugin settings:\n\n[freeze]\nfreeze : 0\n" ) print("SCDB - sectorSize disabled") sectorSize = None elif isFreezeIssued(): # FIXME: Add variable sectorSize support for freeze print("Freeze - sectorSize disabled") sectorSize = None ep.SaveMap(ofname, payloadMain, sectorSize=sectorSize) if isFreezeIssued(): if isPromptIssued(): print("Freeze - prompt enabled ") sys.stdout.flush() os.system("pause") print("[Stage 4/3] Applying freeze mpq modification...") ret = freezeMpq.applyFreezeMpqModification(ep.u2b(ofname), ep.u2b(ofname)) if ret != 0: raise RuntimeError("Error on mpq protection (%d)" % ret) MessageBeep(MB_OK) return True except Exception as e: print("==========================================") MessageBeep(MB_ICONHAND) exc_type, exc_value, exc_traceback = sys.exc_info() excs = traceback.format_exception(exc_type, exc_value, exc_traceback) formatted_excs = [] for i, exc in enumerate(excs): if isEpExc(exc) and not all(isEpExc(e) for e in excs[i + 1:-1]): continue ver = ep.eudplibVersion() plibPath = ( 'File "C:\\Py\\lib\\site-packages\\eudplib-%s-py3.8-win32.egg\\eudplib\\' % ver) exc.replace(plibPath, 'eudplib File"') formatted_excs.append(exc) print("[Error] %s" % e, "".join(formatted_excs), file=sys.stderr) if msgbox.isWindows: msgbox.SetForegroundWindow(msgbox.GetConsoleWindow()) return False