Big Brother Bob's plugin

by Tron842

Bob's radars and big poles can now affect by Big Brothers research. Energy values have been rescaled to account for the new changes as well. Credit to Afforess

Content
2 years ago
0.14 - 1.1
3.20K
Combat

b Multiplayer

6 years ago

When me and my friend tryed to use this in multiplayer i'd said that it wasn't multiplayer save/loader save.

6 years ago

Would it be possible to get the crash log? Without it I can't really see what is happening.

6 years ago

please repair it)) https://pastebin.com/dvjrH1XE

6 years ago
(updated 6 years ago)

That... is interesting. Just so I understand correctly, you are adding this mod to an already existing save file? Does it cause problems for single player as well or does it only show up on multiplayer?

Im not going to lie I am pretty confused by this error atm and won't be able to update it untill the new year. (same with the 0.16 update if big brother gets updated.)

6 years ago

Same error in 0.16, unable to join my local multiplayer server with similar error, it says your event loop is not multiplayer safe.

6 years ago

Ok, this bug is driving me mad, I cannot reproduce it for the life of me. Could you also post your mod list as well as the log. Maby that will give me some more insight into this.

Also, is the error ocuring when you connect to an emptly server or when there was already another player on the server?

6 years ago

The error happens when you try connecting to a multiplayer game in progress - I've only tested locally with joining the game as a second player, but I would assume it's going to happen when trying to connect to a headless server even as the first player to join due to how the client/server code works in Factorio.

The underlying issue causing the bug is that for each player and/or the server, you register and then remove the on_tick handler:

  • Player 1 / Server "joins" the game: control.lua runs and registers the on_tick handler, which runs itself and then removes itself
  • Player 2 joins the game: control.lua runs on their machine and registers the on_tick handler which has already been removed from the server machine, thus causing Factorio to disconnect the player.

The easiest way to fix this is to just not remove the on_tick handler - since you already have the "if not global.scanned_map" line in there, it would be safe to leave it in there, and should be fairly performance friendly (a single if statement is not going to cause much issue).

If you really -really- are concerned about performance, you could also move the entire scan code off to a separate function that you call from your event loop and simply set the function after it's run once into a function that doesn't actually do anything - Lua functions are variables, so they can be changed at runtime; thus when you want to stop doing something you can always just say "nameOfTheFunction = function() end" and it turns the function into a no-op.

I've created this gist to show how that could be done (with a diff between the initial version and the updated version) - https://gist.github.com/legendblade/2da44f5ec652f83780fc384b28961bfb/revisions#diff-2f29ee9c98c28d035046fb40285456da

Hope that helps.

6 years ago

I am embarrassed by missing this. I will update the mod with this fix. Lua isn't a language I code in often, so it is interesting to know that the functions are held as pointers. Thank you for taking the time to work this out and explain it to me.

New response