void CGameAchievements::GiveAchievement(int achievement)
{
	if(AllowAchievement())
	{
		CPersistantStats::GetInstance()->OnGiveAchievement(achievement);

		ICryLobby* pLobby = gEnv->pNetwork->GetLobby();
		IPlatformOS* pOS = gEnv->pSystem->GetPlatformOS();
		if(pLobby != NULL && pOS != NULL)
		{
			ICryReward* pReward = pLobby->GetReward();
			if(pReward)
			{
				unsigned int user = g_pGame->GetExclusiveControllerDeviceIndex();
				if(user != IPlatformOS::Unknown_User)
				{
					uint32 achievementId = achievement + ACHIEVEMENT_STARTINDEX;

					//-- Award() only puts awards into a queue to be awarded.
					//-- This code here only asserts that the award was added to the queue successfully, not if the award was successfully unlocked.
					//-- Function has been modified for a CryLobbyTaskId, callback and callback args parameters, similar to most other lobby functions,
					//-- to allow for callback to trigger when the award is successfully unlocked (eCLE_Success) or failed to unlock (eCLE_InternalError).
					//-- In the case of trying to unlock an award that has already been unlocked, the callback will return eCLE_Success.
					//-- Successful return value of the Award function has been changed from incorrect eCRE_Awarded to more sensible eCRE_Queued.
					CRY_TODO(3,9,2010, "Register a callback to inform game when queued award is processed successfully or failed.");

					ECryRewardError error = pReward->Award(user, achievementId, NULL, NULL, NULL);
					CryLog("Award error %d", error);
					CRY_ASSERT(error == eCRE_Queued);
				}
			}
		}
	}
	else
	{
		CryLog("Not Awarding achievement - have been disabled");
	}
}
Exemple #2
0
void CGameAchievements::GiveAchievement(ECryGameSDKAchievement achievement)
{
	if(AllowAchievement())
	{
		assert(achievement >= 0 && achievement < eA_NumAchievements);

#ifdef GAME_IS_CRYSIS2
		CPersistantStats::GetInstance()->OnGiveAchievement(achievement);
#endif

		ICryLobby* pLobby = gEnv->pNetwork->GetLobby();
		IPlatformOS* pOS = gEnv->pSystem->GetPlatformOS();
		if(pLobby != NULL && pOS != NULL)
		{
			ICryReward* pReward = pLobby->GetReward();
			if(pReward)
			{
				unsigned int user = 0;
#ifdef GAME_IS_CRYSIS2
				unsigned int user = g_pGame->GetExclusiveControllerDeviceIndex();
#endif
				if(user != IPlatformOS::Unknown_User)
				{
					uint32 achievementId = achievement + ACHIEVEMENT_STARTINDEX;

					ECryRewardError error = pReward->Award(user, achievementId, NULL, NULL, NULL);
					CryLog("Award error %d", error);
					CRY_ASSERT(error == eCRE_Queued);
				}
			}
		}
	}
	else
	{
		CryLog("Not Awarding achievement - have been disabled");
	}
}