Skip to content

Commit

Permalink
Game state corrupts when trying to cleanup non existing sims #22
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
TitanNano committed Jan 28, 2020
1 parent 8dd0ee8 commit 0bacd27
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/control_any_sim/services/selection_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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))

Expand Down

0 comments on commit 0bacd27

Please sign in to comment.