Fix some of the things clang --analyze flagged

This commit is contained in:
Tim Angus 2013-03-26 16:50:03 +00:00
parent 352cd151e0
commit 98360bcd57
34 changed files with 58 additions and 112 deletions

View file

@ -3237,8 +3237,10 @@ aas_lreachability_t *AAS_FindFaceReachabilities(vec3_t *facepoints, int numpoint
// //
if (towardsface) VectorCopy(bestend, testpoint); if (towardsface) VectorCopy(bestend, testpoint);
else VectorCopy(beststart, testpoint); else VectorCopy(beststart, testpoint);
testpoint[2] = 0; if (bestfaceplane != NULL)
testpoint[2] = (bestfaceplane->dist - DotProduct(bestfaceplane->normal, testpoint)) / bestfaceplane->normal[2]; testpoint[2] = (bestfaceplane->dist - DotProduct(bestfaceplane->normal, testpoint)) / bestfaceplane->normal[2];
else
testpoint[2] = 0;
// //
if (!AAS_PointInsideFace(bestfacenum, testpoint, 0.1f)) if (!AAS_PointInsideFace(bestfacenum, testpoint, 0.1f))
{ {
@ -3786,7 +3788,7 @@ int AAS_Reachability_Grapple(int area1num, int area2num)
aas_face_t *face2; aas_face_t *face2;
aas_area_t *area1, *area2; aas_area_t *area1, *area2;
aas_lreachability_t *lreach; aas_lreachability_t *lreach;
vec3_t areastart, facecenter, start, end, dir, down = {0, 0, -1}; vec3_t areastart = {0, 0, 0}, facecenter, start, end, dir, down = {0, 0, -1};
vec_t *v; vec_t *v;
//only grapple when on the ground or swimming //only grapple when on the ground or swimming

View file

@ -168,12 +168,11 @@ void AAS_InitTravelFlagFromType(void)
//=========================================================================== //===========================================================================
static ID_INLINE int AAS_TravelFlagForType_inline(int traveltype) static ID_INLINE int AAS_TravelFlagForType_inline(int traveltype)
{ {
int tfl; int tfl = 0;
tfl = 0; if (traveltype & TRAVELFLAG_NOTTEAM1)
if (tfl & TRAVELFLAG_NOTTEAM1)
tfl |= TFL_NOTTEAM1; tfl |= TFL_NOTTEAM1;
if (tfl & TRAVELFLAG_NOTTEAM2) if (traveltype & TRAVELFLAG_NOTTEAM2)
tfl |= TFL_NOTTEAM2; tfl |= TFL_NOTTEAM2;
traveltype &= TRAVELTYPE_MASK; traveltype &= TRAVELTYPE_MASK;
if (traveltype < 0 || traveltype >= MAX_TRAVELTYPES) if (traveltype < 0 || traveltype >= MAX_TRAVELTYPES)

View file

@ -673,7 +673,7 @@ bot_synonymlist_t *BotLoadSynonyms(char *filename)
else if (!strcmp(token.string, "[")) else if (!strcmp(token.string, "["))
{ {
size += sizeof(bot_synonymlist_t); size += sizeof(bot_synonymlist_t);
if (pass) if (pass && ptr)
{ {
syn = (bot_synonymlist_t *) ptr; syn = (bot_synonymlist_t *) ptr;
ptr += sizeof(bot_synonymlist_t); ptr += sizeof(bot_synonymlist_t);
@ -705,7 +705,7 @@ bot_synonymlist_t *BotLoadSynonyms(char *filename)
len = strlen(token.string) + 1; len = strlen(token.string) + 1;
len = PAD(len, sizeof(long)); len = PAD(len, sizeof(long));
size += sizeof(bot_synonym_t) + len; size += sizeof(bot_synonym_t) + len;
if (pass) if (pass && ptr)
{ {
synonym = (bot_synonym_t *) ptr; synonym = (bot_synonym_t *) ptr;
ptr += sizeof(bot_synonym_t); ptr += sizeof(bot_synonym_t);
@ -725,7 +725,7 @@ bot_synonymlist_t *BotLoadSynonyms(char *filename)
FreeSource(source); FreeSource(source);
return NULL; return NULL;
} //end if } //end if
if (pass) if (pass && ptr)
{ {
synonym->weight = token.floatvalue; synonym->weight = token.floatvalue;
syn->totalweight += synonym->weight; syn->totalweight += synonym->weight;
@ -1003,7 +1003,7 @@ bot_randomlist_t *BotLoadRandomStrings(char *filename)
len = strlen(token.string) + 1; len = strlen(token.string) + 1;
len = PAD(len, sizeof(long)); len = PAD(len, sizeof(long));
size += sizeof(bot_randomlist_t) + len; size += sizeof(bot_randomlist_t) + len;
if (pass) if (pass && ptr)
{ {
random = (bot_randomlist_t *) ptr; random = (bot_randomlist_t *) ptr;
ptr += sizeof(bot_randomlist_t); ptr += sizeof(bot_randomlist_t);
@ -1034,7 +1034,7 @@ bot_randomlist_t *BotLoadRandomStrings(char *filename)
len = strlen(chatmessagestring) + 1; len = strlen(chatmessagestring) + 1;
len = PAD(len, sizeof(long)); len = PAD(len, sizeof(long));
size += sizeof(bot_randomstring_t) + len; size += sizeof(bot_randomstring_t) + len;
if (pass) if (pass && ptr)
{ {
randomstring = (bot_randomstring_t *) ptr; randomstring = (bot_randomstring_t *) ptr;
ptr += sizeof(bot_randomstring_t); ptr += sizeof(bot_randomstring_t);
@ -2113,7 +2113,7 @@ bot_chat_t *BotLoadInitialChat(char *chatfile, char *chatname)
return NULL; return NULL;
} //end if } //end if
StripDoubleQuotes(token.string); StripDoubleQuotes(token.string);
if (pass) if (pass && ptr)
{ {
chattype = (bot_chattype_t *) ptr; chattype = (bot_chattype_t *) ptr;
strncpy(chattype->name, token.string, MAX_CHATTYPE_NAME); strncpy(chattype->name, token.string, MAX_CHATTYPE_NAME);
@ -2136,7 +2136,7 @@ bot_chat_t *BotLoadInitialChat(char *chatfile, char *chatname)
} //end if } //end if
len = strlen(chatmessagestring) + 1; len = strlen(chatmessagestring) + 1;
len = PAD(len, sizeof(long)); len = PAD(len, sizeof(long));
if (pass) if (pass && ptr)
{ {
chatmessage = (bot_chatmessage_t *) ptr; chatmessage = (bot_chatmessage_t *) ptr;
chatmessage->time = -2*CHATMESSAGE_RECENTTIME; chatmessage->time = -2*CHATMESSAGE_RECENTTIME;
@ -2583,7 +2583,6 @@ void BotInitialChat(int chatstate, char *type, int mcontext, char *var0, char *v
strcat(match.string, var7); strcat(match.string, var7);
match.variables[7].offset = index; match.variables[7].offset = index;
match.variables[7].length = strlen(var7); match.variables[7].length = strlen(var7);
index += strlen(var7);
} }
// //
BotConstructChatMessage(cs, message, mcontext, &match, 0, qfalse); BotConstructChatMessage(cs, message, mcontext, &match, 0, qfalse);
@ -2766,7 +2765,6 @@ int BotReplyChat(int chatstate, char *message, int mcontext, int vcontext, char
strcat(bestmatch.string, var7); strcat(bestmatch.string, var7);
bestmatch.variables[7].offset = index; bestmatch.variables[7].offset = index;
bestmatch.variables[7].length = strlen(var7); bestmatch.variables[7].length = strlen(var7);
index += strlen(var7);
} }
if (LibVarGetValue("bot_testrchat")) if (LibVarGetValue("bot_testrchat"))
{ {

View file

@ -446,12 +446,6 @@ void BotResetWeaponState(int weaponstate)
ws = BotWeaponStateFromHandle(weaponstate); ws = BotWeaponStateFromHandle(weaponstate);
if (!ws) return; if (!ws) return;
weaponweightconfig = ws->weaponweightconfig;
weaponweightindex = ws->weaponweightindex;
//Com_Memset(ws, 0, sizeof(bot_weaponstate_t));
ws->weaponweightconfig = weaponweightconfig;
ws->weaponweightindex = weaponweightindex;
} //end of the function BotResetWeaponState } //end of the function BotResetWeaponState
//======================================================================== //========================================================================
// //

View file

@ -272,7 +272,6 @@ fuzzyseperator_t *ReadFuzzySeperators_r(source_t *source)
fs->child = NULL; fs->child = NULL;
if (lastfs) lastfs->next = fs; if (lastfs) lastfs->next = fs;
else firstfs = fs; else firstfs = fs;
lastfs = fs;
} //end if } //end if
// //
return firstfs; return firstfs;

View file

@ -414,7 +414,6 @@ int PC_ReadDefineParms(source_t *source, define_t *define, token_t **parms, int
if (indent <= 0) if (indent <= 0)
{ {
if (lastcomma) SourceWarning(source, "too many comma's"); if (lastcomma) SourceWarning(source, "too many comma's");
lastcomma = 1;
break; break;
} //end if } //end if
} //end if } //end if
@ -783,7 +782,7 @@ int PC_ExpandBuiltinDefine(source_t *source, token_t *deftoken, define_t *define
int PC_ExpandDefine(source_t *source, token_t *deftoken, define_t *define, int PC_ExpandDefine(source_t *source, token_t *deftoken, define_t *define,
token_t **firsttoken, token_t **lasttoken) token_t **firsttoken, token_t **lasttoken)
{ {
token_t *parms[MAX_DEFINEPARMS], *dt, *pt, *t; token_t *parms[MAX_DEFINEPARMS] = { NULL }, *dt, *pt, *t;
token_t *t1, *t2, *first, *last, *nextpt, token; token_t *t1, *t2, *first, *last, *nextpt, token;
int parmnum, i; int parmnum, i;
@ -1209,12 +1208,6 @@ int PC_Directive_define(source_t *source)
//unread the define name before executing the #undef directive //unread the define name before executing the #undef directive
PC_UnreadSourceToken(source, &token); PC_UnreadSourceToken(source, &token);
if (!PC_Directive_undef(source)) return qfalse; if (!PC_Directive_undef(source)) return qfalse;
//if the define was not removed (define->flags & DEFINE_FIXED)
#if DEFINEHASHING
define = PC_FindHashedDefine(source->definehash, token.string);
#else
define = PC_FindDefine(source->defines, token.string);
#endif //DEFINEHASHING
} //end if } //end if
//allocate define //allocate define
define = (define_t *) GetMemory(sizeof(define_t)); define = (define_t *) GetMemory(sizeof(define_t));
@ -2096,7 +2089,6 @@ int PC_EvaluateTokens(source_t *source, token_t *tokens, signed long int *intval
if (v->prev) v->prev->next = v->next; if (v->prev) v->prev->next = v->next;
else firstvalue = v->next; else firstvalue = v->next;
if (v->next) v->next->prev = v->prev; if (v->next) v->next->prev = v->prev;
else lastvalue = v->prev;
//FreeMemory(v); //FreeMemory(v);
FreeValue(v); FreeValue(v);
} //end if } //end if
@ -2104,7 +2096,6 @@ int PC_EvaluateTokens(source_t *source, token_t *tokens, signed long int *intval
if (o->prev) o->prev->next = o->next; if (o->prev) o->prev->next = o->next;
else firstoperator = o->next; else firstoperator = o->next;
if (o->next) o->next->prev = o->prev; if (o->next) o->next->prev = o->prev;
else lastoperator = o->prev;
//FreeMemory(o); //FreeMemory(o);
FreeOperator(o); FreeOperator(o);
} //end while } //end while

View file

@ -615,8 +615,6 @@ void Con_DrawNotify (void)
Field_BigDraw( &chatField, skip * BIGCHAR_WIDTH, v, Field_BigDraw( &chatField, skip * BIGCHAR_WIDTH, v,
SCREEN_WIDTH - ( skip + 1 ) * BIGCHAR_WIDTH, qtrue, qtrue ); SCREEN_WIDTH - ( skip + 1 ) * BIGCHAR_WIDTH, qtrue, qtrue );
v += BIGCHAR_HEIGHT;
} }
} }

View file

@ -310,7 +310,7 @@ void S_AdpcmEncodeSound( sfx_t *sfx, short *samples ) {
newchunk = SND_malloc(); newchunk = SND_malloc();
if (sfx->soundData == NULL) { if (sfx->soundData == NULL) {
sfx->soundData = newchunk; sfx->soundData = newchunk;
} else { } else if (chunk != NULL) {
chunk->next = newchunk; chunk->next = newchunk;
} }
chunk = newchunk; chunk = newchunk;

View file

@ -1452,7 +1452,6 @@ void S_UpdateBackgroundTrack( void ) {
r = S_CodecReadStream(s_backgroundStream, fileBytes, raw); r = S_CodecReadStream(s_backgroundStream, fileBytes, raw);
if(r < fileBytes) if(r < fileBytes)
{ {
fileBytes = r;
fileSamples = r / (s_backgroundStream->info.width * s_backgroundStream->info.channels); fileSamples = r / (s_backgroundStream->info.width * s_backgroundStream->info.channels);
} }

View file

@ -598,7 +598,7 @@ void S_PaintChannelFromMuLaw( channel_t *ch, sfx_t *sc, int count, int sampleOff
samp[i].left += (data * leftvol)>>8; samp[i].left += (data * leftvol)>>8;
samp[i].right += (data * rightvol)>>8; samp[i].right += (data * rightvol)>>8;
samples++; samples++;
if (samples == (byte *)chunk->sndChunk+(SND_CHUNK_SIZE*2)) { if (chunk != NULL && samples == (byte *)chunk->sndChunk+(SND_CHUNK_SIZE*2)) {
chunk = chunk->next; chunk = chunk->next;
samples = (byte *)chunk->sndChunk; samples = (byte *)chunk->sndChunk;
} }

View file

@ -2496,8 +2496,6 @@ qboolean S_AL_Init( soundInterface_t *si )
devicelist += curlen + 1; devicelist += curlen + 1;
} }
} }
else
devicelist = "";
s_alAvailableDevices = Cvar_Get("s_alAvailableDevices", devicenames, CVAR_ROM | CVAR_NORESTART); s_alAvailableDevices = Cvar_Get("s_alAvailableDevices", devicenames, CVAR_ROM | CVAR_NORESTART);
} }

View file

@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
void daub4(float b[], unsigned long n, int isign) void daub4(float b[], unsigned long n, int isign)
{ {
float wksp[4097]; float wksp[4097] = { 0.0f };
float *a=b-1; // numerical recipies so a[1] = b[0] float *a=b-1; // numerical recipies so a[1] = b[0]
unsigned long nh,nh1,i,j; unsigned long nh,nh1,i,j;
@ -146,7 +146,7 @@ void encodeWavelet( sfx_t *sfx, short *packets) {
newchunk = SND_malloc(); newchunk = SND_malloc();
if (sfx->soundData == NULL) { if (sfx->soundData == NULL) {
sfx->soundData = newchunk; sfx->soundData = newchunk;
} else { } else if (chunk != NULL) {
chunk->next = newchunk; chunk->next = newchunk;
} }
chunk = newchunk; chunk = newchunk;
@ -215,7 +215,7 @@ void encodeMuLaw( sfx_t *sfx, short *packets) {
newchunk = SND_malloc(); newchunk = SND_malloc();
if (sfx->soundData == NULL) { if (sfx->soundData == NULL) {
sfx->soundData = newchunk; sfx->soundData = newchunk;
} else { } else if (chunk != NULL) {
chunk->next = newchunk; chunk->next = newchunk;
} }
chunk = newchunk; chunk = newchunk;

View file

@ -309,8 +309,8 @@ ClipWindingEpsilon
void ClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist, void ClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist,
vec_t epsilon, winding_t **front, winding_t **back) vec_t epsilon, winding_t **front, winding_t **back)
{ {
vec_t dists[MAX_POINTS_ON_WINDING+4]; vec_t dists[MAX_POINTS_ON_WINDING+4] = { 0 };
int sides[MAX_POINTS_ON_WINDING+4]; int sides[MAX_POINTS_ON_WINDING+4] = { 0 };
int counts[3]; int counts[3];
static vec_t dot; // VC 4.2 optimizer bug if not static static vec_t dot; // VC 4.2 optimizer bug if not static
int i, j; int i, j;
@ -421,8 +421,8 @@ ChopWindingInPlace
void ChopWindingInPlace (winding_t **inout, vec3_t normal, vec_t dist, vec_t epsilon) void ChopWindingInPlace (winding_t **inout, vec3_t normal, vec_t dist, vec_t epsilon)
{ {
winding_t *in; winding_t *in;
vec_t dists[MAX_POINTS_ON_WINDING+4]; vec_t dists[MAX_POINTS_ON_WINDING+4] = { 0 };
int sides[MAX_POINTS_ON_WINDING+4]; int sides[MAX_POINTS_ON_WINDING+4] = { 0 };
int counts[3]; int counts[3];
static vec_t dot; // VC 4.2 optimizer bug if not static static vec_t dot; // VC 4.2 optimizer bug if not static
int i, j; int i, j;

View file

@ -650,8 +650,12 @@ void CM_TraceThroughBrush( traceWork_t *tw, cbrush_t *brush ) {
enterFrac = 0; enterFrac = 0;
} }
tw->trace.fraction = enterFrac; tw->trace.fraction = enterFrac;
tw->trace.plane = *clipplane; if (clipplane != NULL) {
tw->trace.surfaceFlags = leadside->surfaceFlags; tw->trace.plane = *clipplane;
}
if (leadside != NULL) {
tw->trace.surfaceFlags = leadside->surfaceFlags;
}
tw->trace.contents = brush->contents; tw->trace.contents = brush->contents;
} }
} }

View file

@ -887,9 +887,6 @@ void Z_Free( void *ptr ) {
block->size += other->size; block->size += other->size;
block->next = other->next; block->next = other->next;
block->next->prev = block; block->next->prev = block;
if (other == zone->rover) {
zone->rover = block;
}
} }
} }

View file

@ -1671,7 +1671,6 @@ int FS_Seek( fileHandle_t f, long offset, int origin ) {
_origin = SEEK_SET; _origin = SEEK_SET;
break; break;
default: default:
_origin = SEEK_CUR;
Com_Error( ERR_FATAL, "Bad origin in FS_Seek" ); Com_Error( ERR_FATAL, "Bad origin in FS_Seek" );
break; break;
} }

View file

@ -405,7 +405,6 @@ void Huff_Compress(msg_t *mbuf, int offset) {
huff.tree->weight = 0; huff.tree->weight = 0;
huff.lhead->next = huff.lhead->prev = NULL; huff.lhead->next = huff.lhead->prev = NULL;
huff.tree->parent = huff.tree->left = huff.tree->right = NULL; huff.tree->parent = huff.tree->left = huff.tree->right = NULL;
huff.loc[NYT] = huff.tree;
seq[0] = (size>>8); seq[0] = (size>>8);
seq[1] = size&0xff; seq[1] = size&0xff;
@ -442,6 +441,5 @@ void Huff_Init(huffman_t *huff) {
huff->compressor.tree->weight = 0; huff->compressor.tree->weight = 0;
huff->compressor.lhead->next = huff->compressor.lhead->prev = NULL; huff->compressor.lhead->next = huff->compressor.lhead->prev = NULL;
huff->compressor.tree->parent = huff->compressor.tree->left = huff->compressor.tree->right = NULL; huff->compressor.tree->parent = huff->compressor.tree->left = huff->compressor.tree->right = NULL;
huff->compressor.loc[NYT] = huff->compressor.tree;
} }

View file

@ -713,18 +713,13 @@ local int unzlocal_GetCurrentFileInfoInternal (file,
if (lSeek!=0) if (lSeek!=0)
{ {
if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)!=0)
lSeek=0;
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))
if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead) if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead)
err=UNZ_ERRNO; err=UNZ_ERRNO;
lSeek+=file_info.size_file_comment - uSizeRead;
} }
else
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;
@ -1144,13 +1139,12 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
pfile_in_zip_read_info->stream.next_in = (voidpf)0; pfile_in_zip_read_info->stream.next_in = (voidpf)0;
pfile_in_zip_read_info->stream.avail_in = 0; pfile_in_zip_read_info->stream.avail_in = 0;
err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); if (inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS) == Z_OK)
if (err == Z_OK)
pfile_in_zip_read_info->stream_initialised=1; pfile_in_zip_read_info->stream_initialised=1;
else else
{ {
TRYFREE(pfile_in_zip_read_info); TRYFREE(pfile_in_zip_read_info);
return err; return UNZ_INTERNALERROR;
} }
/* windowBits is passed < 0 to tell that there is no zlib header. /* windowBits is passed < 0 to tell that there is no zlib header.
* Note that in this case inflate *requires* an extra "dummy" byte * Note that in this case inflate *requires* an extra "dummy" byte
@ -1197,7 +1191,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
# endif # endif
return UNZ_OK; return err;
} }
extern int ZEXPORT unzOpenCurrentFile (file) extern int ZEXPORT unzOpenCurrentFile (file)

View file

@ -119,7 +119,6 @@ void R_LoadBMP( const char *name, byte **pic, int *width, int *height )
ri.Error( ERR_DROP, "LoadBMP: header too short (%s)", name ); ri.Error( ERR_DROP, "LoadBMP: header too short (%s)", name );
Com_Memcpy( bmpHeader.palette, buf_p, sizeof( bmpHeader.palette ) ); Com_Memcpy( bmpHeader.palette, buf_p, sizeof( bmpHeader.palette ) );
buf_p += sizeof(bmpHeader.palette);
} }
if (buffer.b + bmpHeader.bitmapDataOffset > end) if (buffer.b + bmpHeader.bitmapDataOffset > end)

View file

@ -540,7 +540,6 @@ static uint32_t DecompressIDATs(struct BufferedFile *BF, uint8_t **Buffer)
*/ */
DecompressedData = NULL; DecompressedData = NULL;
DecompressedDataLength = 0;
*Buffer = DecompressedData; *Buffer = DecompressedData;
CompressedData = NULL; CompressedData = NULL;

View file

@ -192,11 +192,6 @@ void R_LoadTGA ( const char *name, byte **pic, int *width, int *height)
else if (targa_header.image_type==10) { // Runlength encoded RGB images else if (targa_header.image_type==10) { // Runlength encoded RGB images
unsigned char red,green,blue,alphabyte,packetHeader,packetSize,j; unsigned char red,green,blue,alphabyte,packetHeader,packetSize,j;
red = 0;
green = 0;
blue = 0;
alphabyte = 0xff;
for(row=rows-1; row>=0; row--) { for(row=rows-1; row>=0; row--) {
pixbuf = targa_rgba + row*columns*4; pixbuf = targa_rgba + row*columns*4;
for(column=0; column<columns; ) { for(column=0; column<columns; ) {

View file

@ -53,7 +53,9 @@ void GL_Bind( image_t *image ) {
} }
if ( glState.currenttextures[glState.currenttmu] != texnum ) { if ( glState.currenttextures[glState.currenttmu] != texnum ) {
image->frameUsed = tr.frameCount; if ( image ) {
image->frameUsed = tr.frameCount;
}
glState.currenttextures[glState.currenttmu] = texnum; glState.currenttextures[glState.currenttmu] = texnum;
qglBindTexture (GL_TEXTURE_2D, texnum); qglBindTexture (GL_TEXTURE_2D, texnum);
} }
@ -215,7 +217,7 @@ void GL_State( unsigned long stateBits )
// //
if ( diff & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) ) if ( diff & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) )
{ {
GLenum srcFactor, dstFactor; GLenum srcFactor = GL_ONE, dstFactor = GL_ONE;
if ( stateBits & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) ) if ( stateBits & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) )
{ {
@ -249,7 +251,6 @@ void GL_State( unsigned long stateBits )
srcFactor = GL_SRC_ALPHA_SATURATE; srcFactor = GL_SRC_ALPHA_SATURATE;
break; break;
default: default:
srcFactor = GL_ONE; // to get warning to shut up
ri.Error( ERR_DROP, "GL_State: invalid src blend state bits" ); ri.Error( ERR_DROP, "GL_State: invalid src blend state bits" );
break; break;
} }
@ -281,7 +282,6 @@ void GL_State( unsigned long stateBits )
dstFactor = GL_ONE_MINUS_DST_ALPHA; dstFactor = GL_ONE_MINUS_DST_ALPHA;
break; break;
default: default:
dstFactor = GL_ONE; // to get warning to shut up
ri.Error( ERR_DROP, "GL_State: invalid dst blend state bits" ); ri.Error( ERR_DROP, "GL_State: invalid dst blend state bits" );
break; break;
} }
@ -545,8 +545,8 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
// change the tess parameters if needed // change the tess parameters if needed
// a "entityMergable" shader is a shader that can have surfaces from seperate // a "entityMergable" shader is a shader that can have surfaces from seperate
// entities merged into a single batch, like smoke and blood puff sprites // entities merged into a single batch, like smoke and blood puff sprites
if (shader != oldShader || fogNum != oldFogNum || dlighted != oldDlighted if ( shader != NULL && ( shader != oldShader || fogNum != oldFogNum || dlighted != oldDlighted
|| ( entityNum != oldEntityNum && !shader->entityMergable ) ) { || ( entityNum != oldEntityNum && !shader->entityMergable ) ) ) {
if (oldShader != NULL) { if (oldShader != NULL) {
RB_EndSurface(); RB_EndSurface();
} }

View file

@ -326,7 +326,6 @@ static void ResampleTexture( unsigned *in, int inwidth, int inheight, unsigned *
for (i=0 ; i<outheight ; i++, out += outwidth) { for (i=0 ; i<outheight ; i++, out += outwidth) {
inrow = in + inwidth*(int)((i+0.25)*inheight/outheight); inrow = in + inwidth*(int)((i+0.25)*inheight/outheight);
inrow2 = in + inwidth*(int)((i+0.75)*inheight/outheight); inrow2 = in + inwidth*(int)((i+0.75)*inheight/outheight);
frac = fracstep >> 1;
for (j=0 ; j<outwidth ; j++) { for (j=0 ; j<outwidth ; j++) {
pix1 = (byte *)inrow + p1[j]; pix1 = (byte *)inrow + p1[j];
pix2 = (byte *)inrow + p2[j]; pix2 = (byte *)inrow + p2[j];

View file

@ -812,10 +812,6 @@ static qboolean IsMirror( const drawSurf_t *drawSurf, int entityNum )
// translate the original plane // translate the original plane
originalPlane.dist = originalPlane.dist + DotProduct( originalPlane.normal, tr.or.origin ); originalPlane.dist = originalPlane.dist + DotProduct( originalPlane.normal, tr.or.origin );
} }
else
{
plane = originalPlane;
}
// locate the portal entity closest to this plane. // locate the portal entity closest to this plane.
// origin will be the origin of the portal, origin2 will be // origin will be the origin of the portal, origin2 will be

View file

@ -41,8 +41,8 @@ Out must have space for two more vertexes than in
static void R_ChopPolyBehindPlane( int numInPoints, vec3_t inPoints[MAX_VERTS_ON_POLY], static void R_ChopPolyBehindPlane( int numInPoints, vec3_t inPoints[MAX_VERTS_ON_POLY],
int *numOutPoints, vec3_t outPoints[MAX_VERTS_ON_POLY], int *numOutPoints, vec3_t outPoints[MAX_VERTS_ON_POLY],
vec3_t normal, vec_t dist, vec_t epsilon) { vec3_t normal, vec_t dist, vec_t epsilon) {
float dists[MAX_VERTS_ON_POLY+4]; float dists[MAX_VERTS_ON_POLY+4] = { 0 };
int sides[MAX_VERTS_ON_POLY+4]; int sides[MAX_VERTS_ON_POLY+4] = { 0 };
int counts[3]; int counts[3];
float dot; float dot;
int i, j; int i, j;

View file

@ -1590,7 +1590,7 @@ static qboolean ParseShader( char **text )
// light <value> determines flaring in q3map, not needed here // light <value> determines flaring in q3map, not needed here
else if ( !Q_stricmp(token, "light") ) else if ( !Q_stricmp(token, "light") )
{ {
token = COM_ParseExt( text, qfalse ); (void)COM_ParseExt( text, qfalse );
continue; continue;
} }
// cull <face> // cull <face>

View file

@ -530,7 +530,7 @@ R_ClusterPVS
============== ==============
*/ */
static const byte *R_ClusterPVS (int cluster) { static const byte *R_ClusterPVS (int cluster) {
if (!tr.world || !tr.world->vis || cluster < 0 || cluster >= tr.world->numClusters ) { if (!tr.world->vis || cluster < 0 || cluster >= tr.world->numClusters ) {
return tr.world->novis; return tr.world->novis;
} }

View file

@ -53,7 +53,9 @@ void GL_Bind2( image_t *image, GLenum type ) {
} }
if ( glState.currenttextures[glState.currenttmu] != texnum ) { if ( glState.currenttextures[glState.currenttmu] != texnum ) {
image->frameUsed = tr.frameCount; if ( image ) {
image->frameUsed = tr.frameCount;
}
glState.currenttextures[glState.currenttmu] = texnum; glState.currenttextures[glState.currenttmu] = texnum;
qglBindTexture (type, texnum); qglBindTexture (type, texnum);
} }
@ -251,7 +253,7 @@ void GL_State( unsigned long stateBits )
// //
if ( diff & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) ) if ( diff & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) )
{ {
GLenum srcFactor, dstFactor; GLenum srcFactor = GL_ONE, dstFactor = GL_ONE;
if ( stateBits & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) ) if ( stateBits & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) )
{ {
@ -285,7 +287,6 @@ void GL_State( unsigned long stateBits )
srcFactor = GL_SRC_ALPHA_SATURATE; srcFactor = GL_SRC_ALPHA_SATURATE;
break; break;
default: default:
srcFactor = GL_ONE; // to get warning to shut up
ri.Error( ERR_DROP, "GL_State: invalid src blend state bits" ); ri.Error( ERR_DROP, "GL_State: invalid src blend state bits" );
break; break;
} }
@ -317,7 +318,6 @@ void GL_State( unsigned long stateBits )
dstFactor = GL_ONE_MINUS_DST_ALPHA; dstFactor = GL_ONE_MINUS_DST_ALPHA;
break; break;
default: default:
dstFactor = GL_ONE; // to get warning to shut up
ri.Error( ERR_DROP, "GL_State: invalid dst blend state bits" ); ri.Error( ERR_DROP, "GL_State: invalid dst blend state bits" );
break; break;
} }
@ -607,7 +607,6 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
oldDlighted = qfalse; oldDlighted = qfalse;
oldPshadowed = qfalse; oldPshadowed = qfalse;
oldSort = -1; oldSort = -1;
depthRange = qfalse;
depth[0] = 0.f; depth[0] = 0.f;
depth[1] = 1.f; depth[1] = 1.f;
@ -630,8 +629,8 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
// change the tess parameters if needed // change the tess parameters if needed
// a "entityMergable" shader is a shader that can have surfaces from seperate // a "entityMergable" shader is a shader that can have surfaces from seperate
// entities merged into a single batch, like smoke and blood puff sprites // entities merged into a single batch, like smoke and blood puff sprites
if (shader != oldShader || fogNum != oldFogNum || dlighted != oldDlighted || pshadowed != oldPshadowed if ( shader != NULL && ( shader != oldShader || fogNum != oldFogNum || dlighted != oldDlighted || pshadowed != oldPshadowed
|| ( entityNum != oldEntityNum && !shader->entityMergable ) ) { || ( entityNum != oldEntityNum && !shader->entityMergable ) ) ) {
if (oldShader != NULL) { if (oldShader != NULL) {
RB_EndSurface(); RB_EndSurface();
} }
@ -756,7 +755,6 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
} }
if (inQuery) { if (inQuery) {
inQuery = qfalse;
qglEndQueryARB(GL_SAMPLES_PASSED_ARB); qglEndQueryARB(GL_SAMPLES_PASSED_ARB);
} }

View file

@ -2123,8 +2123,6 @@ static void R_CreateWorldVBO(void)
} }
startTime = ri.Milliseconds();
ri.Free(surfacesSorted); ri.Free(surfacesSorted);
ri.Hunk_FreeTempMemory(triangles); ri.Hunk_FreeTempMemory(triangles);
@ -2151,7 +2149,6 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) {
numTriSurfs = 0; numTriSurfs = 0;
numFlares = 0; numFlares = 0;
in = (void *)(fileBase + surfs->fileofs);
if (surfs->filelen % sizeof(*in)) if (surfs->filelen % sizeof(*in))
ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name);
count = surfs->filelen / sizeof(*in); count = surfs->filelen / sizeof(*in);

View file

@ -326,7 +326,6 @@ static void ResampleTexture( byte *in, int inwidth, int inheight, byte *out,
for (i=0 ; i<outheight ; i++) { for (i=0 ; i<outheight ; i++) {
inrow = in + 4*inwidth*(int)((i+0.25)*inheight/outheight); inrow = in + 4*inwidth*(int)((i+0.25)*inheight/outheight);
inrow2 = in + 4*inwidth*(int)((i+0.75)*inheight/outheight); inrow2 = in + 4*inwidth*(int)((i+0.75)*inheight/outheight);
frac = fracstep >> 1;
for (j=0 ; j<outwidth ; j++) { for (j=0 ; j<outwidth ; j++) {
pix1 = inrow + p1[j]; pix1 = inrow + p1[j];
pix2 = inrow + p2[j]; pix2 = inrow + p2[j];
@ -957,7 +956,7 @@ static void DoLinear(byte *in, byte *out, int width, int height)
for (y = 1; y < height - 1; y += 2) for (y = 1; y < height - 1; y += 2)
{ {
byte sd[4], se[4], sh[4], si[4]; byte sd[4] = {0}, se[4] = {0}, sh[4] = {0}, si[4] = {0};
byte *line2, *line3; byte *line2, *line3;
x = 1; x = 1;
@ -1572,8 +1571,8 @@ static void RawImage_ScaleToPower2( byte **data, int *inout_width, int *inout_he
{ {
int width = *inout_width; int width = *inout_width;
int height = *inout_height; int height = *inout_height;
int scaled_width = *inout_scaled_width; int scaled_width;
int scaled_height = *inout_scaled_height; int scaled_height;
qboolean picmip = flags & IMGFLAG_PICMIP; qboolean picmip = flags & IMGFLAG_PICMIP;
qboolean mipmap = flags & IMGFLAG_MIPMAP; qboolean mipmap = flags & IMGFLAG_MIPMAP;
qboolean clampToEdge = flags & IMGFLAG_CLAMPTOEDGE; qboolean clampToEdge = flags & IMGFLAG_CLAMPTOEDGE;
@ -1769,7 +1768,6 @@ static GLenum RawImage_GetFormat(const byte *data, int numPixels, qboolean light
} }
else if(lightMap) else if(lightMap)
{ {
samples = 4;
if(r_greyscale->integer) if(r_greyscale->integer)
internalFormat = GL_LUMINANCE; internalFormat = GL_LUMINANCE;
else else

View file

@ -1557,10 +1557,6 @@ static qboolean IsMirror( const drawSurf_t *drawSurf, int entityNum )
// translate the original plane // translate the original plane
originalPlane.dist = originalPlane.dist + DotProduct( originalPlane.normal, tr.or.origin ); originalPlane.dist = originalPlane.dist + DotProduct( originalPlane.normal, tr.or.origin );
} }
else
{
plane = originalPlane;
}
// locate the portal entity closest to this plane. // locate the portal entity closest to this plane.
// origin will be the origin of the portal, origin2 will be // origin will be the origin of the portal, origin2 will be

View file

@ -41,8 +41,8 @@ Out must have space for two more vertexes than in
static void R_ChopPolyBehindPlane( int numInPoints, vec3_t inPoints[MAX_VERTS_ON_POLY], static void R_ChopPolyBehindPlane( int numInPoints, vec3_t inPoints[MAX_VERTS_ON_POLY],
int *numOutPoints, vec3_t outPoints[MAX_VERTS_ON_POLY], int *numOutPoints, vec3_t outPoints[MAX_VERTS_ON_POLY],
vec3_t normal, vec_t dist, vec_t epsilon) { vec3_t normal, vec_t dist, vec_t epsilon) {
float dists[MAX_VERTS_ON_POLY+4]; float dists[MAX_VERTS_ON_POLY+4] = { 0 };
int sides[MAX_VERTS_ON_POLY+4]; int sides[MAX_VERTS_ON_POLY+4] = { 0 };
int counts[3]; int counts[3];
float dot; float dot;
int i, j; int i, j;

View file

@ -1766,7 +1766,7 @@ static qboolean ParseShader( char **text )
// light <value> determines flaring in q3map, not needed here // light <value> determines flaring in q3map, not needed here
else if ( !Q_stricmp(token, "light") ) else if ( !Q_stricmp(token, "light") )
{ {
token = COM_ParseExt( text, qfalse ); COM_ParseExt( text, qfalse );
continue; continue;
} }
// cull <face> // cull <face>
@ -2907,7 +2907,6 @@ static shader_t *FinishShader( void ) {
// //
if ( stage > 1 && ( (r_vertexLight->integer && !r_uiFullScreen->integer) || glConfig.hardwareType == GLHW_PERMEDIA2 ) ) { if ( stage > 1 && ( (r_vertexLight->integer && !r_uiFullScreen->integer) || glConfig.hardwareType == GLHW_PERMEDIA2 ) ) {
VertexLightingCollapse(); VertexLightingCollapse();
stage = 1;
hasLightmapStage = qfalse; hasLightmapStage = qfalse;
} }

View file

@ -635,7 +635,7 @@ R_ClusterPVS
============== ==============
*/ */
static const byte *R_ClusterPVS (int cluster) { static const byte *R_ClusterPVS (int cluster) {
if (!tr.world || !tr.world->vis || cluster < 0 || cluster >= tr.world->numClusters ) { if (!tr.world->vis || cluster < 0 || cluster >= tr.world->numClusters ) {
return tr.world->novis; return tr.world->novis;
} }