Skip to content

Commit 390a3a0

Browse files
authored
Merge pull request #607 from misternebula/dev
0.26.3
2 parents b948f81 + 8864157 commit 390a3a0

File tree

12 files changed

+40
-49
lines changed

12 files changed

+40
-49
lines changed

QSB/AssetBundles/qsb_network

-1.13 KB
Binary file not shown.

QSB/EchoesOfTheEye/RaftSync/TransformSync/RaftTransformSync.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ namespace QSB.EchoesOfTheEye.RaftSync.TransformSync;
1111
public class RaftTransformSync : UnsectoredRigidbodySync, ILinkedNetworkBehaviour
1212
{
1313
private bool ShouldMovePlayer =>
14-
(
15-
Locator.GetPlayerController().GetGroundBody() == null ||
16-
Locator.GetPlayerController().GetGroundBody() == AttachedRigidbody
17-
) &&
1814
Vector3.Distance(AttachedTransform.position, Locator.GetPlayerBody().GetPosition()) < 10;
1915
protected override bool UseInterpolation => !ShouldMovePlayer;
2016

QSB/Menus/MenuManager.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,12 @@ private static void SetButtonActive(GameObject button, bool active)
438438
return;
439439
}
440440

441+
var titleAnimationController = QSBWorldSync.GetUnityObject<TitleScreenManager>()._gfxController;
442+
443+
var activeAlpha = titleAnimationController.IsTitleAnimationComplete() ? 1 : 0;
444+
441445
button.SetActive(active);
442-
button.GetComponent<CanvasGroup>().alpha = active ? 1 : 0;
446+
button.GetComponent<CanvasGroup>().alpha = active ? activeAlpha : 0;
443447
}
444448

445449
private void InitPauseMenus()

QSB/Messaging/QSBMessageManager.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,15 @@ private static void OnServerReceive(QSBMessage msg)
5252
}
5353
else
5454
{
55-
msg.To.GetNetworkConnection().Send<Wrapper>(msg);
55+
var connection = msg.To.GetNetworkConnection();
56+
57+
if (connection == default)
58+
{
59+
DebugLog.ToConsole($"Warning - Tried to handle message from disconnected(?) player.", MessageType.Warning);
60+
return;
61+
}
62+
63+
connection.Send<Wrapper>(msg);
5664
}
5765
}
5866

QSB/QuantumSync/WorldObjects/QSBQuantumObject.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
namespace QSB.QuantumSync.WorldObjects;
1515

1616
/// <summary>
17-
/// TODO: just use OnSectorOccupantsUpdated instead of this shape bullshit
18-
///
1917
/// TODO: make it part of the ad-hoc owner interface
18+
///
19+
/// TODO: make it so only players in the sector (which sector?) are checked for visibility
2020
/// </summary>
2121
internal abstract class QSBQuantumObject<T> : WorldObject<T>, IQSBQuantumObject
2222
where T : QuantumObject

QSB/ShipSync/TransformSync/ShipTransformSync.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using QSB.HUD;
2+
using QSB.Player;
13
using QSB.Syncs.Sectored.Rigidbodies;
24
using QSB.Utility;
35
using UnityEngine;
@@ -124,10 +126,7 @@ private static void SetVelocity(OWRigidbody @this, Vector3 newVelocity)
124126

125127

126128
private bool ShouldMovePlayer =>
127-
(
128-
Locator.GetPlayerController().GetGroundBody() == null ||
129-
Locator.GetPlayerController().GetGroundBody() == AttachedRigidbody
130-
) &&
131-
Vector3.Distance(AttachedTransform.position, Locator.GetPlayerBody().GetPosition()) < 100;
129+
PlayerState.InZeroG()
130+
&& Vector3.Distance(AttachedTransform.position, Locator.GetPlayerBody().GetPosition()) < 100;
132131
protected override bool UseInterpolation => !ShouldMovePlayer;
133132
}

QSB/TimeSync/Messages/ServerTimeMessage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ public override void Deserialize(NetworkReader reader)
3333
}
3434

3535
public override void OnReceiveRemote()
36-
=> WakeUpSync.LocalInstance.OnClientReceiveMessage(ServerTime, LoopCount, SecondsRemaining);
36+
=> WakeUpSync.LocalInstance?.OnClientReceiveMessage(ServerTime, LoopCount, SecondsRemaining);
3737
}

QSB/TimeSync/StopMeditation.cs

Lines changed: 0 additions & 8 deletions
This file was deleted.

QSB/TimeSync/WakeUpSync.cs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@
1616

1717
namespace QSB.TimeSync;
1818

19-
/// <summary>
20-
/// BUG: this runs on remote players = BAD! can we move this off of network player?
21-
/// </summary>
22-
[UsedInUnityProject]
23-
public class WakeUpSync : NetworkBehaviour
19+
public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
2420
{
2521
public static WakeUpSync LocalInstance { get; private set; }
2622

@@ -41,8 +37,6 @@ public enum State { NotLoaded, Loaded, FastForwarding, Pausing }
4137
private int _serverLoopCount;
4238
private bool _hasWokenUp;
4339

44-
public override void OnStartLocalPlayer() => LocalInstance = this;
45-
4640
public void OnDisconnect()
4741
{
4842
OWTime.SetTimeScale(1f);
@@ -60,11 +54,6 @@ public void OnDisconnect()
6054

6155
public void Start()
6256
{
63-
if (!isLocalPlayer)
64-
{
65-
return;
66-
}
67-
6857
if (QSBSceneManager.IsInUniverse)
6958
{
7059
Init();
@@ -108,10 +97,12 @@ private void OnSceneLoaded(OWScene oldScene, OWScene newScene, bool isInUniverse
10897
_hasWokenUp = true;
10998
}
11099

100+
LocalInstance = this;
111101
Init();
112102
}
113103
else
114104
{
105+
LocalInstance = null;
115106
CurrentState = State.NotLoaded;
116107
}
117108
}
@@ -120,7 +111,7 @@ private void Init()
120111
{
121112
new RequestStateResyncMessage().Send();
122113
CurrentState = State.Loaded;
123-
if (isServer)
114+
if (QSBCore.IsHost)
124115
{
125116
SendServerTime();
126117
}
@@ -162,7 +153,7 @@ private void WakeUpOrSleep()
162153
return;
163154
}
164155

165-
if (PlayerData.LoadLoopCount() != _serverLoopCount && !isServer)
156+
if (PlayerData.LoadLoopCount() != _serverLoopCount && !QSBCore.IsHost)
166157
{
167158
DebugLog.ToConsole($"Warning - ServerLoopCount is not the same as local loop count! local:{PlayerData.LoadLoopCount()} server:{_serverLoopCount}");
168159
return;
@@ -268,11 +259,11 @@ private void WakeUp()
268259

269260
public void Update()
270261
{
271-
if (isServer)
262+
if (QSBCore.IsHost)
272263
{
273264
UpdateServer();
274265
}
275-
else if (isLocalPlayer && !QSBCore.DebugSettings.AvoidTimeSync)
266+
else if (NetworkClient.active && QSBSceneManager.IsInUniverse && !QSBCore.DebugSettings.AvoidTimeSync)
276267
{
277268
UpdateClient();
278269
}

QSB/WorldSync/QSBWorldSync.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static class QSBWorldSync
2323
public static WorldObjectManager[] Managers;
2424

2525
private static readonly Dictionary<string, List<IWorldObject>> _managerToBuiltObjects = new();
26-
public static readonly Dictionary<string, string> ManagerHashes = new();
26+
public static readonly Dictionary<string, (string hash, int count)> ManagerHashes = new();
2727

2828
/// <summary>
2929
/// Set when all WorldObjectManagers have called Init() on all their objects (AKA all the objects are created)
@@ -91,15 +91,16 @@ await manager.Try("building world objects", async () =>
9191
foreach (var item in _managerToBuiltObjects)
9292
{
9393
var worldObjects = item.Value;
94-
var hash = worldObjects.Select(x => x.GetType().Name).GetMD5Hash();
95-
ManagerHashes[item.Key] = hash;
94+
var objects = worldObjects.Select(x => x.GetType().Name);
95+
var hash = objects.GetMD5Hash();
96+
ManagerHashes[item.Key] = (hash, objects.Count());
9697
}
9798

9899
if (!QSBCore.IsHost)
99100
{
100101
foreach (var item in ManagerHashes)
101102
{
102-
new WorldObjectsHashMessage(item.Key, item.Value).Send();
103+
new WorldObjectsHashMessage(item.Key, item.Value.hash, item.Value.count).Send();
103104
}
104105

105106
new RequestLinksMessage().Send();

0 commit comments

Comments
 (0)