Пример #1
0
void CDeathmatchVehicle::ResetDamageModelSync(void)
{
    for (int i = 0; i < MAX_DOORS; i++)
        m_ucLastDoorStates[i] = GetDoorStatus(i);
    for (int i = 0; i < MAX_WHEELS; i++)
        m_ucLastWheelStates[i] = GetWheelStatus(i);
    for (int i = 0; i < MAX_PANELS; i++)
        m_ucLastPanelStates[i] = GetPanelStatus(i);
    for (int i = 0; i < MAX_LIGHTS; i++)
        m_ucLastLightStates[i] = GetLightStatus(i);
}
Пример #2
0
bool CDeathmatchVehicle::SyncDamageModel(void)
{
    SVehicleDamageSync damage(true, true, true, true, true);
    bool               bChanges = false;

    // Copy current door states to the sync structure and mark those that changed
    for (unsigned int i = 0; i < MAX_DOORS; ++i)
    {
        damage.data.ucDoorStates[i] = GetDoorStatus(i);
        if (damage.data.ucDoorStates[i] != m_ucLastDoorStates[i])
        {
            bChanges = true;
            damage.data.bDoorStatesChanged[i] = true;
        }
        else
            damage.data.bDoorStatesChanged[i] = false;
    }
    // Copy current wheel states to the sync structure and mark those that changed
    for (unsigned int i = 0; i < MAX_WHEELS; ++i)
    {
        damage.data.ucWheelStates[i] = GetWheelStatus(i);
        if (damage.data.ucWheelStates[i] != m_ucLastWheelStates[i])
        {
            bChanges = true;
            damage.data.bWheelStatesChanged[i] = true;
        }
        else
            damage.data.bWheelStatesChanged[i] = false;
    }
    // Copy current panel states to the sync structure and mark those that changed
    for (unsigned int i = 0; i < MAX_PANELS; ++i)
    {
        damage.data.ucPanelStates[i] = GetPanelStatus(i);
        if (damage.data.ucPanelStates[i] != m_ucLastPanelStates[i])
        {
            bChanges = true;
            damage.data.bPanelStatesChanged[i] = true;
        }
        else
            damage.data.bPanelStatesChanged[i] = false;
    }
    // Copy current light states to the sync structure and mark those that changed
    for (unsigned int i = 0; i < MAX_LIGHTS; ++i)
    {
        damage.data.ucLightStates[i] = GetLightStatus(i);
        if (damage.data.ucLightStates[i] != m_ucLastLightStates[i])
        {
            bChanges = true;
            damage.data.bLightStatesChanged[i] = true;
        }
        else
            damage.data.bLightStatesChanged[i] = false;
    }

    // Something has changed?
    if (bChanges)
    {
        // Set the last state to current
        m_ucLastDoorStates = damage.data.ucDoorStates;
        m_ucLastWheelStates = damage.data.ucWheelStates;
        m_ucLastPanelStates = damage.data.ucPanelStates;
        m_ucLastLightStates = damage.data.ucLightStates;

        // Sync it
        NetBitStreamInterface* pBitStream = g_pNet->AllocateNetBitStream();
        if (pBitStream)
        {
            // Write the vehicle id and the damage model data
            pBitStream->Write(m_ID);
            pBitStream->Write(&damage);

            // Send and delete it
            g_pNet->SendPacket(PACKET_ID_VEHICLE_DAMAGE_SYNC, pBitStream, PACKET_PRIORITY_HIGH, PACKET_RELIABILITY_RELIABLE_ORDERED);
            g_pNet->DeallocateNetBitStream(pBitStream);
        }

        return true;
    }

    return false;
}
Пример #3
0
void DeleteAniTile( ANITILE *pAniTile )
{
	ANITILE				*pAniNode				= NULL;
	ANITILE				*pOldAniNode		= NULL;
	TILE_ELEMENT	*TileElem;

	pAniNode = pAniTileHead;

	while( pAniNode!= NULL )
	{
		if ( pAniNode == pAniTile )
		{
			// OK, set links
			// Check for head or tail
			if ( pOldAniNode == NULL )
			{
				// It's the head
				pAniTileHead = pAniTile->pNext;
			}
			else
			{
				pOldAniNode->pNext = pAniNode->pNext;
			}

			if ( !(pAniNode->uiFlags & ANITILE_EXISTINGTILE  ) )
			{

				// Delete memory assosiated with item
				switch( pAniNode->ubLevelID )
				{
					case ANI_STRUCT_LEVEL:
						
						RemoveStructFromLevelNode( pAniNode->sGridNo, pAniNode->pLevelNode );
						break;

					case ANI_SHADOW_LEVEL:
						
						RemoveShadowFromLevelNode( pAniNode->sGridNo, pAniNode->pLevelNode );
						break;

					case ANI_OBJECT_LEVEL:
						
						RemoveObject( pAniNode->sGridNo, pAniNode->usTileIndex );
						break;

					case ANI_ROOF_LEVEL:
						
						RemoveRoof( pAniNode->sGridNo, pAniNode->usTileIndex );
						break;

					case ANI_ONROOF_LEVEL:
						
						RemoveOnRoof( pAniNode->sGridNo, pAniNode->usTileIndex );
						break;

					case ANI_TOPMOST_LEVEL:
						
						RemoveTopmostFromLevelNode( pAniNode->sGridNo, pAniNode->pLevelNode );
						break;

				}

				if ( ( pAniNode->uiFlags & ANITILE_CACHEDTILE ) )
				{
					RemoveCachedTile( pAniNode->sCachedTileID );
				}

				if ( pAniNode->uiFlags & ANITILE_EXPLOSION )
				{
					// Talk to the explosion data...
					RemoveExplosionData( pAniNode->uiUserData3 );

					if ( !gfExplosionQueueActive )
					{
						// turn on sighting again
						// the explosion queue handles all this at the end of the queue
						gTacticalStatus.uiFlags &= (~DISALLOW_SIGHT);
					}

          // Freeup attacker from explosion
		      DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("@@@@@@@ Reducing attacker busy count..., EXPLOSION effect gone off") );
		      ReduceAttackBusyCount( (UINT8)pAniNode->ubUserData2, FALSE );

				}


				if ( pAniNode->uiFlags & ANITILE_RELEASE_ATTACKER_WHEN_DONE )
				{
					// First delete the bullet!
					RemoveBullet( pAniNode->uiUserData3 );
					
					DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("@@@@@@@ Freeing up attacker - miss finished animation") );
					FreeUpAttacker( (UINT8) pAniNode->ubAttackerMissed );					
				}

			}
			else
			{
				TileElem = &( gTileDatabase[ pAniNode->usTileIndex ] );

				// OK, update existing tile usIndex....
				Assert( TileElem->pAnimData != NULL );
				pAniNode->pLevelNode->usIndex = TileElem->pAnimData->pusFrames[ pAniNode->pLevelNode->sCurrentFrame ];

				// OK, set our frame data back to zero....
				pAniNode->pLevelNode->sCurrentFrame = 0;
				
				// Set some flags to write to Z / update save buffer
				// pAniNode->pLevelNode->uiFlags |=( LEVELNODE_LASTDYNAMIC | LEVELNODE_UPDATESAVEBUFFERONCE );
				pAniNode->pLevelNode->uiFlags &= ~( LEVELNODE_DYNAMIC | LEVELNODE_USEZ | LEVELNODE_ANIMATION );

				if (pAniNode->uiFlags & ANITILE_DOOR)
				{
					// unset door busy!
					DOOR_STATUS * pDoorStatus;

					pDoorStatus = GetDoorStatus( pAniNode->sGridNo );
					if (pDoorStatus)
					{
						pDoorStatus->ubFlags &= ~(DOOR_BUSY);
					}

					if ( GridNoOnScreen( pAniNode->sGridNo ) )
					{
						SetRenderFlags(RENDER_FLAG_FULL);
					}

				}
			}

			MemFree( pAniNode );
			return;
		}

		pOldAniNode = pAniNode;
		pAniNode		= pAniNode->pNext;

	}


}