This commit is contained in:
Pan7 2016-08-21 07:58:20 +02:00
commit 0844bbd4f6
12 changed files with 133 additions and 126 deletions

View file

@ -52,7 +52,7 @@
#define MDC_DIST_SCALE 0.05f #define MDC_DIST_SCALE 0.05f
/* mdc decoding normal table */ /* mdc decoding normal table */
double mdcNormals[ 256 ][ 3 ] = const double mdcNormals[ 256 ][ 3 ] =
{ {
{ 1.000000, 0.000000, 0.000000 }, { 1.000000, 0.000000, 0.000000 },
{ 0.980785, 0.195090, 0.000000 }, { 0.980785, 0.195090, 0.000000 },

View file

@ -119,9 +119,7 @@ int vfsBuildShortPathName( const char* pPath, char* pBuffer, int nBufferLen ){
strcpy( pBuffer, pPath ); // Use long filename strcpy( pBuffer, pPath ); // Use long filename
} }
return nResult; return nResult;
#endif #elif defined ( __linux__ ) || defined ( __APPLE__ )
#if defined ( __linux__ ) || defined ( __APPLE__ )
// remove /../ from directories // remove /../ from directories
const char *scr = pPath; char *dst = pBuffer; const char *scr = pPath; char *dst = pBuffer;
@ -142,6 +140,8 @@ int vfsBuildShortPathName( const char* pPath, char* pBuffer, int nBufferLen ){
*dst = 0; *dst = 0;
return strlen( pBuffer ); return strlen( pBuffer );
#else
#error "unsupported platform"
#endif #endif
} }

View file

@ -382,8 +382,8 @@ void Eclass_Init(){
if ( !strcmp( ValueForKey( g_qeglobals.d_project_entity, "gamemode" ), "sp" ) ) { if ( !strcmp( ValueForKey( g_qeglobals.d_project_entity, "gamemode" ), "sp" ) ) {
// SP mapping, ignore mp_*.def // SP mapping, ignore mp_*.def
char *name = (char *)pFile->data; char *name = (char *)pFile->data;
if ( name[0] == 'm' && name[1] == 'p' && name[2] == '_' if ( ( name[0] == 'm' && name[1] == 'p' && name[2] == '_' )
|| name[0] == 'h' && name[1] == 'm' && name[2] == '_' ) { || ( name[0] == 'h' && name[1] == 'm' && name[2] == '_' ) ) {
Sys_Printf( "Single Player mapping mode. Ignoring '%s'\n", name ); Sys_Printf( "Single Player mapping mode. Ignoring '%s'\n", name );
pFile = pFile->next; pFile = pFile->next;
continue; continue;

View file

@ -411,9 +411,9 @@ static void ASE_SkipRestOfLine( void ){
} }
static void ASE_KeyMAP_DIFFUSE( const char *token ){ static void ASE_KeyMAP_DIFFUSE( const char *token ){
char fullpath[1024], bitmap[1024], modeldir[1024]; char bitmap[1024];
char filename[1024]; char filename[1024];
int i = 0, count; int i = 0;
strcpy( filename, gl_filename ); strcpy( filename, gl_filename );

View file

@ -1463,7 +1463,7 @@ static int unzlocal_getShort (FILE* fin, uLong *pX)
{ {
short v; short v;
if ( unz_GAME_QL == 1 ) { if (unz_GAME_QL == 1) {
fread_ql( &v, sizeof(v), 1, fin ); fread_ql( &v, sizeof(v), 1, fin );
} else { } else {
fread( &v, sizeof(v), 1, fin ); fread( &v, sizeof(v), 1, fin );
@ -1495,7 +1495,7 @@ static int unzlocal_getLong (FILE *fin, uLong *pX)
{ {
int v; int v;
if ( unz_GAME_QL == 1 ) { if (unz_GAME_QL == 1) {
fread_ql( &v, sizeof(v), 1, fin ); fread_ql( &v, sizeof(v), 1, fin );
} else { } else {
fread( &v, sizeof(v), 1, fin ); fread( &v, sizeof(v), 1, fin );
@ -1631,7 +1631,7 @@ static uLong unzlocal_SearchCentralDir(FILE *fin)
if (fseek(fin,uReadPos,SEEK_SET)!=0) if (fseek(fin,uReadPos,SEEK_SET)!=0)
break; break;
if ( unz_GAME_QL == 1 ) { if (unz_GAME_QL == 1) {
gametype = fread_ql(buf,(uInt)uReadSize,1,fin); gametype = fread_ql(buf,(uInt)uReadSize,1,fin);
} else { } else {
gametype = fread(buf,(uInt)uReadSize,1,fin); gametype = fread(buf,(uInt)uReadSize,1,fin);
@ -1697,7 +1697,7 @@ extern unzFile unzOpen (const char* path)
int err=UNZ_OK; int err=UNZ_OK;
if ( unz_GAME_QL == 1 ) { if (unz_GAME_QL == 1) {
fin=fopen_ql(path,"rb"); fin=fopen_ql(path,"rb");
} else { } else {
fin=fopen(path,"rb"); fin=fopen(path,"rb");
@ -1756,7 +1756,7 @@ extern unzFile unzOpen (const char* path)
if (err!=UNZ_OK) if (err!=UNZ_OK)
{ {
if ( unz_GAME_QL == 1 ) { if (unz_GAME_QL == 1) {
fclose_ql(fin); fclose_ql(fin);
} else { } else {
fclose(fin); fclose(fin);
@ -1793,7 +1793,7 @@ extern int unzClose (unzFile file)
if (s->pfile_in_zip_read!=NULL) if (s->pfile_in_zip_read!=NULL)
unzCloseCurrentFile(file); unzCloseCurrentFile(file);
if ( unz_GAME_QL == 1 ) { if (unz_GAME_QL == 1) {
fclose_ql(s->file); fclose_ql(s->file);
} else { } else {
fclose(s->file); fclose(s->file);
@ -1856,19 +1856,24 @@ static int unzlocal_GetCurrentFileInfoInternal (unzFile file,
uLong uMagic; uLong uMagic;
long lSeek=0; long lSeek=0;
if (file==NULL) if (file == NULL) {
return UNZ_PARAMERROR; return UNZ_PARAMERROR;
s=(unz_s*)file; }
if (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0)
err=UNZ_ERRNO;
s = (unz_s*)file;
if (fseek(s->file, s->pos_in_central_dir + s->byte_before_the_zipfile, SEEK_SET) != 0) {
err=UNZ_ERRNO;
}
/* we check the magic */ /* we check the magic */
if (err==UNZ_OK) if (err == UNZ_OK) {
if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) {
err=UNZ_ERRNO; err = UNZ_ERRNO;
else if (uMagic!=0x02014b50) } else if (uMagic != 0x02014b50) {
err=UNZ_BADZIPFILE; err = UNZ_BADZIPFILE;
}
}
if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK) if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK)
err=UNZ_ERRNO; err=UNZ_ERRNO;
@ -1917,98 +1922,102 @@ static int unzlocal_GetCurrentFileInfoInternal (unzFile file,
if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK) if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK)
err=UNZ_ERRNO; err=UNZ_ERRNO;
lSeek+=file_info.size_filename; lSeek += file_info.size_filename;
if ((err==UNZ_OK) && (szFileName!=NULL))
{ if ((err == UNZ_OK) && (szFileName != NULL)) {
uLong uSizeRead ; uLong uSizeRead ;
if (file_info.size_filename<fileNameBufferSize) if (file_info.size_filename<fileNameBufferSize) {
{
*(szFileName+file_info.size_filename)='\0'; *(szFileName+file_info.size_filename)='\0';
uSizeRead = file_info.size_filename; uSizeRead = file_info.size_filename;
} } else {
else
uSizeRead = fileNameBufferSize; uSizeRead = fileNameBufferSize;
}
if ((file_info.size_filename>0) && (fileNameBufferSize>0)) { if ((file_info.size_filename>0) && (fileNameBufferSize>0)) {
size_t gametype; size_t gametype;
if ( unz_GAME_QL == 1 ) { if (unz_GAME_QL == 1) {
gametype = fread_ql(szFileName,(uInt)uSizeRead,1,s->file); gametype = fread_ql(szFileName, (uInt)uSizeRead, 1, s->file);
} else { } else {
gametype = fread(szFileName,(uInt)uSizeRead,1,s->file); gametype = fread(szFileName, (uInt)uSizeRead, 1, s->file);
} }
if (gametype!=1) if (gametype != 1) {
err=UNZ_ERRNO; err = UNZ_ERRNO;
}
} }
lSeek -= uSizeRead; lSeek -= uSizeRead;
} }
if ((err == UNZ_OK) && (extraField != NULL)) {
if ((err==UNZ_OK) && (extraField!=NULL))
{
uLong uSizeRead ; uLong uSizeRead ;
if (file_info.size_file_extra<extraFieldBufferSize) if (file_info.size_file_extra < extraFieldBufferSize) {
uSizeRead = file_info.size_file_extra; uSizeRead = file_info.size_file_extra;
else } else {
uSizeRead = extraFieldBufferSize; uSizeRead = extraFieldBufferSize;
}
if (lSeek!=0) if (lSeek != 0) {
if (fseek(s->file,lSeek,SEEK_CUR)==0) if (fseek(s->file, lSeek, SEEK_CUR) == 0) {
lSeek=0; lSeek=0;
else
err=UNZ_ERRNO;
if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) {
size_t gametype;
if ( unz_GAME_QL == 1 ) {
gametype = fread_ql(extraField,(uInt)uSizeRead,1,s->file);
} else { } else {
gametype = fread(extraField,(uInt)uSizeRead,1,s->file);
}
if (gametype!=1)
err=UNZ_ERRNO; err=UNZ_ERRNO;
}
}
if ((file_info.size_file_extra > 0) && (extraFieldBufferSize > 0)) {
size_t gametype;
if (unz_GAME_QL == 1) {
gametype = fread_ql(extraField, (uInt)uSizeRead, 1, s->file);
} else {
gametype = fread(extraField, (uInt)uSizeRead, 1, s->file);
}
if (gametype != 1) {
err=UNZ_ERRNO;
}
} }
lSeek += file_info.size_file_extra - uSizeRead; lSeek += file_info.size_file_extra - uSizeRead;
} else {
lSeek += file_info.size_file_extra;
} }
else
lSeek+=file_info.size_file_extra;
if ((err == UNZ_OK) && (szComment != NULL)) {
if ((err==UNZ_OK) && (szComment!=NULL))
{
uLong uSizeRead ; uLong uSizeRead ;
if (file_info.size_file_comment<commentBufferSize) if (file_info.size_file_comment < commentBufferSize) {
{ *(szComment+file_info.size_file_comment) = '\0';
*(szComment+file_info.size_file_comment)='\0';
uSizeRead = file_info.size_file_comment; uSizeRead = file_info.size_file_comment;
} } else {
else
uSizeRead = commentBufferSize; uSizeRead = commentBufferSize;
}
if (lSeek!=0) if (lSeek != 0) {
if (fseek(s->file,lSeek,SEEK_CUR)==0) if (fseek(s->file, lSeek, SEEK_CUR) ==0 ) {
lSeek=0; lSeek=0;
else } else {
err=UNZ_ERRNO; err=UNZ_ERRNO;
}
}
if ((file_info.size_file_comment>0) && (commentBufferSize>0)) { if ((file_info.size_file_comment>0) && (commentBufferSize>0)) {
size_t gametype; size_t gametype;
if ( unz_GAME_QL == 1 ) { if (unz_GAME_QL == 1) {
gametype = fread_ql(szComment,(uInt)uSizeRead,1,s->file); gametype = fread_ql(szComment, (uInt)uSizeRead, 1, s->file);
} else { } else {
gametype = fread(szComment,(uInt)uSizeRead,1,s->file); gametype = fread(szComment, (uInt)uSizeRead, 1, s->file);
} }
if (gametype!=1) if (gametype!=1) {
err=UNZ_ERRNO; err=UNZ_ERRNO;
}
} }
lSeek+=file_info.size_file_comment - uSizeRead; lSeek += file_info.size_file_comment - uSizeRead;
} } else {
else
lSeek+=file_info.size_file_comment; lSeek+=file_info.size_file_comment;
}
if ((err==UNZ_OK) && (pfile_info!=NULL)) if ((err==UNZ_OK) && (pfile_info!=NULL)) {
*pfile_info=file_info; *pfile_info=file_info;
}
if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) {
*pfile_info_internal=file_info_internal; *pfile_info_internal=file_info_internal;
}
return err; return err;
} }
@ -2152,16 +2161,18 @@ static int unzlocal_CheckCurrentFileCoherencyHeader (unz_s* s, uInt* piSizeVar,
*poffset_local_extrafield = 0; *poffset_local_extrafield = 0;
*psize_local_extrafield = 0; *psize_local_extrafield = 0;
if (fseek(s->file,s->cur_file_info_internal.offset_curfile + if (fseek(s->file, s->cur_file_info_internal.offset_curfile +
s->byte_before_the_zipfile,SEEK_SET)!=0) s->byte_before_the_zipfile, SEEK_SET) != 0) {
return UNZ_ERRNO; return UNZ_ERRNO;
}
if (err == UNZ_OK) {
if (err==UNZ_OK) if (unzlocal_getLong(s->file, &uMagic) != UNZ_OK) {
if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
err=UNZ_ERRNO; err=UNZ_ERRNO;
else if (uMagic!=0x04034b50) } else if (uMagic!=0x04034b50) {
err=UNZ_BADZIPFILE; err=UNZ_BADZIPFILE;
}
}
if (unzlocal_getShort(s->file,&uData) != UNZ_OK) if (unzlocal_getShort(s->file,&uData) != UNZ_OK)
err=UNZ_ERRNO; err=UNZ_ERRNO;
@ -2210,7 +2221,7 @@ static int unzlocal_CheckCurrentFileCoherencyHeader (unz_s* s, uInt* piSizeVar,
*piSizeVar += (uInt)size_filename; *piSizeVar += (uInt)size_filename;
if (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK) if (unzlocal_getShort(s->file, &size_extra_field) != UNZ_OK)
err=UNZ_ERRNO; err=UNZ_ERRNO;
*poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
SIZEZIPLOCALHEADER + size_filename; SIZEZIPLOCALHEADER + size_filename;
@ -2327,43 +2338,43 @@ extern int unzOpenCurrentFile (unzFile file)
*/ */
extern int unzReadCurrentFile (unzFile file, void *buf, unsigned len) extern int unzReadCurrentFile (unzFile file, void *buf, unsigned len)
{ {
int err=UNZ_OK; int err = UNZ_OK;
uInt iRead = 0; uInt iRead = 0;
unz_s* s; unz_s* s;
file_in_zip_read_info_s* pfile_in_zip_read_info; file_in_zip_read_info_s* pfile_in_zip_read_info;
if (file==NULL) if (file == NULL)
return UNZ_PARAMERROR; return UNZ_PARAMERROR;
s=(unz_s*)file; s = (unz_s*)file;
pfile_in_zip_read_info=s->pfile_in_zip_read; pfile_in_zip_read_info = s->pfile_in_zip_read;
if (pfile_in_zip_read_info==NULL) if (pfile_in_zip_read_info == NULL)
return UNZ_PARAMERROR; return UNZ_PARAMERROR;
if ((pfile_in_zip_read_info->read_buffer == NULL)) if (pfile_in_zip_read_info->read_buffer == NULL)
return UNZ_END_OF_LIST_OF_FILE; return UNZ_END_OF_LIST_OF_FILE;
if (len==0) if (len == 0)
return 0; return 0;
pfile_in_zip_read_info->stream.next_out = (Byte*)buf; pfile_in_zip_read_info->stream.next_out = (Byte*)buf;
pfile_in_zip_read_info->stream.avail_out = (uInt)len; pfile_in_zip_read_info->stream.avail_out = (uInt)len;
if (len>pfile_in_zip_read_info->rest_read_uncompressed) if (len > pfile_in_zip_read_info->rest_read_uncompressed)
pfile_in_zip_read_info->stream.avail_out = pfile_in_zip_read_info->stream.avail_out =
(uInt)pfile_in_zip_read_info->rest_read_uncompressed; (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
while (pfile_in_zip_read_info->stream.avail_out>0) while (pfile_in_zip_read_info->stream.avail_out > 0) {
{ if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
if ((pfile_in_zip_read_info->stream.avail_in==0) && (pfile_in_zip_read_info->rest_read_compressed > 0)) {
(pfile_in_zip_read_info->rest_read_compressed>0))
{
uInt uReadThis = UNZ_BUFSIZE; uInt uReadThis = UNZ_BUFSIZE;
size_t gametype; size_t gametype;
if (pfile_in_zip_read_info->rest_read_compressed<uReadThis) { if (pfile_in_zip_read_info->rest_read_compressed<uReadThis) {
uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed; } uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed; }
if (uReadThis == 0) { if (uReadThis == 0) {
return UNZ_EOF; } return UNZ_EOF;
}
if (s->cur_file_info.compressed_size == pfile_in_zip_read_info->rest_read_compressed) { if (s->cur_file_info.compressed_size == pfile_in_zip_read_info->rest_read_compressed) {
if (fseek(pfile_in_zip_read_info->file, if (fseek(pfile_in_zip_read_info->file,
pfile_in_zip_read_info->pos_in_zipfile + pfile_in_zip_read_info->pos_in_zipfile +
@ -2372,15 +2383,16 @@ extern int unzReadCurrentFile (unzFile file, void *buf, unsigned len)
} }
} }
if ( unz_GAME_QL == 1 ) { if (unz_GAME_QL == 1) {
gametype = fread_ql(pfile_in_zip_read_info->read_buffer,uReadThis,1, gametype = fread_ql(pfile_in_zip_read_info->read_buffer,uReadThis,1,
pfile_in_zip_read_info->file); pfile_in_zip_read_info->file);
} else { } else {
gametype = fread(pfile_in_zip_read_info->read_buffer,uReadThis,1, gametype = fread(pfile_in_zip_read_info->read_buffer,uReadThis,1,
pfile_in_zip_read_info->file); pfile_in_zip_read_info->file);
} }
if (gametype!=1) if (gametype!=1) {
return UNZ_ERRNO; return UNZ_ERRNO;
}
pfile_in_zip_read_info->pos_in_zipfile += uReadThis; pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
pfile_in_zip_read_info->rest_read_compressed-=uReadThis; pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
@ -2390,8 +2402,7 @@ extern int unzReadCurrentFile (unzFile file, void *buf, unsigned len)
pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
} }
if (pfile_in_zip_read_info->compression_method==0) if (pfile_in_zip_read_info->compression_method==0) {
{
uInt uDoCopy,i ; uInt uDoCopy,i ;
if (pfile_in_zip_read_info->stream.avail_out < if (pfile_in_zip_read_info->stream.avail_out <
pfile_in_zip_read_info->stream.avail_in) pfile_in_zip_read_info->stream.avail_in)
@ -2399,9 +2410,9 @@ extern int unzReadCurrentFile (unzFile file, void *buf, unsigned len)
else else
uDoCopy = pfile_in_zip_read_info->stream.avail_in ; uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
for (i=0;i<uDoCopy;i++) for (i = 0; i < uDoCopy; i++)
*(pfile_in_zip_read_info->stream.next_out+i) = *(pfile_in_zip_read_info->stream.next_out + i) =
*(pfile_in_zip_read_info->stream.next_in+i); *(pfile_in_zip_read_info->stream.next_in + i);
pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
pfile_in_zip_read_info->stream.next_out, pfile_in_zip_read_info->stream.next_out,
@ -2413,9 +2424,7 @@ extern int unzReadCurrentFile (unzFile file, void *buf, unsigned len)
pfile_in_zip_read_info->stream.next_in += uDoCopy; pfile_in_zip_read_info->stream.next_in += uDoCopy;
pfile_in_zip_read_info->stream.total_out += uDoCopy; pfile_in_zip_read_info->stream.total_out += uDoCopy;
iRead += uDoCopy; iRead += uDoCopy;
} } else {
else
{
uLong uTotalOutBefore,uTotalOutAfter; uLong uTotalOutBefore,uTotalOutAfter;
const Byte *bufBefore; const Byte *bufBefore;
uLong uOutThis; uLong uOutThis;
@ -2436,22 +2445,20 @@ extern int unzReadCurrentFile (unzFile file, void *buf, unsigned len)
uOutThis = uTotalOutAfter-uTotalOutBefore; uOutThis = uTotalOutAfter-uTotalOutBefore;
pfile_in_zip_read_info->crc32 = pfile_in_zip_read_info->crc32 =
crc32(pfile_in_zip_read_info->crc32,bufBefore, crc32(pfile_in_zip_read_info->crc32, bufBefore, (uInt)(uOutThis));
(uInt)(uOutThis));
pfile_in_zip_read_info->rest_read_uncompressed -= pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis;
uOutThis;
iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
if (err==Z_STREAM_END) if (err == Z_STREAM_END)
return (iRead==0) ? UNZ_EOF : iRead; return (iRead == 0) ? UNZ_EOF : iRead;
if (err!=Z_OK) if (err != Z_OK)
break; break;
} }
} }
if (err==Z_OK) if (err == Z_OK)
return iRead; return iRead;
return err; return err;
} }

View file

@ -251,7 +251,7 @@ void SnapWeldVector( vec3_t a, vec3_t b, vec3_t out ){
{ {
/* round to integer */ /* round to integer */
ai = Q_rint( a[ i ] ); ai = Q_rint( a[ i ] );
bi = Q_rint( a[ i ] ); bi = Q_rint( b[ i ] );
/* prefer exact integer */ /* prefer exact integer */
if ( ai == a[ i ] ) { if ( ai == a[ i ] ) {
@ -262,7 +262,7 @@ void SnapWeldVector( vec3_t a, vec3_t b, vec3_t out ){
} }
/* use nearest */ /* use nearest */
else if ( fabs( ai - a[ i ] ) < fabs( bi < b[ i ] ) ) { else if ( fabs( ai - a[ i ] ) < fabs( bi - b[ i ] ) ) {
out[ i ] = a[ i ]; out[ i ] = a[ i ];
} }
else{ else{

View file

@ -113,7 +113,7 @@ void SetDrawSurfacesBuffer(){
bspDrawSurfaces = safe_malloc_info( sizeof( bspDrawSurface_t ) * numBSPDrawSurfacesBuffer, "IncDrawSurfaces" ); bspDrawSurfaces = safe_malloc_info( sizeof( bspDrawSurface_t ) * numBSPDrawSurfacesBuffer, "IncDrawSurfaces" );
memset( bspDrawSurfaces, 0, MAX_MAP_DRAW_SURFS * sizeof( bspDrawVert_t ) ); memset( bspDrawSurfaces, 0, numBSPDrawSurfacesBuffer * sizeof( bspDrawSurface_t ) );
} }
void SetDrawSurfaces( int n ){ void SetDrawSurfaces( int n ){
@ -126,7 +126,7 @@ void SetDrawSurfaces( int n ){
bspDrawSurfaces = safe_malloc_info( sizeof( bspDrawSurface_t ) * numBSPDrawSurfacesBuffer, "IncDrawSurfaces" ); bspDrawSurfaces = safe_malloc_info( sizeof( bspDrawSurface_t ) * numBSPDrawSurfacesBuffer, "IncDrawSurfaces" );
memset( bspDrawSurfaces, 0, n * sizeof( bspDrawVert_t ) ); memset( bspDrawSurfaces, 0, numBSPDrawSurfacesBuffer * sizeof( bspDrawSurface_t ) );
} }
void BSPFilesCleanup(){ void BSPFilesCleanup(){

View file

@ -63,9 +63,9 @@ void ExportEntities( void ){
strcat( filename, ".ent" ); strcat( filename, ".ent" );
/* sanity check */ /* sanity check */
if ( bspEntData == NULL || bspEntDataSize == 0 ) { if ( bspEntDataSize == 0 ) {
Sys_FPrintf( SYS_WRN, "WARNING: No BSP entity data. aborting...\n" ); Sys_FPrintf( SYS_WRN, "WARNING: No BSP entity data. aborting...\n" );
return; return;
} }
/* write it */ /* write it */

View file

@ -2033,7 +2033,7 @@ void IlluminateRawLightmap( int rawLightmapNum ){
} }
/* set luxel filter radius */ /* set luxel filter radius */
luxelFilterRadius = superSample * filterRadius / lm->sampleSize; luxelFilterRadius = lm->sampleSize != 0 ? superSample * filterRadius / lm->sampleSize : 0;
if ( luxelFilterRadius == 0 && ( filterRadius > 0.0f || filter ) ) { if ( luxelFilterRadius == 0 && ( filterRadius > 0.0f || filter ) ) {
luxelFilterRadius = 1; luxelFilterRadius = 1;
} }

View file

@ -518,7 +518,7 @@ qboolean AddPatchToRawLightmap( int num, rawLightmap_t *lm ){
length = 0; length = 0;
for ( x = 0; x < ( mesh->width - 1 ); x++ ) for ( x = 0; x < ( mesh->width - 1 ); x++ )
length += widthTable[ x ]; length += widthTable[ x ];
lm->w = ceil( length / lm->sampleSize ) + 1; lm->w = lm->sampleSize != 0 ? ceil( length / lm->sampleSize ) + 1 : 0;
if ( lm->w < ds->patchWidth ) { if ( lm->w < ds->patchWidth ) {
lm->w = ds->patchWidth; lm->w = ds->patchWidth;
} }
@ -531,7 +531,7 @@ qboolean AddPatchToRawLightmap( int num, rawLightmap_t *lm ){
length = 0; length = 0;
for ( y = 0; y < ( mesh->height - 1 ); y++ ) for ( y = 0; y < ( mesh->height - 1 ); y++ )
length += heightTable[ y ]; length += heightTable[ y ];
lm->h = ceil( length / lm->sampleSize ) + 1; lm->h = lm->sampleSize != 0 ? ceil( length / lm->sampleSize ) + 1 : 0;
if ( lm->h < ds->patchHeight ) { if ( lm->h < ds->patchHeight ) {
lm->h = ds->patchHeight; lm->h = ds->patchHeight;
} }

View file

@ -622,7 +622,7 @@ typedef struct foliage_s
struct foliage_s *next; struct foliage_s *next;
char model[ MAX_QPATH ]; char model[ MAX_QPATH ];
float scale, density, odds; float scale, density, odds;
qboolean inverseAlpha; int inverseAlpha;
} }
foliage_t; foliage_t;

View file

@ -1467,8 +1467,8 @@ 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( verts, 0, sizeof( *verts ) * maxSurfaceVerts );
memset( indexes, 0, sizeof( indexes ) ); memset( indexes, 0, sizeof( *indexes ) * maxSurfaceIndexes );
/* add the first triangle */ /* add the first triangle */
if ( AddMetaTriangleToSurface( ds, seed, qfalse ) ) { if ( AddMetaTriangleToSurface( ds, seed, qfalse ) ) {