================ idEntity::ServerSendEvent Saved events are also sent to any client that connects late so all clients always receive the events nomatter what time they join the game. ================ */
| 4745 | ================ |
| 4746 | */ |
| 4747 | void idEntity::ServerSendEvent( int eventId, const idBitMsg *msg, bool saveEvent, int excludeClient ) const { |
| 4748 | idBitMsg outMsg; |
| 4749 | byte msgBuf[MAX_GAME_MESSAGE_SIZE]; |
| 4750 | |
| 4751 | if ( !gameLocal.isServer ) { |
| 4752 | return; |
| 4753 | } |
| 4754 | |
| 4755 | // prevent dupe events caused by frame re-runs |
| 4756 | if ( !gameLocal.isNewFrame ) { |
| 4757 | return; |
| 4758 | } |
| 4759 | |
| 4760 | outMsg.Init( msgBuf, sizeof( msgBuf ) ); |
| 4761 | outMsg.BeginWriting(); |
| 4762 | outMsg.WriteByte( GAME_RELIABLE_MESSAGE_EVENT ); |
| 4763 | outMsg.WriteBits( gameLocal.GetSpawnId( this ), 32 ); |
| 4764 | outMsg.WriteByte( eventId ); |
| 4765 | outMsg.WriteInt( gameLocal.time ); |
| 4766 | if ( msg ) { |
| 4767 | outMsg.WriteBits( msg->GetSize(), idMath::BitsForInteger( MAX_EVENT_PARAM_SIZE ) ); |
| 4768 | outMsg.WriteData( msg->GetData(), msg->GetSize() ); |
| 4769 | } else { |
| 4770 | outMsg.WriteBits( 0, idMath::BitsForInteger( MAX_EVENT_PARAM_SIZE ) ); |
| 4771 | } |
| 4772 | |
| 4773 | if ( excludeClient != -1 ) { |
| 4774 | networkSystem->ServerSendReliableMessageExcluding( excludeClient, outMsg ); |
| 4775 | } else { |
| 4776 | networkSystem->ServerSendReliableMessage( -1, outMsg ); |
| 4777 | } |
| 4778 | |
| 4779 | if ( saveEvent ) { |
| 4780 | gameLocal.SaveEntityNetworkEvent( this, eventId, msg ); |
| 4781 | } |
| 4782 | } |
| 4783 | |
| 4784 | /* |
| 4785 | ================ |
no test coverage detected