Using UWorld::GetFirstPlayerController to check if the player controller is the local player

So, I’ve been investigating methods to find if the local player is controlling the current player pawn. It’s quite easy on dedicated servers since clients only have one player controller - the one they currently control - but on non dedicated servers where the player is hosting as well as playing it’s a little more difficult because the server has player controllers for each pawn. The solution that I currently am working with is to check if UWorld::GetFirstPlayerController is the one that’s controlling the pawn, which works out great in testing, but after reading the source of the function it just pulls the first one off the top of an array. Can I assume this method is safe? Is there a better way to find the locally controlled player on a server?

Edit:
After some more investigation, I found GEngine->GetGamePlayer(), which I then use to check if the pawn’s controller is the ULocalPlayer’s controller. I now have a function in my player character class that goes like so:

bool AALastWatchPlayerCharacter::IsLocalPlayer()
{
	if (Controller)
	{
		return GEngine->GetGamePlayer(GetWorld(), 0)->PlayerController == Cast<APlayerController>(Controller);
	}
	
	return false;
}

After some more investigation, I found GEngine->GetGamePlayer(), which I then use to check if the pawn’s controller is the ULocalPlayer’s controller. I now have a function in my player character class that goes like so:

bool AALastWatchPlayerCharacter::IsLocalPlayer()
{
	if (Controller)
	{
		return GEngine->GetGamePlayer(GetWorld(), 0)->PlayerController == Cast<APlayerController>(Controller);
	}
	
	return false;
}