mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-07 21:10:46 +08:00
Apply 4344 update
This commit is contained in:
@@ -620,7 +620,9 @@ void Image_PaletteHueReplace( byte *palSrc, int newHue, int start, int end, int
|
||||
void Image_PaletteTranslate( byte *palSrc, int top, int bottom, int pal_size );
|
||||
void Image_SetForceFlags( uint flags ); // set image force flags on loading
|
||||
size_t Image_DXTGetLinearSize( int type, int width, int height, int depth );
|
||||
qboolean Image_CustomPalette( void );
|
||||
void Image_ClearForceFlags( void );
|
||||
void Image_CheckPaletteQ1( void );
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
@@ -728,22 +728,31 @@ draw console single character
|
||||
*/
|
||||
static int Con_DrawGenericChar( int x, int y, int number, rgba_t color )
|
||||
{
|
||||
int width, height;
|
||||
float s1, t1, s2, t2;
|
||||
wrect_t *rc;
|
||||
int width, height;
|
||||
float s1, t1, s2, t2;
|
||||
gl_texture_t *glt;
|
||||
wrect_t *rc;
|
||||
|
||||
number &= 255;
|
||||
|
||||
if( !con.curFont || !con.curFont->valid )
|
||||
return 0;
|
||||
|
||||
// if( number < 32 ) return 0;
|
||||
if( y < -con.curFont->charHeight )
|
||||
return 0;
|
||||
|
||||
rc = &con.curFont->fontRc[number];
|
||||
glt = R_GetTexture( con.curFont->hFontTexture );
|
||||
width = glt->srcWidth;
|
||||
height = glt->srcHeight;
|
||||
|
||||
pglColor4ubv( color );
|
||||
if( !width || !height )
|
||||
return con.curFont->charWidths[number];
|
||||
|
||||
// don't apply color to fixed fonts it's already colored
|
||||
if( con.curFont->type != FONT_FIXED || glt->format == GL_LUMINANCE8_ALPHA8 )
|
||||
pglColor4ubv( color );
|
||||
else pglColor4ub( 255, 255, 255, color[3] );
|
||||
R_GetTextureParms( &width, &height, con.curFont->hFontTexture );
|
||||
|
||||
// calc rectangle
|
||||
|
||||
@@ -1362,6 +1362,7 @@ void FS_LoadGameInfo( const char *rootfolder )
|
||||
SI.GameInfo = SI.games[i];
|
||||
FS_Rescan(); // create new filesystem
|
||||
|
||||
Image_CheckPaletteQ1 ();
|
||||
Host_InitDecals (); // reload decals
|
||||
}
|
||||
|
||||
|
||||
@@ -95,6 +95,7 @@ typedef struct imglib_s
|
||||
byte *tempbuffer; // for convert operations
|
||||
int cmd_flags; // global imglib flags
|
||||
int force_flags; // override cmd_flags
|
||||
qboolean custom_palette; // custom palette was installed
|
||||
} imglib_t;
|
||||
|
||||
/*
|
||||
|
||||
@@ -177,6 +177,16 @@ byte *Image_Copy( size_t size )
|
||||
return out;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Image_CustomPalette
|
||||
=================
|
||||
*/
|
||||
qboolean Image_CustomPalette( void )
|
||||
{
|
||||
return image.custom_palette;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Image_CheckFlag
|
||||
@@ -311,6 +321,58 @@ void Image_SetPalette( const byte *pal, uint *d_table )
|
||||
}
|
||||
}
|
||||
|
||||
static void Image_ConvertPalTo24bit( rgbdata_t *pic )
|
||||
{
|
||||
byte *pal32, *pal24;
|
||||
byte *converted;
|
||||
int i;
|
||||
|
||||
if( pic->type == PF_INDEXED_24 )
|
||||
return; // does nothing
|
||||
|
||||
pal24 = converted = Mem_Malloc( host.imagepool, 768 );
|
||||
pal32 = pic->palette;
|
||||
|
||||
for( i = 0; i < 256; i++, pal24 += 3, pal32 += 4 )
|
||||
{
|
||||
pal24[0] = pal32[0];
|
||||
pal24[1] = pal32[1];
|
||||
pal24[2] = pal32[2];
|
||||
}
|
||||
|
||||
Mem_Free( pic->palette );
|
||||
pic->palette = converted;
|
||||
pic->type = PF_INDEXED_24;
|
||||
}
|
||||
|
||||
void Image_CopyPalette32bit( void )
|
||||
{
|
||||
if( image.palette ) return; // already created ?
|
||||
image.palette = Mem_Malloc( host.imagepool, 1024 );
|
||||
memcpy( image.palette, image.d_currentpal, 1024 );
|
||||
}
|
||||
|
||||
void Image_CheckPaletteQ1( void )
|
||||
{
|
||||
rgbdata_t *pic = FS_LoadImage( DEFAULT_INTERNAL_PALETTE, NULL, 0 );
|
||||
|
||||
if( pic && pic->size == 1024 )
|
||||
{
|
||||
Image_ConvertPalTo24bit( pic );
|
||||
if( Image_ComparePalette( pic->palette ) == PAL_CUSTOM )
|
||||
{
|
||||
image.d_rendermode = LUMP_NORMAL;
|
||||
Con_DPrintf( "custom quake palette detected\n" );
|
||||
Image_SetPalette( pic->palette, d_8toQ1table );
|
||||
d_8toQ1table[255] = 0; // 255 is transparent
|
||||
image.custom_palette = true;
|
||||
q1palette_init = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( pic ) FS_FreeImage( pic );
|
||||
}
|
||||
|
||||
void Image_GetPaletteQ1( void )
|
||||
{
|
||||
if( !q1palette_init )
|
||||
@@ -376,37 +438,6 @@ void Image_GetPaletteLMP( const byte *pal, int rendermode )
|
||||
}
|
||||
}
|
||||
|
||||
static void Image_ConvertPalTo24bit( rgbdata_t *pic )
|
||||
{
|
||||
byte *pal32, *pal24;
|
||||
byte *converted;
|
||||
int i;
|
||||
|
||||
if( pic->type == PF_INDEXED_24 )
|
||||
return; // does nothing
|
||||
|
||||
pal24 = converted = Mem_Malloc( host.imagepool, 768 );
|
||||
pal32 = pic->palette;
|
||||
|
||||
for( i = 0; i < 256; i++, pal24 += 3, pal32 += 4 )
|
||||
{
|
||||
pal24[0] = pal32[0];
|
||||
pal24[1] = pal32[1];
|
||||
pal24[2] = pal32[2];
|
||||
}
|
||||
|
||||
Mem_Free( pic->palette );
|
||||
pic->palette = converted;
|
||||
pic->type = PF_INDEXED_24;
|
||||
}
|
||||
|
||||
void Image_CopyPalette32bit( void )
|
||||
{
|
||||
if( image.palette ) return; // already created ?
|
||||
image.palette = Mem_Malloc( host.imagepool, 1024 );
|
||||
memcpy( image.palette, image.d_currentpal, 1024 );
|
||||
}
|
||||
|
||||
void Image_PaletteHueReplace( byte *palSrc, int newHue, int start, int end, int pal_size )
|
||||
{
|
||||
float r, g, b;
|
||||
|
||||
@@ -261,7 +261,7 @@ qboolean Image_LoadLMP( const char *name, const byte *buffer, size_t filesize )
|
||||
return Image_LoadPAL( name, buffer, filesize );
|
||||
|
||||
// id software trick (image without header)
|
||||
if( image.hint != IL_HINT_HL && Q_stristr( name, "conchars" ))
|
||||
if( Q_stristr( name, "conchars" ) && filesize == 16384 )
|
||||
{
|
||||
image.width = image.height = 128;
|
||||
rendermode = LUMP_QUAKE1;
|
||||
@@ -293,10 +293,14 @@ qboolean Image_LoadLMP( const char *name, const byte *buffer, size_t filesize )
|
||||
{
|
||||
int numcolors;
|
||||
|
||||
if( fin[0] == 255 )
|
||||
for( i = 0; i < pixels; i++ )
|
||||
{
|
||||
image.flags |= IMAGE_HAS_ALPHA;
|
||||
rendermode = LUMP_MASKED;
|
||||
if( fin[i] == 255 )
|
||||
{
|
||||
image.flags |= IMAGE_HAS_ALPHA;
|
||||
rendermode = LUMP_MASKED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
pal = fin + pixels;
|
||||
numcolors = *(short *)pal;
|
||||
@@ -418,14 +422,17 @@ qboolean Image_LoadMIP( const char *name, const byte *buffer, size_t filesize )
|
||||
hl_texture = false;
|
||||
|
||||
// check for luma and alpha pixels
|
||||
for( i = 0; i < image.width * image.height; i++ )
|
||||
if( !image.custom_palette )
|
||||
{
|
||||
if( fin[i] > 224 && fin[i] != 255 )
|
||||
for( i = 0; i < image.width * image.height; i++ )
|
||||
{
|
||||
// don't apply luma to water surfaces because they have no lightmap
|
||||
if( mip.name[0] != '*' && mip.name[0] != '!' )
|
||||
image.flags |= IMAGE_HAS_LUMA;
|
||||
break;
|
||||
if( fin[i] > 224 && fin[i] != 255 )
|
||||
{
|
||||
// don't apply luma to water surfaces because they have no lightmap
|
||||
if( mip.name[0] != '*' && mip.name[0] != '!' )
|
||||
image.flags |= IMAGE_HAS_LUMA;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2195,6 +2195,9 @@ static void Mod_LoadSurfaces( dbspmodel_t *bmod )
|
||||
if( !Q_strncmp( tex->name, "scroll", 6 ))
|
||||
SetBits( out->flags, SURF_CONVEYOR );
|
||||
|
||||
if( FBitSet( out->texinfo->flags, TEX_SCROLL ))
|
||||
SetBits( out->flags, SURF_CONVEYOR );
|
||||
|
||||
// g-cont. added a combined conveyor-transparent
|
||||
if( !Q_strncmp( tex->name, "{scroll", 7 ))
|
||||
SetBits( out->flags, SURF_CONVEYOR|SURF_TRANSPARENT );
|
||||
|
||||
Reference in New Issue
Block a user