//========================================================================= // // PlayerProfile.cpp // //========================================================================= #include "PlayerProfile.hpp" #include "../../Apps/GameApp/Config.hpp" #include "MemCardMgr/MemCardMgr.hpp" //========================================================================= // Player Profile Functions //========================================================================= player_profile::player_profile( void ) { Reset(); } void player_profile::Reset( void ) { s32 i=0; x_memset( this, 0, sizeof(this) ); if( CONFIG_IS_AUTOSERVER ) { x_strcpy( m_pProfileName, "Server" ); } if( CONFIG_IS_AUTOCLIENT ) { x_strcpy( m_pProfileName, "Client" ); } m_Version = PROFILE_VERSION_NUMBER; m_HashString = 0; m_AvatarID = 0; m_Sensitivity[0] = 50; m_Sensitivity[1] = 50; m_LoreTotal = 0; m_bNewLoreUnlocked = FALSE; m_NumSecretsUnlocked = 0; m_bNewSecretUnlocked = FALSE; m_bInvertY = TRUE; m_bVibration = TRUE; m_bCrouchOn = FALSE; m_bLookspringOn = FALSE; m_bIsVisibleOnline = TRUE; m_bAutosaveOn = TRUE; m_bAlienAvatarsOn = FALSE; m_UniqueIdLength = 0; m_CinemaMutatedMsgCount = 3; m_bIsMutated = FALSE; m_DifficultyLevel = 1; // medium difficulty by default m_bWeaponAutoSwitch = TRUE; // if on/true, will auto-switch to a weapon with a > rating (default is TRUE) m_bSecretAwarded = FALSE; m_bHardUnlocked = FALSE; m_bDifficultyChanged = FALSE; m_bGameFinished = FALSE; #ifdef TARGET_XBOX // always set to true on xbox because if the // player has a Live account, age is verified! m_bAgeVerified = TRUE; #else m_bAgeVerified = FALSE; #endif // Clear lore collected for( i=0; iMapID == MapID ) { // found it! return pCheckpoint; } else if( pCheckpoint->MapID == -1 ) { // no checkpoint for this MapID return NULL; } } // ran out of checkpoints! ASSERT( FALSE ); return NULL; } //========================================================================= void player_profile::Checksum( void ) { m_Checksum = 0; m_Checksum = x_chksum( this, sizeof(player_profile) ); } //========================================================================= xbool player_profile::Validate( void ) { s32 DesiredChecksum; s32 ActualChecksum; DesiredChecksum = m_Checksum; m_Checksum = 0; ActualChecksum = x_chksum( this, sizeof(player_profile) ); m_Checksum = DesiredChecksum; return (ActualChecksum == DesiredChecksum); } //========================================================================= // This is just a changed name for the validate function. We may put some // additional checks to see if this profile has been modified. xbool player_profile::HasChanged( void ) { return Validate()==FALSE; } //========================================================================= void player_profile::MarkDirty( void ) { m_Checksum = 0; } //========================================================================= void player_profile::SetUniqueId( const byte* pUniqueId, s32 Length ) { x_memset( m_UniqueId, 0, sizeof(m_UniqueId) ); if( Length >= sizeof(m_UniqueId) ) { Length = sizeof(m_UniqueId)-1; } x_memcpy( m_UniqueId, pUniqueId, Length ); m_UniqueIdLength = Length; } //========================================================================= const byte* player_profile::GetUniqueId( s32& Length ) { Length = m_UniqueIdLength; return m_UniqueId; } //========================================================================= xbool player_profile::DisplayCinemaMutatedMsg( void ) { if( m_CinemaMutatedMsgCount > 0 ) { m_CinemaMutatedMsgCount--; return TRUE; } return FALSE; } //========================================================================= #ifndef CONFIG_RETAIL void player_profile::UnlockAll( void ) { // this function will unlock everything EXCEPT the checkpoints // unlock all lore for( s32 i=0; i