Skip to content

Commit

Permalink
Merge pull request #4715 from MistakeNot4892/tweak/savecopy
Browse files Browse the repository at this point in the history
Updating the save replication script to allow targeting specific ckey/map.
  • Loading branch information
out-of-phaze authored Jan 12, 2025
2 parents 299e0b6 + 8c21402 commit 57b0f8d
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tools/ReplicateSaves/replicate_saves.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ def main():
print("Cannot find directory '" + mapdir + "', make sure you are running this script from the root repository directory.")
return

ckey = None
if len(sys.argv) > 2:
ckey = sys.argv[2]
if ckey is not None:
ckey = ckey.lower()

singletargetmap = None
if len(sys.argv) > 3:
singletargetmap = sys.argv[3]
if singletargetmap is not None:
singletargetmap = singletargetmap.lower()

# Work out what maps we actually need to replicate to.
# This should be updated as map directories change, or the script will break.
targetmaps = []
Expand All @@ -40,7 +52,7 @@ def main():
if os.path.isdir(dir):
targetmap = dir.path
targetmap = targetmap.replace(mapdir + os.sep, "")
if targetmap not in ignoremaps and targetmap != mapname:
if (targetmap not in ignoremaps) and (targetmap != mapname) and ((singletargetmap is None) or (singletargetmap == targetmap)):
targetmaps.append(targetmap)

# Make sure we can actually see the save directory.
Expand All @@ -62,6 +74,8 @@ def main():
continue
if match.group(1) != mapname:
continue
if (ckey is not None) and (ckey != root[root.rfind("/")+1:]):
continue
savefile = os.path.join(root, file)
with open(savefile, "r") as loadedsave:
wrote = 0
Expand Down

0 comments on commit 57b0f8d

Please sign in to comment.