25 Apr 2016

This commit is contained in:
g-cont 2016-04-25 00:00:00 +03:00 committed by Alibek Omarov
parent b5b7e5bffa
commit c4801700e3
16 changed files with 257 additions and 2094 deletions

View File

@ -1,3 +1,6 @@
build 3366
build 3224
Client: make players solid for prediction code

View File

@ -47,6 +47,7 @@ GNU General Public License for more details.
#define PARM_TEX_TYPE 11
#define PARM_TEX_CACHEFRAME 12 // compare with worldmodel->needload
#define PARM_TEX_GLFORMAT 13 // get a texture GL-format
#define PARM_TEX_ENCODE 14 // custom encoding for DXT image
// reserved
#define PARM_WORLD_VERSION 16 // return the version of bsp
#define PARM_SKY_SPHERE 17 // sky is quake sphere ?
@ -121,7 +122,7 @@ typedef enum
TF_STATIC = (1<<21), // a marker for purge mechanism (not used by engine)
TF_TEXTURE_RECTANGLE= (1<<22), // this is GL_TEXTURE_RECTANGLE
TF_ALPHA_BORDER = (1<<23), // clamp to (0,0,0,255) (probably no difference)
TF_IMAGE_PROGRAM = (1<<24), // enable image program support like in Doom3
TF_ALPHACONTRAST = (1<<25), // special texture flags for internal usage
TF_FLOAT = (1<<26), // float textures
TF_NOCOMPARE = (1<<27), // disable comparing for depth textures

View File

@ -35,19 +35,36 @@ infotable dlumpinfo_t[dwadinfo_t->numlumps]
#define IDWAD3HEADER (('3'<<24)+('D'<<16)+('A'<<8)+'W')
// dlumpinfo_t->compression
#define CMP_NONE 0 // compression none
#define CMP_LZSS 1 // LZSS compression
// dlumpinfo_t->attribs
#define ATTR_NONE 0 // allow to read-write
#define ATTR_READONLY BIT( 0 ) // don't overwrite this lump in anyway
#define ATTR_COMPRESSED BIT( 1 ) // not used for now, just reserved
#define ATTR_HIDDEN BIT( 2 ) // not used for now, just reserved
#define ATTR_SYSTEM BIT( 3 ) // not used for now, just reserved
// dlumpinfo_t->type
#define TYP_QPAL 64 // quake palette
#define TYP_QTEX 65 // probably was never used
#define TYP_QPIC 66 // quake1 and hl pic (lmp_t)
#define TYP_MIPTEX 67 // half-life (mip_t) previous was TYP_SOUND but never used in quake1
#define TYP_QMIP 68 // quake1 (mip_t) (replaced with TYPE_MIPTEX while loading)
#define TYP_RAW 69 // raw data
#define TYP_ANY -1 // any type can be accepted
#define TYP_NONE 0 // unknown lump type
#define TYP_LABEL 1 // legacy from Doom1. Empty lump - label (like P_START, P_END etc)
#define TYP_PALETTE 64 // quake or half-life palette (768 bytes)
#define TYP_DDSTEX 65 // contain DDS texture
#define TYP_GFXPIC 66 // menu or hud image (not contain mip-levels)
#define TYP_MIPTEX 67 // quake1 and half-life in-game textures with four miplevels
#define TYP_RAWDATA 68 // never was used but may contain any data
#define TYP_COLORMAP2 69 // old stuff. build palette from LBM file (not used)
#define TYP_QFONT 70 // half-life font (qfont_t)
// dlumpinfo_t->img_type
#define IMG_DIFFUSE 0 // same as default pad1 always equal 0
#define IMG_ALPHAMASK 1 // alpha-channel that stored separate as luminance texture
#define IMG_NORMALMAP 2 // indexed normalmap
#define IMG_GLOSSMAP 3 // luminance or color specularity map
#define IMG_GLOSSPOWER 4 // gloss power map (each value is a specular pow)
#define IMG_HEIGHTMAP 5 // heightmap (for parallax occlusion mapping or source of normalmap)
#define IMG_LUMA 6 // luma or glow texture with self-illuminated parts
#define IMG_DECAL_ALPHA 7 // it's a decal texture (last color in palette is base color, and other colors his graduations)
#define IMG_DECAL_COLOR 8 // decal without alpha-channel uses base, like 127 127 127 as transparent color
/*
========================================================================

View File

@ -357,8 +357,8 @@ void CL_CreateCmd( void )
pcmd->cmd.lerp_msec = cl_interp->value * 1000;
pcmd->cmd.lerp_msec = bound( 0, cmd.lerp_msec, 250 );
V_ProcessOverviewCmds( &cmd );
V_ProcessShowTexturesCmds( &cmd );
V_ProcessOverviewCmds( &pcmd->cmd );
V_ProcessShowTexturesCmds( &pcmd->cmd );
if(( cl.background && !cls.demoplayback ) || gl_overview->integer || cls.changelevel )
{

View File

@ -36,7 +36,7 @@ GNU General Public License for more details.
#define MAX_MOVIES 8
#define MAX_CDTRACKS 32
#define MAX_IMAGES 256 // SpriteTextures
#define MAX_EFRAGS 1024
#define MAX_EFRAGS 4096
#define MAX_REQUESTS 32
// screenshot types

File diff suppressed because it is too large Load Diff

View File

@ -70,6 +70,7 @@ typedef struct gltexture_s
GLuint target; // glTarget
GLuint texnum; // gl texture binding
GLint format; // uploaded format
GLint encode; // using GLSL decoder
texFlags_t flags;
rgba_t fogParams; // some water textures

View File

@ -1406,6 +1406,9 @@ static int GL_RenderGetParm( int parm, int arg )
case PARM_TEX_GLFORMAT:
glt = R_GetTexture( arg );
return glt->format;
case PARM_TEX_ENCODE:
glt = R_GetTexture( arg );
return glt->encode;
case PARM_TEX_SKYBOX:
ASSERT( arg >= 0 && arg < 6 );
return tr.skyboxTextures[arg];

View File

@ -3373,9 +3373,6 @@ static void R_StudioLoadTexture( model_t *mod, studiohdr_t *phdr, mstudiotexture
imgfilter_t *filter = NULL;
texture_t *tx = NULL;
if( ptexture->flags & STUDIO_NF_TRANSPARENT )
flags |= (TF_CLAMP|TF_NOMIPMAP);
if( ptexture->flags & STUDIO_NF_NORMALMAP )
flags |= (TF_NORMALMAP);

View File

@ -23,7 +23,7 @@ static char mond[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int Q_buildnum( void )
{
// do not touch this! Only author of Xash3D can increase buildnumbers!
#if 1
#if 0
int m = 0, d = 0, y = 0;
static int b = 0;
@ -48,6 +48,6 @@ int Q_buildnum( void )
return b;
#else
return 3308;
return 3366;
#endif
}

View File

@ -85,7 +85,7 @@ typedef enum
#include "com_model.h"
#include "crtlib.h"
#define XASH_VERSION 0.97f // engine current version
#define XASH_VERSION 0.98f // engine current version
// PERFORMANCE INFO
#define MIN_FPS 15.0 // host minimum fps value for maxfps.
@ -459,6 +459,18 @@ typedef enum
IL_DDS_HARDWARE = BIT(4), // DXT compression is support
} ilFlags_t;
// goes into rgbdata_t->encode
#define DXT_ENCODE_DEFAULT 0 // don't use custom encoders
#define DXT_ENCODE_COLOR_YCoCg 0x1A01 // make sure that value dosn't collide with anything
#define DXT_ENCODE_ALPHA_1BIT 0x1A02 // normal 1-bit alpha
#define DXT_ENCODE_ALPHA_8BIT 0x1A03 // normal 8-bit alpha
#define DXT_ENCODE_ALPHA_SDF 0x1A04 // signed distance field
#define DXT_ENCODE_NORMAL_AG_ORTHO 0x1A05 // orthographic projection
#define DXT_ENCODE_NORMAL_AG_STEREO 0x1A06 // stereographic projection
#define DXT_ENCODE_NORMAL_AG_PARABOLOID 0x1A07 // paraboloid projection
#define DXT_ENCODE_NORMAL_AG_QUARTIC 0x1A08 // newton method
#define DXT_ENCODE_NORMAL_AG_AZIMUTHAL 0x1A09 // Lambert Azimuthal Equal-Area
// rgbdata output flags
typedef enum
{
@ -506,6 +518,7 @@ typedef struct rgbdata_s
word depth; // image depth
uint type; // compression type
uint flags; // misc image flags
word encode; // DXT may have custom encoder, that will be decoded in GLSL-side
byte numMips; // mipmap count
byte *palette; // palette if present
byte *buffer; // image buffer
@ -651,6 +664,7 @@ CLIENT / SERVER SYSTEMS
void CL_Init( void );
void CL_Shutdown( void );
void Host_ClientFrame( void );
void Host_RenderFrame( void );
qboolean CL_Active( void );
void SV_Init( void );

View File

@ -2981,14 +2981,29 @@ WADSYSTEM PRIVATE COMMON FUNCTIONS
=============================================================================
*/
// associate extension with wad type
static const wadtype_t wad_types[] =
static const wadtype_t wad_types[6] =
{
{ "pal", TYP_QPAL }, // palette
{ "lmp", TYP_QPIC }, // quake1, hl pic
{ "fnt", TYP_QFONT }, // hl qfonts
{ "mip", TYP_MIPTEX }, // hl/q1 mip
{ "raw", TYP_RAW }, // signed raw data
{ NULL, TYP_NONE }
{ "pal", TYP_PALETTE }, // palette
{ "dds", TYP_DDSTEX }, // DDS image
{ "lmp", TYP_GFXPIC }, // quake1, hl pic
{ "fnt", TYP_QFONT }, // hl qfonts
{ "mip", TYP_MIPTEX }, // hl/q1 mip
{ NULL, TYP_NONE }
};
// suffix converts to img_type and back
static const wadtype_t wad_hints[10] =
{
{ "", IMG_DIFFUSE }, // no suffix
{ "_mask", IMG_ALPHAMASK }, // alpha-channel stored to another lump
{ "_norm", IMG_NORMALMAP }, // indexed normalmap
{ "_spec", IMG_GLOSSMAP }, // grayscale\color specular
{ "_gpow", IMG_GLOSSPOWER }, // grayscale gloss power
{ "_hmap", IMG_HEIGHTMAP }, // heightmap (can be converted to normalmap)
{ "_luma", IMG_LUMA }, // self-illuminate parts on the diffuse
{ "_adec", IMG_DECAL_ALPHA }, // classic HL-decal (with alpha-channel)
{ "_cdec", IMG_DECAL_COLOR }, // paranoia decal (base 127 127 127)
{ NULL, 0 } // terminator
};
static char W_TypeFromExt( const char *lumpname )
@ -3002,12 +3017,19 @@ static char W_TypeFromExt( const char *lumpname )
for( type = wad_types; type->ext; type++ )
{
if(!Q_stricmp( ext, type->ext ))
if( !Q_stricmp( ext, type->ext ))
return type->type;
}
return TYP_NONE;
}
/*
===========
W_ExtFromType
Convert type to extension
===========
*/
static const char *W_ExtFromType( char lumptype )
{
const wadtype_t *type;
@ -3024,35 +3046,87 @@ static const char *W_ExtFromType( char lumptype )
return "";
}
/*
===========
W_HintFromSuf
Convert name suffix into image type
===========
*/
char W_HintFromSuf( const char *lumpname )
{
char barename[64];
char suffix[8];
const wadtype_t *hint;
// trying to extract hint from the name
FS_FileBase( lumpname, barename );
Q_strncpy( suffix, barename + Q_strlen( barename ) - HINT_NAMELEN, sizeof( suffix ));
// we not known about filetype, so match only by filename
for( hint = wad_hints; hint->ext; hint++ )
{
if( !Q_stricmp( suffix, hint->ext ))
return hint->type;
}
// no any special type was found
return IMG_DIFFUSE;
}
static dlumpinfo_t *W_FindLump( wfile_t *wad, const char *name, const char matchtype )
{
int left, right, middle;
char img_type = IMG_DIFFUSE;
char barename[64], suffix[8];
int left, right;
const wadtype_t *hint;
if( !wad || !wad->lumps || matchtype == TYP_NONE )
return NULL;
// trying to extract hint from the name
FS_FileBase( name, barename );
Q_strncpy( suffix, barename + Q_strlen( barename ) - HINT_NAMELEN, sizeof( suffix ));
// we not known about filetype, so match only by filename
for( hint = wad_hints; hint->ext; hint++ )
{
if( !Q_stricmp( suffix, hint->ext ))
{
img_type = hint->type;
break;
}
}
if( img_type != IMG_DIFFUSE )
barename[Q_strlen( barename ) - HINT_NAMELEN] = '\0'; // kill the suffix
// look for the file (binary search)
left = 0;
right = wad->numlumps - 1;
while( left <= right )
{
int diff;
int middle = (left + right) / 2;
int diff = Q_stricmp( wad->lumps[middle].name, barename );
middle = (left + right) / 2;
diff = Q_stricmp( wad->lumps[middle].name, name );
// Found it
if( !diff )
{
if( matchtype == TYP_ANY || matchtype == wad->lumps[middle].type )
if( wad->lumps[middle].img_type > img_type )
diff = 1;
else if( wad->lumps[middle].img_type < img_type )
diff = -1;
else if(( matchtype == TYP_ANY ) || ( matchtype == wad->lumps[middle].type ))
return &wad->lumps[middle]; // found
else break;
else if( wad->lumps[middle].type < matchtype )
diff = 1;
else if( wad->lumps[middle].type > matchtype )
diff = -1;
else break; // not found
}
// if we're too far in the list
if( diff > 0 )
right = middle - 1;
if( diff > 0 ) right = middle - 1;
else left = middle + 1;
}
@ -3066,49 +3140,53 @@ FS_AddFileToWad
Add a file to the list of files contained into a package
====================
*/
static dlumpinfo_t *W_AddFileToWad( const char *name, wfile_t *wad, int filepos, int packsize, int realsize, char type, char compression )
static dlumpinfo_t *W_AddFileToWad( const char *name, wfile_t *wad, dlumpinfo_t *newlump )
{
int left, right, middle;
int left, right;
dlumpinfo_t *plump;
// convert all qmip types to miptex
if( newlump->type == TYP_RAWDATA )
newlump->type = TYP_MIPTEX;
// check for Quake 'conchars' issues (only lmp loader supposed to read this lame pic)
if( !Q_stricmp( newlump->name, "conchars" ) && newlump->type == TYP_RAWDATA )
newlump->type = TYP_GFXPIC;
// look for the slot we should put that file into (binary search)
left = 0;
right = wad->numlumps - 1;
while( left <= right )
{
int diff;
int middle = ( left + right ) / 2;
int diff = Q_stricmp( wad->lumps[middle].name, name );
middle = ( left + right ) / 2;
diff = Q_stricmp( wad->lumps[middle].name, name );
// If we found the file, there's a problem
if( !diff ) MsgDev( D_NOTE, "Wad %s contains the file %s several times\n", wad->filename, name );
if( !diff )
{
if( wad->lumps[middle].img_type > newlump->img_type )
diff = 1;
else if( wad->lumps[middle].img_type < newlump->img_type )
diff = -1;
else if( wad->lumps[middle].type < newlump->type )
diff = 1;
else if( wad->lumps[middle].type > newlump->type )
diff = -1;
else MsgDev( D_NOTE, "Wad %s contains the file %s several times\n", wad->filename, name );
}
// If we're too far in the list
if( diff > 0 ) right = middle - 1;
else left = middle + 1;
}
// We have to move the right of the list by one slot to free the one we need
// we have to move the right of the list by one slot to free the one we need
plump = &wad->lumps[left];
Q_memmove( plump + 1, plump, ( wad->numlumps - left ) * sizeof( *plump ));
memmove( plump + 1, plump, ( wad->numlumps - left ) * sizeof( *plump ));
wad->numlumps++;
Q_memcpy( plump->name, name, sizeof( plump->name ));
plump->filepos = filepos;
plump->disksize = realsize;
plump->size = packsize;
plump->compression = compression;
// convert all qmip types to miptex
if( type == TYP_QMIP )
plump->type = TYP_MIPTEX;
else plump->type = type;
// check for Quake 'conchars' issues (only lmp loader supposed to read this lame pic)
if( !Q_stricmp( plump->name, "conchars" ) && plump->type == TYP_QMIP )
plump->type = TYP_QPIC;
*plump = *newlump;
memcpy( plump->name, name, sizeof( plump->name ));
return plump;
}
@ -3147,7 +3225,7 @@ static qboolean W_ReadLumpTable( wfile_t *wad )
k = Q_strlen( Q_strrchr( name, '*' ));
if( k ) name[Q_strlen( name ) - k] = '!'; // quake1 issues (can't save images that contain '*' symbol)
W_AddFileToWad( name, wad, srclumps[i].filepos, srclumps[i].size, srclumps[i].disksize, srclumps[i].type, srclumps[i].compression );
W_AddFileToWad( name, wad, &srclumps[i] );
}
// release source lumps

View File

@ -62,7 +62,8 @@ infotable dlumpinfo_t[dwadinfo_t->numlumps]
#define IDWAD3HEADER (('3'<<24)+('D'<<16)+('A'<<8)+'W') // little-endian "WAD3" half-life wads
#define WAD3_NAMELEN 16
#define MAX_FILES_IN_WAD 8192
#define HINT_NAMELEN 5 // e.g. _mask, _norm
#define MAX_FILES_IN_WAD 65535 // real limit as above <2Gb size not a lumpcount
// hidden virtual lump types
#define TYP_ANY -1 // any type can be accepted
@ -79,14 +80,14 @@ typedef struct
typedef struct
{
int filepos;
int disksize;
int filepos; // file offset in WAD
int disksize; // compressed or uncompressed
int size; // uncompressed
char type;
char compression; // probably not used
char pad1;
char pad2;
char name[16]; // must be null terminated
char type; // TYP_*
char attribs; // file attribs
char img_type; // IMG_*
char pad;
char name[WAD3_NAMELEN]; // must be null terminated
} dlumpinfo_t;
#include "custom.h"

View File

@ -68,6 +68,7 @@ typedef struct imglib_s
word height;
word depth;
byte num_mips; // mipmap count
word encode; // custom encode type
uint type; // main type switcher
uint flags; // additional image flags
size_t size; // image rgba size (for bounds checking)

View File

@ -102,14 +102,6 @@ void Image_DXTGetPixelFormat( dds_t *hdr )
if( !( hdr->dsCaps.dwCaps2 & DDS_VOLUME ))
hdr->dwDepth = 1;
image.flags |= IMAGE_HAS_COLOR; // predict state
if( hdr->dsPixelFormat.dwFlags & DDS_ALPHA )
image.flags |= IMAGE_HAS_ALPHA;
if( hdr->dsPixelFormat.dwFlags & DDS_LUMINANCE )
image.flags &= ~IMAGE_HAS_COLOR;
if( hdr->dsPixelFormat.dwFlags & DDS_FOURCC )
{
switch( hdr->dsPixelFormat.dwFourCC )
@ -157,9 +149,6 @@ void Image_DXTGetPixelFormat( dds_t *hdr )
if( hdr->dsCaps.dwCaps1 & DDS_COMPLEX && hdr->dsCaps.dwCaps2 & DDS_CUBEMAP )
image.flags |= IMAGE_CUBEMAP;
if( hdr->dsPixelFormat.dwFlags & DDS_ALPHAPIXELS )
image.flags |= IMAGE_HAS_ALPHA;
if( hdr->dwFlags & DDS_MIPMAPCOUNT )
image.num_mips = hdr->dwMipMapCount; // get actual mip count
}
@ -180,18 +169,17 @@ size_t Image_DXTGetLinearSize( int type, int width, int height, int depth )
return 0;
}
uint Image_DXTCalcMipmapSize( dds_t *hdr )
size_t Image_DXTCalcMipmapSize( dds_t *hdr )
{
uint buffsize = 0;
int w = hdr->dwWidth;
int h = hdr->dwHeight;
int i, mipsize = 0;
size_t buffsize = 0;
int i, width, height;
// now correct buffer size
for( i = 0; i < max( 1, image.num_mips ); i++, buffsize += mipsize )
for( i = 0; i < hdr->dwMipMapCount; i++ )
{
mipsize = Image_DXTGetLinearSize( image.type, w, h, image.depth );
w = (w+1)>>1, h = (h+1)>>1;
width = max( 1, ( hdr->dwWidth >> i ));
height = max( 1, ( hdr->dwHeight >> i ));
buffsize += Image_DXTGetLinearSize( image.type, width, height, image.depth );
}
return buffsize;
@ -301,14 +289,28 @@ qboolean Image_LoadDDS( const char *name, const byte *buffer, size_t filesize )
if( image.size == 0 ) return false; // just in case
fin = (byte *)(buffer + sizeof( dds_t ));
// check for real alpha-pixels
if( image.type == PF_DXT3 && Image_CheckDXT3Alpha( &header, fin ))
// copy an encode method
image.encode = (word)header.dwReserved1[0];
switch( image.encode )
{
image.flags |= IMAGE_HAS_ALPHA;
}
else if( image.type == PF_DXT5 && Image_CheckDXT5Alpha( &header, fin ))
{
image.flags |= IMAGE_HAS_ALPHA;
case DXT_ENCODE_COLOR_YCoCg:
image.flags |= IMAGE_HAS_COLOR;
break;
case DXT_ENCODE_NORMAL_AG_ORTHO:
case DXT_ENCODE_NORMAL_AG_STEREO:
case DXT_ENCODE_NORMAL_AG_PARABOLOID:
case DXT_ENCODE_NORMAL_AG_QUARTIC:
case DXT_ENCODE_NORMAL_AG_AZIMUTHAL:
image.flags |= IMAGE_HAS_COLOR;
break;
default: // check for real alpha-pixels
if( image.type == PF_DXT3 && Image_CheckDXT3Alpha( &header, fin ))
image.flags |= IMAGE_HAS_ALPHA;
else if( image.type == PF_DXT5 && Image_CheckDXT5Alpha( &header, fin ))
image.flags |= IMAGE_HAS_ALPHA;
image.flags |= IMAGE_HAS_COLOR;
break;
}
// dds files will be uncompressed on a render. requires minimal of info for set this

View File

@ -107,6 +107,7 @@ void Image_Reset( void )
image.fogParams[1] = 0;
image.fogParams[2] = 0;
image.fogParams[3] = 0;
image.encode = 0;
// pointers will be saved with prevoius picture struct
// don't care about it
@ -146,6 +147,7 @@ rgbdata_t *ImagePack( void )
pack->buffer = image.rgba;
pack->width = image.width;
pack->height = image.height;
pack->depth = image.depth;
pack->type = image.type;
pack->size = image.size;
}
@ -159,7 +161,7 @@ rgbdata_t *ImagePack( void )
pack->flags = image.flags;
pack->numMips = image.num_mips;
pack->palette = image.palette;
pack->depth = image.depth;
pack->encode = image.encode;
return pack;
}