onimp / oni_multiplayer

Oxygen Not Included multiplayer mod. Work in progress.
MIT License
218 stars 18 forks source link

Client unable to load save files larger than 10 MB #353

Open SordX opened 6 months ago

SordX commented 6 months ago

When a save file exceeds 10 MB, the game gets stuck on the waiting for 2nd player to load screen. There is an error in the Player.log [ERROR] [SteamServer] Failed to send message, result: k_EResultLimitExceeded

The problem appears to be caused by defaultBufferSize value in MultiplayerMod.Platform.Steam.Network.Configuration, which is set to 10 MB. Changing this value to a size larger than the save file allows the save file to load.

Attached is an example save file that is larger than 10 MB. The Data Dump 2 Cycle 745.zip

doctorcito0013 commented 6 months ago

I am also facing this issue. I have found the value in cause inside the code and I raised it a bit . But I have some troubles during compiling the mod in order to test. :-(

SordX commented 6 months ago

I also was unable to get a working mod compiled, but found I could use dnSpy to edit the Steam version of the mod. Although it is a bit trickier as the compiled version bakes in the constant, so I changed SendBufferSize to always set m_val to 20 MB. I've also attached my modified steam MultiplayerMod.dll if you just want to swap in a replacement. MultiplayerMod.zip

doctorcito0013 commented 6 months ago

oh thanks a lot @SordX, I will try your change with my friend this evening.

polycone commented 6 months ago

Hi @SordX, @doctorcito0013, I'll look into that when we will be implementing a new networking layer. As I see it's a case of overprovisioning and we need to make a thing to control the stream, wait for flush or something. Anyway, yes, for now it's okay to just increase the buffer size.

Also what happened with the compilation? 🤔 If there's a problem with IDE you can try the following (should work fine on Windows and Linux, PATH_TO_STEAM_LIBRARY must be replaced with the actual directory path)

echo "<Project><PropertyGroup><SteamLibraryPath>PATH_TO_STEAM_LIBRARY</SteamLibraryPath></PropertyGroup></Project>" > Directory.Build.props.user
dotnet restore
dotnet build --disable-build-servers src/MultiplayerMod/MultiplayerMod.csproj --configuration Release

And you can use Debug configuration to autoinstall the mod, but it works only on Windows for now.

Edit: Sorry, I haven't thought maybe you're trying to compile it from v1.1.1-alpha then it could complain about some DLLs being locked, like

warning MSB3026: Could not copy....because it is being used by another process. The file is locked by: "MSBuild.exe (16252)

Just terminate the mentioned process and run the build again - I've tried it now and the build was successful.

SordX commented 6 months ago

@polycone I'm building on Windows with MSVC. The compile seems to work fine and the mod appears to be installed fine, but I get an error when the mod attempts to connect to the steam server. I think it was this one: [ERROR] [SteamClient] Failed to send Command [1b584018f1fd45dba60d6e75d71b2e82] InitializeClientCommand: k_EResultInvalidParam).

While trying to trace back the source of the problem, I noted that the SteamGameServerNetworkingSockets.CreateListenSocketP2P(0, networkConfig.Length, networkConfig) returns 0, which maps to invalid socket. Not sure if that is a problem, or an irrelevant result.

In any case, I can't setup a p2p session while running the mod after I build it.

polycone commented 6 months ago

Does the distributed DLL work fine for you?

SordX commented 6 months ago

Yes, the DLL available on github works fine. Just did a test installing the github mod and was able to start the host without issue. Swapped in the MultiplayerMod.dll I built and the game gets stuck on "Starting Host" and my Player.log file has the "[ERROR] [SteamClient] Failed to send Command [49bb0b9971464aebb01f76520df502e7] InitializeClientCommand: k_EResultInvalidParam" error in it.