StatisticManager::SetStatisticIntegerData throws a “User not found in local map” exception:
The code is fairly straightforward:
bool FOnlineLeaderboardsLive::WriteLeaderboards(const FName& SessionName, const FUniqueNetId& PlayerId, FOnlineLeaderboardWrite& WriteObject)
{
UNREFERENCED_PARAMETER(SessionName);
if (!LiveSubsystem)
return false;
const FOnlineIdentityLivePtr Identity = LiveSubsystem->GetIdentityLive();
if (!Identity.IsValid())
return false;
const FUniqueNetIdLive UserLive(PlayerId);
Windows::Xbox::System::User^ XBoxUser = Identity->GetUserForUniqueNetId(UserLive);
Microsoft::Xbox::Services::XboxLiveContext^ LiveContext = LiveSubsystem->GetLiveContext(XBoxUser);
if (LiveContext == nullptr)
return false;
Microsoft::Xbox::Services::Statistics::Manager::StatisticManager^ mgr = Microsoft::Xbox::Services::Statistics::Manager::StatisticManager::SingletonInstance;
if (mgr != nullptr)
{
for (FStatPropertyArray::TConstIterator item(WriteObject.Properties); item; ++item)
{
Platform::String^ itemName = ref new Platform::String(*item->Key.GetPlainNameString());
int32 itemValue;
item->Value.GetValue(itemValue);
long long llValue;
llValue = itemValue;
mgr->SetStatisticIntegerData(LiveContext->User, itemName, llValue);
}
mgr->RequestFlushToService(LiveContext->User);
return true;
}
return false;
}
Am I using the call to GetLiveContext with the user correctly?
I’ve also tried using LiveSubsystem->GetDefaultLiveContext() but that didn’t work either.
Any help is appreciated.