Skip to content

Commit

Permalink
compressed save files
Browse files Browse the repository at this point in the history
  • Loading branch information
hero-clashes committed Jun 15, 2024
1 parent 53faea0 commit ebcadcc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/gamestate.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import json
import zlib

import src.canvas
import src.characters
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit ebcadcc

Please sign in to comment.