#include "vguiscreen.h" #include "tf_gamerules.h" extern ConVar tf2_object_hard_limits; extern ConVar tf_fastbuild; EXTERN_SEND_TABLE(DT_BaseCombatWeapon) BEGIN_NETWORK_TABLE_NOBASE( CTFWeaponBuilder, DT_BuilderLocalData ) SendPropInt( SENDINFO( m_iObjectType ), BUILDER_OBJECT_BITS, SPROP_UNSIGNED ), SendPropEHandle( SENDINFO( m_hObjectBeingBuilt ) ), END_NETWORK_TABLE() IMPLEMENT_SERVERCLASS_ST(CTFWeaponBuilder, DT_TFWeaponBuilder) SendPropInt( SENDINFO( m_iBuildState ), 4, SPROP_UNSIGNED ), SendPropDataTable( "BuilderLocalData", 0, &REFERENCE_SEND_TABLE( DT_BuilderLocalData ), SendProxy_SendLocalWeaponDataTable ), END_SEND_TABLE() LINK_ENTITY_TO_CLASS( tf_weapon_builder, CTFWeaponBuilder ); PRECACHE_WEAPON_REGISTER( tf_weapon_builder ); //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- CTFWeaponBuilder::CTFWeaponBuilder() { m_iObjectType.Set( BUILDER_INVALID_OBJECT ); } //----------------------------------------------------------------------------- // Purpose:
BEGIN_NETWORK_TABLE_NOBASE( CTFPipebombLauncher, DT_PipebombLauncherLocalData ) #ifdef CLIENT_DLL RecvPropInt( RECVINFO( m_iPipebombCount ) ), RecvPropTime( RECVINFO( m_flChargeBeginTime ) ), #else SendPropInt( SENDINFO( m_iPipebombCount ), 5, SPROP_UNSIGNED ), SendPropTime( SENDINFO( m_flChargeBeginTime ) ), #endif END_NETWORK_TABLE() BEGIN_NETWORK_TABLE( CTFPipebombLauncher, DT_WeaponPipebombLauncher ) #ifdef CLIENT_DLL RecvPropDataTable( "PipebombLauncherLocalData", 0, 0, &REFERENCE_RECV_TABLE( DT_PipebombLauncherLocalData ) ), #else SendPropDataTable( "PipebombLauncherLocalData", 0, &REFERENCE_SEND_TABLE( DT_PipebombLauncherLocalData ), SendProxy_SendLocalWeaponDataTable ), #endif END_NETWORK_TABLE() #ifdef CLIENT_DLL BEGIN_PREDICTION_DATA( CTFPipebombLauncher ) DEFINE_PRED_FIELD( m_flChargeBeginTime, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ), END_PREDICTION_DATA() #endif LINK_ENTITY_TO_CLASS( tf_weapon_pipebomblauncher, CTFPipebombLauncher ); PRECACHE_WEAPON_REGISTER( tf_weapon_pipebomblauncher ); // Server specific. #ifndef CLIENT_DLL BEGIN_DATADESC( CTFPipebombLauncher )
SendPropExclude( "DT_BaseAnimating", "m_flPoseParameter" ), SendPropExclude( "DT_BaseAnimating", "m_flPlaybackRate" ), SendPropExclude( "DT_BaseAnimating", "m_nSequence" ), SendPropExclude( "DT_BaseAnimating", "m_nNewSequenceParity" ), SendPropExclude( "DT_BaseAnimating", "m_nResetEventsParity" ), SendPropExclude( "DT_BaseEntity", "m_angRotation" ), SendPropExclude( "DT_BaseAnimatingOverlay", "overlay_vars" ), SendPropExclude( "DT_ServerAnimationData" , "m_flCycle" ), SendPropExclude( "DT_AnimTimeMustBeFirst" , "m_flAnimTime" ), // New props SendPropBool( SENDINFO( m_bSpawnInterpCounter) ), SendPropEHandle( SENDINFO( m_hRagdoll ) ), // Data that only gets sent to the local player. SendPropDataTable( "netplayer_localdata", 0, &REFERENCE_SEND_TABLE(DT_BaseNetworkedPlayerExclusive), SendProxy_SendLocalDataTable ), // Data that gets sent to all other players SendPropDataTable( "netplayer_nonlocaldata", 0, &REFERENCE_SEND_TABLE(DT_BaseNetworkedPlayerNonLocalExclusive), SendProxy_SendNonLocalDataTable ), END_NETWORK_TABLE() //* ****************** FUNCTIONS* ********************* CBaseNetworkedPlayer::CBaseNetworkedPlayer() { UseClientSideAnimation(); SetPredictionEligible(true); m_bSpawnInterpCounter = false; m_angEyeAngles.Init(); ragdoll_ent_name = "networked_ragdoll";
} return NULL; } REGISTER_SEND_PROXY_NON_MODIFIED_POINTER( SendProxy_SendLocalObjectDataTable ); BEGIN_NETWORK_TABLE_NOBASE( CObjectSentrygun, DT_SentrygunLocalData ) SendPropInt( SENDINFO(m_iKills), 12, SPROP_CHANGES_OFTEN ), SendPropInt( SENDINFO(m_iAssists), 12, SPROP_CHANGES_OFTEN ), END_NETWORK_TABLE() IMPLEMENT_SERVERCLASS_ST( CObjectSentrygun, DT_ObjectSentrygun ) SendPropInt( SENDINFO(m_iAmmoShells), 9, SPROP_CHANGES_OFTEN ), SendPropInt( SENDINFO(m_iAmmoRockets), 6, SPROP_CHANGES_OFTEN ), SendPropInt( SENDINFO(m_iState), Q_log2( SENTRY_NUM_STATES ) + 1, SPROP_UNSIGNED ), SendPropDataTable( "SentrygunLocalData", 0, &REFERENCE_SEND_TABLE( DT_SentrygunLocalData ), SendProxy_SendLocalObjectDataTable ), END_SEND_TABLE() BEGIN_DATADESC( CObjectSentrygun ) END_DATADESC() LINK_ENTITY_TO_CLASS(obj_sentrygun, CObjectSentrygun); PRECACHE_REGISTER(obj_sentrygun); ConVar tf_sentrygun_damage( "tf_sentrygun_damage", "16", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY ); ConVar tf_sentrygun_ammocheat( "tf_sentrygun_ammocheat", "0", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY ); ConVar tf_sentrygun_upgrade_per_hit( "tf_sentrygun_upgrade_per_hit", "25", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY ); ConVar tf_sentrygun_newtarget_dist( "tf_sentrygun_newtarget_dist", "200", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY ); ConVar tf_sentrygun_metal_per_shell( "tf_sentrygun_metal_per_shell", "1", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY ); ConVar tf_sentrygun_metal_per_rocket( "tf_sentrygun_metal_per_rocket", "2", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY ); ConVar tf_sentrygun_notarget( "tf_sentrygun_notarget", "0", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY );
} BEGIN_RECV_TABLE( CSDKGameRulesProxy, DT_SDKGameRulesProxy ) RecvPropDataTable( "sdk_gamerules_data", 0, 0, &REFERENCE_RECV_TABLE( DT_SDKGameRules ), RecvProxy_SDKGameRules ) END_RECV_TABLE() #else void *SendProxy_SDKGameRules( const SendProp *pProp, const void *pStructBase, const void *pData, CSendProxyRecipients *pRecipients, int objectID ) { CSDKGameRules *pRules = SDKGameRules(); Assert( pRules ); pRecipients->SetAllRecipients(); return pRules; } BEGIN_SEND_TABLE( CSDKGameRulesProxy, DT_SDKGameRulesProxy ) SendPropDataTable( "sdk_gamerules_data", 0, &REFERENCE_SEND_TABLE( DT_SDKGameRules ), SendProxy_SDKGameRules ) END_SEND_TABLE() #endif #ifndef CLIENT_DLL ConVar sk_plr_dmg_grenade( "sk_plr_dmg_grenade","0"); #endif ConVar mp_limitteams( "mp_limitteams", "2", FCVAR_REPLICATED | FCVAR_NOTIFY, "Max # of players 1 team can have over another (0 disables check)", true, 0, // min value true, 30 // max value );
#else #include "tf_player.h" #endif //============================================================================= // // Weapon Pistol tables. // IMPLEMENT_NETWORKCLASS_ALIASED( TFPistol, DT_WeaponPistol ) BEGIN_NETWORK_TABLE_NOBASE( CTFPistol, DT_PistolLocalData ) END_NETWORK_TABLE() BEGIN_NETWORK_TABLE( CTFPistol, DT_WeaponPistol ) #if !defined( CLIENT_DLL ) SendPropDataTable( "PistolLocalData", 0, &REFERENCE_SEND_TABLE( DT_PistolLocalData ), SendProxy_SendLocalWeaponDataTable ), #else RecvPropDataTable( "PistolLocalData", 0, 0, &REFERENCE_RECV_TABLE( DT_PistolLocalData ) ), #endif END_NETWORK_TABLE() BEGIN_PREDICTION_DATA( CTFPistol ) END_PREDICTION_DATA() LINK_ENTITY_TO_CLASS( tf_weapon_pistol, CTFPistol ); PRECACHE_WEAPON_REGISTER( tf_weapon_pistol ); // Server specific. #ifndef CLIENT_DLL BEGIN_DATADESC( CTFPistol ) END_DATADESC()
SendPropExclude( "DT_BaseAnimating", "m_nSequence" ), SendPropExclude( "DT_BaseEntity", "m_angRotation" ), SendPropExclude( "DT_BaseAnimatingOverlay", "overlay_vars" ), SendPropExclude( "DT_BaseEntity", "m_vecOrigin" ), // playeranimstate and clientside animation takes care of these on the client SendPropExclude( "DT_ServerAnimationData" , "m_flCycle" ), SendPropExclude( "DT_AnimTimeMustBeFirst" , "m_flAnimTime" ), SendPropExclude( "DT_BaseFlex", "m_flexWeight" ), SendPropExclude( "DT_BaseFlex", "m_blinktoggle" ), SendPropExclude( "DT_BaseFlex", "m_viewtarget" ), // Data that only gets sent to the local player. SendPropDataTable( "hl2mplocaldata", 0, &REFERENCE_SEND_TABLE(DT_HL2MPLocalPlayerExclusive), SendProxy_SendLocalDataTable ), // Data that gets sent to all other players SendPropDataTable( "hl2mpnonlocaldata", 0, &REFERENCE_SEND_TABLE(DT_HL2MPNonLocalPlayerExclusive), SendProxy_SendNonLocalDataTable ), SendPropEHandle( SENDINFO( m_hRagdoll ) ), SendPropInt( SENDINFO( m_iSpawnInterpCounter), 4 ), SendPropInt( SENDINFO( m_iPlayerSoundType), 3 ), END_SEND_TABLE() BEGIN_DATADESC( CHL2MP_Player ) END_DATADESC() const char *g_ppszRandomCitizenModels[] = { "models/humans/group03/male_01.mdl",
DEFINE_PRED_FIELD( m_flSpawnSpeed, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ), END_PREDICTION_DATA() BEGIN_PREDICTION_DATA_NO_BASE( PositionHistory_t ) DEFINE_FIELD( m_Position, FIELD_VECTOR ), DEFINE_FIELD( m_Time, FIELD_FLOAT ), END_PREDICTION_DATA() IMPLEMENT_NETWORKCLASS_ALIASED( BasePlasmaProjectile, DT_BasePlasmaProjectile) BEGIN_NETWORK_TABLE( CBasePlasmaProjectile, DT_BasePlasmaProjectile ) #if !defined( CLIENT_DLL ) SendPropDataTable(SENDINFO_DT(m_Shared), &REFERENCE_SEND_TABLE(DT_PlasmaProjectileShared)), SendPropExclude( "DT_BaseEntity", "m_vecVelocity" ), SendPropExclude( "DT_BaseEntity", "m_vecAbsOrigin" ), //SendPropVector(SENDINFO(m_vecGunOriginOffset), 0, SPROP_COORD), #else RecvPropDataTable(RECVINFO_DT(m_Shared), 0, &REFERENCE_RECV_TABLE(DT_PlasmaProjectileShared)), //RecvPropVector(RECVINFO(m_vecGunOriginOffset)), #endif END_NETWORK_TABLE() LINK_ENTITY_TO_CLASS( base_plasmaprojectile, CBasePlasmaProjectile ); PRECACHE_REGISTER(base_plasmaprojectile);
SendPropInt( NULL, 0, sizeof( char ), 0 ) ), SendPropUtlVector( SENDINFO_UTLVECTOR( m_UtlVectorFloat ), MAX_FLOATARRAY_ELEMENTS, // max elements SendPropFloat( NULL, 0, 0, 0, SPROP_NOSCALE ) ) END_SEND_TABLE() BEGIN_SEND_TABLE_NOBASE(DTTestSub2Sub, DT_DTTestSub2Sub) SendPropInt( SENDINFO_NOCHECK( m_Int2 ), 32 ), END_SEND_TABLE() BEGIN_SEND_TABLE_NOBASE(DTTestSub2, DT_DTTestSub2) SendPropDataTable(SENDINFO_DT(m_Sub), &REFERENCE_SEND_TABLE(DT_DTTestSub2Sub)), SendPropInt( SENDINFO_NOCHECK( m_Int ), 32 ), END_SEND_TABLE() // ------------------------------------------------------------------------------------------- // // DTTestServer and its DataTable. // ------------------------------------------------------------------------------------------- // class DTTestServer { public: DTTestServerSub m_Sub; DTTestSub2 m_Sub2; float m_Float;
SendPropTime( SENDINFO( m_flTimeWeaponIdle ) ), END_NETWORK_TABLE() IMPLEMENT_SERVERCLASS_ST(CASW_Weapon, DT_ASW_Weapon) SendPropExclude( "DT_BaseAnimating", "m_flPoseParameter" ), SendPropExclude( "DT_BaseAnimating", "m_flPlaybackRate" ), SendPropExclude( "DT_BaseAnimating", "m_nSequence" ), SendPropExclude( "DT_BaseAnimatingOverlay", "overlay_vars" ), SendPropExclude( "DT_ServerAnimationData" , "m_flCycle" ), SendPropExclude( "DT_AnimTimeMustBeFirst" , "m_flAnimTime" ), SendPropBool(SENDINFO(m_bIsFiring)), SendPropBool(SENDINFO(m_bInReload)), SendPropBool(SENDINFO(m_bSwitchingWeapons)), SendPropExclude( "DT_BaseCombatWeapon", "LocalWeaponData" ), SendPropExclude( "DT_BaseCombatWeapon", "LocalActiveWeaponData" ), SendPropDataTable("ASWLocalWeaponData", 0, &REFERENCE_SEND_TABLE(DT_ASWLocalWeaponData), SendProxy_SendASWLocalWeaponDataTable ), SendPropDataTable("ASWActiveLocalWeaponData", 0, &REFERENCE_SEND_TABLE(DT_ASWActiveLocalWeaponData), SendProxy_SendASWActiveLocalWeaponDataTable ), SendPropBool(SENDINFO(m_bFastReloadSuccess)), SendPropBool(SENDINFO(m_bFastReloadFailure)), SendPropBool(SENDINFO(m_bPoweredUp)), SendPropIntWithMinusOneFlag( SENDINFO(m_iClip1 ), 8 ), SendPropInt( SENDINFO(m_iPrimaryAmmoType ), 8 ), END_SEND_TABLE() //--------------------------------------------------------- // Save/Restore //--------------------------------------------------------- BEGIN_DATADESC( CASW_Weapon ) DEFINE_FIELD(m_iEquipmentListIndex, FIELD_INTEGER), DEFINE_FIELD( m_bShotDelayed, FIELD_BOOLEAN ), DEFINE_FIELD( m_flDelayedFire, FIELD_TIME ),
SendPropTime( SENDINFO( m_flShieldParrySwingEndTime ) ), SendPropTime( SENDINFO( m_flShieldUnavailableEndTime ) ), SendPropTime( SENDINFO( m_flShieldRaisedTime ) ), SendPropTime( SENDINFO( m_flShieldLoweredTime ) ), #else RecvPropTime( RECVINFO( m_flShieldParryEndTime ) ), RecvPropTime( RECVINFO( m_flShieldParrySwingEndTime ) ), RecvPropTime( RECVINFO( m_flShieldUnavailableEndTime ) ), RecvPropTime( RECVINFO( m_flShieldRaisedTime ) ), RecvPropTime( RECVINFO( m_flShieldLoweredTime ) ), #endif END_NETWORK_TABLE() BEGIN_NETWORK_TABLE( CWeaponCombatShield , DT_WeaponCombatShield ) #if !defined( CLIENT_DLL ) SendPropDataTable("this", 0, &REFERENCE_SEND_TABLE(DT_WeaponCombatShieldLocal), SendProxy_SendCombatShieldLocalWeaponDataTable ), SendPropTime( SENDINFO( m_flShieldUpStartTime ) ), SendPropTime( SENDINFO( m_flShieldDownStartTime ) ), SendPropInt( SENDINFO( m_iShieldState ), 3, SPROP_UNSIGNED ), SendPropInt( SENDINFO( m_bAllowPostFrame ), 1, SPROP_UNSIGNED ), SendPropInt( SENDINFO( m_bHasShieldParry ), 1, SPROP_UNSIGNED ), SendPropFloat(SENDINFO( m_flShieldHealth ), 8, SPROP_ROUNDDOWN, 0.0f, 1.0f ), #else RecvPropDataTable("this", 0, 0, &REFERENCE_RECV_TABLE(DT_WeaponCombatShieldLocal)), RecvPropTime( RECVINFO( m_flShieldUpStartTime ) ), RecvPropTime( RECVINFO( m_flShieldDownStartTime ) ), RecvPropInt( RECVINFO( m_iShieldState ) ), RecvPropInt( RECVINFO( m_bAllowPostFrame ) ), RecvPropInt( RECVINFO( m_bHasShieldParry ) ), RecvPropFloat(RECVINFO( m_flShieldHealth ) ), #endif
#include "mom_triggers.h" #include "mom_replay_entity.h" #include "tier0/memdbgon.h" #define AVERAGE_STATS_INTERVAL 0.1 IMPLEMENT_SERVERCLASS_ST(CMomentumPlayer, DT_MOM_Player) SendPropInt(SENDINFO(m_iShotsFired)), SendPropInt(SENDINFO(m_iDirection)), SendPropBool(SENDINFO(m_bResumeZoom)), SendPropInt(SENDINFO(m_iLastZoom)), SendPropBool(SENDINFO(m_bDidPlayerBhop)), SendPropInt(SENDINFO(m_iSuccessiveBhops)), SendPropBool(SENDINFO(m_bHasPracticeMode)), SendPropDataTable(SENDINFO_DT(m_RunData), &REFERENCE_SEND_TABLE(DT_MOM_RunEntData)), SendPropDataTable(SENDINFO_DT(m_RunStats), &REFERENCE_SEND_TABLE(DT_MOM_RunStats)), END_SEND_TABLE(); BEGIN_DATADESC(CMomentumPlayer) DEFINE_THINKFUNC(CheckForBhop), DEFINE_THINKFUNC(UpdateRunStats), DEFINE_THINKFUNC(CalculateAverageStats), DEFINE_THINKFUNC(LimitSpeedInStartZone), END_DATADESC(); LINK_ENTITY_TO_CLASS(player, CMomentumPlayer); PRECACHE_REGISTER(player); CMomentumPlayer::CMomentumPlayer() : m_duckUntilOnGround(false), m_flStamina(0), m_flTicksOnGround(0), m_flLastVelocity(0), m_flLastSyncVelocity(0),
END_SEND_TABLE() BEGIN_SEND_TABLE_NOBASE( CSDKPlayerShared, DT_SDKPlayerShared ) #if defined ( SDK_USE_STAMINA ) || defined ( SDK_USE_SPRINTING ) SendPropFloat( SENDINFO( m_flStamina ), 0, SPROP_NOSCALE | SPROP_CHANGES_OFTEN ), #endif #if defined ( SDK_USE_PRONE ) SendPropBool( SENDINFO( m_bProne ) ), SendPropTime( SENDINFO( m_flGoProneTime ) ), SendPropTime( SENDINFO( m_flUnProneTime ) ), #endif #if defined ( SDK_USE_SPRINTING ) SendPropBool( SENDINFO( m_bIsSprinting ) ), #endif SendPropDataTable( "sdksharedlocaldata", 0, &REFERENCE_SEND_TABLE(DT_SDKSharedLocalPlayerExclusive), SendProxy_SendLocalDataTable ), END_SEND_TABLE() extern void SendProxy_Origin( const SendProp *pProp, const void *pStruct, const void *pData, DVariant *pOut, int iElement, int objectID ); BEGIN_SEND_TABLE_NOBASE( CSDKPlayer, DT_SDKLocalPlayerExclusive ) SendPropInt( SENDINFO( m_iShotsFired ), 8, SPROP_UNSIGNED ), // send a hi-res origin to the local player for use in prediction SendPropVector (SENDINFO(m_vecOrigin), -1, SPROP_NOSCALE|SPROP_CHANGES_OFTEN, 0.0f, HIGH_DEFAULT, SendProxy_Origin ), SendPropFloat( SENDINFO_VECTORELEM(m_angEyeAngles, 0), 8, SPROP_CHANGES_OFTEN, -90.0f, 90.0f ), // SendPropAngle( SENDINFO_VECTORELEM(m_angEyeAngles, 1), 10, SPROP_CHANGES_OFTEN ), SendPropInt( SENDINFO( m_ArmorValue ), 8, SPROP_UNSIGNED ), END_SEND_TABLE() BEGIN_SEND_TABLE_NOBASE( CSDKPlayer, DT_SDKNonLocalPlayerExclusive )
} BEGIN_RECV_TABLE( CTFCGameRulesProxy, DT_TFCGameRulesProxy ) RecvPropDataTable( "tfc_gamerules_data", 0, 0, &REFERENCE_RECV_TABLE( DT_TFCGameRules ), RecvProxy_TFCGameRules ) END_RECV_TABLE() #else void *SendProxy_TFCGameRules( const SendProp *pProp, const void *pStructBase, const void *pData, CSendProxyRecipients *pRecipients, int objectID ) { CTFCGameRules *pRules = TFCGameRules(); Assert( pRules ); pRecipients->SetAllRecipients(); return pRules; } BEGIN_SEND_TABLE( CTFCGameRulesProxy, DT_TFCGameRulesProxy ) SendPropDataTable( "tfc_gamerules_data", 0, &REFERENCE_SEND_TABLE( DT_TFCGameRules ), SendProxy_TFCGameRules ) END_SEND_TABLE() #endif ConVar mp_fadetoblack( "mp_fadetoblack", "0", FCVAR_REPLICATED, "fade a player's screen to black when he dies" ); // (We clamp ammo ourselves elsewhere). ConVar ammo_max( "ammo_max", "5000", FCVAR_REPLICATED );
} BEGIN_RECV_TABLE( CHalfLife2SurvivalProxy, DT_HalfLife2SurvivalProxy ) RecvPropDataTable( "hl2_survival_gamerules_data", 0, 0, &REFERENCE_RECV_TABLE( DT_HL2SurvivalGameRules ), RecvProxy_HL2SurvivalGameRules ) END_RECV_TABLE() #else void* SendProxy_HL2SurvivalGameRules( const SendProp *pProp, const void *pStructBase, const void *pData, CSendProxyRecipients *pRecipients, int objectID ) { CHalfLife2Survival *pRules = HL2SurvivalGameRules(); Assert( pRules ); pRecipients->SetAllRecipients(); return pRules; } BEGIN_SEND_TABLE( CHalfLife2SurvivalProxy, DT_HalfLife2SurvivalProxy ) SendPropDataTable( "hl2_survival_gamerules_data", 0, &REFERENCE_SEND_TABLE( DT_HL2SurvivalGameRules ), SendProxy_HL2SurvivalGameRules ) END_SEND_TABLE() #endif #ifndef CLIENT_DLL CHalfLife2Survival::CHalfLife2Survival() { m_bActive = false; } void CHalfLife2Survival::Think( void ) { }
void RunDataTableTest() { RecvTable *pRecvTable = &REFERENCE_RECV_TABLE(DT_DTTest); SendTable *pSendTable = &REFERENCE_SEND_TABLE(DT_DTTest); // Initialize the send and receive modules. SendTable_Init( &pSendTable, 1 ); RecvTable_Init( &pRecvTable, 1 ); pSendTable->SetWriteFlag( false ); // Send DataTable info to the client. unsigned char commBuf[8192]; bf_write bfWrite( "RunDataTableTest->commBuf", commBuf, sizeof(commBuf) ); if( !WriteSendTable_R( pSendTable, bfWrite, true ) ) { Assert( !"RunDataTableTest: SendTable_SendInfo failed." ); } bfWrite.WriteOneBit(0); // Receive the SendTable's info. bf_read bfRead( "RunDataTableTest->bfRead", commBuf, sizeof(commBuf)); while( bfRead.ReadOneBit() ) { bool bNeedsDecoder = bfRead.ReadOneBit()!=0; if( !RecvTable_RecvClassInfos( &bfRead, bNeedsDecoder ) ) { Assert( !"RunDataTableTest: RecvTable_ReadInfos failed." ); continue; } } // Register our receive table. if( !RecvTable_CreateDecoders( NULL ) ) { Assert(false); } // Setup the data with all zeros. DTTestServer dtServer; DTTestClient dtClient; unsigned char prevEncoded[4096]; unsigned char fullEncoded[4096]; memset(&dtServer, 0, sizeof(dtServer)); memset(&dtClient, 0, sizeof(dtClient)); memset(prevEncoded, 0, sizeof(prevEncoded)); SetGuardBytes( &dtClient ); // Now loop around, changing the data a little bit each time and send/recv deltas. int nIterations = 25; for( int iIteration=0; iIteration < nIterations; iIteration++ ) { // Change the server's data. g_bSendSub = true; if( (iIteration % 5) == 0 ) { g_bSendSub = false; // every 8th time, don't send the subtable } if( (iIteration & 3) == 0 ) { // Every once in a while, change ALL the properties. for( int iChange=0; iChange < NUMVARTESTINFOS; iChange++ ) g_VarTestInfos[iChange].m_ChangeFn( &dtServer ); } else { int nChanges = 3 + rand() % NUMVARTESTINFOS; for( int iChange=0; iChange < nChanges; iChange++ ) { int iInfo = rand() % NUMVARTESTINFOS; g_VarTestInfos[iInfo].m_ChangeFn( &dtServer ); } } // Fully encode it. bf_write bfFullEncoded( "RunDataTableTest->bfFullEncoded", fullEncoded, sizeof(fullEncoded) ); if( !SendTable_Encode( pSendTable, &dtServer, &bfFullEncoded, -1, NULL ) ) { Assert(false); } unsigned char deltaEncoded[4096]; bf_write bfDeltaEncoded( "RunDataTableTest->bfDeltaEncoded", deltaEncoded, sizeof(deltaEncoded) ); if ( iIteration == 0 ) { // On the first iteration, just write the whole state. if( !SendTable_Encode( pSendTable, &dtServer, &bfDeltaEncoded, -1, NULL ) ) { Assert( false ); } } else { // Figure out the delta between the newly encoded one and the previously encoded one. int deltaProps[MAX_DATATABLE_PROPS]; bf_read fullEncodedRead( "RunDataTableTest->fullEncodedRead", fullEncoded, sizeof( fullEncoded ), bfFullEncoded.GetNumBitsWritten() ); bf_read prevEncodedRead( "RunDataTableTest->prevEncodedRead", prevEncoded, sizeof( prevEncoded ) ); int nDeltaProps = SendTable_CalcDelta( pSendTable, prevEncoded, sizeof( prevEncoded ) * 8, fullEncoded, bfFullEncoded.GetNumBitsWritten(), deltaProps, ARRAYSIZE( deltaProps ), -1 ); Assert( nDeltaProps != -1 ); // BAD: buffer overflow // Reencode with just the delta. This is what is actually sent to the client. SendTable_WritePropList( pSendTable, fullEncoded, bfFullEncoded.GetNumBitsWritten(), &bfDeltaEncoded, -1111, deltaProps, nDeltaProps ); } memcpy( prevEncoded, fullEncoded, sizeof( prevEncoded ) ); // This step isn't necessary to have the client decode the data but it's here to test // RecvTable_CopyEncoding (and RecvTable_MergeDeltas). This call should just make an exact // copy of the encoded data. unsigned char copyEncoded[4096]; bf_read bfReadDeltaEncoded( "RunDataTableTest->bfReadDeltaEncoded", deltaEncoded, sizeof( deltaEncoded ) ); bf_write bfCopyEncoded( "RunDataTableTest->bfCopyEncoded", copyEncoded, sizeof(copyEncoded) ); RecvTable_CopyEncoding( pRecvTable, &bfReadDeltaEncoded, &bfCopyEncoded, -1 ); // Decode.. bf_read bfDecode( "RunDataTableTest->copyEncoded", copyEncoded, sizeof( copyEncoded ) ); if(!RecvTable_Decode(pRecvTable, &dtClient, &bfDecode, 1111)) { Assert(false); } // Make sure it didn't go into memory it shouldn't have. CheckGuardBytes( &dtClient ); // Verify that only the changed properties were sent and that they were received correctly. CompareDTTest( &dtClient, &dtServer ); } SendTable_Term(); RecvTable_Term(); }
}; IMPLEMENT_SERVERCLASS_ST_NOBASE( CFunc_Dust, DT_Func_Dust ) SendPropInt( SENDINFO(m_Color), 32, SPROP_UNSIGNED ), SendPropInt( SENDINFO(m_SpawnRate), 12, SPROP_UNSIGNED ), SendPropInt( SENDINFO(m_SpeedMax), 12, SPROP_UNSIGNED ), SendPropFloat( SENDINFO(m_flSizeMin), 0, SPROP_NOSCALE ), SendPropFloat( SENDINFO(m_flSizeMax), 0, SPROP_NOSCALE ), SendPropInt( SENDINFO(m_DistMax), 16, SPROP_UNSIGNED ), SendPropInt( SENDINFO(m_LifetimeMin), 4, SPROP_UNSIGNED ), SendPropInt( SENDINFO(m_LifetimeMax), 4, SPROP_UNSIGNED ), SendPropInt( SENDINFO(m_DustFlags), DUST_NUMFLAGS, SPROP_UNSIGNED ), SendPropModelIndex( SENDINFO(m_nModelIndex) ), SendPropFloat( SENDINFO(m_FallSpeed), 0, SPROP_NOSCALE ), SendPropDataTable( SENDINFO_DT( m_Collision ), &REFERENCE_SEND_TABLE(DT_CollisionProperty) ), END_SEND_TABLE() BEGIN_DATADESC( CFunc_Dust ) DEFINE_FIELD( m_DustFlags,FIELD_INTEGER ), DEFINE_KEYFIELD( m_Color, FIELD_COLOR32, "Color" ), DEFINE_KEYFIELD( m_SpawnRate, FIELD_INTEGER, "SpawnRate" ), DEFINE_KEYFIELD( m_flSizeMin, FIELD_FLOAT, "SizeMin" ), DEFINE_KEYFIELD( m_flSizeMax, FIELD_FLOAT, "SizeMax" ), DEFINE_KEYFIELD( m_SpeedMax, FIELD_INTEGER, "SpeedMax" ), DEFINE_KEYFIELD( m_LifetimeMin, FIELD_INTEGER, "LifetimeMin" ), DEFINE_KEYFIELD( m_LifetimeMax, FIELD_INTEGER, "LifetimeMax" ), DEFINE_KEYFIELD( m_DistMax, FIELD_INTEGER, "DistMax" ),
// main table IMPLEMENT_SERVERCLASS_ST( CHL2WarsPlayer, DT_HL2WarsPlayer ) SendPropExclude( "DT_BaseAnimating", "m_flPoseParameter" ), SendPropExclude( "DT_BaseAnimating", "m_flPlaybackRate" ), SendPropExclude( "DT_BaseAnimating", "m_nSequence" ), SendPropExclude( "DT_BaseAnimating", "m_nNewSequenceParity" ), SendPropExclude( "DT_BaseAnimating", "m_nResetEventsParity" ), //SendPropExclude( "DT_BaseEntity", "m_angRotation" ), SendPropExclude( "DT_BaseAnimatingOverlay", "overlay_vars" ), SendPropExclude( "DT_BaseEntity", "m_vecOrigin" ), SendPropExclude( "DT_ServerAnimationData" , "m_flCycle" ), SendPropExclude( "DT_AnimTimeMustBeFirst" , "m_flAnimTime" ), // Data that only gets sent to the local player. SendPropDataTable( "hl2warslocaldata", 0, &REFERENCE_SEND_TABLE(DT_HL2WarsLocalPlayerExclusive), SendProxy_SendLocalDataTable ), // Data that gets sent to all other players SendPropDataTable( "hl2warsnonlocaldata", 0, &REFERENCE_SEND_TABLE(DT_HL2WarsNonLocalPlayerExclusive), SendProxy_SendNonLocalDataTable ), END_SEND_TABLE() // DATADESC BEGIN_DATADESC( CHL2WarsPlayer ) //DEFINE_AUTO_ARRAY( m_NetworkedFactionName, FIELD_CHARACTER ), END_DATADESC() CHL2WarsPlayer::CHL2WarsPlayer() : m_nMouseButtonsPressed(0) { SetViewDistance(1500.0f); m_vCameraLimits.Init( 0, 2.0f, 2.0f );
#define WEIGHT_BITS 8 BEGIN_SEND_TABLE_NOBASE(CAnimationLayer, DT_Animationlayer) SendPropInt (SENDINFO(m_nSequence), ANIMATION_SEQUENCE_BITS,SPROP_UNSIGNED), SendPropFloat (SENDINFO(m_flCycle), ANIMATION_CYCLE_BITS, SPROP_ROUNDDOWN, 0.0f, 1.0f), SendPropFloat (SENDINFO(m_flPrevCycle), ANIMATION_CYCLE_BITS, SPROP_ROUNDDOWN, 0.0f, 1.0f), SendPropFloat (SENDINFO(m_flWeight), WEIGHT_BITS, 0, 0.0f, 1.0f), SendPropInt (SENDINFO(m_nOrder), ORDER_BITS, SPROP_UNSIGNED), END_SEND_TABLE() BEGIN_SEND_TABLE_NOBASE( CBaseAnimatingOverlay, DT_OverlayVars ) SendPropUtlVector( SENDINFO_UTLVECTOR( m_AnimOverlay ), CBaseAnimatingOverlay::MAX_OVERLAYS, // max elements SendPropDataTable( NULL, 0, &REFERENCE_SEND_TABLE( DT_Animationlayer ) ) ) END_SEND_TABLE() IMPLEMENT_SERVERCLASS_ST( CBaseAnimatingOverlay, DT_BaseAnimatingOverlay ) // These are in their own separate data table so CCSPlayer can exclude all of these. SendPropDataTable( "overlay_vars", 0, &REFERENCE_SEND_TABLE( DT_OverlayVars ) ) END_SEND_TABLE() CAnimationLayer::CAnimationLayer( ) { Init( NULL ); }
SendPropInt( SENDINFO( m_iShotsFired ), 8, SPROP_UNSIGNED ), END_SEND_TABLE() IMPLEMENT_SERVERCLASS_ST( CSDKPlayer, DT_SDKPlayer ) SendPropExclude( "DT_BaseAnimating", "m_flPoseParameter" ), SendPropExclude( "DT_BaseAnimating", "m_flPlaybackRate" ), SendPropExclude( "DT_BaseAnimating", "m_nSequence" ), SendPropExclude( "DT_BaseEntity", "m_angRotation" ), SendPropExclude( "DT_BaseAnimatingOverlay", "overlay_vars" ), // playeranimstate and clientside animation takes care of these on the client SendPropExclude( "DT_ServerAnimationData" , "m_flCycle" ), SendPropExclude( "DT_AnimTimeMustBeFirst" , "m_flAnimTime" ), // Data that only gets sent to the local player. SendPropDataTable( "sdklocaldata", 0, &REFERENCE_SEND_TABLE(DT_SDKLocalPlayerExclusive), SendProxy_SendLocalDataTable ), SendPropAngle( SENDINFO_VECTORELEM(m_angEyeAngles, 0), 11 ), SendPropAngle( SENDINFO_VECTORELEM(m_angEyeAngles, 1), 11 ), SendPropEHandle( SENDINFO( m_hRagdoll ) ), SendPropInt( SENDINFO( m_iThrowGrenadeCounter ), THROWGRENADE_COUNTER_BITS, SPROP_UNSIGNED ), END_SEND_TABLE() class CSDKRagdoll : public CBaseAnimatingOverlay { public: DECLARE_CLASS( CSDKRagdoll, CBaseAnimatingOverlay ); DECLARE_SERVERCLASS(); // Transmit ragdolls to everyone.
} REGISTER_SEND_PROXY_NON_MODIFIED_POINTER( SendProxy_TestProxyToggle ); // ---------------------------------------------------------------------------------------- // // Datatables. // ---------------------------------------------------------------------------------------- // LINK_ENTITY_TO_CLASS( test_proxytoggle, CTest_ProxyToggle_Networkable ); BEGIN_SEND_TABLE_NOBASE( CTest_ProxyToggle_Networkable, DT_ProxyToggle_ProxiedData ) SendPropInt( SENDINFO( m_WithProxy ) ) END_SEND_TABLE() IMPLEMENT_SERVERCLASS_ST( CTest_ProxyToggle_Networkable, DT_ProxyToggle ) SendPropDataTable( "blah", 0, &REFERENCE_SEND_TABLE( DT_ProxyToggle_ProxiedData ), SendProxy_TestProxyToggle ) END_SEND_TABLE() // ---------------------------------------------------------------------------------------- // // Console commands for this test. // ---------------------------------------------------------------------------------------- // void Test_ProxyToggle_EnableProxy( const CCommand &args ) { if ( args.ArgC() < 2 ) { Error( "Test_ProxyToggle_EnableProxy: requires parameter (0 or 1)." ); }
// Weapon Hunter Rifles tables. // IMPLEMENT_NETWORKCLASS_ALIASED(TFHunterRifle, DT_TFHunterRifle) BEGIN_NETWORK_TABLE_NOBASE( CTFHunterRifle, DT_HunterRifleLocalData ) #if !defined( CLIENT_DLL ) SendPropFloat( SENDINFO(m_flChargedSpread), 0, SPROP_NOSCALE | SPROP_CHANGES_OFTEN ), #else RecvPropFloat( RECVINFO(m_flChargedSpread) ), #endif END_NETWORK_TABLE() BEGIN_NETWORK_TABLE(CTFHunterRifle, DT_TFHunterRifle) #if !defined( CLIENT_DLL ) SendPropDataTable( "HunterRifleLocalData", 0, &REFERENCE_SEND_TABLE( DT_HunterRifleLocalData ), SendProxy_SendLocalWeaponDataTable ), #else RecvPropDataTable("HunterRifleLocalData", 0, 0, &REFERENCE_RECV_TABLE(DT_HunterRifleLocalData)), #endif END_NETWORK_TABLE() BEGIN_PREDICTION_DATA( CTFHunterRifle ) #ifdef CLIENT_DLL DEFINE_PRED_FIELD( m_flUnzoomTime, FIELD_FLOAT, 0 ), DEFINE_PRED_FIELD( m_flRezoomTime, FIELD_FLOAT, 0 ), DEFINE_PRED_FIELD( m_bRezoomAfterShot, FIELD_BOOLEAN, 0 ), DEFINE_PRED_FIELD( m_flChargedSpread, FIELD_FLOAT, 0 ), #endif END_PREDICTION_DATA() LINK_ENTITY_TO_CLASS( tf_weapon_hunterrifle, CTFHunterRifle );
DEFINE_INPUTFUNC( FIELD_VOID, "OpenCanister", InputOpenCanister ), DEFINE_INPUTFUNC( FIELD_VOID, "SpawnHeadcrabs", InputSpawnHeadcrabs ), DEFINE_INPUTFUNC( FIELD_VOID, "StopSmoke", InputStopSmoke ), // Outputs DEFINE_OUTPUT( m_OnLaunched, "OnLaunched" ), DEFINE_OUTPUT( m_OnImpacted, "OnImpacted" ), DEFINE_OUTPUT( m_OnOpened, "OnOpened" ), END_DATADESC() EXTERN_SEND_TABLE(DT_EnvHeadcrabCanisterShared); IMPLEMENT_SERVERCLASS_ST( CEnvHeadcrabCanister, DT_EnvHeadcrabCanister ) SendPropDataTable( SENDINFO_DT( m_Shared ), &REFERENCE_SEND_TABLE(DT_EnvHeadcrabCanisterShared) ), SendPropBool( SENDINFO( m_bLanded ) ), END_SEND_TABLE() //----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- CEnvHeadcrabCanister::CEnvHeadcrabCanister() { m_flMinRefireTime = -1.0f; m_flMaxRefireTime = -1.0f; } //-----------------------------------------------------------------------------
DEFINE_FIELD( m_iMaterialName, FIELD_MATERIALINDEX ), DEFINE_EMBEDDED( m_Info ), DEFINE_FIELD( m_hConstraintEntity, FIELD_EHANDLE ), // Think this should be handled by StartTouch/etc. // DEFINE_FIELD( m_nRefCount, FIELD_INTEGER ), END_DATADESC() //----------------------------------------------------------------------------- // Networking //----------------------------------------------------------------------------- IMPLEMENT_SERVERCLASS_ST( CEntityParticleTrail, DT_EntityParticleTrail ) SendPropInt(SENDINFO(m_iMaterialName), MAX_MATERIAL_STRING_BITS, SPROP_UNSIGNED ), SendPropDataTable( SENDINFO_DT( m_Info ), &REFERENCE_SEND_TABLE( DT_EntityParticleTrailInfo ) ), SendPropEHandle(SENDINFO(m_hConstraintEntity)), END_SEND_TABLE() LINK_ENTITY_TO_CLASS( env_particle_trail, CEntityParticleTrail ); //----------------------------------------------------------------------------- // Purpose: Creates a flame and attaches it to a target entity. // Input : pTarget - //----------------------------------------------------------------------------- CEntityParticleTrail *CEntityParticleTrail::Create( CBaseEntity *pTarget, const EntityParticleTrailInfo_t &info, CBaseEntity *pConstraintEntity ) { int iMaterialName = GetMaterialIndex( STRING(info.m_strMaterialName) );
*pOut = pRules; } BEGIN_RECV_TABLE( CHL2MPGameRulesProxy, DT_HL2MPGameRulesProxy ) RecvPropDataTable( "hl2mp_gamerules_data", 0, 0, &REFERENCE_RECV_TABLE( DT_HL2MPRules ), RecvProxy_HL2MPRules ) END_RECV_TABLE() #else void* SendProxy_HL2MPRules( const SendProp *pProp, const void *pStructBase, const void *pData, CSendProxyRecipients *pRecipients, int objectID ) { CHL2MPRules *pRules = HL2MPRules(); Assert( pRules ); return pRules; } BEGIN_SEND_TABLE( CHL2MPGameRulesProxy, DT_HL2MPGameRulesProxy ) SendPropDataTable( "hl2mp_gamerules_data", 0, &REFERENCE_SEND_TABLE( DT_HL2MPRules ), SendProxy_HL2MPRules ) END_SEND_TABLE() #endif #ifndef CLIENT_DLL class CVoiceGameMgrHelper : public IVoiceGameMgrHelper { public: virtual bool CanPlayerHearPlayer( CBasePlayer *pListener, CBasePlayer *pTalker, bool &bProximity ) { return ( pListener->GetTeamNumber() == pTalker->GetTeamNumber() ); } }; CVoiceGameMgrHelper g_VoiceGameMgrHelper; IVoiceGameMgrHelper *g_pVoiceGameMgrHelper = &g_VoiceGameMgrHelper;
//----------------------------------------------------------------------------- CTEEffectDispatch::CTEEffectDispatch( const char *name ) : CBaseTempEntity( name ) { } //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- CTEEffectDispatch::~CTEEffectDispatch( void ) { } IMPLEMENT_SERVERCLASS_ST( CTEEffectDispatch, DT_TEEffectDispatch ) SendPropDataTable( SENDINFO_DT( m_EffectData ), &REFERENCE_SEND_TABLE( DT_EffectData ) ) END_SEND_TABLE() // Singleton to fire TEEffectDispatch objects static CTEEffectDispatch g_TEEffectDispatch( "EffectDispatch" ); //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void TE_DispatchEffect( IRecipientFilter& filter, float delay, const Vector &pos, const char *pName, const CEffectData &data ) { // Copy the supplied effect data. g_TEEffectDispatch.m_EffectData = data;
SendPropInt (SENDINFO(m_nRenderMode), 8, SPROP_UNSIGNED ), SendPropFloat (SENDINFO(m_flFrameRate), 10, SPROP_ROUNDUP, -25.0f, 25.0f ), SendPropFloat (SENDINFO(m_flHDRColorScale), 0, SPROP_NOSCALE, 0.0f, 100.0f ), SendPropFloat (SENDINFO(m_flFrame), 20, SPROP_ROUNDDOWN | SPROP_CHANGES_OFTEN, 0.0f, 256.0f), SendPropInt (SENDINFO(m_clrRender), 32, SPROP_UNSIGNED | SPROP_CHANGES_OFTEN ), SendPropVector (SENDINFO(m_vecEndPos), -1, SPROP_COORD ), #ifdef PORTAL SendPropBool (SENDINFO(m_bDrawInMainRender) ), SendPropBool (SENDINFO(m_bDrawInPortalRender) ), #endif SendPropModelIndex(SENDINFO(m_nModelIndex) ), SendPropVector (SENDINFO(m_vecOrigin), 19, SPROP_CHANGES_OFTEN, MIN_COORD_INTEGER, MAX_COORD_INTEGER), SendPropEHandle(SENDINFO_NAME(m_hMoveParent, moveparent) ), SendPropInt (SENDINFO(m_nMinDXLevel), 8, SPROP_UNSIGNED ), #if !defined( NO_ENTITY_PREDICTION ) SendPropDataTable( "beampredictable_id", 0, &REFERENCE_SEND_TABLE( DT_BeamPredictableId ), SendProxy_SendPredictableId ), #endif #else RecvPropInt (RECVINFO(m_nBeamType)), RecvPropInt (RECVINFO(m_nBeamFlags)), RecvPropInt (RECVINFO(m_nNumBeamEnts)), RecvPropArray3 ( RECVINFO_ARRAY( m_hAttachEntity ), RecvPropEHandle (RECVINFO(m_hAttachEntity[0])) ), RecvPropArray3 ( RECVINFO_ARRAY( m_nAttachIndex ), RecvPropInt (RECVINFO(m_nAttachIndex[0]))
#include "tier0/memdbgon.h" #ifdef CLIENT_DLL EXTERN_RECV_TABLE( DT_ScriptCreatedItem ) #else EXTERN_SEND_TABLE( DT_ScriptCreatedItem ) #endif IMPLEMENT_NETWORKCLASS_ALIASED( EconEntity, DT_EconEntity ) BEGIN_NETWORK_TABLE( CEconEntity, DT_EconEntity ) #ifdef CLIENT_DLL RecvPropDataTable( RECVINFO_DT( m_Item ), 0, &REFERENCE_RECV_TABLE( DT_ScriptCreatedItem ) ), RecvPropDataTable( RECVINFO_DT( m_AttributeManager ), 0, &REFERENCE_RECV_TABLE( DT_AttributeContainer ) ), #else SendPropDataTable( SENDINFO_DT( m_Item ), &REFERENCE_SEND_TABLE( DT_ScriptCreatedItem ) ), SendPropDataTable( SENDINFO_DT( m_AttributeManager ), &REFERENCE_SEND_TABLE( DT_AttributeContainer ) ), #endif END_NETWORK_TABLE() #ifdef CLIENT_DLL BEGIN_PREDICTION_DATA( C_EconEntity ) DEFINE_PRED_TYPEDESCRIPTION( m_AttributeManager, CAttributeContainer ), END_PREDICTION_DATA() #endif CEconEntity::CEconEntity() { m_pAttributes = this; }