Thank you, this seems to work! The force of entities was even updated when I changed to another force while I was in a sandbox.
A minor thing: I inspected your mod's data with gvv and noticed that you keep data of forces after the last player has changed to another force. That shouldn't do any actual damage, but will bloat saved games with obsolete data, so cleaning up may still be a good idea.
In Autodrive and GCKI, I've added support for BPS by turning off GUI and shortcuts of players who change to one of your forces. As players are expected to return from the sandbox, the change is only temporarily, so I add the player to global.force_data[old_force_name].suspended_players
.
When there is no player left at the old force, I disable the handlers for GUI and shortcut events unless next(force.connected_players)
is true for any of the other forces stored in global.force_data
. I also remove the force_data stored for forces where both not next(force.players)
and not (force_data.suspended_players and next(force_data.suspended_players))
are true. The force data will be rebuilt when needed, i.e. if a player joins the game or changes to another force.