diff --git a/src/game/shared/achievementmgr.cpp b/src/game/shared/achievementmgr.cpp index 66c5e9c3e..edf7d5164 100644 --- a/src/game/shared/achievementmgr.cpp +++ b/src/game/shared/achievementmgr.cpp @@ -141,7 +141,11 @@ static void WriteAchievementGlobalState( KeyValues *pKV, bool bPersistToSteamClo if (pData) { // Read in the data from the file system GameState.txt file +#ifdef NEO + FileHandle_t handle = filesystem->Open(szFilename, "rb"); +#else FileHandle_t handle = filesystem->Open(szFilename, "r"); +#endif if (handle) { @@ -154,6 +158,12 @@ static void WriteAchievementGlobalState( KeyValues *pKV, bool bPersistToSteamClo // Write out the data to steam cloud pRemoteStorage->FileWrite(szFilename, pData, filesize); } +#ifdef NEO + else + { + Warning("CAchievementMgr: Failed to write to steam cloud! Expected size %d got size %d\n", filesize, nRead); + } +#endif } // Delete the data array diff --git a/src/game/shared/achievementmgr.h b/src/game/shared/achievementmgr.h index c33261e2d..7a990fbf7 100644 --- a/src/game/shared/achievementmgr.h +++ b/src/game/shared/achievementmgr.h @@ -34,7 +34,11 @@ class CAchievementMgr : public CAutoGameSystemPerFrame, public CGameEventListene SteamCloudPersist_On, }; +#ifdef NEO + CAchievementMgr( SteamCloudPersisting ePersistToSteamCloud = SteamCloudPersist_On ); +#else CAchievementMgr( SteamCloudPersisting ePersistToSteamCloud = SteamCloudPersist_Off ); +#endif //============================================================================= // HPE_END diff --git a/src/game/shared/baseachievement.cpp b/src/game/shared/baseachievement.cpp index ebc5876ec..bfe61ab15 100644 --- a/src/game/shared/baseachievement.cpp +++ b/src/game/shared/baseachievement.cpp @@ -519,6 +519,25 @@ void CBaseAchievement::SetComponentBits( uint64 iComponentBits ) iComponentBits >>= 1; } m_iCount = iNumBitsSet; + +#ifdef NEO +#ifndef NO_STEAM + // 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", GetStat() ); + bool bRet = steamapicontext->SteamUserStats()->SetStat( pszProgressName, m_iCount ); + if ( !bRet ) + { + DevMsg( "ISteamUserStats::GetStat failed to set progress value in Steam for achievement %s\n", pszProgressName ); + } + + m_pAchievementMgr->SetDirty( true ); + } +#endif // NO_STEAM +#endif // NEO } //----------------------------------------------------------------------------- diff --git a/src/game/shared/baseachievement.h b/src/game/shared/baseachievement.h index 355185a0c..32681b411 100644 --- a/src/game/shared/baseachievement.h +++ b/src/game/shared/baseachievement.h @@ -31,7 +31,11 @@ class CBaseAchievement : public CGameEventListener, public IAchievement virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event ); int GetAchievementID() { return m_iAchievementID; } +#ifdef NEO // NEO NOTE DG: Must be larger than 0. ALWAYS! + void SetAchievementID( int iAchievementID ) { Assert( iAchievementID > 0 ); m_iAchievementID = iAchievementID; } +#else void SetAchievementID( int iAchievementID ) { m_iAchievementID = iAchievementID; } +#endif void SetName( const char *pszName ) { m_pszName = pszName; } const char *GetName() { return m_pszName; } const char *GetStat() { return m_pszStat?m_pszStat:GetName(); } diff --git a/src/game/shared/neo/achievements_neo.cpp b/src/game/shared/neo/achievements_neo.cpp index e3c5fba38..caef7bf89 100644 --- a/src/game/shared/neo/achievements_neo.cpp +++ b/src/game/shared/neo/achievements_neo.cpp @@ -18,6 +18,7 @@ class CAchievementNEO_TutorialComplete : public CBaseAchievement SetFlags( ACH_SAVE_GLOBAL | ACH_HAS_COMPONENTS | ACH_LISTEN_COMPONENT_EVENTS ); SetGoal( m_iNumComponents ); SetMapNameFilter( "ntre_class_tut" ); + SetStoreProgressInSteam( true ); } }; DECLARE_NEO_ACHIEVEMENT( CAchievementNEO_TutorialComplete, ACHIEVEMENT_NEO_TUTORIAL_COMPLETE, "NEO_TUTORIAL_COMPLETE" ); diff --git a/src/game/shared/neo/neo_enums.h b/src/game/shared/neo/neo_enums.h index b2f4dbc9f..88974ef10 100644 --- a/src/game/shared/neo/neo_enums.h +++ b/src/game/shared/neo/neo_enums.h @@ -56,7 +56,8 @@ static const constexpr short NEO_ENVIRON_KILLED = -1; enum NeoAchievementID { - ACHIEVEMENT_NEO_TUTORIAL_COMPLETE = 0, + // Must start greater than 0 always + ACHIEVEMENT_NEO_TUTORIAL_COMPLETE = 1, ACHIEVEMENT_NEO_TRIAL_50_SECONDS, ACHIEVEMENT_NEO_TRIAL_40_SECONDS, };