Open TehFreek opened 7 years ago
And here's a quick bit of code I came up with to read the mods used by a savegame:
#!/usr/bin/python3
import os.path
import sys
import zipfile
import struct
DATADIR = os.path.expanduser('~/.factorio')
savegamename = sys.argv[1]
savegame = os.path.join(DATADIR, 'saves', savegamename + '.zip')
sgfile = zipfile.ZipFile(savegame, 'r')
leveldat = sgfile.open(savegamename + '/level.dat')
leveldat.read(48)
nummods = struct.unpack('<I', leveldat.read(4))[0]
print('{} mods used:'.format(nummods))
for modnum in range(nummods):
namelen = struct.unpack('B', leveldat.read(1))[0]
name = leveldat.read(namelen).decode('ascii')
versionseq = struct.unpack('3B', leveldat.read(3))
print('{} {}.{}.{}'.format(name, *versionseq))
"ascii" is a guess, but I have nothing that proves it wrong here.
I'll think about that, this should go with the modpack feature (#9)
By the way your parsing code didn't work with 0.15 so I went ahead and did some RE on Factorio to make a working one: https://gist.github.com/mickael9/5dbdb926d3a800bc0b9badf0cc1d5a9f . It should handle all maps currently recognized by Factorio
Would be a great feature in my humble opinion.
I want to add to think about the used version in the given save and try to install exactly the ones given.
One thing that would be handy is to have the ability to enable the mods that are used in a specific savegame and disable all others. This way the savegame can be loaded immediately once Factorio is started instead of having to examine the savegame in Factorio to determine the mods used, shut down Factorio, and then use fac-cli to enable the appropriate mods.