From 0bacd27e84677b30d5d34c2ec869e13a42ac749f Mon Sep 17 00:00:00 2001 From: Jovan Gerodetti Date: Mon, 27 Jan 2020 21:05:13 +0100 Subject: [PATCH] Game state corrupts when trying to cleanup non existing sims #22 If a game is loaded with a non existing sim_info_id in the cache it sometimes will throw an exception when trying to clean up said sim. --- src/control_any_sim/services/selection_group.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/control_any_sim/services/selection_group.py b/src/control_any_sim/services/selection_group.py index a900ec9..e4e82ac 100644 --- a/src/control_any_sim/services/selection_group.py +++ b/src/control_any_sim/services/selection_group.py @@ -147,6 +147,7 @@ def setup_zone(self): Logger.log(traceback.format_exc()) self.client.selectable_sims.add_watcher(self, self.update_selectable_sims) + self.update_selectable_sims() self.zone_is_setup = True def is_selectable(self, sim_id): @@ -196,8 +197,13 @@ def cleanup_sims(self): for sim_info_id in self.selectable_sims: sim_info = services.sim_info_manager().get(sim_info_id) + if sim_info is None: + Logger.log("sim with id {} does not exist and shouldn't apear here" + .format(sim_info_id)) + continue + if sim_info.household_id == self.household_id: - return + continue Logger.log("{} is not in household, removing to avoid teardown issues".format(sim_info))