43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
import os
|
|
|
|
|
|
class Map:
|
|
def __init__(self, mappath):
|
|
self.mappath = mappath
|
|
self.checksum = None
|
|
self.mapname = "Unknown map"
|
|
self.load_map(mappath)
|
|
|
|
def load_map(self, mappath):
|
|
if not os.path.exists("maps/"+mappath):
|
|
raise Exception("Map not found: "+mappath)
|
|
|
|
if not mappath.endswith(".gck"):
|
|
raise Exception("Server only supports GCK maps")
|
|
|
|
self.mapname = mappath.split(".gck")[0]
|
|
self.checksum = Map.checksum(mappath)
|
|
|
|
@staticmethod
|
|
def checksum(mappath):
|
|
# TODO
|
|
if mappath == "Three Way Island - Canyons.gck":
|
|
return b"\x9c\x53\xf4\xdd"
|
|
if mappath == "test1.gck":
|
|
return b"\x9f\xb2\x42\xec"
|
|
if mappath == "test.gck":
|
|
return b"\x48\x52\x33\x23"
|
|
if mappath == "test2.gck":
|
|
return b"\xc7\x5f\x61\x1f"
|
|
if mappath == "test3.gck":
|
|
return b"\x59\xbb\xab\x52"
|
|
if mappath == "Testmap.gck":
|
|
return b"\x74\x07\x98\xaf"
|
|
# \x00\x00\x00\x00: [None]
|
|
# \x00\x00\x00\x01: <custom map>
|
|
# \x9c\x53\xf4\xdd: Three Way Island - Canyons
|
|
# \x1e\xe9\x39\xe1: Still Winter
|
|
# \x9f\xb2\x42\xec: testv1
|
|
# \x48\x52\x33\x23: testv2
|
|
return b"\x00\x00\x00\x00"
|