I have 2 saves for my mod Avatars, one is a fresh save and one was a heavily modded save from a player who ran into some issues with a global table reference to an entity (a character copy entity called an avatar). I assumed some mod invalidated the entity reference long before, so I made a command to repair the global table manually and told them to run that.
The problem that is happening is that the player and myself can still cause the entity reference to become invalid, consistently. But, if I do the exact same steps on a fresh save, I cannot. Both are run with just Avatars enabled, on the same mod version and same Factorio version. My mod doesn't have an on_load handler.
I added 2 log statements to the Factorio current log, one on_load and one on just the first tick, to check if the entity references are valid. On_load the entity is valid and I can read the unit_number from it, but on the first tick for the player's save it is showing as invalid. On my fresh save they are both showing as valid.
Quick steps to reproduce: Load both the _post saves and see that the validity of the avatars in the log is lost on the player's save.
The long way around:
- Start with the _pre saves
- Enter the vehicle (old radar entity)
- Click "Control" on the avatar
- Save the game
- Load that save
- The on_load & 1st tick events will show the loss in entity reference
- Disconnect from the avatar (top left)
- Leave and re-enter the vehicle will also show in the avatar can be found (it won't show in the list if it is an invalid reference)
- t90_pre - player's save
- t90_post - player's save, where the entity reference becomes invalid (but only on the first tick)
I have no idea how common of an issue this is, (I assume it's something down to mod compatibility somewhere, so probably not very common), and there is an easy work around for this (don't save while swapped with an avatar, and if you do, run the manual command to fix the global table), but I figured to post it on the off chance it is something with Factorio itself.