From c1ab987e992c1c56ed9ea09426408f7b62ae5100 Mon Sep 17 00:00:00 2001 From: havoc Date: Wed, 11 Nov 2009 16:04:42 +0000 Subject: [PATCH] migrated a large number of #define MAX values to quakedef.h and added a #ifdef DP_SMALLMEMORY case which drops darkplaces-sdl from 42MB to 24MB of reserved space (according to size command) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9467 d7cf8633-e32d-0410-b094-e92efae38249 --- bspfile.h | 8 +-- cd_shared.c | 16 +++++- cl_dyntexture.h | 1 - cl_gecko.h | 1 - cl_particles.c | 3 -- cl_video.h | 1 - client.h | 33 +++++------- clvm_cmds.c | 10 ++-- cmd.c | 11 ---- common.h | 3 -- console.c | 3 -- csprogs.c | 2 +- cvar.c | 2 +- gl_backend.h | 2 +- gl_draw.c | 2 - gl_rmain.c | 36 +++++++++++++ gl_rsurf.c | 2 - keys.c | 2 - menu.c | 1 - menu.h | 1 - model_shared.c | 2 +- model_shared.h | 2 - quakedef.h | 140 ++++++++++++++++++++++++++++++++++++++---------- r_explosion.c | 15 +++++- r_modules.c | 2 +- r_shadow.c | 1 - render.h | 4 +- server.h | 2 - snd_main.c | 8 +-- snd_main.h | 6 --- svvm_cmds.c | 4 +- 31 files changed, 207 insertions(+), 119 deletions(-) diff --git a/bspfile.h b/bspfile.h index fe00b325..648b294d 100644 --- a/bspfile.h +++ b/bspfile.h @@ -19,13 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#define MAX_MAP_HULLS 16 // was 4 -#define MAX_MAP_LEAFS 65536 // was 8192 - -// key / value pair sizes - -#define MAX_KEY 32 -#define MAX_VALUE 1024 +#define MAX_MAP_HULLS 16 // Q1BSP has 4, Hexen2 Q1BSP has 8, MCBSP has 16 //============================================================================= diff --git a/cd_shared.c b/cd_shared.c index 7706e91c..f00f6612 100644 --- a/cd_shared.c +++ b/cd_shared.c @@ -24,8 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "cdaudio.h" #include "sound.h" -#define MAXTRACKS 256 - // Prototypes of the system dependent functions extern void CDAudio_SysEject (void); extern void CDAudio_SysCloseDoor (void); @@ -50,7 +48,9 @@ static qboolean initialized = false; static qboolean enabled = false; static float cdvolume; typedef char filename_t[MAX_QPATH]; +#ifdef MAXTRACKS static filename_t remap[MAXTRACKS]; +#endif static unsigned char maxTrack; static int faketrack = -1; @@ -156,6 +156,7 @@ void CDAudio_Play_byName (const char *trackname, qboolean looping) if(strspn(trackname, "0123456789") == strlen(trackname)) { track = (unsigned char) atoi(trackname); +#ifdef MAXTRACKS if(track > 0 && track < MAXTRACKS) if(*remap[track]) { @@ -183,6 +184,7 @@ void CDAudio_Play_byName (const char *trackname, qboolean looping) } } } +#endif } if(strspn(trackname, "0123456789") == strlen(trackname)) @@ -366,8 +368,10 @@ void CDAudio_Resume (void) static void CD_f (void) { const char *command; +#ifdef MAXTRACKS int ret; int n; +#endif command = Cmd_Argv (1); @@ -391,8 +395,10 @@ static void CD_f (void) { enabled = true; CDAudio_Stop(); +#ifdef MAXTRACKS for (n = 0; n < MAXTRACKS; n++) *remap[n] = 0; // empty string, that is, unremapped +#endif CDAudio_GetAudioDiskInfo(); return; } @@ -406,6 +412,7 @@ static void CD_f (void) if (strcasecmp(command, "remap") == 0) { +#ifdef MAXTRACKS ret = Cmd_Argc() - 2; if (ret <= 0) { @@ -416,6 +423,7 @@ static void CD_f (void) } for (n = 1; n <= ret; n++) strlcpy(remap[n], Cmd_Argv (n+1), sizeof(*remap)); +#endif return; } @@ -535,7 +543,9 @@ void CDAudio_Update (void) int CDAudio_Init (void) { +#ifdef MAXTRACKS int i; +#endif if (cls.state == ca_dedicated) return -1; @@ -546,8 +556,10 @@ int CDAudio_Init (void) CDAudio_SysInit(); +#ifdef MAXTRACKS for (i = 0; i < MAXTRACKS; i++) *remap[i] = 0; +#endif Cvar_RegisterVariable(&cdaudio); Cvar_RegisterVariable(&cdaudioinitialized); diff --git a/cl_dyntexture.h b/cl_dyntexture.h index 3b0a6834..29783cf6 100644 --- a/cl_dyntexture.h +++ b/cl_dyntexture.h @@ -3,7 +3,6 @@ #define CL_DYNTEXTURE_H #define CLDYNTEXTUREPREFIX "_dynamic/" -#define MAX_DYNAMIC_TEXTURE_COUNT 64 // always path fully specified names to the dynamic texture functions! (ie. with the _dynamic/ prefix, etc.!) diff --git a/cl_gecko.h b/cl_gecko.h index fd12e801..22ab2fa5 100644 --- a/cl_gecko.h +++ b/cl_gecko.h @@ -6,7 +6,6 @@ #include "cl_dyntexture.h" #define CLGECKOPREFIX CLDYNTEXTUREPREFIX "gecko/" -#define MAX_GECKO_INSTANCES 16 typedef enum clgecko_buttoneventtype_e { CLG_BET_DOWN, diff --git a/cl_particles.c b/cl_particles.c index 4ee46901..70dc7cc5 100644 --- a/cl_particles.c +++ b/cl_particles.c @@ -120,10 +120,8 @@ typedef struct particleeffectinfo_s } particleeffectinfo_t; -#define MAX_PARTICLEEFFECTNAME 256 char particleeffectname[MAX_PARTICLEEFFECTNAME][64]; -#define MAX_PARTICLEEFFECTINFO 4096 particleeffectinfo_t particleeffectinfo[MAX_PARTICLEEFFECTINFO]; @@ -169,7 +167,6 @@ int ramp3[8] = {0x6d, 0x6b, 6, 5, 4, 3}; //static int explosparkramp[8] = {0x4b0700, 0x6f0f00, 0x931f07, 0xb7330f, 0xcf632b, 0xe3974f, 0xffe7b5, 0xffffff}; -#define MAX_PARTICLETEXTURES 1024 // particletexture_t is a rectangle in the particlefonttexture typedef struct particletexture_s { diff --git a/cl_video.h b/cl_video.h index 05bf4a16..d98c0087 100644 --- a/cl_video.h +++ b/cl_video.h @@ -4,7 +4,6 @@ #include "cl_dyntexture.h" -#define MAXCLVIDEOS 64 + 1 // 1 video is reserved for the cinematic mode // yields DYNAMIC_TEXTURE_PATH_PREFIX CLVIDEOPREFIX video name for a path #define CLVIDEOPREFIX CLDYNTEXTUREPREFIX "video/" #define CLTHRESHOLD 2.0 diff --git a/client.h b/client.h index c57c0177..ac5e866d 100644 --- a/client.h +++ b/client.h @@ -25,12 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "matrixlib.h" #include "snd_main.h" -// LordHavoc: 256 dynamic lights -#define MAX_DLIGHTS 256 - -/// this is the maximum number of input packets that can be predicted -#define CL_MAX_USERCMDS 128 - // flags for rtlight rendering #define LIGHTFLAG_NORMALMODE 1 #define LIGHTFLAG_REALTIMEMODE 2 @@ -271,7 +265,7 @@ framegroupblend_t; // note: technically each framegroupblend can produce two of these, but that // never happens in practice because no one blends between more than 2 // framegroups at once -#define MAX_FRAMEBLENDS MAX_FRAMEGROUPBLENDS +#define MAX_FRAMEBLENDS (MAX_FRAMEGROUPBLENDS * 2) typedef struct frameblend_s { int subframe; @@ -477,9 +471,6 @@ typedef struct cshift_s #define SIGNONS 4 // signon messages to receive before connected -#define MAX_DEMOS 8 -#define MAX_DEMONAME 16 - typedef enum cactive_e { ca_uninitialized, // during early startup @@ -1564,19 +1555,23 @@ r_refdef_view_t; typedef struct r_refdef_viewcache_s { + // updated by gl_main_newmap() + int maxentities; + int world_numclusters; + int world_numleafs; + int world_numsurfaces; + // these properties are generated by R_View_Update() // which entities are currently visible for this viewpoint // (the used range is 0...r_refdef.scene.numentities) - unsigned char entityvisible[MAX_EDICTS]; + unsigned char *entityvisible; + // flag arrays used for visibility checking on world model // (all other entities have no per-surface/per-leaf visibility checks) - // TODO: dynamic resize according to r_refdef.scene.worldmodel->brush.num_clusters - unsigned char world_pvsbits[(32768+7)>>3]; // FIXME: buffer overflow on huge maps - // TODO: dynamic resize according to r_refdef.scene.worldmodel->brush.num_leafs - unsigned char world_leafvisible[32768]; // FIXME: buffer overflow on huge maps - // TODO: dynamic resize according to r_refdef.scene.worldmodel->num_surfaces - unsigned char world_surfacevisible[262144]; // FIXME: buffer overflow on huge maps + unsigned char *world_pvsbits; + unsigned char *world_leafvisible; + unsigned char *world_surfacevisible; // if true, the view is currently in a leaf without pvs data qboolean world_novis; } @@ -1613,10 +1608,10 @@ typedef struct r_refdef_scene_s { int numlights; // intensities for light styles right now, controls rtlights - float rtlightstylevalue[256]; // float fraction of base light value + float rtlightstylevalue[MAX_LIGHTSTYLES]; // float fraction of base light value // 8.8bit fixed point intensities for light styles // controls intensity lightmap layers - unsigned short lightstylevalue[256]; // 8.8 fraction of base light value + unsigned short lightstylevalue[MAX_LIGHTSTYLES]; // 8.8 fraction of base light value float ambient; diff --git a/clvm_cmds.c b/clvm_cmds.c index 82d63a16..6e6efed8 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -189,7 +189,7 @@ static void VM_CL_sound (void) return; } - S_StartSound(32768 + PRVM_NUM_FOR_EDICT(entity), channel, S_FindName(sample), entity->fields.client->origin, volume, attenuation); + S_StartSound(MAX_EDICTS + PRVM_NUM_FOR_EDICT(entity), channel, S_FindName(sample), entity->fields.client->origin, volume, attenuation); } // #483 void(vector origin, string sample, float volume, float attenuation) pointsound @@ -219,8 +219,8 @@ static void VM_CL_pointsound(void) return; } - // Send World Entity as Entity to Play Sound (for CSQC, that is 32768) - S_StartSound(32768, 0, S_FindName(sample), org, volume, attenuation); + // Send World Entity as Entity to Play Sound (for CSQC, that is MAX_EDICTS) + S_StartSound(MAX_EDICTS, 0, S_FindName(sample), org, volume, attenuation); } // #14 entity() spawn @@ -3594,8 +3594,8 @@ static void VM_CL_checkpvs (void) #if 1 unsigned char *pvs; #else - static int fatpvsbytes; - static unsigned char fatpvs[MAX_MAP_LEAFS/8]; + int fatpvsbytes; + unsigned char fatpvs[MAX_MAP_LEAFS/8]; #endif VM_SAFEPARMCOUNT(2, VM_SV_checkpvs); diff --git a/cmd.c b/cmd.c index 3457a534..db6acdb9 100644 --- a/cmd.c +++ b/cmd.c @@ -21,17 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" -#define MAX_ALIAS_NAME 32 -// this is the largest script file that can be executed in one step -// LordHavoc: inreased this from 8192 to 32768 -// div0: increased this from 32k to 128k -// div0: increased this from 128k to 640k which ought to be enough for anyone -#define CMDBUFSIZE 655360 -// maximum number of parameters to a command -#define MAX_ARGS 80 -// maximum tokenizable commandline length (counting NUL terminations) -#define CMD_TOKENIZELENGTH (MAX_INPUTLINE + MAX_ARGS) - typedef struct cmdalias_s { struct cmdalias_s *next; diff --git a/common.h b/common.h index cc5029ea..3b605849 100644 --- a/common.h +++ b/common.h @@ -21,9 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef COMMON_H #define COMMON_H -/// many buffers use this size -#define MAX_INPUTLINE 16384 - /// MSVC has a different name for several standard functions #ifdef WIN32 diff --git a/console.c b/console.c index fc29e5f7..2798199b 100644 --- a/console.c +++ b/console.c @@ -28,9 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. float con_cursorspeed = 4; -#define CON_TEXTSIZE 1048576 -#define CON_MAXLINES 16384 - // lines up from bottom to display int con_backscroll; diff --git a/csprogs.c b/csprogs.c index 27b82992..ba3861f4 100644 --- a/csprogs.c +++ b/csprogs.c @@ -986,7 +986,7 @@ qboolean CL_VM_GetEntitySoundOrigin(int entnum, vec3_t out) // FIXME consider attachments here! - ed = PRVM_EDICT_NUM(entnum - 32768); + ed = PRVM_EDICT_NUM(entnum - MAX_EDICTS); if(!ed->priv.required->free) { diff --git a/cvar.c b/cvar.c index a6734b53..29e299e1 100644 --- a/cvar.c +++ b/cvar.c @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. char *cvar_dummy_description = "custom cvar"; cvar_t *cvar_vars = NULL; -cvar_t *cvar_hashtable[65536]; +cvar_t *cvar_hashtable[CVAR_HASHSIZE]; char *cvar_null_string = ""; /* diff --git a/gl_backend.h b/gl_backend.h index e8113e21..6332865b 100644 --- a/gl_backend.h +++ b/gl_backend.h @@ -3,7 +3,7 @@ #define GL_BACKEND_H // how many texture units to track state on (backendunits/backendimageunits/backendarrayunits are limited to this value) -#define MAX_TEXTUREUNITS 64 +#define MAX_TEXTUREUNITS 16 #define POLYGONELEMENTS_MAXPOINTS 258 extern int polygonelement3i[(POLYGONELEMENTS_MAXPOINTS-2)*3]; diff --git a/gl_draw.c b/gl_draw.c index f0a2c073..ae817471 100644 --- a/gl_draw.c +++ b/gl_draw.c @@ -37,8 +37,6 @@ extern cvar_t v_glslgamma; /* Support Routines */ #define FONT_FILESIZE 13468 -#define MAX_CACHED_PICS 1024 -#define CACHEPICHASHSIZE 256 static cachepic_t *cachepichash[CACHEPICHASHSIZE]; static cachepic_t cachepics[MAX_CACHED_PICS]; static int numcachepics; diff --git a/gl_rmain.c b/gl_rmain.c index 34d05c0c..3d4915b2 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -2854,8 +2854,40 @@ skinframe_t *R_SkinFrame_LoadMissing(void) return skinframe; } +void R_Main_FreeViewCache(void) +{ + if (r_refdef.viewcache.entityvisible) + Mem_Free(r_refdef.viewcache.entityvisible); + if (r_refdef.viewcache.world_pvsbits) + Mem_Free(r_refdef.viewcache.world_pvsbits); + if (r_refdef.viewcache.world_leafvisible) + Mem_Free(r_refdef.viewcache.world_leafvisible); + if (r_refdef.viewcache.world_surfacevisible) + Mem_Free(r_refdef.viewcache.world_surfacevisible); + memset(&r_refdef.viewcache, 0, sizeof(r_refdef.viewcache)); +} + +void R_Main_AllocViewCache(void) +{ + memset(&r_refdef.viewcache, 0, sizeof(r_refdef.viewcache)); + r_refdef.viewcache.maxentities = r_refdef.scene.maxentities; + if (r_refdef.viewcache.maxentities) + r_refdef.viewcache.entityvisible = Mem_Alloc(r_main_mempool, r_refdef.viewcache.maxentities); + if (cl.worldmodel) + { + r_refdef.viewcache.world_numclusters = cl.worldmodel->brush.num_pvsclusters; + r_refdef.viewcache.world_numleafs = cl.worldmodel->brush.num_leafs; + r_refdef.viewcache.world_numsurfaces = cl.worldmodel->num_surfaces; + r_refdef.viewcache.world_pvsbits = Mem_Alloc(r_main_mempool, (r_refdef.viewcache.world_numclusters+7)>>3); + r_refdef.viewcache.world_leafvisible = Mem_Alloc(r_main_mempool, r_refdef.viewcache.world_numleafs); + r_refdef.viewcache.world_surfacevisible = Mem_Alloc(r_main_mempool, r_refdef.viewcache.world_numsurfaces); + } +} + void gl_main_start(void) { + R_Main_AllocViewCache(); + r_numqueries = 0; r_maxqueries = 0; memset(r_queries, 0, sizeof(r_queries)); @@ -2891,6 +2923,8 @@ void gl_main_start(void) extern rtexture_t *loadingscreentexture; void gl_main_shutdown(void) { + R_Main_FreeViewCache(); + if (r_maxqueries) qglDeleteQueriesARB(r_maxqueries, r_queries); @@ -2951,6 +2985,8 @@ void gl_main_newmap(void) if (cl.worldmodel->brush.entities) CL_ParseEntityLump(cl.worldmodel->brush.entities); } + R_Main_FreeViewCache(); + R_Main_AllocViewCache(); } void GL_Main_Init(void) diff --git a/gl_rsurf.c b/gl_rsurf.c index a7d91f1c..3ba46ac8 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -23,8 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "r_shadow.h" #include "portals.h" -#define MAX_LIGHTMAP_SIZE 256 - cvar_t r_ambient = {0, "r_ambient", "0", "brightens map, value is 0-128"}; cvar_t r_lockpvs = {0, "r_lockpvs", "0", "disables pvs switching, allows you to walk around and inspect what is visible from a given location in the map (anything not visible from your current location will not be drawn)"}; cvar_t r_lockvisibility = {0, "r_lockvisibility", "0", "disables visibility updates, allows you to walk around and inspect what is visible from a given viewpoint in the map (anything offscreen at the moment this is enabled will not be drawn)"}; diff --git a/keys.c b/keys.c index 8f35831b..b4a40ed8 100644 --- a/keys.c +++ b/keys.c @@ -38,8 +38,6 @@ char *keybindings[MAX_BINDMAPS][MAX_KEYS]; int history_line; char history_savedline[MAX_INPUTLINE]; conbuffer_t history; -#define HIST_TEXTSIZE 262144 -#define HIST_MAXLINES 4096 extern cvar_t con_textsize; diff --git a/menu.c b/menu.c index 06d164d0..7dd5ddce 100644 --- a/menu.c +++ b/menu.c @@ -812,7 +812,6 @@ static void M_SinglePlayer_Key (int key, int ascii) static int load_cursor; ///< 0 < load_cursor < MAX_SAVEGAMES -#define MAX_SAVEGAMES 12 static char m_filenames[MAX_SAVEGAMES][SAVEGAME_COMMENT_LENGTH+1]; static int loadable[MAX_SAVEGAMES]; diff --git a/menu.h b/menu.h index 5e8db63a..c1950fc2 100644 --- a/menu.h +++ b/menu.h @@ -23,7 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define M_PROG_FILENAME "menu.dat" #define M_NAME "menu" -#define M_MAX_EDICTS 32768 // hopefully won't have to increase this again anytime soon... enum m_state_e { m_none, diff --git a/model_shared.c b/model_shared.c index 6ea5a859..13af108b 100644 --- a/model_shared.c +++ b/model_shared.c @@ -2266,7 +2266,7 @@ tag_weapon, tag_torso, */ memset(word, 0, sizeof(word)); - for (i = 0;i < MAX_SKINS && (data = text = (char *)FS_LoadFile(va("%s_%i.skin", loadmodel->name, i), tempmempool, true, NULL));i++) + for (i = 0;i < 256 && (data = text = (char *)FS_LoadFile(va("%s_%i.skin", loadmodel->name, i), tempmempool, true, NULL));i++) { // If it's the first file we parse if (skinfile == NULL) diff --git a/model_shared.h b/model_shared.h index 4caa59e0..d7de9456 100644 --- a/model_shared.h +++ b/model_shared.h @@ -75,8 +75,6 @@ typedef struct skinframe_s } skinframe_t; -#define MAX_SKINS 256 - struct md3vertex_s; struct trivertx_s; typedef struct texvecvertex_s diff --git a/quakedef.h b/quakedef.h index f2353785..d27b54d6 100644 --- a/quakedef.h +++ b/quakedef.h @@ -55,30 +55,123 @@ extern char engineversion[128]; #define MAX_NUM_ARGVS 50 +#ifdef DP_SMALLMEMORY +#define MAX_INPUTLINE 1024 +#define CON_TEXTSIZE 16384 +#define CON_MAXLINES 256 +#define HIST_TEXTSIZE 2048 +#define HIST_MAXLINES 16 +#define MAX_ALIAS_NAME 32 +#define CMDBUFSIZE 8192 +#define MAX_ARGS 10 + +#define NET_MAXMESSAGE 8192 +#define MAX_PACKETFRAGMENT 1024 +#define MAX_EDICTS 4096 +#define MAX_MODELS 1024 +#define MAX_SOUNDS 1024 +#define MAX_LIGHTSTYLES 64 +#define MAX_STYLESTRING 16 +#define MAX_SCOREBOARD 32 +#define MAX_SCOREBOARDNAME 64 +#define MAX_USERINFO_STRING 196 +#define MAX_SERVERINFO_STRING 512 +#define MAX_LOCALINFO_STRING 1 // not actually used by DP servers +#define CL_MAX_USERCMDS 32 +#define CVAR_HASHSIZE 1024 +#define M_MAX_EDICTS 4096 +#define MAX_DEMOS 8 +#define MAX_DEMONAME 16 +#define MAX_SAVEGAMES 12 +#define SAVEGAME_COMMENT_LENGTH 39 +#define MAX_CLIENTNETWORKEYES 1 + +#define MAX_WATERPLANES 2 +#define MAX_CUBEMAPS 64 +//#define MAX_EXPLOSIONS 64 +#define MAX_DLIGHTS 16 +#define MAX_CACHED_PICS 128 // this is 144 bytes each (or 152 on 64bit) +#define CACHEPICHASHSIZE 256 +#define MAX_PARTICLEEFFECTNAME 64 +#define MAX_PARTICLEEFFECTINFO 256 +#define MAX_PARTICLETEXTURES 96 +#define MAXCLVIDEOS 1 +#define MAX_GECKO_INSTANCES 1 +#define MAX_DYNAMIC_TEXTURE_COUNT 2 +#define MAX_MAP_LEAFS 8192 + +//#define MAXTRACKS 256 +#define MAX_DYNAMIC_CHANNELS 64 +#define MAX_CHANNELS 260 +#else +#define MAX_INPUTLINE 16384 ///< maximum length of console commandline, QuakeC strings, and many other text processing buffers +#define CON_TEXTSIZE 1048576 ///< max scrollback buffer characters in console +#define CON_MAXLINES 16384 ///< max scrollback buffer lines in console +#define HIST_TEXTSIZE 262144 ///< max command history buffer characters in console +#define HIST_MAXLINES 4096 ///< max command history buffer lines in console +#define MAX_ALIAS_NAME 32 +#define CMDBUFSIZE 655360 ///< maximum script size that can be loaded by the exec command (8192 in Quake) +#define MAX_ARGS 80 ///< maximum number of parameters to a console command or alias + +#define NET_MAXMESSAGE 65536 ///< max reliable packet size (sent as multiple fragments of MAX_PACKETFRAGMENT) +#define MAX_PACKETFRAGMENT 1024 ///< max length of packet fragment +#define MAX_EDICTS 32768 ///< max number of objects in game world at once (32768 protocol limit) +#define MAX_MODELS 8192 ///< max number of models loaded at once (including during level transitions) +#define MAX_SOUNDS 4096 ///< max number of sounds loaded at once +#define MAX_LIGHTSTYLES 256 ///< max flickering light styles in level (note: affects savegame format) +#define MAX_STYLESTRING 64 ///< max length of flicker pattern for light style +#define MAX_SCOREBOARD 255 ///< max number of players in game at once (255 protocol limit) +#define MAX_SCOREBOARDNAME 64 ///< max length of player name in game +#define MAX_USERINFO_STRING 1280 ///< max length of infostring for PROTOCOL_QUAKEWORLD (196 in QuakeWorld) +#define MAX_SERVERINFO_STRING 1280 ///< max length of server infostring for PROTOCOL_QUAKEWORLD (512 in QuakeWorld) +#define MAX_LOCALINFO_STRING 32768 ///< max length of server-local infostring for PROTOCOL_QUAKEWORLD (32768 in QuakeWorld) +#define CL_MAX_USERCMDS 128 ///< max number of predicted input packets in queue +#define CVAR_HASHSIZE 65536 ///< number of hash buckets for accelerating cvar name lookups +#define M_MAX_EDICTS 32768 ///< max objects in menu vm +#define MAX_DEMOS 8 ///< max demos provided to demos command +#define MAX_DEMONAME 16 ///< max demo name length for demos command +#define MAX_SAVEGAMES 12 ///< max savegames listed in savegame menu +#define SAVEGAME_COMMENT_LENGTH 39 ///< max comment length of savegame in menu +#define MAX_CLIENTNETWORKEYES 1 ///< max number of locations that can be added to pvs when culling network entities + +#define MAX_WATERPLANES 16 ///< max number of water planes visible (each one causes additional view renders) +#define MAX_CUBEMAPS 256 ///< max number of cubemap textures loaded for light filters +#define MAX_EXPLOSIONS 64 ///< max number of explosion shell effects active at once (not particle related) +#define MAX_DLIGHTS 256 ///< max number of dynamic lights (rocket flashes, etc) in scene at once +#define MAX_CACHED_PICS 1024 ///< max number of 2D pics loaded at once +#define CACHEPICHASHSIZE 256 ///< number of hash buckets for accelerating 2D pic name lookups +#define MAX_PARTICLEEFFECTNAME 256 ///< maximum number of unique names of particle effects (for particleeffectnum) +#define MAX_PARTICLEEFFECTINFO 4096 ///< maximum number of unique particle effects (each name may associate with several of these) +#define MAX_PARTICLETEXTURES 1024 ///< maximum number of unique particle textures in the particle font +#define MAXCLVIDEOS 65 ///< maximum number of video streams being played back at once (1 is reserved for the playvideo command) +#define MAX_GECKO_INSTANCES 16 ///< maximum number of web browser textures active at once +#define MAX_DYNAMIC_TEXTURE_COUNT 64 ///< maximum number of dynamic textures (web browsers, playvideo, etc) +#define MAX_MAP_LEAFS 65536 ///< maximum number of BSP leafs in world (8192 in Quake) + +#define MAXTRACKS 256 ///< max CD track index +// 0 to NUM_AMBIENTS - 1 = water, etc +// NUM_AMBIENTS to NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS - 1 = normal entity sounds +// NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS to total_channels = static sounds +#define MAX_DYNAMIC_CHANNELS 512 +#define MAX_CHANNELS 1028 +#endif -#define MAX_QPATH 128 ///< max length of a quake game pathname -#define MAX_OSPATH 1024 ///< max length of a filesystem pathname -#define ON_EPSILON 0.1 ///< point on plane side epsilon +#define CMD_TOKENIZELENGTH (MAX_INPUTLINE + MAX_ARGS) ///< maximum tokenizable commandline length (counting trailing 0) -#define MAX_PACKETFRAGMENT 1024 ///< max length of packet fragment -#define NET_MAXMESSAGE 65536 -#define NET_MINRATE 1000 ///< limits "rate" and "sv_maxrate" cvars -// -// per-level limits -// -// LordHavoc: increased entity limit to 2048 from 600 -#define MAX_EDICTS 32768 // FIXME: ouch! ouch! ouch! -#define MAX_LIGHTSTYLES 256 // LordHavoc: increased from 64, NOTE special consideration is needed in savegames! -// LordHavoc: increased model and sound limits from 256 and 256 to 4096 and 4096 (and added protocol extensions accordingly to break the 256 barrier) -// div0: increased model limit to 8192 -#define MAX_MODELS 8192 -#define MAX_SOUNDS 4096 +#define MAX_QPATH 128 ///< max length of a quake game pathname +#ifdef PATH_MAX +#define MAX_OSPATH PATH_MAX +#elif MAX_PATH +#define MAX_OSPATH MAX_PATH +#else +#define MAX_OSPATH 1024 ///< max length of a filesystem pathname +#endif -#define SAVEGAME_COMMENT_LENGTH 39 +#define ON_EPSILON 0.1 ///< point on plane side epsilon -#define MAX_STYLESTRING 64 +#define NET_MINRATE 1000 ///< limits "rate" and "sv_maxrate" cvars // // stats are integers communicated to the client by the server @@ -228,17 +321,6 @@ extern char engineversion[128]; //=========================================== -// LordHavoc: increased player limit from 16 to 255 -#define MAX_SCOREBOARD 255 -// LordHavoc: increased name limit from 32 to 64 characters -#define MAX_SCOREBOARDNAME 64 -// infostring sizes used by QuakeWorld support -// was 196 -#define MAX_USERINFO_STRING 1280 -// was 512 -#define MAX_SERVERINFO_STRING 1280 -#define MAX_LOCALINFO_STRING 32768 - #include "zone.h" #include "fs.h" #include "common.h" diff --git a/r_explosion.c b/r_explosion.c index 2c1f72f7..afb033da 100644 --- a/r_explosion.c +++ b/r_explosion.c @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" #include "cl_collision.h" -#define MAX_EXPLOSIONS 64 +#ifdef MAX_EXPLOSIONS #define EXPLOSIONGRID 8 #define EXPLOSIONVERTS ((EXPLOSIONGRID+1)*(EXPLOSIONGRID+1)) #define EXPLOSIONTRIS (EXPLOSIONGRID*EXPLOSIONGRID*2) @@ -53,8 +53,10 @@ static rtexture_t *explosiontexture; static rtexture_t *explosiontexturefog; static rtexturepool_t *explosiontexturepool; +#endif cvar_t r_explosionclip = {CVAR_SAVE, "r_explosionclip", "1", "enables collision detection for explosion shell (so that it flattens against walls and floors)"}; +#ifdef MAX_EXPLOSIONS static cvar_t r_drawexplosions = {0, "r_drawexplosions", "1", "enables rendering of explosion shells (see also cl_particles_explosions_shell)"}; static void r_explosion_start(void) @@ -118,9 +120,11 @@ static int R_ExplosionVert(int column, int row) explosionnoiseindex[i] = (row % EXPLOSIONGRID) * EXPLOSIONGRID + (column % EXPLOSIONGRID); return i; } +#endif void R_Explosion_Init(void) { +#ifdef MAX_EXPLOSIONS int i, x, y; i = 0; for (y = 0;y < EXPLOSIONGRID;y++) @@ -138,14 +142,18 @@ void R_Explosion_Init(void) } } +#endif Cvar_RegisterVariable(&r_explosionclip); +#ifdef MAX_EXPLOSIONS Cvar_RegisterVariable(&r_drawexplosions); R_RegisterModule("R_Explosions", r_explosion_start, r_explosion_shutdown, r_explosion_newmap); +#endif } void R_NewExplosion(const vec3_t org) { +#ifdef MAX_EXPLOSIONS int i, j; float dist, n; explosion_t *e; @@ -182,8 +190,10 @@ void R_NewExplosion(const vec3_t org) break; } } +#endif } +#ifdef MAX_EXPLOSIONS static void R_DrawExplosion_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist) { int surfacelistindex = 0; @@ -250,9 +260,11 @@ static void R_MoveExplosion(explosion_t *e) } } } +#endif void R_DrawExplosions(void) { +#ifdef MAX_EXPLOSIONS int i; if (!r_drawexplosions.integer) @@ -269,5 +281,6 @@ void R_DrawExplosions(void) } while (numexplosions > 0 && explosion[i-1].alpha <= 0) numexplosions--; +#endif } diff --git a/r_modules.c b/r_modules.c index 91221fc3..8021ade7 100644 --- a/r_modules.c +++ b/r_modules.c @@ -1,7 +1,7 @@ #include "quakedef.h" -#define MAXRENDERMODULES 64 +#define MAXRENDERMODULES 20 typedef struct rendermodule_s { diff --git a/r_shadow.c b/r_shadow.c index 03e06444..9dd92149 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -345,7 +345,6 @@ typedef struct cubemapinfo_s } cubemapinfo_t; -#define MAX_CUBEMAPS 256 static int numcubemaps; static cubemapinfo_t cubemaps[MAX_CUBEMAPS]; diff --git a/render.h b/render.h index 85e22850..d6bef5dd 100644 --- a/render.h +++ b/render.h @@ -451,13 +451,11 @@ typedef struct r_waterstate_waterplane_s rtexture_t *texture_reflection; mplane_t plane; int materialflags; // combined flags of all water surfaces on this plane - unsigned char pvsbits[(32768+7)>>3]; // FIXME: buffer overflow on huge maps + unsigned char pvsbits[(MAX_MAP_LEAFS+7)>>3]; // FIXME: buffer overflow on huge maps qboolean pvsvalid; } r_waterstate_waterplane_t; -#define MAX_WATERPLANES 16 - typedef struct r_waterstate_s { qboolean enabled; diff --git a/server.h b/server.h index 06543a55..2faca630 100644 --- a/server.h +++ b/server.h @@ -68,8 +68,6 @@ typedef struct server_connectfloodaddress_s } server_connectfloodaddress_t; -#define MAX_CLIENTNETWORKEYES 256 - typedef struct server_s { /// false if only a net client diff --git a/snd_main.c b/snd_main.c index 540a7f9e..2ade24b4 100644 --- a/snd_main.c +++ b/snd_main.c @@ -1239,13 +1239,13 @@ void SND_Spatialize(channel_t *ch, qboolean isstatic) // update sound origin if we know about the entity if (ch->entnum > 0 && cls.state == ca_connected && cl_gameplayfix_soundsmovewithentities.integer) { - if (ch->entnum >= 32768) + if (ch->entnum >= MAX_EDICTS) { //Con_Printf("-- entnum %i origin %f %f %f neworigin %f %f %f\n", ch->entnum, ch->origin[0], ch->origin[1], ch->origin[2], cl.entities[ch->entnum].state_current.origin[0], cl.entities[ch->entnum].state_current.origin[1], cl.entities[ch->entnum].state_current.origin[2]); - if (ch->entnum > 32768) + if (ch->entnum > MAX_EDICTS) if (!CL_VM_GetEntitySoundOrigin(ch->entnum, ch->origin)) - ch->entnum = 32768; // entity was removed, disown sound + ch->entnum = MAX_EDICTS; // entity was removed, disown sound } else if (cl.entities[ch->entnum].state_current.active) { @@ -1264,7 +1264,7 @@ void SND_Spatialize(channel_t *ch, qboolean isstatic) mastervol *= snd_staticvolume.value; else if(!(ch->flags & CHANNELFLAG_FULLVOLUME)) // same as SND_PaintChannel uses { - if(ch->entnum >= 32768) + if(ch->entnum >= MAX_EDICTS) { switch(ch->entchannel) { diff --git a/snd_main.h b/snd_main.h index 07cc6e11..771205ae 100644 --- a/snd_main.h +++ b/snd_main.h @@ -110,12 +110,6 @@ struct snd_fetcher_s snd_fetcher_getfmt_t getfmt; }; -// 0 to NUM_AMBIENTS - 1 = water, etc -// NUM_AMBIENTS to NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS - 1 = normal entity sounds -// NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS to total_channels = static sounds -#define MAX_DYNAMIC_CHANNELS 512 -#define MAX_CHANNELS 1028 - extern unsigned int total_channels; extern channel_t channels[MAX_CHANNELS]; diff --git a/svvm_cmds.c b/svvm_cmds.c index 030bb92b..ce61e9f5 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -819,8 +819,8 @@ static void VM_SV_checkpvs (void) #if 1 unsigned char *pvs; #else - static int fatpvsbytes; - static unsigned char fatpvs[MAX_MAP_LEAFS/8]; + int fatpvsbytes; + unsigned char fatpvs[MAX_MAP_LEAFS/8]; #endif VM_SAFEPARMCOUNT(2, VM_SV_checkpvs); -- 2.39.2