/*
========================
idLobby::GetMigrationGameDataUser
This will setup the passed in idBitMsg to either read or write from the user's migration game data buffer
========================
*/
bool idLobby::GetMigrationGameDataUser( lobbyUserID_t lobbyUserID, idBitMsg & msg, bool reading ) {
	const int userNum = GetLobbyUserIndexByID( lobbyUserID );

	if ( !verify( userNum >=0 && userNum < MAX_PLAYERS ) ) {
		return false;
	}

	lobbyUser_t * u = GetLobbyUser( userNum );
	if ( u != NULL ) {
		if ( reading ) {

			if ( !IsMigratedStatsGame() || !migrationInfo.persistUntilGameEndsData.wasMigratedHost ) {
				// This was not a migrated session, we have no migration data
				return false;
			}

			if ( u->migrationGameData >= 0 && u->migrationGameData < MAX_PLAYERS ) {
				msg.InitRead( migrationInfo.persistUntilGameEndsData.gameDataUser[ u->migrationGameData ], sizeof( migrationInfo.persistUntilGameEndsData.gameDataUser[ 0 ] ) );
			} else {
				// We don't have migration data for this user
				idLib::Warning( "No migration data for user %d in a migrated game (%d)", userNum, u->migrationGameData );
				return false;
			}
		} else {
			// Writing
			migrationInfo.persistUntilGameEndsData.hasGameData = true;
			u->migrationGameData = userNum;
			memset( migrationInfo.persistUntilGameEndsData.gameDataUser[ userNum ], 0, sizeof( migrationInfo.persistUntilGameEndsData.gameDataUser[0] ) );
			msg.InitWrite( migrationInfo.persistUntilGameEndsData.gameDataUser[ userNum ], sizeof( migrationInfo.persistUntilGameEndsData.gameDataUser[0] ) );
			
		}
		return true;
	}
	return false;
}
Beispiel #2
0
/*
================
sdStatsTracker::OnServerStatsRequestMessage
================
*/
void sdStatsTracker::OnServerStatsRequestMessage( const idBitMsg& msg ) {
	idStrPool* globalKeys;
	idStrPool* globalValues;
	idDict::GetGlobalPools( globalKeys, globalValues );

	char buffer[ 2048 ];

	sdNetStatKeyValList list;
	int numEntries = msg.ReadLong();
	for ( int i = 0; i < numEntries; i++ ) {
		msg.ReadString( buffer, sizeof( buffer ) );		

		sdNetStatKeyValue kv;
		kv.type = ( sdNetStatKeyValue::statValueType )msg.ReadByte();
		kv.key = globalKeys->AllocString( buffer );
		switch ( kv.type ) {
			case sdNetStatKeyValue::SVT_FLOAT:
			case sdNetStatKeyValue::SVT_FLOAT_MAX:
				kv.val.f = msg.ReadFloat();
				break;
			case sdNetStatKeyValue::SVT_INT:
			case sdNetStatKeyValue::SVT_INT_MAX:
				kv.val.i = msg.ReadLong();
				break;
		}

		list.Append( kv );
	}

	OnServerStatsRequestMessage( list );

	sdReliableClientMessage response( GAME_RELIABLE_CMESSAGE_ACKNOWLEDGESTATS );
	response.Send();
}
Beispiel #3
0
void rvInstance::PopulateFromMessage( const idBitMsg& msg ) {
	bool proto69 = ( gameLocal.GetCurrentDemoProtocol() == 69 );

	if ( proto69 ) {
		numMapEntities = msg.ReadShort();
	}
	initialSpawnCount = msg.ReadShort();

	delete[] mapEntityNumbers;
	mapEntityNumbers = NULL;

	if ( proto69 ) {
		RV_PUSH_SYS_HEAP_ID(RV_HEAP_ID_LEVEL);
		mapEntityNumbers = new unsigned short[ numMapEntities ];
		RV_POP_HEAP();
		memset( mapEntityNumbers, -1, sizeof( unsigned short ) * numMapEntities );

		for ( int i = 0; i < numMapEntities; i++ ) {
			mapEntityNumbers[ i ] = msg.ReadShort();
		}
		Populate();
	} else {
		int populateIndex = msg.ReadLong();
		gameLocal.ClientSetStartingIndex( populateIndex );
		//common->Printf( "pos: set firstFreeIndex to %d\n", populateIndex );
		int checksum = msg.ReadLong();
		Populate( checksum );
	}
}
/*
========================
idLobby::HandleMigrationGameData
========================
*/
void idLobby::HandleMigrationGameData( idBitMsg& msg )
{
	// Receives game migration data from the server. Just save off the raw data. If we ever become host we'll let the game code read
	// that chunk in (we can't do anything with it now anyways: we don't have entities or any server code to read it in to)
	migrationInfo.persistUntilGameEndsData.hasGameData = true;
	
	// Reset each user's migration game data. If we don't receive new data for them in this msg, we don't want to use the old data
	for( int i = 0; i < GetNumLobbyUsers(); i++ )
	{
		lobbyUser_t* u = GetLobbyUser( i );
		if( u != NULL )
		{
			u->migrationGameData = -1;
		}
	}
	
	msg.ReadData( migrationInfo.persistUntilGameEndsData.gameData, sizeof( migrationInfo.persistUntilGameEndsData.gameData ) );
	int numUsers = msg.ReadByte();
	int dataIndex = 0;
	for( int i = 0; i < numUsers; i++ )
	{
		lobbyUserID_t lobbyUserID;
		lobbyUserID.ReadFromMsg( msg );
		lobbyUser_t* user = GetLobbyUser( GetLobbyUserIndexByID( lobbyUserID ) );
		if( user != NULL )
		{
		
			NET_VERBOSE_PRINT( "NET:    Got migration data[%d] for user %s\n", dataIndex, user->gamertag );
			
			user->migrationGameData = dataIndex;
			msg.ReadData( migrationInfo.persistUntilGameEndsData.gameDataUser[ dataIndex ], sizeof( migrationInfo.persistUntilGameEndsData.gameDataUser[ dataIndex ] ) );
			dataIndex++;
		}
	}
}
Beispiel #5
0
/*
============
sdGUIDFile::WriteBans
============
*/
bool sdGUIDFile::WriteBans( int& startIndex, idBitMsg& msg ) {
	CheckForUpdates();

	const int MAX_WRITE_BANS = 5;
	int count = 0;
	int i = startIndex + 1;
	for ( ; i < info.Num(); i++ ) {
		sdGUIDInfo& gInfo = info[ i ];
		if ( !gInfo.IsBanned() ) {
			continue;
		}

		count++;
		msg.WriteLong( i );
		idStr name;
		gInfo.GetPrintableName( name );
		msg.WriteString( name.c_str() );

		if ( count == MAX_WRITE_BANS ) {
			startIndex = i;
			return false;
		}
	}

	startIndex = -1;
	return true;
}
/*
========================
idLobby::UpdateSessionUserOnPeers
========================
*/
void idLobby::UpdateSessionUserOnPeers( idBitMsg & msg ) {
	for ( int p = 0; p < peers.Num(); p++ ) {
		QueueReliableMessage( p, RELIABLE_UPDATE_SESSION_USER, msg.GetReadData() + msg.GetReadCount(), msg.GetSize() - msg.GetReadCount() );
	}

	HandleUpdateSessionUser( msg );
}
Beispiel #7
0
/*
================
sdClientProjectile::ClientReceiveEvent
================
*/
bool sdClientProjectile::ClientReceiveEvent( const idVec3 &origin, int event, int time, const idBitMsg &msg ) {
	if ( sdClientEntity::ClientReceiveEvent( origin, event, time, msg ) ) {
		return true;
	}

	switch( event ) {
		case EVENT_COLLIDE: {
			trace_t collision;
			idVec3 velocity;
			int index;

			memset( &collision, 0, sizeof( collision ) );
			collision.endpos = collision.c.point = origin;
			collision.c.normal = msg.ReadDir( 24 );

			collision.endAxis = collision.c.normal.ToMat3();

			index = msg.ReadShort();
			if ( index >= -1 && index < declManager->GetNumMaterials() ) {
				if ( index != -1 ) {
					collision.c.material =  declManager->MaterialByIndex( index, false );
				}						
			}

			velocity[0] = msg.ReadFloat( 5, 10 );
			velocity[1] = msg.ReadFloat( 5, 10 );
			velocity[2] = msg.ReadFloat( 5, 10 );
			Collide( collision, velocity );
			return true;
		}
		default: {
			return false;
		}
	}
}
Beispiel #8
0
/*
============
sdGUIDFile::ListBans
============
*/
void sdGUIDFile::ListBans( const idBitMsg& msg ) {
	while ( msg.GetSize() != msg.GetReadCount() ) {
		int index = msg.ReadLong();
		char buffer[ 128 ];
		msg.ReadString( buffer, sizeof( buffer ) );
		gameLocal.Printf( "%d: %s\n", index, buffer );
	}
}
Beispiel #9
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;
			}
		}
	}
}
/*
========================
idCommonLocal::NetReadUsercmds
========================
*/
void idCommonLocal::NetReadUsercmds( int clientNum, idBitMsg& msg )
{
	if( clientNum == -1 )
	{
		idLib::Warning( "NetReadUsercmds: Trying to read commands from invalid clientNum %d", clientNum );
		return;
	}
	
	// TODO: This shouldn't actually happen. Figure out why it does.
	// Seen on clients when another client leaves a match.
	if( msg.GetReadData() == NULL )
	{
		return;
	}
	
	idSerializer ser( msg, false );
	
	usercmd_t fakeCmd;
	usercmd_t* base = &fakeCmd;
	
	usercmd_t lastCmd;
	
	bool										gotNewCmd = false;
	idStaticList< usercmd_t, NUM_USERCMD_RELAY >	newCmdBuffer;
	
	usercmd_t baseCmd = userCmdMgr.NewestUserCmdForPlayer( clientNum );
	int curMilliseconds = baseCmd.clientGameMilliseconds;
	
	const int numCmds = msg.ReadByte();
	
	for( int i = 0; i < numCmds; i++ )
	{
		usercmd_t newCmd;
		newCmd.Serialize( ser, *base );
		
		lastCmd = newCmd;
		base = &lastCmd;
		
		int newMilliseconds = newCmd.clientGameMilliseconds;
		
		if( newMilliseconds > curMilliseconds )
		{
			if( verify( i < NUM_USERCMD_RELAY ) )
			{
				newCmdBuffer.Append( newCmd );
				gotNewCmd = true;
				curMilliseconds = newMilliseconds;
			}
		}
	}
	
	// Push the commands into the buffer.
	for( int i = 0; i < newCmdBuffer.Num(); ++i )
	{
		userCmdMgr.PutUserCmdForPlayer( clientNum, newCmdBuffer[i] );
	}
}
/*
================
idPhysics_StaticMulti::WriteToSnapshot
================
*/
void idPhysics_StaticMulti::WriteToSnapshot( idBitMsg& msg ) const
{
	int i;
	idCQuat quat, localQuat;
	
	msg.WriteByte( current.Num() );
	
	for( i = 0; i < current.Num(); i++ )
	{
		quat = current[i].axis.ToCQuat();
		localQuat = current[i].localAxis.ToCQuat();
		
		msg.WriteFloat( current[i].origin[0] );
		msg.WriteFloat( current[i].origin[1] );
		msg.WriteFloat( current[i].origin[2] );
		msg.WriteFloat( quat.x );
		msg.WriteFloat( quat.y );
		msg.WriteFloat( quat.z );
		msg.WriteDeltaFloat( current[i].origin[0], current[i].localOrigin[0] );
		msg.WriteDeltaFloat( current[i].origin[1], current[i].localOrigin[1] );
		msg.WriteDeltaFloat( current[i].origin[2], current[i].localOrigin[2] );
		msg.WriteDeltaFloat( quat.x, localQuat.x );
		msg.WriteDeltaFloat( quat.y, localQuat.y );
		msg.WriteDeltaFloat( quat.z, localQuat.z );
	}
}
Beispiel #12
0
/*
================
sdGameRulesStopWatch::ReadNetworkState
================
*/
void sdGameRulesStopWatch::ReadNetworkState( const sdEntityStateNetworkData& baseState, sdEntityStateNetworkData& newState, const idBitMsg& msg ) const {
	sdGameRules::ReadNetworkState( baseState, newState, msg );

	NET_GET_STATES( sdGameRulesStopWatchNetworkState );

	sdTeamManagerLocal& teamManager = sdTeamManager::GetInstance();

	newData.winningTeam	= teamManager.ReadTeamFromStream( baseData.winningTeam, msg );
	newData.progression = msg.ReadDeltaLong( baseData.progression );
	newData.timeToBeat	= msg.ReadDeltaLong( baseData.timeToBeat );
	newData.winReason	= msg.ReadDeltaLong( baseData.winReason );
}
Beispiel #13
0
/*
================
idBrittleFracture::ClientReceiveEvent
================
*/
bool idBrittleFracture::ClientReceiveEvent( int event, int time, const idBitMsg &msg ) {
	idVec3 point, dir;

	switch( event ) {
		case EVENT_PROJECT_DECAL: {
			point[0] = msg.ReadFloat();
			point[1] = msg.ReadFloat();
			point[2] = msg.ReadFloat();
			dir[0] = msg.ReadFloat();
			dir[1] = msg.ReadFloat();
			dir[2] = msg.ReadFloat();
			ProjectDecal( point, dir, time, NULL );
			return true;
		}
		case EVENT_SHATTER: {
			point[0] = msg.ReadFloat();
			point[1] = msg.ReadFloat();
			point[2] = msg.ReadFloat();
			dir[0] = msg.ReadFloat();
			dir[1] = msg.ReadFloat();
			dir[2] = msg.ReadFloat();
			Shatter( point, dir, time );
			return true;
		}
		default: {
			return idEntity::ClientReceiveEvent( event, time, msg );
		}
	}
	return false;
}
Beispiel #14
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;
	}
}
/*
========================
idSnapShot::ApplyToExistingState
Take uncompressed state in msg and add it to existing state
========================
*/
void idSnapShot::ApplyToExistingState( int objId, idBitMsg& msg )
{
	objectState_t* 	objectState = FindObjectByID( objId );
	if( !verify( objectState != NULL ) )
	{
		return;
	}
	
	if( !objectState->createdFromTemplate )
	{
		// We were created this from a template, so we shouldn't be applying it again
		if( net_ssTemplateDebug.GetBool() )
		{
			idLib::Printf( "NOT ApplyToExistingState[%d] because object was created from existing base state. %d\n", objId, objectState->expectedSequence );
			objectState->Print( "SS STATE" );
		}
		return;
	}
	
	// Debug print the template (spawn) and delta state
	if( net_ssTemplateDebug.GetBool() )
	{
		idLib::Printf( "\nApplyToExistingState[%d]. buffer size: %d msg size: %d\n", objId, objectState->buffer.Size(), msg.GetSize() );
		objectState->Print( "DELTA STATE" );
		
		PrintAlign( "SPAWN STATE" );
		for( int i = 0; i < msg.GetSize(); i++ )
		{
			if( InDebugRange( i ) )
			{
				idLib::Printf( "%02X", msg.GetReadData()[i] );
			}
		}
		idLib::Printf( "\n" );
	}
	
	// Actually apply it
	for( objectSize_t i = 0; i < Min( objectState->buffer.Size(), msg.GetSize() ); i++ )
	{
		objectState->buffer[i] += msg.GetReadData()[i];
	}
	
	// Debug print the final state
	if( net_ssTemplateDebug.GetBool() )
	{
		objectState->Print( "NEW STATE" );
		idLib::Printf( "\n" );
	}
}
/*
========================
idLobby::GetMigrationGameData
This will setup the passed in idBitMsg to either read or write from the global migration game data buffer
========================
*/
bool idLobby::GetMigrationGameData( idBitMsg &msg, bool reading ) {
	if ( reading ) {
		if ( !IsMigratedStatsGame() || !migrationInfo.persistUntilGameEndsData.wasMigratedHost ) {
			// This was not a migrated session, we have no migration data
			return false;
		}
		msg.InitRead( migrationInfo.persistUntilGameEndsData.gameData, sizeof( migrationInfo.persistUntilGameEndsData.gameData ) );
	} else {
		migrationInfo.persistUntilGameEndsData.hasGameData = true;
		memset( migrationInfo.persistUntilGameEndsData.gameData, 0, sizeof( migrationInfo.persistUntilGameEndsData.gameData ) );
		msg.InitWrite( migrationInfo.persistUntilGameEndsData.gameData, sizeof( migrationInfo.persistUntilGameEndsData.gameData ) );
	}

	return true;
}
Beispiel #17
0
/*
============
sdGeneralMover::ClientReceiveEvent
============
*/
bool sdGeneralMover::ClientReceiveEvent( int event, int time, const idBitMsg& msg ) {
	switch ( event ) {
		case EVENT_MOVE: {
			int startPos	= msg.ReadLong();
			int endPos		= msg.ReadLong();
			int moveTime	= msg.ReadLong();
			int startTime	= msg.ReadLong();

			StartTimedMove( startPos, endPos, moveTime, startTime );

			return true;
		}
	}

	return sdScriptEntity::ClientReceiveEvent( event, time, msg );
}
Beispiel #18
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 #19
0
void idMultiplayerGame::ReceiveAndPlayVoiceData( const idBitMsg &inMsg )
{
	int		clientNum;

	if( !gameLocal.serverInfo.GetBool( "si_voiceChat" ) )
	{
		return;
	}
	
	clientNum = inMsg.ReadByte();
	soundSystem->PlayVoiceData( clientNum, inMsg.GetReadData(), inMsg.GetRemainingData() );
	if( g_voiceChatDebug.GetInteger() & 4 )
	{
		common->Printf( "VC: Playing %d bytes\n", inMsg.GetRemainingData() );
	}
}
/*
========================
idLobby::CreateUserUpdateMessage
========================
*/
void idLobby::CreateUserUpdateMessage( int userIndex, idBitMsg & msg ) {
	lobbyUser_t * user = GetLobbyUser( userIndex );

	if ( verify( user != NULL ) ) {
		msg.WriteByte( userIndex );
		user->WriteClientMutableData( msg );
	}
}
/*
================
idPhysics_Monster::ReadFromSnapshot
================
*/
void idPhysics_Monster::ReadFromSnapshot( const idBitMsg& msg )
{
	current.origin[0] = msg.ReadFloat();
	current.origin[1] = msg.ReadFloat();
	current.origin[2] = msg.ReadFloat();
	current.velocity[0] = msg.ReadFloat( MONSTER_VELOCITY_EXPONENT_BITS, MONSTER_VELOCITY_MANTISSA_BITS );
	current.velocity[1] = msg.ReadFloat( MONSTER_VELOCITY_EXPONENT_BITS, MONSTER_VELOCITY_MANTISSA_BITS );
	current.velocity[2] = msg.ReadFloat( MONSTER_VELOCITY_EXPONENT_BITS, MONSTER_VELOCITY_MANTISSA_BITS );
	current.localOrigin[0] = msg.ReadDeltaFloat( current.origin[0] );
	current.localOrigin[1] = msg.ReadDeltaFloat( current.origin[1] );
	current.localOrigin[2] = msg.ReadDeltaFloat( current.origin[2] );
	current.pushVelocity[0] = msg.ReadDeltaFloat( 0.0f, MONSTER_VELOCITY_EXPONENT_BITS, MONSTER_VELOCITY_MANTISSA_BITS );
	current.pushVelocity[1] = msg.ReadDeltaFloat( 0.0f, MONSTER_VELOCITY_EXPONENT_BITS, MONSTER_VELOCITY_MANTISSA_BITS );
	current.pushVelocity[2] = msg.ReadDeltaFloat( 0.0f, MONSTER_VELOCITY_EXPONENT_BITS, MONSTER_VELOCITY_MANTISSA_BITS );
	current.atRest = msg.ReadLong();
	current.onGround = msg.ReadBits( 1 ) != 0;
}
/*
================
idPhysics_Monster::WriteToSnapshot
================
*/
void idPhysics_Monster::WriteToSnapshot( idBitMsg& msg ) const
{
	msg.WriteFloat( current.origin[0] );
	msg.WriteFloat( current.origin[1] );
	msg.WriteFloat( current.origin[2] );
	msg.WriteFloat( current.velocity[0], MONSTER_VELOCITY_EXPONENT_BITS, MONSTER_VELOCITY_MANTISSA_BITS );
	msg.WriteFloat( current.velocity[1], MONSTER_VELOCITY_EXPONENT_BITS, MONSTER_VELOCITY_MANTISSA_BITS );
	msg.WriteFloat( current.velocity[2], MONSTER_VELOCITY_EXPONENT_BITS, MONSTER_VELOCITY_MANTISSA_BITS );
	msg.WriteDeltaFloat( current.origin[0], current.localOrigin[0] );
	msg.WriteDeltaFloat( current.origin[1], current.localOrigin[1] );
	msg.WriteDeltaFloat( current.origin[2], current.localOrigin[2] );
	msg.WriteDeltaFloat( 0.0f, current.pushVelocity[0], MONSTER_VELOCITY_EXPONENT_BITS, MONSTER_VELOCITY_MANTISSA_BITS );
	msg.WriteDeltaFloat( 0.0f, current.pushVelocity[1], MONSTER_VELOCITY_EXPONENT_BITS, MONSTER_VELOCITY_MANTISSA_BITS );
	msg.WriteDeltaFloat( 0.0f, current.pushVelocity[2], MONSTER_VELOCITY_EXPONENT_BITS, MONSTER_VELOCITY_MANTISSA_BITS );
	msg.WriteLong( current.atRest );
	msg.WriteBits( current.onGround, 1 );
}
Beispiel #23
0
/*
================
sdGameRulesStopWatch::WriteNetworkState
================
*/
void sdGameRulesStopWatch::WriteNetworkState( const sdEntityStateNetworkData& baseState, sdEntityStateNetworkData& newState, idBitMsg& msg ) const {
	sdGameRules::WriteNetworkState( baseState, newState, msg );

	NET_GET_STATES( sdGameRulesStopWatchNetworkState );

	newData.winningTeam		= GetWinningTeam();
	newData.progression		= progression;
	newData.timeToBeat		= timeToBeat;
	newData.winReason		= winReason;

	sdTeamManagerLocal& teamManager = sdTeamManager::GetInstance();

	teamManager.WriteTeamToStream( baseData.winningTeam, newData.winningTeam, msg );
	msg.WriteDeltaLong( baseData.progression, newData.progression );
	msg.WriteDeltaLong( baseData.timeToBeat, newData.timeToBeat );
	msg.WriteDeltaLong( baseData.winReason, newData.winReason );
}
Beispiel #24
0
/*
================
idMoveable::ReadFromSnapshot
================
*/
void idMoveable::ReadFromSnapshot( const idBitMsg& msg )
{
	physicsObj.ReadFromSnapshot( msg );
	if( msg.HasChanged() )
	{
		UpdateVisuals();
	}
}
/*
===============
idCommonLocal::NetReceiveReliable
===============
*/
void idCommonLocal::NetReceiveReliable( int peer, int type, idBitMsg & msg ) {
    int clientNum = Game()->MapPeerToClient( peer );
    // Only servers care about the client num. Band-aid for problems related to the host's peerIndex being -1 on clients.
    if ( common->IsServer() && clientNum == -1 ) {
        idLib::Warning( "NetReceiveReliable: Could not find client for peer %d", peer );
        return;
    }

    const byte * msgData = msg.GetReadData() + msg.GetReadCount();
    int msgSize = msg.GetRemainingData();
    reliableMsg_t & reliable = reliableQueue.Alloc();
    reliable.client = clientNum;
    reliable.type = type;
    reliable.dataSize = msgSize;
    reliable.data = (byte *)Mem_Alloc( msgSize, TAG_NETWORKING );
    memcpy( reliable.data, msgData, msgSize );
}
/*
========================
idLobby::HandleUpdateSessionUser
========================
*/
void idLobby::HandleUpdateSessionUser( idBitMsg & msg ) {
	// FIXME: Use a user id here
	int sessionUserIndex = msg.ReadByte();

	lobbyUser_t * user = GetLobbyUser( sessionUserIndex );

	if ( verify( user != NULL ) ) {
		user->ReadClientMutableData( msg );
	}
}
Beispiel #27
0
/*
================
sdGameRulesCampaign::ReadCampaignInfo
================
*/
void sdGameRulesCampaign::ReadCampaignInfo( const idBitMsg& msg ) {
	int campaignIndex = msg.ReadLong();

	const sdDeclCampaign* newCampaign = NULL;
	if ( campaignIndex != -1 ) {
		newCampaign = gameLocal.declCampaignType[ campaignIndex ];
	}

	SetCampaign( newCampaign );
}
Beispiel #28
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 #29
0
/*
================
sdProficiencyTable::WriteNetworkState
================
*/
void sdProficiencyTable::WriteNetworkState( const sdNetworkData& baseData, sdNetworkData& newData, idBitMsg& msg ) const {
	bool profChanged		= false;
	bool baseProfChanged	= false;
	bool spawnLevelChanged	= false;

	for ( int i = 0; i < points.Num(); i++ ) {
		newData.points[ i ] = points[ i ];
		profChanged |= newData.points[ i ] != baseData.points[ i ];
		newData.basePoints[ i ] = basePoints[ i ];
		baseProfChanged |= newData.basePoints[ i ] != baseData.basePoints[ i ];
		newData.spawnLevels[ i ] = spawnLevels[ i ];
		spawnLevelChanged |= newData.spawnLevels[ i ] != baseData.spawnLevels[ i ];
	}

	msg.WriteBool( profChanged );
	if ( profChanged ) {
		for ( int i = 0; i < points.Num(); i++ ) {
			msg.WriteDeltaFloat( baseData.points[ i ], newData.points[ i ] );
		}
	}
	msg.WriteBool( baseProfChanged );
	if ( baseProfChanged ) {
		for ( int i = 0; i < basePoints.Num(); i++ ) {
			msg.WriteDeltaFloat( baseData.basePoints[ i ], newData.basePoints[ i ] );
		}
	}
	msg.WriteBool( spawnLevelChanged );
	if ( spawnLevelChanged ) {
		for ( int i = 0; i < points.Num(); i++ ) {
			msg.WriteDeltaLong( baseData.spawnLevels[ i ], newData.spawnLevels[ i ] );
		}
	}

	if ( !baseData.fixedRank ) {
		newData.fixedRank = fixedRank;
		if ( fixedRank ) {
			msg.WriteBool( true );
			newData.fixedRankIndex = rank == NULL ? -1 : rank->Index();
			msg.WriteLong( newData.fixedRankIndex );
		} else {
			msg.WriteBool( false );
			newData.fixedRankIndex = -1;
		}
	} else {
		newData.fixedRank = true;
		newData.fixedRankIndex = baseData.fixedRankIndex;
	}
}
Beispiel #30
0
/*
================
sdGameRulesCampaign::ReadMapStats
================
*/
void sdGameRulesCampaign::ReadMapStats( const idBitMsg& msg ) {
	int index = msg.ReadLong();

	if ( index >= campaignMapData.Num() ) {
		gameLocal.Warning( "sdGameRulesCampaign::ReadStats Out of Bounds Map Stats Received" );
		return;
	}

	mapData_t& mapData = campaignMapData[ index ];

	mapData.winner = sdTeamManager::GetInstance().ReadTeamFromStream( msg );
	mapData.written = true;

	for ( int i = 0; i < mapData.teamData.Num(); i++ ) {
		teamMapData_t& teamData = mapData.teamData[ i ];

		for ( int j = 0; j < teamData.xp.Num(); j++ ) {
			teamData.xp[ j ] = msg.ReadFloat();
		}
	}
	OnMapStatsReceived( index );
}