Skip to content

Commit dc586db

Browse files
committed
Revert "Fix remaining overflows of network msg"
This reverts commit 6c104a8.
1 parent 6c104a8 commit dc586db

File tree

6 files changed

+18
-110
lines changed

6 files changed

+18
-110
lines changed

src/engine/client/cl_main.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -420,24 +420,6 @@ void CL_Record(std::string demo_name)
420420
MSG_WriteByte( &buf, svc_configstring );
421421
MSG_WriteShort( &buf, i );
422422
MSG_WriteBigString( &buf, cl.gameState[i].c_str() );
423-
424-
if ( MAX_MSGLEN - buf.cursize < 128 ) {
425-
// We have too much configstring data to put it all into one msg_t, so split it here
426-
MSG_WriteByte( &buf, svc_partial );
427-
428-
int len = LittleLong( clc.serverMessageSequence - 1 );
429-
FS_Write( &len, 4, clc.demofile );
430-
431-
len = LittleLong( buf.cursize );
432-
FS_Write( &len, 4, clc.demofile );
433-
FS_Write( buf.data, buf.cursize, clc.demofile );
434-
435-
MSG_Init( &buf, bufData, sizeof( bufData ) );
436-
MSG_Bitstream( &buf );
437-
MSG_WriteLong( &buf, clc.reliableSequence );
438-
MSG_WriteByte( &buf, svc_gamestate );
439-
MSG_WriteLong( &buf, clc.serverCommandSequence );
440-
}
441423
}
442424

443425
// baselines

src/engine/client/cl_parse.cpp

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,14 @@ MESSAGE PARSING
6767

6868
// TODO(kangz) if we can make sure that the baseline entities have the correct entity
6969
// number, then we could grab the entity number from old directly, simplifying code a bit.
70-
bool CL_DeltaEntity( msg_t *msg, clSnapshot_t *snapshot, int entityNum, const entityState_t &oldEntity)
70+
void CL_DeltaEntity( msg_t *msg, clSnapshot_t *snapshot, int entityNum, const entityState_t &oldEntity)
7171
{
7272
entityState_t entity;
73-
if ( MSG_ReadDeltaEntity( msg, &oldEntity, &entity, entityNum ) ) {
74-
return true;
75-
}
73+
MSG_ReadDeltaEntity(msg, &oldEntity, &entity, entityNum);
7674

7775
if (entity.number != MAX_GENTITIES - 1) {
7876
snapshot->entities.push_back(entity);
7977
}
80-
81-
return false;
8278
}
8379

8480
/*
@@ -140,9 +136,7 @@ void CL_ParsePacketEntities( msg_t *msg, const clSnapshot_t *oldSnapshot, clSnap
140136

141137
// (2) there is an entry for an entity in the old snapshot, apply the delta
142138
if (oldEntityNum == newEntityNum) {
143-
if ( CL_DeltaEntity( msg, newSnapshot, newEntityNum, oldEntities[oldIndex] ) ) {
144-
break;
145-
}
139+
CL_DeltaEntity(msg, newSnapshot, newEntityNum, oldEntities[oldIndex]);
146140

147141
oldIndex ++;
148142
if (oldIndex >= oldEntities.size()) {
@@ -155,9 +149,7 @@ void CL_ParsePacketEntities( msg_t *msg, const clSnapshot_t *oldSnapshot, clSnap
155149
// from the baseline
156150
ASSERT_GT(oldEntityNum, newEntityNum);
157151

158-
if ( CL_DeltaEntity( msg, newSnapshot, newEntityNum, cl.entityBaselines[newEntityNum] ) ) {
159-
break;
160-
}
152+
CL_DeltaEntity(msg, newSnapshot, newEntityNum, cl.entityBaselines[newEntityNum]);
161153
}
162154
}
163155

@@ -429,11 +421,7 @@ void CL_ParseGamestate( msg_t *msg )
429421
break;
430422
}
431423

432-
if ( cmd == svc_partial ) {
433-
cl.reading = true;
434-
break;
435-
}
436-
else if ( cmd == svc_configstring )
424+
if ( cmd == svc_configstring )
437425
{
438426
i = MSG_ReadShort( msg );
439427

@@ -460,6 +448,11 @@ void CL_ParseGamestate( msg_t *msg )
460448

461449
cl.reading = false;
462450
}
451+
else if ( cmd == svc_gamestatePartial )
452+
{
453+
cl.reading = true;
454+
break;
455+
}
463456
else
464457
{
465458
Sys::Drop( "CL_ParseGamestate: bad command byte" );
@@ -595,9 +588,6 @@ void CL_ParseServerMessage( msg_t *msg )
595588
case svc_download:
596589
CL_ParseDownload( msg );
597590
break;
598-
599-
case svc_partial:
600-
break;
601591
}
602592
}
603593
}

src/engine/qcommon/msg.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,6 @@ void MSG_WriteDeltaEntity( msg_t *msg, entityState_t *from, entityState_t *to, b
919919

920920
MSG_WriteBits( msg, from->number, GENTITYNUM_BITS );
921921
MSG_WriteBits( msg, 1, 1 );
922-
MSG_WriteBits( msg, 0, 1 );
923922
return;
924923
}
925924

@@ -1062,7 +1061,7 @@ Can go from either a baseline or a previous packet_entity
10621061
*/
10631062
extern cvar_t *cl_shownet;
10641063

1065-
bool MSG_ReadDeltaEntity( msg_t *msg, const entityState_t *from, entityState_t *to, int number )
1064+
void MSG_ReadDeltaEntity( msg_t *msg, const entityState_t *from, entityState_t *to, int number )
10661065
{
10671066
int i, lc;
10681067
int numFields;
@@ -1089,11 +1088,6 @@ bool MSG_ReadDeltaEntity( msg_t *msg, const entityState_t *from, entityState_t *
10891088
// check for a remove
10901089
if ( MSG_ReadBits( msg, 1 ) == 1 )
10911090
{
1092-
// partial snapshot; this is not an actual entity, the next entity had to be put into a different msg
1093-
if ( MSG_ReadBits( msg, 1 ) == 1 ) {
1094-
return true;
1095-
}
1096-
10971091
*to = {};
10981092
to->number = MAX_GENTITIES - 1;
10991093

@@ -1102,15 +1096,15 @@ bool MSG_ReadDeltaEntity( msg_t *msg, const entityState_t *from, entityState_t *
11021096
Log::Notice( "%3i: #%-3i remove", msg->readcount, number );
11031097
}
11041098

1105-
return false;
1099+
return;
11061100
}
11071101

11081102
// check for no delta
11091103
if ( MSG_ReadBits( msg, 1 ) == 0 )
11101104
{
11111105
*to = *from;
11121106
to->number = number;
1113-
return false;
1107+
return;
11141108
}
11151109

11161110
numFields = ARRAY_LEN( entityStateFields );
@@ -1222,8 +1216,6 @@ bool MSG_ReadDeltaEntity( msg_t *msg, const entityState_t *from, entityState_t *
12221216

12231217
Log::Notice( " (%i bits)", endBit - startBit );
12241218
}
1225-
1226-
return false;
12271219
}
12281220

12291221
/*

src/engine/qcommon/qcommon.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void MSG_WriteDeltaUsercmd( msg_t *msg, usercmd_t *from, usercmd_t *to );
9393
void MSG_ReadDeltaUsercmd( msg_t *msg, usercmd_t *from, usercmd_t *to );
9494

9595
void MSG_WriteDeltaEntity( msg_t *msg, entityState_t *from, entityState_t *to, bool force );
96-
bool MSG_ReadDeltaEntity( msg_t *msg, const entityState_t *from, entityState_t *to, int number );
96+
void MSG_ReadDeltaEntity( msg_t *msg, const entityState_t *from, entityState_t *to, int number );
9797

9898
void MSG_InitNetcodeTables(NetcodeTable playerStateTable, int playerStateSize);
9999
void MSG_WriteDeltaPlayerstate( msg_t *msg, const OpaquePlayerState *from, const OpaquePlayerState *to );
@@ -248,12 +248,12 @@ enum svc_ops_e
248248
svc_bad,
249249
svc_nop,
250250
svc_gamestate,
251+
svc_gamestatePartial,
251252
svc_configstring, // [short] [string] only in gamestate messages
252253
svc_baseline, // only in gamestate messages
253254
svc_serverCommand, // [string] to be executed by client game module
254255
svc_download, // [short] size [size bytes]
255256
svc_snapshot,
256-
svc_partial,
257257
svc_EOF
258258
};
259259

src/engine/server/sv_client.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -368,17 +368,6 @@ void SV_SendClientGameState( client_t *client )
368368
MSG_WriteByte( &msg, svc_configstring );
369369
MSG_WriteShort( &msg, start );
370370
MSG_WriteBigString( &msg, sv.configstrings[ start ] );
371-
372-
if ( MAX_MSGLEN - msg.cursize < 128 ) {
373-
// We have too much configstring data to put it all into one msg_t, so split it here
374-
MSG_WriteByte( &msg, svc_partial );
375-
SV_SendMessageToClient( &msg, client );
376-
377-
MSG_Init( &msg, msgBuffer, sizeof( msgBuffer ) );
378-
MSG_WriteLong( &msg, client->lastClientCommand );
379-
MSG_WriteByte( &msg, svc_gamestate );
380-
MSG_WriteLong( &msg, client->reliableSequence );
381-
}
382371
}
383372
}
384373

@@ -399,7 +388,7 @@ void SV_SendClientGameState( client_t *client )
399388

400389
if ( MAX_MSGLEN - msg.cursize < 128 ) {
401390
// We have too many entities to put them all into one msg_t, so split it here
402-
MSG_WriteByte( &msg, svc_partial );
391+
MSG_WriteByte( &msg, svc_gamestatePartial );
403392
SV_SendMessageToClient( &msg, client );
404393

405394
MSG_Init( &msg, msgBuffer, sizeof( msgBuffer ) );

src/engine/server/sv_snapshot.cpp

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ SV_EmitPacketEntities
6868
Writes a delta update of an entityState_t list to the message.
6969
=============
7070
*/
71-
static void SV_EmitPacketEntities( const clientSnapshot_t *from, clientSnapshot_t *to, msg_t *msg,
72-
client_t* client, int lastframe, int snapFlags )
71+
static void SV_EmitPacketEntities( const clientSnapshot_t *from, clientSnapshot_t *to, msg_t *msg )
7372
{
7473
entityState_t *oldent, *newent;
7574
int oldindex, newindex;
@@ -98,42 +97,6 @@ static void SV_EmitPacketEntities( const clientSnapshot_t *from, clientSnapshot_
9897

9998
while ( newindex < to->num_entities || oldindex < from_num_entities )
10099
{
101-
102-
if ( MAX_MSGLEN - msg->cursize < 128 ) {
103-
MSG_WriteBits( msg, 0, GENTITYNUM_BITS );
104-
MSG_WriteBits( msg, 1, 1 );
105-
MSG_WriteBits( msg, 1, 1 );
106-
107-
SV_SendMessageToClient( msg, client );
108-
109-
MSG_Init( msg, msg->data, msg->maxsize );
110-
MSG_WriteByte( msg, svc_snapshot );
111-
112-
MSG_WriteLong( msg, sv.time );
113-
114-
// what we are delta'ing from
115-
MSG_WriteByte( msg, lastframe );
116-
117-
snapFlags = svs.snapFlagServerBit;
118-
119-
MSG_WriteByte( msg, snapFlags );
120-
121-
// send over the areabits
122-
MSG_WriteByte( msg, to->areabytes );
123-
MSG_WriteData( msg, to->areabits, to->areabytes );
124-
125-
{
126-
// delta encode the playerstate
127-
if ( from ) {
128-
MSG_WriteDeltaPlayerstate( msg, &from->ps, &to->ps );
129-
} else {
130-
MSG_WriteDeltaPlayerstate( msg, nullptr, &to->ps );
131-
}
132-
}
133-
134-
MSG_WriteShort( msg, to->num_entities - newindex );
135-
}
136-
137100
if ( newindex >= to->num_entities )
138101
{
139102
newnum = MAX_GENTITIES;
@@ -273,7 +236,7 @@ static void SV_WriteSnapshotToClient( client_t *client, msg_t *msg )
273236
}
274237

275238
// delta encode the entities
276-
SV_EmitPacketEntities( oldframe, frame, msg, client, lastframe, snapFlags );
239+
SV_EmitPacketEntities( oldframe, frame, msg );
277240

278241
// padding for rate debugging
279242
if ( sv_padPackets.Get() )
@@ -302,14 +265,6 @@ void SV_UpdateServerCommandsToClient( client_t *client, msg_t *msg )
302265
MSG_WriteByte( msg, svc_serverCommand );
303266
MSG_WriteLong( msg, i );
304267
MSG_WriteString( msg, client->reliableCommands[ i & ( MAX_RELIABLE_COMMANDS - 1 ) ] );
305-
306-
if ( MAX_MSGLEN - msg->cursize < 128 ) {
307-
MSG_WriteByte( msg, svc_partial );
308-
SV_SendMessageToClient( msg, client );
309-
310-
MSG_Init( msg, msg->data, msg->maxsize );
311-
MSG_WriteLong( msg, client->lastClientCommand );
312-
}
313268
}
314269

315270
client->reliableSent = client->reliableSequence;

0 commit comments

Comments
 (0)