For anyone following along
To trace this further I need to step through the logic of UWorld::NotifyControlMessage and UWorld::DestroySwappedPC to understand why DestroySwappedPC is returning false.
Here is my reasoning case someone has a better idea
In this code here
UNetConnection* SwapConnection = Connection;
int32 ChildIndex;
if (FNetControlMessage<NMT_PCSwap>::Receive(Bunch, ChildIndex))
{
if (ChildIndex >= 0)
{
SwapConnection = Connection->Children.IsValidIndex(ChildIndex) ? ToRawPtr(Connection->Children[ChildIndex]) : nullptr;
}
bool bSuccess = false;
if (SwapConnection != nullptr)
{
bSuccess = DestroySwappedPC(SwapConnection);
}
if (!bSuccess)
{
UE_LOG(LogNet, Log, TEXT("Received invalid swap message with child index %i"), ChildIndex);
}
}
I know the only way I could see the message Received invalid swap message with child index -1
Is if ChildIndex >= 0 is false … so we did not set SwapConnection to nullptr
There for If(SwapConnection != nullptr is true and we called DestroySwappedPC
That must have returned false for us to get that log message. That can only have returned false if none of the player controllers (which I know there are 2 on the server at this time) had a matching Connection listed in the PendingSwapConnection
So is it that PendingSwapConnection is nullptr … or is it that the connection we are testing isn’t the same e.g. we have an orphaned connection or something? … not sure
I’ll also want to debug AGameModeBase::SwapPlayerControllers as far as I can tell this is where PendingSwapConnection is set, there would be a SwapPlayerControllers warning message if this was somehow invalid and I don’t see that so I am guessing this doesn’t fail … so why isn’t PendingSwapConnection that is being set here the same as the one being tested for in DestroySwappedPC hoping to see the values that are set there and to confirm they are set the way I think they are will shed some light on that
I am assuming it is something I am doing wrong in my NetDriver or rather something else I need aside from the NetDriver and Connection since my custom NetDriver and Connection are really close to identical to the builtin ones for SteamSocket.
I am also working on setting up the same test but using the built in OSS Steam and its driver … really not a fan of OSS so procrastinating on that
hoping I find my issue without bothering