================== SV_UserMove The message usually contains all the movement commands that were in the last three packets, so that the information in dropped packets can be recovered. On very fast clients, there may be multiple usercmd packed into each of the backup packets. ================== */
| 412 | ================== |
| 413 | */ |
| 414 | static void SV_UserMove( client_t *cl, msg_t *msg ) { |
| 415 | int i, start; |
| 416 | int cmdNum; |
| 417 | int firstNum; |
| 418 | int cmdCount; |
| 419 | usercmd_t nullcmd; |
| 420 | usercmd_t cmds[MAX_PACKET_USERCMDS]; |
| 421 | usercmd_t *cmd, *oldcmd; |
| 422 | //int clientTime; |
| 423 | int serverId; |
| 424 | |
| 425 | cl->reliableAcknowledge = MSG_ReadLong( msg ); |
| 426 | serverId = MSG_ReadLong( msg ); |
| 427 | /*clientTime = */MSG_ReadLong( msg ); |
| 428 | cl->deltaMessage = MSG_ReadLong( msg ); |
| 429 | |
| 430 | // cmdNum is the command number of the most recent included usercmd |
| 431 | cmdNum = MSG_ReadLong( msg ); |
| 432 | cmdCount = MSG_ReadByte( msg ); |
| 433 | |
| 434 | if ( cmdCount < 1 ) { |
| 435 | Com_Printf( "cmdCount < 1\n" ); |
| 436 | return; |
| 437 | } |
| 438 | |
| 439 | if ( cmdCount > MAX_PACKET_USERCMDS ) { |
| 440 | Com_Printf( "cmdCount > MAX_PACKET_USERCMDS\n" ); |
| 441 | return; |
| 442 | } |
| 443 | |
| 444 | memset( &nullcmd, 0, sizeof(nullcmd) ); |
| 445 | oldcmd = &nullcmd; |
| 446 | for ( i = 0 ; i < cmdCount ; i++ ) { |
| 447 | cmd = &cmds[i]; |
| 448 | MSG_ReadDeltaUsercmd( msg, oldcmd, cmd ); |
| 449 | oldcmd = cmd; |
| 450 | } |
| 451 | |
| 452 | // if this is a usercmd from a previous gamestate, |
| 453 | // ignore it or retransmit the current gamestate |
| 454 | if ( serverId != sv.serverId ) { |
| 455 | // if we can tell that the client has dropped the last |
| 456 | // gamestate we sent them, resend it |
| 457 | if ( cl->netchan.incomingAcknowledged > cl->gamestateMessageNum ) { |
| 458 | Com_DPrintf( "%s : dropped gamestate, resending\n", cl->name ); |
| 459 | SV_SendClientGameState( cl ); |
| 460 | } |
| 461 | return; |
| 462 | } |
| 463 | |
| 464 | // if this is the first usercmd we have received |
| 465 | // this gamestate, put the client into the world |
| 466 | if ( cl->state == CS_PRIMED ) { |
| 467 | |
| 468 | SV_ClientEnterWorld( cl, &cmds[0], eSavedGameJustLoaded ); |
| 469 | if ( sv_mapname->string[0]!='_' ) |
| 470 | { |
| 471 | char savename[MAX_QPATH]; |
no test coverage detected