• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-c誰得cocoaqtpythonrubywindowsphpgameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwitterdombtronvb.nettestarduinodirectxpreviewerゲームエンジン

This is a fork of Zandronum Beta for TSPG.


Commit MetaInfo

Revisionbef9a71cd25de4d03c4fd3bc11f9c2fbaf4a0ddb (tree)
Time2021-11-22 07:32:33
AuthorJoshua Surace <doomjoshuaboy@live...>
CommiterJoshua Surace

Log Message

Repurposed cl_backupcommands so that clients can send backup commands for the server to use to perform a backtrace, even they suffer from packet loss. This means backup commands don't delay a player's input anymore.

Change Summary

Incremental Difference

diff -r bc71b20f4906 -r bef9a71cd25d src/cl_commands.cpp
--- a/src/cl_commands.cpp Mon Nov 22 09:23:55 2021 +1100
+++ b/src/cl_commands.cpp Mon Nov 22 09:32:33 2021 +1100
@@ -432,7 +432,7 @@
432432 CLIENT_MOVE_COMMAND_s moveCMD = clientcommand_CreateMoveCommand( );
433433
434434 // [AK] If we don't want to send backup commands, send only this one and that's it.
435- if ( cl_backupcommands == 0 )
435+ if (( sv_smoothplayers == 0 ) || ( cl_backupcommands == 0 ))
436436 {
437437 CLIENT_GetLocalBuffer( )->ByteStream.WriteByte( CLC_CLIENTMOVE );
438438 clientcommand_WriteMoveCommandToBuffer( moveCMD );
@@ -455,10 +455,8 @@
455455 ULONG ulNumCMDsToSend = MIN( ulNumSavedCMDs, ulNumExpectedCMDs );
456456 CLIENT_GetLocalBuffer( )->ByteStream.WriteByte( CLC_CLIENTMOVEBACKUP );
457457
458- // [AK] We need to tell the server the number of movement commands we sent, and
459- // up to how many movment commands we actually want to send.
460- CLIENT_GetLocalBuffer( )->ByteStream.WriteShortByte( ulNumCMDsToSend, 4 );
461- CLIENT_GetLocalBuffer( )->ByteStream.WriteShortByte( ulNumExpectedCMDs, 4 );
458+ // [AK] We need to tell the server the number of movement commands we sent.
459+ CLIENT_GetLocalBuffer( )->ByteStream.WriteByte( ulNumCMDsToSend );
462460
463461 // [AK] Older movement commands must be written to the buffer before newer ones.
464462 for ( int i = ulNumCMDsToSend; i >= 1; i-- )
diff -r bc71b20f4906 -r bef9a71cd25d src/cl_main.h
--- a/src/cl_main.h Mon Nov 22 09:23:55 2021 +1100
+++ b/src/cl_main.h Mon Nov 22 09:32:33 2021 +1100
@@ -62,7 +62,7 @@
6262 #define GAMESTATE_RESEND_TIME ( 3 * TICRATE )
6363
6464 // [AK] The maximum number of move commands we're allowed to send per tic.
65-#define MAX_BACKUP_COMMANDS 3
65+#define MAX_BACKUP_COMMANDS 4
6666
6767 //*****************************************************************************
6868 enum CONNECTIONSTATE_e
diff -r bc71b20f4906 -r bef9a71cd25d src/p_tick.cpp
--- a/src/p_tick.cpp Mon Nov 22 09:23:55 2021 +1100
+++ b/src/p_tick.cpp Mon Nov 22 09:32:33 2021 +1100
@@ -333,9 +333,6 @@
333333 ulNumMoveCMDs++;
334334 }
335335
336- // [AK] Check if we should process this client's movement commands.
337- bool bProcessMoveCMD = SERVER_ShouldProcessMoveCommand( ulIdx, ulNumMoveCMDs );
338-
339336 // [AK] Handle the skip correction.
340337 SERVER_HandleSkipCorrection( ulIdx, ulNumMoveCMDs );
341338
@@ -343,10 +340,9 @@
343340 {
344341 // Process only one movement command.
345342 const bool bMovement = client->MoveCMDs[0]->isMoveCmd( );
346-
347- // [AK] Only update the last movement command if we're supposed to be processing any
348- // movement commands in the buffer at this time.
349- if (( bProcessMoveCMD ) && ( bMovement ))
343+ client->MoveCMDs[0]->process( ulIdx );
344+
345+ if ( bMovement )
350346 {
351347 if ( client->LastMoveCMD != NULL )
352348 delete client->LastMoveCMD;
@@ -355,14 +351,8 @@
355351 client->LastMoveCMD = new ClientMoveCommand( *static_cast<ClientMoveCommand *>( client->MoveCMDs[0] ));
356352 }
357353
358- // [AK] Only process movement commands if we're allowed to at this time. On the other
359- // hand, we can still process other commands in the buffer.
360- if (( bProcessMoveCMD ) || ( bMovement == false ))
361- {
362- client->MoveCMDs[0]->process( ulIdx );
363- delete client->MoveCMDs[0];
364- client->MoveCMDs.Delete( 0 );
365- }
354+ delete client->MoveCMDs[0];
355+ client->MoveCMDs.Delete(0);
366356
367357 if ( bMovement == true )
368358 break;
diff -r bc71b20f4906 -r bef9a71cd25d src/sv_main.cpp
--- a/src/sv_main.cpp Mon Nov 22 09:23:55 2021 +1100
+++ b/src/sv_main.cpp Mon Nov 22 09:32:33 2021 +1100
@@ -5298,7 +5298,7 @@
52985298
52995299 if ( sv_useticbuffer )
53005300 {
5301- if (( sv_smoothplayers ) && ( bIsMoveCMD ))
5301+ if ( sv_smoothplayers )
53025302 {
53035303 // [AK] It's possible this was a command that arrived late and we already extrapolated
53045304 // the player's movement at this tic. In this case, we'll store these commands into a
@@ -5352,40 +5352,6 @@
53525352
53535353 //*****************************************************************************
53545354 //
5355-bool SERVER_ShouldProcessMoveCommand( ULONG ulClient, ULONG ulNumMoveCMDs )
5356-{
5357- // [AK] If the client isn't sending us backup commands, then always process movement commands.
5358- if ( g_aClients[ulClient].ulNumExpectedCMDs == 1 )
5359- return true;
5360-
5361- // [AK] If the client is sending us backup commands and their tic buffer is getting too full, we
5362- // must always process their movement commands. This condition is true when the number of commands
5363- // stored in the buffer exceeds the number of commands we expect them to send us per tic.
5364- if ( ulNumMoveCMDs >= g_aClients[ulClient].ulNumExpectedCMDs )
5365- return true;
5366-
5367- // [AK] Don't execute this block if we already processed a movement commands on this tic.
5368- if ( g_aClients[ulClient].lLastMoveTickProcess != gametic )
5369- {
5370- // [AK] We have received enough movement commands from this client to process them, but we can only
5371- // do this once per tic. Otherwise, their tic buffer will become too empty for us to process any
5372- // backup commands properly.
5373- if ( g_aClients[ulClient].ulNumSentCMDs == g_aClients[ulClient].ulNumExpectedCMDs )
5374- return true;
5375-
5376- // [AK] Are we still waiting for the client to send us more movement commands than we expect? In case
5377- // case they suffer from packet loss, we don't want to wait forever to receive all of them , so we'll
5378- // just have process whatever we have. To do this, increment the counter once per tic, which will
5379- // eventually satisfy the condition above this one.
5380- if ( g_aClients[ulClient].lLastMoveTick != gametic )
5381- g_aClients[ulClient].ulNumSentCMDs++;
5382- }
5383-
5384- return false;
5385-}
5386-
5387-//*****************************************************************************
5388-//
53895355 CLIENT_PLAYER_DATA_s::CLIENT_PLAYER_DATA_s ( player_t *player )
53905356 {
53915357 ulSavedGametic = gametic;
@@ -5595,9 +5561,6 @@
55955561 g_aClients[ulClient].LastMoveCMD = NULL;
55965562 }
55975563
5598- // [AK] Also reset the backup command counters.
5599- g_aClients[ulClient].ulNumSentCMDs = g_aClients[ulClient].ulNumExpectedCMDs = 1;
5600-
56015564 SERVER_ResetClientExtrapolation( ulClient );
56025565 }
56035566
@@ -5895,21 +5858,11 @@
58955858 // we process for a player in a given tic to prevent the player from
58965859 // seemingly teleporting in case too many movement commands arrive at once.
58975860 if ( !bSentBackup )
5898- {
5899- g_aClients[g_lCurrentClient].ulNumSentCMDs = 1;
5900- g_aClients[g_lCurrentClient].ulNumExpectedCMDs = 1;
5901-
59025861 return server_ParseBufferedCommand<ClientMoveCommand>( pByteStream );
5903- }
59045862
59055863 // [AK] If we get to this point, that means the client also wanted to
5906- // send us backup movement commands. Here, we'll determine how many commands
5907- // they actually sent us (ulNumSentCMDs), and how many commands they're
5908- // trying to send to us per tic (ulNumExpectedCMDs = cl_backupcommands + 1).
5909- ULONG ulNumSentCMDs = pByteStream->ReadShortByte( 4 );
5910- ULONG ulNumExpectedCMDs = pByteStream->ReadShortByte( 4 );
5911-
5912- ULONG ulOldBufferSize = g_aClients[g_lCurrentClient].MoveCMDs.Size( );
5864+ // send us backup movement commands. Get how many commands they sent us.
5865+ ULONG ulNumSentCMDs = pByteStream->ReadByte( );
59135866 bool result = false;
59145867
59155868 // [AK] Parse all of the movement commands, but also remember if the client
@@ -5920,16 +5873,6 @@
59205873 result = true;
59215874 }
59225875
5923- // [AK] We only want to update the number of sent/expected commands from
5924- // the client if these movement commands weren't treated as late commands
5925- // because of the skip correction. We can figure this out by checking if
5926- // the size of the tic buffer changed at all.
5927- if ( ulOldBufferSize != g_aClients[g_lCurrentClient].MoveCMDs.Size( ))
5928- {
5929- g_aClients[g_lCurrentClient].ulNumSentCMDs = ulNumSentCMDs;
5930- g_aClients[g_lCurrentClient].ulNumExpectedCMDs = ulNumExpectedCMDs;
5931- }
5932-
59335876 return result;
59345877 }
59355878
diff -r bc71b20f4906 -r bef9a71cd25d src/sv_main.h
--- a/src/sv_main.h Mon Nov 22 09:23:55 2021 +1100
+++ b/src/sv_main.h Mon Nov 22 09:32:33 2021 +1100
@@ -472,14 +472,6 @@
472472 // [AK] The number of tics we extrapolated this player's movement.
473473 ULONG ulExtrapolatedTics;
474474
475- // [AK] How many movement commands did this player send us in the last packet? If this is greater than
476- // one, that means they also sent us backups of older commands.
477- ULONG ulNumSentCMDs;
478-
479- // [AK] How many movement commands are we expecting from this player? If this is greater than one, that
480- // means we're expecting them to also send us backups of older commands.
481- ULONG ulNumExpectedCMDs;
482-
483475 // [AK] A list of specials this player executed while being extrapolated.
484476 TArray<CLIENT_SAVED_SPECIAL_s> ExtrapolatedSpecials;
485477
@@ -647,7 +639,6 @@
647639 void SERVER_KillCheat( const char* what );
648640 void STACK_ARGS SERVER_PrintWarning( const char* format, ... ) GCCPRINTF( 1, 2 );
649641 void SERVER_FlagsetChanged( FIntCVar& flagset, int maxflags = 2 );
650-bool SERVER_ShouldProcessMoveCommand( ULONG ulClient, ULONG ulNumMoveCMDs );
651642 void SERVER_HandleSkipCorrection( ULONG ulClient, ULONG ulNumMoveCMDs );
652643 bool SERVER_IsExtrapolatingPlayer( ULONG ulClient );
653644 bool SERVER_IsBacktracingPlayer( ULONG ulClient );
diff -r bc71b20f4906 -r bef9a71cd25d wadsrc/static/menudef.za
--- a/wadsrc/static/menudef.za Mon Nov 22 09:23:55 2021 +1100
+++ b/wadsrc/static/menudef.za Mon Nov 22 09:32:33 2021 +1100
@@ -98,6 +98,7 @@
9898 0.0, "None"
9999 1.0, "One per tick"
100100 2.0, "Two per tick"
101+ 3.0, "Three per tick"
101102 }
102103
103104 OptionMenu ZA_NetworkOptions
@@ -112,13 +113,12 @@
112113 Option "Clientside puffs", "cl_clientsidepuffs", "OnOff"
113114 Option "Display packet loss", "cl_showpacketloss", "YesNo"
114115
115- // [AK] Sending backup commands comes with drawbacks, such as increased outbound
116- // net traffic and their commands being delayed on the server's end. If the client
117- // decides to enable this, they should be made aware of the consequences too.
116+ // [AK] Sending backup commands increases outbound net traffic. If the client decides
117+ // to enable this, they should be made aware of this too.
118118 StaticText " "
119119 StaticText "--- WARNING ---"
120120 StaticText "Sending backup commands helps mitigate packet loss", 1
121- StaticText "but increases outbound net traffic and delays your input!", 1
121+ StaticText "but increases outbound net traffic!", 1
122122 StaticText " "
123123 StaticText "You should only enable them if you're actually", 1
124124 StaticText "suffering from severe packet loss!", 1