From 605d8f057fd32afc304f8183e0c1ec49c9276051 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sun, 6 Mar 2022 00:14:20 -0800 Subject: [PATCH] Fix save loading. https://stackoverflow.com/a/44888113/632035 Pickle can't deal with loading sets (and probably dicts) of objects with custom __hash__ functions that depend on their state because __hash__ can be called before __setstate__. Make the hash function stupider (but still correct) by just relying on the object ID. --- game/theater/frontline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/game/theater/frontline.py b/game/theater/frontline.py index 9c0e1ae7..5374c907 100644 --- a/game/theater/frontline.py +++ b/game/theater/frontline.py @@ -78,7 +78,7 @@ class FrontLine(MissionTarget): return (self.blue_cp, self.red_cp) == (other.blue_cp, other.red_cp) def __hash__(self) -> int: - return hash((self.blue_cp, self.red_cp)) + return hash(id(self)) def _compute_position(self) -> Point: return self.point_from_a(self._position_distance)