Skip to content

fix: Fixed NetworkVar assignment of the same value triggering replication #1819

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 11 commits into from
Mar 23, 2022

Conversation

TwoTenPvP
Copy link
Contributor

Setting the value of a NetworkVar to the same value it's currently set to no longer triggers replication.

MTT-2882

Changelog

com.unity.netcode.gameobjects

  • Fixed: NetworkVar assignment of the same value no longer triggers replication

Testing and Documentation

  • Includes unit tests.
  • No documentation changes or additions were necessary.

@TwoTenPvP
Copy link
Contributor Author

This was a feature. Awaiting answer on why it was removed 5f81331

@TwoTenPvP TwoTenPvP marked this pull request as ready for review March 21, 2022 20:35
@mattwalsh-unity mattwalsh-unity self-requested a review March 21, 2022 21:03
Comment on lines 106 to 109
// Compares two values of the same unmanaged type bitwise
// Ignoring any overriden value checks
// Size is fixed
private static unsafe bool ValueEquals(ref T a, ref T b)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Compares two values of the same unmanaged type bitwise
// Ignoring any overriden value checks
// Size is fixed
private static unsafe bool ValueEquals(ref T a, ref T b)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static unsafe bool ValueEquals(ref T a, ref T b)

the comment block is out of date.
also what about hinting compiler to inline it too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How is the comment out of date?

Could be inlined but I think it's premature optimization.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean I think its fair that we should at least tell the compiler it could inline if possible. I mean inlining is a common practice where it makes sense would you not agree? I mean marking something as inline in say C++ is done with a purpose and I would expect no difference here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing. I'll add the flag as we are only using it in one place anyways.

0xFA11
0xFA11 previously approved these changes Mar 23, 2022
@TwoTenPvP TwoTenPvP enabled auto-merge (squash) March 23, 2022 16:27
@0xFA11 0xFA11 dismissed their stale review March 23, 2022 16:48

@wackoisgod raised a fair point, would like to wait for conversation to resolve.

@TwoTenPvP TwoTenPvP disabled auto-merge March 23, 2022 16:55
@TwoTenPvP TwoTenPvP enabled auto-merge (squash) March 23, 2022 17:00
@TwoTenPvP TwoTenPvP merged commit cda389d into develop Mar 23, 2022
@TwoTenPvP TwoTenPvP deleted the networkvar-unchanged-replication branch March 23, 2022 17:44
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