forked from hitmen047/Source-PlusPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasepresence_xbox.cpp
167 lines (147 loc) · 5.37 KB
/
basepresence_xbox.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
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" );
}
}