From b04e28752e4f1bb7cee55f607819122e8aec02c0 Mon Sep 17 00:00:00 2001
From: _nebula <41904486+misternebula@users.noreply.github.com>
Date: Tue, 13 Feb 2024 13:06:43 +0000
Subject: [PATCH] move worldsync messages to folder
---
QSB/Animation/Player/AnimationSync.cs | 2 +-
.../LightSensorSync/QSBPlayerLightSensor.cs | 2 +-
QSB/Utility/QSBNetworkBehaviour.cs | 1 +
.../Messages/RequestInitialStatesMessage.cs | 31 +++++++++++++++++++
.../Messages/WorldObjectsHashMessage.cs | 29 +++++++++++++++++
QSB/WorldSync/QSBWorldSync.cs | 1 +
QSB/WorldSync/RequestInitialStatesMessage.cs | 31 -------------------
QSB/WorldSync/WorldObjectsHashMessage.cs | 29 -----------------
8 files changed, 64 insertions(+), 62 deletions(-)
create mode 100644 QSB/WorldSync/Messages/RequestInitialStatesMessage.cs
create mode 100644 QSB/WorldSync/Messages/WorldObjectsHashMessage.cs
delete mode 100644 QSB/WorldSync/RequestInitialStatesMessage.cs
delete mode 100644 QSB/WorldSync/WorldObjectsHashMessage.cs
diff --git a/QSB/Animation/Player/AnimationSync.cs b/QSB/Animation/Player/AnimationSync.cs
index 0c68d99e..39b99a02 100644
--- a/QSB/Animation/Player/AnimationSync.cs
+++ b/QSB/Animation/Player/AnimationSync.cs
@@ -6,7 +6,7 @@ using QSB.Animation.Player.Thrusters;
using QSB.Messaging;
using QSB.Player;
using QSB.Utility;
-using QSB.WorldSync;
+using QSB.WorldSync.Messages;
using System;
using UnityEngine;
diff --git a/QSB/EchoesOfTheEye/LightSensorSync/QSBPlayerLightSensor.cs b/QSB/EchoesOfTheEye/LightSensorSync/QSBPlayerLightSensor.cs
index acf44cc8..477b7a8d 100644
--- a/QSB/EchoesOfTheEye/LightSensorSync/QSBPlayerLightSensor.cs
+++ b/QSB/EchoesOfTheEye/LightSensorSync/QSBPlayerLightSensor.cs
@@ -1,7 +1,7 @@
using QSB.EchoesOfTheEye.LightSensorSync.Messages;
using QSB.Messaging;
using QSB.Player;
-using QSB.WorldSync;
+using QSB.WorldSync.Messages;
using System.Linq;
using UnityEngine;
diff --git a/QSB/Utility/QSBNetworkBehaviour.cs b/QSB/Utility/QSBNetworkBehaviour.cs
index 542dd5a6..049b9fac 100644
--- a/QSB/Utility/QSBNetworkBehaviour.cs
+++ b/QSB/Utility/QSBNetworkBehaviour.cs
@@ -1,5 +1,6 @@
using Mirror;
using QSB.WorldSync;
+using QSB.WorldSync.Messages;
using System;
namespace QSB.Utility;
diff --git a/QSB/WorldSync/Messages/RequestInitialStatesMessage.cs b/QSB/WorldSync/Messages/RequestInitialStatesMessage.cs
new file mode 100644
index 00000000..98482c6e
--- /dev/null
+++ b/QSB/WorldSync/Messages/RequestInitialStatesMessage.cs
@@ -0,0 +1,31 @@
+using QSB.Messaging;
+using QSB.Utility;
+using System;
+
+namespace QSB.WorldSync.Messages;
+
+///
+/// sent to the host to get initial object states.
+///
+/// world objects will be ready on both sides at this point
+///
+public class RequestInitialStatesMessage : QSBMessage
+{
+ public RequestInitialStatesMessage() => To = 0;
+
+ public override void OnReceiveRemote() =>
+ Delay.RunWhen(() => QSBWorldSync.AllObjectsReady,
+ () => SendInitialStates(From));
+
+ private static void SendInitialStates(uint to)
+ {
+ SendInitialState?.SafeInvoke(to);
+ DebugLog.DebugWrite($"sent initial states to {to}");
+ }
+
+ ///
+ /// called on the host.
+ /// use this to send initial states to whoever is asking for it.
+ ///
+ public static event Action SendInitialState;
+}
diff --git a/QSB/WorldSync/Messages/WorldObjectsHashMessage.cs b/QSB/WorldSync/Messages/WorldObjectsHashMessage.cs
new file mode 100644
index 00000000..e638b60a
--- /dev/null
+++ b/QSB/WorldSync/Messages/WorldObjectsHashMessage.cs
@@ -0,0 +1,29 @@
+using OWML.Common;
+using QSB.Messaging;
+using QSB.Player.Messages;
+using QSB.Utility;
+
+namespace QSB.WorldSync.Messages;
+
+///
+/// sends QSBWorldSync.WorldObjectsHash to the server for sanity checking
+///
+public class WorldObjectsHashMessage : QSBMessage<(string managerName, string hash, int count)>
+{
+ public WorldObjectsHashMessage(string managerName, string hash, int count) : base((managerName, hash, count)) => To = 0;
+
+ public override void OnReceiveRemote()
+ {
+ Delay.RunWhen(() => QSBWorldSync.AllObjectsAdded, () =>
+ {
+ var (hash, count) = QSBWorldSync.ManagerHashes[Data.managerName];
+
+ if (hash != Data.hash)
+ {
+ // oh fuck oh no oh god
+ DebugLog.ToConsole($"Kicking {From} because their WorldObjects hash for {Data.managerName} is wrong. (Server:{hash} count:{count}, Client:{Data.hash} count:{Data.count})", MessageType.Error);
+ new PlayerKickMessage(From, $"WorldObject hash error for {Data.managerName}. (Server:{hash} count:{count}, Client:{Data.hash}, count:{Data.count})").Send();
+ }
+ });
+ }
+}
diff --git a/QSB/WorldSync/QSBWorldSync.cs b/QSB/WorldSync/QSBWorldSync.cs
index a20ef519..1f0865d8 100644
--- a/QSB/WorldSync/QSBWorldSync.cs
+++ b/QSB/WorldSync/QSBWorldSync.cs
@@ -9,6 +9,7 @@ using QSB.Player.TransformSync;
using QSB.TriggerSync.WorldObjects;
using QSB.Utility;
using QSB.Utility.LinkedWorldObject;
+using QSB.WorldSync.Messages;
using System;
using System.Collections.Generic;
using System.Diagnostics;
diff --git a/QSB/WorldSync/RequestInitialStatesMessage.cs b/QSB/WorldSync/RequestInitialStatesMessage.cs
deleted file mode 100644
index 85d2ed2a..00000000
--- a/QSB/WorldSync/RequestInitialStatesMessage.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using QSB.Messaging;
-using QSB.Utility;
-using System;
-
-namespace QSB.WorldSync;
-
-///
-/// sent to the host to get initial object states.
-///
-/// world objects will be ready on both sides at this point
-///
-public class RequestInitialStatesMessage : QSBMessage
-{
- public RequestInitialStatesMessage() => To = 0;
-
- public override void OnReceiveRemote() =>
- Delay.RunWhen(() => QSBWorldSync.AllObjectsReady,
- () => SendInitialStates(From));
-
- private static void SendInitialStates(uint to)
- {
- SendInitialState?.SafeInvoke(to);
- DebugLog.DebugWrite($"sent initial states to {to}");
- }
-
- ///
- /// called on the host.
- /// use this to send initial states to whoever is asking for it.
- ///
- public static event Action SendInitialState;
-}
diff --git a/QSB/WorldSync/WorldObjectsHashMessage.cs b/QSB/WorldSync/WorldObjectsHashMessage.cs
deleted file mode 100644
index 45905df5..00000000
--- a/QSB/WorldSync/WorldObjectsHashMessage.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using OWML.Common;
-using QSB.Messaging;
-using QSB.Player.Messages;
-using QSB.Utility;
-
-namespace QSB.WorldSync;
-
-///
-/// sends QSBWorldSync.WorldObjectsHash to the server for sanity checking
-///
-public class WorldObjectsHashMessage : QSBMessage<(string managerName, string hash, int count)>
-{
- public WorldObjectsHashMessage(string managerName, string hash, int count) : base((managerName, hash, count)) => To = 0;
-
- public override void OnReceiveRemote()
- {
- Delay.RunWhen(() => QSBWorldSync.AllObjectsAdded, () =>
- {
- var (hash, count) = QSBWorldSync.ManagerHashes[Data.managerName];
-
- if (hash != Data.hash)
- {
- // oh fuck oh no oh god
- DebugLog.ToConsole($"Kicking {From} because their WorldObjects hash for {Data.managerName} is wrong. (Server:{hash} count:{count}, Client:{Data.hash} count:{Data.count})", MessageType.Error);
- new PlayerKickMessage(From, $"WorldObject hash error for {Data.managerName}. (Server:{hash} count:{count}, Client:{Data.hash}, count:{Data.count})").Send();
- }
- });
- }
-}