-
Notifications
You must be signed in to change notification settings - Fork 20
Store achievement progress in steam cloud #1622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Technically not an error in |
||
| } | ||
| #endif | ||
| } | ||
|
|
||
| // Delete the data array | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Comment on lines
+37
to
+41
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Opinionated, but perhaps instead of modifying the base SDK constructor defaults, it might be cleaner to instantiate our NEO-specific instance with the desired value: diff --git a/src/game/shared/achievementmgr.h b/src/game/shared/achievementmgr.h
index 7a990fbf..c33261e2 100644
--- a/src/game/shared/achievementmgr.h
+++ b/src/game/shared/achievementmgr.h
@@ -34,11 +34,7 @@ public:
SteamCloudPersist_On,
};
-#ifdef NEO
- CAchievementMgr( SteamCloudPersisting ePersistToSteamCloud = SteamCloudPersist_On );
-#else
CAchievementMgr( SteamCloudPersisting ePersistToSteamCloud = SteamCloudPersist_Off );
-#endif
//=============================================================================
// HPE_END
diff --git a/src/game/shared/neo/achievements_neo.cpp b/src/game/shared/neo/achievements_neo.cpp
index caef7bf8..b6a005ff 100644
--- a/src/game/shared/neo/achievements_neo.cpp
+++ b/src/game/shared/neo/achievements_neo.cpp
@@ -2,7 +2,7 @@
#ifdef CLIENT_DLL
#include "achievements_neo.h"
-CAchievementMgr g_AchievementMgrNEO; // global achievement mgr for NEO
+CAchievementMgr g_AchievementMgrNEO(CAchievementMgr::SteamCloudPersist_On); // global achievement mgr for NEO
class CAchievementNEO_TutorialComplete : public CBaseAchievement
{But if you prefer this way, I'm ok with that too, so I don't necessarily require a change here. |
||
|
|
||
| //============================================================================= | ||
| // HPE_END | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 ); | ||
|
Comment on lines
+531
to
+534
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possibly a typo in the Also maybe we want |
||
| } | ||
|
|
||
| m_pAchievementMgr->SetDirty( true ); | ||
| } | ||
| #endif // NO_STEAM | ||
| #endif // NEO | ||
| } | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to open the text file in binary mode? Encoding related?