MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / ServerSendEvent

Method ServerSendEvent

neo/game/Entity.cpp:4747–4782  ·  view source on GitHub ↗

================ 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. ================ */

Source from the content-addressed store, hash-verified

4745================
4746*/
4747void 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================

Callers 1

SwitchToTeamMethod · 0.45

Calls 12

BeginWritingMethod · 0.80
InitMethod · 0.45
WriteByteMethod · 0.45
WriteBitsMethod · 0.45
GetSpawnIdMethod · 0.45
WriteIntMethod · 0.45
GetSizeMethod · 0.45
WriteDataMethod · 0.45
GetDataMethod · 0.45

Tested by

no test coverage detected