Pathoschild / SMAPI

The modding API for Stardew Valley.
https://smapi.io/
GNU Lesser General Public License v3.0
1.71k stars 258 forks source link

Constants.SaveFolderName does not include the farm name prefix on multiplayer client game instance #956

Open MolsonCAD opened 2 weeks ago

MolsonCAD commented 2 weeks ago

Describe the bug Constants.SaveFolderName returns a string of the form "name_id". The host/main farmer receives the expected result, e.g. "FooBar_304200428" for the farm with name "FooBar" and id "304200428". A guest/farmhand receives a string with no farm name and only the id, e.g. "_304200428". This happens in both split-screen and regular multiplayer modes.

To Reproduce The issue can be observed without any mods through the standard log output, but I've included a test mod entry file that will showcase the issue with Constants.SaveFolderName directly. It can be observed in either regular multiplayer or split-screen, so the reproduction steps and SMAPI log file will be using split-screen for simplicity.

  1. Launch the game. Optionally include TestMod (below) in the Mods folder.
  2. Load any save and start local co-op. (My save is "FooBar_304200428")
  3. Join the game with a gamepad controller and create/select a character.
  4. View the log output (first and last two lines):
    [14:11:13 TRACE SMAPI] Context: loaded save 'FooBar_304200428', starting summer 19 Y1, locale set to . Single-player.
    [14:11:13 DEBUG TestMod] FooBar_304200428
    [14:11:20 TRACE game] Window_ClientSizeChanged(); Window.ClientBounds={X:0 Y:0 Width:1920 Height:1080}
    [14:11:28 TRACE game] Starting multiplayer server for local multiplayer...
    [14:11:28 TRACE game] Starting server. Protocol version: 1.6.6
    [14:11:28 TRACE game] Starting LAN server
    ...
    [14:11:34 TRACE screen_1 SMAPI] Received context for host 6355978755418457551 running SMAPI 4.0.8 with 3 mods.
    [14:11:34 TRACE screen_1 game] gameMode was 'loadingMode (6)', set to 'playingGameMode (3)'.
    [14:11:34 TRACE screen_1 SMAPI] Context: loaded save '_304200428', starting summer 19 Y1, locale set to . Farmhand with 2 players online.
    [14:11:34 DEBUG screen_1 TestMod] _304200428
// TestMod/ModEntry.cs
using StardewModdingAPI;

namespace TestMod
{
    internal sealed class ModEntry : Mod
    {
        public override void Entry(IModHelper helper)
        {
            helper.Events.GameLoop.SaveLoaded += (_, _) => Monitor.Log($"{Constants.SaveFolderName}", LogLevel.Debug);
        }
    }
}

Log file Full log output: https://smapi.io/log/ef42253c5868478087181f7c329a20a1