-
Notifications
You must be signed in to change notification settings - Fork 69
Fix remaining network message overflows #1935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
VReaperV
wants to merge
1
commit into
for-0.56.0/sync
Choose a base branch
from
fix-net-overflow
base: for-0.56.0/sync
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+110
−18
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -368,6 +368,17 @@ void SV_SendClientGameState( client_t *client ) | |
| MSG_WriteByte( &msg, svc_configstring ); | ||
| MSG_WriteShort( &msg, start ); | ||
| MSG_WriteBigString( &msg, sv.configstrings[ start ] ); | ||
|
|
||
| if ( MAX_MSGLEN - msg.cursize < 128 ) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A configstring can be up to 8k so this isn't enough to guarantee there is space |
||
| // We have too much configstring data to put it all into one msg_t, so split it here | ||
| MSG_WriteByte( &msg, svc_partial ); | ||
| SV_SendMessageToClient( &msg, client ); | ||
|
|
||
| MSG_Init( &msg, msgBuffer, sizeof( msgBuffer ) ); | ||
| MSG_WriteLong( &msg, client->lastClientCommand ); | ||
| MSG_WriteByte( &msg, svc_gamestate ); | ||
| MSG_WriteLong( &msg, client->reliableSequence ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -388,7 +399,7 @@ void SV_SendClientGameState( client_t *client ) | |
|
|
||
| if ( MAX_MSGLEN - msg.cursize < 128 ) { | ||
| // We have too many entities to put them all into one msg_t, so split it here | ||
| MSG_WriteByte( &msg, svc_gamestatePartial ); | ||
| MSG_WriteByte( &msg, svc_partial ); | ||
| SV_SendMessageToClient( &msg, client ); | ||
|
|
||
| MSG_Init( &msg, msgBuffer, sizeof( msgBuffer ) ); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,7 +68,8 @@ SV_EmitPacketEntities | |
| Writes a delta update of an entityState_t list to the message. | ||
| ============= | ||
| */ | ||
| static void SV_EmitPacketEntities( const clientSnapshot_t *from, clientSnapshot_t *to, msg_t *msg ) | ||
| static void SV_EmitPacketEntities( const clientSnapshot_t *from, clientSnapshot_t *to, msg_t *msg, | ||
| client_t* client, int lastframe, int snapFlags ) | ||
| { | ||
| entityState_t *oldent, *newent; | ||
| int oldindex, newindex; | ||
|
|
@@ -97,6 +98,42 @@ static void SV_EmitPacketEntities( const clientSnapshot_t *from, clientSnapshot_ | |
|
|
||
| while ( newindex < to->num_entities || oldindex < from_num_entities ) | ||
| { | ||
|
|
||
| if ( MAX_MSGLEN - msg->cursize < 128 ) { | ||
| MSG_WriteBits( msg, 0, GENTITYNUM_BITS ); | ||
| MSG_WriteBits( msg, 1, 1 ); | ||
| MSG_WriteBits( msg, 1, 1 ); | ||
|
|
||
| SV_SendMessageToClient( msg, client ); | ||
|
|
||
| MSG_Init( msg, msg->data, msg->maxsize ); | ||
| MSG_WriteByte( msg, svc_snapshot ); | ||
|
|
||
| MSG_WriteLong( msg, sv.time ); | ||
|
|
||
| // what we are delta'ing from | ||
| MSG_WriteByte( msg, lastframe ); | ||
|
|
||
| snapFlags = svs.snapFlagServerBit; | ||
|
|
||
| MSG_WriteByte( msg, snapFlags ); | ||
|
|
||
| // send over the areabits | ||
| MSG_WriteByte( msg, to->areabytes ); | ||
| MSG_WriteData( msg, to->areabits, to->areabytes ); | ||
|
|
||
| { | ||
| // delta encode the playerstate | ||
| if ( from ) { | ||
| MSG_WriteDeltaPlayerstate( msg, &from->ps, &to->ps ); | ||
| } else { | ||
| MSG_WriteDeltaPlayerstate( msg, nullptr, &to->ps ); | ||
| } | ||
| } | ||
|
|
||
| MSG_WriteShort( msg, to->num_entities - newindex ); | ||
| } | ||
|
|
||
| if ( newindex >= to->num_entities ) | ||
| { | ||
| newnum = MAX_GENTITIES; | ||
|
|
@@ -236,7 +273,7 @@ static void SV_WriteSnapshotToClient( client_t *client, msg_t *msg ) | |
| } | ||
|
|
||
| // delta encode the entities | ||
| SV_EmitPacketEntities( oldframe, frame, msg ); | ||
| SV_EmitPacketEntities( oldframe, frame, msg, client, lastframe, snapFlags ); | ||
|
|
||
| // padding for rate debugging | ||
| if ( sv_padPackets.Get() ) | ||
|
|
@@ -265,6 +302,14 @@ void SV_UpdateServerCommandsToClient( client_t *client, msg_t *msg ) | |
| MSG_WriteByte( msg, svc_serverCommand ); | ||
| MSG_WriteLong( msg, i ); | ||
| MSG_WriteString( msg, client->reliableCommands[ i & ( MAX_RELIABLE_COMMANDS - 1 ) ] ); | ||
|
|
||
| if ( MAX_MSGLEN - msg->cursize < 128 ) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think commands could be longer than 128 bytes. |
||
| MSG_WriteByte( msg, svc_partial ); | ||
| SV_SendMessageToClient( msg, client ); | ||
|
|
||
| MSG_Init( msg, msg->data, msg->maxsize ); | ||
| MSG_WriteLong( msg, client->lastClientCommand ); | ||
| } | ||
| } | ||
|
|
||
| client->reliableSent = client->reliableSequence; | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A configstring can be up to 8k so this isn't enough to guarantee there is space