For classes not in ReplicationGraph, bClassIsSpatialized initializing code throws nullptr

I don’t know much about ReplicationGraph specifics, but when trying to add replicating components to the ShooterCharacter class in the ShooterGame example project in a vanilla 4.24 engine version, I get a nullptr exception at TClassMap<enum EClassRepNodeMapping>::GetChecked(UClass * Class).

The line that essentially fails in ShooterReplicationGraph.cpp is:

const bool bClassIsSpatialized = IsSpatialized(ClassRepNodePolicies.GetChecked(ReplicatedClass));

I know this is a fairly specific example in ShooterGame, but it’s a largely unaltered reference implementation of the UE Replication Graph concept. What is the best practice to either implement Spatialization logic or bypass these nullptrs safely?

1 Like

I solved this by changing the ShooterGame ShooterReplicationGraph.cpp file to include a nullptr check on ClassRepNodePolicies.Get before the call it made to ClassRepNodePolicies.GetChecked above, and defaulted it to false.

This resolved the nullptr exception and defaulted non-specific replication node policies to a bClassIsSpatialized of false.

1 Like