From ebcadcced4f0dd08fd68c0d2672554aae2d224f6 Mon Sep 17 00:00:00 2001 From: hero2002 Date: Sun, 16 Jun 2024 01:14:01 +0300 Subject: [PATCH] compressed save files --- src/gamestate.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gamestate.py b/src/gamestate.py index 20c9122f..f41d282d 100644 --- a/src/gamestate.py +++ b/src/gamestate.py @@ -1,5 +1,6 @@ import json +import zlib import src.canvas import src.characters @@ -160,7 +161,8 @@ def save(self): pass with open(f"gamestate/gamestate_{self.gameIndex}", 'wb') as file: - pickle.dump(self, file) + compressed = zlib.compress(pickle.dumps(self),9) + file.write(compressed) try: # register the save @@ -198,7 +200,7 @@ def loadP(self,gameIndex): import pickle with open(f"gamestate/gamestate_{gameIndex}", 'rb') as file: - newSelf = pickle.load(file) + newSelf = pickle.loads(zlib.decompress(file.read())) return newSelf