Skip to content

Commit 1ad835a

Browse files
Merge branch 'develop-2.0.0' into fix/networktransform-autoswitchspace-forcing-updates-localspace
2 parents f958400 + bcb73cd commit 1ad835a

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
2525
- Changed when NetworkObjects pending to be shown to clients can now occur on partial network ticks. If any pending NetworkObjects pending to be shown to clients happens to be ready on a new network tick they still are shown after network variable deltas have been processed. (#3664)
2626
- Changed the default `NetworkDelivery` used by all messages is now reliable fragmented sequenced with the exception of named, unnamed, and any messages sent with a user specified network delivery type. This assures certain order of operations to be preserved when same call-stack changes are applied to a newly spawned, authority side, NetworkObject. (#3664)
2727
- Changed NetworkTransform documentation to better reflect the Teleport methods intended usage along with updates to NetworkObject and physics areas of the documentation. (#3664)
28+
- The first session owner no longer sends two synchronization messages to the service. (#3563)
2829

2930
### Deprecated
3031

com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,11 @@ internal void SetSessionOwner(ulong sessionOwner)
236236
OnSessionOwnerPromoted?.Invoke(sessionOwner);
237237
}
238238

239+
#if ENABLE_SESSIONOWNER_PROMOTION_NOTIFICATION
240+
public void PromoteSessionOwner(ulong clientId)
241+
#else
239242
internal void PromoteSessionOwner(ulong clientId)
243+
#endif
240244
{
241245
if (!DistributedAuthorityMode)
242246
{
@@ -253,10 +257,18 @@ internal void PromoteSessionOwner(ulong clientId)
253257
{
254258
SessionOwner = clientId,
255259
};
256-
var clients = ConnectionManager.ConnectedClientIds.Where(c => c != LocalClientId).ToArray();
257-
foreach (var targetClient in clients)
260+
var delivery = MessageDeliveryType<SessionOwnerMessage>.DefaultDelivery;
261+
if (CMBServiceConnection)
258262
{
259-
ConnectionManager.SendMessage(ref sessionOwnerMessage, MessageDeliveryType<SessionOwnerMessage>.DefaultDelivery, targetClient);
263+
ConnectionManager.SendMessage(ref sessionOwnerMessage, delivery, ServerClientId);
264+
}
265+
else
266+
{
267+
var clients = ConnectionManager.ConnectedClientIds.Where(c => c != LocalClientId).ToArray();
268+
foreach (var targetClient in clients)
269+
{
270+
ConnectionManager.SendMessage(ref sessionOwnerMessage, delivery, targetClient);
271+
}
260272
}
261273
}
262274

com.unity.netcode.gameobjects/Runtime/Messaging/Messages/ConnectionApprovedMessage.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -373,21 +373,18 @@ public void Handle(ref NetworkContext context)
373373

374374
if (!networkManager.SceneManager.IsRestoringSession)
375375
{
376-
// Synchronize the service with the initial session owner's loaded scenes and spawned objects
377-
networkManager.SceneManager.SynchronizeNetworkObjects(NetworkManager.ServerClientId, true);
378-
379376
// Spawn any in-scene placed NetworkObjects
380377
networkManager.SpawnManager.ServerSpawnSceneObjectsOnStartSweep();
381378

379+
// Synchronize the service with the initial session owner's loaded scenes and spawned objects
380+
networkManager.SceneManager.SynchronizeNetworkObjects(NetworkManager.ServerClientId, true);
381+
382382
// Spawn the local player of the session owner
383383
if (networkManager.AutoSpawnPlayerPrefabClientSide)
384384
{
385385
networkManager.ConnectionManager.CreateAndSpawnPlayer(OwnerClientId);
386386
}
387387

388-
// Synchronize the service with the initial session owner's loaded scenes and spawned objects
389-
networkManager.SceneManager.SynchronizeNetworkObjects(NetworkManager.ServerClientId, true);
390-
391388
// With scene management enabled and since the session owner doesn't send a scene event synchronize to itself,
392389
// we need to notify the session owner that everything should be synchronized/spawned at this time.
393390
networkManager.SpawnManager.NotifyNetworkObjectsSynchronized();

0 commit comments

Comments
 (0)