-
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?
Store achievement progress in steam cloud #1622
Conversation
| 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 ); |
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.
Possibly a typo in the DevMsg method name (The print message says GetStat but the bRet error originated from the SetStat call)
Also maybe we want DevWarning instead of DevMsg, since this is something going wrong.
| #ifdef NEO | ||
| else | ||
| { | ||
| Warning("CAchievementMgr: Failed to write to steam cloud! Expected size %d got size %d\n", filesize, nRead); |
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.
Nit: Technically not an error in CAchievementMgr, since we're inside the free-standing static function WriteAchievementGlobalState. Perhaps instead format as Warning("%s: ...", __FUNCTION__, where __FUNCTION__ will be automatically substituted by the current function name by the compiler
| { | ||
| // Read in the data from the file system GameState.txt file | ||
| #ifdef NEO | ||
| FileHandle_t handle = filesystem->Open(szFilename, "rb"); |
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?
| #ifdef NEO | ||
| CAchievementMgr( SteamCloudPersisting ePersistToSteamCloud = SteamCloudPersist_On ); | ||
| #else | ||
| CAchievementMgr( SteamCloudPersisting ePersistToSteamCloud = SteamCloudPersist_Off ); | ||
| #endif |
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.
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.
Description
This fixes achievement progress being removed on game restart and should allow for achievement progress to be saved across systems. This also improves communication with the steam stats API for component type achievements
Toolchain
Linked Issues