add safe_calloc(), safe_calloc_info() functions, use them (optimization, code shortening)
This commit is contained in:
parent
23a166a4dd
commit
99bae99b36
|
|
@ -96,9 +96,7 @@ void SetLightBytes( int n ){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lightBytes = safe_malloc_info( numLightBytes, "SetLightBytes" );
|
lightBytes = safe_calloc_info( numLightBytes, "SetLightBytes" );
|
||||||
|
|
||||||
memset( lightBytes, 0, numLightBytes );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetGridPoints( int n ){
|
void SetGridPoints( int n ){
|
||||||
|
|
@ -112,9 +110,7 @@ void SetGridPoints( int n ){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gridData = safe_malloc_info( numGridPoints * 8, "SetGridPoints" );
|
gridData = safe_calloc_info( numGridPoints * 8, "SetGridPoints" );
|
||||||
|
|
||||||
memset( gridData, 0, numGridPoints * 8 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IncDrawVerts(){
|
void IncDrawVerts(){
|
||||||
|
|
@ -149,12 +145,10 @@ void SetDrawVerts( int n ){
|
||||||
free( drawVerts );
|
free( drawVerts );
|
||||||
}
|
}
|
||||||
|
|
||||||
numDrawVerts = n;
|
numDrawVerts =
|
||||||
numDrawVertsBuffer = numDrawVerts;
|
numDrawVertsBuffer = n;
|
||||||
|
|
||||||
drawVerts = safe_malloc_info( sizeof( drawVert_t ) * numDrawVertsBuffer, "IncDrawVerts" );
|
drawVerts = safe_calloc_info( sizeof( drawVert_t ) * numDrawVertsBuffer, "IncDrawVerts" );
|
||||||
|
|
||||||
memset( drawVerts, 0, n * sizeof( drawVert_t ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetDrawSurfacesBuffer(){
|
void SetDrawSurfacesBuffer(){
|
||||||
|
|
@ -164,9 +158,7 @@ void SetDrawSurfacesBuffer(){
|
||||||
|
|
||||||
numDrawSurfacesBuffer = MAX_MAP_DRAW_SURFS;
|
numDrawSurfacesBuffer = MAX_MAP_DRAW_SURFS;
|
||||||
|
|
||||||
drawSurfaces = safe_malloc_info( sizeof( dsurface_t ) * numDrawSurfacesBuffer, "IncDrawSurfaces" );
|
drawSurfaces = safe_calloc_info( sizeof( dsurface_t ) * numDrawSurfacesBuffer, "IncDrawSurfaces" );
|
||||||
|
|
||||||
memset( drawSurfaces, 0, MAX_MAP_DRAW_SURFS * sizeof( drawVert_t ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetDrawSurfaces( int n ){
|
void SetDrawSurfaces( int n ){
|
||||||
|
|
@ -174,12 +166,10 @@ void SetDrawSurfaces( int n ){
|
||||||
free( drawSurfaces );
|
free( drawSurfaces );
|
||||||
}
|
}
|
||||||
|
|
||||||
numDrawSurfaces = n;
|
numDrawSurfaces =
|
||||||
numDrawSurfacesBuffer = numDrawSurfaces;
|
numDrawSurfacesBuffer = n;
|
||||||
|
|
||||||
drawSurfaces = safe_malloc_info( sizeof( dsurface_t ) * numDrawSurfacesBuffer, "IncDrawSurfaces" );
|
drawSurfaces = safe_calloc_info( sizeof( dsurface_t ) * numDrawSurfacesBuffer, "IncDrawSurfaces" );
|
||||||
|
|
||||||
memset( drawSurfaces, 0, n * sizeof( drawVert_t ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BspFilesCleanup(){
|
void BspFilesCleanup(){
|
||||||
|
|
@ -522,10 +512,7 @@ void StripTrailing( char *e ) {
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
epair_t *ParseEpair( void ) {
|
epair_t *ParseEpair( void ) {
|
||||||
epair_t *e;
|
epair_t *e = safe_calloc( sizeof( epair_t ) );
|
||||||
|
|
||||||
e = safe_malloc( sizeof( epair_t ) );
|
|
||||||
memset( e, 0, sizeof( epair_t ) );
|
|
||||||
|
|
||||||
if ( strlen( token ) >= MAX_KEY - 1 ) {
|
if ( strlen( token ) >= MAX_KEY - 1 ) {
|
||||||
Error( "ParseEpar: token too long" );
|
Error( "ParseEpar: token too long" );
|
||||||
|
|
|
||||||
|
|
@ -52,24 +52,34 @@
|
||||||
|
|
||||||
#ifdef SAFE_MALLOC
|
#ifdef SAFE_MALLOC
|
||||||
void *safe_malloc( size_t size ){
|
void *safe_malloc( size_t size ){
|
||||||
void *p;
|
void *p = malloc( size );
|
||||||
|
|
||||||
p = malloc( size );
|
|
||||||
if ( !p ) {
|
if ( !p ) {
|
||||||
Error( "safe_malloc failed on allocation of %i bytes", size );
|
Error( "safe_malloc failed on allocation of %i bytes", size );
|
||||||
}
|
}
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *safe_malloc_info( size_t size, char* info ){
|
void *safe_malloc_info( size_t size, const char* info ){
|
||||||
void *p;
|
void *p = malloc( size );
|
||||||
|
|
||||||
p = malloc( size );
|
|
||||||
if ( !p ) {
|
if ( !p ) {
|
||||||
Error( "%s: safe_malloc failed on allocation of %i bytes", info, size );
|
Error( "%s: safe_malloc failed on allocation of %i bytes", info, size );
|
||||||
}
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *safe_calloc( size_t size ){
|
||||||
|
void *p = calloc( 1, size );
|
||||||
|
if ( !p ) {
|
||||||
|
Error( "safe_calloc failed on allocation of %i bytes", size );
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *safe_calloc_info( size_t size, const char* info ){
|
||||||
|
void *p = calloc( 1, size );
|
||||||
|
if ( !p ) {
|
||||||
|
Error( "%s: safe_calloc failed on allocation of %i bytes", info, size );
|
||||||
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -619,8 +629,7 @@ int LoadFileBlock( const char *filename, void **bufferptr ){
|
||||||
if ( nBlock > 0 ) {
|
if ( nBlock > 0 ) {
|
||||||
nAllocSize += MEM_BLOCKSIZE - nBlock;
|
nAllocSize += MEM_BLOCKSIZE - nBlock;
|
||||||
}
|
}
|
||||||
buffer = safe_malloc( nAllocSize + 1 );
|
buffer = safe_calloc( nAllocSize + 1 );
|
||||||
memset( buffer, 0, nAllocSize + 1 );
|
|
||||||
SafeRead( f, buffer, length );
|
SafeRead( f, buffer, length );
|
||||||
fclose( f );
|
fclose( f );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,9 +66,14 @@
|
||||||
#define SAFE_MALLOC
|
#define SAFE_MALLOC
|
||||||
#ifdef SAFE_MALLOC
|
#ifdef SAFE_MALLOC
|
||||||
void *safe_malloc( size_t size );
|
void *safe_malloc( size_t size );
|
||||||
void *safe_malloc_info( size_t size, char* info );
|
void *safe_malloc_info( size_t size, const char* info );
|
||||||
|
void *safe_calloc( size_t size );
|
||||||
|
void *safe_calloc_info( size_t size, const char* info );
|
||||||
#else
|
#else
|
||||||
#define safe_malloc( a ) malloc( a )
|
#define safe_malloc( size ) malloc( size )
|
||||||
|
#define safe_malloc_info( size, info ) malloc( size )
|
||||||
|
#define safe_calloc( size ) calloc( 1, size )
|
||||||
|
#define safe_calloc_info( size, info ) calloc( 1, size )
|
||||||
#endif /* SAFE_MALLOC */
|
#endif /* SAFE_MALLOC */
|
||||||
|
|
||||||
// set these before calling CheckParm
|
// set these before calling CheckParm
|
||||||
|
|
|
||||||
|
|
@ -255,8 +255,7 @@ void LoadLBM( const char *filename, byte **picture, byte **palette ){
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMAPID:
|
case CMAPID:
|
||||||
cmapbuffer = safe_malloc( 768 );
|
cmapbuffer = safe_calloc( 768 );
|
||||||
memset( cmapbuffer, 0, 768 );
|
|
||||||
memcpy( cmapbuffer, LBM_P, chunklength );
|
memcpy( cmapbuffer, LBM_P, chunklength );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -358,8 +358,7 @@ int LoadJPGBuff( void *src_buffer, int src_size, unsigned char **pic, int *width
|
||||||
size = cinfo.output_width * cinfo.output_height * 4;
|
size = cinfo.output_width * cinfo.output_height * 4;
|
||||||
*width = cinfo.output_width;
|
*width = cinfo.output_width;
|
||||||
*height = cinfo.output_height;
|
*height = cinfo.output_height;
|
||||||
*pic = (unsigned char*)( malloc( size + 1 ) );
|
*pic = calloc( 1, size + 1 );
|
||||||
memset( *pic, 0, size + 1 );
|
|
||||||
|
|
||||||
buffer = ( *cinfo.mem->alloc_sarray )( ( j_common_ptr ) & cinfo, JPOOL_IMAGE, row_stride, 1 );
|
buffer = ( *cinfo.mem->alloc_sarray )( ( j_common_ptr ) & cinfo, JPOOL_IMAGE, row_stride, 1 );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ void mdfour_begin( struct mdfour *md ){
|
||||||
|
|
||||||
|
|
||||||
static void mdfour_tail( unsigned char *in, int n ){
|
static void mdfour_tail( unsigned char *in, int n ){
|
||||||
unsigned char buf[128];
|
unsigned char buf[128] = {0};
|
||||||
uint32 M[16];
|
uint32 M[16];
|
||||||
uint32 b;
|
uint32 b;
|
||||||
|
|
||||||
|
|
@ -136,7 +136,6 @@ static void mdfour_tail( unsigned char *in, int n ){
|
||||||
|
|
||||||
b = m->totalN * 8;
|
b = m->totalN * 8;
|
||||||
|
|
||||||
memset( buf, 0, 128 );
|
|
||||||
if ( n ) {
|
if ( n ) {
|
||||||
memcpy( buf, in, n );
|
memcpy( buf, in, n );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,9 +53,6 @@ void pw( winding_t *w ){
|
||||||
=============
|
=============
|
||||||
*/
|
*/
|
||||||
winding_t *AllocWinding( int points ){
|
winding_t *AllocWinding( int points ){
|
||||||
winding_t *w;
|
|
||||||
int s;
|
|
||||||
|
|
||||||
if ( points >= MAX_POINTS_ON_WINDING ) {
|
if ( points >= MAX_POINTS_ON_WINDING ) {
|
||||||
Error( "AllocWinding failed: MAX_POINTS_ON_WINDING exceeded" );
|
Error( "AllocWinding failed: MAX_POINTS_ON_WINDING exceeded" );
|
||||||
}
|
}
|
||||||
|
|
@ -68,10 +65,7 @@ winding_t *AllocWinding( int points ){
|
||||||
c_peak_windings = c_active_windings;
|
c_peak_windings = c_active_windings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s = sizeof( *w ) + points * sizeof( *w->p );
|
return safe_calloc( offsetof( winding_t, p[points] ) );
|
||||||
w = safe_malloc( s );
|
|
||||||
memset( w, 0, s );
|
|
||||||
return w;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -80,9 +74,6 @@ winding_t *AllocWinding( int points ){
|
||||||
=============
|
=============
|
||||||
*/
|
*/
|
||||||
winding_accu_t *AllocWindingAccu( int points ){
|
winding_accu_t *AllocWindingAccu( int points ){
|
||||||
winding_accu_t *w;
|
|
||||||
int s;
|
|
||||||
|
|
||||||
if ( points >= MAX_POINTS_ON_WINDING ) {
|
if ( points >= MAX_POINTS_ON_WINDING ) {
|
||||||
Error( "AllocWindingAccu failed: MAX_POINTS_ON_WINDING exceeded" );
|
Error( "AllocWindingAccu failed: MAX_POINTS_ON_WINDING exceeded" );
|
||||||
}
|
}
|
||||||
|
|
@ -96,10 +87,7 @@ winding_accu_t *AllocWindingAccu( int points ){
|
||||||
c_peak_windings = c_active_windings;
|
c_peak_windings = c_active_windings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s = sizeof( *w ) + points * sizeof( *w->p );
|
return safe_calloc( offsetof( winding_accu_t, p[points] ) );
|
||||||
w = safe_malloc( s );
|
|
||||||
memset( w, 0, s );
|
|
||||||
return w;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -40,10 +40,7 @@ typedef struct StrList_s
|
||||||
StrList;
|
StrList;
|
||||||
|
|
||||||
static inline StrList* StrList_allocate( size_t strNum ){
|
static inline StrList* StrList_allocate( size_t strNum ){
|
||||||
StrList* ret;
|
StrList* ret = safe_calloc( offsetof( StrList, s[strNum] ) );
|
||||||
const size_t size = sizeof( StrList ) + sizeof( ret->s[0] ) * strNum;
|
|
||||||
ret = safe_malloc( size );
|
|
||||||
memset( ret, 0, size );
|
|
||||||
memcpy( ret,
|
memcpy( ret,
|
||||||
&( StrList const ){ .n = 0, .max = strNum },
|
&( StrList const ){ .n = 0, .max = strNum },
|
||||||
sizeof( StrList ) );
|
sizeof( StrList ) );
|
||||||
|
|
@ -198,10 +195,7 @@ typedef struct
|
||||||
StrBuf;
|
StrBuf;
|
||||||
|
|
||||||
static inline StrBuf* StrBuf_allocate( size_t strLen ){
|
static inline StrBuf* StrBuf_allocate( size_t strLen ){
|
||||||
StrBuf* ret;
|
StrBuf* ret = safe_calloc( offsetof( StrBuf, s[strLen] ) );
|
||||||
const size_t size = sizeof( StrBuf ) + sizeof( ret->s[0] ) * strLen;
|
|
||||||
ret = safe_malloc( size );
|
|
||||||
memset( ret, 0, size );
|
|
||||||
memcpy( ret,
|
memcpy( ret,
|
||||||
&( StrBuf const ){ .strlen = 0, .max = strLen },
|
&( StrBuf const ){ .strlen = 0, .max = strLen },
|
||||||
sizeof( StrBuf ) );
|
sizeof( StrBuf ) );
|
||||||
|
|
|
||||||
|
|
@ -90,18 +90,10 @@ int CountBrushList( brush_t *brushes ){
|
||||||
*/
|
*/
|
||||||
|
|
||||||
brush_t *AllocBrush( int numSides ){
|
brush_t *AllocBrush( int numSides ){
|
||||||
brush_t *bb;
|
|
||||||
size_t c;
|
|
||||||
|
|
||||||
c = sizeof( *bb ) + sizeof( *bb->sides ) * numSides;
|
|
||||||
bb = safe_malloc( c );
|
|
||||||
memset( bb, 0, c );
|
|
||||||
if ( numthreads == 1 ) {
|
if ( numthreads == 1 ) {
|
||||||
numActiveBrushes++;
|
numActiveBrushes++;
|
||||||
}
|
}
|
||||||
|
return safe_calloc( offsetof( brush_t, sides[numSides] ) );
|
||||||
/* return it */
|
|
||||||
return bb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -128,7 +120,7 @@ void FreeBrush( brush_t *b ){
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ydnar: overwrite it */
|
/* ydnar: overwrite it */
|
||||||
memset( b, 0xFE, offsetof( brush_t, sides ) + sizeof( *b->sides ) * b->numsides );
|
memset( b, 0xFE, offsetof( brush_t, sides[b->numsides] ) );
|
||||||
*( (unsigned int*) b ) = 0xFEFEFEFE;
|
*( (unsigned int*) b ) = 0xFEFEFEFE;
|
||||||
|
|
||||||
/* free it */
|
/* free it */
|
||||||
|
|
@ -819,12 +811,8 @@ void FilterStructuralBrushesIntoTree( entity_t *e, tree_t *tree ) {
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
tree_t *AllocTree( void ){
|
tree_t *AllocTree( void ){
|
||||||
tree_t *tree;
|
tree_t *tree = safe_calloc( sizeof( *tree ) );
|
||||||
|
|
||||||
tree = safe_malloc( sizeof( *tree ) );
|
|
||||||
memset( tree, 0, sizeof( *tree ) );
|
|
||||||
ClearBounds( tree->mins, tree->maxs );
|
ClearBounds( tree->mins, tree->maxs );
|
||||||
|
|
||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -834,12 +822,7 @@ tree_t *AllocTree( void ){
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
node_t *AllocNode( void ){
|
node_t *AllocNode( void ){
|
||||||
node_t *node;
|
return safe_calloc( sizeof( node_t ) );
|
||||||
|
|
||||||
node = safe_malloc( sizeof( *node ) );
|
|
||||||
memset( node, 0, sizeof( *node ) );
|
|
||||||
|
|
||||||
return node;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -777,8 +777,7 @@ int BSPMain( int argc, char **argv ){
|
||||||
|
|
||||||
doingBSP = qtrue;
|
doingBSP = qtrue;
|
||||||
SetDrawSurfacesBuffer();
|
SetDrawSurfacesBuffer();
|
||||||
mapDrawSurfs = safe_malloc( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
|
mapDrawSurfs = safe_calloc( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
|
||||||
memset( mapDrawSurfs, 0, sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
|
|
||||||
numMapDrawSurfs = 0;
|
numMapDrawSurfs = 0;
|
||||||
|
|
||||||
tempSource[ 0 ] = '\0';
|
tempSource[ 0 ] = '\0';
|
||||||
|
|
|
||||||
|
|
@ -91,12 +91,10 @@ void SetDrawVerts( int n ){
|
||||||
free( bspDrawVerts );
|
free( bspDrawVerts );
|
||||||
}
|
}
|
||||||
|
|
||||||
numBSPDrawVerts = n;
|
numBSPDrawVerts =
|
||||||
numBSPDrawVertsBuffer = numBSPDrawVerts;
|
numBSPDrawVertsBuffer = n;
|
||||||
|
|
||||||
bspDrawVerts = safe_malloc_info( sizeof( bspDrawVert_t ) * numBSPDrawVertsBuffer, "IncDrawVerts" );
|
bspDrawVerts = safe_calloc_info( sizeof( bspDrawVert_t ) * numBSPDrawVertsBuffer, "IncDrawVerts" );
|
||||||
|
|
||||||
memset( bspDrawVerts, 0, n * sizeof( bspDrawVert_t ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int numBSPDrawSurfacesBuffer = 0;
|
int numBSPDrawSurfacesBuffer = 0;
|
||||||
|
|
@ -107,9 +105,7 @@ void SetDrawSurfacesBuffer(){
|
||||||
|
|
||||||
numBSPDrawSurfacesBuffer = MAX_MAP_DRAW_SURFS;
|
numBSPDrawSurfacesBuffer = MAX_MAP_DRAW_SURFS;
|
||||||
|
|
||||||
bspDrawSurfaces = safe_malloc_info( sizeof( bspDrawSurface_t ) * numBSPDrawSurfacesBuffer, "IncDrawSurfaces" );
|
bspDrawSurfaces = safe_calloc_info( sizeof( bspDrawSurface_t ) * numBSPDrawSurfacesBuffer, "IncDrawSurfaces" );
|
||||||
|
|
||||||
memset( bspDrawSurfaces, 0, MAX_MAP_DRAW_SURFS * sizeof( bspDrawSurface_t ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetDrawSurfaces( int n ){
|
void SetDrawSurfaces( int n ){
|
||||||
|
|
@ -117,12 +113,10 @@ void SetDrawSurfaces( int n ){
|
||||||
free( bspDrawSurfaces );
|
free( bspDrawSurfaces );
|
||||||
}
|
}
|
||||||
|
|
||||||
numBSPDrawSurfaces = n;
|
numBSPDrawSurfaces =
|
||||||
numBSPDrawSurfacesBuffer = numBSPDrawSurfaces;
|
numBSPDrawSurfacesBuffer = n;
|
||||||
|
|
||||||
bspDrawSurfaces = safe_malloc_info( sizeof( bspDrawSurface_t ) * numBSPDrawSurfacesBuffer, "IncDrawSurfaces" );
|
bspDrawSurfaces = safe_calloc_info( sizeof( bspDrawSurface_t ) * numBSPDrawSurfacesBuffer, "IncDrawSurfaces" );
|
||||||
|
|
||||||
memset( bspDrawSurfaces, 0, n * sizeof( bspDrawSurface_t ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BSPFilesCleanup(){
|
void BSPFilesCleanup(){
|
||||||
|
|
@ -538,12 +532,8 @@ void StripTrailing( char *e ){
|
||||||
*/
|
*/
|
||||||
|
|
||||||
epair_t *ParseEPair( void ){
|
epair_t *ParseEPair( void ){
|
||||||
epair_t *e;
|
|
||||||
|
|
||||||
|
|
||||||
/* allocate and clear new epair */
|
/* allocate and clear new epair */
|
||||||
e = safe_malloc( sizeof( epair_t ) );
|
epair_t *e = safe_calloc( sizeof( epair_t ) );
|
||||||
memset( e, 0, sizeof( epair_t ) );
|
|
||||||
|
|
||||||
/* handle key */
|
/* handle key */
|
||||||
if ( strlen( token ) >= ( MAX_KEY - 1 ) ) {
|
if ( strlen( token ) >= ( MAX_KEY - 1 ) ) {
|
||||||
|
|
|
||||||
|
|
@ -120,8 +120,7 @@ static void AddBrushSidesLump( FILE *file, ibspHeader_t *header ){
|
||||||
|
|
||||||
/* allocate output buffer */
|
/* allocate output buffer */
|
||||||
size = numBSPBrushSides * sizeof( *buffer );
|
size = numBSPBrushSides * sizeof( *buffer );
|
||||||
buffer = safe_malloc( size );
|
buffer = safe_calloc( size );
|
||||||
memset( buffer, 0, size );
|
|
||||||
|
|
||||||
/* convert */
|
/* convert */
|
||||||
in = bspBrushSides;
|
in = bspBrushSides;
|
||||||
|
|
@ -232,8 +231,7 @@ static void AddDrawSurfacesLump( FILE *file, ibspHeader_t *header ){
|
||||||
|
|
||||||
/* allocate output buffer */
|
/* allocate output buffer */
|
||||||
size = numBSPDrawSurfaces * sizeof( *buffer );
|
size = numBSPDrawSurfaces * sizeof( *buffer );
|
||||||
buffer = safe_malloc( size );
|
buffer = safe_calloc( size );
|
||||||
memset( buffer, 0, size );
|
|
||||||
|
|
||||||
/* convert */
|
/* convert */
|
||||||
in = bspDrawSurfaces;
|
in = bspDrawSurfaces;
|
||||||
|
|
@ -330,8 +328,7 @@ static void AddDrawVertsLump( FILE *file, ibspHeader_t *header ){
|
||||||
|
|
||||||
/* allocate output buffer */
|
/* allocate output buffer */
|
||||||
size = numBSPDrawVerts * sizeof( *buffer );
|
size = numBSPDrawVerts * sizeof( *buffer );
|
||||||
buffer = safe_malloc( size );
|
buffer = safe_calloc( size );
|
||||||
memset( buffer, 0, size );
|
|
||||||
|
|
||||||
/* convert */
|
/* convert */
|
||||||
in = bspDrawVerts;
|
in = bspDrawVerts;
|
||||||
|
|
@ -385,8 +382,7 @@ static void CopyLightGridLumps( ibspHeader_t *header ){
|
||||||
numBSPGridPoints = GetLumpElements( (bspHeader_t*) header, LUMP_LIGHTGRID, sizeof( *in ) );
|
numBSPGridPoints = GetLumpElements( (bspHeader_t*) header, LUMP_LIGHTGRID, sizeof( *in ) );
|
||||||
|
|
||||||
/* allocate buffer */
|
/* allocate buffer */
|
||||||
bspGridPoints = safe_malloc( numBSPGridPoints * sizeof( *bspGridPoints ) );
|
bspGridPoints = safe_calloc( numBSPGridPoints * sizeof( *bspGridPoints ) );
|
||||||
memset( bspGridPoints, 0, numBSPGridPoints * sizeof( *bspGridPoints ) );
|
|
||||||
|
|
||||||
/* copy */
|
/* copy */
|
||||||
in = GetLump( (bspHeader_t*) header, LUMP_LIGHTGRID );
|
in = GetLump( (bspHeader_t*) header, LUMP_LIGHTGRID );
|
||||||
|
|
|
||||||
|
|
@ -96,8 +96,7 @@ static void CopyLightGridLumps( rbspHeader_t *header ){
|
||||||
numBSPGridPoints = GetLumpElements( (bspHeader_t*) header, LUMP_LIGHTARRAY, sizeof( *inArray ) );
|
numBSPGridPoints = GetLumpElements( (bspHeader_t*) header, LUMP_LIGHTARRAY, sizeof( *inArray ) );
|
||||||
|
|
||||||
/* allocate buffer */
|
/* allocate buffer */
|
||||||
bspGridPoints = safe_malloc( numBSPGridPoints * sizeof( *bspGridPoints ) );
|
bspGridPoints = safe_calloc( numBSPGridPoints * sizeof( *bspGridPoints ) );
|
||||||
memset( bspGridPoints, 0, numBSPGridPoints * sizeof( *bspGridPoints ) );
|
|
||||||
|
|
||||||
/* copy */
|
/* copy */
|
||||||
inArray = GetLump( (bspHeader_t*) header, LUMP_LIGHTARRAY );
|
inArray = GetLump( (bspHeader_t*) header, LUMP_LIGHTARRAY );
|
||||||
|
|
|
||||||
|
|
@ -833,8 +833,7 @@ void PseudoCompileBSP( qboolean need_tree ){
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
SetDrawSurfacesBuffer();
|
SetDrawSurfacesBuffer();
|
||||||
mapDrawSurfs = safe_malloc( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
|
mapDrawSurfs = safe_calloc( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
|
||||||
memset( mapDrawSurfs, 0, sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
|
|
||||||
numMapDrawSurfs = 0;
|
numMapDrawSurfs = 0;
|
||||||
|
|
||||||
BeginBSPFile();
|
BeginBSPFile();
|
||||||
|
|
|
||||||
|
|
@ -620,8 +620,7 @@ static void ProjectDecalOntoWinding( decalProjector_t *dp, mapDrawSurface_t *ds,
|
||||||
ds2->lightmapScale = ds->lightmapScale;
|
ds2->lightmapScale = ds->lightmapScale;
|
||||||
ds2->shadeAngleDegrees = ds->shadeAngleDegrees;
|
ds2->shadeAngleDegrees = ds->shadeAngleDegrees;
|
||||||
ds2->numVerts = w->numpoints;
|
ds2->numVerts = w->numpoints;
|
||||||
ds2->verts = safe_malloc( ds2->numVerts * sizeof( *ds2->verts ) );
|
ds2->verts = safe_calloc( ds2->numVerts * sizeof( *ds2->verts ) );
|
||||||
memset( ds2->verts, 0, ds2->numVerts * sizeof( *ds2->verts ) );
|
|
||||||
|
|
||||||
/* set vertexes */
|
/* set vertexes */
|
||||||
for ( i = 0; i < ds2->numVerts; i++ )
|
for ( i = 0; i < ds2->numVerts; i++ )
|
||||||
|
|
|
||||||
|
|
@ -47,12 +47,7 @@ int c_faceLeafs;
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
face_t *AllocBspFace( void ) {
|
face_t *AllocBspFace( void ) {
|
||||||
face_t *f;
|
return safe_calloc( sizeof( face_t ) );
|
||||||
|
|
||||||
f = safe_malloc( sizeof( *f ) );
|
|
||||||
memset( f, 0, sizeof( *f ) );
|
|
||||||
|
|
||||||
return f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -234,9 +234,6 @@ static void LoadPNGBuffer( byte *buffer, int size, byte **pixels, int *width, in
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void ImageInit( void ){
|
static void ImageInit( void ){
|
||||||
int i;
|
|
||||||
|
|
||||||
|
|
||||||
if ( numImages <= 0 ) {
|
if ( numImages <= 0 ) {
|
||||||
/* clear images (fixme: this could theoretically leak) */
|
/* clear images (fixme: this could theoretically leak) */
|
||||||
memset( images, 0, sizeof( images ) );
|
memset( images, 0, sizeof( images ) );
|
||||||
|
|
@ -248,8 +245,7 @@ static void ImageInit( void ){
|
||||||
images[ 0 ].height = 64;
|
images[ 0 ].height = 64;
|
||||||
images[ 0 ].refCount = 1;
|
images[ 0 ].refCount = 1;
|
||||||
images[ 0 ].pixels = safe_malloc( 64 * 64 * 4 );
|
images[ 0 ].pixels = safe_malloc( 64 * 64 * 4 );
|
||||||
for ( i = 0; i < ( 64 * 64 * 4 ); i++ )
|
memset( images[ 0 ].pixels, 255, 64 * 64 * 4 );
|
||||||
images[ 0 ].pixels[ i ] = 255;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -107,8 +107,7 @@ static void CreateSunLight( sun_t *sun ){
|
||||||
|
|
||||||
/* create a light */
|
/* create a light */
|
||||||
numSunLights++;
|
numSunLights++;
|
||||||
light = safe_malloc( sizeof( *light ) );
|
light = safe_calloc( sizeof( *light ) );
|
||||||
memset( light, 0, sizeof( *light ) );
|
|
||||||
light->next = lights;
|
light->next = lights;
|
||||||
lights = light;
|
lights = light;
|
||||||
|
|
||||||
|
|
@ -254,8 +253,7 @@ void CreateEntityLights( void ){
|
||||||
|
|
||||||
/* create a light */
|
/* create a light */
|
||||||
numPointLights++;
|
numPointLights++;
|
||||||
light = safe_malloc( sizeof( *light ) );
|
light = safe_calloc( sizeof( *light ) );
|
||||||
memset( light, 0, sizeof( *light ) );
|
|
||||||
light->next = lights;
|
light->next = lights;
|
||||||
lights = light;
|
lights = light;
|
||||||
|
|
||||||
|
|
@ -592,8 +590,7 @@ void CreateSurfaceLights( void ){
|
||||||
VectorScale( origin, 0.5f, origin );
|
VectorScale( origin, 0.5f, origin );
|
||||||
|
|
||||||
/* create a light */
|
/* create a light */
|
||||||
light = safe_malloc( sizeof( *light ) );
|
light = safe_calloc( sizeof( *light ) );
|
||||||
memset( light, 0, sizeof( *light ) );
|
|
||||||
light->next = lights;
|
light->next = lights;
|
||||||
lights = light;
|
lights = light;
|
||||||
|
|
||||||
|
|
@ -1857,14 +1854,12 @@ void SetupGrid( void ){
|
||||||
numBSPGridPoints = numRawGridPoints;
|
numBSPGridPoints = numRawGridPoints;
|
||||||
|
|
||||||
/* allocate lightgrid */
|
/* allocate lightgrid */
|
||||||
rawGridPoints = safe_malloc( numRawGridPoints * sizeof( *rawGridPoints ) );
|
rawGridPoints = safe_calloc( numRawGridPoints * sizeof( *rawGridPoints ) );
|
||||||
memset( rawGridPoints, 0, numRawGridPoints * sizeof( *rawGridPoints ) );
|
|
||||||
|
|
||||||
if ( bspGridPoints != NULL ) {
|
if ( bspGridPoints != NULL ) {
|
||||||
free( bspGridPoints );
|
free( bspGridPoints );
|
||||||
}
|
}
|
||||||
bspGridPoints = safe_malloc( numBSPGridPoints * sizeof( *bspGridPoints ) );
|
bspGridPoints = safe_calloc( numBSPGridPoints * sizeof( *bspGridPoints ) );
|
||||||
memset( bspGridPoints, 0, numBSPGridPoints * sizeof( *bspGridPoints ) );
|
|
||||||
|
|
||||||
/* clear lightgrid */
|
/* clear lightgrid */
|
||||||
for ( i = 0; i < numRawGridPoints; i++ )
|
for ( i = 0; i < numRawGridPoints; i++ )
|
||||||
|
|
|
||||||
|
|
@ -538,8 +538,7 @@ static void RadSubdivideDiffuseLight( int lightmapNum, bspDrawSurface_t *ds, raw
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create a light */
|
/* create a light */
|
||||||
light = safe_malloc( sizeof( *light ) );
|
light = safe_calloc( sizeof( *light ) );
|
||||||
memset( light, 0, sizeof( *light ) );
|
|
||||||
|
|
||||||
/* attach it */
|
/* attach it */
|
||||||
ThreadLock();
|
ThreadLock();
|
||||||
|
|
@ -587,8 +586,7 @@ static void RadSubdivideDiffuseLight( int lightmapNum, bspDrawSurface_t *ds, raw
|
||||||
if ( si->backsplashFraction > 0 ) {
|
if ( si->backsplashFraction > 0 ) {
|
||||||
|
|
||||||
/* allocate a new point light */
|
/* allocate a new point light */
|
||||||
splash = safe_malloc( sizeof( *splash ) );
|
splash = safe_calloc( sizeof( *splash ) );
|
||||||
memset( splash, 0, sizeof( *splash ) );
|
|
||||||
|
|
||||||
splash->next = lights;
|
splash->next = lights;
|
||||||
lights = splash;
|
lights = splash;
|
||||||
|
|
@ -617,8 +615,7 @@ static void RadSubdivideDiffuseLight( int lightmapNum, bspDrawSurface_t *ds, raw
|
||||||
//if ( original && si->backsplashFraction > 0 ) {
|
//if ( original && si->backsplashFraction > 0 ) {
|
||||||
if ( si->backsplashFraction > 0 && !( si->compileFlags & C_SKY ) ) {
|
if ( si->backsplashFraction > 0 && !( si->compileFlags & C_SKY ) ) {
|
||||||
/* allocate a new area light */
|
/* allocate a new area light */
|
||||||
splash = safe_malloc( sizeof( *splash ) );
|
splash = safe_calloc( sizeof( *splash ) );
|
||||||
memset( splash, 0, sizeof( *splash ) );
|
|
||||||
ThreadLock();
|
ThreadLock();
|
||||||
splash->next = lights;
|
splash->next = lights;
|
||||||
lights = splash;
|
lights = splash;
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ void ColorToBytes( const float *color, byte *colorBytes, float scale ){
|
||||||
#define EQUAL_NORMAL_EPSILON 0.01
|
#define EQUAL_NORMAL_EPSILON 0.01
|
||||||
|
|
||||||
void SmoothNormals( void ){
|
void SmoothNormals( void ){
|
||||||
int i, j, k, f, cs, numVerts, numVotes, fOld, start;
|
int i, j, k, f, numVerts, numVotes, fOld, start;
|
||||||
float shadeAngle, defaultShadeAngle, maxShadeAngle, dot, testAngle;
|
float shadeAngle, defaultShadeAngle, maxShadeAngle, dot, testAngle;
|
||||||
bspDrawSurface_t *ds;
|
bspDrawSurface_t *ds;
|
||||||
shaderInfo_t *si;
|
shaderInfo_t *si;
|
||||||
|
|
@ -165,13 +165,10 @@ void SmoothNormals( void ){
|
||||||
|
|
||||||
|
|
||||||
/* allocate shade angle table */
|
/* allocate shade angle table */
|
||||||
shadeAngles = safe_malloc( numBSPDrawVerts * sizeof( float ) );
|
shadeAngles = safe_calloc( numBSPDrawVerts * sizeof( float ) );
|
||||||
memset( shadeAngles, 0, numBSPDrawVerts * sizeof( float ) );
|
|
||||||
|
|
||||||
/* allocate smoothed table */
|
/* allocate smoothed table */
|
||||||
cs = ( numBSPDrawVerts / 8 ) + 1;
|
smoothed = safe_calloc( ( numBSPDrawVerts / 8 ) + 1 );
|
||||||
smoothed = safe_malloc( cs );
|
|
||||||
memset( smoothed, 0, cs );
|
|
||||||
|
|
||||||
/* set default shade angle */
|
/* set default shade angle */
|
||||||
defaultShadeAngle = DEG2RAD( shadeAngleDegrees );
|
defaultShadeAngle = DEG2RAD( shadeAngleDegrees );
|
||||||
|
|
@ -2407,8 +2404,7 @@ void IlluminateRawLightmap( int rawLightmapNum ){
|
||||||
if ( lm->superLuxels[ lightmapNum ] == NULL ) {
|
if ( lm->superLuxels[ lightmapNum ] == NULL ) {
|
||||||
/* allocate sampling lightmap storage */
|
/* allocate sampling lightmap storage */
|
||||||
size = lm->sw * lm->sh * SUPER_LUXEL_SIZE * sizeof( float );
|
size = lm->sw * lm->sh * SUPER_LUXEL_SIZE * sizeof( float );
|
||||||
lm->superLuxels[ lightmapNum ] = safe_malloc( size );
|
lm->superLuxels[ lightmapNum ] = safe_calloc( size );
|
||||||
memset( lm->superLuxels[ lightmapNum ], 0, size );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set style */
|
/* set style */
|
||||||
|
|
|
||||||
|
|
@ -468,7 +468,7 @@ qboolean AddPatchToRawLightmap( int num, rawLightmap_t *lm ){
|
||||||
vec3_t delta;
|
vec3_t delta;
|
||||||
mesh_t src, *subdivided, *mesh;
|
mesh_t src, *subdivided, *mesh;
|
||||||
float sBasis, tBasis, s, t;
|
float sBasis, tBasis, s, t;
|
||||||
float length, widthTable[ MAX_EXPANDED_AXIS ], heightTable[ MAX_EXPANDED_AXIS ];
|
float length, widthTable[ MAX_EXPANDED_AXIS ] = {0}, heightTable[ MAX_EXPANDED_AXIS ] = {0};
|
||||||
|
|
||||||
|
|
||||||
/* patches finish a raw lightmap */
|
/* patches finish a raw lightmap */
|
||||||
|
|
@ -492,8 +492,6 @@ qboolean AddPatchToRawLightmap( int num, rawLightmap_t *lm ){
|
||||||
|
|
||||||
/* find the longest distance on each row/column */
|
/* find the longest distance on each row/column */
|
||||||
verts = mesh->verts;
|
verts = mesh->verts;
|
||||||
memset( widthTable, 0, sizeof( widthTable ) );
|
|
||||||
memset( heightTable, 0, sizeof( heightTable ) );
|
|
||||||
for ( y = 0; y < mesh->height; y++ )
|
for ( y = 0; y < mesh->height; y++ )
|
||||||
{
|
{
|
||||||
for ( x = 0; x < mesh->width; x++ )
|
for ( x = 0; x < mesh->width; x++ )
|
||||||
|
|
@ -827,8 +825,7 @@ qboolean AddSurfaceToRawLightmap( int num, rawLightmap_t *lm ){
|
||||||
/* for planar surfaces, create lightmap vectors for st->xyz conversion */
|
/* for planar surfaces, create lightmap vectors for st->xyz conversion */
|
||||||
if ( VectorLength( ds->lightmapVecs[ 2 ] ) || 1 ) { /* ydnar: can't remember what exactly i was thinking here... */
|
if ( VectorLength( ds->lightmapVecs[ 2 ] ) || 1 ) { /* ydnar: can't remember what exactly i was thinking here... */
|
||||||
/* allocate space for the vectors */
|
/* allocate space for the vectors */
|
||||||
lm->vecs = safe_malloc( 3 * sizeof( vec3_t ) );
|
lm->vecs = safe_calloc( 3 * sizeof( vec3_t ) );
|
||||||
memset( lm->vecs, 0, 3 * sizeof( vec3_t ) );
|
|
||||||
VectorCopy( ds->lightmapVecs[ 2 ], lm->vecs[ 2 ] );
|
VectorCopy( ds->lightmapVecs[ 2 ], lm->vecs[ 2 ] );
|
||||||
|
|
||||||
/* project stepped lightmap blocks and subtract to get planevecs */
|
/* project stepped lightmap blocks and subtract to get planevecs */
|
||||||
|
|
@ -999,18 +996,15 @@ void SetupSurfaceLightmaps( void ){
|
||||||
/* allocate a list of surface clusters */
|
/* allocate a list of surface clusters */
|
||||||
numSurfaceClusters = 0;
|
numSurfaceClusters = 0;
|
||||||
maxSurfaceClusters = numBSPLeafSurfaces;
|
maxSurfaceClusters = numBSPLeafSurfaces;
|
||||||
surfaceClusters = safe_malloc( maxSurfaceClusters * sizeof( *surfaceClusters ) );
|
surfaceClusters = safe_calloc( maxSurfaceClusters * sizeof( *surfaceClusters ) );
|
||||||
memset( surfaceClusters, 0, maxSurfaceClusters * sizeof( *surfaceClusters ) );
|
|
||||||
|
|
||||||
/* allocate a list for per-surface info */
|
/* allocate a list for per-surface info */
|
||||||
surfaceInfos = safe_malloc( numBSPDrawSurfaces * sizeof( *surfaceInfos ) );
|
surfaceInfos = safe_calloc( numBSPDrawSurfaces * sizeof( *surfaceInfos ) );
|
||||||
memset( surfaceInfos, 0, numBSPDrawSurfaces * sizeof( *surfaceInfos ) );
|
|
||||||
for ( i = 0; i < numBSPDrawSurfaces; i++ )
|
for ( i = 0; i < numBSPDrawSurfaces; i++ )
|
||||||
surfaceInfos[ i ].childSurfaceNum = -1;
|
surfaceInfos[ i ].childSurfaceNum = -1;
|
||||||
|
|
||||||
/* allocate a list of surface indexes to be sorted */
|
/* allocate a list of surface indexes to be sorted */
|
||||||
sortSurfaces = safe_malloc( numBSPDrawSurfaces * sizeof( int ) );
|
sortSurfaces = safe_calloc( numBSPDrawSurfaces * sizeof( int ) );
|
||||||
memset( sortSurfaces, 0, numBSPDrawSurfaces * sizeof( int ) );
|
|
||||||
|
|
||||||
/* walk each model in the bsp */
|
/* walk each model in the bsp */
|
||||||
for ( i = 0; i < numBSPModels; i++ )
|
for ( i = 0; i < numBSPModels; i++ )
|
||||||
|
|
@ -1131,14 +1125,12 @@ void SetupSurfaceLightmaps( void ){
|
||||||
|
|
||||||
/* allocate a list of surfaces that would go into raw lightmaps */
|
/* allocate a list of surfaces that would go into raw lightmaps */
|
||||||
numLightSurfaces = 0;
|
numLightSurfaces = 0;
|
||||||
lightSurfaces = safe_malloc( numSurfsLightmapped * sizeof( int ) );
|
lightSurfaces = safe_calloc( numSurfsLightmapped * sizeof( int ) );
|
||||||
memset( lightSurfaces, 0, numSurfsLightmapped * sizeof( int ) );
|
|
||||||
|
|
||||||
/* allocate a list of raw lightmaps */
|
/* allocate a list of raw lightmaps */
|
||||||
numRawSuperLuxels = 0;
|
numRawSuperLuxels = 0;
|
||||||
numRawLightmaps = 0;
|
numRawLightmaps = 0;
|
||||||
rawLightmaps = safe_malloc( numSurfsLightmapped * sizeof( *rawLightmaps ) );
|
rawLightmaps = safe_calloc( numSurfsLightmapped * sizeof( *rawLightmaps ) );
|
||||||
memset( rawLightmaps, 0, numSurfsLightmapped * sizeof( *rawLightmaps ) );
|
|
||||||
|
|
||||||
/* walk the list of sorted surfaces */
|
/* walk the list of sorted surfaces */
|
||||||
for ( i = 0; i < numBSPDrawSurfaces; i++ )
|
for ( i = 0; i < numBSPDrawSurfaces; i++ )
|
||||||
|
|
@ -1227,10 +1219,8 @@ void SetupSurfaceLightmaps( void ){
|
||||||
/* allocate vertex luxel storage */
|
/* allocate vertex luxel storage */
|
||||||
for ( k = 0; k < MAX_LIGHTMAPS; k++ )
|
for ( k = 0; k < MAX_LIGHTMAPS; k++ )
|
||||||
{
|
{
|
||||||
vertexLuxels[ k ] = safe_malloc( numBSPDrawVerts * VERTEX_LUXEL_SIZE * sizeof( float ) );
|
vertexLuxels[ k ] = safe_calloc( numBSPDrawVerts * VERTEX_LUXEL_SIZE * sizeof( float ) );
|
||||||
memset( vertexLuxels[ k ], 0, numBSPDrawVerts * VERTEX_LUXEL_SIZE * sizeof( float ) );
|
radVertexLuxels[ k ] = safe_calloc( numBSPDrawVerts * VERTEX_LUXEL_SIZE * sizeof( float ) );
|
||||||
radVertexLuxels[ k ] = safe_malloc( numBSPDrawVerts * VERTEX_LUXEL_SIZE * sizeof( float ) );
|
|
||||||
memset( radVertexLuxels[ k ], 0, numBSPDrawVerts * VERTEX_LUXEL_SIZE * sizeof( float ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* emit some stats */
|
/* emit some stats */
|
||||||
|
|
@ -1982,13 +1972,10 @@ static void SetupOutLightmap( rawLightmap_t *lm, outLightmap_t *olm ){
|
||||||
olm->numShaders = 0;
|
olm->numShaders = 0;
|
||||||
|
|
||||||
/* allocate buffers */
|
/* allocate buffers */
|
||||||
olm->lightBits = safe_malloc( ( olm->customWidth * olm->customHeight / 8 ) + 8 );
|
olm->lightBits = safe_calloc( ( olm->customWidth * olm->customHeight / 8 ) + 8 );
|
||||||
memset( olm->lightBits, 0, ( olm->customWidth * olm->customHeight / 8 ) + 8 );
|
olm->bspLightBytes = safe_calloc( olm->customWidth * olm->customHeight * 3 );
|
||||||
olm->bspLightBytes = safe_malloc( olm->customWidth * olm->customHeight * 3 );
|
|
||||||
memset( olm->bspLightBytes, 0, olm->customWidth * olm->customHeight * 3 );
|
|
||||||
if ( deluxemap ) {
|
if ( deluxemap ) {
|
||||||
olm->bspDirBytes = safe_malloc( olm->customWidth * olm->customHeight * 3 );
|
olm->bspDirBytes = safe_calloc( olm->customWidth * olm->customHeight * 3 );
|
||||||
memset( olm->bspDirBytes, 0, olm->customWidth * olm->customHeight * 3 );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2515,8 +2502,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
|
||||||
char dirname[ 1024 ], filename[ 1024 ];
|
char dirname[ 1024 ], filename[ 1024 ];
|
||||||
shaderInfo_t *csi;
|
shaderInfo_t *csi;
|
||||||
char lightmapName[ 128 ];
|
char lightmapName[ 128 ];
|
||||||
const char *rgbGenValues[ 256 ];
|
const char *rgbGenValues[ 256 ] = {0};
|
||||||
const char *alphaGenValues[ 256 ];
|
const char *alphaGenValues[ 256 ] = {0};
|
||||||
|
|
||||||
|
|
||||||
/* note it */
|
/* note it */
|
||||||
|
|
@ -2531,8 +2518,6 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
|
||||||
strcpy( dirname, source );
|
strcpy( dirname, source );
|
||||||
StripExtension( dirname );
|
StripExtension( dirname );
|
||||||
}
|
}
|
||||||
memset( rgbGenValues, 0, sizeof( rgbGenValues ) );
|
|
||||||
memset( alphaGenValues, 0, sizeof( alphaGenValues ) );
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------
|
/* -----------------------------------------------------------------
|
||||||
average the sampled luxels into the bsp luxels
|
average the sampled luxels into the bsp luxels
|
||||||
|
|
@ -2564,8 +2549,7 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
|
||||||
/* allocate bsp luxel storage */
|
/* allocate bsp luxel storage */
|
||||||
if ( lm->bspLuxels[ lightmapNum ] == NULL ) {
|
if ( lm->bspLuxels[ lightmapNum ] == NULL ) {
|
||||||
size = lm->w * lm->h * BSP_LUXEL_SIZE * sizeof( float );
|
size = lm->w * lm->h * BSP_LUXEL_SIZE * sizeof( float );
|
||||||
lm->bspLuxels[ lightmapNum ] = safe_malloc( size );
|
lm->bspLuxels[ lightmapNum ] = safe_calloc( size );
|
||||||
memset( lm->bspLuxels[ lightmapNum ], 0, size );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocate radiosity lightmap storage */
|
/* allocate radiosity lightmap storage */
|
||||||
|
|
@ -3181,8 +3165,7 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
numBSPLightBytes = ( numBSPLightmaps * game->lightmapSize * game->lightmapSize * 3 );
|
numBSPLightBytes = ( numBSPLightmaps * game->lightmapSize * game->lightmapSize * 3 );
|
||||||
bspLightBytes = safe_malloc( numBSPLightBytes );
|
bspLightBytes = safe_calloc( numBSPLightBytes );
|
||||||
memset( bspLightBytes, 0, numBSPLightBytes );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* walk the list of output lightmaps */
|
/* walk the list of output lightmaps */
|
||||||
|
|
|
||||||
|
|
@ -1646,8 +1646,7 @@ void LoadEntityIndexMap( entity_t *e ){
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create a new index map */
|
/* create a new index map */
|
||||||
im = safe_malloc( sizeof( *im ) );
|
im = safe_calloc( sizeof( *im ) );
|
||||||
memset( im, 0, sizeof( *im ) );
|
|
||||||
|
|
||||||
/* set it up */
|
/* set it up */
|
||||||
im->w = w;
|
im->w = w;
|
||||||
|
|
|
||||||
|
|
@ -449,12 +449,10 @@ void InsertModel( const char *name, int skin, int frame, m4x4_t transform, remap
|
||||||
|
|
||||||
/* set particulars */
|
/* set particulars */
|
||||||
ds->numVerts = PicoGetSurfaceNumVertexes( surface );
|
ds->numVerts = PicoGetSurfaceNumVertexes( surface );
|
||||||
ds->verts = safe_malloc( ds->numVerts * sizeof( ds->verts[ 0 ] ) );
|
ds->verts = safe_calloc( ds->numVerts * sizeof( ds->verts[ 0 ] ) );
|
||||||
memset( ds->verts, 0, ds->numVerts * sizeof( ds->verts[ 0 ] ) );
|
|
||||||
|
|
||||||
ds->numIndexes = PicoGetSurfaceNumIndexes( surface );
|
ds->numIndexes = PicoGetSurfaceNumIndexes( surface );
|
||||||
ds->indexes = safe_malloc( ds->numIndexes * sizeof( ds->indexes[ 0 ] ) );
|
ds->indexes = safe_calloc( ds->numIndexes * sizeof( ds->indexes[ 0 ] ) );
|
||||||
memset( ds->indexes, 0, ds->numIndexes * sizeof( ds->indexes[ 0 ] ) );
|
|
||||||
|
|
||||||
/* copy vertexes */
|
/* copy vertexes */
|
||||||
for ( i = 0; i < ds->numVerts; i++ )
|
for ( i = 0; i < ds->numVerts; i++ )
|
||||||
|
|
|
||||||
|
|
@ -348,8 +348,7 @@ void ParsePatch( qboolean onlyLights ){
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocate patch mesh */
|
/* allocate patch mesh */
|
||||||
pm = safe_malloc( sizeof( *pm ) );
|
pm = safe_calloc( sizeof( *pm ) );
|
||||||
memset( pm, 0, sizeof( *pm ) );
|
|
||||||
|
|
||||||
/* ydnar: add entity/brush numbering */
|
/* ydnar: add entity/brush numbering */
|
||||||
pm->entityNum = mapEnt->mapEntityNum;
|
pm->entityNum = mapEnt->mapEntityNum;
|
||||||
|
|
@ -446,8 +445,7 @@ void PatchMapDrawSurfs( entity_t *e ){
|
||||||
if ( !patchCount ) {
|
if ( !patchCount ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bordering = safe_malloc( patchCount * patchCount );
|
bordering = safe_calloc( patchCount * patchCount );
|
||||||
memset( bordering, 0, patchCount * patchCount );
|
|
||||||
|
|
||||||
// build the bordering matrix
|
// build the bordering matrix
|
||||||
for ( k = 0 ; k < patchCount ; k++ ) {
|
for ( k = 0 ; k < patchCount ; k++ ) {
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,6 @@ int c_boundary_sides;
|
||||||
===========
|
===========
|
||||||
*/
|
*/
|
||||||
portal_t *AllocPortal( void ){
|
portal_t *AllocPortal( void ){
|
||||||
portal_t *p;
|
|
||||||
|
|
||||||
if ( numthreads == 1 ) {
|
if ( numthreads == 1 ) {
|
||||||
c_active_portals++;
|
c_active_portals++;
|
||||||
}
|
}
|
||||||
|
|
@ -62,10 +60,7 @@ portal_t *AllocPortal( void ){
|
||||||
c_peak_portals = c_active_portals;
|
c_peak_portals = c_active_portals;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = safe_malloc( sizeof( portal_t ) );
|
return safe_calloc( sizeof( portal_t ) );
|
||||||
memset( p, 0, sizeof( portal_t ) );
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreePortal( portal_t *p ){
|
void FreePortal( portal_t *p ){
|
||||||
|
|
|
||||||
|
|
@ -1273,8 +1273,7 @@ static void ParseShaderFile( const char *filename ){
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocate sun */
|
/* allocate sun */
|
||||||
sun = safe_malloc( sizeof( *sun ) );
|
sun = safe_calloc( sizeof( *sun ) );
|
||||||
memset( sun, 0, sizeof( *sun ) );
|
|
||||||
|
|
||||||
/* set style */
|
/* set style */
|
||||||
sun->style = si->lightStyle;
|
sun->style = si->lightStyle;
|
||||||
|
|
@ -1374,8 +1373,7 @@ static void ParseShaderFile( const char *filename ){
|
||||||
surfaceModel_t *model;
|
surfaceModel_t *model;
|
||||||
|
|
||||||
/* allocate new model and attach it */
|
/* allocate new model and attach it */
|
||||||
model = safe_malloc( sizeof( *model ) );
|
model = safe_calloc( sizeof( *model ) );
|
||||||
memset( model, 0, sizeof( *model ) );
|
|
||||||
model->next = si->surfaceModel;
|
model->next = si->surfaceModel;
|
||||||
si->surfaceModel = model;
|
si->surfaceModel = model;
|
||||||
|
|
||||||
|
|
@ -1408,8 +1406,7 @@ static void ParseShaderFile( const char *filename ){
|
||||||
|
|
||||||
|
|
||||||
/* allocate new foliage struct and attach it */
|
/* allocate new foliage struct and attach it */
|
||||||
foliage = safe_malloc( sizeof( *foliage ) );
|
foliage = safe_calloc( sizeof( *foliage ) );
|
||||||
memset( foliage, 0, sizeof( *foliage ) );
|
|
||||||
foliage->next = si->foliage;
|
foliage->next = si->foliage;
|
||||||
si->foliage = foliage;
|
si->foliage = foliage;
|
||||||
|
|
||||||
|
|
@ -1733,8 +1730,7 @@ static void ParseShaderFile( const char *filename ){
|
||||||
alpha = ( !Q_stricmp( token, "q3map_alphaGen" ) || !Q_stricmp( token, "q3map_alphaMod" ) ) ? 1 : 0;
|
alpha = ( !Q_stricmp( token, "q3map_alphaGen" ) || !Q_stricmp( token, "q3map_alphaMod" ) ) ? 1 : 0;
|
||||||
|
|
||||||
/* allocate new colormod */
|
/* allocate new colormod */
|
||||||
cm = safe_malloc( sizeof( *cm ) );
|
cm = safe_calloc( sizeof( *cm ) );
|
||||||
memset( cm, 0, sizeof( *cm ) );
|
|
||||||
|
|
||||||
/* attach to shader */
|
/* attach to shader */
|
||||||
if ( si->colorMod == NULL ) {
|
if ( si->colorMod == NULL ) {
|
||||||
|
|
|
||||||
|
|
@ -957,8 +957,7 @@ mapDrawSurface_t *DrawSurfaceForSide( entity_t *e, brush_t *b, side_t *s, windin
|
||||||
ds->sampleSize = b->lightmapSampleSize;
|
ds->sampleSize = b->lightmapSampleSize;
|
||||||
ds->lightmapScale = b->lightmapScale;
|
ds->lightmapScale = b->lightmapScale;
|
||||||
ds->numVerts = w->numpoints;
|
ds->numVerts = w->numpoints;
|
||||||
ds->verts = safe_malloc( ds->numVerts * sizeof( *ds->verts ) );
|
ds->verts = safe_calloc( ds->numVerts * sizeof( *ds->verts ) );
|
||||||
memset( ds->verts, 0, ds->numVerts * sizeof( *ds->verts ) );
|
|
||||||
|
|
||||||
/* compute s/t coordinates from brush primitive texture matrix (compute axis base) */
|
/* compute s/t coordinates from brush primitive texture matrix (compute axis base) */
|
||||||
ComputeAxisBase( mapplanes[ s->planenum ].normal, texX, texY );
|
ComputeAxisBase( mapplanes[ s->planenum ].normal, texX, texY );
|
||||||
|
|
@ -3025,8 +3024,7 @@ static void MakeDebugPortalSurfs_r( node_t *node, shaderInfo_t *si ){
|
||||||
VectorCopy( p->plane.normal, ds->lightmapVecs[ 2 ] );
|
VectorCopy( p->plane.normal, ds->lightmapVecs[ 2 ] );
|
||||||
ds->fogNum = -1;
|
ds->fogNum = -1;
|
||||||
ds->numVerts = w->numpoints;
|
ds->numVerts = w->numpoints;
|
||||||
ds->verts = safe_malloc( ds->numVerts * sizeof( *ds->verts ) );
|
ds->verts = safe_calloc( ds->numVerts * sizeof( *ds->verts ) );
|
||||||
memset( ds->verts, 0, ds->numVerts * sizeof( *ds->verts ) );
|
|
||||||
|
|
||||||
/* walk the winding */
|
/* walk the winding */
|
||||||
for ( i = 0; i < ds->numVerts; i++ )
|
for ( i = 0; i < ds->numVerts; i++ )
|
||||||
|
|
@ -3117,11 +3115,9 @@ void MakeFogHullSurfs( entity_t *e, tree_t *tree, char *shader ){
|
||||||
ds->shaderInfo = si;
|
ds->shaderInfo = si;
|
||||||
ds->fogNum = -1;
|
ds->fogNum = -1;
|
||||||
ds->numVerts = 8;
|
ds->numVerts = 8;
|
||||||
ds->verts = safe_malloc( ds->numVerts * sizeof( *ds->verts ) );
|
ds->verts = safe_calloc( ds->numVerts * sizeof( *ds->verts ) );
|
||||||
memset( ds->verts, 0, ds->numVerts * sizeof( *ds->verts ) );
|
|
||||||
ds->numIndexes = 36;
|
ds->numIndexes = 36;
|
||||||
ds->indexes = safe_malloc( ds->numIndexes * sizeof( *ds->indexes ) );
|
ds->indexes = safe_calloc( ds->numIndexes * sizeof( *ds->indexes ) );
|
||||||
memset( ds->indexes, 0, ds->numIndexes * sizeof( *ds->indexes ) );
|
|
||||||
|
|
||||||
/* set verts */
|
/* set verts */
|
||||||
VectorSet( ds->verts[ 0 ].xyz, fogMins[ 0 ], fogMins[ 1 ], fogMins[ 2 ] );
|
VectorSet( ds->verts[ 0 ].xyz, fogMins[ 0 ], fogMins[ 1 ], fogMins[ 2 ] );
|
||||||
|
|
|
||||||
|
|
@ -301,8 +301,7 @@ void Foliage( mapDrawSurface_t *src ){
|
||||||
ds->fogNum = src->fogNum;
|
ds->fogNum = src->fogNum;
|
||||||
|
|
||||||
/* add a drawvert for every instance */
|
/* add a drawvert for every instance */
|
||||||
verts = safe_malloc( ( ds->numVerts + ds->numFoliageInstances ) * sizeof( *verts ) );
|
verts = safe_calloc( ( ds->numVerts + ds->numFoliageInstances ) * sizeof( *verts ) );
|
||||||
memset( verts, 0, ( ds->numVerts + ds->numFoliageInstances ) * sizeof( *verts ) );
|
|
||||||
memcpy( verts, ds->verts, ds->numVerts * sizeof( *verts ) );
|
memcpy( verts, ds->verts, ds->numVerts * sizeof( *verts ) );
|
||||||
free( ds->verts );
|
free( ds->verts );
|
||||||
ds->verts = verts;
|
ds->verts = verts;
|
||||||
|
|
|
||||||
|
|
@ -638,7 +638,8 @@ void MaxAreaFaceSurface( mapDrawSurface_t *ds ){
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void FanFaceSurface( mapDrawSurface_t *ds ){
|
void FanFaceSurface( mapDrawSurface_t *ds ){
|
||||||
int i, j, k, a, b, c, color[ MAX_LIGHTMAPS ][ 4 ];
|
int i, j, k, a, b, c;
|
||||||
|
int color[ MAX_LIGHTMAPS ][ 4 ] = {0};
|
||||||
bspDrawVert_t *verts, *centroid, *dv;
|
bspDrawVert_t *verts, *centroid, *dv;
|
||||||
double iv;
|
double iv;
|
||||||
|
|
||||||
|
|
@ -657,7 +658,6 @@ void FanFaceSurface( mapDrawSurface_t *ds ){
|
||||||
|
|
||||||
/* add up the drawverts to create a centroid */
|
/* add up the drawverts to create a centroid */
|
||||||
centroid = &verts[ 0 ];
|
centroid = &verts[ 0 ];
|
||||||
memset( color, 0, 4 * MAX_LIGHTMAPS * sizeof( int ) );
|
|
||||||
for ( i = 1, dv = &verts[ 1 ]; i < ( ds->numVerts + 1 ); i++, dv++ )
|
for ( i = 1, dv = &verts[ 1 ]; i < ( ds->numVerts + 1 ); i++, dv++ )
|
||||||
{
|
{
|
||||||
VectorAdd( centroid->xyz, dv->xyz, centroid->xyz );
|
VectorAdd( centroid->xyz, dv->xyz, centroid->xyz );
|
||||||
|
|
@ -1180,7 +1180,7 @@ void FixMetaTJunctions( void ){
|
||||||
#define EQUAL_NORMAL_EPSILON 0.01
|
#define EQUAL_NORMAL_EPSILON 0.01
|
||||||
|
|
||||||
void SmoothMetaTriangles( void ){
|
void SmoothMetaTriangles( void ){
|
||||||
int i, j, k, f, fOld, start, cs, numVerts, numVotes, numSmoothed;
|
int i, j, k, f, fOld, start, numVerts, numVotes, numSmoothed;
|
||||||
float shadeAngle, defaultShadeAngle, maxShadeAngle, dot, testAngle;
|
float shadeAngle, defaultShadeAngle, maxShadeAngle, dot, testAngle;
|
||||||
metaTriangle_t *tri;
|
metaTriangle_t *tri;
|
||||||
float *shadeAngles;
|
float *shadeAngles;
|
||||||
|
|
@ -1193,13 +1193,10 @@ void SmoothMetaTriangles( void ){
|
||||||
Sys_FPrintf( SYS_VRB, "--- SmoothMetaTriangles ---\n" );
|
Sys_FPrintf( SYS_VRB, "--- SmoothMetaTriangles ---\n" );
|
||||||
|
|
||||||
/* allocate shade angle table */
|
/* allocate shade angle table */
|
||||||
shadeAngles = safe_malloc( numMetaVerts * sizeof( float ) );
|
shadeAngles = safe_calloc( numMetaVerts * sizeof( float ) );
|
||||||
memset( shadeAngles, 0, numMetaVerts * sizeof( float ) );
|
|
||||||
|
|
||||||
/* allocate smoothed table */
|
/* allocate smoothed table */
|
||||||
cs = ( numMetaVerts / 8 ) + 1;
|
smoothed = safe_calloc( ( numMetaVerts / 8 ) + 1 );
|
||||||
smoothed = safe_malloc( cs );
|
|
||||||
memset( smoothed, 0, cs );
|
|
||||||
|
|
||||||
/* set default shade angle */
|
/* set default shade angle */
|
||||||
defaultShadeAngle = DEG2RAD( npDegrees );
|
defaultShadeAngle = DEG2RAD( npDegrees );
|
||||||
|
|
@ -1705,9 +1702,6 @@ static void MetaTrianglesToSurface( int numPossibles, metaTriangle_t *possibles,
|
||||||
ClearBounds( ds->mins, ds->maxs );
|
ClearBounds( ds->mins, ds->maxs );
|
||||||
|
|
||||||
/* clear verts/indexes */
|
/* clear verts/indexes */
|
||||||
// memset( verts, 0, sizeof( verts ) );
|
|
||||||
// memset( indexes, 0, sizeof( indexes ) );
|
|
||||||
//is more correct, but upper works ok too
|
|
||||||
memset( verts, 0, sizeof( *verts ) * maxSurfaceVerts );
|
memset( verts, 0, sizeof( *verts ) * maxSurfaceVerts );
|
||||||
memset( indexes, 0, sizeof( *indexes ) * maxSurfaceIndexes );
|
memset( indexes, 0, sizeof( *indexes ) * maxSurfaceIndexes );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,18 +58,10 @@ void PlaneFromWinding( fixedWinding_t *w, visPlane_t *plane ){
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fixedWinding_t *NewFixedWinding( int points ){
|
fixedWinding_t *NewFixedWinding( int points ){
|
||||||
fixedWinding_t *w;
|
|
||||||
int size;
|
|
||||||
|
|
||||||
if ( points > MAX_POINTS_ON_WINDING ) {
|
if ( points > MAX_POINTS_ON_WINDING ) {
|
||||||
Error( "NewWinding: %i points", points );
|
Error( "NewWinding: %i points", points );
|
||||||
}
|
}
|
||||||
|
return safe_calloc( offsetof( fixedWinding_t, points[points] ) );
|
||||||
size = offsetof( fixedWinding_t, points ) + sizeof( *w->points ) * points;
|
|
||||||
w = safe_malloc( size );
|
|
||||||
memset( w, 0, size );
|
|
||||||
|
|
||||||
return w;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -943,11 +935,8 @@ void LoadPortals( char *name ){
|
||||||
portallongs = portalbytes / sizeof( long );
|
portallongs = portalbytes / sizeof( long );
|
||||||
|
|
||||||
// each file portal is split into two memory portals
|
// each file portal is split into two memory portals
|
||||||
portals = safe_malloc( 2 * numportals * sizeof( vportal_t ) );
|
portals = safe_calloc( 2 * numportals * sizeof( vportal_t ) );
|
||||||
memset( portals, 0, 2 * numportals * sizeof( vportal_t ) );
|
leafs = safe_calloc( portalclusters * sizeof( leaf_t ) );
|
||||||
|
|
||||||
leafs = safe_malloc( portalclusters * sizeof( leaf_t ) );
|
|
||||||
memset( leafs, 0, portalclusters * sizeof( leaf_t ) );
|
|
||||||
|
|
||||||
for ( i = 0; i < portalclusters; i++ )
|
for ( i = 0; i < portalclusters; i++ )
|
||||||
leafs[i].merged = -1;
|
leafs[i].merged = -1;
|
||||||
|
|
@ -1043,11 +1032,8 @@ void LoadPortals( char *name ){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
faces = safe_malloc( 2 * numfaces * sizeof( vportal_t ) );
|
faces = safe_calloc( 2 * numfaces * sizeof( vportal_t ) );
|
||||||
memset( faces, 0, 2 * numfaces * sizeof( vportal_t ) );
|
faceleafs = safe_calloc( portalclusters * sizeof( leaf_t ) );
|
||||||
|
|
||||||
faceleafs = safe_malloc( portalclusters * sizeof( leaf_t ) );
|
|
||||||
memset( faceleafs, 0, portalclusters * sizeof( leaf_t ) );
|
|
||||||
|
|
||||||
for ( i = 0, p = faces; i < numfaces; i++ )
|
for ( i = 0, p = faces; i < numfaces; i++ )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1362,8 +1362,7 @@ void CreatePassages( int portalnum ){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
passage = (passage_t *) safe_malloc( sizeof( passage_t ) + portalbytes );
|
passage = safe_calloc( sizeof( passage_t ) + portalbytes );
|
||||||
memset( passage, 0, sizeof( passage_t ) + portalbytes );
|
|
||||||
numseperators = AddSeperators( portal->winding, target->winding, qfalse, seperators, MAX_SEPERATORS * 2 );
|
numseperators = AddSeperators( portal->winding, target->winding, qfalse, seperators, MAX_SEPERATORS * 2 );
|
||||||
numseperators += AddSeperators( target->winding, portal->winding, qtrue, &seperators[numseperators], MAX_SEPERATORS * 2 - numseperators );
|
numseperators += AddSeperators( target->winding, portal->winding, qtrue, &seperators[numseperators], MAX_SEPERATORS * 2 - numseperators );
|
||||||
|
|
||||||
|
|
@ -1583,14 +1582,9 @@ void BasePortalVis( int portalnum ){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
p->portalfront = safe_malloc( portalbytes );
|
p->portalfront = safe_calloc( portalbytes );
|
||||||
memset( p->portalfront, 0, portalbytes );
|
p->portalflood = safe_calloc( portalbytes );
|
||||||
|
p->portalvis = safe_calloc( portalbytes );
|
||||||
p->portalflood = safe_malloc( portalbytes );
|
|
||||||
memset( p->portalflood, 0, portalbytes );
|
|
||||||
|
|
||||||
p->portalvis = safe_malloc( portalbytes );
|
|
||||||
memset( p->portalvis, 0, portalbytes );
|
|
||||||
|
|
||||||
for ( j = 0, tp = portals ; j < numportals * 2 ; j++, tp++ )
|
for ( j = 0, tp = portals ; j < numportals * 2 ; j++, tp++ )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user