Skip to content

refactor: assign auto-incremented GlobalObjectIdHash as a fallback in MultiInstanceHelpers.MakeNetworkObjectTestPrefab() #1094

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 26, 2021

Conversation

0xFA11
Copy link
Contributor

@0xFA11 0xFA11 commented Aug 25, 2021

a quick follow-up refactor after PR #1092

… MultiInstanceHelpers.MakeNetworkObjectTestPrefab()
Comment on lines +229 to +234
// Fallback to auto-increment if generation fails
if (networkObject.GlobalObjectIdHash == default)
{
networkObject.GlobalObjectIdHash = ++s_AutoIncrementGlobalObjectIdHashCounter;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the main addition

@@ -214,7 +215,7 @@ public class CoroutineResultWrapper<T>
/// </summary>
/// <param name="networkObject">The networkObject to be treated as Prefab</param>
/// <param name="globalObjectIdHash">The GlobalObjectId to force</param>
public static void MakeNetworkedObjectTestPrefab(NetworkObject networkObject, uint globalObjectIdHash = default)
public static void MakeNetworkObjectTestPrefab(NetworkObject networkObject, uint globalObjectIdHash = default)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also using this as a chance to correct the method name here too

Comment on lines +81 to +85
server.NetworkConfig.NetworkPrefabs.Add(new NetworkPrefab { Prefab = m_PlayerPrefabOverride });
foreach (var client in clients)
{
client.NetworkConfig.NetworkPrefabs.Add(new NetworkPrefab { Prefab = m_PlayerPrefabOverride });
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also this PR exposed this issue here too (it should've registered prefabs with networkmanagers but never did).
so, we're killing 2 issues with 1 fix here :)

NoelStephensUnity and others added 2 commits August 25, 2021 18:29
Removing DefaultPayerGlobalObjectIdHashValue with new GlobalObjectIdHash goodness.
@0xFA11 0xFA11 force-pushed the refactor/MakeNetObjTestPrefab branch from f898733 to 24cc69a Compare August 25, 2021 23:54
Comment on lines 59 to +60
Assert.AreEqual(Client.LocalClientId, objectSpawned.Connection.Id);
Assert.AreEqual(NewNetworkObjectName, objectSpawned.NetworkId.Name);
Assert.AreEqual($"{k_NewNetworkObjectName}(Clone)", objectSpawned.NetworkId.Name);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@becksebenius-unity FYI for changes in this file. tests were quite tricky — I think they're more reliable now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! I think @josiemessa will be interested too

Copy link
Collaborator

@NoelStephensUnity NoelStephensUnity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@0xFA11 0xFA11 enabled auto-merge (squash) August 26, 2021 00:18
@0xFA11 0xFA11 merged commit 90e4bbe into develop Aug 26, 2021
@0xFA11 0xFA11 deleted the refactor/MakeNetObjTestPrefab branch August 26, 2021 00:48
mollstam pushed a commit to Keepsake-Games/com.unity.netcode.gameobjects that referenced this pull request Feb 13, 2023
…in `MultiInstanceHelpers.MakeNetworkObjectTestPrefab()` + fix flaky tests exposed by this fix (Unity-Technologies#1094)

* refactor: assign auto-incremented GlobalObjectIdHash as a fallback in MultiInstanceHelpers.MakeNetworkObjectTestPrefab()

* fix MultiClientConnectionApproval.ConnectionApproval() test

* refactor

Removing DefaultPayerGlobalObjectIdHashValue with new GlobalObjectIdHash goodness.

* fix NetworkObjectMetricsTests

* remove `DefaultPayerGlobalObjectIdHashValue` from OwnershipChangeMetricsTests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants