Skip to content

Conversation

@MrBrax
Copy link
Contributor

@MrBrax MrBrax commented Feb 12, 2026

Introduce NetFlags.SkipCaller and update RPC dispatch to skip local execution when the flag is set.
Added a SkipCaller enum entry with documentation and early-return checks in Rpc.StaticRpc.cs and Rpc.InstanceRpc.cs so RPCs with this flag are still sent to remote recipients but not executed on the caller (useful for cases like dedicated servers broadcasting sounds).

Pull Request

Thanks for contributing to s&box ❤️
Please fill out the sections below to help us review your change efficiently.


Summary

Adds a flag to Rpc that makes the call not execute on host, only on the other targets.

Motivation & Context

I do a lot of particle and sound broadcasts, there's no point spawning these on the host (dedicated server), and adding Rpc.FilterExclude for the host each time is really messy.

Fixes:

Implementation Details

vibe coded but tested, thanks claude

Screenshots / Videos (if applicable)

2026-02-12 21 58 55
[Rpc.Broadcast(NetFlags.HostOnly | NetFlags.SkipCaller)]
private void BroadcastMessage()
{
	Log.Info( "Broadcasting message to all clients except host." );
}

protected override void OnUpdate()
{
	if ( Input.Pressed( "jump" ) )
	{
		Log.Info( "Jump pressed, broadcasting message to clients." );
		BroadcastMessage();
	}

}

Checklist

  • Code follows existing style and conventions
  • No unnecessary formatting or unrelated changes
  • Public APIs are documented (if applicable)
  • Unit tests added where applicable and all passing
  • I’m okay with this PR being rejected or requested to change 🙂

Introduce NetFlags.SkipCaller and update RPC dispatch to skip local execution when the flag is set. Added a SkipCaller enum entry with documentation and early-return checks in Rpc.StaticRpc.cs and Rpc.InstanceRpc.cs so RPCs with this flag are still sent to remote recipients but not executed on the caller (useful for cases like dedicated servers broadcasting sounds).
Copilot AI review requested due to automatic review settings February 12, 2026 21:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new NetFlags.SkipCaller bit to support RPCs that still send to normal remote recipients but intentionally do not execute on the machine that initiated the call (useful for dedicated-server-originated broadcasts like effects/sounds).

Changes:

  • Added NetFlags.SkipCaller = 64 with XML documentation.
  • Updated static RPC dispatch to early-return (skip local execution) when SkipCaller is set.
  • Updated instance RPC dispatch (system + component overloads) with the same early-return behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
engine/Sandbox.Engine/Systems/Networking/System/NetworkEnums.cs Introduces the NetFlags.SkipCaller enum value and documents intended behavior.
engine/Sandbox.Engine/Scene/Networking/Rpc.StaticRpc.cs Skips local static RPC execution for the initiating caller when SkipCaller is present.
engine/Sandbox.Engine/Scene/Networking/Rpc.InstanceRpc.cs Skips local instance RPC execution (both overloads) for the initiating caller when SkipCaller is present.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +41 to +42
/// When set, the caller will not execute the RPC method locally. The message is still sent to
/// all remote recipients as normal. This is useful when broadcasting sounds from a dedicated server,
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

The XML doc for SkipCaller says the RPC is still sent to "all remote recipients". Since NetFlags are used across different RpcMode/filters, this reads like it always broadcasts; consider rewording to clarify it skips only local execution while sending proceeds to the normal recipients (respecting RpcMode/filters).

Suggested change
/// When set, the caller will not execute the RPC method locally. The message is still sent to
/// all remote recipients as normal. This is useful when broadcasting sounds from a dedicated server,
/// When set, the caller will not execute the RPC method locally. The RPC is still sent to its
/// normal remote recipients according to the current RpcMode/filters; this flag only affects local
/// execution on the calling peer. This is useful when broadcasting sounds from a dedicated server,

Copilot uses AI. Check for mistakes.
SendStaticRpc( m, argumentList, attribute );
}

// Caller already handled this locally
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

This inline comment is inaccurate: when SkipCaller is set, the caller is intentionally not executing the RPC locally. Please adjust the comment to reflect that local execution is being skipped (while the RPC may still have been sent to remote recipients above).

Suggested change
// Caller already handled this locally
// Skip executing the RPC locally for the caller when SkipCaller is set

Copilot uses AI. Check for mistakes.
SendInstanceRpc( system, m, argumentList, attribute );
}

// Caller already handled this locally
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

This inline comment is inaccurate: when SkipCaller is set, the caller is intentionally not executing the RPC locally. Please adjust the comment to reflect that local execution is being skipped (while the RPC may still have been sent to remote recipients above).

Suggested change
// Caller already handled this locally
// Skip local execution for the caller when SkipCaller is set (RPC may still have been sent to remote recipients above)

Copilot uses AI. Check for mistakes.
SendInstanceRpc( go, component, m, argumentList, attribute );
}

// Caller already handled this locally
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

This inline comment is inaccurate: when SkipCaller is set, the caller is intentionally not executing the RPC locally. Please adjust the comment to reflect that local execution is being skipped (while the RPC may still have been sent to remote recipients above).

Suggested change
// Caller already handled this locally
// Skip executing this RPC locally on the caller when requested

Copilot uses AI. Check for mistakes.
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