diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/client/basepresence_xbox.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/client/basepresence_xbox.cpp')
| -rw-r--r-- | game/client/basepresence_xbox.cpp | 167 |
1 files changed, 167 insertions, 0 deletions
diff --git a/game/client/basepresence_xbox.cpp b/game/client/basepresence_xbox.cpp new file mode 100644 index 0000000..96adca9 --- /dev/null +++ b/game/client/basepresence_xbox.cpp @@ -0,0 +1,167 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Base rich presence implementation for Xbox360 +// +//=====================================================================================// + +#include "cbase.h" +#include "basepresence.h" +#include "cdll_client_int.h" +#include "ixboxsystem.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +// Default global instance. Mods should override this. +static CBasePresence s_basePresence; +IPresence *presence = NULL; + +//----------------------------------------------------------------------------- +// Purpose: Init +//----------------------------------------------------------------------------- +bool CBasePresence::Init( void ) +{ + if ( !presence ) + { + // Mod didn't override, default to base implementation + presence = &s_basePresence; + } + return true; +} + + +//----------------------------------------------------------------------------- +// Purpose: Shutdown +//----------------------------------------------------------------------------- +void CBasePresence::Shutdown( void ) +{ + // Do nothing +} + + +//----------------------------------------------------------------------------- +// Purpose: Per-frame update +//----------------------------------------------------------------------------- +void CBasePresence::Update( float frametime ) +{ + // Do nothing +} + + +//----------------------------------------------------------------------------- +// Contexts are strings that describe the current state of the game. +//----------------------------------------------------------------------------- +void CBasePresence::UserSetContext( unsigned int nUserIndex, unsigned int nContextId, unsigned int nContextValue, bool bAsync ) +{ + if ( !xboxsystem->UserSetContext( nUserIndex, nContextId, nContextValue, bAsync ) ) + { + Warning( "CBasePresence: UserSetContext failed.\n" ); + } +} + + +//----------------------------------------------------------------------------- +// Properties are (usually) numeric values that can be insterted into context strings. +//----------------------------------------------------------------------------- +void CBasePresence::UserSetProperty( unsigned int nUserIndex, unsigned int nPropertyId, unsigned int nBytes, const void *pvValue, bool bAsync ) +{ + if ( !xboxsystem->UserSetProperty( nUserIndex, nPropertyId, nBytes, pvValue, bAsync ) ) + { + Warning( "CBasePresence: UserSetProperty failed.\n" ); + } +} + +//----------------------------------------------------------------------------- +// Get game session properties from matchmaking. +//----------------------------------------------------------------------------- +void CBasePresence::SetupGameProperties( CUtlVector< XUSER_CONTEXT > &contexts, CUtlVector< XUSER_PROPERTY > &properties ) +{ + Assert( 0 ); +} + +//----------------------------------------------------------------------------- +// Convert a string to a presence ID. +//----------------------------------------------------------------------------- +uint CBasePresence::GetPresenceID( const char *pIdName ) +{ + Assert( 0 ); + return 0; +} + +//----------------------------------------------------------------------------- +// Convert a presence ID to a string. +//----------------------------------------------------------------------------- +const char *CBasePresence::GetPropertyIdString( const uint id ) +{ + Assert( 0 ); + return NULL; +} + +//----------------------------------------------------------------------------- +// Get display string for a game property. +//----------------------------------------------------------------------------- +void CBasePresence::GetPropertyDisplayString( uint id, uint value, char *pOutput, int nBytes ) +{ + Assert( 0 ); +} + +//----------------------------------------------------------------------------- +// Set up for reporting stats to Live. +//----------------------------------------------------------------------------- +void CBasePresence::StartStatsReporting( HANDLE handle, bool bArbitrated ) +{ + m_bArbitrated = bArbitrated; + m_hSession = handle; + m_bReportingStats = true; + m_PlayerStats.RemoveAll(); +} + +//----------------------------------------------------------------------------- +// Set a specific stat property. +//----------------------------------------------------------------------------- +void CBasePresence::SetStat( uint iPropertyId, int iPropertyValue, int dataType ) +{ + if ( m_bReportingStats ) + { + XUSER_PROPERTY prop; + prop.dwPropertyId = iPropertyId; + prop.value.nData = iPropertyValue; + prop.value.type = dataType; + m_PlayerStats.AddToTail( prop ); + } +} + +//----------------------------------------------------------------------------- +// Upload the stats to Live. +//----------------------------------------------------------------------------- +void CBasePresence::UploadStats() +{ + Assert( 0 ); +} + +//--------------------------------------------------------- +// Debug support +//--------------------------------------------------------- +void CBasePresence::DebugUserSetContext( const CCommand &args ) +{ + if ( args.ArgC() == 3 ) + { + UserSetContext( XBX_GetPrimaryUserId(), atoi( args.Arg( 1 ) ), atoi( args.Arg( 2 ) ) ); + } + else + { + Warning( "user_context <context id> <context value>\n" ); + } +} +void CBasePresence::DebugUserSetProperty( const CCommand &args ) +{ + if ( args.ArgC() == 3 ) + { + int value = atoi( args.Arg( 2 ) ); + UserSetProperty( XBX_GetPrimaryUserId(), strtoul( args.Arg( 1 ), NULL, 0 ), sizeof(int), &value ); + } + else + { + Warning( "user_property <property id> <property value>\n" ); + } +} |