mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-27 21:35:51 +00:00
Fix #671
This commit is contained in:
parent
ada70a41de
commit
7aba6bb2a8
@ -50,6 +50,8 @@ public class MenuManager : MonoBehaviour, IAddComponentOnStart
|
||||
|
||||
private GameObject _choicePopupPrefab;
|
||||
|
||||
public bool WillBeHost;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
Instance = this;
|
||||
@ -606,6 +608,7 @@ public class MenuManager : MonoBehaviour, IAddComponentOnStart
|
||||
private void Host(bool newMultiplayerSave)
|
||||
{
|
||||
QSBCore.IsInMultiplayer = true;
|
||||
WillBeHost = true;
|
||||
|
||||
if (newMultiplayerSave)
|
||||
{
|
||||
@ -648,7 +651,11 @@ public class MenuManager : MonoBehaviour, IAddComponentOnStart
|
||||
LoadGame(PlayerData.GetWarpedToTheEye());
|
||||
// wait until scene load and then wait until Start has ran
|
||||
// why is this done? GameStateMessage etc works on title screen since nonhost has to deal with that
|
||||
Delay.RunWhen(() => TimeLoop._initialized, QSBNetworkManager.singleton.StartHost);
|
||||
Delay.RunWhen(() => TimeLoop._initialized, () =>
|
||||
{
|
||||
QSBNetworkManager.singleton.StartHost();
|
||||
Delay.RunWhen(() => NetworkServer.active, () => WillBeHost = false);
|
||||
});
|
||||
};
|
||||
|
||||
OpenInfoPopup(string.Format(QSBLocalization.Current.CopySteamIDToClipboard, steamId)
|
||||
@ -660,7 +667,11 @@ public class MenuManager : MonoBehaviour, IAddComponentOnStart
|
||||
LoadGame(PlayerData.GetWarpedToTheEye());
|
||||
// wait until scene load and then wait until Start has ran
|
||||
// why is this done? GameStateMessage etc works on title screen since nonhost has to deal with that
|
||||
Delay.RunWhen(() => TimeLoop._initialized, QSBNetworkManager.singleton.StartHost);
|
||||
Delay.RunWhen(() => TimeLoop._initialized, () =>
|
||||
{
|
||||
QSBNetworkManager.singleton.StartHost();
|
||||
Delay.RunWhen(() => NetworkServer.active, () => WillBeHost = false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class QSBCore : ModBehaviour
|
||||
public static AssetBundle NetworkAssetBundle { get; private set; }
|
||||
public static AssetBundle ConversationAssetBundle { get; private set; }
|
||||
public static AssetBundle HUDAssetBundle { get; private set; }
|
||||
public static bool IsHost => NetworkServer.active;
|
||||
public static bool IsHost => NetworkServer.active || (IsInMultiplayer && MenuManager.Instance.WillBeHost);
|
||||
public static bool IsInMultiplayer;
|
||||
public static string QSBVersion => Helper.Manifest.Version;
|
||||
public static string GameVersion =>
|
||||
|
@ -66,6 +66,11 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
|
||||
|
||||
public float GetTimeDifference()
|
||||
{
|
||||
if (QSBCore.IsHost)
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
|
||||
var myTime = Time.timeSinceLevelLoad;
|
||||
return myTime - _serverTime;
|
||||
}
|
||||
@ -114,6 +119,7 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
|
||||
CurrentState = State.Loaded;
|
||||
if (QSBCore.IsHost)
|
||||
{
|
||||
_serverTime = Time.timeSinceLevelLoad;
|
||||
SendServerTime();
|
||||
}
|
||||
else
|
||||
@ -160,8 +166,7 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
|
||||
return;
|
||||
}
|
||||
|
||||
var myTime = Time.timeSinceLevelLoad;
|
||||
var diff = myTime - _serverTime;
|
||||
var diff = GetTimeDifference();
|
||||
|
||||
if (ServerStateManager.Instance.GetServerState() is not (ServerState.InSolarSystem or ServerState.InEye))
|
||||
{
|
||||
@ -188,6 +193,12 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
|
||||
|
||||
private void StartFastForwarding(FastForwardReason reason)
|
||||
{
|
||||
if (QSBCore.IsHost)
|
||||
{
|
||||
DebugLog.ToConsole($"Tried to fast-forward as server??? What???? _serverTime = {_serverTime}, GetTimeDifference() = {GetTimeDifference()}", MessageType.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (CurrentState == State.FastForwarding)
|
||||
{
|
||||
TimeSyncUI.TargetTime = _serverTime;
|
||||
@ -276,13 +287,11 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
|
||||
|
||||
if (ServerStateManager.Instance == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - ServerStateManager.Instance is null!", MessageType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
if (QSBPlayerManager.LocalPlayer == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - LocalPlayer is null!", MessageType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ using QSB.TimeSync;
|
||||
using QSB.WorldSync;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using QSB.Menus;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.Utility;
|
||||
@ -108,7 +109,7 @@ public class DebugGUI : MonoBehaviour, IAddComponentOnStart
|
||||
return;
|
||||
}
|
||||
|
||||
WriteLine(1, $"IsHost : {QSBCore.IsHost}");
|
||||
WriteLine(1, $"IsHost : {QSBCore.IsHost} (WillBeHost : {(MenuManager.Instance != null ? MenuManager.Instance.WillBeHost : "MenuManager null")})");
|
||||
WriteLine(1, $"HasWokenUp : {QSBWorldSync.AllObjectsReady}");
|
||||
if (WakeUpSync.LocalInstance != null)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user