================== idAsyncClient::SendUsercmdsToServer ================== */
| 669 | ================== |
| 670 | */ |
| 671 | void 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 | ================== |
nothing calls this directly
no test coverage detected