}
net_message.cursize = LittleLong (net_message.cursize);
- if (net_message.cursize > MAX_MSGLEN)
- Host_Error ("Demo message > MAX_MSGLEN");
+ if (net_message.cursize > MAX_DATAGRAM)
+ Host_Error ("Demo message > MAX_DATAGRAM");
r = Qread (cls.demofile, net_message.data, net_message.cursize);
if (r != net_message.cursize)
{
int field_mask;
float attenuation;
int i;
-
+
field_mask = MSG_ReadByte();
if (field_mask & SND_VOLUME)
volume = MSG_ReadByte ();
else
volume = DEFAULT_SOUND_PACKET_VOLUME;
-
+
if (field_mask & SND_ATTENUATION)
attenuation = MSG_ReadByte () / 64.0;
else
attenuation = DEFAULT_SOUND_PACKET_ATTENUATION;
-
- channel = MSG_ReadShort ();
- if (largesoundindex)
+
+ if (field_mask & SND_LARGEENTITY)
+ {
+ ent = (unsigned short) MSG_ReadShort ();
+ channel = MSG_ReadByte ();
+ }
+ else
+ {
+ channel = (unsigned short) MSG_ReadShort ();
+ ent = channel >> 3;
+ channel &= 7;
+ }
+
+ if (largesoundindex || field_mask & SND_LARGESOUND)
sound_num = (unsigned short) MSG_ReadShort ();
else
sound_num = MSG_ReadByte ();
if (sound_num >= MAX_SOUNDS)
Host_Error("CL_ParseStartSoundPacket: sound_num (%i) >= MAX_SOUNDS (%i)\n", sound_num, MAX_SOUNDS);
- ent = channel >> 3;
- channel &= 7;
- if (ent > MAX_EDICTS)
+ if (ent >= MAX_EDICTS)
Host_Error ("CL_ParseStartSoundPacket: ent = %i", ent);
-
- for (i=0 ; i<3 ; i++)
+
+ for (i = 0;i < 3;i++)
pos[i] = MSG_ReadCoord ();
S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, volume/255.0, attenuation);
int c;
sizebuf_t old;
qbyte olddata[8192];
-
+
if (sv.active)
return; // no need if server is local
if (cls.demoplayback)
// read messages from server, should just be nops
old = net_message;
memcpy (olddata, net_message.data, net_message.cursize);
-
+
do
{
ret = CL_GetMessage ();
#define NET_NAMELEN 64
-#define NET_MAXMESSAGE 16384
+#define NET_MAXMESSAGE (MAX_DATAGRAM + 64)
#define NET_HEADERSIZE (2 * sizeof(unsigned int))
#define NET_DATAGRAMSIZE (MAX_DATAGRAM + NET_HEADERSIZE)
struct link_s *prev, *next;
} link_t;
-// LordHavoc: increased number of leafs per entity limit from 16 to 256
-#define MAX_ENT_LEAFS 256
+// the entire server entity structure
typedef struct edict_s
{
- qboolean free; // true if this edict is unused
- link_t area; // physics area this edict is linked into
+ // true if this edict is unused
+ qboolean free;
+ // physics area this edict is linked into
+ link_t area;
+ // old entity protocol, not used
#ifdef QUAKEENTITIES
- entity_state_t baseline; // baseline values
- entity_state_t deltabaseline; // LordHavoc: previous frame
+ // baseline values
+ entity_state_t baseline;
+ // LordHavoc: previous frame
+ entity_state_t deltabaseline;
#endif
- int suspendedinairflag; // LordHavoc: gross hack to make floating items still work
- float freetime; // sv.time when the object was freed
- entvars_t *v; // edict fields
+ // LordHavoc: gross hack to make floating items still work
+ int suspendedinairflag;
+ // sv.time when the object was freed (to prevent early reuse which could
+ // mess up client interpolation or obscure severe QuakeC bugs)
+ float freetime;
+ // used by PushMove to keep track of where objects were before they were
+ // moved, in case they need to be moved back
+ vec3_t moved_from;
+ vec3_t moved_fromangles;
+ // edict fields (stored in another array)
+ entvars_t *v;
} edict_t;
// LordHavoc: in an effort to eliminate time wasted on GetEdictFieldValue... see pr_edict.c for the functions which use these.
#define SND_VOLUME (1<<0) // a byte
#define SND_ATTENUATION (1<<1) // a byte
#define SND_LOOPING (1<<2) // a long
+#define SND_LARGEENTITY (1<<3) // a short and a byte (instead of a short)
+#define SND_LARGESOUND (1<<4) // a short (instead of a byte)
// defaults for clientinfo messages
entity_frameinfo_t;
#define MAX_ENTITY_HISTORY 64
-#define MAX_ENTITY_DATABASE 4096
+#define MAX_ENTITY_DATABASE (MAX_EDICTS * 2)
typedef struct
{
#define ON_EPSILON 0.1 // point on plane side epsilon
-// LordHavoc: these were 8000 and 1024 respectively, now 64000 and 8000
-#define MAX_MSGLEN 64000 // max length of a reliable message
-#define MAX_DATAGRAM 8000 // max length of unreliable message
+// LordHavoc: this was 1024, now 65536
+#define MAX_DATAGRAM 65536 // max length of message
//
// per-level limits
//
// LordHavoc: increased entity limit to 2048 from 600
-#define MAX_EDICTS 2048 // FIXME: ouch! ouch! ouch!
+#define MAX_EDICTS 32768 // FIXME: ouch! ouch! ouch!
#define MAX_LIGHTSTYLES 64
-// LordHavoc: increased model and sound limits from 256 and 256 to 1024 and 1024 (and added protocol extensions accordingly)
-#define MAX_MODELS 1024 // these are sent over the net as bytes
-#define MAX_SOUNDS 1024 // so they cannot be blindly increased
+// LordHavoc: increased model and sound limits from 256 and 256 to 4096 and 4096 (and added protocol extensions accordingly to break the 256 barrier)
+#define MAX_MODELS 4096
+#define MAX_SOUNDS 4096
#define SAVEGAME_COMMENT_LENGTH 39
edict_t **edictstable;
// array of QC edict field variables
void *edictsfields;
+ // PushMove sometimes has to move entities back from a failed move
+ edict_t **moved_edicts;
// some actions are only valid during load
server_state_t state;
// can be added to at any time, copied and clear once per frame
sizebuf_t message;
- qbyte msgbuf[MAX_MSGLEN];
+ qbyte msgbuf[MAX_DATAGRAM];
// EDICT_NUM(clientnum+1)
edict_t *edict;
// for printing to other people
ent = NUM_FOR_EDICT(entity);
- channel = (ent<<3) | channel;
-
field_mask = 0;
if (volume != DEFAULT_SOUND_PACKET_VOLUME)
field_mask |= SND_VOLUME;
if (attenuation != DEFAULT_SOUND_PACKET_ATTENUATION)
field_mask |= SND_ATTENUATION;
+ if (ent >= 8192)
+ field_mask |= SND_LARGEENTITY;
+ if (sound_num >= 256 || channel >= 8)
+ field_mask |= SND_LARGESOUND;
// directed messages go only to the entity they are targeted on
- if (sound_num >= 256)
- MSG_WriteByte (&sv.datagram, svc_sound2);
- else
- MSG_WriteByte (&sv.datagram, svc_sound);
+ MSG_WriteByte (&sv.datagram, svc_sound);
MSG_WriteByte (&sv.datagram, field_mask);
if (field_mask & SND_VOLUME)
MSG_WriteByte (&sv.datagram, volume);
if (field_mask & SND_ATTENUATION)
MSG_WriteByte (&sv.datagram, attenuation*64);
- MSG_WriteShort (&sv.datagram, channel);
- if (sound_num >= 256)
+ if (field_mask & SND_LARGEENTITY)
+ {
+ MSG_WriteShort (&sv.datagram, ent);
+ MSG_WriteByte (&sv.datagram, channel);
+ }
+ else
+ MSG_WriteShort (&sv.datagram, (ent<<3) | channel);
+ if (field_mask & SND_LARGESOUND)
MSG_WriteShort (&sv.datagram, sound_num);
else
MSG_WriteByte (&sv.datagram, sound_num);
- for (i=0 ; i<3 ; i++)
+ for (i = 0;i < 3;i++)
MSG_WriteDPCoord (&sv.datagram, entity->v->origin[i]+0.5*(entity->v->mins[i]+entity->v->maxs[i]));
}
edict_t *svent;
// LordHavoc: clear *all* states (note just active ones)
- for (entnum = 0; entnum < MAX_EDICTS ; entnum++)
+ for (entnum = 0;entnum < sv.max_edicts;entnum++)
{
// get the current server version
svent = EDICT_NUM(entnum);
trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end);
void SV_PushMove (edict_t *pusher, float movetime)
{
- int i, e, index;
- edict_t *check;
- float savesolid, movetime2, pushltime;
- vec3_t mins, maxs, move, move1, moveangle, pushorig, pushang, a, forward, left, up, org, org2;
- int num_moved;
- edict_t *moved_edict[MAX_EDICTS];
- vec3_t moved_from[MAX_EDICTS], moved_fromangles[MAX_EDICTS];
- model_t *pushermodel;
- trace_t trace;
+ int i, e, index;
+ edict_t *check, *ed;
+ float savesolid, movetime2, pushltime;
+ vec3_t mins, maxs, move, move1, moveangle, pushorig, pushang, a, forward, left, up, org, org2;
+ int num_moved;
+ model_t *pushermodel;
+ trace_t trace;
switch ((int) pusher->v->solid)
{
if (check->v->movetype != MOVETYPE_WALK)
check->v->flags = (int)check->v->flags & ~FL_ONGROUND;
- VectorCopy (check->v->origin, moved_from[num_moved]);
- VectorCopy (check->v->angles, moved_fromangles[num_moved]);
- moved_edict[num_moved++] = check;
+ VectorCopy (check->v->origin, check->moved_from);
+ VectorCopy (check->v->angles, check->moved_fromangles);
+ sv.moved_edicts[num_moved++] = check;
// try moving the contacted entity
pusher->v->solid = SOLID_NOT;
SV_LinkEdict (pusher, false);
// move back any entities we already moved
- for (i=0 ; i<num_moved ; i++)
+ for (i = 0;i < num_moved;i++)
{
- VectorCopy (moved_from[i], moved_edict[i]->v->origin);
- VectorCopy (moved_fromangles[i], moved_edict[i]->v->angles);
- SV_LinkEdict (moved_edict[i], false);
+ ed = sv.moved_edicts[i];
+ VectorCopy (ed->moved_from, ed->v->origin);
+ VectorCopy (ed->moved_fromangles, ed->v->angles);
+ SV_LinkEdict (ed, false);
}
// if the pusher has a "blocked" function, call it, otherwise just stay in place until the obstacle is gone