- Fixed network synchro of vars, needs synctype testing.

This commit is contained in:
MapleWheels
2026-04-09 05:34:50 -04:00
parent 84cb7cfeb7
commit ef66d27ffe
22 changed files with 115 additions and 23 deletions
@@ -13,9 +13,25 @@ partial class NetworkingService : INetworkingService, IEventServerConnected, IEv
public void OnServerConnected()
{
ActivateNetVars();
SendSyncMessage();
}
private void ActivateNetVars()
{
if (GameMain.Client == null)
{
return;
}
// re-activate net vars
// todo: unregister net vars on client disconnect, currently handled by unloading the state machine.
foreach (var networkSyncVar in netVars.Keys)
{
networkSyncVar.SetNetworkOwner(this);
}
}
public void OnReceivedServerNetMessage(IReadMessage netMessage, ServerPacketHeader serverPacketHeader)
{
if (serverPacketHeader != ServerHeader)
@@ -44,7 +60,7 @@ partial class NetworkingService : INetworkingService, IEventServerConnected, IEv
private void SendSyncMessage()
{
if (GameMain.Client == null) { return; }
WriteOnlyMessage message = new WriteOnlyMessage();
message.WriteByte((byte)ClientHeader);
message.WriteByte((byte)ClientToServer.RequestSync);