SDT0604: RPC Non Replicable Target
| Property | Value |
|---|---|
| Rule ID | SDT0604 |
| Title | RPC Non Replicable Target |
| Category | Network |
| Severity | Error |
Cause
An instance (non-static) method is decorated with [RPC], but the enclosing class is missing the [Replicate] attribute.
Rule Description
Instance RPCs run on specific network objects. For the network layer to route an RPC to a specific object instance, that entire class must be marked with [Replicate] so it has a valid network network identity tracking it.
How to Fix Violations
Either mark the method as static (if it does not rely on object instances) or add the [Replicate] attribute to the class definition.
Violation:
public class CombatHandler : PropScript
{
[RPC(PacketBroadcast.Multicast)]
public void RPC_DealDamage(int amount) { }
}
Fix:
[Replicate]
public class CombatHandler : PropScript
{
[RPC(PacketBroadcast.Multicast)]
public void RPC_DealDamage(int amount) { }
}
When to Suppress Warnings
Danger
Do not suppress this error. An instance RPC on a non-replicated class has no way of determining which instance the network message belongs to.