This is a fork of Zandronum for Mac Os (Silicon and Intel)
Revisión | fad199a4c89bedf7593066ecdfc0cd61cef643e2 (tree) |
---|---|
Tiempo | 2021-12-01 12:54:42 |
Autor | Adam Kaminski <kaminskiadam9@gmai...> |
Commiter | Adam Kaminski |
The server now waits until it has received as many move commands from the player as it emulated during extrapolation, then performs a backtrace. This means that the gametics associated with each command don't matter anymore and no commands shall be ignored.
@@ -172,7 +172,7 @@ | ||
172 | 172 | static bool server_InfoCheat( BYTESTREAM_s* pByteStream ); |
173 | 173 | static bool server_CheckLogin( const ULONG ulClient ); |
174 | 174 | static void server_PrintWithIP( FString message, const NETADDRESS_s &address ); |
175 | -static void server_PerformBacktrace( ULONG ulClient ); | |
175 | +static void server_PerformBacktrace( ULONG ulClient, ULONG ulNumLateMoveCMDs ); | |
176 | 176 | static bool server_ShouldPerformBacktrace( ULONG ulClient ); |
177 | 177 | static void server_FixZFromBacktrace( APlayerPawn *pmo, fixed_t oldFloorZ ); |
178 | 178 |
@@ -5213,18 +5213,23 @@ | ||
5213 | 5213 | { |
5214 | 5214 | if ( ulClientTic != 0 ) |
5215 | 5215 | { |
5216 | - if ( sv_smoothplayers ) | |
5216 | + // [AK] It's possible that we were extrapolating this player's movement. If that's the case, | |
5217 | + // then we're going to store any incoming commands into a separate buffer until we receive | |
5218 | + // as many of them as we emulated during extrapolation. Once that happens, we'll use them to | |
5219 | + // backtrace the player's actual movement. | |
5220 | + if (( sv_smoothplayers ) && ( g_aClients[g_lCurrentClient].ulExtrapolatedTics > 0 )) | |
5217 | 5221 | { |
5218 | - // [AK] It's possible this was a command that arrived late and we already extrapolated | |
5219 | - // the player's movement at this tic. In this case, we'll store these commands into a | |
5220 | - // separate buffer so we can backtrace the player's actual movement. | |
5221 | - if (( g_aClients[g_lCurrentClient].LastMoveCMD != NULL ) && ( g_aClients[g_lCurrentClient].ulExtrapolatedTics > 0 )) | |
5222 | + ULONG ulNumLateMoveCMDs = 0; | |
5223 | + | |
5224 | + // [AK] Only count how many movement commands are in the buffer, weapon select command don't matter. | |
5225 | + for ( unsigned int i = 0; i < g_aClients[g_lCurrentClient].LateMoveCMDs.Size( ); i++ ) | |
5222 | 5226 | { |
5223 | - // [AK] We want to try filling this buffer only when the client is suffering from a ping | |
5224 | - // spike, not when they're experiencing packet loss. | |
5225 | - if ( ulClientTic <= g_aClients[g_lCurrentClient].ulClientGameTic + g_aClients[g_lCurrentClient].ulExtrapolatedTics ) | |
5226 | - buffer = &g_aClients[g_lCurrentClient].LateMoveCMDs; | |
5227 | + if ( g_aClients[g_lCurrentClient].LateMoveCMDs[i]->isMoveCmd( )) | |
5228 | + ulNumLateMoveCMDs++; | |
5227 | 5229 | } |
5230 | + | |
5231 | + if ( ulNumLateMoveCMDs < g_aClients[g_lCurrentClient].ulExtrapolatedTics ) | |
5232 | + buffer = &g_aClients[g_lCurrentClient].LateMoveCMDs; | |
5228 | 5233 | } |
5229 | 5234 | |
5230 | 5235 | for ( unsigned int i = 0; i < buffer->Size( ); i++ ) |
@@ -5386,8 +5391,8 @@ | ||
5386 | 5391 | |
5387 | 5392 | // [AK] If we have enough late commands in the buffer, process them all immediately, so as long |
5388 | 5393 | // as they hadn't morphed or unmorphed at any point during extrapolation. |
5389 | - if (( ulNumLateMoveCMDs > 0 ) && ( ulNumMoveCMDs > 0 || ulNumLateMoveCMDs == pClient->ulExtrapolatedTics ) && ( pClient->OldData != NULL )) | |
5390 | - server_PerformBacktrace( ulClient ); | |
5394 | + if (( pClient->OldData != NULL ) && ( pClient->ulExtrapolatedTics > 0 ) && ( pClient->ulExtrapolatedTics == ulNumLateMoveCMDs )) | |
5395 | + server_PerformBacktrace( ulClient, ulNumLateMoveCMDs ); | |
5391 | 5396 | |
5392 | 5397 | // [AK] If there are no movement commands left in the client's tic buffer then we'll keep processing |
5393 | 5398 | // the last movement command we received from them, but we won't extrapolate more than we should. |
@@ -5407,15 +5412,6 @@ | ||
5407 | 5412 | |
5408 | 5413 | pClient->LastMoveCMD->process( ulClient ); |
5409 | 5414 | } |
5410 | - | |
5411 | - // [AK] Reset the client's extrapolation data if necessary. | |
5412 | - if (( ulNumMoveCMDs > 0 ) && ( pClient->ulExtrapolatedTics > 0 )) | |
5413 | - { | |
5414 | - if ( sv_smoothplayers_debuginfo ) | |
5415 | - Printf( "%d: resetting extrapolation data for %s.\n", gametic, players[ulClient].userinfo.GetName( )); | |
5416 | - | |
5417 | - SERVER_ResetClientExtrapolation( ulClient ); | |
5418 | - } | |
5419 | 5415 | } |
5420 | 5416 | else if ( pClient->ulExtrapolatedTics > 0 ) |
5421 | 5417 | { |
@@ -7447,7 +7443,7 @@ | ||
7447 | 7443 | |
7448 | 7444 | //***************************************************************************** |
7449 | 7445 | // |
7450 | -static void server_PerformBacktrace( ULONG ulClient ) | |
7446 | +static void server_PerformBacktrace( ULONG ulClient, ULONG ulNumLateMoveCMDs ) | |
7451 | 7447 | { |
7452 | 7448 | CLIENT_s *pClient = &g_aClients[ulClient]; |
7453 | 7449 | APlayerPawn *pmo = players[ulClient].mo; |
@@ -7477,39 +7473,25 @@ | ||
7477 | 7473 | // [AK] Check if the player hasn't moved into a spot that's blocking them or something else. |
7478 | 7474 | if ( P_TestMobjLocation( players[ulClient].mo )) |
7479 | 7475 | { |
7480 | - ULONG ulExtrapolateStartTic = pClient->LastMoveCMD->getClientTic( ); | |
7481 | - ULONG ulNumExtrapolatedTics = pClient->ulExtrapolatedTics; | |
7476 | + ULONG ulNumProcessedMoveCMDs = 0; | |
7482 | 7477 | fixed_t oldFloorZ = 0; |
7483 | 7478 | |
7484 | 7479 | pClient->bIsBacktracing = true; |
7485 | 7480 | pClient->ulExtrapolatedTics = 0; |
7486 | 7481 | |
7487 | - // [AK] Ideally, we want to have as many late move commands in the buffer as the number of tics we | |
7488 | - // extrapolated this player for. If that's not the case, however, then we'll try "filling in the gaps" | |
7489 | - // by re-processing the command we last processed until every tic is accounted for. | |
7490 | - for ( ULONG ulTic = 1; ulTic <= ulNumExtrapolatedTics; ulTic++ ) | |
7482 | + for ( int tic = 0; tic < static_cast<int>( pClient->LateMoveCMDs.Size( )); tic++ ) | |
7491 | 7483 | { |
7492 | - if (( pClient->LateMoveCMDs.Size( ) > 0 ) && ( pClient->LateMoveCMDs[0]->getClientTic( ) == ulExtrapolateStartTic + ulTic )) | |
7484 | + // [AK] If this is a weapon select command, just process it and move onto the next late command. | |
7485 | + if ( pClient->LateMoveCMDs[tic]->isMoveCmd( ) == false ) | |
7493 | 7486 | { |
7494 | - // [AK] If this is a weapon select command, just process it and move onto the next late command. | |
7495 | - if ( pClient->LateMoveCMDs[0]->isMoveCmd( ) == false ) | |
7496 | - { | |
7497 | - pClient->LateMoveCMDs[0]->process( ulClient ); | |
7498 | - | |
7499 | - delete pClient->LateMoveCMDs[0]; | |
7500 | - pClient->LateMoveCMDs.Delete( 0 ); | |
7501 | - | |
7502 | - ulTic--; | |
7503 | - continue; | |
7504 | - } | |
7505 | - | |
7506 | - delete pClient->LastMoveCMD; | |
7507 | - pClient->LastMoveCMD = new ClientMoveCommand( *static_cast<ClientMoveCommand *>( pClient->LateMoveCMDs[0] )); | |
7508 | - | |
7509 | - delete pClient->LateMoveCMDs[0]; | |
7510 | - pClient->LateMoveCMDs.Delete( 0 ); | |
7487 | + pClient->LateMoveCMDs[tic]->process( ulClient ); | |
7488 | + continue; | |
7511 | 7489 | } |
7512 | 7490 | |
7491 | + // [AK] This becomes the last movement command we received from the client. | |
7492 | + delete pClient->LastMoveCMD; | |
7493 | + pClient->LastMoveCMD = new ClientMoveCommand( *static_cast<ClientMoveCommand *>( pClient->LateMoveCMDs[tic] )); | |
7494 | + | |
7513 | 7495 | pClient->LastMoveCMD->process( ulClient ); |
7514 | 7496 | |
7515 | 7497 | // [AK] Now we have to tick this player's body and set the proper psprite settings. |
@@ -7521,7 +7503,7 @@ | ||
7521 | 7503 | |
7522 | 7504 | // [AK] Adjust the sector ceiling/floor heights for the next tic that we extrapolated the player. |
7523 | 7505 | // We don't have to do this on the last tic that we extrapolated the player. |
7524 | - if ( ulTic < ulNumExtrapolatedTics ) | |
7506 | + if ( ++ulNumProcessedMoveCMDs < ulNumLateMoveCMDs ) | |
7525 | 7507 | { |
7526 | 7508 | unlaggedIndex = ( unlaggedIndex + 1 ) % UNLAGGEDTICS; |
7527 | 7509 |
@@ -7546,8 +7528,6 @@ | ||
7546 | 7528 | // [AK] As a final measure, fix the player's floorz/ceilingz and to ensure that they don't |
7547 | 7529 | // get stuck in the floor/ceiling of whatever sector they're supposed to be in. |
7548 | 7530 | server_FixZFromBacktrace( pmo, oldFloorZ ); |
7549 | - | |
7550 | - pClient->LastMoveCMD->setClientTic( ulExtrapolateStartTic + ulNumExtrapolatedTics ); | |
7551 | 7531 | debugMessage += "accepted"; |
7552 | 7532 | } |
7553 | 7533 | else |