Barotrauma icon indicating copy to clipboard operation
Barotrauma copied to clipboard

Defining any OutpostConfig to use premade outposts will cause level equality to fail in multiplayer

Open NilanthAnimosus opened this issue 1 year ago • 0 comments

Discussed in https://github.com/FakeFishGames/Barotrauma/discussions/14204

Originally posted by NilanthAnimosus June 25, 2024

Disclaimers

  • [X] I have searched the issue tracker to check if the issue has already been reported.
  • [X] My issue happened while using mods.

What happened?

Defining an OutpostConfig that uses outpostfilepath="pathtosub.sub" will cause level equality issues in multiplayer, rejoining might result in a single module outpost or other equivilant (and not the expected submarine) though the issue appears to be the client generating the submarine file outpost, while the server generates from modules only, related code in additional info.

Reproduction steps

  1. Add to locationTypes.xml an entry such as:
<Tutorialtwo
    identifier="TutorialOutposttwo"
    replaceinradiation="Abandoned"
    nameidentifiers="generic,city"
    forceoutpostgenerationparams="tutorialoutposttwo"
		commonnessperzone="1: 1.5, 2: 2.5, 3: 1.0, 4: 0.75"
		mincountperzone="1: 1"
    AllowAsBiomeGate="false">
  1. now add to OutpostGenerationParameters.xml an entry such as:
<OutpostConfig
    identifier="tutorialoutposttwo"
    allowedlocationtypes="tutorialoutposttwo"
    outpostfilepath="Content/Tutorials/CampaignStartOutpost.sub">
    <npcs>
      <npc from="tutorialnpcs" identifier="merchantoutpost"/>
      <npc from="outpostnpcs1" identifier="outpostmanagercoalition"/>
      <npc from="outpostnpcs1" identifier="commoner"/>
      <npc from="outpostnpcs1" identifier="commoner"/>
      <npc from="outpostnpcs1" identifier="securitynpccoalition"/>
    </npcs>
  </OutpostConfig>
  1. Now host a dedicated campaign and as a client find an outpost that is "Unknown" (as no text exists), upon loading that outpost a level equality fail will occur.

Bug prevalence

Happens every time I play

Single player or multiplayer?

Multiplayer hosted using a dedicated server

-

No response

Version

v1.5.8.0 (Summer Update)

-

No response

Which operating system did you encounter this bug on?

Windows

Relevant error messages and crash reports

The issue appears to be the client code has an override to generate a specific outpost, but the shared/server code does not. I understand the tutorial outpost aka setting a starting outpost is singleplayer only, though any mod trying to have specific locations be specific outposts will break multiplayer syncing currently.

After debugging, CampaignMode.cs (Clientsource) hits this code on line 347 which the server instead generates with modules as the client uses the sub file:

protected SubmarineInfo GetPredefinedStartOutpost()
{
    if (Map?.CurrentLocation?.Type?.GetForcedOutpostGenerationParams() is OutpostGenerationParams parameters && !parameters.OutpostFilePath.IsNullOrEmpty())
    {
        return new SubmarineInfo(parameters.OutpostFilePath.Value)
        {
            OutpostGenerationParams = parameters
        };
    }
    return null;
}

Suggest moving this code from client to shared/server (Or at the very least - a check if connected to server, though this will still have mod issues in MP), and perhaps allowing the setting of a starting outpost regardless of tutorial setting (to open that up for modders perhaps - That seems to be popular on discord amongst modders as a wanted feature).

NilanthAnimosus avatar Jun 24 '24 23:06 NilanthAnimosus