export
void UnlockDotaPlus()//invoke from main thread
{
const auto* SOCachePtr = GCClient::GetInstance()->GetInventorySOCache();
if (SOCachePtr) {
auto PlusCache = SOCachePtr->GetPlusAccountCache();
Logger::LogInfo("SOTypeCache GameAccountPlus Cache 0x%p\n", PlusCache);
if (PlusCache) {
for (const auto& objs = PlusCache->GetObjects(); const auto & obj : objs)
{
if (obj->IsGameAccountPlus())
{
Logger::LogInfo("SOTypeCache GameAccountPlus 0x%p\n", obj);
auto& accountProto = static_cast<CDOTAGameAccountPlus*>(obj)->GetProto();
accountProto.set_plus_flags(0);
accountProto.set_plus_status(1);//0 = lock, 1 = unlock
GCClient::GetInstance()->
DispatchSOUpdate(
SOCachePtr->GetOwner(),
obj,
ESOCacheEvent::eSOCacheEvent_Incremental
);
return;
}
}
Logger::LogError("UnlockDotaPlus: Could not get GameAccountPlus from cache");
}
else Logger::LogError("UnlockDotaPlus: PlusCache is nullptr");
}
else Logger::LogError("UnlockDotaPlus: SOCache is nullptr");
throw std::runtime_error{"UnlockDotaPlus -> failed to unlock dota plus."};
}