• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoawindowspythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdombtronvb.netdirectxarduinopreviewerゲームエンジン

This is a fork of Zandronum for Mac Os (M1 and Intel)


Commit MetaInfo

Revisionfad199a4c89bedf7593066ecdfc0cd61cef643e2 (tree)
Time2021-12-01 12:54:42
AuthorAdam Kaminski <kaminskiadam9@gmai...>
CommiterAdam Kaminski

Log Message

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.

Change Summary

Incremental Difference

diff -r ff855e8a94f9 -r fad199a4c89b src/sv_main.cpp
--- a/src/sv_main.cpp Mon Nov 29 10:15:15 2021 -0500
+++ b/src/sv_main.cpp Tue Nov 30 22:54:42 2021 -0500
@@ -172,7 +172,7 @@
172172 static bool server_InfoCheat( BYTESTREAM_s* pByteStream );
173173 static bool server_CheckLogin( const ULONG ulClient );
174174 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 );
176176 static bool server_ShouldPerformBacktrace( ULONG ulClient );
177177 static void server_FixZFromBacktrace( APlayerPawn *pmo, fixed_t oldFloorZ );
178178
@@ -5213,18 +5213,23 @@
52135213 {
52145214 if ( ulClientTic != 0 )
52155215 {
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 ))
52175221 {
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++ )
52225226 {
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++;
52275229 }
5230+
5231+ if ( ulNumLateMoveCMDs < g_aClients[g_lCurrentClient].ulExtrapolatedTics )
5232+ buffer = &g_aClients[g_lCurrentClient].LateMoveCMDs;
52285233 }
52295234
52305235 for ( unsigned int i = 0; i < buffer->Size( ); i++ )
@@ -5386,8 +5391,8 @@
53865391
53875392 // [AK] If we have enough late commands in the buffer, process them all immediately, so as long
53885393 // 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 );
53915396
53925397 // [AK] If there are no movement commands left in the client's tic buffer then we'll keep processing
53935398 // the last movement command we received from them, but we won't extrapolate more than we should.
@@ -5407,15 +5412,6 @@
54075412
54085413 pClient->LastMoveCMD->process( ulClient );
54095414 }
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- }
54195415 }
54205416 else if ( pClient->ulExtrapolatedTics > 0 )
54215417 {
@@ -7447,7 +7443,7 @@
74477443
74487444 //*****************************************************************************
74497445 //
7450-static void server_PerformBacktrace( ULONG ulClient )
7446+static void server_PerformBacktrace( ULONG ulClient, ULONG ulNumLateMoveCMDs )
74517447 {
74527448 CLIENT_s *pClient = &g_aClients[ulClient];
74537449 APlayerPawn *pmo = players[ulClient].mo;
@@ -7477,39 +7473,25 @@
74777473 // [AK] Check if the player hasn't moved into a spot that's blocking them or something else.
74787474 if ( P_TestMobjLocation( players[ulClient].mo ))
74797475 {
7480- ULONG ulExtrapolateStartTic = pClient->LastMoveCMD->getClientTic( );
7481- ULONG ulNumExtrapolatedTics = pClient->ulExtrapolatedTics;
7476+ ULONG ulNumProcessedMoveCMDs = 0;
74827477 fixed_t oldFloorZ = 0;
74837478
74847479 pClient->bIsBacktracing = true;
74857480 pClient->ulExtrapolatedTics = 0;
74867481
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++ )
74917483 {
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 )
74937486 {
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;
75117489 }
75127490
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+
75137495 pClient->LastMoveCMD->process( ulClient );
75147496
75157497 // [AK] Now we have to tick this player's body and set the proper psprite settings.
@@ -7521,7 +7503,7 @@
75217503
75227504 // [AK] Adjust the sector ceiling/floor heights for the next tic that we extrapolated the player.
75237505 // We don't have to do this on the last tic that we extrapolated the player.
7524- if ( ulTic < ulNumExtrapolatedTics )
7506+ if ( ++ulNumProcessedMoveCMDs < ulNumLateMoveCMDs )
75257507 {
75267508 unlaggedIndex = ( unlaggedIndex + 1 ) % UNLAGGEDTICS;
75277509
@@ -7546,8 +7528,6 @@
75467528 // [AK] As a final measure, fix the player's floorz/ceilingz and to ensure that they don't
75477529 // get stuck in the floor/ceiling of whatever sector they're supposed to be in.
75487530 server_FixZFromBacktrace( pmo, oldFloorZ );
7549-
7550- pClient->LastMoveCMD->setClientTic( ulExtrapolateStartTic + ulNumExtrapolatedTics );
75517531 debugMessage += "accepted";
75527532 }
75537533 else