Skip to content

refactor: cache HasAuthority to avoid recomputing it on every access#4026

Open
noellie-velez wants to merge 7 commits into
develop-2.0.0from
refactor/use-internal-has-authority-network-object
Open

refactor: cache HasAuthority to avoid recomputing it on every access#4026
noellie-velez wants to merge 7 commits into
develop-2.0.0from
refactor/use-internal-has-authority-network-object

Conversation

@noellie-velez

@noellie-velez noellie-velez commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Purpose of this PR

  • refactor: precalculate HasAuthority into cached m_HasAuthority field
    • Removed InternalHasAuthority() and replaced with private m_HasAuthority field
    • Set m_HasAuthority on Spawn (before SpawnInternal), cleared on despawn, updated on ownership change
    • Replaced all internal HasAuthority call sites with direct m_HasAuthority field access
    • Updated public HasAuthority property to return cached value when spawned

Jira ticket

MTT-14792

Changelog

N/A

Documentation

  • No documentation changes or additions were necessary.

Testing & QA (How your changes can be verified during release Playtest)

Functional Testing

Manual testing :

  • Manual testing done

Automated tests:

  • Covered by existing automated tests
  • Covered by new automated tests

Does the change require QA team to:

  • Review automated tests?
  • Execute manual tests?
  • Provide feedback about the PR?

If any boxes above are checked the QA team will be automatically added as a PR reviewer.

Backports

N/A

@noellie-velez noellie-velez changed the title refactor: use InternalHasAuthority() for all internal authority checks in NetworkObject refactor: use InternalHasAuthority() for internal self-calls in NetworkObject Jun 11, 2026
Update it on Spawn, InvokeBehaviourOnOwnershipChanged and ResetOnDespawn
@noellie-velez noellie-velez changed the title refactor: use InternalHasAuthority() for internal self-calls in NetworkObject refactor: cache HasAuthority to avoid recomputing it on every access Jun 15, 2026
@noellie-velez noellie-velez marked this pull request as ready for review June 15, 2026 16:51
@noellie-velez noellie-velez requested a review from a team as a code owner June 15, 2026 16:51
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.

1 participant