cvar_t cl_prydoncursor = {0, "cl_prydoncursor", "0"};
-mempool_t *cl_refdef_mempool;
-mempool_t *cl_entities_mempool;
+mempool_t *cl_mempool;
client_static_t cls;
client_state_t cl;
{
int i;
+ if (cl_entities) Mem_Free(cl_entities);cl_entities = NULL;
+ if (cl_entities_active) Mem_Free(cl_entities_active);cl_entities_active = NULL;
+ if (cl_static_entities) Mem_Free(cl_static_entities);cl_static_entities = NULL;
+ if (cl_temp_entities) Mem_Free(cl_temp_entities);cl_temp_entities = NULL;
+ if (cl_effects) Mem_Free(cl_effects);cl_effects = NULL;
+ if (cl_beams) Mem_Free(cl_beams);cl_beams = NULL;
+ if (cl_dlights) Mem_Free(cl_dlights);cl_dlights = NULL;
+ if (cl_lightstyle) Mem_Free(cl_lightstyle);cl_lightstyle = NULL;
+ if (cl_brushmodel_entities) Mem_Free(cl_brushmodel_entities);cl_brushmodel_entities = NULL;
+ if (cl.entitydatabase) EntityFrame_FreeDatabase(cl.entitydatabase);cl.entitydatabase = NULL;
+ if (cl.entitydatabase4) EntityFrame4_FreeDatabase(cl.entitydatabase4);cl.entitydatabase4 = NULL;
+ if (cl.scores) Mem_Free(cl.scores);cl.scores = NULL;
+
if (!sv.active)
Host_ClearMemory ();
- // note: this also gets rid of the entity database
- Mem_EmptyPool(cl_entities_mempool);
-
// wipe the entire cl structure
memset (&cl, 0, sizeof(cl));
// reset the view zoom interpolation
cl_max_lightstyle = MAX_LIGHTSTYLES;
cl_max_brushmodel_entities = MAX_EDICTS;
- cl_entities = Mem_Alloc(cl_entities_mempool, cl_max_entities * sizeof(entity_t));
- cl_entities_active = Mem_Alloc(cl_entities_mempool, cl_max_entities * sizeof(qbyte));
- cl_static_entities = Mem_Alloc(cl_entities_mempool, cl_max_static_entities * sizeof(entity_t));
- cl_temp_entities = Mem_Alloc(cl_entities_mempool, cl_max_temp_entities * sizeof(entity_t));
- cl_effects = Mem_Alloc(cl_entities_mempool, cl_max_effects * sizeof(cl_effect_t));
- cl_beams = Mem_Alloc(cl_entities_mempool, cl_max_beams * sizeof(beam_t));
- cl_dlights = Mem_Alloc(cl_entities_mempool, cl_max_dlights * sizeof(dlight_t));
- cl_lightstyle = Mem_Alloc(cl_entities_mempool, cl_max_lightstyle * sizeof(lightstyle_t));
- cl_brushmodel_entities = Mem_Alloc(cl_entities_mempool, cl_max_brushmodel_entities * sizeof(entity_render_t *));
+ cl_entities = Mem_Alloc(cl_mempool, cl_max_entities * sizeof(entity_t));
+ cl_entities_active = Mem_Alloc(cl_mempool, cl_max_brushmodel_entities * sizeof(qbyte));
+ cl_static_entities = Mem_Alloc(cl_mempool, cl_max_static_entities * sizeof(entity_t));
+ cl_temp_entities = Mem_Alloc(cl_mempool, cl_max_temp_entities * sizeof(entity_t));
+ cl_effects = Mem_Alloc(cl_mempool, cl_max_effects * sizeof(cl_effect_t));
+ cl_beams = Mem_Alloc(cl_mempool, cl_max_beams * sizeof(beam_t));
+ cl_dlights = Mem_Alloc(cl_mempool, cl_max_dlights * sizeof(dlight_t));
+ cl_lightstyle = Mem_Alloc(cl_mempool, cl_max_lightstyle * sizeof(lightstyle_t));
+ cl_brushmodel_entities = Mem_Alloc(cl_mempool, cl_max_brushmodel_entities * sizeof(entity_render_t *));
// LordHavoc: have to set up the baseline info for alpha and other stuff
for (i = 0;i < cl_max_entities;i++)
oldmaxentities = cl_max_entities;
oldentities = cl_entities;
cl_max_entities = (num & ~255) + 256;
- cl_entities = Mem_Alloc(cl_entities_mempool, cl_max_entities * sizeof(entity_t));
+ cl_entities = Mem_Alloc(cl_mempool, cl_max_entities * sizeof(entity_t));
memcpy(cl_entities, oldentities, oldmaxentities * sizeof(entity_t));
Mem_Free(oldentities);
for (i = oldmaxentities;i < cl_max_entities;i++)
CL_Particles_Shutdown();
CL_Parse_Shutdown();
- SZ_Free (&cls.message);
-
- Mem_FreePool (&cl_entities_mempool);
- Mem_FreePool (&cl_refdef_mempool);
+ Mem_FreePool (&cl_mempool);
}
/*
*/
void CL_Init (void)
{
- cl_entities_mempool = Mem_AllocPool("client entities", 0, NULL);
- cl_refdef_mempool = Mem_AllocPool("refdef", 0, NULL);
+ cl_mempool = Mem_AllocPool("client", 0, NULL);
memset(&r_refdef, 0, sizeof(r_refdef));
// max entities sent to renderer per frame
r_refdef.maxentities = MAX_EDICTS + 256 + 512;
- r_refdef.entities = Mem_Alloc(cl_refdef_mempool, sizeof(entity_render_t *) * r_refdef.maxentities);
+ r_refdef.entities = Mem_Alloc(cl_mempool, sizeof(entity_render_t *) * r_refdef.maxentities);
// 256k drawqueue buffer
r_refdef.maxdrawqueuesize = 256 * 1024;
- r_refdef.drawqueue = Mem_Alloc(cl_refdef_mempool, r_refdef.maxdrawqueuesize);
+ r_refdef.drawqueue = Mem_Alloc(cl_mempool, r_refdef.maxdrawqueuesize);
- SZ_Alloc (&cls.message, 1024, "cls.message");
+ cls.message.data = cls.message_buf;
+ cls.message.maxsize = sizeof(cls.message_buf);
+ cls.message.cursize = 0;
CL_InitInput ();
cvar_t demo_nehahra = {0, "demo_nehahra", "0"};
cvar_t developer_networkentities = {0, "developer_networkentities", "0"};
-mempool_t *cl_scores_mempool;
-
/*
==================
CL_ParseStartSoundPacket
entity_t *ent;
Con_DPrint("Serverinfo packet received.\n");
+
//
// wipe the client_state_t struct
//
Host_Error("Bad maxclients (%u) from server\n", cl.maxclients);
return;
}
- Mem_EmptyPool(cl_scores_mempool);
- cl.scores = Mem_Alloc(cl_scores_mempool, cl.maxclients*sizeof(*cl.scores));
+ cl.scores = Mem_Alloc(cl_mempool, cl.maxclients*sizeof(*cl.scores));
// parse gametype
cl.gametype = MSG_ReadByte ();
void CL_Parse_Init(void)
{
// LordHavoc: added demo_nehahra cvar
- cl_scores_mempool = Mem_AllocPool("client player info", 0, NULL);
Cvar_RegisterVariable (&demo_nehahra);
if (gamemode == GAME_NEHAHRA)
Cvar_SetValue("demo_nehahra", 1);
void CL_Parse_Shutdown(void)
{
- Mem_FreePool (&cl_scores_mempool);
}
cvar_t cl_decals_time = {CVAR_SAVE, "cl_decals_time", "0"};
cvar_t cl_decals_fadetime = {CVAR_SAVE, "cl_decals_fadetime", "20"};
-#ifndef WORKINGLQUAKE
-static mempool_t *cl_part_mempool;
-#endif
-
void CL_Particles_Clear(void)
{
cl_numparticles = 0;
#ifdef WORKINGLQUAKE
particles = (particle_t *) Hunk_AllocName(cl_maxparticles * sizeof(particle_t), "particles");
#else
- cl_part_mempool = Mem_AllocPool("CL_Part", 0, NULL);
- particles = (particle_t *) Mem_Alloc(cl_part_mempool, cl_maxparticles * sizeof(particle_t));
+ particles = (particle_t *) Mem_Alloc(cl_mempool, cl_maxparticles * sizeof(particle_t));
#endif
CL_Particles_Clear();
}
{
#ifdef WORKINGLQUAKE
// No clue what to do here...
-#else
- Mem_FreePool (&cl_part_mempool);
#endif
}
static int cl_videobytesperpixel;
static clvideo_t videoarray[ MAXCLVIDEOS ];
-static mempool_t *cl_videomempool;
static rtexturepool_t *cl_videotexturepool;
static clvideo_t *FindUnusedVid( void )
// free the image data
Mem_Free( video->imagedata );
// if we are in firstframe mode, also close the stream
- if( video->state == CLVIDEO_FIRSTFRAME )
- dpvsimpledecode_close( video->stream );
+ if( video->state == CLVIDEO_FIRSTFRAME )
+ dpvsimpledecode_close( video->stream );
}
static qboolean WakeVideo( clvideo_t * video )
video->state = CLVIDEO_UNUSED;
return false;
}
-
- video->imagedata = Mem_Alloc( cl_videomempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel );
- video->cpif.tex = R_LoadTexture2D( cl_videotexturepool, video->cpif.name,
- video->cpif.width, video->cpif.height, NULL, TEXTYPE_RGBA, 0, NULL );
+
+ video->imagedata = Mem_Alloc( cl_mempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel );
+ video->cpif.tex = R_LoadTexture2D( cl_videotexturepool, video->cpif.name,
+ video->cpif.width, video->cpif.height, NULL, TEXTYPE_RGBA, 0, NULL );
// update starttime
video->starttime += realtime - video->lasttime;
video->cpif.width = dpvsimpledecode_getwidth( video->stream );
video->cpif.height = dpvsimpledecode_getheight( video->stream );
- video->cpif.tex = R_LoadTexture2D( cl_videotexturepool, video->cpif.name,
+ video->cpif.tex = R_LoadTexture2D( cl_videotexturepool, video->cpif.name,
video->cpif.width, video->cpif.height, NULL, TEXTYPE_RGBA, 0, NULL );
- video->imagedata = Mem_Alloc( cl_videomempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel );
+ video->imagedata = Mem_Alloc( cl_mempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel );
return video;
}
clvideo_t *video;
for( i = 0 ; i < MAXCLVIDEOS ; i++ )
- if( videoarray[ i ].state != CLVIDEO_UNUSED
+ if( videoarray[ i ].state != CLVIDEO_UNUSED
&& !strcmp( videoarray[ i ].cpif.name , name ) )
break;
if( i == MAXCLVIDEOS )
{
if( !WakeVideo( video ) )
return NULL;
- else if( video->state == CLVIDEO_RESETONWAKEUP )
+ else if( video->state == CLVIDEO_RESETONWAKEUP )
video->framenum = -1;
}
{
if( !video )
return;
-
+
video->starttime = video->lasttime = realtime;
video->framenum = -1;
if( video->framenum < destframe ) {
do {
video->framenum++;
- if( dpvsimpledecode_video( video->stream, video->imagedata, cl_videormask,
- cl_videogmask, cl_videobmask, cl_videobytesperpixel,
- cl_videobytesperpixel * video->cpif.width )
+ if( dpvsimpledecode_video( video->stream, video->imagedata, cl_videormask,
+ cl_videogmask, cl_videobmask, cl_videobytesperpixel,
+ cl_videobytesperpixel * video->cpif.width )
) { // finished?
CL_RestartVideo( video );
if( video->state == CLVIDEO_PLAY )
}
} while( video->framenum < destframe );
R_UpdateTexture( video->cpif.tex, video->imagedata );
- }
+ }
}
void CL_VideoFrame( void ) // update all videos
SuspendVideo( video );
else if( video->state == CLVIDEO_PAUSE )
video->starttime = realtime - video->framenum * video->framerate;
- else
+ else
VideoFrame( video );
}
int i;
for( i = 0 ; i < MAXCLVIDEOS ; i++ )
CL_CloseVideo( &videoarray[ i ] );
-
- Mem_FreePool( &cl_videomempool );
}
void CL_PurgeOwner( int owner )
for( video = videoarray, i = 0 ; i < MAXCLVIDEOS ; i++, video++ )
if( video->state != CLVIDEO_UNUSED && !video->suspended )
- video->cpif.tex = R_LoadTexture2D( cl_videotexturepool, video->cpif.name,
+ video->cpif.tex = R_LoadTexture2D( cl_videotexturepool, video->cpif.name,
video->cpif.width, video->cpif.height, NULL, TEXTYPE_RGBA, 0, NULL );
}
Cmd_AddCommand( "playvideo", CL_PlayVideo_f );
Cmd_AddCommand( "stopvideo", CL_StopVideo_f );
-
- cl_videomempool = Mem_AllocPool( "CL_Video", 0, NULL );
R_RegisterModule( "CL_Video", cl_video_start, cl_video_shutdown, cl_video_newmap );
}
netconn_t *netcon;
// writing buffer to send to server
sizebuf_t message;
+ qbyte message_buf[1024];
}
client_static_t;
}
client_state_t;
-extern mempool_t *cl_scores_mempool;
-
//
// cvars
//
extern int cl_num_temp_entities;
extern int cl_num_brushmodel_entities;
-extern mempool_t *cl_entities_mempool;
+extern mempool_t *cl_mempool;
extern entity_t *cl_entities;
extern qbyte *cl_entities_active;
extern entity_t *cl_static_entities;
refdef_t r_refdef;
-extern mempool_t *cl_refdef_mempool;
-
#include "cgamevm.h"
#endif
//===========================================================================
-void SZ_Alloc (sizebuf_t *buf, int startsize, const char *name)
-{
- if (startsize < 256)
- startsize = 256;
- buf->mempool = Mem_AllocPool(name, 0, NULL);
- buf->data = Mem_Alloc(buf->mempool, startsize);
- buf->maxsize = startsize;
- buf->cursize = 0;
-}
-
-
-void SZ_Free (sizebuf_t *buf)
-{
- Mem_FreePool(&buf->mempool);
- buf->data = NULL;
- buf->maxsize = 0;
- buf->cursize = 0;
-}
-
void SZ_Clear (sizebuf_t *buf)
{
buf->cursize = 0;
qboolean allowoverflow; // if false, do a Sys_Error
qboolean overflowed; // set to true if the buffer size failed
qbyte *data;
- mempool_t *mempool;
int maxsize;
int cursize;
} sizebuf_t;
-void SZ_Alloc (sizebuf_t *buf, int startsize, const char *name);
-void SZ_Free (sizebuf_t *buf);
void SZ_Clear (sizebuf_t *buf);
void *SZ_GetSpace (sizebuf_t *buf, int length);
void SZ_Write (sizebuf_t *buf, const void *data, int length);
int con_current;
// offset in current line for next print
int con_x;
-char *con_text = 0;
+char con_text[CON_TEXTSIZE];
//seconds
cvar_t con_notifytime = {CVAR_SAVE, "con_notifytime","3"};
qboolean con_initialized;
-mempool_t *console_mempool;
-
/*
==============================================================================
*/
void Con_Init (void)
{
- console_mempool = Mem_AllocPool("console", 0, NULL);
- con_text = Mem_Alloc(console_mempool, CON_TEXTSIZE);
memset (con_text, ' ', CON_TEXTSIZE);
con_linewidth = -1;
Con_CheckResize ();
int ignorecase; // PK3 ignores case
int numfiles;
packfile_t *files;
- mempool_t *mempool;
struct pack_s *next;
} pack_t;
*/
mempool_t *fs_mempool;
-mempool_t *pak_mempool;
int fs_filesize;
#endif
// Create a package structure in memory
- pack = Mem_Alloc (pak_mempool, sizeof (pack_t));
+ pack = Mem_Alloc(fs_mempool, sizeof (pack_t));
pack->ignorecase = true; // PK3 ignores case
strlcpy (pack->filename, packfile, sizeof (pack->filename));
pack->handle = packhandle;
pack->numfiles = eocd.nbentries;
- pack->mempool = Mem_AllocPool (packfile, 0, NULL);
- pack->files = Mem_Alloc (pack->mempool, eocd.nbentries * sizeof(packfile_t));
+ pack->files = Mem_Alloc(fs_mempool, eocd.nbentries * sizeof(packfile_t));
pack->next = packlist;
packlist = pack;
if (numpackfiles > MAX_FILES_IN_PACK)
Sys_Error ("%s has %i files", packfile, numpackfiles);
- pack = Mem_Alloc(pak_mempool, sizeof (pack_t));
+ pack = Mem_Alloc(fs_mempool, sizeof (pack_t));
pack->ignorecase = false; // PAK is case sensitive
strlcpy (pack->filename, packfile, sizeof (pack->filename));
pack->handle = packhandle;
pack->numfiles = 0;
- pack->mempool = Mem_AllocPool(packfile, 0, NULL);
- pack->files = Mem_Alloc(pack->mempool, numpackfiles * sizeof(packfile_t));
+ pack->files = Mem_Alloc(fs_mempool, numpackfiles * sizeof(packfile_t));
pack->next = packlist;
packlist = pack;
pak = FS_LoadPackPAK (pakfile);
if (pak)
{
- search = Mem_Alloc(pak_mempool, sizeof(searchpath_t));
+ search = Mem_Alloc(fs_mempool, sizeof(searchpath_t));
search->pack = pak;
search->next = fs_searchpaths;
fs_searchpaths = search;
pak = FS_LoadPackPK3 (pakfile);
if (pak)
{
- search = Mem_Alloc(pak_mempool, sizeof(searchpath_t));
+ search = Mem_Alloc(fs_mempool, sizeof(searchpath_t));
search->pack = pak;
search->next = fs_searchpaths;
fs_searchpaths = search;
// Add the directory to the search path
// (unpacked files have the priority over packed files)
- search = Mem_Alloc(pak_mempool, sizeof(searchpath_t));
+ search = Mem_Alloc(fs_mempool, sizeof(searchpath_t));
strlcpy (search->filename, dir, sizeof (search->filename));
search->next = fs_searchpaths;
fs_searchpaths = search;
searchpath_t *search;
fs_mempool = Mem_AllocPool("file management", 0, NULL);
- pak_mempool = Mem_AllocPool("paks", 0, NULL);
Cvar_RegisterVariable (&scr_screenshot_name);
if (!com_argv[i] || com_argv[i][0] == '+' || com_argv[i][0] == '-')
break;
- search = Mem_Alloc(pak_mempool, sizeof(searchpath_t));
+ search = Mem_Alloc(fs_mempool, sizeof(searchpath_t));
if (!strcasecmp (FS_FileExtension(com_argv[i]), "pak"))
{
search->pack = FS_LoadPackPAK (com_argv[i]);
*/
void FS_Shutdown (void)
{
- Mem_FreePool (&pak_mempool);
Mem_FreePool (&fs_mempool);
}
static matrix4x4_t backend_projectmatrix;
static unsigned int backendunits, backendimageunits, backendarrayunits, backendactive;
-static mempool_t *gl_backend_mempool;
/*
note: here's strip order for a terrain row:
static void R_Mesh_CacheArray_Shutdown(void);
void GL_Backend_AllocArrays(void)
{
- if (!gl_backend_mempool)
- gl_backend_mempool = Mem_AllocPool("GL_Backend", 0, NULL);
R_Mesh_CacheArray_Startup();
}
void GL_Backend_FreeArrays(void)
{
R_Mesh_CacheArray_Shutdown();
- Mem_FreePool(&gl_backend_mempool);
}
static void gl_backend_start(void)
static mempool_t *texturemempool;
-static mempool_t *texturedatamempool;
-static mempool_t *textureprocessingmempool;
// note: this must not conflict with TEXF_ flags in r_textures.h
// cleared when a texture is uploaded
// pointer into gltextureimage array
gltextureimage_t *image;
// name of the texture (this might be removed someday), no duplicates
- char *identifier;
+ char identifier[32];
// location in the image, and size
int x, y, z, width, height, depth;
// copy of the original texture(s) supplied to the upload function, for
}
}
- if (glt->identifier)
- Mem_Free(glt->identifier);
if (glt->inputtexels)
Mem_Free(glt->inputtexels);
Mem_Free(glt);
}
-/*
-static gltexture_t *R_FindTexture (gltexturepool_t *pool, char *identifier)
-{
- gltexture_t *glt;
-
- if (!identifier)
- return NULL;
-
- for (glt = pool->gltchain;glt;glt = glt->chain)
- if (glt->identifier && !strcmp (identifier, glt->identifier))
- return glt;
-
- return NULL;
-}
-*/
-
rtexturepool_t *R_AllocTexturePool(void)
{
gltexturepool_t *pool;
poolloadedp += glt->inputdatasize;
}
if (printeach)
- Con_Printf("%c%4i%c%c%4i%c %s %s %s %s\n", isloaded ? '[' : ' ', (glsize + 1023) / 1024, isloaded ? ']' : ' ', glt->inputtexels ? '[' : ' ', (glt->inputdatasize + 1023) / 1024, glt->inputtexels ? ']' : ' ', isloaded ? "loaded" : " ", (glt->flags & TEXF_MIPMAP) ? "mip" : " ", (glt->flags & TEXF_ALPHA) ? "alpha" : " ", glt->identifier ? glt->identifier : "<unnamed>");
+ Con_Printf("%c%4i%c%c%4i%c %s %s %s %s\n", isloaded ? '[' : ' ', (glsize + 1023) / 1024, isloaded ? ']' : ' ', glt->inputtexels ? '[' : ' ', (glt->inputdatasize + 1023) / 1024, glt->inputtexels ? ']' : ' ', isloaded ? "loaded" : " ", (glt->flags & TEXF_MIPMAP) ? "mip" : " ", (glt->flags & TEXF_ALPHA) ? "alpha" : " ", glt->identifier);
}
if (printpool)
Con_Printf("texturepool %10p total: %i (%.3fMB, %.3fMB original), uploaded %i (%.3fMB, %.3fMB original), upload on demand %i (%.3fMB, %.3fMB original)\n", pool, pooltotal, pooltotalt / 1048576.0, pooltotalp / 1048576.0, poolloaded, poolloadedt / 1048576.0, poolloadedp / 1048576.0, pooltotal - poolloaded, (pooltotalt - poolloadedt) / 1048576.0, (pooltotalp - poolloadedp) / 1048576.0);
// use the largest scrap texture size we can (not sure if this is really a good idea)
for (block_size = 1;block_size < realmaxsize && block_size < gl_max_scrapsize.integer;block_size <<= 1);
- texturemempool = Mem_AllocPool("Texture Info", 0, NULL);
- texturedatamempool = Mem_AllocPool("Texture Storage (not yet uploaded)", 0, NULL);
- textureprocessingmempool = Mem_AllocPool("Texture Processing Buffers", 0, NULL);
+ texturemempool = Mem_AllocPool("texture management", 0, NULL);
// Disable JPEG screenshots if the DLL isn't loaded
if (! JPEG_OpenLibrary ())
colorconvertbuffer = NULL;
texturebuffer = NULL;
Mem_FreePool(&texturemempool);
- Mem_FreePool(&texturedatamempool);
- Mem_FreePool(&textureprocessingmempool);
}
static void r_textures_newmap(void)
Mem_Free(resizebuffer);
if (colorconvertbuffer)
Mem_Free(colorconvertbuffer);
- resizebuffer = Mem_Alloc(textureprocessingmempool, resizebuffersize);
- colorconvertbuffer = Mem_Alloc(textureprocessingmempool, resizebuffersize);
+ resizebuffer = Mem_Alloc(texturemempool, resizebuffersize);
+ colorconvertbuffer = Mem_Alloc(texturemempool, resizebuffersize);
if (!resizebuffer || !colorconvertbuffer)
Host_Error("R_Upload: out of memory\n");
}
if (texturetype == GLTEXTURETYPE_3D && !gl_texture3d)
Sys_Error("R_LoadTexture: 3d texture not supported by driver\n");
- /*
- glt = R_FindTexture (pool, identifier);
- if (glt)
- {
- Con_Printf("R_LoadTexture: replacing existing texture %s\n", identifier);
- R_FreeTexture((rtexture_t *)glt);
- }
- */
-
texinfo = R_GetTexTypeInfo(textype, flags);
size = width * height * depth * sides * texinfo->inputbytesperpixel;
if (size < 1)
glt = Mem_Alloc(texturemempool, sizeof(gltexture_t));
if (identifier)
- {
- glt->identifier = Mem_Alloc(texturemempool, strlen(identifier)+1);
- strcpy (glt->identifier, identifier);
- }
- else
- glt->identifier = NULL;
+ strlcpy (glt->identifier, identifier, sizeof(glt->identifier));
glt->pool = pool;
glt->chain = pool->gltchain;
pool->gltchain = glt;
if (data)
{
- glt->inputtexels = Mem_Alloc(texturedatamempool, size);
+ glt->inputtexels = Mem_Alloc(texturemempool, size);
if (glt->inputtexels == NULL)
Sys_Error("R_LoadTexture: out of memory\n");
memcpy(glt->inputtexels, data, size);
longjmp (host_abortserver, 1);
}
-mempool_t *sv_clients_mempool = NULL;
-
void Host_ServerOptions (void)
{
int i, numplayers;
Cvar_SetValueQuick(&deathmatch, 1);
svs.maxclients = numplayers;
- sv_clients_mempool = Mem_AllocPool("server clients", 0, NULL);
- svs.clients = Mem_Alloc(sv_clients_mempool, sizeof(client_t) * svs.maxclients);
+ svs.clients = Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients);
}
/*
Cmd_Init();
Memory_Init_Commands();
- R_Modules_Init();
+ Con_Init();
Cbuf_Init();
+ R_Modules_Init();
V_Init();
COM_Init();
- Host_InitLocal();
Key_Init();
- Con_Init();
PR_Init();
PRVM_Init();
Mod_Init();
NetConn_Init();
SV_Init();
+ Host_InitLocal();
Con_Printf("Builddate: %s\n", buildstring);
}
-extern mempool_t *edictstring_mempool;
-
/*
===============
Host_Loadgame_f
{
// light style
COM_ParseToken(&t, false);
- sv.lightstyles[i] = Mem_Alloc(edictstring_mempool, strlen(com_token)+1);
- strcpy (sv.lightstyles[i], com_token);
+ sv.lightstyles[i] = PR_Alloc(strlen(com_token)+1);
+ strcpy(sv.lightstyles[i], com_token);
}
// load the edicts out of the savegame file
if (svs.clients)
Mem_Free(svs.clients);
svs.maxclients = n;
- svs.clients = Mem_Alloc(sv_clients_mempool, sizeof(client_t) * svs.maxclients);
+ svs.clients = Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients);
if (n == 1)
Cvar_Set ("deathmatch", "0");
else
}
}
-int resamplerowsize = 0;
-qbyte *resamplerow1 = NULL;
-qbyte *resamplerow2 = NULL;
-mempool_t *resamplemempool = NULL;
-
#define LERPBYTE(i) r = resamplerow1[i];out[i] = (qbyte) ((((resamplerow2[i] - r) * lerp) >> 16) + r)
void Image_Resample32Lerp(const void *indata, int inwidth, int inheight, void *outdata, int outwidth, int outheight)
{
int i, j, r, yi, oldy, f, fstep, lerp, endy = (inheight-1), inwidth4 = inwidth*4, outwidth4 = outwidth*4;
qbyte *out;
const qbyte *inrow;
+ qbyte *resamplerow1;
+ qbyte *resamplerow2;
out = outdata;
fstep = (int) (inheight*65536.0f/outheight);
+ resamplerow1 = Mem_Alloc(tempmempool, outwidth*4*2);
+ resamplerow2 = resamplerow1 + outwidth*4;
+
inrow = indata;
oldy = 0;
Image_Resample32LerpLine (inrow, resamplerow1, inwidth, outwidth);
memcpy(out, resamplerow1, outwidth4);
}
}
+
+ Mem_Free(resamplerow1);
+ resamplerow1 = NULL;
+ resamplerow2 = NULL;
}
-void Image_Resample32Nearest(const void *indata, int inwidth, int inheight, void *outdata, int outwidth, int outheight)
+void Image_Resample32Nolerp(const void *indata, int inwidth, int inheight, void *outdata, int outwidth, int outheight)
{
int i, j;
unsigned frac, fracstep;
int i, j, r, yi, oldy, f, fstep, lerp, endy = (inheight-1), inwidth3 = inwidth * 3, outwidth3 = outwidth * 3;
qbyte *out;
const qbyte *inrow;
+ qbyte *resamplerow1;
+ qbyte *resamplerow2;
out = outdata;
fstep = (int) (inheight*65536.0f/outheight);
+ resamplerow1 = Mem_Alloc(tempmempool, outwidth*3*2);
+ resamplerow2 = resamplerow1 + outwidth*3;
+
inrow = indata;
oldy = 0;
Image_Resample24LerpLine (inrow, resamplerow1, inwidth, outwidth);
memcpy(out, resamplerow1, outwidth3);
}
}
+ Mem_Free(resamplerow1);
+ resamplerow1 = NULL;
+ resamplerow2 = NULL;
}
void Image_Resample24Nolerp(const void *indata, int inwidth, int inheight, void *outdata, int outwidth, int outheight)
{
if (indepth != 1 || outdepth != 1)
Sys_Error("Image_Resample: 3D resampling not supported\n");
- if (resamplerowsize < outwidth*4)
- {
- if (resamplerow1)
- Mem_Free(resamplerow1);
- resamplerowsize = outwidth*4;
- if (!resamplemempool)
- resamplemempool = Mem_AllocPool("Image Scaling Buffer", 0, NULL);
- resamplerow1 = Mem_Alloc(resamplemempool, resamplerowsize*2);
- resamplerow2 = resamplerow1 + resamplerowsize;
- }
if (bytesperpixel == 4)
{
if (quality)
Image_Resample32Lerp(indata, inwidth, inheight, outdata, outwidth, outheight);
else
- Image_Resample32Nearest(indata, inwidth, inheight, outdata, outwidth, outheight);
+ Image_Resample32Nolerp(indata, inwidth, inheight, outdata, outwidth, outheight);
}
else if (bytesperpixel == 3)
{
#define TYPE_GAME 2
#define TYPE_BOTH 3
-mempool_t *menu_mempool;
-
int NehGameType;
enum m_state_e m_state;
menuplyr_width = image_width;
menuplyr_height = image_height;
Mem_Free(f);
- menuplyr_pixels = Mem_Alloc(menu_mempool, menuplyr_width * menuplyr_height);
- menuplyr_translated = Mem_Alloc(menu_mempool, menuplyr_width * menuplyr_height * 4);
+ menuplyr_pixels = Mem_Alloc(cl_mempool, menuplyr_width * menuplyr_height);
+ menuplyr_translated = Mem_Alloc(cl_mempool, menuplyr_width * menuplyr_height * 4);
memcpy(menuplyr_pixels, data, menuplyr_width * menuplyr_height);
Mem_Free(data);
}
void M_Init (void)
{
- menu_mempool = Mem_AllocPool("Menu", 0, NULL);
menuplyr_load = true;
menuplyr_pixels = NULL;
{
// reset key_dest
key_dest = key_game;
-
- Mem_FreePool (&menu_mempool);
}
void M_Restart(void)
prog->error_cmd = MP_Error;
// allocate the mempools
- prog->edicts_mempool = Mem_AllocPool(M_NAME " edicts mempool", 0, NULL);
- prog->edictstring_mempool = Mem_AllocPool( M_NAME " edict string mempool", 0, NULL);
prog->progs_mempool = Mem_AllocPool(M_PROG_FILENAME, 0, NULL);
PRVM_LoadProgs(M_PROG_FILENAME, m_numrequiredfunc, m_required_func);
int mq_count, mqt_count;
int mq_total, mqt_total;
-mempool_t *meshqueuemempool;
-
void R_MeshQueue_Init(void)
{
Cvar_RegisterVariable(&r_meshqueue_entries);
Cvar_RegisterVariable(&r_meshqueue_immediaterender);
Cvar_RegisterVariable(&r_meshqueue_sort);
- meshqueuemempool = Mem_AllocPool("R_MeshQueue", 0, NULL);
mq_total = 0;
mqt_total = 0;
mq_array = NULL;
static void R_MeshQueue_EnlargeTransparentArray(int newtotal)
{
meshqueue_t *newarray;
- newarray = Mem_Alloc(meshqueuemempool, newtotal * sizeof(meshqueue_t));
+ newarray = Mem_Alloc(cl_mempool, newtotal * sizeof(meshqueue_t));
if (mqt_array)
{
memcpy(newarray, mqt_array, mqt_total * sizeof(meshqueue_t));
mq_total = r_meshqueue_entries.integer;
if (mq_array)
Mem_Free(mq_array);
- mq_array = Mem_Alloc(meshqueuemempool, mq_total * sizeof(meshqueue_t));
+ mq_array = Mem_Alloc(cl_mempool, mq_total * sizeof(meshqueue_t));
}
if (mqt_array == NULL)
- mqt_array = Mem_Alloc(meshqueuemempool, mqt_total * sizeof(meshqueue_t));
+ mqt_array = Mem_Alloc(cl_mempool, mqt_total * sizeof(meshqueue_t));
mq_count = 0;
mqt_count = 0;
static double nextheartbeattime = 0;
sizebuf_t net_message;
+static qbyte net_message_buf[NET_MAXMESSAGE];
cvar_t net_messagetimeout = {0, "net_messagetimeout","300"};
cvar_t net_messagerejointimeout = {0, "net_messagerejointimeout","10"};
}
static qboolean _ServerList_CompareStr( const char *A, serverlist_maskop_t op, const char *B )
-{
+{
// Same here, also using an intermediate & final return would be more appropriate
// A info B mask
switch( op ) {
cls.demonum = -1; // not in the demo loop now
cls.state = ca_connected;
cls.signon = 0; // need all the signon messages before playing
- CL_ClearState();
}
int NetConn_IsLocalGame(void)
if( serverlist_cachecount == SERVERLIST_TOTALSIZE )
break;
// also ignore it if we have already queried it (other master server response)
- for( n = 0 ; n < serverlist_cachecount ; n++ )
+ for( n = 0 ; n < serverlist_cachecount ; n++ )
if( !strcmp( ipstring, serverlist_cache[ n ].info.cname ) )
break;
if( n >= serverlist_cachecount )
{
int i;
lhnetaddress_t tempaddress;
- netconn_mempool = Mem_AllocPool("Networking", 0, NULL);
+ netconn_mempool = Mem_AllocPool("network connections", 0, NULL);
Cmd_AddCommand("net_stats", Net_Stats_f);
Cmd_AddCommand("net_slist", Net_Slist_f);
Cmd_AddCommand("heartbeat", Net_Heartbeat_f);
}
cl_numsockets = 0;
sv_numsockets = 0;
- SZ_Alloc(&net_message, NET_MAXMESSAGE, "net_message");
+ net_message.data = net_message_buf;
+ net_message.maxsize = sizeof(net_message_buf);
+ net_message.cursize = 0;
LHNET_Init();
}
cvar_t sv_aim = {CVAR_SAVE, "sv_aim", "2"}; //"0.93"}; // LordHavoc: disabled autoaim by default
cvar_t pr_zone_min_strings = {0, "pr_zone_min_strings", "64"};
-mempool_t *pr_strings_mempool;
-
// LordHavoc: added this to semi-fix the problem of using many ftos calls in a print
#define STRINGTEMP_BUFFERS 16
#define STRINGTEMP_LENGTH 4096
{
char *in, *out;
in = G_STRING(OFS_PARM0);
- out = Mem_Alloc(pr_strings_mempool, strlen(in) + 1);
+ out = PR_Alloc(strlen(in) + 1);
strcpy(out, in);
G_INT(OFS_RETURN) = PR_SetString(out);
}
//void(string s) strunzone = #119; // removes a copy of a string from the string zone (you can not use that string again or it may crash!!!)
void PF_strunzone(void)
{
- Mem_Free(G_STRING(OFS_PARM0));
+ PR_Free(G_STRING(OFS_PARM0));
}
//void(entity e, string s) clientcommand = #440; // executes a command string as if it came from the specified client
void PR_Cmd_Init(void)
{
- pr_strings_mempool = Mem_AllocPool("pr_stringszone", 0, NULL);
PR_Files_Init();
PR_Search_Init();
}
void PR_Cmd_Shutdown(void)
{
- Mem_FreePool (&pr_strings_mempool);
}
void PR_Cmd_Reset(void)
{
- Mem_EmptyPool(pr_strings_mempool);
PR_Search_Reset();
PR_Files_CloseAll();
}
unsigned short pr_crc;
-mempool_t *progs_mempool;
-mempool_t *edictstring_mempool;
+mempool_t *serverprogs_mempool;
int type_size[8] = {1,sizeof(string_t)/4,1,3,1,1,sizeof(func_t)/4,sizeof(void *)/4};
int i,l;
l = strlen(string) + 1;
- new = Mem_Alloc(edictstring_mempool, l);
+ new = PR_Alloc(l);
new_p = new;
for (i=0 ; i< l ; i++)
for (i=0 ; i<GEFV_CACHESIZE ; i++)
gefvCache[i].field[0] = 0;
- Mem_EmptyPool(progs_mempool);
- Mem_EmptyPool(edictstring_mempool);
+ PR_FreeAll();
- progs = (dprograms_t *)FS_LoadFile (progsname, progs_mempool, false);
+ progs = (dprograms_t *)FS_LoadFile (progsname, serverprogs_mempool, false);
if (!progs)
Host_Error ("PR_LoadProgs: couldn't load %s", progsname);
// we need to expand the fielddefs list to include all the engine fields,
// so allocate a new place for it
infielddefs = (ddef_t *)((qbyte *)progs + progs->ofs_fielddefs);
- pr_fielddefs = Mem_Alloc(progs_mempool, (progs->numfielddefs + DPFIELDS) * sizeof(ddef_t));
+ pr_fielddefs = PR_Alloc((progs->numfielddefs + DPFIELDS) * sizeof(ddef_t));
+ pr_functions = PR_Alloc(sizeof(mfunction_t) * progs->numfunctions);
pr_statements = (dstatement_t *)((qbyte *)progs + progs->ofs_statements);
pr_statements[i].c = LittleShort(pr_statements[i].c);
}
- pr_functions = Mem_Alloc(progs_mempool, sizeof(mfunction_t) * progs->numfunctions);
for (i = 0;i < progs->numfunctions;i++)
{
pr_functions[i].first_statement = LittleLong (dfunctions[i].first_statement);
Cvar_RegisterVariable (&pr_boundscheck);
Cvar_RegisterVariable (&pr_traceqc);
- progs_mempool = Mem_AllocPool("progs.dat", 0, NULL);
- edictstring_mempool = Mem_AllocPool("edict strings", 0, NULL);
+ serverprogs_mempool = Mem_AllocPool("server progs", 0, NULL);
PR_Cmd_Init();
}
{
PR_Cmd_Shutdown();
- Mem_FreePool(&edictstring_mempool);
- Mem_FreePool(&progs_mempool);
+ Mem_FreePool(&serverprogs_mempool);
+}
+
+void *PR_Alloc(size_t buffersize)
+{
+ return Mem_Alloc(serverprogs_mempool, buffersize);
+}
+
+void PR_Free(void *buffer)
+{
+ Mem_Free(buffer);
+}
+
+void PR_FreeAll(void)
+{
+ progs = NULL;
+ pr_fielddefs = NULL;
+ pr_functions = NULL;
+ Mem_EmptyPool(serverprogs_mempool);
}
// LordHavoc: turned EDICT_NUM into a #define for speed reasons
void PR_ExecuteProgram (func_t fnum, const char *errormessage);
void PR_LoadProgs (const char *progsname);
+void *PR_Alloc (size_t buffersize);
+void PR_Free (void *buffer);
+void PR_FreeAll (void);
+
void PR_Profile_f (void);
void PR_PrintState(void);
void ED_PrintEdicts (void);
void ED_PrintNum (int ent);
-#define PR_GetString(num) (pr_strings + num)
+#define PR_GetString(num) (pr_strings + num)
#define PR_SetString(s) ((s) != NULL ? (int) (s - pr_strings) : 0)
#endif
{
// engine-private fields (stored in dynamically resized array)
//edict_engineprivate_t *e;
- union
+ union
{
prvm_edict_private_t *e;
void *vp;
//entvars_t *v;
void *v;
} prvm_edict_t;
-
+
#define PRVM_GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (prvm_eval_t *)((qbyte *)ed->v + fieldoffset) : NULL)
/*// this struct is the basic requirement for a qc prog
ddef_t *fielddefs;
ddef_t *globaldefs;
dstatement_t *statements;
- //prvm_pr_globalvars_t*pr_global_struct;
+ //prvm_pr_globalvars_t*pr_global_struct;
float *globals; // same as pr_global_struct
int edict_size; // in bytes
int edictareasize; // LordHavoc: in bytes (for bound checking)
-
+
+ // all memory allocations related to this vm_prog (code, edicts, strings)
mempool_t *progs_mempool;
- mempool_t *edictstring_mempool;
prvm_builtin_t *builtins;
int numbuiltins;
-
+
int argc;
-
+
int trace;
mfunction_t *xfunction;
int xstatement;
// thus increase the array, so depth wont be overwritten
prvm_stack_t stack[PRVM_MAX_STACK_DEPTH+1];
int depth;
-
+
int localstack[PRVM_LOCALSTACK_SIZE];
int localstack_used;
- unsigned short crc;
+ unsigned short crc;
//============================================================================
// until this point everything also exists (with the pr_ prefix) in the old vm
// size of the engine private struct
int edictprivate_size;
- // instead of sv_editcts_mempool
- mempool_t *edicts_mempool;
-
// has to be updated every frame - so the vm time is up-to-date
// AK changed so time will point to the time field (if there is one) else it points to _time
// actually should be double, but qc doesnt support it
// prvm_builtin_mem_t *mem_list;
// now passes as parameter of PRVM_LoadProgs
-// char **required_func;
+// char **required_func;
// int numrequiredfunc;
//============================================================================
-
+
ddef_t *self; // if self != 0 then there is a global self
-
+
//============================================================================
// function pointers
-
+
void (*begin_increase_edicts)(void); // used by PRVM_MEM_Increase_Edicts
- void (*end_increase_edicts)(void);
-
+ void (*end_increase_edicts)(void);
+
void (*init_edict)(int num); // used by PRVM_ED_ClearEdict
void (*free_edict)(prvm_edict_t *ed); // used by PRVM_ED_Free
//============================================================================
// prvm_cmds part
-extern prvm_builtin_t vm_sv_builtins[];
-extern prvm_builtin_t vm_cl_builtins[];
-extern prvm_builtin_t vm_m_builtins[];
+extern prvm_builtin_t vm_sv_builtins[];
+extern prvm_builtin_t vm_cl_builtins[];
+extern prvm_builtin_t vm_m_builtins[];
extern const int vm_sv_numbuiltins;
extern const int vm_cl_numbuiltins;
extern const int vm_m_numbuiltins;
-extern char * vm_sv_extensions;
-extern char * vm_cl_extensions;
-extern char * vm_m_extensions;
+extern char * vm_sv_extensions;
+extern char * vm_cl_extensions;
+extern char * vm_m_extensions;
-void VM_SV_Cmd_Init(void);
-void VM_SV_Cmd_Reset(void);
+void VM_SV_Cmd_Init(void);
+void VM_SV_Cmd_Reset(void);
-void VM_CL_Cmd_Init(void);
-void VM_CL_Cmd_Reset(void);
+void VM_CL_Cmd_Init(void);
+void VM_CL_Cmd_Reset(void);
-void VM_M_Cmd_Init(void);
+void VM_M_Cmd_Init(void);
void VM_M_Cmd_Reset(void);
void VM_Cmd_Init(void);
#define PRVM_Begin if(prog != 0) Con_Printf("prog not 0(prog = %i) in file: %s line: %i!\n", PRVM_GetProgNr(), __FILE__, __LINE__)
#define PRVM_End prog = 0
#else
-#define PRVM_Begin
+#define PRVM_Begin
#define PRVM_End prog = 0
#endif
qboolean PRVM_ProgLoaded(int prognr);
int PRVM_GetProgNr(void);
-
+
// TODO: fill in the params
//void PRVM_Create();
entity_t *ent;
entityframe_database_t *d;
if (!cl.entitydatabase)
- cl.entitydatabase = EntityFrame_AllocDatabase(cl_entities_mempool);
+ cl.entitydatabase = EntityFrame_AllocDatabase(cl_mempool);
d = cl.entitydatabase;
EntityFrame_Clear(f, NULL, -1);
entity_state_t *s;
entityframe4_database_t *d;
if (!cl.entitydatabase4)
- cl.entitydatabase4 = EntityFrame4_AllocDatabase(cl_entities_mempool);
+ cl.entitydatabase4 = EntityFrame4_AllocDatabase(cl_mempool);
d = cl.entitydatabase4;
// read the number of the frame this refers to
referenceframenum = MSG_ReadLong();
void EntityFrame5_FreeDatabase(entityframe5_database_t *d)
{
+ // all the [maxedicts] memory is allocated at once, so there's only one
+ // thing to free
+ if (d->maxedicts)
+ Mem_Free(d->deltabits);
Mem_Free(d);
}
int i;
memset(d, 0, sizeof(*d));
d->latestframenum = 0;
- for (i = 0;i < MAX_EDICTS;i++)
+ for (i = 0;i < d->maxedicts;i++)
d->states[i] = defaultstate;
}
+void EntityFrame5_ExpandEdicts(entityframe5_database_t *d, mempool_t *mempool, int newmax)
+{
+ if (d->maxedicts < newmax)
+ {
+ qbyte *data;
+ int oldmaxedicts = d->maxedicts;
+ int *olddeltabits = d->deltabits;
+ qbyte *oldpriorities = d->priorities;
+ int *oldupdateframenum = d->updateframenum;
+ entity_state_t *oldstates = d->states;
+ qbyte *oldvisiblebits = d->visiblebits;
+ d->maxedicts = newmax;
+ data = Mem_Alloc(mempool, d->maxedicts * sizeof(int) + d->maxedicts * sizeof(qbyte) + d->maxedicts * sizeof(int) + d->maxedicts * sizeof(entity_state_t) + (d->maxedicts+7)/8 * sizeof(qbyte));
+ d->deltabits = (void *)data;data += d->maxedicts * sizeof(int);
+ d->priorities = (void *)data;data += d->maxedicts * sizeof(qbyte);
+ d->updateframenum = (void *)data;data += d->maxedicts * sizeof(int);
+ d->states = (void *)data;data += d->maxedicts * sizeof(entity_state_t);
+ d->visiblebits = (void *)data;data += (d->maxedicts+7)/8 * sizeof(qbyte);
+ if (oldmaxedicts)
+ {
+ memcpy(d->deltabits, olddeltabits, d->maxedicts * sizeof(int));
+ memcpy(d->priorities, oldpriorities, d->maxedicts * sizeof(qbyte));
+ memcpy(d->updateframenum, oldupdateframenum, d->maxedicts * sizeof(int));
+ memcpy(d->states, oldstates, d->maxedicts * sizeof(entity_state_t));
+ memcpy(d->visiblebits, oldvisiblebits, (d->maxedicts+7)/8 * sizeof(qbyte));
+ // the previous buffers were a single allocation, so just one free
+ Mem_Free(d->deltabits);
+ }
+ }
+}
int EntityState5_Priority(entityframe5_database_t *d, entity_state_t *view, entity_state_t *s, int changedbits, int age)
{
qbyte data[128];
entityframe5_packetlog_t *packetlog;
+ if (sv.num_edicts > d->maxedicts)
+ EntityFrame5_ExpandEdicts(d, sv_mempool, (sv.num_edicts + 255) & ~255);
+
framenum = d->latestframenum + 1;
// if packet log is full, mark all frames as lost, this will cause
// byte = bound(0, s->scale * 16, 255)
#define E5_SCALE (1<<10)
// flag
-#define E5_ORIGIN32 (1<<11)
+#define E5_ORIGIN32 (1<<11)
// flag
#define E5_ANGLES16 (1<<12)
// flag
// logs of all recently sent messages (between acked and latest)
entityframe5_packetlog_t packetlog[ENTITYFRAME5_MAXPACKETLOGS];
+ // this goes up as needed and causes all the arrays to be reallocated
+ int maxedicts;
+
// which properties of each entity have changed since last send
- int deltabits[MAX_EDICTS];
+ int *deltabits; // [maxedicts]
// priorities of entities (updated whenever deltabits change)
// (derived from deltabits)
- qbyte priorities[MAX_EDICTS];
+ qbyte *priorities; // [maxedicts]
// last frame this entity was sent on, for prioritzation
- int updateframenum[MAX_EDICTS];
+ int *updateframenum; // [maxedicts]
// database of current status of all entities
- // (FIXME: this is 2.5mb per client even if most is unused!)
- entity_state_t states[MAX_EDICTS];
+ entity_state_t *states; // [maxedicts]
// which entities are currently active
// (duplicate of the active bit of every state in states[])
// (derived from states)
- qbyte visiblebits[(MAX_EDICTS+7)/8];
+ qbyte *visiblebits; // [(maxedicts+7)/8]
// delta compression of stats
qbyte statsdeltabits[(MAX_CL_STATS+7)/8];
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-// AK new vm
+// AK new vm
#include "quakedef.h"
#include "progsvm.h"
// reserve space for the null entity aka world
// check bound of max_edicts
prog->max_edicts = bound(1, prog->max_edicts, prog->limit_edicts);
- prog->num_edicts = bound(1, prog->num_edicts, prog->max_edicts);
+ prog->num_edicts = bound(1, prog->num_edicts, prog->max_edicts);
// edictprivate_size has to be min as big prvm_edict_private_t
- prog->edictprivate_size = max(prog->edictprivate_size,(int)sizeof(prvm_edict_private_t));
+ prog->edictprivate_size = max(prog->edictprivate_size,(int)sizeof(prvm_edict_private_t));
// alloc edicts
- prog->edicts = Mem_Alloc(prog->edicts_mempool,prog->limit_edicts * sizeof(prvm_edict_t));
-
+ prog->edicts = Mem_Alloc(prog->progs_mempool,prog->limit_edicts * sizeof(prvm_edict_t));
+
// alloc edict private space
- prog->edictprivate = Mem_Alloc(prog->edicts_mempool, prog->max_edicts * prog->edictprivate_size);
-
+ prog->edictprivate = Mem_Alloc(prog->progs_mempool, prog->max_edicts * prog->edictprivate_size);
+
// alloc edict fields
- prog->edictsfields = Mem_Alloc(prog->edicts_mempool, prog->max_edicts * prog->edict_size);
+ prog->edictsfields = Mem_Alloc(prog->progs_mempool, prog->max_edicts * prog->edict_size);
// set edict pointers
for(i = 0; i < prog->max_edicts; i++)
void PRVM_MEM_IncreaseEdicts()
{
int i;
- int oldmaxedicts = prog->max_edicts;
+ int oldmaxedicts = prog->max_edicts;
void *oldedictsfields = prog->edictsfields;
void *oldedictprivate = prog->edictprivate;
-
+
if(prog->max_edicts >= prog->limit_edicts)
return;
-
+
PRVM_GCALL(begin_increase_edicts)();
// increase edicts
prog->max_edicts = min(prog->max_edicts + 256, prog->limit_edicts);
- prog->edictsfields = Mem_Alloc(prog->edicts_mempool, prog->max_edicts * prog->edict_size);
- prog->edictprivate = Mem_Alloc(prog->edicts_mempool, prog->max_edicts * prog->edictprivate_size);
+ prog->edictsfields = Mem_Alloc(prog->progs_mempool, prog->max_edicts * prog->edict_size);
+ prog->edictprivate = Mem_Alloc(prog->progs_mempool, prog->max_edicts * prog->edictprivate_size);
memcpy(prog->edictsfields, oldedictsfields, oldmaxedicts * prog->edict_size);
memcpy(prog->edictprivate, oldedictprivate, oldmaxedicts * prog->edictprivate_size);
void PRVM_SetProg(int prognr)
{
if(prognr && prognr < PRVM_MAXPROGS)
- {
+ {
if(prog_list[prognr].loaded)
prog = &prog_list[prognr];
else
num = PRVM_NUM_FOR_EDICT(e) - 1;
// AK: Let the init_edict function determine if something needs to be initialized
- PRVM_GCALL(init_edict)(num);
+ PRVM_GCALL(init_edict)(num);
}
/*
char *s;
ddef_t *def;
mfunction_t *f;
-
+
type &= ~DEF_SAVEGLOBAL;
-
+
switch (type)
{
case ev_string:
dpsnprintf (line, sizeof (line), "bad type %i", type);
break;
}
-
+
return line;
}
Con_Print("prvm_edicts <program name>\n");
return;
}
-
+
PRVM_Begin;
if(!PRVM_SetProgFromString(Cmd_Argv(1)))
return;
continue;
active++;
}
-
+
Con_Printf("num_edicts:%3i\n", prog->num_edicts);
Con_Printf("active :%3i\n", active);
}
int i,l;
l = strlen(string) + 1;
- new = Mem_Alloc(prog->edictstring_mempool, l);
+ new = Mem_Alloc(prog->progs_mempool, l);
new_p = new;
for (i=0 ; i< l ; i++)
PRVM_ERROR ("PRVM_ED_LoadFromFile: %s: found %s when expecting {", PRVM_NAME, com_token);
// CHANGED: this is not conform to ED_LoadFromFile
- if(!prog->num_edicts)
+ if(!prog->num_edicts)
ent = PRVM_EDICT_NUM(0);
- else
+ else
ent = PRVM_ED_Alloc();
// clear it
PRVM_ED_Free (ent);
continue;
}
-
+
// look for the spawn function
func = PRVM_ED_FindFunction (PRVM_GetString(handle));
-
+
if (!func)
{
if (developer.integer) // don't confuse non-developers with errors
PRVM_ED_Free (ent);
continue;
}
-
+
// self = ent
PRVM_G_INT(prog->self->ofs) = PRVM_EDICT_TO_PROG(ent);
PRVM_ExecuteProgram (func - prog->functions, "");
}
-
+
spawned++;
if (ent->p.e->free)
died++;
}
Con_DPrintf("%s: %i new entities parsed, %i new inhibited, %i (%i new) spawned (whereas %i removed self, %i stayed)\n", PRVM_NAME, parsed, inhibited, prog->num_edicts, spawned, died, spawned - died);
-}
+}
// not used
/*
void PRVM_ResetProg()
{
- /*mempool_t *t1, *t2, *t3;
+ /*mempool_t *t1;
t1 = prog->progs_mempool;
- t2 = prog->edictstring_mempool;
- t3 = prog->edicts_mempool;
-
- Mem_EmptyPool(prog->progs_mempool);
- Mem_EmptyPool(prog->edictstring_mempool);
- Mem_EmptyPool(prog->edicts_mempool);*/
+
+ Mem_EmptyPool(prog->progs_mempool);*/
Mem_FreePool(&prog->progs_mempool);
- Mem_FreePool(&prog->edictstring_mempool);
- Mem_FreePool(&prog->edicts_mempool);
-
+
memset(prog,0,sizeof(prvm_prog_t));
-
+
/*prog->time = &prog->_time;
-
- prog->progs_mempool = t1;
- prog->edictstring_mempool = t2;
- prog->edicts_mempool = t3;*/
+
+ prog->progs_mempool = t1;*/
PRVM_GCALL(reset_cmd)();
}
dfunction_t *dfunctions;
Mem_EmptyPool(prog->progs_mempool);
- Mem_EmptyPool(prog->edictstring_mempool);
prog->progs = (dprograms_t *)FS_LoadFile (filename, prog->progs_mempool, false);
if (prog->progs == NULL)
PRVM_Init_Exec();
prog->loaded = TRUE;
-
+
// set flags & ddef_ts in prog
-
+
prog->flag = 0;
-
+
prog->self = PRVM_ED_FindGlobal("self");
if( PRVM_ED_FindGlobal("time") && PRVM_ED_FindGlobal("time")->type & ev_float )
prog->flag |= PRVM_FE_CHAIN;
if(PRVM_ED_FindField ("classname"))
- prog->flag |= PRVM_FE_CLASSNAME;
+ prog->flag |= PRVM_FE_CLASSNAME;
- if(PRVM_ED_FindField ("nextthink") && PRVM_ED_FindField ("frame") && PRVM_ED_FindField ("think")
- && prog->flag && prog->self)
+ if(PRVM_ED_FindField ("nextthink") && PRVM_ED_FindField ("frame") && PRVM_ED_FindField ("think")
+ && prog->flag && prog->self)
prog->flag |= PRVM_OP_STATE;
-
+
PRVM_GCALL(reset_cmd)();
PRVM_GCALL(init_cmd)();
if( !global )
Con_Printf( "No global '%s' in %s!\n", Cmd_Argv(2), Cmd_Argv(1) );
else
- Con_Printf( "%s: %s\n", Cmd_Argv(2), PRVM_ValueString( global->type, (prvm_eval_t *) &prog->globals[ global->ofs ] ) );
+ Con_Printf( "%s: %s\n", Cmd_Argv(2), PRVM_ValueString( global->type, (prvm_eval_t *) &prog->globals[ global->ofs ] ) );
PRVM_End;
}
global = PRVM_ED_FindGlobal( Cmd_Argv(2) );
if( !global )
Con_Printf( "No global '%s' in %s!\n", Cmd_Argv(2), Cmd_Argv(1) );
- else
+ else
PRVM_ED_ParseEpair( NULL, global, Cmd_Argv(3) );
PRVM_End;
}
{
bufmaxchars = bufchars + strlen(line) + 2048;
oldbuf = buf;
- buf = Mem_Alloc(r_shadow_mempool, bufmaxchars);
+ buf = Mem_Alloc(tempmempool, bufmaxchars);
if (oldbuf)
{
if (bufchars)
extern cvar_t sv_gameplayfix_swiminbmodels;
extern cvar_t sv_gameplayfix_setmodelrealbox;
-extern mempool_t *sv_clients_mempool;
-extern mempool_t *sv_edicts_mempool;
+extern mempool_t *sv_mempool;
// persistant server info
extern server_static_t svs;
server_t sv;
server_static_t svs;
-mempool_t *sv_edicts_mempool = NULL;
+mempool_t *sv_mempool = NULL;
//============================================================================
SV_Phys_Init();
SV_World_Init();
- sv_edicts_mempool = Mem_AllocPool("server edicts", 0, NULL);
+ sv_mempool = Mem_AllocPool("server", 0, NULL);
}
static void SV_SaveEntFile_f(void)
EntityFrame5_FreeDatabase(client->entitydatabase5);
if (sv.protocol == PROTOCOL_DARKPLACES1 || sv.protocol == PROTOCOL_DARKPLACES2 || sv.protocol == PROTOCOL_DARKPLACES3)
- client->entitydatabase = EntityFrame_AllocDatabase(sv_clients_mempool);
+ client->entitydatabase = EntityFrame_AllocDatabase(sv_mempool);
if (sv.protocol == PROTOCOL_DARKPLACES4)
- client->entitydatabase4 = EntityFrame4_AllocDatabase(sv_clients_mempool);
+ client->entitydatabase4 = EntityFrame4_AllocDatabase(sv_mempool);
if (sv.protocol == PROTOCOL_DARKPLACES5 || sv.protocol == PROTOCOL_DARKPLACES6)
- client->entitydatabase5 = EntityFrame5_AllocDatabase(sv_clients_mempool);
+ client->entitydatabase5 = EntityFrame5_AllocDatabase(sv_mempool);
MSG_WriteByte (&client->message, svc_print);
dpsnprintf (message, sizeof (message), "\002\nServer: %s build %s (progs %i crc)", gamename, buildstring, pr_crc);
sententities[s->number] = sententitiesmark;
}
-entity_state_t sendstates[MAX_EDICTS];
+entity_state_t sendstates[MAX_EDICTS];
void SV_WriteEntitiesToClient(client_t *client, edict_t *clent, sizebuf_t *msg, int *stats)
{
SV_ClearWorld();
sv.max_edicts = min(sv.max_edicts + 256, MAX_EDICTS);
- sv.edictsengineprivate = Mem_Alloc(sv_edicts_mempool, sv.max_edicts * sizeof(edict_engineprivate_t));
- sv.edictsfields = Mem_Alloc(sv_edicts_mempool, sv.max_edicts * pr_edict_size);
- sv.moved_edicts = Mem_Alloc(sv_edicts_mempool, sv.max_edicts * sizeof(edict_t *));
+ sv.edictsengineprivate = PR_Alloc(sv.max_edicts * sizeof(edict_engineprivate_t));
+ sv.edictsfields = PR_Alloc(sv.max_edicts * pr_edict_size);
+ sv.moved_edicts = PR_Alloc(sv.max_edicts * sizeof(edict_t *));
memcpy(sv.edictsengineprivate, oldedictsengineprivate, oldmax_edicts * sizeof(edict_engineprivate_t));
memcpy(sv.edictsfields, oldedictsfields, oldmax_edicts * pr_edict_size);
SV_LinkEdict(ent, false);
}
- Mem_Free(oldedictsengineprivate);
- Mem_Free(oldedictsfields);
- Mem_Free(oldmoved_edicts);
+ PR_Free(oldedictsengineprivate);
+ PR_Free(oldedictsfields);
+ PR_Free(oldmoved_edicts);
}
/*
sv.max_edicts = max(svs.maxclients + 1, 512);
sv.max_edicts = min(sv.max_edicts, MAX_EDICTS);
- // clear the edict memory pool
- Mem_EmptyPool(sv_edicts_mempool);
// edict_t structures (hidden from progs)
- sv.edicts = Mem_Alloc(sv_edicts_mempool, MAX_EDICTS * sizeof(edict_t));
+ sv.edicts = PR_Alloc(MAX_EDICTS * sizeof(edict_t));
// engine private structures (hidden from progs)
- sv.edictsengineprivate = Mem_Alloc(sv_edicts_mempool, sv.max_edicts * sizeof(edict_engineprivate_t));
+ sv.edictsengineprivate = PR_Alloc(sv.max_edicts * sizeof(edict_engineprivate_t));
// progs fields, often accessed by server
- sv.edictsfields = Mem_Alloc(sv_edicts_mempool, sv.max_edicts * pr_edict_size);
+ sv.edictsfields = PR_Alloc(sv.max_edicts * pr_edict_size);
// used by PushMove to move back pushed entities
- sv.moved_edicts = Mem_Alloc(sv_edicts_mempool, sv.max_edicts * sizeof(edict_t *));
+ sv.moved_edicts = PR_Alloc(sv.max_edicts * sizeof(edict_t *));
for (i = 0;i < sv.max_edicts;i++)
{
ent = sv.edicts + i;
#include "quakedef.h"
-// here is the real ui drawing engine
+// here is the real ui drawing engine
/*
#define FRAME_THICKNESS 2
DrawQ_Fill(x + w, y, FRAME_THICKNESS, h, FRAME_COLOR1);
// area
DrawQ_Fill(x, y, w, h, FRAME_COLOR2);
-}
+}
static void UIG_DrawText(const char *text, float x, float y, float w, float h, float r, float g, float b, float a, float f)
{
if(w != 0 && h != 0)
DrawQ_SetClipArea(x, y, w, h);
DrawQ_String(x, y, text, 0, TEXT_FONTSIZE_X, TEXT_FONTSIZE_Y, r, g, b, a, f);
- if(w != 0 && h != 0)
+ if(w != 0 && h != 0)
DrawQ_ResetClipArea();
}
}
*/
-static mempool_t *ui_mem;
-
//#define UI_MEM_SIZE (1 << 10) << 9 // 512 KByte
#define UI_MEM_SIZE 1
void UI_Init(void)
{
- ui_mem = Mem_AllocPool("Intern UI Memory", 0, NULL);
}
-#define UI_Alloc(size) Mem_Alloc(ui_mem, size)
+#define UI_Alloc(size) Mem_Alloc(cl_mempool, size)
#define UI_Free(ptr) Mem_Free(ptr)
void UI_Event(ui_itemlist_t list, ui_message_t *in)
for(item = list->list; item != 0 && !processed; item = item->next)
{
unsigned int i;
-
+
processed = item->eventhandler(list, item, in, &out);
-
+
// process posted messages
for(i = 0; i < out.used; i++)
list->eventhandler(list, &out.queue[i]);
}
if(!processed)
- list->eventhandler(list, in);
+ list->eventhandler(list, in);
}
void UI_Draw(ui_itemlist_t list)
{
unsigned int depth = 0, nextdepth = ~0;
- while(depth != nextdepth)
+ while(depth != nextdepth)
{
for(item = list->list; item != 0; item = item->next)
{
static int wad_numlumps = 0;
static lumpinfo_t *wad_lumps = NULL;
static qbyte *wad_base = NULL;
- static mempool_t *wad_mempool = NULL;
W_CleanupName (name, clean);
Con_Print("gfx.wad doesn't have WAD2 id\n");
else
{
- wad_mempool = Mem_AllocPool("gfx.wad", 0, NULL);
- wad_base = Mem_Alloc(wad_mempool, fs_filesize);
+ wad_base = Mem_Alloc(cl_mempool, fs_filesize);
memcpy(wad_base, temp, fs_filesize);
Mem_Free(temp);