From 01c56d03e7f6ea54ff712cb0f5ada885ec931eca Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Sat, 7 Dec 2024 22:15:28 +0100 Subject: [PATCH] Fix nullref on dedi --- Fika.Core/Coop/GameMode/CoopGame.cs | 7 ++++++- .../Coop/HostClasses/FikaHostTransitController.cs | 11 +++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Fika.Core/Coop/GameMode/CoopGame.cs b/Fika.Core/Coop/GameMode/CoopGame.cs index 04f3c154..af4377a4 100644 --- a/Fika.Core/Coop/GameMode/CoopGame.cs +++ b/Fika.Core/Coop/GameMode/CoopGame.cs @@ -1061,7 +1061,7 @@ public async Task InitPlayer(BotControllerSettings botsSettings, string backendU } if (transitActive) { - Singleton.Instance.TransitController = isServer ? new FikaHostTransitController(instance.transitSettings, Location_0.transitParameters, + gameWorld.TransitController = isServer ? new FikaHostTransitController(instance.transitSettings, Location_0.transitParameters, Profile_0, localRaidSettings_0) : new FikaClientTransitController(instance.transitSettings, Location_0.transitParameters, Profile_0, localRaidSettings_0); } @@ -1089,6 +1089,11 @@ public async Task InitPlayer(BotControllerSettings botsSettings, string backendU PlayerCameraController.Create(gparam_0.Player); CameraClass.Instance.SetOcclusionCullingEnabled(Location_0.OcculsionCullingEnabled); CameraClass.Instance.IsActive = false; + + if (FikaBackendUtils.IsDedicated && gameWorld.TransitController is FikaHostTransitController hostController) + { + hostController.SetupDedicatedPlayerTransitStash(player); + } } await WaitForPlayersToConnect(); diff --git a/Fika.Core/Coop/HostClasses/FikaHostTransitController.cs b/Fika.Core/Coop/HostClasses/FikaHostTransitController.cs index a6e0bcfa..f78c092c 100644 --- a/Fika.Core/Coop/HostClasses/FikaHostTransitController.cs +++ b/Fika.Core/Coop/HostClasses/FikaHostTransitController.cs @@ -30,13 +30,12 @@ public FikaHostTransitController(BackendConfigSettingsClass.GClass1529 settings, playersInTransitZone = []; dediTransit = false; transittedPlayers = []; + } - if (FikaBackendUtils.IsDedicated) - { - CoopPlayer dediPlayer = (CoopPlayer)GamePlayerOwner.MyPlayer; - TransferItemsController.InitPlayerStash(dediPlayer); - dediPlayer.UpdateBtrTraderServiceData().HandleExceptions(); - } + public void SetupDedicatedPlayerTransitStash(LocalPlayer player) + { + TransferItemsController.InitPlayerStash(player); + player.UpdateBtrTraderServiceData().HandleExceptions(); } private readonly LocalRaidSettings localRaidSettings;