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

Method SendUsercmdsToServer

neo/framework/async/AsyncClient.cpp:671–710  ·  view source on GitHub ↗

================== idAsyncClient::SendUsercmdsToServer ================== */

Source from the content-addressed store, hash-verified

669==================
670*/
671void idAsyncClient::SendUsercmdsToServer( void ) {
672 int i, numUsercmds, index;
673 idBitMsg msg;
674 byte msgBuf[MAX_MESSAGE_SIZE];
675 usercmd_t * last;
676
677 if ( idAsyncNetwork::verbose.GetInteger() == 2 ) {
678 common->Printf( "sending usercmd to server: gameInitId = %d, gameFrame = %d, gameTime = %d\n", gameInitId, gameFrame, gameTime );
679 }
680
681 // generate user command for this client
682 index = gameFrame & ( MAX_USERCMD_BACKUP - 1 );
683 userCmds[index][clientNum] = usercmdGen->GetDirectUsercmd();
684 userCmds[index][clientNum].gameFrame = gameFrame;
685 userCmds[index][clientNum].gameTime = gameTime;
686
687 // send the user commands to the server
688 msg.Init( msgBuf, sizeof( msgBuf ) );
689 msg.WriteInt( serverMessageSequence );
690 msg.WriteInt( gameInitId );
691 msg.WriteInt( snapshotSequence );
692 msg.WriteByte( CLIENT_UNRELIABLE_MESSAGE_USERCMD );
693 msg.WriteShort( clientPrediction );
694
695 numUsercmds = idMath::ClampInt( 0, 10, idAsyncNetwork::clientUsercmdBackup.GetInteger() ) + 1;
696
697 // write the user commands
698 msg.WriteInt( gameFrame );
699 msg.WriteByte( numUsercmds );
700 for ( last = NULL, i = gameFrame - numUsercmds + 1; i <= gameFrame; i++ ) {
701 index = i & ( MAX_USERCMD_BACKUP - 1 );
702 idAsyncNetwork::WriteUserCmdDelta( msg, userCmds[index][clientNum], last );
703 last = &userCmds[index][clientNum];
704 }
705
706 channel.SendMessage( clientPort, clientTime, msg );
707 while( channel.UnsentFragmentsLeft() ) {
708 channel.SendNextFragment( clientPort, clientTime );
709 }
710}
711
712/*
713==================

Callers

nothing calls this directly

Calls 10

GetIntegerMethod · 0.80
GetDirectUsercmdMethod · 0.80
UnsentFragmentsLeftMethod · 0.80
SendNextFragmentMethod · 0.80
PrintfMethod · 0.45
InitMethod · 0.45
WriteIntMethod · 0.45
WriteByteMethod · 0.45
WriteShortMethod · 0.45
SendMessageMethod · 0.45

Tested by

no test coverage detected