-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bea9764
commit b04e287
Showing
8 changed files
with
64 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
using Mirror; | ||
using QSB.WorldSync; | ||
using QSB.WorldSync.Messages; | ||
using System; | ||
|
||
namespace QSB.Utility; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using QSB.Messaging; | ||
using QSB.Utility; | ||
using System; | ||
|
||
namespace QSB.WorldSync.Messages; | ||
|
||
/// <summary> | ||
/// sent to the host to get initial object states. | ||
/// <para/> | ||
/// world objects will be ready on both sides at this point | ||
/// </summary> | ||
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}"); | ||
} | ||
|
||
/// <summary> | ||
/// called on the host. | ||
/// use this to send initial states to whoever is asking for it. | ||
/// </summary> | ||
public static event Action<uint> SendInitialState; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using OWML.Common; | ||
using QSB.Messaging; | ||
using QSB.Player.Messages; | ||
using QSB.Utility; | ||
|
||
namespace QSB.WorldSync.Messages; | ||
|
||
/// <summary> | ||
/// sends QSBWorldSync.WorldObjectsHash to the server for sanity checking | ||
/// </summary> | ||
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(); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.