fix: ClientToServer [SyncVar] wouldn't be broadcast to other clients because server never set it dirty

This commit is contained in:
vis2k 2022-12-04 16:47:46 -05:00
parent 4743d27f74
commit d5f7c4bc01

View File

@ -1047,6 +1047,15 @@ internal bool DeserializeServer(NetworkReader reader)
// server always knows the initial state (initial=false) // server always knows the initial state (initial=false)
// disconnect if failed, to prevent exploits etc. // disconnect if failed, to prevent exploits etc.
if (!comp.Deserialize(reader, false)) return false; if (!comp.Deserialize(reader, false)) return false;
// server received state from the owner client.
// set dirty so it's broadcast to other clients too.
//
// note that we set the _whole_ component as dirty.
// everything will be broadcast to others.
// SetSyncVarDirtyBits() would be nicer, but not all
// components use [SyncVar]s.
comp.SetDirty();
} }
} }
} }