|
@@ -22,6 +22,11 @@ class GameData(object):
|
|
|
self.usergame = usergame
|
|
|
self.warps = {}
|
|
|
self.ports = {}
|
|
|
+ # 10 = 300 bytes
|
|
|
+ self.warp_groups = 10
|
|
|
+ # 3 = 560 bytes
|
|
|
+ # 5 = 930 bytes
|
|
|
+ self.port_groups = 3
|
|
|
|
|
|
def storage_filename(self):
|
|
|
""" return filename
|
|
@@ -46,20 +51,38 @@ class GameData(object):
|
|
|
|
|
|
with jsonlines.open(filename, mode="w", sort_keys=True) as writer:
|
|
|
# for warp, sectors in self.warps.items():
|
|
|
+ w = {"warp": {}}
|
|
|
+
|
|
|
for warp in sorted(self.warps.keys()):
|
|
|
sectors = self.warps[warp]
|
|
|
# log.msg("save:", warp, sectors)
|
|
|
sects = sorted(list(sectors)) # make a list
|
|
|
- w = {"warp": {warp: sects}}
|
|
|
+ w["warp"][warp] = sects
|
|
|
+ if len(w["warp"]) >= self.warp_groups:
|
|
|
+ writer.write(w)
|
|
|
+ w = {"warp": {}}
|
|
|
+ yield
|
|
|
+
|
|
|
# log.msg(w)
|
|
|
+ # writer.write(w)
|
|
|
+ # yield
|
|
|
+
|
|
|
+ if len(w["warp"]) > 1:
|
|
|
writer.write(w)
|
|
|
- yield
|
|
|
+
|
|
|
# for sector, port in self.ports.items():
|
|
|
+ p = {"port": {}}
|
|
|
+
|
|
|
for sector in sorted(self.ports.keys()):
|
|
|
port = self.ports[sector]
|
|
|
- p = {"port": {sector: port}}
|
|
|
+ p["port"][sector] = port
|
|
|
+ if len(p["port"]) >= self.port_groups:
|
|
|
+ writer.write(p)
|
|
|
+ p = {"port": {}}
|
|
|
+ yield
|
|
|
+ if len(p["port"]) > 1:
|
|
|
writer.write(p)
|
|
|
- yield
|
|
|
+
|
|
|
log.msg("Saved {0} {1}/{2}".format(filename, len(self.ports), len(self.warps)))
|
|
|
|
|
|
def load(self):
|