2022-10-08 19:18:22 +00:00
using OWML.Common ;
using QSB.Messaging ;
using QSB.Player.Messages ;
using QSB.Utility ;
namespace QSB.WorldSync ;
2022-10-08 21:27:57 +00:00
/// <summary>
/// sends QSBWorldSync.WorldObjectsHash to the server for sanity checking
/// </summary>
2022-12-06 17:12:25 +00:00
internal class WorldObjectsHashMessage : QSBMessage < ( string managerName , string hash ) >
2022-10-08 19:18:22 +00:00
{
2022-12-06 17:12:25 +00:00
public WorldObjectsHashMessage ( string managerName , string hash ) : base ( ( managerName , hash ) ) = > To = 0 ;
2022-10-08 19:18:22 +00:00
public override void OnReceiveRemote ( )
{
2022-12-31 19:51:11 +00:00
Delay . RunWhen ( ( ) = > QSBWorldSync . AllObjectsAdded , ( ) = >
2022-10-08 19:18:22 +00:00
{
2022-12-11 13:59:04 +00:00
var serverHash = QSBWorldSync . ManagerHashes [ Data . managerName ] ;
if ( serverHash ! = Data . hash )
{
// oh fuck oh no oh god
DebugLog . ToConsole ( $"Kicking {From} because their WorldObjects hash for {Data.managerName} is wrong. (server:{serverHash}, client:{Data.hash})" , MessageType . Error ) ;
new PlayerKickMessage ( From , $"WorldObject hash error for {Data.managerName}. (Server:{serverHash}, Client:{Data.hash})" ) . Send ( ) ;
}
} ) ;
2022-10-08 19:18:22 +00:00
}
}