Skip to content

Commit 34d62f6

Browse files
committed
PROTOCOL: PEXT_MODELDBL uint16 indices if needed.
Broken implementation from way back when. If modelindex is beyond uint8 + MODELDBL, unflag U_MODEL and write uint16 instead.
1 parent d069dab commit 34d62f6

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

src/bothdefs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
4848
//
4949
// per-level limits
5050
//
51+
#define MAX_STATIC_ENTITIES 2048 // Could be MAX_MODELS - MAX_EDICTS, but static allocation
5152
#define MAX_EDICTS 2048 // can't encode more than this, see SV_WriteDelta
5253
#define MAX_EDICTS_SAFE 512 // lower limit, to make sure no client limits exceeded
5354
#define MAX_LIGHTSTYLES 64
54-
#define MAX_MODELS 512 // can't encode more than this, see SV_WriteDelta
55+
#define MAX_MODELS 4096 // really just UINT16_MAX, see SV_WriteDelta, PEXT_MODELDBL, dynamic + static entities
5556
#define MAX_SOUNDS 256 // so they cannot be blindly increased
5657
#define MAX_VWEP_MODELS 32 // could be increased to 256
5758

src/bspfile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2525

2626
#define MAX_MAP_HULLS 4
2727

28-
#define MAX_MAP_MODELS 512
28+
#define MAX_MAP_MODELS 4096
2929
#define MAX_MAP_BRUSHES 4096
3030
#define MAX_MAP_ENTITIES 1024
3131
#define MAX_MAP_ENTSTRING 65536

src/server.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ typedef struct
126126

127127
qbool mvdrecording;
128128

129-
entity_state_t static_entities[512];
129+
entity_state_t static_entities[MAX_STATIC_ENTITIES];
130130
int static_entity_count;
131131
} server_t;
132132

src/sv_demo.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,8 +1321,9 @@ void SV_MVD_SendInitialGamestate(mvddest_t* dest)
13211321
while (s)
13221322
{
13231323
MSG_WriteString (&buf, s);
1324-
if (buf.cursize > MAX_MSGLEN/2)
1324+
if (buf.cursize > MAX_MSGLEN/2 && n & 0xff)
13251325
{
1326+
// partial flush as long as not at a zero boundary
13261327
MSG_WriteByte (&buf, 0);
13271328
MSG_WriteByte (&buf, n);
13281329
SV_WriteRecordMVDMessage (&buf);

src/sv_ents.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ void SV_WriteDelta(client_t* client, entity_state_t *from, entity_state_t *to, s
159159
bits |= U_MODEL;
160160
#ifdef FTE_PEXT_ENTITYDBL
161161
if (to->modelindex > 255) {
162+
if (to->modelindex >= 512) {
163+
bits &= ~U_MODEL;
164+
}
162165
evenmorebits |= U_FTE_MODELDBL;
163166
required_extensions |= FTE_PEXT_MODELDBL;
164167
}
@@ -264,6 +267,8 @@ void SV_WriteDelta(client_t* client, entity_state_t *from, entity_state_t *to, s
264267

265268
if (bits & U_MODEL)
266269
MSG_WriteByte(msg, to->modelindex & 255);
270+
else if (evenmorebits & U_FTE_MODELDBL)
271+
MSG_WriteShort(msg, to->modelindex);
267272
if (bits & U_FRAME)
268273
MSG_WriteByte(msg, to->frame);
269274
if (bits & U_COLORMAP)

0 commit comments

Comments
 (0)