Merge pull request #410 from misternebula/fixes

Fixes
This commit is contained in:
_nebula 2021-12-12 11:21:36 +00:00 committed by GitHub
commit 0628af1634
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 20 deletions

View File

@ -176,7 +176,7 @@ namespace QSB.Menus
DisconnectButton = MenuApi.PauseMenu_MakeMenuOpenButton("DISCONNECT", DisconnectPopup);
QuitButton = Locator.GetSceneMenuManager().pauseMenu._exitToMainMenuAction.gameObject;
QuitButton = FindObjectOfType<PauseMenuManager>()._exitToMainMenuAction.gameObject;
if (QSBCore.IsInMultiplayer)
{

View File

@ -17,13 +17,18 @@ namespace QSB.Player
return;
}
if (!WorldObjectManager.AllObjectsReady)
{
return;
}
var controller = Locator.GetPlayerController();
if (controller == null)
{
return;
}
var collidingQuantumObject = controller.GetValue<QuantumObject>("_collidingQuantumObject");
var collidingQuantumObject = controller._collidingQuantumObject;
if (_previousCollidingQuantumObject != collidingQuantumObject)
{
var objectIndex = (collidingQuantumObject != null)

View File

@ -5,6 +5,7 @@ using QSB.Patches;
using QSB.Utility;
using QSB.WorldSync;
using System;
using QSB.ShipSync.TransformSync;
using UnityEngine;
namespace QSB.ShipSync.Patches
@ -206,7 +207,7 @@ namespace QSB.ShipSync.Patches
[HarmonyPrefix]
[HarmonyPatch(typeof(ShipDamageController), nameof(ShipDamageController.OnImpact))]
public static bool ShipDamageController_OnImpact()
=> ShipManager.Instance.HasAuthority;
=> ShipTransformSync.LocalInstance == null || ShipManager.Instance.HasAuthority;
[HarmonyPostfix]
[HarmonyPatch(typeof(ShipComponent), nameof(ShipComponent.RepairTick))]

View File

@ -1,4 +1,5 @@
using QSB.Player;
using OWML.Common;
using QSB.Player;
using QSB.SectorSync;
using QSB.SectorSync.WorldObjects;
using QSB.Utility;
@ -65,7 +66,7 @@ namespace QSB.Syncs.Sectored
}
else
{
DebugLog.ToConsole($"Warning - {LogName}'s initial sector was null.", OWML.Common.MessageType.Warning);
DebugLog.ToConsole($"Warning - {LogName}'s initial sector was null.", MessageType.Warning);
}
}
@ -75,7 +76,7 @@ namespace QSB.Syncs.Sectored
{
if (ReferenceSector != null && ReferenceSector.Transform != ReferenceTransform)
{
DebugLog.ToConsole($"Warning - {LogName} : ReferenceSector.Transform was different to ReferenceTransform. Correcting...", OWML.Common.MessageType.Warning);
DebugLog.ToConsole($"Warning - {LogName} : ReferenceSector.Transform was different to ReferenceTransform. Correcting...", MessageType.Warning);
SetReferenceTransform(ReferenceSector.Transform);
}
@ -97,7 +98,7 @@ namespace QSB.Syncs.Sectored
{
if (sector == null)
{
DebugLog.ToConsole($"Error - {PlayerId}.{GetType().Name} got sector of ID -1.", OWML.Common.MessageType.Error);
DebugLog.ToConsole($"Error - {LogName} got sector of ID -1. (From waiting slot.)", MessageType.Error);
base.Update();
return;
}
@ -112,15 +113,21 @@ namespace QSB.Syncs.Sectored
public override void SerializeTransform(QNetworkWriter writer, bool initialState)
{
if (!QSBPlayerManager.PlayerExists(PlayerId))
if (IsPlayerObject)
{
writer.Write(-1);
if (!QSBPlayerManager.PlayerExists(PlayerId))
{
writer.Write(-1);
return;
}
else if (!Player.IsReady)
{
writer.Write(-1);
return;
}
}
else if (!Player.IsReady)
{
writer.Write(-1);
}
else if (ReferenceSector != null)
if (ReferenceSector != null)
{
writer.Write(ReferenceSector.ObjectId);
}
@ -128,7 +135,7 @@ namespace QSB.Syncs.Sectored
{
if (_isInitialized)
{
DebugLog.ToConsole($"Warning - ReferenceSector of {PlayerId}.{GetType().Name} is null.", OWML.Common.MessageType.Warning);
DebugLog.ToConsole($"Warning - ReferenceSector of {LogName} is null.", MessageType.Warning);
}
writer.Write(-1);
@ -143,7 +150,6 @@ namespace QSB.Syncs.Sectored
sectorId = reader.ReadInt32();
if (initialState && sectorId != -1)
{
DebugLog.DebugWrite($"{LogName} set waiting sector id:{sectorId}");
_sectorIdWaitingSlot = sectorId;
}
@ -159,7 +165,7 @@ namespace QSB.Syncs.Sectored
{
if (sector == null)
{
DebugLog.ToConsole($"Error - {PlayerId}.{GetType().Name} got sector of ID -1.", OWML.Common.MessageType.Error);
DebugLog.ToConsole($"Error - {LogName} got sector of ID -1. (From deserializing transform.)", MessageType.Error);
return;
}
@ -178,7 +184,7 @@ namespace QSB.Syncs.Sectored
{
DebugLog.ToConsole($"Warning - Reference was null, but sector manager wasn't ready. " +
$"Transform:{ReferenceTransform == null}, Sector:{ReferenceSector == null}",
OWML.Common.MessageType.Warning);
MessageType.Warning);
}
DebugLog.DebugWrite($"{LogName} : Sector Manager not ready.");
@ -202,7 +208,7 @@ namespace QSB.Syncs.Sectored
}
else
{
DebugLog.ToConsole($"Error - No closest sector found to {PlayerId}.{GetType().Name}!", OWML.Common.MessageType.Error);
DebugLog.ToConsole($"Error - No closest sector found to {LogName}!", MessageType.Error);
return false;
}
}

View File

@ -13,7 +13,9 @@ namespace QSB.TornadoSync.TransformSync
{
public class OccasionalTransformSync : UnsectoredRigidbodySync
{
public override bool IsReady => WorldObjectManager.AllObjectsReady;
public override bool IsReady => WorldObjectManager.AllObjectsReady
&& _bodyIndex >= 0 && _bodyIndex < CenterOfTheUniverse.s_rigidbodies.Count
&& _refBodyIndex >= 0 && _refBodyIndex < CenterOfTheUniverse.s_rigidbodies.Count;
public override bool UseInterpolation => false;
public override bool IsPlayerObject => false;