BananaPuncher714 / LethalQuantities

A lethal company mod
MIT License
5 stars 1 forks source link

Multiplayer enemy desync #55

Closed Index154 closed 7 months ago

Index154 commented 8 months ago

Edit: I just noticed the new update to the mod while I was typing this lol nice timing - I've been testing on 1.1.12. Maybe it's already fixed now?

A while ago I was having issues in multiplayer where some enemies were spawned for me (host) but not for the other players (using the same modpack). After first experiencing the issue we turned off LethalQuantities and that seemed to fix it. I'm not yet sure why only some enemies are affected and I haven't played around with the mod's configs yet but I have found some other details regarding the issue:

To test this I've been opening two game clients simultaneously, hosting a LAN lobby with one and joining with the other. Then I would go to a moon and try to find a few enemies in both games using the FreeCammer mod while looking at the live logs. After a lot of turning off/on various mods and trying to find nonexistent enemies I think I discovered that it only happens when both LethalQuantities and AtlasAbyss are installed.

The main reason why I am so sure that this is the case is that while the issue was present there would be error messages in the client's log when the host's game spawns in enemies (at the step where the enemies are chosen and not when they are actually spawned from a vent). Here is an example screenshot showing the logs of both games in one instance: image (Left side is the host while right is the client) These errors would always appear until I turned off AtlasAbyss! Here is the error message in text form:

[Error  : Unity Log] ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Stack trace:
System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <787acc3c9a4c471ba7d971300105af24>:0)
EnemyVent.SyncVentSpawnTimeClientRpc (System.Int32 time, System.Int32 enemyIndex) (at <af9b1eec498a45aebd42601d6ab85015>:0)
EnemyVent.rpc_handler_3841281693 (Unity.Netcode.NetworkBehaviour target, Unity.Netcode.FastBufferReader reader, Unity.Netcode.RpcParams rpcParams) (at <af9b1eec498a45aebd42601d6ab85015>:0)
Unity.Netcode.RpcMessageHelpers.Handle (Unity.Netcode.NetworkContext& context, Unity.Netcode.RpcMetadata& metadata, Unity.Netcode.FastBufferReader& payload, Unity.Netcode.RpcParams& rpcParams) (at <895801699cfc4b4ab52267f31e2a4998>:0)
Rethrow as Exception: Unhandled RPC exception!
UnityEngine.Debug:LogException(Exception)
Unity.Netcode.RpcMessageHelpers:Handle(NetworkContext&, RpcMetadata&, FastBufferReader&, RpcParams&)
Unity.Netcode.ClientRpcMessage:Handle(NetworkContext&)
Unity.Netcode.NetworkMessageManager:ReceiveMessage(FastBufferReader, NetworkContext&, NetworkMessageManager)
Unity.Netcode.NetworkMessageManager:HandleMessage(NetworkMessageHeader&, FastBufferReader, UInt64, Single, Int32)
Unity.Netcode.NetworkMessageManager:ProcessIncomingMessageQueue()
Unity.Netcode.NetworkManager:NetworkUpdate(NetworkUpdateStage)
Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage(NetworkUpdateStage)
Unity.Netcode.<>c:<CreateLoopSystem>b__0_0()

Side note: While testing this I actually also encountered the shotgunless Nutcracker issue as mentioned in #48. Pretty much every Nutcracker I saw on Rend or Dine would be without a shotgun in the host's game (and would not appear at all in the client's game). The shotgun would float next to the vent they spawned from. image They would be accompanied by lots and lots of errors on the host's side but unfortunately I didn't take note of the exact message.

I haven't actually tried testing it with only LethalQuantities and AtlasAbyss so here's my modpack profile code in case it's not easy to reproduce: 018d7674-f1a4-b879-5ff3-d09b44a37de0

Index154 commented 8 months ago

Alright I just did one more test with the new version and it seems to be fixed now? I'll probably have an actual playing session again tomorrow so I can report if there's something weird again.

BananaPuncher714 commented 8 months ago

Ok thanks. In the latest update (1.1.13), I added in some code to verify that items/enemy objects are registered in the NetworkManager, which should have fixed any improper objects between clients. Hopefully that was the solution, but please do keep me updated just in case.

Index154 commented 8 months ago

We played for around 6 hours yesterday and there was no enemy desync so it seems to be fine on that front now. However we did have one instance where the dungeon generation was problematic. One of my friends fell through the map after entering the facility and the other said he saw me and enemies moving through walls. The first friend also reported seeing network errors in his log.

What's notable about this is that it was on the only moon (AtlasAbyss) where I had turned on the DungeonGeneration config, changing size multipliers and dungeonFlow weights. After this issue happened (pretty early on) we disabled that part of the config and there were no more problems for the rest of the session. Maybe this is worth looking into.

BananaPuncher714 commented 8 months ago

Ok thanks. If you're changing the dungeon generation configuration, then all players need to have the mod with the same configs enabled. It might be the same for the price configuration too, but I'll try to add in some networking in the future.

Index154 commented 8 months ago

The configs should have been the same for all players since we all used the same modpack

BananaPuncher714 commented 8 months ago

I forgot to make the dungeon flows set for clients, which would result in different interiors between host and clients. That would be the most likely cause, although if there are network errors there may be more problems causing this. If you have the errors then it would be helpful, but if not then I'll try to do some testing with Atlas Abyss.