-
Notifications
You must be signed in to change notification settings - Fork 0
/
maptools.py
47 lines (39 loc) · 1.65 KB
/
maptools.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import os.path
import configparser
import blowfish_compat
def decompilemap(file_path, encryption_key):
temp_file = file_path + ".tmp"
final_file = os.path.splitext(file_path)[0] + ".proj"
print "Decrypting with the key %s." % encryption_key
blowfish_compat.decrypt(file_path, temp_file, encryption_key)
print "Done."
properties = configparser.ConfigParser(allow_no_value=True)
properties.read(temp_file)
print "Parsing decrypted map file"
if not properties.has_option("Info", "Rdy") or not properties.has_option("Info", "Custom"):
print "Map missing Rdy and/or Custom flags, adding..."
properties.set("Info", "Rdy", "0")
properties.set("Info", "Custom", "-1")
print "Done."
else:
print "Setting Info.Rdy to 0 and Info.Custom to -1..."
properties.set("Info", "Rdy", "0")
properties.set("Info", "Custom", "-1")
print "Done."
with open(temp_file, "w") as mapfile:
properties.write(mapfile)
blowfish_compat.encrypt(temp_file, final_file, encryption_key)
print "Written to %s." % final_file
os.remove(temp_file)
print "Temp file removed"
print "Complete"
def decryptmap(file_path, encryption_key):
final_file = os.path.splitext(file_path)[0] + ".decrypted.map"
print "Decrypting with the key %s" % encryption_key
blowfish_compat.decrypt(file_path, final_file, encryption_key)
print "Done"
def encryptmap(file_path, encryption_key):
final_file = os.path.splitext(file_path)[0] + ".encrypted.map"
print "Encrypting with the key %s" % encryption_key
blowfish_compat.encrypt(file_path, final_file, encryption_key)
print "Done"