Beispiel #1
0
/*
================
sdPhysics_GeneralMover::ReadNetworkState
================
*/
void sdPhysics_GeneralMover::ReadNetworkState( networkStateMode_t mode, const sdEntityStateNetworkData& baseState, sdEntityStateNetworkData& newState, const idBitMsg& msg ) const {
	if ( mode == NSM_VISIBLE ) {
		NET_GET_STATES( sdGeneralMoverPhysicsNetworkData );

		newData.currentFraction = msg.ReadDeltaFloat( baseData.currentFraction );
	}
}
Beispiel #2
0
/*
================
sdPhysics_Linear::WriteNetworkState
================
*/
void sdPhysics_Linear::WriteNetworkState( networkStateMode_t mode, const sdEntityStateNetworkData& baseState, sdEntityStateNetworkData& newState, idBitMsg& msg ) const {
	if ( mode == NSM_BROADCAST ) {
		NET_GET_STATES( sdPhysicsLinearBroadcastData );

		// update state
		newData.atRest				= current.atRest;
		newData.localOrigin			= current.localOrigin;
		newData.baseSpeed			= current.linearExtrapolation.GetBaseSpeed();
		newData.duration			= SEC2MS( current.linearExtrapolation.GetDuration() );
		newData.extrapolationType	= current.linearExtrapolation.GetExtrapolationType();
		newData.speed				= current.linearExtrapolation.GetSpeed();
		newData.startTime			= SEC2MS( current.linearExtrapolation.GetStartTime() );
		newData.startValue			= current.linearExtrapolation.GetStartValue();

		// write state
		msg.WriteDeltaLong( baseData.atRest, newData.atRest );
		msg.WriteDeltaVector( baseData.localOrigin, newData.localOrigin );
		msg.WriteDeltaVector( baseData.baseSpeed, newData.baseSpeed );
		msg.WriteDeltaLong( baseData.duration, newData.duration );
		msg.WriteDelta( baseData.extrapolationType, newData.extrapolationType, 8 );
		msg.WriteDeltaVector( baseData.speed, newData.speed );
		msg.WriteDeltaLong( baseData.startTime, newData.startTime );
		msg.WriteDeltaVector( baseData.startValue, newData.startValue );

		return;
	}
}
Beispiel #3
0
/*
================
idScriptObject::WriteNetworkState
================
*/
void idScriptObject::WriteNetworkState( networkStateMode_t mode, const sdEntityStateNetworkData& baseState, sdEntityStateNetworkData& newState, idBitMsg& msg ) const {
	NET_GET_STATES( sdScriptObjectNetworkData );
	SetupStateData( mode, newData );

	baseData.Reset();
	newData.Reset();

	for ( int i = 0; i < networkFields[ mode ].fields.Num(); i++ ) {
		const networkFieldSync_t& value = networkFields[ mode ].fields[ i ];

		switch( value.type ) {
			case ev_object: {
				idScriptObject* object = gameLocal.program->GetScriptObject( *reinterpret_cast< int* >( value.data ) );
				int id = 0;
				if ( object ) {
					idEntity* ent = object->GetClass()->Cast< idEntity >();
					id = gameLocal.GetSpawnId( ent );
				}
				
				const int& oldBase = baseData.GetInt();
				int& newBase = newData.GetInt();

				newBase = id;

				msg.WriteDeltaLong( oldBase, newBase );

				break;
			}
			case ev_vector: {
				const idVec3& oldBase = baseData.GetVector();
				idVec3& newBase = newData.GetVector();

				newBase = *reinterpret_cast< idVec3* >( value.data );

				msg.WriteDeltaVector( oldBase, newBase );
				break;
			}
			case ev_float: {
				const float& oldBase = baseData.GetFloat();
				float& newBase = newData.GetFloat();

				newBase = *reinterpret_cast< float* >( value.data );

				msg.WriteDeltaFloat( oldBase, newBase );
				break;
			}
			case ev_boolean: {
				const int& oldBase = baseData.GetInt();
				int& newBase = newData.GetInt();

				newBase = *reinterpret_cast< int* >( value.data ) != 0;

				msg.WriteBits( newBase, 1 );
				break;
			}
		}
	}
}
Beispiel #4
0
/*
==============
sdDeliveryVehicle::ReadNetworkState
==============
*/
void sdDeliveryVehicle::ReadNetworkState( networkStateMode_t mode, const sdEntityStateNetworkData& baseState, sdEntityStateNetworkData& newState, const idBitMsg& msg ) const {
	if ( mode == NSM_BROADCAST ) {
		NET_GET_STATES( sdDeliveryVehicleBroadcastData );

		// read state
		newData.lastRollAccel = msg.ReadDeltaFloat( baseData.lastRollAccel );
	}

	sdScriptEntity::ReadNetworkState( mode, baseState, newState, msg );
}
Beispiel #5
0
/*
================
sdPhysics_Linear::ReadNetworkState
================
*/
void sdPhysics_Linear::ReadNetworkState( networkStateMode_t mode, const sdEntityStateNetworkData& baseState, sdEntityStateNetworkData& newState, const idBitMsg& msg ) const {
	if ( mode == NSM_BROADCAST ) {
		NET_GET_STATES( sdPhysicsLinearBroadcastData );

		// read state
		newData.atRest				= msg.ReadDeltaLong( baseData.atRest );
		newData.localOrigin			= msg.ReadDeltaVector( baseData.localOrigin );
		newData.baseSpeed			= msg.ReadDeltaVector( baseData.baseSpeed );
		newData.duration			= msg.ReadDeltaLong( baseData.duration );
		newData.extrapolationType	= ( extrapolation_t )msg.ReadDelta( baseData.extrapolationType, 8 );
		newData.speed				= msg.ReadDeltaVector( baseData.speed );
		newData.startTime			= msg.ReadDeltaLong( baseData.startTime );
		newData.startValue			= msg.ReadDeltaVector( baseData.startValue );

		return;
	}
}
Beispiel #6
0
/*
================
idScriptObject::ReadNetworkState
================
*/
void idScriptObject::ReadNetworkState( networkStateMode_t mode, const sdEntityStateNetworkData& baseState, sdEntityStateNetworkData& newState, const idBitMsg& msg ) const {
	NET_GET_STATES( sdScriptObjectNetworkData );
	SetupStateData( mode, newData );

	baseData.Reset();
	newData.Reset();

	for ( int i = 0; i < networkFields[ mode ].fields.Num(); i++ ) {
		const networkFieldSync_t& value = networkFields[ mode ].fields[ i ];

		switch( value.type ) {
			case ev_object: {
				const int& oldBase = baseData.GetInt();
				int& newBase = newData.GetInt();
				newBase = msg.ReadDeltaLong( oldBase );
				break;
			}
			case ev_vector: {
				const idVec3& oldBase = baseData.GetVector();
				idVec3& newBase = newData.GetVector();
				newBase = msg.ReadDeltaVector( oldBase );
				break;
			}
			case ev_float: {
				const float& oldBase = baseData.GetFloat();
				float& newBase = newData.GetFloat();
				newBase = msg.ReadDeltaFloat( oldBase );
				break;
			}
			case ev_boolean: {
				const int& oldBase = baseData.GetInt();
				int& newBase = newData.GetInt();
				newBase = msg.ReadBits( 1 );
				break;
			}
		}
	}
}