bool CMapInfoPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    // Write the map weather
    BitStream.Write ( m_ucWeather );
    BitStream.Write ( m_ucWeatherBlendingTo );
    BitStream.Write ( m_ucBlendedWeatherHour );

    BitStream.WriteBit ( m_bHasSkyGradient );
    if ( m_bHasSkyGradient )
    {
        BitStream.Write ( m_ucSkyGradientTR );
        BitStream.Write ( m_ucSkyGradientTG );
        BitStream.Write ( m_ucSkyGradientTB );
        BitStream.Write ( m_ucSkyGradientBR );
        BitStream.Write ( m_ucSkyGradientBG );
        BitStream.Write ( m_ucSkyGradientBB );
    }

    // Write heat haze
    BitStream.WriteBit ( m_bHasHeatHaze );
    if ( m_bHasHeatHaze )
    {
        SHeatHazeSync heatHaze ( m_HeatHazeSettings );
        BitStream.Write ( &heatHaze );
    }

    // Write the map hour
    BitStream.Write ( m_ucClockHour );
    BitStream.Write ( m_ucClockMin );

    BitStream.WriteCompressed ( m_ulMinuteDuration );

    // Write the map flags
    SMapInfoFlagsSync flags;
    flags.data.bShowNametags  = m_bShowNametags;
    flags.data.bShowRadar     = m_bShowRadar;
    flags.data.bCloudsEnabled = m_bCloudsEnabled;
    BitStream.Write ( &flags );

    // Write any other world conditions
    BitStream.Write ( m_fGravity );
    if ( m_fGameSpeed == 1.0f )
        BitStream.WriteBit ( true );
    else
    {
        BitStream.WriteBit ( false );
        BitStream.Write ( m_fGameSpeed );
    }
    BitStream.Write ( m_fWaveHeight );
    // Write world water level
    BitStream.Write ( m_WorldWaterLevelInfo.fSeaLevel );
    BitStream.WriteBit ( m_WorldWaterLevelInfo.bNonSeaLevelSet );
    if ( m_WorldWaterLevelInfo.bNonSeaLevelSet )
        BitStream.Write ( m_WorldWaterLevelInfo.fNonSeaLevel );

    BitStream.WriteCompressed ( m_usFPSLimit );

    // Write the garage states
    for ( unsigned char i = 0 ; i < MAX_GARAGES ; i++ )
    {
        const SGarageStates& garageStates = *m_pGarageStates;
        BitStream.WriteBit( garageStates[i] );
    }

    // Write the fun bugs state
    SFunBugsStateSync funBugs;
    funBugs.data.bQuickReload = g_pGame->IsGlitchEnabled ( CGame::GLITCH_QUICKRELOAD );
    funBugs.data.bFastFire    = g_pGame->IsGlitchEnabled ( CGame::GLITCH_FASTFIRE );
    funBugs.data.bFastMove    = g_pGame->IsGlitchEnabled ( CGame::GLITCH_FASTMOVE );
    funBugs.data.bCrouchBug   = g_pGame->IsGlitchEnabled ( CGame::GLITCH_CROUCHBUG );
    funBugs.data.bCloseRangeDamage = g_pGame->IsGlitchEnabled ( CGame::GLITCH_CLOSEDAMAGE );
    funBugs.data2.bHitAnim    = g_pGame->IsGlitchEnabled ( CGame::GLITCH_HITANIM );
    funBugs.data3.bFastSprint = g_pGame->IsGlitchEnabled ( CGame::GLITCH_FASTSPRINT );
    BitStream.Write ( &funBugs );

    BitStream.Write ( m_fJetpackMaxHeight );

    BitStream.WriteBit ( m_bOverrideWaterColor );
    if ( m_bOverrideWaterColor )
    {
        BitStream.Write ( m_ucWaterRed );
        BitStream.Write ( m_ucWaterGreen );
        BitStream.Write ( m_ucWaterBlue );
        BitStream.Write ( m_ucWaterAlpha );
    }

    // Interior sounds
    BitStream.WriteBit ( m_bInteriorSoundsEnabled );

    // Rain level
    BitStream.WriteBit ( m_bOverrideRainLevel );
    if ( m_bOverrideRainLevel )
    {
        BitStream.Write ( m_fRainLevel );
    }

    // Moon size
    if ( BitStream.Version () >= 0x40 )
    {
        BitStream.WriteBit ( m_bOverrideMoonSize );
        if ( m_bOverrideMoonSize )
        {
            BitStream.Write ( m_iMoonSize );
        }
    }

    // Sun size
    BitStream.WriteBit ( m_bOverrideSunSize );
    if ( m_bOverrideSunSize )
    {
        BitStream.Write ( m_fSunSize );
    }

    // Sun color
    BitStream.WriteBit ( m_bOverrideSunColor );
    if ( m_bOverrideSunColor )
    {
        BitStream.Write ( m_ucSunCoreR );
        BitStream.Write ( m_ucSunCoreG );
        BitStream.Write ( m_ucSunCoreB );
        BitStream.Write ( m_ucSunCoronaR );
        BitStream.Write ( m_ucSunCoronaG );
        BitStream.Write ( m_ucSunCoronaB );
    }

    // Wind velocity
    BitStream.WriteBit ( m_bOverrideWindVelocity );
    if ( m_bOverrideWindVelocity )
    {
        BitStream.Write ( m_fWindVelX );
        BitStream.Write ( m_fWindVelY );
        BitStream.Write ( m_fWindVelZ );
    }

    // Far clip distance
    BitStream.WriteBit ( m_bOverrideFarClipDistance );
    if ( m_bOverrideFarClipDistance )
    {
        BitStream.Write ( m_fFarClip );
    }

    // Fog distance
    BitStream.WriteBit ( m_bOverrideFogDistance );
    if ( m_bOverrideFogDistance )
    {
        BitStream.Write ( m_fFogDistance );
    }

    BitStream.Write ( m_fAircraftMaxHeight );

    if ( BitStream.Version () >= 0x3E ) 
        BitStream.Write ( m_fAircraftMaxVelocity );
    
    if ( BitStream.Version () >= 0x30 )
    {
        for (int i = WEAPONTYPE_BRASSKNUCKLE; i < WEAPONTYPE_PISTOL; i++)
        {
            bool bEnabled;
            bEnabled = g_pGame->GetJetpackWeaponEnabled ( (eWeaponType) i );
            BitStream.WriteBit ( bEnabled );
        }
    }
    for (int i = WEAPONTYPE_PISTOL;i <= WEAPONTYPE_EXTINGUISHER;i++)
    {
        sWeaponPropertySync WeaponProperty;
        CWeaponStat* pWeaponStat = g_pGame->GetWeaponStatManager ()->GetWeaponStats( (eWeaponType)i );
        BitStream.WriteBit ( true );
        WeaponProperty.data.weaponType = (int)pWeaponStat->GetWeaponType();
        WeaponProperty.data.fAccuracy = pWeaponStat->GetAccuracy();
        WeaponProperty.data.fMoveSpeed = pWeaponStat->GetMoveSpeed();
        WeaponProperty.data.fTargetRange = pWeaponStat->GetTargetRange();
        WeaponProperty.data.fWeaponRange = pWeaponStat->GetWeaponRange();
        WeaponProperty.data.nAmmo = pWeaponStat->GetMaximumClipAmmo();
        WeaponProperty.data.nDamage = pWeaponStat->GetDamagePerHit();
        WeaponProperty.data.nFlags = pWeaponStat->GetFlags();

        WeaponProperty.data.anim_loop_start = pWeaponStat->GetWeaponAnimLoopStart();
        WeaponProperty.data.anim_loop_stop = pWeaponStat->GetWeaponAnimLoopStop();
        WeaponProperty.data.anim_loop_bullet_fire = pWeaponStat->GetWeaponAnimLoopFireTime();

        WeaponProperty.data.anim2_loop_start = pWeaponStat->GetWeaponAnim2LoopStart();
        WeaponProperty.data.anim2_loop_stop = pWeaponStat->GetWeaponAnim2LoopStop();
        WeaponProperty.data.anim2_loop_bullet_fire = pWeaponStat->GetWeaponAnim2LoopFireTime();

        WeaponProperty.data.anim_breakout_time = pWeaponStat->GetWeaponAnimBreakoutTime();
        BitStream.Write( &WeaponProperty );
        if ( BitStream.Version () >= 0x30 )
        {
            BitStream.WriteBit ( g_pGame->GetJetpackWeaponEnabled ( (eWeaponType) i ) );
        }
    }

    for (int i = WEAPONTYPE_PISTOL;i <= WEAPONTYPE_TEC9;i++)
    {
        sWeaponPropertySync WeaponProperty;
        BitStream.WriteBit ( true );
        for (int j = 0; j <= 2;j++)
        {
            CWeaponStat* pWeaponStat = g_pGame->GetWeaponStatManager ()->GetWeaponStats( (eWeaponType)i, (eWeaponSkill)j );
            WeaponProperty.data.weaponType = (int)pWeaponStat->GetWeaponType();
            WeaponProperty.data.fAccuracy = pWeaponStat->GetAccuracy();
            WeaponProperty.data.fMoveSpeed = pWeaponStat->GetMoveSpeed();
            WeaponProperty.data.fTargetRange = pWeaponStat->GetTargetRange();
            WeaponProperty.data.fWeaponRange = pWeaponStat->GetWeaponRange();
            WeaponProperty.data.nAmmo = pWeaponStat->GetMaximumClipAmmo();
            WeaponProperty.data.nDamage = pWeaponStat->GetDamagePerHit();
            WeaponProperty.data.nFlags = pWeaponStat->GetFlags();

            WeaponProperty.data.anim_loop_start = pWeaponStat->GetWeaponAnimLoopStart();
            WeaponProperty.data.anim_loop_stop = pWeaponStat->GetWeaponAnimLoopStop();
            WeaponProperty.data.anim_loop_bullet_fire = pWeaponStat->GetWeaponAnimLoopFireTime();

            WeaponProperty.data.anim2_loop_start = pWeaponStat->GetWeaponAnim2LoopStart();
            WeaponProperty.data.anim2_loop_stop = pWeaponStat->GetWeaponAnim2LoopStop();
            WeaponProperty.data.anim2_loop_bullet_fire = pWeaponStat->GetWeaponAnim2LoopFireTime();

            WeaponProperty.data.anim_breakout_time = pWeaponStat->GetWeaponAnimBreakoutTime();
            BitStream.Write( &WeaponProperty );
        }
        if ( BitStream.Version () >= 0x36 )
        {
            BitStream.WriteBit ( g_pGame->GetJetpackWeaponEnabled ( (eWeaponType) i ) );
        }
    }
    if ( BitStream.Version () >= 0x30 )
    {
        for (int i = WEAPONTYPE_CAMERA; i <= WEAPONTYPE_PARACHUTE; i++)
        {
            bool bEnabled;
            bEnabled = g_pGame->GetJetpackWeaponEnabled ( (eWeaponType) i );
            BitStream.WriteBit ( bEnabled );
        }
    }

    multimap< unsigned short, CBuildingRemoval* >::const_iterator iter = g_pGame->GetBuildingRemovalManager ( )->IterBegin();
    for (; iter != g_pGame->GetBuildingRemovalManager ( )->IterEnd();++iter)
    {
        CBuildingRemoval * pBuildingRemoval = (*iter).second;
        BitStream.WriteBit( true );
        BitStream.Write( pBuildingRemoval->GetModel ( ) );
        BitStream.Write( pBuildingRemoval->GetRadius ( ) );
        BitStream.Write( pBuildingRemoval->GetPosition ( ).fX );
        BitStream.Write( pBuildingRemoval->GetPosition ( ).fY );
        BitStream.Write( pBuildingRemoval->GetPosition ( ).fZ );
        if ( BitStream.Version() >= 0x039 )
        {
            BitStream.Write ( pBuildingRemoval->GetInterior ( ) );
        }
    }
    BitStream.WriteBit( false );

    if ( BitStream.Version () >= 0x25 )
    {
        bool bOcclusionsEnabled = g_pGame->GetOcclusionsEnabled ();
        BitStream.WriteBit( bOcclusionsEnabled );
    }

    return true;
}
Beispiel #2
0
bool CMapInfoPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    // Write the map weather
    BitStream.Write ( m_ucWeather );
    BitStream.Write ( m_ucWeatherBlendingTo );
    BitStream.Write ( m_ucBlendedWeatherHour );

    BitStream.WriteBit ( m_bHasSkyGradient );
    if ( m_bHasSkyGradient )
    {
        BitStream.Write ( m_ucSkyGradientTR );
        BitStream.Write ( m_ucSkyGradientTG );
        BitStream.Write ( m_ucSkyGradientTB );
        BitStream.Write ( m_ucSkyGradientBR );
        BitStream.Write ( m_ucSkyGradientBG );
        BitStream.Write ( m_ucSkyGradientBB );
    }

    // Write heat haze
    BitStream.WriteBit ( m_bHasHeatHaze );
    if ( m_bHasHeatHaze )
    {
        SHeatHazeSync heatHaze ( m_HeatHazeSettings );
        BitStream.Write ( &heatHaze );
    }

    // Write the map hour
    BitStream.Write ( m_ucClockHour );
    BitStream.Write ( m_ucClockMin );

    BitStream.WriteCompressed ( m_ulMinuteDuration );

    // Write the map flags
    SMapInfoFlagsSync flags;
    flags.data.bShowNametags  = m_bShowNametags;
    flags.data.bShowRadar     = m_bShowRadar;
    flags.data.bCloudsEnabled = m_bCloudsEnabled;
    BitStream.Write ( &flags );

    // Write any other world conditions
    BitStream.Write ( m_fGravity );
    if ( m_fGameSpeed == 1.0f )
        BitStream.WriteBit ( true );
    else
    {
        BitStream.WriteBit ( false );
        BitStream.Write ( m_fGameSpeed );
    }
    BitStream.Write ( m_fWaveHeight );
    // Write world water level
    BitStream.Write ( m_WorldWaterLevelInfo.fSeaLevel );
    BitStream.WriteBit ( m_WorldWaterLevelInfo.bNonSeaLevelSet );
    if ( m_WorldWaterLevelInfo.bNonSeaLevelSet )
        BitStream.Write ( m_WorldWaterLevelInfo.fNonSeaLevel );

    BitStream.WriteCompressed ( m_usFPSLimit );

    // Write the garage states
    for ( unsigned char i = 0 ; i < MAX_GARAGES ; i++ )
    {
        BitStream.WriteBit( static_cast < unsigned char > ( m_pbGarageStates[i] ) );
    }

    // Write the fun bugs state
    SFunBugsStateSync funBugs;
    funBugs.data.bQuickReload = g_pGame->IsGlitchEnabled ( CGame::GLITCH_QUICKRELOAD );
    funBugs.data.bFastFire    = g_pGame->IsGlitchEnabled ( CGame::GLITCH_FASTFIRE );
    funBugs.data.bFastMove    = g_pGame->IsGlitchEnabled ( CGame::GLITCH_FASTMOVE );
    funBugs.data.bCrouchBug   = g_pGame->IsGlitchEnabled ( CGame::GLITCH_CROUCHBUG );
    funBugs.data.bCloseRangeDamage = g_pGame->IsGlitchEnabled ( CGame::GLITCH_CLOSEDAMAGE );
    BitStream.Write ( &funBugs );

    BitStream.Write ( m_fJetpackMaxHeight );

    BitStream.WriteBit ( m_bOverrideWaterColor );
    if ( m_bOverrideWaterColor )
    {
        BitStream.Write ( m_ucWaterRed );
        BitStream.Write ( m_ucWaterGreen );
        BitStream.Write ( m_ucWaterBlue );
        BitStream.Write ( m_ucWaterAlpha );
    }

    // Interior sounds
    BitStream.WriteBit ( m_bInteriorSoundsEnabled );

    // Rain level
    BitStream.WriteBit ( m_bOverrideRainLevel );
    if ( m_bOverrideRainLevel )
    {
        BitStream.Write ( m_fRainLevel );
    }

    // Sun size
    BitStream.WriteBit ( m_bOverrideSunSize );
    if ( m_bOverrideSunSize )
    {
        BitStream.Write ( m_fSunSize );
    }

    // Sun color
    BitStream.WriteBit ( m_bOverrideSunColor );
    if ( m_bOverrideSunColor )
    {
        BitStream.Write ( m_ucSunCoreR );
        BitStream.Write ( m_ucSunCoreG );
        BitStream.Write ( m_ucSunCoreB );
        BitStream.Write ( m_ucSunCoronaR );
        BitStream.Write ( m_ucSunCoronaG );
        BitStream.Write ( m_ucSunCoronaB );
    }

    // Wind velocity
    BitStream.WriteBit ( m_bOverrideWindVelocity );
    if ( m_bOverrideWindVelocity )
    {
        BitStream.Write ( m_fWindVelX );
        BitStream.Write ( m_fWindVelY );
        BitStream.Write ( m_fWindVelZ );
    }

    // Far clip distance
    BitStream.WriteBit ( m_bOverrideFarClipDistance );
    if ( m_bOverrideFarClipDistance )
    {
        BitStream.Write ( m_fFarClip );
    }

    // Fog distance
    BitStream.WriteBit ( m_bOverrideFogDistance );
    if ( m_bOverrideFogDistance )
    {
        BitStream.Write ( m_fFogDistance );
    }

    BitStream.Write ( m_fAircraftMaxHeight );

    for (int i = WEAPONTYPE_PISTOL;i <= WEAPONTYPE_EXTINGUISHER;i++)
    {
        sWeaponPropertySync WeaponProperty;
        CWeaponStat* pWeaponStat = g_pGame->GetWeaponStatManager ()->GetWeaponStats( (eWeaponType)i );
        BitStream.WriteBit ( true );
        WeaponProperty.data.weaponType = (int)pWeaponStat->GetWeaponType();
        WeaponProperty.data.fAccuracy = pWeaponStat->GetAccuracy();
        WeaponProperty.data.fMoveSpeed = pWeaponStat->GetMoveSpeed();
        WeaponProperty.data.fTargetRange = pWeaponStat->GetTargetRange();
        WeaponProperty.data.fWeaponRange = pWeaponStat->GetWeaponRange();
        WeaponProperty.data.nAmmo = pWeaponStat->GetMaximumClipAmmo();
        WeaponProperty.data.nDamage = pWeaponStat->GetDamagePerHit();
        WeaponProperty.data.nFlags = pWeaponStat->GetFlags();

        WeaponProperty.data.anim_loop_start = pWeaponStat->GetWeaponAnimLoopStart();
        WeaponProperty.data.anim_loop_stop = pWeaponStat->GetWeaponAnimLoopStop();
        WeaponProperty.data.anim_loop_bullet_fire = pWeaponStat->GetWeaponAnimLoopFireTime();

        WeaponProperty.data.anim2_loop_start = pWeaponStat->GetWeaponAnim2LoopStart();
        WeaponProperty.data.anim2_loop_stop = pWeaponStat->GetWeaponAnim2LoopStop();
        WeaponProperty.data.anim2_loop_bullet_fire = pWeaponStat->GetWeaponAnim2LoopFireTime();

        WeaponProperty.data.anim_breakout_time = pWeaponStat->GetWeaponAnimBreakoutTime();
        BitStream.Write( &WeaponProperty );
    }

    for (int i = WEAPONTYPE_PISTOL;i <= WEAPONTYPE_TEC9;i++)
    {
        sWeaponPropertySync WeaponProperty;
        BitStream.WriteBit ( true );
        for (int j = 0; j <= 2;j++)
        {
            CWeaponStat* pWeaponStat = g_pGame->GetWeaponStatManager ()->GetWeaponStats( (eWeaponType)i, (eWeaponSkill)j );
            WeaponProperty.data.weaponType = (int)pWeaponStat->GetWeaponType();
            WeaponProperty.data.fAccuracy = pWeaponStat->GetAccuracy();
            WeaponProperty.data.fMoveSpeed = pWeaponStat->GetMoveSpeed();
            WeaponProperty.data.fTargetRange = pWeaponStat->GetTargetRange();
            WeaponProperty.data.fWeaponRange = pWeaponStat->GetWeaponRange();
            WeaponProperty.data.nAmmo = pWeaponStat->GetMaximumClipAmmo();
            WeaponProperty.data.nDamage = pWeaponStat->GetDamagePerHit();
            WeaponProperty.data.nFlags = pWeaponStat->GetFlags();

            WeaponProperty.data.anim_loop_start = pWeaponStat->GetWeaponAnimLoopStart();
            WeaponProperty.data.anim_loop_stop = pWeaponStat->GetWeaponAnimLoopStop();
            WeaponProperty.data.anim_loop_bullet_fire = pWeaponStat->GetWeaponAnimLoopFireTime();

            WeaponProperty.data.anim2_loop_start = pWeaponStat->GetWeaponAnim2LoopStart();
            WeaponProperty.data.anim2_loop_stop = pWeaponStat->GetWeaponAnim2LoopStop();
            WeaponProperty.data.anim2_loop_bullet_fire = pWeaponStat->GetWeaponAnim2LoopFireTime();

            WeaponProperty.data.anim_breakout_time = pWeaponStat->GetWeaponAnimBreakoutTime();
            BitStream.Write( &WeaponProperty );
        }
    }

    return true;
}