From 7e25351dbcf703b73f54a0ba0b5deb789ba94353 Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Wed, 3 Jun 2020 19:33:08 +0200 Subject: [PATCH 01/15] fix editor/god mode --- control.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/control.lua b/control.lua index 8e8f8d0..7e1c9c7 100644 --- a/control.lua +++ b/control.lua @@ -255,7 +255,9 @@ script.on_event(defines.events.on_tick, function(event) game.tick_paused = true game.ticks_to_run = 0 - player.character.active = false + if player.character then + player.character.active = false + end local main = player.gui.center.add{type = "frame", caption = text[1], direction = "vertical"} local topLine = main.add{type = "flow", direction = "horizontal"} From d8a4355457565e199e29162663fd2bd6ed12c896 Mon Sep 17 00:00:00 2001 From: Truman Kilen Date: Tue, 2 Jun 2020 14:02:49 -0500 Subject: [PATCH 02/15] Fix maps saved in editor mode not working --- control.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/control.lua b/control.lua index 8e8f8d0..1ec6ff0 100644 --- a/control.lua +++ b/control.lua @@ -255,7 +255,9 @@ script.on_event(defines.events.on_tick, function(event) game.tick_paused = true game.ticks_to_run = 0 - player.character.active = false + if player.character ~= nil then + player.character.active = false + end local main = player.gui.center.add{type = "frame", caption = text[1], direction = "vertical"} local topLine = main.add{type = "flow", direction = "horizontal"} @@ -286,3 +288,8 @@ script.on_event(defines.events.on_tick, function(event) end end) +function unpause() + game.tick_paused = false +end +script.on_init(unpause) +script.on_load(unpause) From b938e0d3e05529fdb672e9a71dd5b762a3632db8 Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Wed, 3 Jun 2020 21:51:04 +0200 Subject: [PATCH 03/15] removed factoriomaps.com demo as I haven't been able to get in contact with the owner for a good year now --- README.md | 2 -- data.lua | 0 zoom.py | 4 ++-- 3 files changed, 2 insertions(+), 4 deletions(-) create mode 100644 data.lua diff --git a/README.md b/README.md index 11500b5..200795a 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,6 @@ ![image](https://user-images.githubusercontent.com/6313423/46447780-0d723880-c784-11e8-8e6f-2b35d24f25b9.png) This [Factorio](http://www.factorio.com/) mod turns your factory into a timeline! You can view the map locally or upload it to a web server. -Live demo: https://factoriomaps.com/beta/user/L0laapk3/megabase/index.html - Mod portal link: https://mods.factorio.com/mod/L0laapk3_FactorioMaps # How to Install diff --git a/data.lua b/data.lua new file mode 100644 index 0000000..e69de29 diff --git a/zoom.py b/zoom.py index 42b9cdd..0f34de1 100644 --- a/zoom.py +++ b/zoom.py @@ -41,11 +41,11 @@ def printErase(arg): # note that these are all 64 bit libraries since factorio doesnt support 32 bit. if os.name == "nt": - jpeg = TurboJPEG(Path(__file__, "..", "mozjpeg/turbojpeg.dll").as_posix()) + jpeg = TurboJPEG(Path(__file__, "..", "mozjpeg/turbojpeg.dll").resolve().as_posix()) # elif _platform == "darwin": # I'm not actually sure if mac can run linux libraries or not. # jpeg = TurboJPEG("mozjpeg/libturbojpeg.dylib") # If anyone on mac has problems with the line below please make an issue :) else: - jpeg = TurboJPEG(Path(__file__, "..", "mozjpeg/libturbojpeg.so").as_posix()) + jpeg = TurboJPEG(Path(__file__, "..", "mozjpeg/libturbojpeg.so").resolve().as_posix()) def saveCompress(img, path: Path): From 58574801162e119f30f5aefc55649e526caafe9c Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Wed, 3 Jun 2020 22:06:52 +0200 Subject: [PATCH 04/15] added version check --- data.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data.lua b/data.lua index e69de29..4e722bf 100644 --- a/data.lua +++ b/data.lua @@ -0,0 +1,4 @@ +_, _, mainVersion, majorVersion, minorVersion = string.find(mods["base"], "(%d+)%.(%d+)%.(%d+)") +if tonumber(mainVersion) <= 0 and tonumber(majorVersion) <= 18 and tonumber(minorVersion) < 29 then + error("\nThis version of factorioMaps requires factorio 0.18.29 or higher!") +end \ No newline at end of file From d421ed5375b05537a2472c9230c68b0cb64cfa57 Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Wed, 3 Jun 2020 22:10:16 +0200 Subject: [PATCH 05/15] (Hopefully) Fixes #74 --- auto.py | 4 ++-- crop.py | 2 +- ref.py | 2 +- zoom.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/auto.py b/auto.py index 9cf3f0a..4675fdf 100644 --- a/auto.py +++ b/auto.py @@ -11,7 +11,7 @@ from pathlib import Path try: - with Path(__file__, "..", "packages.txt").open("r", encoding="utf-8") as f: + with Path(__file__, "..", "packages.txt").resolve().open("r", encoding="utf-8") as f: pkg_resources.require(f.read().splitlines()) except (DistributionNotFound, VersionConflict) as ex: traceback.print_exc() @@ -169,7 +169,7 @@ def checkUpdate(reverseUpdateTest:bool = False): try: print("checking for updates") latestUpdates = json.loads(urllib.request.urlopen('https://cdn.jsdelivr.net/gh/L0laapk3/FactorioMaps@latest/updates.json', timeout=30).read()) - with Path(__file__, "..", "updates.json").open("r", encoding="utf-8") as f: + with Path(__file__, "..", "updates.json").resolve().open("r", encoding="utf-8") as f: currentUpdates = json.load(f) if reverseUpdateTest: latestUpdates, currentUpdates = currentUpdates, latestUpdates diff --git a/crop.py b/crop.py index 023fc52..b36538c 100644 --- a/crop.py +++ b/crop.py @@ -42,7 +42,7 @@ def crop(outFolder, timestamp, surface, daytime, basePath=None, args: Namespace subname = Path(timestamp, surface, daytime) toppath = Path( - basePath if basePath else Path(__file__, "..", "..", "..", "script-output", "FactorioMaps"), + basePath if basePath else Path(__file__, "..", "..", "..", "script-output", "FactorioMaps").resolve(), outFolder, ) diff --git a/ref.py b/ref.py index f0a24fe..2e8f4c2 100644 --- a/ref.py +++ b/ref.py @@ -107,7 +107,7 @@ def ref( psutil.Process(os.getpid()).nice(psutil.BELOW_NORMAL_PRIORITY_CLASS if os.name == 'nt' else 10) - workFolder = basepath if basepath else Path(__file__, "..", "..", "..", "script-output", "FactorioMaps") + workFolder = basepath if basepath else Path(__file__, "..", "..", "..", "script-output", "FactorioMaps").resolve() topPath = Path(workFolder, outFolder) dataPath = Path(topPath, "mapInfo.json") maxthreads = args.refthreads if args.refthreads else args.maxthreads diff --git a/zoom.py b/zoom.py index 0f34de1..68b3681 100644 --- a/zoom.py +++ b/zoom.py @@ -270,7 +270,7 @@ def zoom( psutil.Process(os.getpid()).nice(psutil.BELOW_NORMAL_PRIORITY_CLASS if os.name == "nt" else 10) - workFolder = basepath if basepath else Path(__file__, "..", "..", "..", "script-output", "FactorioMaps") + workFolder = basepath if basepath else Path(__file__, "..", "..", "..", "script-output", "FactorioMaps").resolve() topPath = Path(workFolder, outFolder) dataPath = Path(topPath, "mapInfo.json") From 5ed313073b515db5ad682d763f9674bfe015b91d Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Wed, 3 Jun 2020 22:19:40 +0200 Subject: [PATCH 06/15] hopefully, FINALLY Closes #57 --- auto.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/auto.py b/auto.py index 4675fdf..bf23bf5 100644 --- a/auto.py +++ b/auto.py @@ -335,6 +335,8 @@ def buildConfig(args: Namespace, tmpDir, basepath): config["path"] = {} config["path"]["write-data"] = tmpDir + config["path"]["script-output"] = str(basepath) + if "graphics" not in config: config["graphics"] = {} config["graphics"]["screenshots-threads-count"] = str(args.screenshotthreads if args.screenshotthreads else args.maxthreads) @@ -344,9 +346,6 @@ def buildConfig(args: Namespace, tmpDir, basepath): configFile.writelines(("; version=3\n", )) config.write(configFile, space_around_delimiters=False) - # TODO: change this when https://forums.factorio.com/viewtopic.php?f=28&t=81221 is implemented - linkDir(Path(tmpDir, "script-output"), basepath) - copy(Path(userFolder, 'player-data.json'), tmpDir) return configPath From 0e9cbce8ad8432d407d303a471242172e8e65538 Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Wed, 3 Jun 2020 22:33:18 +0200 Subject: [PATCH 07/15] Fix #74, part 2 :D --- auto.py | 1 + updateLib.py | 2 +- updates.json | 6 +++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/auto.py b/auto.py index bf23bf5..b04737e 100644 --- a/auto.py +++ b/auto.py @@ -335,6 +335,7 @@ def buildConfig(args: Namespace, tmpDir, basepath): config["path"] = {} config["path"]["write-data"] = tmpDir + print(tmpDir) config["path"]["script-output"] = str(basepath) if "graphics" not in config: diff --git a/updateLib.py b/updateLib.py index 45fd38b..b9a3093 100644 --- a/updateLib.py +++ b/updateLib.py @@ -24,7 +24,7 @@ def update(Force=True): - targetPath = Path(__file__, "..", "web", "lib") + targetPath = Path(__file__, "..", "web", "lib").resolve() if not Force: try: diff --git a/updates.json b/updates.json index 7979607..e9addff 100644 --- a/updates.json +++ b/updates.json @@ -61,5 +61,9 @@ "Day and night snapshots are now completely identical instead of 1 tick apart", "Added option to set the default snapshot when the page loads" ], - "4.0.1": "!Bugfix with default snapshot index" + "4.0.1": "!Bugfix with default snapshot index", + "4.1.0": [ + "Replace symlinks with the new script-output config option, restore linux compatibility", + "Fix for editor/god mode maps" + ] } \ No newline at end of file From a6464bdace555a38d52bd8f5eff9d416ae409dcb Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Wed, 3 Jun 2020 22:40:04 +0200 Subject: [PATCH 08/15] fix for different cwd from current directory --- auto.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auto.py b/auto.py index b04737e..af62d8b 100644 --- a/auto.py +++ b/auto.py @@ -294,7 +294,7 @@ def buildAutorun(args: Namespace, workFolder: Path, outFolder: Path, isFirstSnap def lowerBool(value: bool): return str(value).lower() - with open("autorun.lua", "w", encoding="utf-8") as f: + with Path(__file__, "..", "autorun.lua").resolve().open("autorun.lua", "w", encoding="utf-8") as f: surfaceString = '{"' + '", "'.join(args.surface) + '"}' if args.surface else "nil" autorunString = \ f'''fm.autorun = {{ @@ -601,7 +601,7 @@ def kill(pid, onlyStall=False): time.sleep(0.4) # empty autorun.lua - open("autorun.lua", 'w', encoding="utf-8").close() + Path(__file__, "..", "autorun.lua").resolve().open('w', encoding="utf-8").close() latest = [] with datapath.open('r', encoding="utf-8") as f: From e18cdf0143d78f3341bdd1f02bc4e034a3a5a73e Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Wed, 3 Jun 2020 22:44:28 +0200 Subject: [PATCH 09/15] actually fix different CWD this time --- auto.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/auto.py b/auto.py index af62d8b..300a748 100644 --- a/auto.py +++ b/auto.py @@ -294,7 +294,7 @@ def buildAutorun(args: Namespace, workFolder: Path, outFolder: Path, isFirstSnap def lowerBool(value: bool): return str(value).lower() - with Path(__file__, "..", "autorun.lua").resolve().open("autorun.lua", "w", encoding="utf-8") as f: + with Path(__file__, "..", "autorun.lua").resolve().open("w", encoding="utf-8") as f: surfaceString = '{"' + '", "'.join(args.surface) + '"}' if args.surface else "nil" autorunString = \ f'''fm.autorun = {{ @@ -335,7 +335,6 @@ def buildConfig(args: Namespace, tmpDir, basepath): config["path"] = {} config["path"]["write-data"] = tmpDir - print(tmpDir) config["path"]["script-output"] = str(basepath) if "graphics" not in config: From af892f721025547889ef3cd41121b1a3d1bef344 Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Wed, 3 Jun 2020 22:46:08 +0200 Subject: [PATCH 10/15] updated updates.json --- updates.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/updates.json b/updates.json index e9addff..c91c2ff 100644 --- a/updates.json +++ b/updates.json @@ -64,6 +64,7 @@ "4.0.1": "!Bugfix with default snapshot index", "4.1.0": [ "Replace symlinks with the new script-output config option, restore linux compatibility", - "Fix for editor/god mode maps" + "Fix for editor/god mode maps", + "Fix for when the CWD is different than the script directory" ] } \ No newline at end of file From 0b9743b02d6005179ebc9e64bf092884e60e55e7 Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Sun, 14 Jun 2020 15:15:07 +0200 Subject: [PATCH 11/15] escape all glob patterns except '*'. Fixes #77 --- auto.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/auto.py b/auto.py index 300a748..15ef444 100644 --- a/auto.py +++ b/auto.py @@ -18,6 +18,7 @@ print("\nDependencies not met. Run `pip install -r packages.txt` to install missing dependencies.") sys.exit(1) +import glob import argparse import configparser import datetime @@ -426,8 +427,9 @@ def kill(pid, onlyStall=False): saveGames = OrderedSet() for saveName in saveNames: - globResults = list(saves.glob(saveName)) - globResults += list(saves.glob(f"{saveName}.zip")) + saveNameEscaped = glob.escape(saveName).replace("[*]", "*") + globResults = list(saves.glob(saveNameEscaped)) + globResults += list(saves.glob(f"{saveNameEscaped}.zip")) if not globResults: print(f'Cannot find savefile: "{saveName}"') From 8de3b5ab6b7914590010e3bae2af00f8d1ed9a85 Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Sun, 14 Jun 2020 15:16:12 +0200 Subject: [PATCH 12/15] updated changelog --- updates.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/updates.json b/updates.json index c91c2ff..0dae7f6 100644 --- a/updates.json +++ b/updates.json @@ -65,6 +65,7 @@ "4.1.0": [ "Replace symlinks with the new script-output config option, restore linux compatibility", "Fix for editor/god mode maps", - "Fix for when the CWD is different than the script directory" + "Fix for when the CWD is different than the script directory", + "Bugfixes :)" ] } \ No newline at end of file From 2d82810040fd8f46847e4bc4bbc3f3e90db421c0 Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Sun, 14 Jun 2020 15:17:37 +0200 Subject: [PATCH 13/15] bump version number --- info.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/info.json b/info.json index 40b99c6..f7a1119 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "L0laapk3_FactorioMaps", - "version": "4.0.1", + "version": "4.1.0", "title": "FactorioMaps", "author": "L0laapk3", "contact": "https://github.com/L0laapk3/", From c41b1e49e2b670cb584341a176e268a05a29a4c4 Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Sun, 14 Jun 2020 15:22:36 +0200 Subject: [PATCH 14/15] Partially rollback #75. See comment --- control.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/control.lua b/control.lua index 2eb8f6d..3366ea7 100644 --- a/control.lua +++ b/control.lua @@ -293,4 +293,3 @@ function unpause() game.tick_paused = false end script.on_init(unpause) -script.on_load(unpause) From b219e7e66439c9d02344fa484866c9f1f18a8f11 Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Sun, 14 Jun 2020 15:48:43 +0200 Subject: [PATCH 15/15] bugfix. Might be a race condition on small maps only..? idk --- auto.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/auto.py b/auto.py index 15ef444..c4f3998 100644 --- a/auto.py +++ b/auto.py @@ -702,9 +702,10 @@ def refZoom(): for surfaceName, surfaceStuff in mapStuff["surfaces"].items(): if "chunks" in surfaceStuff: data["maps"][int(mapIndex)]["surfaces"][surfaceName]["chunks"] = surfaceStuff["chunks"] - for linkIndex, link in enumerate(surfaceStuff["links"]): - data["maps"][int(mapIndex)]["surfaces"][surfaceName]["links"][linkIndex]["path"] = link["path"] - data["maps"][int(mapIndex)]["surfaces"][surfaceName]["links"][linkIndex]["zoom"]["min"] = link["zoom"]["min"] + if "links" in surfaceStuff: + for linkIndex, link in enumerate(surfaceStuff["links"]): + data["maps"][int(mapIndex)]["surfaces"][surfaceName]["links"][linkIndex]["path"] = link["path"] + data["maps"][int(mapIndex)]["surfaces"][surfaceName]["links"][linkIndex]["zoom"]["min"] = link["zoom"]["min"] destf.seek(0) json.dump(data, destf) destf.truncate()