//----------------------------------------------------------------------------- // Purpose: // Input : *pVarName - // sizeofVar - // Output : RecvProp //----------------------------------------------------------------------------- RecvProp RecvPropPredictableId( char *pVarName, int offset, int sizeofVar/*=SIZEOF_IGNORE*/ ) { return RecvPropInt( pVarName, offset, sizeofVar, 0, RecvProxy_IntToPredictableId ); }
RecvProp RecvPropBool( char *pVarName, int offset, int sizeofVar ) { Assert( sizeofVar == sizeof( bool ) ); return RecvPropInt( pVarName, offset, sizeofVar ); }
RecvProp RecvPropEHandle( char *pVarName, int offset, int sizeofVar, RecvVarProxyFn proxyFn ) { return RecvPropInt( pVarName, offset, sizeofVar, 0, proxyFn ); }
DataTableProp PropInt( const char *pVarName, int offset, int sizeofVar, // Handled by SENDINFO macro. int nBits, // Set to -1 to automatically pick (max) number of bits based on size of element. int flags, int rightShift ) { #if !defined (CLIENT_DLL) return SendPropInt( pVarName, offset, sizeofVar, nBits, flags, rightShift ); #else return RecvPropInt( pVarName, offset, sizeofVar, flags ); #endif }
C_TFTeam *pPlayer = (C_TFTeam*)pStruct; if ( pPlayer->m_aObjects.Count() != currentArrayLength ) { pPlayer->m_aObjects.SetSize( currentArrayLength ); } } IMPLEMENT_CLIENTCLASS_DT( C_TFTeam, DT_TFTeam, CTFTeam ) RecvPropInt( RECVINFO( m_nFlagCaptures ) ), RecvPropInt( RECVINFO( m_iRole ) ), RecvPropArray2( RecvProxyArrayLength_TeamObjects, RecvPropInt( "team_object_array_element", 0, SIZEOF_IGNORE, 0, RecvProxy_TeamObjectList ), MAX_PLAYERS * MAX_OBJECTS_PER_PLAYER, 0, "team_object_array" ), END_RECV_TABLE() //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- C_TFTeam::C_TFTeam() { m_nFlagCaptures = 0; } //-----------------------------------------------------------------------------
void RecvProxyArrayLength_AOEGrenArray( void *pStruct, int objectID, int currentArrayLength ) { C_ASW_AOEGrenade_Projectile *pAOEGren = (C_ASW_AOEGrenade_Projectile*)pStruct; if ( pAOEGren->m_hAOETargets.Count() != currentArrayLength ) pAOEGren->m_hAOETargets.SetSize( currentArrayLength ); // update the heal beams pAOEGren->m_bUpdateAOETargets = true; } IMPLEMENT_CLIENTCLASS_DT( C_ASW_AOEGrenade_Projectile, DT_ASW_AOEGrenade_Projectile, CASW_AOEGrenade_Projectile ) RecvPropArray2( RecvProxyArrayLength_AOEGrenArray, RecvPropInt( "aoegren_array_element", 0, SIZEOF_IGNORE, 0, RecvProxy_AOEGrenList ), MAX_PLAYERS, 0, "aoetarget_array" ), RecvPropFloat( RECVINFO( m_flTimeBurnOut ) ), //RecvPropFloat( RECVINFO( m_flTimePulse ) ), RecvPropFloat( RECVINFO( m_flScale ) ), RecvPropBool( RECVINFO( m_bSettled ) ), RecvPropFloat( RECVINFO( m_flRadius ) ), END_RECV_TABLE() // aoegrenades maintain a linked list of themselves, for quick checking for autoaim C_ASW_AOEGrenade_Projectile* g_pHeadAOEGrenade = NULL;
RecvPropVector(RECVINFO(m_vCornerRight)), RecvPropVector(RECVINFO(m_vGoalkickLeft)), RecvPropVector(RECVINFO(m_vGoalkickRight)), RecvPropVector(RECVINFO(m_vPenalty)), RecvPropVector(RECVINFO(m_vGoalCenter)), RecvPropVector(RECVINFO(m_vPenBoxMin)), RecvPropVector(RECVINFO(m_vPenBoxMax)), RecvPropVector(RECVINFO(m_vSixYardBoxMin)), RecvPropVector(RECVINFO(m_vSixYardBoxMax)), RecvPropInt(RECVINFO(m_nForward)), RecvPropInt(RECVINFO(m_nRight)), RecvPropIntWithMinusOneFlag(RECVINFO(m_nCaptainPosIndex)), RecvPropArray2( RecvProxyArrayLength_PlayerArray, RecvPropInt( "player_array_element", 0, SIZEOF_IGNORE, 0, RecvProxy_PlayerList ), MAX_PLAYERS, 0, "player_array" ), RecvPropArray3( RECVINFO_ARRAY(m_szMatchEventPlayers), RecvPropString( RECVINFO(m_szMatchEventPlayers[0]))), RecvPropArray3( RECVINFO_ARRAY(m_eMatchEventTypes), RecvPropInt( RECVINFO(m_eMatchEventTypes[0]))), RecvPropArray3( RECVINFO_ARRAY(m_eMatchEventMatchPeriods), RecvPropInt( RECVINFO(m_eMatchEventMatchPeriods[0]))), RecvPropArray3( RECVINFO_ARRAY(m_nMatchEventSeconds), RecvPropInt( RECVINFO(m_nMatchEventSeconds[0]))), RecvPropArray3( RECVINFO_ARRAY(m_PosNextJoinSeconds), RecvPropInt( RECVINFO(m_PosNextJoinSeconds[0]))), RecvPropInt(RECVINFO(m_RedCards)), RecvPropInt(RECVINFO(m_YellowCards)), RecvPropInt(RECVINFO(m_Fouls)),
{ // Have the regular proxy store the data. RecvProxy_Int32ToInt32( pData, pStruct, pOut ); if ( g_PR ) { g_PR->TeamChanged(); } } IMPLEMENT_CLIENTCLASS_DT_NOBASE(C_PlayerResource, DT_PlayerResource, CPlayerResource) RecvPropArray3( RECVINFO_ARRAY(m_iPing), RecvPropInt( RECVINFO(m_iPing[0]))), RecvPropArray3( RECVINFO_ARRAY(m_iScore), RecvPropInt( RECVINFO(m_iScore[0]))), RecvPropArray3( RECVINFO_ARRAY(m_iDeaths), RecvPropInt( RECVINFO(m_iDeaths[0]))), RecvPropArray3( RECVINFO_ARRAY(m_bConnected), RecvPropInt( RECVINFO(m_bConnected[0]))), RecvPropArray3( RECVINFO_ARRAY(m_iTeam), RecvPropInt( RECVINFO(m_iTeam[0]), 0, RecvProxy_ChangedTeam )), RecvPropArray3( RECVINFO_ARRAY(m_bAlive), RecvPropInt( RECVINFO(m_bAlive[0]))), RecvPropArray3( RECVINFO_ARRAY(m_iHealth), RecvPropInt( RECVINFO(m_iHealth[0]))), RecvPropArray3( RECVINFO_ARRAY(m_iOwnerNumbers), RecvPropInt( RECVINFO(m_iOwnerNumbers[0]))), END_RECV_TABLE() BEGIN_PREDICTION_DATA( C_PlayerResource ) DEFINE_PRED_ARRAY( m_szName, FIELD_STRING, MAX_PLAYERS+1, FTYPEDESC_PRIVATE ), DEFINE_PRED_ARRAY( m_iPing, FIELD_INTEGER, MAX_PLAYERS+1, FTYPEDESC_PRIVATE ), DEFINE_PRED_ARRAY( m_iScore, FIELD_INTEGER, MAX_PLAYERS+1, FTYPEDESC_PRIVATE ), DEFINE_PRED_ARRAY( m_iDeaths, FIELD_INTEGER, MAX_PLAYERS+1, FTYPEDESC_PRIVATE ), DEFINE_PRED_ARRAY( m_bConnected, FIELD_BOOLEAN, MAX_PLAYERS+1, FTYPEDESC_PRIVATE ), DEFINE_PRED_ARRAY( m_iTeam, FIELD_INTEGER, MAX_PLAYERS+1, FTYPEDESC_PRIVATE ), DEFINE_PRED_ARRAY( m_bAlive, FIELD_BOOLEAN, MAX_PLAYERS+1, FTYPEDESC_PRIVATE ), DEFINE_PRED_ARRAY( m_iHealth, FIELD_INTEGER, MAX_PLAYERS+1, FTYPEDESC_PRIVATE ),
RecvProp RecvPropUtlVector( const char *pVarName, // Use RECVINFO_UTLVECTOR to generate these 4. int offset, // Used to generate pData in the function specified in varProxy. int sizeofVar, // The size of each element in the utlvector. ResizeUtlVectorFn fn, EnsureCapacityFn ensureFn, int nMaxElements, // Max # of elements in the array. Keep this as low as possible. RecvProp pArrayProp ) { RecvProp ret; Assert( nMaxElements <= MAX_ARRAY_ELEMENTS ); ret.m_RecvType = DPT_DataTable; ret.m_pVarName = pVarName; ret.SetOffset( 0 ); ret.SetDataTableProxyFn( DataTableRecvProxy_StaticDataTable ); RecvProp *pProps = new RecvProp[nMaxElements+1]; // TODO free that again // Extra data bound to each of the properties. CRecvPropExtra_UtlVector *pExtraData = new CRecvPropExtra_UtlVector; pExtraData->m_nMaxElements = nMaxElements; pExtraData->m_ElementStride = sizeofVar; pExtraData->m_ResizeFn = fn; pExtraData->m_EnsureCapacityFn = ensureFn; pExtraData->m_Offset = offset; if ( pArrayProp.m_RecvType == DPT_DataTable ) pExtraData->m_DataTableProxyFn = pArrayProp.GetDataTableProxyFn(); else pExtraData->m_ProxyFn = pArrayProp.GetProxyFn(); // The first property is datatable with an int that tells the length of the array. // It has to go in a datatable, otherwise if this array holds datatable properties, it will be received last. RecvProp *pLengthProp = new RecvProp; *pLengthProp = RecvPropInt( AllocateStringHelper( "lengthprop%d", nMaxElements ), 0, 0, 0, RecvProxy_UtlVectorLength ); pLengthProp->SetExtraData( pExtraData ); char *pLengthProxyTableName = AllocateUniqueDataTableName( false, "_LPT_%s_%d", pVarName, nMaxElements ); RecvTable *pLengthTable = new RecvTable( pLengthProp, 1, pLengthProxyTableName ); pProps[0] = RecvPropDataTable( "lengthproxy", 0, 0, pLengthTable, DataTableRecvProxy_LengthProxy ); pProps[0].SetExtraData( pExtraData ); // The first element is a sub-datatable. for ( int i = 1; i < nMaxElements+1; i++ ) { pProps[i] = pArrayProp; // copy array element property setting pProps[i].SetOffset( 0 ); // leave offset at 0 so pStructBase is always a pointer to the CUtlVector pProps[i].m_pVarName = s_ClientElementNames[i-1]; // give unique name pProps[i].SetExtraData( pExtraData ); pProps[i].SetElementStride( i-1 ); // Kind of lame overloading element stride to hold the element index, // but we can easily move it into its SetExtraData stuff if we need to. // We provide our own proxy here. if ( pArrayProp.m_RecvType == DPT_DataTable ) { pProps[i].SetDataTableProxyFn( RecvProxy_UtlVectorElement_DataTable ); } else { pProps[i].SetProxyFn( RecvProxy_UtlVectorElement ); } } RecvTable *pTable = new RecvTable( pProps, nMaxElements+1, AllocateUniqueDataTableName( false, "_ST_%s_%d", pVarName, nMaxElements ) ); // TODO free that again ret.SetDataTable( pTable ); return ret; }
#include "cbase.h" #include "run_stats.h" #include "mom_player_shared.h" #include "tier0/memdbgon.h" #ifdef CLIENT_DLL BEGIN_RECV_TABLE_NOBASE(C_MomRunStats, DT_MomRunStats) RecvPropInt(RECVINFO(m_iTotalZones), SPROP_UNSIGNED), //Keypress RecvPropArray3(RECVINFO_ARRAY(m_iZoneJumps), RecvPropInt(RECVINFO(m_iZoneJumps[0]), SPROP_UNSIGNED | SPROP_CHANGES_OFTEN)), RecvPropArray3(RECVINFO_ARRAY(m_iZoneStrafes), RecvPropInt(RECVINFO(m_iZoneStrafes[0]), SPROP_UNSIGNED | SPROP_CHANGES_OFTEN)), //Sync RecvPropArray3(RECVINFO_ARRAY(m_flZoneStrafeSyncAvg), RecvPropFloat(RECVINFO(m_flZoneStrafeSyncAvg[0]), SPROP_CHANGES_OFTEN)), RecvPropArray3(RECVINFO_ARRAY(m_flZoneStrafeSync2Avg), RecvPropFloat(RECVINFO(m_flZoneStrafeSync2Avg[0]), SPROP_CHANGES_OFTEN)), //Time RecvPropArray3(RECVINFO_ARRAY(m_iZoneEnterTick), RecvPropInt(RECVINFO(m_iZoneEnterTick[0]), SPROP_UNSIGNED)), RecvPropArray3(RECVINFO_ARRAY(m_iZoneTicks), RecvPropInt(RECVINFO(m_iZoneTicks[0]), SPROP_UNSIGNED)), //Velocity RecvPropArray3(RECVINFO_ARRAY(m_flZoneEnterSpeed3D), RecvPropFloat(RECVINFO(m_flZoneEnterSpeed3D[0]))), RecvPropArray3(RECVINFO_ARRAY(m_flZoneEnterSpeed2D), RecvPropFloat(RECVINFO(m_flZoneEnterSpeed2D[0]))), RecvPropArray3(RECVINFO_ARRAY(m_flZoneExitSpeed3D), RecvPropFloat(RECVINFO(m_flZoneExitSpeed3D[0]))), RecvPropArray3(RECVINFO_ARRAY(m_flZoneExitSpeed2D), RecvPropFloat(RECVINFO(m_flZoneExitSpeed2D[0]))), RecvPropArray3(RECVINFO_ARRAY(m_flZoneVelocityAvg3D), RecvPropFloat(RECVINFO(m_flZoneVelocityAvg3D[0]))), RecvPropArray3(RECVINFO_ARRAY(m_flZoneVelocityAvg2D), RecvPropFloat(RECVINFO(m_flZoneVelocityAvg2D[0]))), RecvPropArray3(RECVINFO_ARRAY(m_flZoneVelocityMax3D), RecvPropFloat(RECVINFO(m_flZoneVelocityMax3D[0]))), RecvPropArray3(RECVINFO_ARRAY(m_flZoneVelocityMax2D), RecvPropFloat(RECVINFO(m_flZoneVelocityMax2D[0]))), END_RECV_TABLE(); #else BEGIN_SEND_TABLE_NOBASE(CMomRunStats, DT_MomRunStats) SendPropInt(SENDINFO(m_iTotalZones), 7, SPROP_UNSIGNED),
RecvPropFloat( RECVINFO( f ) ), END_RECV_TABLE() BEGIN_RECV_TABLE_NOBASE(DTTestClientSub, DT_DTTestSub) // - Auto type conversions (receiving an array of floats into an array of ints). RecvPropArray( RecvPropFloat(RECVINFO(m_FloatArray[0])), m_FloatArray), RecvPropUtlVector( RECVINFO_UTLVECTOR( m_UtlVectorFloat ), MAX_FLOATARRAY_ELEMENTS, RecvPropFloat(NULL,0,0) ), RecvPropUtlVectorDataTable( m_UtlVectorStruct, MAX_STRUCTARRAY_ELEMENTS, DT_TestStruct ), RecvPropUtlVector( RECVINFO_UTLVECTOR( m_UtlVectorChar ), MAX_CHARARRAY_ELEMENTS, RecvPropInt( NULL, 0, sizeof( char ) ) ), RecvPropArray( RecvPropString(RECVINFO(m_Strings[0]), 0, RecvProxy_DTTestClientSubString), m_Strings), END_RECV_TABLE() BEGIN_RECV_TABLE_NOBASE(DTTestSub2Sub, DT_DTTestSub2Sub) RecvPropInt( RECVINFO( m_Int2 ), 32 ), END_RECV_TABLE() BEGIN_RECV_TABLE_NOBASE(DTTestSub2, DT_DTTestSub2) RecvPropDataTable(RECVINFO_DT(m_Sub), 0, &REFERENCE_RECV_TABLE(DT_DTTestSub2Sub)), RecvPropInt( RECVINFO( m_Int ) ), END_RECV_TABLE()
RecvProp RecvPropIntWithMinusOneFlag( char *pVarName, int offset, int sizeofVar, RecvVarProxyFn proxyFn ) { return RecvPropInt( pVarName, offset, sizeofVar, 0, proxyFn ); }