Skip to content

Commit

Permalink
Merge pull request #50 from hero-clashes/master
Browse files Browse the repository at this point in the history
compressed save files
  • Loading branch information
MarxMustermann authored Jun 15, 2024
2 parents be20334 + ebcadcc commit a4d0393
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 a4d0393

Please sign in to comment.