================ 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. ================ */
| 4916 | ================ |
| 4917 | */ |
| 4918 | void idEntity::ServerSendEvent( int eventId, const idBitMsg *msg, bool saveEvent, int excludeClient ) const { |
| 4919 | idBitMsg outMsg; |
| 4920 | byte msgBuf[MAX_GAME_MESSAGE_SIZE]; |
| 4921 | |
| 4922 | if ( !gameLocal.isServer ) { |
| 4923 | return; |
| 4924 | } |
| 4925 | |
| 4926 | // prevent dupe events caused by frame re-runs |
| 4927 | if ( !gameLocal.isNewFrame ) { |
| 4928 | return; |
| 4929 | } |
| 4930 | |
| 4931 | outMsg.Init( msgBuf, sizeof( msgBuf ) ); |
| 4932 | outMsg.BeginWriting(); |
| 4933 | outMsg.WriteByte( GAME_RELIABLE_MESSAGE_EVENT ); |
| 4934 | outMsg.WriteBits( gameLocal.GetSpawnId( this ), 32 ); |
| 4935 | outMsg.WriteByte( eventId ); |
| 4936 | outMsg.WriteInt( gameLocal.time ); |
| 4937 | if ( msg ) { |
| 4938 | outMsg.WriteBits( msg->GetSize(), idMath::BitsForInteger( MAX_EVENT_PARAM_SIZE ) ); |
| 4939 | outMsg.WriteData( msg->GetData(), msg->GetSize() ); |
| 4940 | } else { |
| 4941 | outMsg.WriteBits( 0, idMath::BitsForInteger( MAX_EVENT_PARAM_SIZE ) ); |
| 4942 | } |
| 4943 | |
| 4944 | if ( excludeClient != -1 ) { |
| 4945 | networkSystem->ServerSendReliableMessageExcluding( excludeClient, outMsg ); |
| 4946 | } else { |
| 4947 | networkSystem->ServerSendReliableMessage( -1, outMsg ); |
| 4948 | } |
| 4949 | |
| 4950 | if ( saveEvent ) { |
| 4951 | gameLocal.SaveEntityNetworkEvent( this, eventId, msg ); |
| 4952 | } |
| 4953 | } |
| 4954 | |
| 4955 | /* |
| 4956 | ================ |
no test coverage detected