Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/game/shared/achievementmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Copy link
Collaborator

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?

#else
FileHandle_t handle = filesystem->Open(szFilename, "r");
#endif

if (handle)
{
Expand All @@ -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);
Copy link
Collaborator

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

}
#endif
}

// Delete the data array
Expand Down
4 changes: 4 additions & 0 deletions src/game/shared/achievementmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

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.


//=============================================================================
// HPE_END
Expand Down
19 changes: 19 additions & 0 deletions src/game/shared/baseachievement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

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.

}

m_pAchievementMgr->SetDirty( true );
}
#endif // NO_STEAM
#endif // NEO
}

//-----------------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions src/game/shared/baseachievement.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand Down
1 change: 1 addition & 0 deletions src/game/shared/neo/achievements_neo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down
3 changes: 2 additions & 1 deletion src/game/shared/neo/neo_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};