eott / preciouspreciouscaffeine

[Done] A mod for the game Factorio, adding coffee products and technology to the game
2 stars 3 forks source link

Desync issues when caffeine level is not 0 for all players when a player joins the game #2

Closed StefanPrintezis closed 5 years ago

StefanPrintezis commented 7 years ago

The caffeine level is not loaded correctly when a new player joins the game. Somehow the caffeine level needs to be shared between al sessions.

I've tried imitating plantations global logic, but no luck. Ontick feels a bit weird.

eott commented 7 years ago

Does the caffeine level load incorrectly for the joining player or for everyone else? I noticed that the speed bonuses without the additional caffeine buff are saved globally, instead of seperately for each player. This might cause this to happen.

Unfortunately I can't really test multiplayer functionality of PPC, since I don't know anyone who plays Factorio and might help me investigate the issues.

StefanPrintezis commented 7 years ago

The player joining has a different caffeine level for the existing ingame player. The joining player thinks that all existing player(s) have caffeine level 0, while the existing player(s) have a 0> caffeine level. This causes the desync 'crash'. You can only join a game if every ingame player has a caffeine level 0.

I've read some threads on the forums about variables getting synced if stored in the global table, but my attempts haven't been succesful as of yet.