//----------------------------------------------------------------------------- // Purpose: called when an event that counts toward an achievement occurs //----------------------------------------------------------------------------- void CBaseAchievement::IncrementCount() { if ( !IsAchieved() ) { if ( !m_pAchievementMgr->CheckAchievementsEnabled() ) { Msg( "Achievements disabled, ignoring achievement progress for %s\n", GetName() ); return; } // on client, where the count is kept, increment count m_iCount++; // if this achievement gets saved w/global state, flag our global state as dirty if ( GetFlags() & ACH_SAVE_GLOBAL ) { m_pAchievementMgr->SetDirty( true ); } if ( cc_achievement_debug.GetInt() ) { Msg( "Achievement count increased for %s: %d/%d\n", GetName(), m_iCount, m_iGoal ); } // if this achievement's progress should be stored in Steam, set the steam stat for it if ( StoreProgressInSteam() && steamapicontext->SteamUserStats() ) { // Set the Steam stat with the same name as the achievement. Only cached locally until we upload it. char pszProgressName[1024]; Q_snprintf( pszProgressName, 1024, "%s_STAT", GetName() ); bool bRet = steamapicontext->SteamUserStats()->SetStat( CGameID( engine->GetAppID() ), pszProgressName, m_iCount ); if ( !bRet ) { DevMsg( "ISteamUserStats::GetStat failed to set progress value in Steam for achievement %s\n", pszProgressName ); } // Upload user data to commit the change to Steam so if the client crashes, progress isn't lost. // Only upload if we haven't uploaded recently, to keep us from spamming Steam with uploads. If we don't // upload now, it will get uploaded no later than level shutdown. if ( ( m_pAchievementMgr->GetTimeLastUpload() == 0 ) || ( Plat_FloatTime() - m_pAchievementMgr->GetTimeLastUpload() > 60 * 15 ) ) { m_pAchievementMgr->UploadUserData(); } } // if we've hit goal, award the achievement if ( m_iGoal > 0 ) { if ( m_iCount >= m_iGoal ) { AwardAchievement(); } else { HandleProgressUpdate(); } } } }
//----------------------------------------------------------------------------- // Purpose: Get the steam3 logon cookie to use //----------------------------------------------------------------------------- int CSteam3Client::InitiateConnection( void *pData, int cbMaxData, uint32 unIP, uint16 usPort, uint64 unGSSteamID, bool bSecure, void *pvSteam2GetEncryptionKey, int cbSteam2GetEncryptionKey ) { m_bGSSecure = bSecure; #if !defined( NO_STEAM ) if ( !SteamUser() ) return 0; return SteamUser()->InitiateGameConnection( pData, cbMaxData, unGSSteamID, CGameID( g_iSteamAppID ), ntohl( unIP ), usPort, bSecure, pvSteam2GetEncryptionKey, cbSteam2GetEncryptionKey ); // port is already in host order #else return 0; #endif }
void CUser::TrackAppUsageEvent( GameID gameID, s32 appUsageEvent, PConstantString extraInfo) { user->TrackAppUsageEvent( CGameID(gameID), appUsageEvent, extraInfo ); }