From b29b9e54dee7965354aede860e187c6f6276a758 Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 10 Feb 2003 14:46:15 +0000 Subject: [PATCH] MAX_EDICTS has changed to 32768. Yes this is madness. Thanks to banshee for prompting this necessity to run his map helm10000! Sound protocol has been upgraded to be able to send 16bit entity numbers (this allows going beyond the old 8192 limit) MAX_ENTITY_DATABASE is now dependent on MAX_EDICTS MAX_DATAGRAM increased from 8000 to 65536 MAX_MSGLEN has been removed (now uses MAX_DATAGRAM) NET_MAXMESSAGE is now dependent on MAX_DATAGRAM SV_PushMove's list of moved entities has been moved into sv.moved_edicts (just an array of pointers) and their original origin and angles have been moved into edict_t, this avoids stack crashes on win32 with the new edict limit increased MAX_MODELS and MAX_SOUNDS from 1024 to 4096 (this is not really necessary but a good idea) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2727 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_demo.c | 4 ++-- cl_parse.c | 33 +++++++++++++++++++++------------ net.h | 2 +- progs.h | 30 +++++++++++++++++++++--------- protocol.h | 4 +++- quakedef.h | 13 ++++++------- server.h | 4 +++- sv_main.c | 25 +++++++++++++++---------- sv_phys.c | 31 +++++++++++++++---------------- 9 files changed, 87 insertions(+), 59 deletions(-) diff --git a/cl_demo.c b/cl_demo.c index b38a2db5..831973dc 100644 --- a/cl_demo.c +++ b/cl_demo.c @@ -159,8 +159,8 @@ int CL_GetMessage (void) } 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) { diff --git a/cl_parse.c b/cl_parse.c index 50d1aea4..b15f72cf 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -113,21 +113,32 @@ void CL_ParseStartSoundPacket(int largesoundindex) 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 (); @@ -135,13 +146,11 @@ void CL_ParseStartSoundPacket(int largesoundindex) 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); @@ -163,7 +172,7 @@ void CL_KeepaliveMessage (void) int c; sizebuf_t old; qbyte olddata[8192]; - + if (sv.active) return; // no need if server is local if (cls.demoplayback) @@ -172,7 +181,7 @@ void CL_KeepaliveMessage (void) // read messages from server, should just be nops old = net_message; memcpy (olddata, net_message.data, net_message.cursize); - + do { ret = CL_GetMessage (); diff --git a/net.h b/net.h index d7c315f1..8323b205 100644 --- a/net.h +++ b/net.h @@ -31,7 +31,7 @@ struct qsockaddr #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) diff --git a/progs.h b/progs.h index 7ba47c30..a8a5f3b7 100644 --- a/progs.h +++ b/progs.h @@ -40,21 +40,33 @@ typedef struct link_s 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. diff --git a/protocol.h b/protocol.h index c6d92df9..e42227de 100644 --- a/protocol.h +++ b/protocol.h @@ -138,6 +138,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #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 @@ -333,7 +335,7 @@ typedef struct entity_frameinfo_t; #define MAX_ENTITY_HISTORY 64 -#define MAX_ENTITY_DATABASE 4096 +#define MAX_ENTITY_DATABASE (MAX_EDICTS * 2) typedef struct { diff --git a/quakedef.h b/quakedef.h index ae27cfee..360b4b0d 100644 --- a/quakedef.h +++ b/quakedef.h @@ -45,19 +45,18 @@ extern char *buildstring; #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 diff --git a/server.h b/server.h index 5ee45a31..459a0ec5 100644 --- a/server.h +++ b/server.h @@ -73,6 +73,8 @@ typedef struct 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; @@ -124,7 +126,7 @@ typedef struct client_s // 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 diff --git a/sv_main.c b/sv_main.c index 74530b39..3e0f6866 100644 --- a/sv_main.c +++ b/sv_main.c @@ -195,30 +195,35 @@ void SV_StartSound (edict_t *entity, int channel, char *sample, int volume, 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])); } @@ -1599,7 +1604,7 @@ void SV_CreateBaseline (void) 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); diff --git a/sv_phys.c b/sv_phys.c index 44daad48..5ed7426f 100644 --- a/sv_phys.c +++ b/sv_phys.c @@ -459,15 +459,13 @@ SV_PushMove 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) { @@ -611,9 +609,9 @@ void SV_PushMove (edict_t *pusher, float movetime) 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; @@ -649,11 +647,12 @@ void SV_PushMove (edict_t *pusher, float movetime) SV_LinkEdict (pusher, false); // move back any entities we already moved - for (i=0 ; iv->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 -- 2.39.2