Skip to content

Commit

Permalink
clean up dt formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
luttje committed Aug 19, 2024
1 parent 4406b09 commit 2574d98
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 151 deletions.
82 changes: 42 additions & 40 deletions src/game/client/c_baseentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,19 +439,21 @@ void RecvProxy_EffectFlags( const CRecvProxyData *pData, void *pStruct, void *pO
( ( C_BaseEntity * )pStruct )->SetEffects( pData->m_Value.m_Int );
}

// clang-format off

BEGIN_RECV_TABLE_NOBASE( C_BaseEntity, DT_AnimTimeMustBeFirst )
RecvPropInt( RECVINFO( m_flAnimTime ), 0, RecvProxy_AnimTime ),
END_RECV_TABLE()
RecvPropInt( RECVINFO( m_flAnimTime ), 0, RecvProxy_AnimTime ),
END_RECV_TABLE()

#ifndef NO_ENTITY_PREDICTION
BEGIN_RECV_TABLE_NOBASE( C_BaseEntity, DT_PredictableId )
RecvPropPredictableId( RECVINFO( m_PredictableID ) ),
BEGIN_RECV_TABLE_NOBASE( C_BaseEntity, DT_PredictableId )
RecvPropPredictableId( RECVINFO( m_PredictableID ) ),
RecvPropInt( RECVINFO( m_bIsPlayerSimulated ) ),
END_RECV_TABLE()
END_RECV_TABLE()
#endif

BEGIN_RECV_TABLE_NOBASE( C_BaseEntity, DT_BaseEntity )
RecvPropDataTable( "AnimTimeMustBeFirst", 0, 0, &REFERENCE_RECV_TABLE( DT_AnimTimeMustBeFirst ) ),
BEGIN_RECV_TABLE_NOBASE( C_BaseEntity, DT_BaseEntity )
RecvPropDataTable( "AnimTimeMustBeFirst", 0, 0, &REFERENCE_RECV_TABLE( DT_AnimTimeMustBeFirst ) ),
RecvPropInt( RECVINFO( m_flSimulationTime ), 0, RecvProxy_SimulationTime ),
RecvPropInt( RECVINFO( m_ubInterpolationFrame ) ),

Expand Down Expand Up @@ -487,24 +489,23 @@ RecvPropInt( RECVINFO( m_flAnimTime ), 0, RecvProxy_AnimTime ),
#if !defined( NO_ENTITY_PREDICTION )
RecvPropDataTable( "predictable_id", 0, 0, &REFERENCE_RECV_TABLE( DT_PredictableId ) ),
#endif

RecvPropInt( RECVINFO( m_bSimulatedEveryTick ), 0, RecvProxy_InterpolationAmountChanged ),
RecvPropInt( RECVINFO( m_bAnimatedEveryTick ), 0, RecvProxy_InterpolationAmountChanged ),
RecvPropBool( RECVINFO( m_bAlternateSorting ) ),

#ifdef TF_CLIENT_DLL
RecvPropArray3( RECVINFO_ARRAY( m_nModelIndexOverrides ),
RecvPropInt( RECVINFO( m_nModelIndexOverrides[0] ) ) ),
RecvPropInt( RECVINFO( m_nModelIndexOverrides[0] ) ) ),
#endif
END_RECV_TABLE()

END_RECV_TABLE()

const float coordTolerance = 2.0f / ( float )( 1 << COORD_FRACTIONAL_BITS );
const float coordTolerance = 2.0f / ( float )( 1 << COORD_FRACTIONAL_BITS );

BEGIN_PREDICTION_DATA_NO_BASE( C_BaseEntity )

// These have a special proxy to handle send/receive
DEFINE_PRED_TYPEDESCRIPTION( m_Collision, CCollisionProperty ),
// These have a special proxy to handle send/receive
DEFINE_PRED_TYPEDESCRIPTION( m_Collision, CCollisionProperty ),

DEFINE_PRED_FIELD( m_MoveType, FIELD_CHARACTER, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( m_MoveCollide, FIELD_CHARACTER, FTYPEDESC_INSENDTABLE ),
Expand Down Expand Up @@ -558,35 +559,36 @@ DEFINE_PRED_TYPEDESCRIPTION( m_Collision, CCollisionProperty ),
DEFINE_FIELD( m_flGravity, FIELD_FLOAT ),
// DEFINE_FIELD( m_ModelInstance, FIELD_SHORT ),
DEFINE_FIELD( m_flProxyRandomValue, FIELD_FLOAT ),
// DEFINE_FIELD( m_PredictableID, FIELD_INTEGER ),
// DEFINE_FIELD( m_pPredictionContext, FIELD_POINTER ),
// Stuff specific to rendering and therefore not to be copied back and forth
// DEFINE_PRED_FIELD( m_clrRender, color32, FTYPEDESC_INSENDTABLE ),
// DEFINE_FIELD( m_bReadyToDraw, FIELD_BOOLEAN ),
// DEFINE_FIELD( anim, CLatchedAnim ),
// DEFINE_FIELD( mouth, CMouthInfo ),
// DEFINE_FIELD( GetAbsOrigin(), FIELD_VECTOR ),
// DEFINE_FIELD( GetAbsAngles(), FIELD_VECTOR ),
// DEFINE_FIELD( m_nNumAttachments, FIELD_SHORT ),
// DEFINE_FIELD( m_pAttachmentAngles, FIELD_VECTOR ),
// DEFINE_FIELD( m_pAttachmentOrigin, FIELD_VECTOR ),
// DEFINE_FIELD( m_listentry, CSerialEntity ),
// DEFINE_FIELD( m_ShadowHandle, ClientShadowHandle_t ),
// DEFINE_FIELD( m_hThink, ClientThinkHandle_t ),
// Definitely private and not copied around
// DEFINE_FIELD( m_bPredictable, FIELD_BOOLEAN ),
// DEFINE_FIELD( m_CollisionGroup, FIELD_INTEGER ),
// DEFINE_FIELD( m_DataChangeEventRef, FIELD_INTEGER ),
// DEFINE_FIELD( m_PredictableID, FIELD_INTEGER ),
// DEFINE_FIELD( m_pPredictionContext, FIELD_POINTER ),
// Stuff specific to rendering and therefore not to be copied back and forth
// DEFINE_PRED_FIELD( m_clrRender, color32, FTYPEDESC_INSENDTABLE ),
// DEFINE_FIELD( m_bReadyToDraw, FIELD_BOOLEAN ),
// DEFINE_FIELD( anim, CLatchedAnim ),
// DEFINE_FIELD( mouth, CMouthInfo ),
// DEFINE_FIELD( GetAbsOrigin(), FIELD_VECTOR ),
// DEFINE_FIELD( GetAbsAngles(), FIELD_VECTOR ),
// DEFINE_FIELD( m_nNumAttachments, FIELD_SHORT ),
// DEFINE_FIELD( m_pAttachmentAngles, FIELD_VECTOR ),
// DEFINE_FIELD( m_pAttachmentOrigin, FIELD_VECTOR ),
// DEFINE_FIELD( m_listentry, CSerialEntity ),
// DEFINE_FIELD( m_ShadowHandle, ClientShadowHandle_t ),
// DEFINE_FIELD( m_hThink, ClientThinkHandle_t ),
// Definitely private and not copied around
// DEFINE_FIELD( m_bPredictable, FIELD_BOOLEAN ),
// DEFINE_FIELD( m_CollisionGroup, FIELD_INTEGER ),
// DEFINE_FIELD( m_DataChangeEventRef, FIELD_INTEGER ),
#if !defined( CLIENT_DLL )
// DEFINE_FIELD( m_bPredictionEligible, FIELD_BOOLEAN ),
// DEFINE_FIELD( m_bPredictionEligible, FIELD_BOOLEAN ),
#endif
END_PREDICTION_DATA()
END_PREDICTION_DATA()

//-----------------------------------------------------------------------------
// Helper functions.
//-----------------------------------------------------------------------------
static void* WORKAROUND_NASTY_FORMATTING_BUG; // clang-format on

void SpewInterpolatedVar( CInterpolatedVar< Vector > *pVar )
//-----------------------------------------------------------------------------
// Helper functions.
//-----------------------------------------------------------------------------
void SpewInterpolatedVar( CInterpolatedVar< Vector > *pVar )
{
Msg( "--------------------------------------------------\n" );
int i = pVar->GetHead();
Expand Down Expand Up @@ -1015,7 +1017,7 @@ C_BaseEntity::~C_BaseEntity()
RemoveFromTeleportList();

#ifdef LUA_SDK
if( L )
if ( L )
lua_unref( L, m_nTableReference );
#endif
}
Expand Down
75 changes: 39 additions & 36 deletions src/game/client/c_baseplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,18 @@ void RecvProxy_ObserverMode( const CRecvProxyData *pData, void *pStruct, void *p
// --------------------------------------------------------------------------------
// // RecvTable for CPlayerState.
// --------------------------------------------------------------------------------
// //

// clang-format off

BEGIN_RECV_TABLE_NOBASE( CPlayerState, DT_PlayerState )
RecvPropInt( RECVINFO( deadflag ) ),
END_RECV_TABLE()
RecvPropInt( RECVINFO( deadflag ) ),
END_RECV_TABLE()

BEGIN_RECV_TABLE_NOBASE( CPlayerLocalData, DT_Local )
RecvPropArray3( RECVINFO_ARRAY( m_chAreaBits ),
RecvPropInt( RECVINFO( m_chAreaBits[0] ) ) ),
BEGIN_RECV_TABLE_NOBASE( CPlayerLocalData, DT_Local )
RecvPropArray3( RECVINFO_ARRAY( m_chAreaBits ),
RecvPropInt( RECVINFO( m_chAreaBits[0] ) ) ),
RecvPropArray3( RECVINFO_ARRAY( m_chAreaPortalBits ),
RecvPropInt( RECVINFO( m_chAreaPortalBits[0] ) ) ),
RecvPropInt( RECVINFO( m_chAreaPortalBits[0] ) ) ),
RecvPropInt( RECVINFO( m_iHideHUD ) ),

// View
Expand All @@ -221,17 +222,17 @@ RecvPropInt( RECVINFO( deadflag ) ),

#if PREDICTION_ERROR_CHECK_LEVEL > 1
RecvPropFloat( RECVINFO_NAME( m_vecPunchAngle.m_Value[0],
m_vecPunchAngle[0] ) ),
m_vecPunchAngle[0] ) ),
RecvPropFloat( RECVINFO_NAME( m_vecPunchAngle.m_Value[1],
m_vecPunchAngle[1] ) ),
m_vecPunchAngle[1] ) ),
RecvPropFloat( RECVINFO_NAME( m_vecPunchAngle.m_Value[2],
m_vecPunchAngle[2] ) ),
m_vecPunchAngle[2] ) ),
RecvPropFloat( RECVINFO_NAME( m_vecPunchAngleVel.m_Value[0],
m_vecPunchAngleVel[0] ) ),
m_vecPunchAngleVel[0] ) ),
RecvPropFloat( RECVINFO_NAME( m_vecPunchAngleVel.m_Value[1],
m_vecPunchAngleVel[1] ) ),
m_vecPunchAngleVel[1] ) ),
RecvPropFloat( RECVINFO_NAME( m_vecPunchAngleVel.m_Value[2],
m_vecPunchAngleVel[2] ) ),
m_vecPunchAngleVel[2] ) ),
#else
RecvPropVector( RECVINFO( m_vecPunchAngle ) ),
RecvPropVector( RECVINFO( m_vecPunchAngleVel ) ),
Expand Down Expand Up @@ -272,16 +273,16 @@ RecvPropInt( RECVINFO( deadflag ) ),
RecvPropInt( RECVINFO( m_audio.soundscapeIndex ) ),
RecvPropInt( RECVINFO( m_audio.localBits ) ),
RecvPropEHandle( RECVINFO( m_audio.ent ) ),
END_RECV_TABLE()
END_RECV_TABLE()

// --------------------------------------------------------------------------------
// // This data only gets sent to clients that ARE this player entity.
// --------------------------------------------------------------------------------
// //
// --------------------------------------------------------------------------------
// // This data only gets sent to clients that ARE this player entity.
// --------------------------------------------------------------------------------
// //

BEGIN_RECV_TABLE_NOBASE( C_BasePlayer, DT_LocalPlayerExclusive )
BEGIN_RECV_TABLE_NOBASE( C_BasePlayer, DT_LocalPlayerExclusive )

RecvPropDataTable( RECVINFO_DT( m_Local ), 0, &REFERENCE_RECV_TABLE( DT_Local ) ),
RecvPropDataTable( RECVINFO_DT( m_Local ), 0, &REFERENCE_RECV_TABLE( DT_Local ) ),

RecvPropFloat( RECVINFO( m_vecViewOffset[0] ) ),
RecvPropFloat( RECVINFO( m_vecViewOffset[1] ) ),
Expand Down Expand Up @@ -314,21 +315,21 @@ RecvPropInt( RECVINFO( deadflag ) ),
RecvPropInt( RECVINFO( m_nWaterLevel ) ),
RecvPropFloat( RECVINFO( m_flLaggedMovementValue ) ),

END_RECV_TABLE()
END_RECV_TABLE()

// --------------------------------------------------------------------------------
// // DT_BasePlayer datatable.
// --------------------------------------------------------------------------------
// //

#if defined USES_ECON_ITEMS
EXTERN_RECV_TABLE( DT_AttributeList );
EXTERN_RECV_TABLE( DT_AttributeList );
#endif

IMPLEMENT_CLIENTCLASS_DT( C_BasePlayer, DT_BasePlayer, CBasePlayer )
// We have both the local and nonlocal data in here, but the server proxies
// only send one.
RecvPropDataTable( "localdata", 0, 0, &REFERENCE_RECV_TABLE( DT_LocalPlayerExclusive ) ),
// We have both the local and nonlocal data in here, but the server proxies
// only send one.
RecvPropDataTable( "localdata", 0, 0, &REFERENCE_RECV_TABLE( DT_LocalPlayerExclusive ) ),

#if defined USES_ECON_ITEMS
RecvPropDataTable( RECVINFO_DT( m_AttributeList ), 0, &REFERENCE_RECV_TABLE( DT_AttributeList ) ),
Expand Down Expand Up @@ -364,25 +365,25 @@ RecvPropDataTable( "localdata", 0, 0, &REFERENCE_RECV_TABLE( DT_LocalPlayerExclu

#if defined USES_ECON_ITEMS
RecvPropUtlVector( RECVINFO_UTLVECTOR( m_hMyWearables ),
MAX_WEARABLES_SENT_FROM_SERVER,
RecvPropEHandle( NULL, 0, 0 ) ),
MAX_WEARABLES_SENT_FROM_SERVER,
RecvPropEHandle( NULL, 0, 0 ) ),
#endif

RecvPropEHandle( RECVINFO( m_hHandsEntity ) ),

END_RECV_TABLE()
END_RECV_TABLE()

BEGIN_PREDICTION_DATA_NO_BASE( CPlayerState )
BEGIN_PREDICTION_DATA_NO_BASE( CPlayerState )

DEFINE_PRED_FIELD( deadflag, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( deadflag, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE ),
// DEFINE_FIELD( netname, string_t ),
// DEFINE_FIELD( fixangle, FIELD_INTEGER ),
// DEFINE_FIELD( anglechange, FIELD_FLOAT ),
// DEFINE_FIELD( v_angle, FIELD_VECTOR ),

END_PREDICTION_DATA()
END_PREDICTION_DATA()

BEGIN_PREDICTION_DATA_NO_BASE( CPlayerLocalData )
BEGIN_PREDICTION_DATA_NO_BASE( CPlayerLocalData )

// DEFINE_PRED_TYPEDESCRIPTION( m_skybox3d, sky3dparams_t ),
// DEFINE_PRED_TYPEDESCRIPTION( m_fog, fogparams_t ),
Expand Down Expand Up @@ -415,9 +416,9 @@ RecvPropDataTable( "localdata", 0, 0, &REFERENCE_RECV_TABLE( DT_LocalPlayerExclu
DEFINE_PRED_FIELD( m_flStepSize, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ),
DEFINE_FIELD( m_flFOVRate, FIELD_FLOAT ),

END_PREDICTION_DATA()
END_PREDICTION_DATA()

BEGIN_PREDICTION_DATA( C_BasePlayer )
BEGIN_PREDICTION_DATA( C_BasePlayer )

DEFINE_PRED_TYPEDESCRIPTION( m_Local, CPlayerLocalData ),
DEFINE_PRED_TYPEDESCRIPTION( pl, CPlayerState ),
Expand Down Expand Up @@ -472,9 +473,11 @@ RecvPropDataTable( "localdata", 0, 0, &REFERENCE_RECV_TABLE( DT_LocalPlayerExclu

DEFINE_FIELD( m_surfaceFriction, FIELD_FLOAT ),

END_PREDICTION_DATA()
END_PREDICTION_DATA()

LINK_ENTITY_TO_CLASS( player, C_BasePlayer );

LINK_ENTITY_TO_CLASS( player, C_BasePlayer );
// clang-format on

// --------------------------------------------------------------------------------
// // Functions.
Expand Down
39 changes: 18 additions & 21 deletions src/game/client/recvproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
#ifndef RECVPROXY_H
#define RECVPROXY_H


#include "dt_recv.h"

class CRecvProxyData;


// This converts the int stored in pData to an EHANDLE in pOut.
void RecvProxy_IntToEHandle( const CRecvProxyData *pData, void *pStruct, void *pOut );

Expand All @@ -26,33 +24,32 @@ void RecvProxy_IntToModelIndex16_BackCompatible( const CRecvProxyData *pData, vo
void RecvProxy_IntToModelIndex32_BackCompatible( const CRecvProxyData *pData, void *pStruct, void *pOut );

RecvProp RecvPropTime(
const char *pVarName,
int offset,
int sizeofVar=SIZEOF_IGNORE );
const char *pVarName,
int offset,
int sizeofVar = SIZEOF_IGNORE );

#if !defined( NO_ENTITY_PREDICTION )
RecvProp RecvPropPredictableId(
const char *pVarName,
int offset,
int sizeofVar=SIZEOF_IGNORE );
const char *pVarName,
int offset,
int sizeofVar = SIZEOF_IGNORE );
#endif

RecvProp RecvPropEHandle(
const char *pVarName,
int offset,
int sizeofVar=SIZEOF_IGNORE,
RecvVarProxyFn proxyFn=RecvProxy_IntToEHandle );
const char *pVarName,
int offset,
int sizeofVar = SIZEOF_IGNORE,
RecvVarProxyFn proxyFn = RecvProxy_IntToEHandle );

RecvProp RecvPropBool(
const char *pVarName,
int offset,
int sizeofVar );
const char *pVarName,
int offset,
int sizeofVar );

RecvProp RecvPropIntWithMinusOneFlag(
const char *pVarName,
int offset,
int sizeofVar=SIZEOF_IGNORE,
RecvVarProxyFn proxyFn=RecvProxy_IntSubOne );

#endif // RECVPROXY_H
const char *pVarName,
int offset,
int sizeofVar = SIZEOF_IGNORE,
RecvVarProxyFn proxyFn = RecvProxy_IntSubOne );

#endif // RECVPROXY_H
Loading

0 comments on commit 2574d98

Please sign in to comment.