13 Nov 2008

This commit is contained in:
g-cont 2008-11-13 00:00:00 +03:00 committed by Alibek Omarov
parent 08b2fdfb51
commit a628cce80c
26 changed files with 3777 additions and 3494 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -35,7 +35,7 @@ void LeakFile (tree_t *tree)
return;
// write the points to the file
sprintf (path, "%s.lin", gs_filename);
com.sprintf( path, "maps/%s.lin", gs_filename );
linefile = FS_Open (path, "w" );
if (!linefile) Sys_Error ("Couldn't open %s\n", path);

View File

@ -561,6 +561,16 @@ void ParseBrush( bsp_entity_t *mapent )
Com_ReadFloat( mapfile, SC_COMMENT_SEMICOLON, &td.vects.hammer.scale[1] );
}
// hidden q2/q3 legacy, but can be used
if( g_brushtype != BRUSH_QUARK && Com_ReadToken( mapfile, SC_COMMENT_SEMICOLON, &token ))
{
// overwrite shader values directly from .map file
Com_SaveToken( mapfile, &token );
Com_ReadLong( mapfile, false, &td.contents );
Com_ReadLong( mapfile, false, &td.flags );
Com_ReadLong( mapfile, false, &td.value );
}
if( mapfile->TXcommand == '1' || mapfile->TXcommand == '2' )
{
// we are QuArK mode and need to translate some numbers to align textures its way
@ -630,15 +640,6 @@ void ParseBrush( bsp_entity_t *mapent )
side->surf = td.flags;
}
// hidden q2/q3 legacy, but can be used
if( g_brushtype != BRUSH_QUARK && Com_ReadLong( mapfile, SC_COMMENT_SEMICOLON, &side->contents ))
{
// overwrite shader values directly from .map file
Com_ReadLong( mapfile, false, &td.contents );
Com_ReadLong( mapfile, false, &td.flags );
Com_ReadLong( mapfile, false, &td.value );
}
// translucent objects are automatically classified as detail
if( side->surf & ( SURF_TRANS|SURF_BLEND ))
{

View File

@ -15,37 +15,45 @@ typedef struct
bool clearSolid;
} infoParm_t;
// NOTE: this table must match with same table in render\r_shader.c
infoParm_t infoParms[] =
{
// server relevant contents
{"window", SURF_BLEND, CONTENTS_WINDOW, 0},
{"aux", SURF_NONE, CONTENTS_AUX, 0},
{"lava", SURF_WARP, CONTENTS_LAVA, 1}, // very damaging
{"slime", SURF_WARP, CONTENTS_SLIME, 1}, // mildly damaging
{"water", SURF_WARP, CONTENTS_WATER, 1},
// utility relevant attributes
{"fog", SURF_NONE, CONTENTS_FOG, 0}, // carves surfaces entering
{"areaportal", SURF_NONE, CONTENTS_AREAPORTAL, 1},
{"window", SURF_NONE, CONTENTS_WINDOW, 0},
{"aux", SURF_NONE, CONTENTS_AUX, 0},
{"warp", SURF_WARP, CONTENTS_NONE, 0},
{"water", SURF_NONE, CONTENTS_WATER, 1},
{"slime", SURF_NONE, CONTENTS_SLIME, 1}, // mildly damaging
{"lava", SURF_NONE, CONTENTS_LAVA, 1}, // very damaging
{"playerclip", SURF_NONE, CONTENTS_PLAYERCLIP, 1},
{"monsterclip", SURF_NONE, CONTENTS_MONSTERCLIP, 1},
{"clip", SURF_NODRAW, CONTENTS_CLIP, 1},
{"clip", SURF_NONE, CONTENTS_CLIP, 1},
{"notsolid", SURF_NONE, CONTENTS_NONE, 1}, // just clear solid flag
{"trigger", SURF_NONE, CONTENTS_TRIGGER, 1}, // trigger volume
// utility relevant attributes
{"origin", SURF_NONE, CONTENTS_ORIGIN, 1}, // center of rotating brushes
{"trans", SURF_TRANS, CONTENTS_TRANSLUCENT, 0}, // don't eat contained surfaces
{"nolightmap", SURF_NOLIGHTMAP, CONTENTS_NONE, 0}, // don't generate a lightmap
{"translucent", SURF_NONE, CONTENTS_TRANSLUCENT, 0}, // don't eat contained surfaces
{"detail", SURF_NONE, CONTENTS_DETAIL, 0}, // don't include in structural bsp
{"fog", SURF_NOLIGHTMAP, CONTENTS_FOG, 0}, // carves surfaces entering
{"sky", SURF_SKY, CONTENTS_NONE, 0}, // emit light from environment map
{"hint", SURF_HINT, CONTENTS_NONE, 0}, // use as a primary splitter
{"skip", SURF_SKIP, CONTENTS_NONE, 0}, // use as a secondary splitter
{"null", SURF_NODRAW, CONTENTS_SOLID, 0},
{"mirror", SURF_MIRROR, CONTENTS_SOLID, 0},
{"null", SURF_NODRAW, CONTENTS_NONE, 0}, // nodraw texture
{"mirror", SURF_MIRROR, CONTENTS_NONE, 0},
// server attributes
{"slick", SURF_SLICK, CONTENTS_NONE, 0},
{"light", SURF_LIGHT, CONTENTS_NONE, 0},
{"ladder", SURF_NONE, CONTENTS_LADDER, 0},
// drawsurf attributes
{"nodraw", SURF_NODRAW, CONTENTS_NONE, 0,}, // don't generate a drawsurface
// drawsurf attributes (matched with Half-Life render modes)
{"texture", SURF_BLEND, CONTENTS_NONE, 0}, // blend surface
{"glow", SURF_GLOW, CONTENTS_NONE, 0}, // glow sprite
{"solid", SURF_ALPHA, CONTENTS_NONE, 0}, // alphatest
{"additive", SURF_ADDITIVE, CONTENTS_NONE, 0}, // additive
{"chrome", SURF_CHROME, CONTENTS_NONE, 0}, // studio chrome
};
/*
@ -56,19 +64,16 @@ FindShader
bsp_shader_t *FindShader( const char *texture )
{
bsp_shader_t *texshader;
string shader, texname;
string shader;
int i;
// convert to lower case
com.strlwr( texture, texname );
// build full path
com.sprintf( shader, "textures/%s", texname );
com.strlwr( texture, shader );
// look for it
for( i = 0, texshader = shaderInfo; i < numShaderInfo; i++, texshader++)
{
if(!com.strcmp(shader, texshader->name))
if(!com.stricmp( shader, texshader->name ))
return texshader;
}
return NULL; //no shaders for this texture
@ -201,8 +206,8 @@ int LoadShaderInfo( void )
int i, numShaderFiles;
numShaderFiles = 0;
search = FS_Search( "scripts/shaders/*.txt", true );
if (!search) return 0;
search = FS_Search( "scripts/*.shader", true );
if( !search ) return 0;
for( i = 0; i < search->numfilenames; i++ )
{

View File

@ -27,7 +27,7 @@ winding_t *AllocWinding (int points)
c_peak_windings = c_active_windings;
}
s = sizeof(vec_t)*3*points + sizeof(int);
w = Malloc (s);
w = malloc (s);
memset (w, 0, s);
return w;
}
@ -40,7 +40,7 @@ void FreeWinding (winding_t *w)
if (GetNumThreads() == 1)
c_active_windings--;
Mem_Free (w);
free (w);
}

View File

@ -319,7 +319,7 @@ bool Conv_CreateShader( const char *name, rgbdata_t *pic, const char *ext, const
FS_ExtractFilePath( name, shadername );
FS_FileBase( shadername, shadername ); // remove "textures" from path
FS_FileBase( name, imagename );
com.snprintf( shaderpath, MAX_STRING, "%s/shaders/%s.txt", gs_gamedir, shadername );
com.snprintf( shaderpath, MAX_STRING, "%s/scripts/%s.txt", gs_gamedir, shadername );
com.snprintf( imagepath, MAX_STRING, "%s", name ); // full path
nextanimchain[0] = 0; // clear chain

View File

@ -67,5 +67,5 @@ if exist vsound\vsound.plg del /f /q vsound\vsound.plg
echo Build succeeded!
echo Please wait. Xash is now loading
cd D:\Xash3D\
quake.exe -game tmpQuArK -log -debug -dev 3 +map start
quake.exe -game tmpQuArK -log -debug -dev 3 +map dm_knot
:done

View File

@ -691,7 +691,7 @@ with the archive flag set to true.
static void Cmd_WriteCvar(const char *name, const char *string, const char *desc, void *f )
{
//if(!desc) return; // ignore fantom cvars
if( !desc ) return; // ignore cvars without description (fantom variables)
FS_Printf(f, "seta %s \"%s\"\n", name, string );
}
@ -722,11 +722,11 @@ void CL_WriteConfiguration( void )
if( !cls.initialized ) return;
f = FS_Open("scripts/config/keys.rc", "w");
if(f)
f = FS_Open( "config/keys.rc", "w" );
if( f )
{
FS_Printf (f, "//=======================================================================\n");
FS_Printf (f, "//\t\t\tCopyright XashXT Group 2007 ©\n");
FS_Printf (f, "//\t\t\tCopyright XashXT Group %s ©\n", timestamp( TIME_YEAR_ONLY ));
FS_Printf (f, "//\t\t\tkeys.rc - current key bindings\n");
FS_Printf (f, "//=======================================================================\n");
Key_WriteBindings(f);
@ -734,11 +734,11 @@ void CL_WriteConfiguration( void )
}
else MsgDev( D_ERROR, "Couldn't write keys.rc.\n");
f = FS_Open("scripts/config/vars.rc", "w");
if(f)
f = FS_Open( "config/vars.rc", "w" );
if( f )
{
FS_Printf (f, "//=======================================================================\n");
FS_Printf (f, "//\t\t\tCopyright XashXT Group 2007 ©\n");
FS_Printf (f, "//\t\t\tCopyright XashXT Group %s ©\n", timestamp( TIME_YEAR_ONLY ));
FS_Printf (f, "//\t\t\tvars.rc - archive of cvars\n");
FS_Printf (f, "//=======================================================================\n");
Cmd_WriteVariables(f);
@ -753,7 +753,7 @@ void Key_EnumCmds_f( void )
if( f )
{
FS_Printf( f, "//=======================================================================\n");
FS_Printf( f, "//\t\t\tCopyright XashXT Group 2007 ©\n");
FS_Printf( f, "//\t\t\tCopyright XashXT Group %s ©\n", timestamp( TIME_YEAR_ONLY ));
FS_Printf( f, "//\t\thelp.txt - xash commands and console variables\n");
FS_Printf( f, "//=======================================================================\n");

View File

@ -331,7 +331,7 @@ SV_WriteSaveFile
void SV_WriteSaveFile( const char *name )
{
string comment;
wfile_t *savfile;
wfile_t *savfile = NULL;
bool autosave = false;
char path[MAX_SYSPATH];
byte *portalstate = Z_Malloc( MAX_MAP_AREAPORTALS );

View File

@ -130,7 +130,7 @@ void Cbuf_Execute( void )
char line[MAX_CMD_LINE];
int quotes;
while (cmd_text.cursize)
while( cmd_text.cursize )
{
if( cmd_wait )
{
@ -168,7 +168,7 @@ void Cbuf_Execute( void )
}
// execute the command line
Cmd_ExecuteString (line);
Cmd_ExecuteString( line );
}
}
@ -270,7 +270,7 @@ void Cmd_Exec_f (void)
return;
}
com.snprintf( rcpath, MAX_STRING, "scripts/config/%s", Cmd_Argv(1));
com.snprintf( rcpath, MAX_STRING, "config/%s", Cmd_Argv(1));
FS_DefaultExtension(rcpath, ".rc" ); // append as default
f = FS_LoadFile(rcpath, &len );

View File

@ -1520,9 +1520,10 @@ Appends lines containing "set variable value" for all variables
with the archive flag set to true.
============
*/
static void FS_WriteCvar( const char *name, const char *string, const char *unused, void *f )
static void FS_WriteCvar( const char *name, const char *string, const char *desc, void *f )
{
FS_Printf(f, "setc %s \"%s\"\n", name, string );
if( !desc ) return; // ignore cvars without description (fantom variables)
FS_Printf( f, "setc %s \"%s\"\n", name, string );
}
void FS_WriteVariables( file_t *f )
@ -1542,7 +1543,7 @@ void FS_UpdateConfig( void )
if( f )
{
FS_Printf (f, "//=======================================================================\n");
FS_Printf (f, "//\t\t\tCopyright XashXT Group 2008 ©\n");
FS_Printf (f, "//\t\t\tCopyright XashXT Group %s ©\n", com_timestamp( TIME_YEAR_ONLY ));
FS_Printf (f, "//\t\t system.rc - archive of system cvars\n");
FS_Printf (f, "//=======================================================================\n");
FS_WriteVariables( f );

View File

@ -547,6 +547,8 @@ bool Image_SavePCX( const char *name, rgbdata_t *pix );
//
// img_utils.c
//
void Image_Reset( void );
rgbdata_t *ImagePack( void );
byte *Image_Copy( size_t size );
bool Image_ValidSize( const char *name );
bool Image_LumpValidSize( const char *name );

View File

@ -1325,7 +1325,7 @@ void Image_DXTGetPixelFormat( dds_t *hdr )
else
{
if( bits == 32 ) image.type = PF_ABGR_64;
else if( bits == 24 ) image.type = PF_RGB_24;
else if( bits == 24 ) image.type = PF_BGR_24;
else image.type = PF_ARGB_32;
}
}
@ -2142,6 +2142,72 @@ bool Image_DecompressARGB( uint target, int level, int intformat, uint width, ui
return true;
}
bool Image_DecompressPal8( uint target, int level, int intformat, uint width, uint height, uint imageSize, const void* data )
{
byte *fin, *fout;
int size;
if( !data ) return false;
fin = (byte *)data;
size = width * height * image.curdepth * 4;
image.tempbuffer = Mem_Realloc( Sys.imagepool, image.tempbuffer, size );
fout = image.tempbuffer;
switch( PFDesc[intformat].format )
{
case PF_INDEXED_24:
if( image.flags & IMAGE_HAS_ALPHA )
{
if( image.flags & IMAGE_COLORINDEX )
Image_GetPaletteLMP( image.palette, LUMP_DECAL );
else Image_GetPaletteLMP( image.palette, LUMP_TRANSPARENT );
}
else Image_GetPaletteLMP( image.palette, LUMP_NORMAL );
// intentional falltrough
case PF_INDEXED_32:
if( !image.d_currentpal ) image.d_currentpal = ( uint *)image.palette;
if( !Image_Copy8bitRGBA( fin, fout, width * height )) return false;
break;
}
Image_AddRGBAToPack( target, level, size, fout );
return true;
}
bool Image_DecompressDUDV( uint target, int level, int intformat, uint width, uint height, uint imageSize, const void* data )
{
byte *fin, *fout;
int i, size;
short *col;
if( !data ) return false;
fin = (byte *)data;
size = width * height * image.curdepth * 4;
image.tempbuffer = Mem_Realloc( Sys.imagepool, image.tempbuffer, size );
fout = image.tempbuffer;
switch( PFDesc[intformat].format )
{
case PF_UV_16:
for( i = 0, col = (short *)fin; i < width * height; i++, col += sizeof( short ))
{
fout[(i<<2)+0] = col[0];
fout[(i<<2)+1] = col[1];
fout[(i<<2)+2] = 0;
fout[(i<<2)+3] = 0;
}
break;
case PF_UV_32:
Mem_Copy( fout, fin, size ); // nothing to process
break;
}
Image_AddRGBAToPack( target, level, size, fout );
return true;
}
bool Image_DecompressRGBA( uint target, int level, int intformat, uint width, uint height, uint imageSize, const void* data )
{
byte *fin, *fout;
@ -2160,9 +2226,9 @@ bool Image_DecompressRGBA( uint target, int level, int intformat, uint width, ui
case PF_RGB_16:
for( i = 0, col = (color16 *)fin; i < width * height; i++, col += sizeof( color16 ))
{
fout[(i<<2)+0] = col->r;
fout[(i<<2)+1] = col->g;
fout[(i<<2)+2] = col->b;
fout[(i<<2)+0] = col->r << 3;
fout[(i<<2)+1] = col->g << 2;
fout[(i<<2)+2] = col->b << 3;
fout[(i<<2)+3] = 255;
}
break;
@ -2184,6 +2250,7 @@ bool Image_DecompressRGBA( uint target, int level, int intformat, uint width, ui
fout[(i<<2)+3] = 255;
}
break;
case PF_RGBA_GN:
case PF_RGBA_32:
Mem_Copy( fout, fin, size );
break;
@ -2216,14 +2283,15 @@ void Image_DecompressDDS( const byte *buffer, uint target )
switch( image.type )
{
case PF_RGB_24:
case PF_INDEXED_24:
case PF_INDEXED_32: image.decompress = Image_DecompressPal8; break;
case PF_RGBA_32:
case PF_BGRA_32:
case PF_ABGR_64: image.decompress = Image_DecompressRGBA; break;
case PF_LUMINANCE:
case PF_LUMINANCE_16:
case PF_LUMINANCE_ALPHA:
case PF_BGRA_32: image.decompress = Image_DecompressRGBA; break;
case PF_ARGB_32: image.decompress = Image_DecompressARGB; break;
case PF_ABGR_64:
case PF_RGB_24:
case PF_BGR_24:
case PF_RGB_16: image.decompress = Image_DecompressRGBA; break;
case PF_DXT1:
case PF_DXT2:
case PF_DXT3:
@ -2232,13 +2300,19 @@ void Image_DecompressDDS( const byte *buffer, uint target )
case PF_RXGB: image.decompress = Image_DecompressDXT; break;
case PF_ATI1N:
case PF_ATI2N: image.decompress = Image_DecompressATI; break;
case PF_LUMINANCE:
case PF_LUMINANCE_16:
case PF_LUMINANCE_ALPHA: image.decompress = Image_DecompressARGB; break;
case PF_UV_16:
case PF_UV_32: image.decompress = Image_DecompressDUDV; break;
case PF_R_16F:
case PF_R_32F:
case PF_GR_32F:
case PF_GR_64F:
case PF_ABGR_64F:
case PF_ABGR_128F: image.decompress = Image_DecompressFloat; break;
case PF_UNKNOWN: break;
case PF_RGBA_GN: image.decompress = Image_DecompressRGBA; break;
default: Sys_Error( "Image_DecompressDDS: unknown image format\n" );
}
for( i = 0; i < image.cur_mips; i++, buffer += size )
@ -2358,6 +2432,7 @@ bool Image_LoadDDS( const char *name, const byte *buffer, size_t filesize )
// now we can change type to RGBA
if( image.filter != CB_HINT_NO ) image.flags &= ~IMAGE_CUBEMAP; // side extracted
image.type = PF_RGBA_32;
image.bits_count = 32;
}
else
{

View File

@ -552,6 +552,22 @@ void Image_CopyPalette32bit( void )
Mem_Copy( image.palette, image.d_currentpal, 1024 );
}
void Image_CopyParms( rgbdata_t *src )
{
Image_Reset();
image.width = src->width;
image.height = src->height;
image.num_layers = src->numLayers;
image.num_mips = src->numMips;
image.type = src->type;
image.flags = src->flags;
image.bits_count = src->bitsCount;
image.size = src->size;
image.rgba = src->buffer;
image.palette = src->palette; // may be NULL
}
/*
============
Image_Copy8bitRGBA
@ -1196,6 +1212,48 @@ byte *Image_FlipInternal( const byte *in, int *srcwidth, int *srcheight, int typ
return image.tempbuffer;
}
rgbdata_t *Image_DecompressInternal( rgbdata_t *pic )
{
int i, offset, numsides = 1;
uint target = 1;
byte *buf;
// quick case to reject unneeded conversions
switch( pic->type )
{
case PF_UV_32:
case PF_RGBA_GN:
case PF_RGBA_32:
case PF_ABGR_128F:
return pic; // just change type
}
Image_CopyParms( pic );
if( image.flags & IMAGE_CUBEMAP ) numsides = 6;
Image_SetPixelFormat( image.width, image.height, image.num_layers ); // setup
image.size = image.ptr = 0;
if( image.cmd_flags & IL_IGNORE_MIPS ) image.cur_mips = 1;
else image.cur_mips = image.num_mips;
image.num_mips = 0; // clear mipcount
buf = image.rgba;
for( i = 0, offset = 0; i < numsides; i++, buf += offset )
{
Image_SetPixelFormat( image.curwidth, image.curheight, image.curdepth );
offset = image.SizeOfFile; // move pointer
Image_DecompressDDS( buf, target + i );
}
// now we can change type to RGBA
if( image.filter != CB_HINT_NO ) image.flags &= ~IMAGE_CUBEMAP; // side extracted
image.type = PF_RGBA_32;
FS_FreeImage( pic ); // free original
return ImagePack();
}
void Image_Process( rgbdata_t **pix, int width, int height, uint flags )
{
rgbdata_t *pic = *pix;
@ -1208,10 +1266,10 @@ void Image_Process( rgbdata_t **pix, int width, int height, uint flags )
return;
}
// FIXME:
// if( flags & IMAGE_FORCE_RGBA ) Sys_Error( "Image_Process: Image_ForceRGBA not implemented\n" );
// update format to RGBA if any
if( flags & IMAGE_FORCE_RGBA ) pic = Image_DecompressInternal( pic );
// NOTE: flip and resample algorythms can't different palette size
// NOTE: flip and resample algorythms can't difference palette size
if( flags & IMAGE_PALTO24 ) Image_ConvertPalTo24bit( pic );
out = Image_FlipInternal( pic->buffer, &pic->width, &pic->height, pic->type, flags );
if( pic->buffer != out ) Mem_Copy( pic->buffer, image.tempbuffer, pic->size );

View File

@ -973,15 +973,35 @@ choseclump:
return (void *)((byte *) mem + sizeof(memheader_t));
}
static const char *_mem_check_filename( const char *filename )
{
static const char *dummy = "<corrupted>\0";
const char *out = filename;
int i;
if( !out ) return dummy;
for( i = 0; i < 32; i++, out++ )
if( out == '\0' ) break; // valid name
if( i == 32 ) return dummy;
return filename;
}
static void _mem_freeblock(memheader_t *mem, const char *filename, int fileline)
{
int i, firstblock, endblock;
memclump_t *clump, **clumpchainpointer;
mempool_t *pool;
if (mem->sentinel1 != MEMHEADER_SENTINEL1) Sys_Error("Mem_Free: trashed header sentinel 1 (alloc at %s:%i, free at %s:%i)\n", mem->filename, mem->fileline, filename, fileline);
if (*((byte *) mem + sizeof(memheader_t) + mem->size) != MEMHEADER_SENTINEL2)
Sys_Error("Mem_Free: trashed header sentinel 2 (alloc at %s:%i, free at %s:%i)\n", mem->filename, mem->fileline, filename, fileline);
if( mem->sentinel1 != MEMHEADER_SENTINEL1 )
{
mem->filename = _mem_check_filename( mem->filename ); // make sure what we don't crash var_args
Sys_Error( "Mem_Free: trashed header sentinel 1 (alloc at %s:%i, free at %s:%i)\n", mem->filename, mem->fileline, filename, fileline );
}
if(*((byte *) mem + sizeof(memheader_t) + mem->size) != MEMHEADER_SENTINEL2 )
{
mem->filename = _mem_check_filename( mem->filename ); // make sure what we don't crash var_args
Sys_Error( "Mem_Free: trashed header sentinel 2 (alloc at %s:%i, free at %s:%i)\n", mem->filename, mem->fileline, filename, fileline );
}
pool = mem->pool;
// unlink memheader from doubly linked list
if ((mem->prev ? mem->prev->next != mem : pool->chain != mem) || (mem->next && mem->next->prev != mem))
@ -1321,10 +1341,16 @@ void _mem_checkheadersentinels( void *data, const char *filename, int fileline )
if (data == NULL) Sys_Error("Mem_CheckSentinels: data == NULL (sentinel check at %s:%i)\n", filename, fileline);
mem = (memheader_t *)((byte *) data - sizeof(memheader_t));
if (mem->sentinel1 != MEMHEADER_SENTINEL1)
if( mem->sentinel1 != MEMHEADER_SENTINEL1 )
{
mem->filename = _mem_check_filename( mem->filename ); // make sure what we don't crash var_args
Sys_Error("Mem_CheckSentinels: trashed header sentinel 1 (block allocated at %s:%i, sentinel check at %s:%i)\n", mem->filename, mem->fileline, filename, fileline);
if (*((byte *) mem + sizeof(memheader_t) + mem->size) != MEMHEADER_SENTINEL2)
}
if(*((byte *) mem + sizeof(memheader_t) + mem->size) != MEMHEADER_SENTINEL2 )
{
mem->filename = _mem_check_filename( mem->filename ); // make sure what we don't crash var_args
Sys_Error("Mem_CheckSentinels: trashed header sentinel 2 (block allocated at %s:%i, sentinel check at %s:%i)\n", mem->filename, mem->fileline, filename, fileline);
}
}
static void _mem_checkclumpsentinels( memclump_t *clump, const char *filename, int fileline )

View File

@ -784,6 +784,12 @@ static bool PS_ReadName( script_t *script, scFlags_t flags, token_t *token )
&& c != '/' && c != '\\' && c != ':' && c != '.' && c != '+' && c != '-')
break;
}
else if( flags & SC_ALLOW_PATHNAMES2 )
{
if((c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && (c < '0' || c > '9')
&& c != '_' && c != '/' && c != '\\' && c != ':' && c != '.' && c != '+'
&& c != '-' && c != '{' && c != '!' && c != '$' ) break;
}
else
{
if((c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && (c < '0' || c > '9') && c != '_')
@ -924,6 +930,13 @@ bool PS_ReadToken( script_t *script, scFlags_t flags, token_t *token )
if( PS_ReadLiteral( script, flags, token ))
return true;
}
// old pathnames must be grab before numbers because they contains '+', '-' and other unexpected symbols
else if((flags & SC_ALLOW_PATHNAMES2) && (*script->text == '/' || *script->text == '\\' || *script->text == ':' || *script->text == '.'
|| *script->text == '$' || *script->text == '-' || *script->text == '+' || *script->text == '!' || *script->text == '{' )) // damn prefix!
{
if( PS_ReadName( script, flags, token ))
return true;
}
// if it is a number
else if((*script->text >= '0' && *script->text <= '9') || (*script->text == '.' && (script->text[1] >= '0' && script->text[1] <= '9')))
{

View File

@ -331,6 +331,7 @@ void Sys_LookupInstance( void )
else if(!com_strcmp(Sys.progname, "bsplib"))
{
Sys.app_name = HOST_BSPLIB;
Sys.log_active = true; // always create log
Sys.linked_dll = &common_dll; // pointer to common.dll info
com_strcpy(Sys.log_path, "bsplib.log" ); // xash3d root directory
com_strcpy(Sys.caption, "Xash3D BSP Compiler");

View File

@ -91,7 +91,7 @@ typedef enum
CONTENTS_TRIGGER = BIT(23),// trigger volume
// content masks
MASK_SOLID = (CONTENTS_SOLID||CONTENTS_WINDOW),
MASK_SOLID = (CONTENTS_SOLID|CONTENTS_WINDOW),
MASK_PLAYERSOLID = (CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW|CONTENTS_BODY),
MASK_MONSTERSOLID = (CONTENTS_SOLID|CONTENTS_MONSTERCLIP|CONTENTS_WINDOW|CONTENTS_BODY),
MASK_DEADSOLID = (CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW|CONTENTS_WINDOW),
@ -117,6 +117,8 @@ typedef enum
SURF_NULL = BIT(11),// remove face after compile
SURF_NOLIGHTMAP = BIT(12),// don't place lightmap for this surface
SURF_MIRROR = BIT(12),// remove face after compile
SURF_CHROME = BIT(13),// chrome surface effect
SURF_GLOW = BIT(14),// sprites glow
} surfaceType_t;
// engine physics constants

View File

@ -184,11 +184,12 @@ typedef enum
SC_ALLOW_STRINGCONCAT = BIT(1),
SC_ALLOW_ESCAPECHARS = BIT(2),
SC_ALLOW_PATHNAMES = BIT(3),
SC_PARSE_GENERIC = BIT(4),
SC_PRINT_ERRORS = BIT(5),
SC_PRINT_WARNINGS = BIT(6),
SC_PARSE_LINE = BIT(7), // read line, ignore whitespaces
SC_COMMENT_SEMICOLON = BIT(8), // using semicolon as mark or begin comment (q2 oldstyle)
SC_ALLOW_PATHNAMES2 = BIT(4), // allow pathnames with quake symbols (!, %, $, +, -, { )
SC_PARSE_GENERIC = BIT(5),
SC_PRINT_ERRORS = BIT(6),
SC_PRINT_WARNINGS = BIT(7),
SC_PARSE_LINE = BIT(8), // read line, ignore whitespaces
SC_COMMENT_SEMICOLON = BIT(9), // using semicolon as mark or begin comment (q2 oldstyle)
} scFlags_t;
typedef struct

View File

@ -175,31 +175,30 @@ BRUSH MODELS
#define MAX_LIGHT_STYLES 64
#define MAX_SWITCHED_LIGHTS 32
// lump offset (TODO: compress it same as much more as possible)
// lump offset
#define LUMP_ENTITIES 0
#define LUMP_PLANES 1
#define LUMP_LEAFS 2
#define LUMP_LEAFFACES 3
#define LUMP_LEAFBRUSHES 4
#define LUMP_NODES 5
#define LUMP_VERTEXES 6
#define LUMP_EDGES 7
#define LUMP_SURFEDGES 8
#define LUMP_TEXINFO 9
#define LUMP_SURFACES 10
#define LUMP_MODELS 11
#define LUMP_BRUSHES 12
#define LUMP_BRUSHSIDES 13
#define LUMP_VISIBILITY 14
#define LUMP_LIGHTING 15
#define LUMP_COLLISION 16 // newton collision tree (worldmodel coords already convert to meters)
#define LUMP_SHADERS 17 // contains texture name and dims
#define LUMP_SHADERS 1 // contains shader name and dims
#define LUMP_PLANES 2
#define LUMP_LEAFS 3
#define LUMP_LEAFFACES 4 // marksurfaces
#define LUMP_LEAFBRUSHES 5
#define LUMP_NODES 6
#define LUMP_VERTEXES 7
#define LUMP_EDGES 8
#define LUMP_SURFEDGES 9
#define LUMP_TEXINFO 10
#define LUMP_SURFACES 11
#define LUMP_MODELS 12 // bsp brushmodels
#define LUMP_BRUSHES 13
#define LUMP_BRUSHSIDES 14
#define LUMP_VISIBILITY 15
#define LUMP_LIGHTING 16
#define LUMP_COLLISION 17 // prepared newton collision tree
#define LUMP_LIGHTGRID 18 // private server.dat for current map
// get rid of this
#define LUMP_AREAS 19
#define LUMP_AREAPORTALS 20
#define LUMP_TOTALCOUNT 32 // max lumps
// reserved for future expansions
#define LUMP_TOTALCOUNT 24 // max lumps
typedef struct
{

View File

@ -67,5 +67,5 @@ if exist vsound\vsound.plg del /f /q vsound\vsound.plg
echo Build succeeded!
echo Please wait. Xash is now loading
cd D:\Xash3D\
quake.exe -game tmpQuArK -dev 5 -debug -log +map qctest
quake.exe -game tmpQuArK -dev 3 -log +map start +load quick
:done

View File

@ -13,7 +13,8 @@ static int r_textureMinFilter = GL_LINEAR_MIPMAP_LINEAR;
static int r_textureMagFilter = GL_LINEAR;
// internal tables
static vec3_t r_luminanceTable[256]; // RGB to LUMA
static vec3_t r_luminanceTable[256]; // RGB to luminance
static byte r_glowTable[256][3]; // auto LUMA table
static byte r_intensityTable[256]; // scale intensity
static byte r_gammaTable[256]; // adjust screenshot gamma
@ -896,6 +897,42 @@ static rgbdata_t *R_MakeLuminance( rgbdata_t *in )
return out;
}
/*
=================
R_MakeGlow
Converts the given image to glow (LUMA)
=================
*/
static rgbdata_t *R_MakeGlow( rgbdata_t *in )
{
rgbdata_t *out;
int width, height;
byte r, g, b;
int x, y;
// make sure what we processing RGBA image
in = R_ForceImageToRGBA( in );
width = in->width, height = in->height;
out = in;
for( y = 0; y < height; y++ )
{
for( x = 0; x < width; x++ )
{
r = r_glowTable[in->buffer[4*(y*width+x)+0]][0];
g = r_glowTable[in->buffer[4*(y*width+x)+1]][1];
b = r_glowTable[in->buffer[4*(y*width+x)+2]][2];
out->buffer[4*(y*width+x)+0] = r;
out->buffer[4*(y*width+x)+1] = g;
out->buffer[4*(y*width+x)+2] = b;
out->buffer[4*(y*width+x)+3] = 255; // kill alpha if any
}
}
return out;
}
/*
=================
R_MakeAlpha
@ -1586,9 +1623,48 @@ static rgbdata_t *R_ParseMakeAlpha( script_t *script, int *samples, texFlags_t *
}
/*
=================
R_ParseHeightMap
=================
=================
R_ParseMakeGlow
=================
*/
static rgbdata_t *R_ParseMakeGlow( script_t *script, int *samples, texFlags_t *flags )
{
token_t token;
rgbdata_t *pic;
Com_ReadToken( script, 0, &token );
if( com.stricmp( token.string, "(" ))
{
MsgDev( D_WARN, "expected '(', found '%s' instead for 'makeGlow'\n", token.string );
return NULL;
}
if( !Com_ReadToken( script, SC_ALLOW_PATHNAMES2, &token ))
{
MsgDev( D_WARN, "missing parameters for 'makeGlow'\n" );
return NULL;
}
pic = R_LoadImage( script, token.string, NULL, 0, samples, flags );
if( !pic ) return NULL;
Com_ReadToken( script, 0, &token );
if( com.stricmp( token.string, ")" ))
{
MsgDev( D_WARN, "expected ')', found '%s' instead for 'makeGlow'\n", token.string );
FS_FreeImage( pic );
return NULL;
}
*samples = 3;
return R_MakeGlow( pic );
}
/*
=================
R_ParseHeightMap
=================
*/
static rgbdata_t *R_ParseHeightMap( script_t *script, int *samples, texFlags_t *flags )
{
@ -1785,6 +1861,8 @@ static rgbdata_t *R_LoadImage( script_t *script, const char *name, const byte *b
return R_ParseMakeLuminance( script, samples, flags);
else if( !com.stricmp( name, "makeAlpha" ))
return R_ParseMakeAlpha( script, samples, flags );
else if( !com.stricmp( name, "makeGlow" ))
return R_ParseMakeGlow( script, samples, flags );
else if( !com.stricmp( name, "heightMap" ))
return R_ParseHeightMap( script, samples, flags );
else if( !com.stricmp( name, "addNormals" ))
@ -2679,6 +2757,15 @@ void R_InitTextures( void )
r_intensityTable[i] = bound( 0, j, 255 );
}
// build the auto-luma table
for( i = 0; i < 256; i++ )
{
// 224 is a Q1 luma threshold
r_glowTable[i][0] = i > 196 ? i : 0;
r_glowTable[i][1] = i > 196 ? i : 0;
r_glowTable[i][2] = i > 196 ? i : 0;
}
// build luminance table
for( i = 0; i < 256; i++ )
{

View File

@ -46,39 +46,45 @@ static int r_numTables;
ref_shader_t *r_shaders[MAX_SHADERS];
int r_numShaders = 0;
// NOTE: this table must match with same table in common\bsplib\shaders.c
shaderParm_t infoParms[] =
{
// server relevant contents
{"water", 0, CONTENTS_WATER },
{"slime", 0, CONTENTS_SLIME, }, // mildly damaging
{"lava", 0, CONTENTS_LAVA, }, // very damaging
{"playerclip", 0, CONTENTS_PLAYERCLIP, },
{"monsterclip", 0, CONTENTS_MONSTERCLIP, },
{"clip", 0, CONTENTS_CLIP, },
{"nonsolid", 0, 0, }, // just clears the solid flag
{"window", SURF_NONE, CONTENTS_WINDOW, },
{"aux", SURF_NONE, CONTENTS_AUX, },
{"warp", SURF_WARP, CONTENTS_NONE, },
{"water", SURF_NONE, CONTENTS_WATER, },
{"slime", SURF_NONE, CONTENTS_SLIME, }, // mildly damaging
{"lava", SURF_NONE, CONTENTS_LAVA, }, // very damaging
{"playerclip", SURF_NONE, CONTENTS_PLAYERCLIP, },
{"monsterclip", SURF_NONE, CONTENTS_MONSTERCLIP, },
{"clip", SURF_NONE, CONTENTS_CLIP, },
{"notsolid", SURF_NONE, CONTENTS_NONE, },
{"trigger", SURF_NONE, CONTENTS_TRIGGER, },
// utility relevant attributes
{"origin", 0, CONTENTS_ORIGIN, }, // center of rotating brushes
{"trans", 0, CONTENTS_TRANSLUCENT, }, // don't eat contained surfaces
{"detail", 0, CONTENTS_DETAIL, }, // carves surfaces entering
{"areaportal", 0, CONTENTS_AREAPORTAL, },
{"fog", 0, CONTENTS_FOG, }, // carves surfaces entering
{"sky", SURF_SKY, 0, }, // emit light from environment map
{"hint", SURF_HINT, 0, }, // use as a primary splitter
{"skip", SURF_NODRAW, 0, }, // use as a secondary splitter
{"null", SURF_NODRAW, 0, }, // don't generate a drawsurface
{"nodraw", SURF_NODRAW, 0, }, // don't generate a drawsurface
{"origin", SURF_NONE, CONTENTS_ORIGIN, }, // center of rotating brushes
{"nolightmap", SURF_NOLIGHTMAP, CONTENTS_NONE, }, // don't generate a lightmap
{"translucent", SURF_NONE, CONTENTS_TRANSLUCENT, }, // don't eat contained surfaces
{"detail", SURF_NONE, CONTENTS_DETAIL, }, // carves surfaces entering
{"fog", SURF_NOLIGHTMAP, CONTENTS_FOG, }, // carves surfaces entering
{"sky", SURF_SKY, CONTENTS_NONE, }, // emit light from environment map
{"hint", SURF_HINT, CONTENTS_NONE, }, // use as a primary splitter
{"skip", SURF_SKIP, CONTENTS_NONE, }, // use as a secondary splitter
{"null", SURF_NODRAW, CONTENTS_NONE, }, // don't generate a drawsurface
{"mirror", SURF_MIRROR, CONTENTS_NONE, }, // mirror surface
// server attributes
{"slick", 0, SURF_SLICK, },
{"ladder", 0, CONTENTS_LADDER, },
{"slick", SURF_SLICK, CONTENTS_NONE, },
{"light", SURF_LIGHT, CONTENTS_NONE, },
{"ladder", SURF_NONE, CONTENTS_LADDER, },
// drawsurf attributes
{"nolightmap", SURF_NOLIGHTMAP, 0, }, // don't generate a lightmap
{"alpha", SURF_ALPHA, CONTENTS_TRANSLUCENT, }, // alpha surface preset
{"additive", SURF_ADDITIVE, CONTENTS_TRANSLUCENT, }, // additive surface preset
{"blend", SURF_BLEND, CONTENTS_TRANSLUCENT, }, // blend surface preset
{"mirror", SURF_MIRROR, 0, }, // mirror surface
// drawsurf attributes (matched with Half-Life render modes)
{"texture", SURF_BLEND, CONTENTS_NONE, }, // blend surface
{"glow", SURF_GLOW, CONTENTS_NONE, }, // glow sprite
{"solid", SURF_ALPHA, CONTENTS_NONE, }, // alphatest
{"additive", SURF_ADDITIVE, CONTENTS_NONE, }, // additive
{"chrome", SURF_CHROME, CONTENTS_NONE, }, // studio chrome
};
/*
@ -1764,7 +1770,7 @@ static bool R_ParseStageMap( ref_shader_t *shader, shaderStage_t *stage, script_
return false;
}
if( !Com_ReadToken( script, SC_PARSE_GENERIC, &tok ))
if( !Com_ReadToken( script, SC_ALLOW_PATHNAMES2, &tok ))
{
MsgDev( D_WARN, "missing parameters for 'map' in shader '%s'\n", shader->name );
return false;
@ -3898,7 +3904,7 @@ static ref_shader_t *R_CreateDefaultShader( const char *name, int shaderType, ui
shader->stages[0]->numBundles++;
shader->numStages++;
if(!( shader->surfaceParm & SURF_NOLIGHTMAP ))
if(!( shader->surfaceParm & (SURF_NOLIGHTMAP|SURF_LIGHT)))
{
shader->flags |= SHADER_HASLIGHTMAP;
shader->stages[1]->bundles[0]->flags |= STAGEBUNDLE_MAP;
@ -4053,9 +4059,9 @@ static ref_shader_t *R_CreateShader( const char *name, int shaderType, uint surf
shader->surfaceParm = surfaceParm;
shader->flags = SHADER_EXTERNAL;
if( shaderType == SHADER_NOMIP ) shader->flags |= (SHADER_NOMIPMAPS | SHADER_NOPICMIP);
if( shaderType == SHADER_NOMIP ) shader->flags |= (SHADER_NOMIPMAPS|SHADER_NOPICMIP);
// If we have a script, create an external shader
// if we have a script, create an external shader
if( shaderScript )
{
shader->shaderScript = shaderScript;
@ -4064,6 +4070,8 @@ static ref_shader_t *R_CreateShader( const char *name, int shaderType, uint surf
script = Com_OpenScript( shaderScript->name, shaderScript->buffer, shaderScript->size );
if( !script ) return R_CreateDefaultShader( name, shaderType, surfaceParm );
Msg("ParseScript: %s\n", shaderScript->name );
// parse it
if( !R_ParseShader( shader, script ))
{
@ -4768,10 +4776,8 @@ shader_t R_FindShader( const char *name, int shaderType, uint surfaceParm )
{
if( !com.stricmp( shaderScript->name, name ))
{
if( shaderScript->type == -1 ) // not initialized
break;
if( shaderScript->type == shaderType && shaderScript->surfaceParm == surfaceParm )
break;
if( shaderScript->type == -1 ) break; // not initialized
if( shaderScript->type == shaderType ) break;
}
}
@ -5036,7 +5042,7 @@ void R_InitShaders( void )
MsgDev( D_NOTE, "R_InitShaders()\n" );
r_shaderpool = Mem_AllocPool( "Shader Zone" );
t = FS_Search( "scripts/shaders/*.txt", true );
t = FS_Search( "scripts/*.shader", true );
if( !t ) MsgDev( D_WARN, "no shader files found!\n");
// Load them

View File

@ -15,6 +15,7 @@ fopen
1. Поддержка loop для ogg vorbis
2. переписать studiomdl для использования VFS
3. избавится от PR_ParseToken\Word в vprogs.dll
4. поправить генератор шейдеров в extragen
GLOBAL: Достигнуть уровня xash 0.45 к очередному релизу
@ -22,9 +23,13 @@ GLOBAL:
1. имплементация нового формата карт OK
2. новый загрузчик моделей на рендере OK
3. проверить 4 варианта winding.c
4. переписать загрузчик BSP
5. отладить R_ImageFreeUnused OK
6. переписать генератор порталов
4. переписать загрузчик BSP OK
5. отладить R_ImageFreeUnused
6. дописать Image_ForceRGBA OK
7. SC_ALLOW_PATHNAMES2 - набор символов OK
8. упорядочить ресурсы OK
9. оставить только tmpQuArK OK
10. починить IMAGE_FORCE_RGBA (или избавится ?)
операция "Полная отладка менеджера текстур"
0. анализ менеджера egl и q2e_068

View File

@ -502,7 +502,7 @@ word PR_WriteProgdefs( void )
switch( crc )
{
case 9289:
case 9691:
PR_Message("Xash3D unmodified server.dat\n");
if(!com.strcmp(progsoutname, "unknown.dat")) com.strcpy(progsoutname, "server.dat");
break;