Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
L0laapk3 committed Dec 18, 2019
2 parents 0fad476 + b493041 commit 98cfdb8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
8 changes: 5 additions & 3 deletions auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ def handleGameLine(line):
raise Exception("Unrecognised output from factorio (maybe your version is outdated?)\n\nOutput from factorio:\n" + line)

if isSteam:
# note: possibility to avoid this: https://www.reddit.com/r/Steam/comments/4rgrxj/where_are_launch_options_saved_for_games/
# requirements for this approach: root?, need to figure out steam userid, parse the file format, ensure no conflicts between instances. overall probably not worth it.
print("WARNING: Running in limited support mode trough steam. Consider using standalone factorio instead.\n\t If you have any default arguments set in steam for factorio, delete them and restart the script.\n\t Please alt tab to steam and confirm the steam 'start game with arguments' popup.\n\t (Yes, you'll have to click this every time the game starts for the steam version)")
attrs = ('pid', 'name', 'create_time')

Expand Down Expand Up @@ -450,7 +452,7 @@ def changeModlist(newState):
else:
chunkCache = "{}"

with open("autorun.lua", "w") as f:
with open("autorun.lua", "w", encoding="utf-8") as f:
surfaceString = '{"' + '", "'.join(kwargs["surface"]) + '"}' if len(kwargs["surface"]) > 0 else "nil"
autorunString = (f'fm.autorun = {{\n'
f'HD = {str(kwargs["hd"] == True).lower()},\n'
Expand All @@ -465,7 +467,7 @@ def changeModlist(newState):
f'date = "{datetime.datetime.strptime(kwargs["date"], "%d/%m/%y").strftime("%d/%m/%y")}",\n'
f'surfaces = {surfaceString},\n'
f'name = "{foldername + "/"}",\n'
f'mapInfo = {mapInfoLua},\n'
f'mapInfo = {mapInfoLua.encode("utf-8").decode("unicode-escape")},\n'
f'chunkCache = {chunkCache},\n'
f'}}')
f.write(autorunString)
Expand Down Expand Up @@ -643,7 +645,7 @@ def refZoom():

if os.path.isfile(os.path.join(workfolder, "mapInfo.out.json")):
print("generating mapInfo.json")
with open(os.path.join(workfolder, "mapInfo.json"), 'r+', encoding='utf-8') as destf, open(os.path.join(workfolder, "mapInfo.out.json"), "r") as srcf:
with open(os.path.join(workfolder, "mapInfo.json"), 'r+', encoding='utf-8') as destf, open(os.path.join(workfolder, "mapInfo.out.json"), "r", encoding='utf-8') as srcf:
data = json.load(destf)
for mapIndex, mapStuff in json.load(srcf)["maps"].items():
for surfaceName, surfaceStuff in mapStuff["surfaces"].items():
Expand Down
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "L0laapk3_FactorioMaps",
"version": "3.5.2",
"version": "3.5.3",
"title": "FactorioMaps",
"author": "L0laapk3",
"contact": "https://github.com/L0laapk3/",
Expand Down
8 changes: 5 additions & 3 deletions ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ def ref(*args, **kwargs):

pool = mp.Pool(processes=maxthreads)

with open(datapath, "r") as f:
with open(datapath, "r", encoding="utf-8") as f:
data = json.load(f)
if os.path.isfile(datapath[:-5] + ".out.json"):
with open(datapath[:-5] + ".out.json", "r") as f:
with open(datapath[:-5] + ".out.json", "r", encoding="utf-8") as f:
outdata = json.load(f)
else:
outdata = {}
Expand Down Expand Up @@ -367,6 +367,8 @@ def readCropList(path, combinePrevious):
for surfaceName, daytimeImageIndex in allImageIndex.items():
indexList = []
daytime = "night" if "night" in daytimeImageIndex and data["maps"][new]["surfaces"][surfaceName] and str(data["maps"][new]["surfaces"][surfaceName]["night"]) else "day"
if daytime not in daytimeImageIndex: # this is true if nothing changed
continue
surfaceImageIndex = daytimeImageIndex[daytime]
for y, xList in surfaceImageIndex.items():
string = getBase64(y, False)
Expand Down Expand Up @@ -394,7 +396,7 @@ def readCropList(path, combinePrevious):

if changed:
if kwargs["verbose"]: print("writing mapInfo.out.json")
with open(datapath[:-5] + ".out.json", "w+") as f:
with open(datapath[:-5] + ".out.json", "w+", encoding="utf-8") as f:
json.dump(outdata, f)

if kwargs["verbose"]: print("deleting empty folders")
Expand Down
3 changes: 2 additions & 1 deletion updates.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
"3.4.0": ["Separated map tags to surface and snapshot level", "Thumbnail generation of the map"],
"3.5.0": ["!Added API for integration with i.a. Factorissimo", "Better dependency management", "Several bugfixes"],
"3.5.1": "Removed dependency on package that isnt being updated anymore.",
"3.5.2": "Added support for unicode characters"
"3.5.2": "Added support for unicode characters",
"3.5.3": "Bugfixes"
}
4 changes: 3 additions & 1 deletion zoom.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def zoom(*args, **kwargs):
#print(basepath)


with open(datapath, "r") as f:
with open(datapath, "r", encoding="utf-8") as f:
data = json.load(f)
for mapIndex, map in enumerate(data["maps"]):
if len(args) <= 1 or map["path"] == args[1]:
Expand Down Expand Up @@ -294,6 +294,8 @@ def zoom(*args, **kwargs):
maxY = max(maxY, y)
allBigChunks[(x >> maxzoom - minzoom, y >> maxzoom - minzoom)] = True

if len(allBigChunks) <= 0:
continue

pathList = []
for otherMapIndex in range(mapIndex, -1, -1):
Expand Down

0 comments on commit 98cfdb8

Please sign in to comment.