[0.18.27] [Modding] Inconsistent Global Table Across Saves

Bugs that are actually features.
Post Reply
User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 253
Joined: Fri Jun 20, 2014 11:42 am
Contact:

[0.18.27] [Modding] Inconsistent Global Table Across Saves

Post by DedlySpyder »

So, to preface, I'm not even sure this is a bug, but I can't track down what is happening.

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:
  1. Start with the _pre saves
  2. Enter the vehicle (old radar entity)
  3. Click "Control" on the avatar
  4. Save the game
  5. Load that save
  6. The on_load & 1st tick events will show the loss in entity reference
  7. Disconnect from the avatar (top left)
  8. 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)
Player's Save Files (too big to upload to the forums)
  • 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.
Attachments
avatars_issue_control_post.zip
my fresh save, but where the issue would occur (but it doesn't happen)
(1.27 MiB) Downloaded 65 times
avatars_issue_control_pre.zip
my fresh save
(1.27 MiB) Downloaded 65 times
Avatars_0.5.7.zip
Mod with debug log statements
(1.04 MiB) Downloaded 65 times

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.18.27] [Modding] Inconsistent Global Table Across Saves

Post by Rseding91 »

You aren't handling on_player_left_game and on_player_joined_game.

https://lua-api.factorio.com/latest/eve ... _left_game
https://lua-api.factorio.com/latest/eve ... oined_game

The save you linked that "breaks" was loaded in multiplayer and so on loading it acts like a player disconnects and then joins in.
If you want to get ahold of me I'm almost always on Discord.

User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 253
Joined: Fri Jun 20, 2014 11:42 am
Contact:

Re: [0.18.27] [Modding] Inconsistent Global Table Across Saves

Post by DedlySpyder »

Oooooooh, ok that makes sense then. Thanks!

User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 253
Joined: Fri Jun 20, 2014 11:42 am
Contact:

Re: [0.18.27] [Modding] Inconsistent Global Table Across Saves

Post by DedlySpyder »

So, I was handling on_player_left_game. I was kicking the player out of controlling the avatar when that happens.

But, that was never firing in this single player game, I'm only getting on_player_joined_game. Which I can handle repairing the reference there easily enough, just making sure that is as expected.

Post Reply

Return to “Not a bug”