/* ================ 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; } }
/* ================ 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 ); }
/* ================ 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; } } } }
/* ================ 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; } }