Removed most warnings except for array bound.

Some logic changes has happened where I was certain that there was a bug.
This commit is contained in:
sago007
2018-02-06 20:27:38 +01:00
parent bf8b294d46
commit 8c43d3368f
9 changed files with 222 additions and 251 deletions

View File

@@ -1772,6 +1772,8 @@ int AAS_AreaTravelTimeToGoalArea(int areanum, vec3_t origin, int goalareanum, in
{ {
int traveltime, reachnum; int traveltime, reachnum;
traveltime = 0;
reachnum = 0;
if (AAS_AreaRouteToGoalArea(areanum, origin, goalareanum, travelflags, &traveltime, &reachnum)) if (AAS_AreaRouteToGoalArea(areanum, origin, goalareanum, travelflags, &traveltime, &reachnum))
{ {
return traveltime; return traveltime;
@@ -1788,6 +1790,8 @@ int AAS_AreaReachabilityToGoalArea(int areanum, vec3_t origin, int goalareanum,
{ {
int traveltime, reachnum; int traveltime, reachnum;
traveltime = 0;
reachnum = 0;
if (AAS_AreaRouteToGoalArea(areanum, origin, goalareanum, travelflags, &traveltime, &reachnum)) if (AAS_AreaRouteToGoalArea(areanum, origin, goalareanum, travelflags, &traveltime, &reachnum))
{ {
return reachnum; return reachnum;

View File

@@ -577,8 +577,12 @@ static unsigned short yuv_to_rgb( long y, long u, long v )
g = (YY + ROQ_UG_tab[u] + ROQ_VG_tab[v]) >> 8; g = (YY + ROQ_UG_tab[u] + ROQ_VG_tab[v]) >> 8;
b = (YY + ROQ_UB_tab[u]) >> 9; b = (YY + ROQ_UB_tab[u]) >> 9;
if (r<0) r = 0; if (g<0) g = 0; if (b<0) b = 0; if (r<0) r = 0;
if (r > 31) r = 31; if (g > 63) g = 63; if (b > 31) b = 31; if (g<0) g = 0;
if (b<0) b = 0;
if (r > 31) r = 31;
if (g > 63) g = 63;
if (b > 31) b = 31;
return (unsigned short)((r<<11)+(g<<5)+(b)); return (unsigned short)((r<<11)+(g<<5)+(b));
} }
@@ -598,8 +602,12 @@ static unsigned int yuv_to_rgb24( long y, long u, long v )
g = (YY + ROQ_UG_tab[u] + ROQ_VG_tab[v]) >> 6; g = (YY + ROQ_UG_tab[u] + ROQ_VG_tab[v]) >> 6;
b = (YY + ROQ_UB_tab[u]) >> 6; b = (YY + ROQ_UB_tab[u]) >> 6;
if (r<0) r = 0; if (g<0) g = 0; if (b<0) b = 0; if (r<0) r = 0;
if (r > 255) r = 255; if (g > 255) g = 255; if (b > 255) b = 255; if (g<0) g = 0;
if (b<0) b = 0;
if (r > 255) r = 255;
if (g > 255) g = 255;
if (b > 255) b = 255;
return LittleLong ((r)|(g<<8)|(b<<16)|(255<<24)); return LittleLong ((r)|(g<<8)|(b<<16)|(255<<24));
} }

View File

@@ -146,7 +146,7 @@ void mumble_set_identity(const char* identity)
size_t len; size_t len;
if (!lm) if (!lm)
return; return;
len = MIN(sizeof(lm->identity), strlen(identity)+1); len = MIN(sizeof(lm->identity)/sizeof(wchar_t), strlen(identity)+1);
mbstowcs(lm->identity, identity, len); mbstowcs(lm->identity, identity, len);
} }

View File

@@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define C2 0.2241438680420134 #define C2 0.2241438680420134
#define C3 -0.1294095225512604 #define C3 -0.1294095225512604
void daub4(float b[], unsigned long n, int isign) static void daub4(float b[], unsigned long n, int isign)
{ {
float wksp[4097] = { 0.0f }; 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]
@@ -57,7 +57,7 @@ void daub4(float b[], unsigned long n, int isign)
} }
} }
void wt1(float a[], unsigned long n, int isign) static void wt1(float a[], unsigned long n, int isign)
{ {
unsigned long nn; unsigned long nn;
int inverseStartLength = n/4; int inverseStartLength = n/4;

View File

@@ -175,25 +175,7 @@ or configs will never get loaded from disk!
// every time a new demo pk3 file is built, this checksum must be updated. // every time a new demo pk3 file is built, this checksum must be updated.
// the easiest way to get it is to just run the game and see what it spits out // the easiest way to get it is to just run the game and see what it spits out
#define DEMO_PAK0_CHECKSUM 2985612116u #define DEMO_PAK0_CHECKSUM 2985612116u
static const unsigned int pak_checksums[] = {
1566731103u,
298122907u,
412165236u,
2991495316u,
1197932710u,
4087071573u,
3709064859u,
908855077u,
977125798u
};
static const unsigned int missionpak_checksums[] =
{
2430342401u,
511014160u,
2662638993u,
1438664554u
};
// if this is defined, the executable positively won't work with any paks other // if this is defined, the executable positively won't work with any paks other
// than the demo pak, even if productid is present. This is only used for our // than the demo pak, even if productid is present. This is only used for our

View File

@@ -1481,7 +1481,6 @@ void R_MblurScreen( void );
void R_MblurScreenPost( void ); void R_MblurScreenPost( void );
void RB_UpdateMotionBlur (void){ void RB_UpdateMotionBlur (void){
// leilei - motion blur hack // leilei - motion blur hack
int e;
numofmotionpasses = 4; numofmotionpasses = 4;
numofmotionpasses = backEnd.refdef.time - backEnd.refdef.floatTime / 1000.0f; numofmotionpasses = backEnd.refdef.time - backEnd.refdef.floatTime / 1000.0f;
@@ -1551,9 +1550,6 @@ int mblurredframes;
int mblurredframestotal; int mblurredframestotal;
void RB_AccumBlurValue (void) void RB_AccumBlurValue (void)
{ {
int ah, tim, oltim;
oltim = time_last * 10;
tim = time_now * 10;
// calculate how much we need, determined by motion blur fps // calculate how much we need, determined by motion blur fps
mblur_time = time_now - time_last; mblur_time = time_now - time_last;
mbluracc = (mblur_time) / 32; mbluracc = (mblur_time) / 32;
@@ -1566,7 +1562,6 @@ void RB_DrawAccumBlur (void)
{ {
static int blurstate = 0; static int blurstate = 0;
float accblur; float accblur;
static float damagetime = -1.0f;
if (r_tvMode->integer > -1) return; // tvmode causes this to crash if (r_tvMode->integer > -1) return; // tvmode causes this to crash
if (!r_motionblur->integer) return; if (!r_motionblur->integer) return;

View File

@@ -2214,7 +2214,7 @@ void R_PaletteScreen( void )
// WATER BUFFER TEST // WATER BUFFER TEST
// ================================================================= // =================================================================
#if 0
static struct { static struct {
// NO! // NO!
} water; } water;
@@ -2224,7 +2224,7 @@ static void R_Water_InitTextures( void )
{ {
// NO! // NO!
} }
#endif
@@ -2234,7 +2234,7 @@ void R_InitWaterTextures( void )
} }
#if 0
static void R_Water_BackupScreen( void ) static void R_Water_BackupScreen( void )
{ {
// NO! // NO!
@@ -2250,7 +2250,7 @@ static void R_Water_RestoreScreen( void )
{ {
// NO! // NO!
} }
#endif
void R_WaterInit( void ) void R_WaterInit( void )
{ {

View File

@@ -99,8 +99,9 @@ byte BestColor (int r, int g, int b, int start, int stop)
berstcolor = i; berstcolor = i;
} }
} }
if (berstcolor) if (berstcolor) {
//ri.Printf( PRINT_ALL, "returned %i\n", berstcolor ); //ri.Printf( PRINT_ALL, "returned %i\n", berstcolor );
}
return berstcolor; return berstcolor;
} }
@@ -211,17 +212,14 @@ void R_GLSLPalette_f ( )
void R_InitPalette( void ) { void R_InitPalette( void ) {
byte *buff; byte *buff;
int len;
int i, v; int i, v;
ri.Printf( PRINT_ALL, "INIT PALETTE......\n"); ri.Printf( PRINT_ALL, "INIT PALETTE......\n");
len = ri.FS_ReadFile("gfx/palette.lmp", (void **)&buff); ri.FS_ReadFile("gfx/palette.lmp", (void **)&buff);
if(!buff){ if(!buff){
ri.Printf( PRINT_ALL, "PALLETE FALED :(!\n" );
paletteavailable = 0; // Don't have a palette
ri.Printf( PRINT_ALL, "PALLETE FALED :(!\n" ); paletteenabled = 0; // Don't do 8-bit textures
paletteavailable = 0; // Don't have a palette
paletteenabled = 0; // Don't do 8-bit textures
return; return;
} }
@@ -229,21 +227,23 @@ void R_InitPalette( void ) {
ri.Printf( PRINT_ALL, "PALETTE LOADDEEEED!!!!!!!!!!!!1\n" ); ri.Printf( PRINT_ALL, "PALETTE LOADDEEEED!!!!!!!!!!!!1\n" );
paletteavailable = 1; // Do have a palette paletteavailable = 1; // Do have a palette
if (palettedTextureSupport) if (palettedTextureSupport) {
paletteability = 1; paletteability = 1;
else }
else {
paletteability = 0; paletteability = 0;
}
// change the transparent color to black // change the transparent color to black
palettemain[255*3] = 0; palettemain[255*3] = 0;
palettemain[255*3+1] = 0; palettemain[255*3+1] = 0;
palettemain[255*3+2] = 0; palettemain[255*3+2] = 0;
if (paletteability) // load this palette for GL if (paletteability) // load this palette for GL
{ {
qglEnable( GL_SHARED_TEXTURE_PALETTE_EXT ); qglEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
R_SetTexturePalette( palettemain ); R_SetTexturePalette( (unsigned*)palettemain );
R_SetPalette(palettemain); R_SetPalette(palettemain);
} }
@@ -252,13 +252,10 @@ void R_InitPalette( void ) {
{ {
int r, g, b, beastcolor; int r, g, b, beastcolor;
ri.Printf( PRINT_ALL, "15bpp lookup generation.\n" ); ri.Printf( PRINT_ALL, "15bpp lookup generation.\n" );
for (r=0 ; r<256 ; r+=8) for (r=0 ; r<256 ; r+=8) {
{
ri.Printf( PRINT_ALL, "." ); ri.Printf( PRINT_ALL, "." );
for (g=0 ; g<256 ; g+=8) for (g=0 ; g<256 ; g+=8) {
{ for (b=0 ; b<256 ; b+=8) {
for (b=0 ; b<256 ; b+=8)
{
beastcolor = BestColor (r, g, b, 1, 254); beastcolor = BestColor (r, g, b, 1, 254);
palmap[r>>3][g>>3][b>>3] = beastcolor; palmap[r>>3][g>>3][b>>3] = beastcolor;
} }
@@ -269,16 +266,15 @@ void R_InitPalette( void ) {
{ {
int re, ge, be; int re, ge, be;
for (i=0 ; i<256 ; i++) for (i=0 ; i<256 ; i++){
{ re = palettemain[0];
re = palettemain[0]; ge = palettemain[1];
ge = palettemain[1]; be = palettemain[2];
be = palettemain[2]; palettemain += 3;
palettemain += 3;
v = (255<<24) + (re<<0) + (ge<<8) + (be<<16); v = (255<<24) + (re<<0) + (ge<<8) + (be<<16);
d_8to24table[i] = v; d_8to24table[i] = v;
} }
} }
} }
@@ -354,7 +350,7 @@ void GL_TextureMode( const char *string ) {
// hack to prevent trilinear from being set on voodoo, // hack to prevent trilinear from being set on voodoo,
// because their driver freaks... // because their driver freaks...
if ( i == 5 && glConfig.hardwareType == GLHW_3DFX_2D3D || r_leifx->integer ) { if ( (i == 5 && glConfig.hardwareType == GLHW_3DFX_2D3D) || r_leifx->integer ) {
ri.Printf( PRINT_ALL, "Refusing to set trilinear on a voodoo.\n" ); ri.Printf( PRINT_ALL, "Refusing to set trilinear on a voodoo.\n" );
i = 3; i = 3;
} }
@@ -562,30 +558,22 @@ R_ImageListMapOnly_f
void R_ImageListMapOnly_f( void ) { void R_ImageListMapOnly_f( void ) {
int i; int i;
for ( i = 0 ; i < tr.numImages ; i++ ) for ( i = 0 ; i < tr.numImages ; i++ ) {
{
image_t *image = tr.images[i]; image_t *image = tr.images[i];
char *zipcommand = "zip -9 "; char *zipcommand = "zip -9 ";
char localName[ MAX_QPATH ]; char localName[ MAX_QPATH ];
char *sizeSuffix;
int estSize; int estSize;
int displaySize;
estSize = image->uploadHeight * image->uploadWidth; estSize = image->uploadHeight * image->uploadWidth;
// mipmap adds about 50% // mipmap adds about 50%
if (image->flags & IMGFLAG_MIPMAP) if (image->flags & IMGFLAG_MIPMAP)
estSize += estSize / 2; estSize += estSize / 2;
sizeSuffix = "b ";
displaySize = estSize;
//if ( !strncmp( image->imgName, "textures", 8 ) ) { if (image->maptexture) {
if (image->maptexture){ COM_StripExtension( image->imgName, localName, MAX_QPATH );
ri.Printf(PRINT_ALL, "%s pak1-map-mapname.pk3 %s.*\n", zipcommand, localName);
COM_StripExtension( image->imgName, localName, MAX_QPATH );
ri.Printf(PRINT_ALL, "%s pak1-map-mapname.pk3 %s.*\n", zipcommand, localName);
} }
} }
@@ -923,7 +911,7 @@ static void R_MipMap (byte *in, int width, int height) {
static void R_MipMap8 (byte *in, int width, int height) static void R_MipMap8 (byte *in, int width, int height)
{ {
int i, j; int i, j;
byte *out, *at1;//, *at2, *at3, *at4; byte *out, at1;//, *at2, *at3, *at4;
height >>= 1; height >>= 1;
out = in; out = in;
@@ -1052,71 +1040,70 @@ static void DumpTex( unsigned *data,
{ {
// leilei - Do crazy dumping crap // leilei - Do crazy dumping crap
byte *scan; byte *scan;
byte *baffer, *alffer, *flipper; byte *baffer, *alffer, *flipper;
scan = ((byte *)data); scan = ((byte *)data);
size_t offset = 0;//, memcount; int padlen = 0;
int padlen = 0; int be, ber;
int be, ber; int scrale = width * height;
int scrale = width * height; int hasalf = 0;
int scravg = width + height / 2; float countw = 0;
int quality = 85; // estimate quality from total size #if 0
int hasalf = 0; int scravg = width + height / 2;
float countw = 0; int quality = 85; // estimate quality from total size
if (scravg > 511) quality = 42; // huge textures
if (scravg > 511) quality = 42; // huge textures else if (scravg > 255) quality = 62; // large textures
else if (scravg > 255) quality = 62; // large textures else if (scravg > 127) quality = 72; // large textures
else if (scravg > 127) quality = 72; // large textures else if (scravg < 127) quality = 95; // tiny textures
else if (scravg < 127) quality = 95; // tiny textures #endif
baffer = ri.Hunk_AllocateTempMemory( width * height * 3 ); baffer = ri.Hunk_AllocateTempMemory( width * height * 3 );
flipper = ri.Hunk_AllocateTempMemory( width * height * 3 ); flipper = ri.Hunk_AllocateTempMemory( width * height * 3 );
alffer = ri.Hunk_AllocateTempMemory( width * height * 3 ); alffer = ri.Hunk_AllocateTempMemory( width * height * 3 );
// TODO: Save alpha separately // TODO: Save alpha separately
// I'm gonna flip...... // I'm gonna flip......
int alfcnt = 0; int alfcnt = 0;
for (be=0; be<scrale; be++){ for (be=0; be<scrale; be++){
int bib; int bib;
if (countw > width) if (countw > width)
countw = 0; countw = 0;
else else
countw++; countw++;
ber = scrale - be - 1; ber = scrale - be - 1;
bib = be; bib = be;
if (bib < 0) bib = 0; if (bib < 0) bib = 0;
if (bib > scrale) bib = 0; if (bib > scrale) bib = 0;
baffer[bib*3] = scan[ber*4]; baffer[bib*3] = scan[ber*4];
baffer[bib*3+1] = scan[ber*4+1]; baffer[bib*3+1] = scan[ber*4+1];
baffer[bib*3+2] = scan[ber*4+2]; baffer[bib*3+2] = scan[ber*4+2];
alffer[bib*3] = scan[ber*4+3]; alffer[bib*3] = scan[ber*4+3];
alffer[bib*3+1] = scan[ber*4+3]; alffer[bib*3+1] = scan[ber*4+3];
alffer[bib*3+2] = scan[ber*4+3]; alffer[bib*3+2] = scan[ber*4+3];
if (scan[ber*4+3] > 1){ hasalf = 1;} if (scan[ber*4+3] > 1){ hasalf = 1;}
if (scan[ber*4+3] == 255){ alfcnt += 1; } if (scan[ber*4+3] == 255){ alfcnt += 1; }
} }
// NOW FIX IT // NOW FIX IT
//memcount = (width * 3 + padlen) * height;
if ((width > 16) && (height > 16)){
//memcount = (width * 3 + padlen) * height;
if ((width > 16) && (height > 16)){
RE_SaveJPG( va("dump/%s.jpg", dumpname), 85,width, height, baffer, padlen); RE_SaveJPG( va("dump/%s.jpg", dumpname), 85,width, height, baffer, padlen);
if (hasalf) if (hasalf) {
RE_SaveJPG( va("dump/%s_alpha.jpg", dumpname), 85,width, height, alffer, padlen); RE_SaveJPG( va("dump/%s_alpha.jpg", dumpname), 85,width, height, alffer, padlen);
} }
ri.Printf( PRINT_ALL, "TEXDUMP: %s \n", dumpname ); }
ri.Printf( PRINT_ALL, "TEXDUMP: %s \n", dumpname );
// if ( baffer != 0 ) // if ( baffer != 0 )
ri.Hunk_FreeTempMemory( baffer ); ri.Hunk_FreeTempMemory( baffer );
// if ( alffer != 0 ) // if ( alffer != 0 )
ri.Hunk_FreeTempMemory( alffer ); ri.Hunk_FreeTempMemory( alffer );
ri.Hunk_FreeTempMemory( flipper ); ri.Hunk_FreeTempMemory( flipper );
} }
@@ -1132,7 +1119,6 @@ static void Upload32( unsigned *data,
unsigned *scaledBuffer = NULL; unsigned *scaledBuffer = NULL;
unsigned *resampledBuffer = NULL; unsigned *resampledBuffer = NULL;
int scaled_width, scaled_height; int scaled_width, scaled_height;
int orig_width, orig_height;
int i, c; int i, c;
byte *scan; byte *scan;
GLenum internalFormat = GL_RGB; GLenum internalFormat = GL_RGB;
@@ -1145,9 +1131,6 @@ static void Upload32( unsigned *data,
if (lightMap && r_parseStageSimple->integer) hackoperation = 4; if (lightMap && r_parseStageSimple->integer) hackoperation = 4;
// leilei - npot support
orig_width = width;
orig_height = height;
// //
// convert to exact power of 2 sizes // convert to exact power of 2 sizes
@@ -1317,7 +1300,6 @@ static void Upload32( unsigned *data,
{ {
int r, g, b; int r, g, b;
vec3_t rgb; vec3_t rgb;
float amplify;
byte alfa = LUMA(scan[i*4], scan[i*4 + 1], scan[i*4 + 2]); byte alfa = LUMA(scan[i*4], scan[i*4 + 1], scan[i*4 + 2]);
//byte alfa = (scan[i*4]+ scan[i*4 + 1]+ scan[i*4 + 2]) / 3; //byte alfa = (scan[i*4]+ scan[i*4 + 1]+ scan[i*4 + 2]) / 3;
@@ -1975,12 +1957,9 @@ static void Upload8( unsigned *data,
if (paletteability) if (paletteability)
R_PickTexturePalette(1); R_PickTexturePalette(1);
// Preparing for native upload
if (paletteability && !isalphaedrgba) // Preparing for native upload if (paletteability && !isalphaedrgba) {
{ for ( i = 0; i < c; i++ ) {
for ( i = 0; i < c; i++ )
{
int thecol; int thecol;
int r, g, b, a; int r, g, b, a;
r = scan[i*4]; r = scan[i*4];
@@ -1992,17 +1971,15 @@ static void Upload8( unsigned *data,
a /= 255; a /= 255;
a *= 255; a *= 255;
if (!a){ if (!a){
thecol = 255; // transparent color thecol = 255; // transparent color
} }
scan[i] = thecol; scan[i] = thecol;
samples = 1; samples = 1;
} }
} }
else // Preparing for simulated RGBA upload else {
{ // Preparing for simulated RGBA upload
for ( i = 0; i < c; i++ ) for ( i = 0; i < c; i++ ) {
{
int thecol; int thecol;
int r, g, b, a; int r, g, b, a;
unsigned char *pix24; unsigned char *pix24;
@@ -2012,42 +1989,33 @@ static void Upload8( unsigned *data,
a = scan[i*4 +3]; a = scan[i*4 +3];
thecol = palmap[r>>3][g>>3][b>>3]; thecol = palmap[r>>3][g>>3][b>>3];
a *= 1.9; a *= 1.9;
a /= 255; a /= 255;
a *= 255; a *= 255;
pix24 = (unsigned char *)&d_8to24table[thecol]; pix24 = (unsigned char *)&d_8to24table[thecol];
if (!a){ if (!a) {
thecol = 255; // transparent color thecol = 255; // transparent color
samples = 4; samples = 4;
} }
scan[i*4] = pix24[0]; scan[i*4] = pix24[0];
scan[i*4+1] = pix24[1]; scan[i*4+1] = pix24[1];
scan[i*4+2] = pix24[2]; scan[i*4+2] = pix24[2];
scan[i*4+3] = a; scan[i*4+3] = a;
} }
} }
{ {
// select proper internal format // select proper internal format
if ( samples == 1 ) {
// leilei - gl has no knowledge of a paletted format, so use this for imagelist
if ( samples == 1 ) internalFormat = GL_LUMINANCE;
{
internalFormat = GL_LUMINANCE; // leilei - gl has no knowledge of a paletted format, so use this for imagelist
} }
else if ( samples == 3 ) else if ( samples == 3 ) {
{
internalFormat = GL_RGB; internalFormat = GL_RGB;
} }
else if ( samples == 4 ) else if ( samples == 4 ) {
{
internalFormat = GL_RGBA; internalFormat = GL_RGBA;
} }
@@ -2058,33 +2026,36 @@ static void Upload8( unsigned *data,
if ( ( scaled_width == width ) && if ( ( scaled_width == width ) && ( scaled_height == height ) ) {
( scaled_height == height ) ) { if (!mipmap) {
if (!mipmap) if (paletteability && !isalphaedrgba) {
{ qglTexImage2D( GL_TEXTURE_2D, 0, palettedformat, scaled_width, scaled_height, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, data);
if (paletteability && !isalphaedrgba) }
qglTexImage2D( GL_TEXTURE_2D, 0, palettedformat, scaled_width, scaled_height, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, data); else {
else qglTexImage2D (GL_TEXTURE_2D, 0, internalFormat, scaled_width, scaled_height, 0, temp_GLformat, temp_GLtype, data);
qglTexImage2D (GL_TEXTURE_2D, 0, internalFormat, scaled_width, scaled_height, 0, temp_GLformat, temp_GLtype, data); }
*pUploadWidth = scaled_width; *pUploadWidth = scaled_width;
*pUploadHeight = scaled_height; *pUploadHeight = scaled_height;
*format = internalFormat; *format = internalFormat;
goto done; goto done;
} }
if (!paletteability || isalphaedrgba) if (!paletteability || isalphaedrgba) {
Com_Memcpy (scaledBuffer, data, width*height*4); Com_Memcpy (scaledBuffer, data, width*height*4);
else Com_Memcpy (scaledBuffer, data, width*height); }
else {
Com_Memcpy (scaledBuffer, data, width*height);
}
} }
else else {
{
// use the normal mip-mapping function to go down from here // use the normal mip-mapping function to go down from here
while ( width > scaled_width || height > scaled_height ) { while ( width > scaled_width || height > scaled_height ) {
if (paletteability && !isalphaedrgba) if (paletteability && !isalphaedrgba) {
R_MipMap8( (byte *)data, width, height ); R_MipMap8( (byte *)data, width, height );
else }
R_MipMap( (byte *)data, width, height ); else {
R_MipMap( (byte *)data, width, height );
}
width >>= 1; width >>= 1;
height >>= 1; height >>= 1;
if ( width < 1 ) { if ( width < 1 ) {
@@ -2094,9 +2065,12 @@ static void Upload8( unsigned *data,
height = 1; height = 1;
} }
} }
if (!paletteability || isalphaedrgba) if (!paletteability || isalphaedrgba) {
Com_Memcpy( scaledBuffer, data, width * height * 4 ); Com_Memcpy( scaledBuffer, data, width * height * 4 );
else Com_Memcpy( scaledBuffer, data, width * height); }
else {
Com_Memcpy( scaledBuffer, data, width * height);
}
} }
@@ -2105,63 +2079,68 @@ static void Upload8( unsigned *data,
*format = internalFormat; *format = internalFormat;
if (paletteability && !isalphaedrgba) if (paletteability && !isalphaedrgba) {
qglTexImage2D( GL_TEXTURE_2D, 0, palettedformat, scaled_width, scaled_height, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, scaledBuffer ); qglTexImage2D( GL_TEXTURE_2D, 0, palettedformat, scaled_width, scaled_height, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, scaledBuffer );
else }
qglTexImage2D (GL_TEXTURE_2D, 0, internalFormat, scaled_width, scaled_height, 0, temp_GLformat, temp_GLtype, scaledBuffer ); else {
qglTexImage2D (GL_TEXTURE_2D, 0, internalFormat, scaled_width, scaled_height, 0, temp_GLformat, temp_GLtype, scaledBuffer );
}
if (mipmap) if (mipmap)
{ {
int miplevel; int miplevel;
miplevel = 0; miplevel = 0;
while (scaled_width > 1 || scaled_height > 1) while (scaled_width > 1 || scaled_height > 1) {
{ if (paletteability && !isalphaedrgba) {
if (paletteability && !isalphaedrgba) R_MipMap8( (byte *)scaledBuffer, scaled_width, scaled_height );
R_MipMap8( (byte *)scaledBuffer, scaled_width, scaled_height ); }
else else {
R_MipMap( (byte *)scaledBuffer, scaled_width, scaled_height ); R_MipMap( (byte *)scaledBuffer, scaled_width, scaled_height );
}
scaled_width >>= 1; scaled_width >>= 1;
scaled_height >>= 1; scaled_height >>= 1;
if (scaled_width < 1) if (scaled_width < 1) {
scaled_width = 1; scaled_width = 1;
if (scaled_height < 1) }
if (scaled_height < 1) {
scaled_height = 1; scaled_height = 1;
}
miplevel++; miplevel++;
if (paletteability && !isalphaedrgba) if (paletteability && !isalphaedrgba) {
qglTexImage2D( GL_TEXTURE_2D, miplevel, palettedformat, scaled_width, scaled_height, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, scaledBuffer ); qglTexImage2D( GL_TEXTURE_2D, miplevel, palettedformat, scaled_width, scaled_height, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, scaledBuffer );
else }
qglTexImage2D (GL_TEXTURE_2D, miplevel, internalFormat, scaled_width, scaled_height, 0, temp_GLformat, temp_GLtype, scaledBuffer ); else {
qglTexImage2D (GL_TEXTURE_2D, miplevel, internalFormat, scaled_width, scaled_height, 0, temp_GLformat, temp_GLtype, scaledBuffer );
}
} }
} }
done: done:
if (mipmap) if (mipmap) {
{ if ( textureFilterAnisotropic ) {
if ( textureFilterAnisotropic )
qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT,
(GLint)Com_Clamp( 1, maxAnisotropy, r_ext_max_anisotropy->integer ) ); (GLint)Com_Clamp( 1, maxAnisotropy, r_ext_max_anisotropy->integer ) );
}
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
} }
else else {
{ if ( textureFilterAnisotropic ) {
if ( textureFilterAnisotropic )
qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1 ); qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1 );
}
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
} }
if (softwaremode) { // leilei - software speedup if (softwaremode) {
// leilei - software speedup
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
} }
GL_CheckErrors(); GL_CheckErrors();
@@ -2240,28 +2219,29 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height,
GL_Bind(image); GL_Bind(image);
// leilei - texture dumping // leilei - texture dumping
if (r_texdump->integer){ if (r_texdump->integer) {
COM_StripExtension( name, dumpname, MAX_QPATH ); // leilei - transfer name for texdump COM_StripExtension( name, dumpname, MAX_QPATH ); // leilei - transfer name for texdump
DumpTex( (unsigned *)pic, image->width, image->height); DumpTex( (unsigned *)pic, image->width, image->height);
} }
if (paletteavailable && r_texturebits->integer == 8 && !isLightmap && !depthimage && !force32upload) if (paletteavailable && r_texturebits->integer == 8 && !isLightmap && !depthimage && !force32upload) {
Upload8( (unsigned *)pic, image->width, image->height, Upload8( (unsigned *)pic, image->width, image->height,
image->flags & IMGFLAG_MIPMAP, image->flags & IMGFLAG_MIPMAP,
image->flags & IMGFLAG_PICMIP, image->flags & IMGFLAG_PICMIP,
isLightmap, isLightmap,
&image->internalFormat, &image->internalFormat,
&image->uploadWidth, &image->uploadWidth,
&image->uploadHeight ); &image->uploadHeight );
}
else else {
Upload32( (unsigned *)pic, image->width, image->height, Upload32( (unsigned *)pic, image->width, image->height,
image->flags & IMGFLAG_MIPMAP, image->flags & IMGFLAG_MIPMAP,
image->flags & IMGFLAG_PICMIP, image->flags & IMGFLAG_PICMIP,
isLightmap, isLightmap,
&image->internalFormat, &image->internalFormat,
&image->uploadWidth, &image->uploadWidth,
&image->uploadHeight ); &image->uploadHeight );
}
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, glWrapClampMode ); qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, glWrapClampMode );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, glWrapClampMode ); qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, glWrapClampMode );
@@ -2410,7 +2390,6 @@ image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags )
long hash; long hash;
float oldtime; float oldtime;
float loadtime; float loadtime;
float proctime;
if (!name) { if (!name) {
return NULL; return NULL;
@@ -2439,15 +2418,16 @@ image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags )
if ( !Q_strncmp( name, "textures/detail/", 16 ) || !Q_strncmp( name, "gfx/fx/detail/", 14 )) { if ( !Q_strncmp( name, "textures/detail/", 16 ) || !Q_strncmp( name, "gfx/fx/detail/", 14 )) {
ri.Printf( PRINT_DEVELOPER, "DETAILHACK: %s - mips will be gray\n", name ); ri.Printf( PRINT_DEVELOPER, "DETAILHACK: %s - mips will be gray\n", name );
detailhack = 1; // leilei - attempt to fade detail mips to gray, EXPECTS DST_COLOR/SRC_COLOR for this to work right detailhack = 1; // leilei - attempt to fade detail mips to gray, EXPECTS DST_COLOR/SRC_COLOR for this to work right
} }
// leilei - iconmip hack // leilei - iconmip hack
if ( !Q_strncmp( name, "icons/", 5 ) || ((!Q_strncmp( name, "gfx/2d", 6 )) && (Q_strncmp( name, "gfx/2d/bigchars", 14 )))){ if ( !Q_strncmp( name, "icons/", 5 ) || ((!Q_strncmp( name, "gfx/2d", 6 )) && (Q_strncmp( name, "gfx/2d/bigchars", 14 )))) {
isicon = 1; isicon = 1;
} }
else else {
isicon = 0; isicon = 0;
}
// //
// load the pic from disk // load the pic from disk
@@ -2455,7 +2435,7 @@ image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags )
oldtime = ri.Milliseconds() * 100; oldtime = ri.Milliseconds() * 100;
dontgotsafe = 0; dontgotsafe = 0;
if (r_suggestiveThemes->integer == 1) dontgotsafe = 1; if (r_suggestiveThemes->integer == 1) { dontgotsafe = 1; }
// leilei - load safe or lewd textures if desired. // leilei - load safe or lewd textures if desired.
@@ -2467,7 +2447,7 @@ image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags )
char narm[ MAX_QPATH ]; char narm[ MAX_QPATH ];
COM_StripExtension( name, narm, MAX_QPATH ); COM_StripExtension( name, narm, MAX_QPATH );
R_LoadImage( va("%s_safe", narm), &pic, &width, &height ); R_LoadImage( va("%s_safe", narm), &pic, &width, &height );
if ( pic == NULL ) if ( pic == NULL )
dontgotsafe = 1; dontgotsafe = 1;
else else
dontgotsafe = 0; dontgotsafe = 0;
@@ -2482,7 +2462,6 @@ image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags )
dontgotsafe = 1; dontgotsafe = 1;
else else
dontgotsafe = 0; dontgotsafe = 0;
} }
} }
@@ -2505,23 +2484,23 @@ image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags )
// leilei - if we need to change the texture upload with a special image prefix to separate from differently blended things // leilei - if we need to change the texture upload with a special image prefix to separate from differently blended things
if (hackoperation) if (hackoperation) {
{ char hackName[MAX_QPATH];
char hackName[MAX_QPATH]; char *hackedName;
char *hackedName; COM_StripExtension( name, hackName, MAX_QPATH );
COM_StripExtension( name, hackName, MAX_QPATH ); if(hackoperation==1) hackedName = va("%shackadd", hackName);
if(hackoperation==1) hackedName = va("%shackadd", hackName); if(hackoperation==2) hackedName = va("%shacknob", hackName);
if(hackoperation==2) hackedName = va("%shacknob", hackName); if(hackoperation==3) hackedName = va("%shacksub", hackName);
if(hackoperation==3) hackedName = va("%shacksub", hackName); if(hackoperation==4) {
if(hackoperation==4) hackedName = va("%shackmod", hackName); hackedName = va("%shackmod", hackName);
else hackedName = va("%shackblend", hackName);
image = R_CreateImage( ( char * ) hackedName, pic, width, height, type, flags, 0 );
} }
else {
else hackedName = va("%shackblend", hackName);
}
{ image = R_CreateImage( ( char * ) hackedName, pic, width, height, type, flags, 0 );
image = R_CreateImage( ( char * ) name, pic, width, height, type, flags, 0 ); }
else {
image = R_CreateImage( ( char * ) name, pic, width, height, type, flags, 0 );
} }
@@ -2577,7 +2556,7 @@ image_t *R_FindImageFileIfItsThere( const char *name, imgType_t type, imgFlags_t
if ( !Q_strncmp( name, "textures/detail/", 16 ) || !Q_strncmp( name, "gfx/fx/detail/", 14 )) { if ( !Q_strncmp( name, "textures/detail/", 16 ) || !Q_strncmp( name, "gfx/fx/detail/", 14 )) {
ri.Printf( PRINT_DEVELOPER, "DETAILHACK: %s - mips will be gray\n", name ); ri.Printf( PRINT_DEVELOPER, "DETAILHACK: %s - mips will be gray\n", name );
detailhack = 1; // leilei - attempt to fade detail mips to gray, EXPECTS DST_COLOR/SRC_COLOR for this to work right detailhack = 1; // leilei - attempt to fade detail mips to gray, EXPECTS DST_COLOR/SRC_COLOR for this to work right
} }
// //
// load the pic from disk // load the pic from disk

View File

@@ -2246,6 +2246,7 @@ void LFX_ShaderInit ( void )
void LFX_ParticleEffect1996 (int effect, const vec3_t org, const vec3_t dir) void LFX_ParticleEffect1996 (int effect, const vec3_t org, const vec3_t dir)
{ {
vec3_t notatall; vec3_t notatall;
memset(&notatall, 0, sizeof(notatall));
// Smoke trails on grenades and rockets // Smoke trails on grenades and rockets
if (effect == 1) { if (effect == 1) {
@@ -2868,12 +2869,13 @@ void LFX_ParticleEffect200X (int effect, const vec3_t org, const vec3_t dir)
// - high atlas usage // - high atlas usage
void LFX_ParticleEffect1997 (int effect, const vec3_t org, const vec3_t dir) void LFX_ParticleEffect1997 (int effect, const vec3_t org, const vec3_t dir)
{ {
#if 0
vec3_t origin, sprOrg, sprVel; // laziness vec3_t origin, sprOrg, sprVel; // laziness
vec4_t colory, colory2, colory3, colory4;
VectorCopy(org, sprOrg); VectorCopy(org, sprOrg);
VectorCopy(org, origin); VectorCopy(org, origin);
VectorCopy(dir, sprVel); VectorCopy(dir, sprVel);
#endif
// Smoke trails on grenades and rockets // Smoke trails on grenades and rockets
// this should be several smoke atlases along a line. // this should be several smoke atlases along a line.
@@ -2918,9 +2920,9 @@ void LFX_ParticleEffect1997 (int effect, const vec3_t org, const vec3_t dir)
} }
#if 0
// Blood Sprays for bullets // Blood Sprays for bullets
vec4_t colory, colory2, colory3, colory4;
if (effect == 14 && com_blood->integer) { if (effect == 14 && com_blood->integer) {
colory[0] = 1.0; colory[0] = 1.0;
colory[1] = 0.0; colory[1] = 0.0;
@@ -2941,6 +2943,7 @@ void LFX_ParticleEffect1997 (int effect, const vec3_t org, const vec3_t dir)
//R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 6.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 800 + (random()*2000), 2, 8+ (random()*6), 0); //R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 6.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 800 + (random()*2000), 2, 8+ (random()*6), 0);
//R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 3.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 300 + (random()*2000), 2, 8+ (random()*6), 4); //R_LFX_Smoke2 (sprOrg, sprVel, 2 + (random()*6), 3.54+ (random()*8.7), colory, colory2, colory3, colory4, colory4, 1, 300 + (random()*2000), 2, 8+ (random()*6), 4);
} }
#endif
// "Blood" Sprays for bullets // "Blood" Sprays for bullets
if (effect == 14 && !com_blood->integer) { if (effect == 14 && !com_blood->integer) {