2019-01-23 10:28:23 +01:00
|
|
|
import os
|
|
|
|
|
|
|
|
|
2019-01-22 01:30:42 +01:00
|
|
|
class Map:
|
2019-01-23 10:28:23 +01:00
|
|
|
def __init__(self, mappath):
|
|
|
|
self.mappath = mappath
|
2019-01-22 01:30:42 +01:00
|
|
|
self.checksum = None
|
2019-01-23 10:28:23 +01:00
|
|
|
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")
|
2019-01-22 01:30:42 +01:00
|
|
|
|
2019-01-23 10:28:23 +01:00
|
|
|
self.mapname = mappath.split(".gck")[0]
|
|
|
|
self.checksum = Map.checksum(mappath)
|
2019-01-22 01:30:42 +01:00
|
|
|
|
|
|
|
@staticmethod
|
2019-02-19 01:01:31 +01:00
|
|
|
def checksum(mappath):
|
2019-01-23 10:28:23 +01:00
|
|
|
# TODO
|
2019-02-19 01:01:31 +01:00
|
|
|
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"
|
2019-02-28 04:01:03 +01:00
|
|
|
if mappath == "test2.gck":
|
|
|
|
return b"\xc7\x5f\x61\x1f"
|
|
|
|
if mappath == "test3.gck":
|
|
|
|
return b"\x59\xbb\xab\x52"
|
2019-03-05 03:58:01 +01:00
|
|
|
if mappath == "Testmap.gck":
|
|
|
|
return b"\x74\x07\x98\xaf"
|
2019-02-19 01:01:31 +01:00
|
|
|
# \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"
|