07 Dec 2008

This commit is contained in:
g-cont 2008-12-07 00:00:00 +03:00 committed by Alibek Omarov
parent b4a5fd9f16
commit 5802157c26
26 changed files with 227 additions and 190 deletions

View File

@ -242,7 +242,8 @@ bspbrush_t *AllocBrush (int numsides)
int c;
c = (int)&(((bspbrush_t *)0)->sides[numsides]);
bb = Malloc(c);
bb = malloc(c);
memset (bb, 0, c);
if (GetNumThreads() == 1) c_active_brushes++;
return bb;
}
@ -259,7 +260,7 @@ void FreeBrush (bspbrush_t *brushes)
for (i=0 ; i<brushes->numsides ; i++)
if (brushes->sides[i].winding)
FreeWinding(brushes->sides[i].winding);
Mem_Free (brushes);
free(brushes);
if (GetNumThreads() == 1)
c_active_brushes--;
}

View File

@ -71,6 +71,7 @@ bool PrepareBSPModel( const char *dir, const char *name )
int numshaders;
bsp_parms = 0;
maxdist = 0.0;
bsplog = NULL;
// get global parms
@ -80,6 +81,7 @@ bool PrepareBSPModel( const char *dir, const char *name )
if( FS_CheckParm( "-full" )) bsp_parms |= BSPLIB_FULLCOMPILE;
if( FS_CheckParm( "-onlyents" )) bsp_parms |= BSPLIB_ONLYENTS;
if( FS_CheckParm( "-info" )) bsp_parms |= BSPLIB_SHOWINFO;
if( FS_CheckParm( "-cullerror" )) bsp_parms |= BSPLIB_CULLERROR;
// famous q1 "notexture" image: purple-black checkerboard
checkermate_dds = FS_LoadInternal( "checkerboard.dds", &checkermate_dds_size );

View File

@ -50,11 +50,13 @@ typedef enum
BSPLIB_RAD_NOCOLOR = BIT(8),
BSPLIB_DELETE_TEMP = BIT(9), // delete itermediate files
BSPLIB_SHOWINFO = BIT(10),
BSPLIB_CULLERROR = BIT(11),
} bsplibFlags_t;
extern uint bsp_parms;
extern char path[MAX_SYSPATH];
extern cvar_t *bsplib_compress_bsp;
extern float maxdist;
// bsplib export functions
void WradMain( void );
@ -258,19 +260,20 @@ typedef struct
typedef enum {stat_none, stat_working, stat_done} vstatus_t;
typedef struct
{
visplane_t plane; // normal pointing into neighbor
int leaf; // neighbor
vec3_t origin; // for fast clip testing
visplane_t plane; // normal pointing into neighbor
int leaf; // neighbor
int owner_leaf; // neighbor
vec3_t origin; // for fast clip testing
float radius;
viswinding_t *winding;
vstatus_t status;
byte *portalfront; // [portals], preliminary
byte *portalflood; // [portals], intermediate
byte *portalvis; // [portals], final
byte *portalvis; // [portals], final
int nummightsee; // bit count on portalflood for sort
int nummightsee; // bit count on portalflood for sort
} visportal_t;
typedef struct seperating_plane_s

View File

@ -462,11 +462,13 @@ float d;
d = DotProduct (thread->base->origin, p->plane.normal);
d -= p->plane.dist;
if (d > p->radius)
if (d > thread->base->radius)
// if (d > p->radius)
{
continue;
}
else if (d < -p->radius)
// else if (d < -p->radius)
else if (d < -thread->base->radius)
{
stack.source = prevstack->source;
}
@ -589,6 +591,7 @@ all seperating planes, and both portals must be behind the mew portal
int c_flood, c_vis;
char test_leaf[MAX_MAP_LEAFS];
/*
==================
@ -603,6 +606,11 @@ void SimpleFlood (visportal_t *srcportal, int leafnum)
visportal_t *p;
int pnum;
if( bsp_parms & BSPLIB_CULLERROR && !test_leaf[leafnum])
return;
test_leaf[leafnum] = 0;
leaf = &leafs[leafnum];
for (i=0 ; i<leaf->numportals ; i++)
@ -632,18 +640,27 @@ void BasePortalVis (int portalnum)
visportal_t *tp, *p;
float d;
viswinding_t *w;
vec3_t prenormal, normal;
float p_dot, tp_dot, p_rad, tp_rad;
p = portals+portalnum;
p->portalfront = Malloc (portalbytes);
p->portalflood = Malloc (portalbytes);
p->portalvis = Malloc (portalbytes);
Mem_Set( test_leaf, 0, MAX_MAP_LEAFS );
for (j=0, tp = portals ; j<numportals*2 ; j++, tp++)
{
if (j == portalnum)
continue;
else if( bsp_parms & BSPLIB_CULLERROR && tp->leaf == p->owner_leaf)
continue;
test_leaf[tp->leaf] = 1;
w = tp->winding;
for (k=0 ; k<w->numpoints ; k++)
{
d = DotProduct (w->points[k], p->plane.normal)
@ -665,6 +682,36 @@ void BasePortalVis (int portalnum)
if (k == w->numpoints)
continue; // no points on front
if( maxdist > 0.0 )
{
// This approximation will consider 2 circles in 3d space with the centeer
// and radius of the polygons on the planes of the polygons.
prenormal[0] = p->origin[0] - tp->origin[0];
prenormal[1] = p->origin[1] - tp->origin[1];
prenormal[2] = p->origin[2] - tp->origin[2];
VectorCopy( prenormal, normal );
d = VectorNormalizeLength( normal );
p_dot = DotProduct(p->plane.normal, normal);
if(p_dot < 0.0)
p_rad = -p_dot * p->radius;
else
p_rad = p_dot * p->radius;
tp_dot = DotProduct(tp->plane.normal, normal);
if(tp_dot < 0.0)
tp_rad = -tp_dot * tp->radius;
else
tp_rad = tp_dot * tp->radius;
if(d > (maxdist + tp_rad + p_rad))
continue;
}
p->portalfront[j>>3] |= (1<<(j&7));
}

View File

@ -230,6 +230,33 @@ int PlaneFromPoints( vec_t *p0, vec_t *p1, vec_t *p2 )
return FindFloatPlane( normal, dist );
}
void PrintContents( int cnt )
{
Msg("Contents:" );
if( cnt & CONTENTS_SOLID ) Msg( "solid " );
if( cnt & CONTENTS_WINDOW) Msg( "window " );
if( cnt & CONTENTS_AUX ) Msg( "aux " );
if( cnt & CONTENTS_LAVA) Msg( "lava " );
if( cnt & CONTENTS_SLIME) Msg( "slime " );
if( cnt & CONTENTS_WATER) Msg( "water " );
if( cnt & CONTENTS_SKY) Msg( "sky " );
if( cnt & CONTENTS_MIST) Msg( "mist " );
if( cnt & CONTENTS_FOG) Msg( "fog " );
if( cnt & CONTENTS_AREAPORTAL) Msg( "areaportal " );
if( cnt & CONTENTS_PLAYERCLIP) Msg( "playerclip " );
if( cnt & CONTENTS_MONSTERCLIP) Msg(" monsterclip " );
if( cnt & CONTENTS_CLIP) Msg( "clip " );
if( cnt & CONTENTS_ORIGIN) Msg(" origin" );
if( cnt & CONTENTS_BODY) Sys_Error("\nCONTENTS_BODY detected\n" );
if( cnt & CONTENTS_CORPSE) Sys_Error("\nCONTENTS_CORPSE detected\n" );
if( cnt & CONTENTS_DETAIL) Msg(" detail " );
if( cnt & CONTENTS_TRANSLUCENT) Msg( "translucent " );
if( cnt & CONTENTS_LADDER) Msg( "ladder " );
if( cnt & CONTENTS_TRIGGER) Msg( "trigger " );
Msg( "\n" );
}
//====================================================================
/*
@ -252,8 +279,9 @@ int BrushContents( mapbrush_t *b )
{
s = &b->original_sides[i];
trans |= dshaders[texinfo[s->texinfo].shadernum].surfaceFlags;
if( s->contents != contents )
if( s->contents != contents && !( trans & SURF_NODRAW ))
{
// nodraw textures are ignored
MsgDev( D_WARN, "Entity %i, Brush %i: mixed face contents\n", b->entitynum, b->brushnum );
break;
}

View File

@ -6,6 +6,8 @@
#include "bsplib.h"
#include "const.h"
#define BLOCK_SIZE 8192 // test
int block_xl = -8, block_xh = 7, block_yl = -8, block_yh = 7;
int entity_num;
node_t *block_nodes[10][10];
@ -45,7 +47,7 @@ node_t *BlockTree (int xl, int yl, int xh, int yh)
normal[0] = 1;
normal[1] = 0;
normal[2] = 0;
dist = mid*32768;
dist = mid*BLOCK_SIZE;
node->planenum = FindFloatPlane (normal, dist);
node->children[0] = BlockTree ( mid, yl, xh, yh);
node->children[1] = BlockTree ( xl, yl, mid-1, yh);
@ -56,7 +58,7 @@ node_t *BlockTree (int xl, int yl, int xh, int yh)
normal[0] = 0;
normal[1] = 1;
normal[2] = 0;
dist = mid*32768;
dist = mid*BLOCK_SIZE;
node->planenum = FindFloatPlane (normal, dist);
node->children[0] = BlockTree ( xl, mid, xh, yh);
node->children[1] = BlockTree ( xl, yl, xh, mid-1);
@ -84,12 +86,12 @@ void ProcessBlock_Thread (int blocknum)
yblock = block_yl + blocknum / (block_xh-block_xl+1);
xblock = block_xl + blocknum % (block_xh-block_xl+1);
mins[0] = xblock*32768;
mins[1] = yblock*32768;
mins[2] = -131072;
maxs[0] = (xblock+1)*32768;
maxs[1] = (yblock+1)*32768;
maxs[2] = 131072;
mins[0] = xblock*BLOCK_SIZE;
mins[1] = yblock*BLOCK_SIZE;
mins[2] = MIN_WORLD_COORD;
maxs[0] = (xblock+1)*BLOCK_SIZE;
maxs[1] = (yblock+1)*BLOCK_SIZE;
maxs[2] = MAX_WORLD_COORD;
// the makelist and chopbrushes could be cached between the passes...
brushes = MakeBspBrushList (brush_start, brush_end, mins, maxs);
@ -102,10 +104,12 @@ void ProcessBlock_Thread (int blocknum)
return;
}
brushes = ChopBrushes (brushes);
// brushes = ChopBrushes (brushes);
tree = BrushBSP (brushes, mins, maxs);
block_nodes[xblock+5][yblock+5] = tree->headnode;
Mem_Free( tree );
}
/*
@ -130,14 +134,14 @@ void ProcessWorldModel( void )
//
// perform per-block operations
//
if (block_xh * 32768 > map_maxs[0])
block_xh = floor(map_maxs[0]/32768.0);
if ( (block_xl+1) * 32768 < map_mins[0])
block_xl = floor(map_mins[0]/32768.0);
if (block_yh * 32768 > map_maxs[1])
block_yh = floor(map_maxs[1]/32768.0);
if ( (block_yl+1) * 32768 < map_mins[1])
block_yl = floor(map_mins[1]/32768.0);
if (block_xh * BLOCK_SIZE > map_maxs[0])
block_xh = floor(map_maxs[0]/BLOCK_SIZE);
if ( (block_xl+1) * BLOCK_SIZE < map_mins[0])
block_xl = floor(map_mins[0]/BLOCK_SIZE);
if (block_yh * BLOCK_SIZE > map_maxs[1])
block_yh = floor(map_maxs[1]/BLOCK_SIZE);
if ( (block_yl+1) * BLOCK_SIZE < map_mins[1])
block_yl = floor(map_mins[1]/BLOCK_SIZE);
if (block_xl <-4) block_xl = -4;
if (block_yl <-4) block_yl = -4;
@ -155,12 +159,12 @@ void ProcessWorldModel( void )
tree = AllocTree ();
tree->headnode = BlockTree (block_xl-1, block_yl-1, block_xh+1, block_yh+1);
tree->mins[0] = (block_xl)*32768;
tree->mins[1] = (block_yl)*32768;
tree->mins[0] = (block_xl)*BLOCK_SIZE;
tree->mins[1] = (block_yl)*BLOCK_SIZE;
tree->mins[2] = map_mins[2] - 8;
tree->maxs[0] = (block_xh+1)*32768;
tree->maxs[1] = (block_yh+1)*32768;
tree->maxs[0] = (block_xh+1)*BLOCK_SIZE;
tree->maxs[1] = (block_yh+1)*BLOCK_SIZE;
tree->maxs[2] = map_maxs[2] + 8;
//
@ -218,8 +222,8 @@ void ProcessSubModel (void)
start = e->firstbrush;
end = start + e->numbrushes;
mins[0] = mins[1] = mins[2] = -131072;
maxs[0] = maxs[1] = maxs[2] = 131072;
mins[0] = mins[1] = mins[2] = MIN_WORLD_COORD;
maxs[0] = maxs[1] = maxs[2] = MAX_WORLD_COORD;
list = MakeBspBrushList (start, end, mins, maxs);
list = ChopBrushes (list);
tree = BrushBSP (list, mins, maxs);

View File

@ -19,6 +19,7 @@ int portalbytes, portallongs;
int totalvis;
int totalphs;
visportal_t *sorted_portals[MAX_MAP_PORTALS*2];
float maxdist;
/*
===============
@ -152,23 +153,23 @@ void PlaneFromWinding( viswinding_t *w, visplane_t *plane )
plane->dist = DotProduct (w->points[0], plane->normal);
}
/*
==================
NewVisWinding
==================
*/
viswinding_t *NewVisWinding (int points)
viswinding_t *NewVisWinding( int points )
{
viswinding_t *w;
int size;
int size;
if (points > MAX_POINTS_ON_WINDING)
if( points > MAX_POINTS_ON_WINDING )
Sys_Error ("NewVisWinding: %i points", points);
size = (int)((viswinding_t *)0)->points[points];
w = Malloc (size);
w = malloc( size );
memset( w, 0, size );
return w;
}
@ -518,6 +519,7 @@ void LoadPortals( void )
p++;
}
Com_CloseScript( prtfile );
}
void ClusterPHS( int clusternum )

View File

@ -186,10 +186,12 @@ void Conv_RunSearch( void )
AddMask( "*.flt" ); // Doom1 textures
AddMask( "*.mus" ); // Doom1 music
}
if( !FS_CheckParm( "-force32" ))
if( !FS_CheckParm( "-force32" ))
{
imageflags |= IL_KEEP_8BIT;
write_qscsript = true;
}
Image_Init( "Doom1", imageflags );
write_qscsript = true;
break;
case GAME_HEXEN2:
case GAME_QUAKE1:
@ -211,8 +213,10 @@ void Conv_RunSearch( void )
AddMask( "*.sp32");
AddMask( "*.spr" );
if( !FS_CheckParm( "-force32" ))
{
imageflags |= IL_KEEP_8BIT;
write_qscsript = true;
write_qscsript = true;
}
Image_Init( "Quake1", imageflags );
break;
case GAME_QUAKE2:
@ -235,8 +239,10 @@ void Conv_RunSearch( void )
AddMask( "pics/*.pcx"); // Quake2 pics
AddMask( "env/*.pcx" ); // Quake2 skyboxes
if( !FS_CheckParm( "-force32" ))
{
imageflags |= IL_KEEP_8BIT;
write_qscsript = true;
write_qscsript = true;
}
Image_Init( "Quake2", imageflags );
break;
case GAME_RTCW:
@ -331,8 +337,10 @@ void Conv_RunSearch( void )
AddMask( "maps/*.bsp" ); // textures from bsp
AddMask( "sprites/*.spr" ); // Half-Life sprites
if( !FS_CheckParm( "-force32" ))
{
imageflags |= IL_KEEP_8BIT;
write_qscsript = true;
write_qscsript = true;
}
Image_Init( "Half-Life", imageflags );
break;
case GAME_XASH3D:

View File

@ -192,7 +192,7 @@ void CL_LevelShot_f( void )
string checkname;
// check for exist
com.sprintf( checkname, "gfx/background/%s.png", cl.configstrings[CS_NAME] );
com.sprintf( checkname, "media/background/%s.png", cl.configstrings[CS_NAME] );
if(!FS_FileExists( checkname )) re->ScrShot( checkname, true );
else Msg("levelshot for this map already created\nFirst remove old image if you wants do it again\n" );
}

View File

@ -1029,7 +1029,7 @@ void CL_RequestNextDownload( void )
while( precache_tex < pe->NumTextures())
{
com.sprintf( fn, "textures/%s.tga", pe->GetTextureName( precache_tex++ ));
if(!CL_CheckOrDownloadFile(fn)) return; // started a download
if(!CL_CheckOrDownloadFile( fn )) return; // started a download
}
}
precache_check = TEXTURE_CNT + 999;

View File

@ -210,11 +210,11 @@ void CL_ParseServerData( sizebuf_t *msg )
str = MSG_ReadString( msg );
// get splash name
Cvar_Set( "cl_levelshot_name", va( "background/%s.png", str ));
Cvar_SetValue("scr_loading", 0.0f ); // reset progress bar
if(!FS_FileExists( va("gfx/%s", Cvar_VariableString( "cl_levelshot_name" ))))
Cvar_Set( "cl_levelshot_name", va( "media/background/%s.png", str ));
Cvar_SetValue( "scr_loading", 0.0f ); // reset progress bar
if(!FS_FileExists( Cvar_VariableString( "cl_levelshot_name" )))
{
Cvar_Set("cl_levelshot_name", "common/black");
Cvar_Set( "cl_levelshot_name", "" );
cl.make_levelshot = true; // make levelshot
}
// seperate the printfs so the server message can have a color

View File

@ -6,25 +6,6 @@
#include "common.h"
#include "client.h"
#define STAT_MINUS 10 // num frame for '-' stats digit
const char *field_nums[11] =
{
"hud/num_0",
"hud/num_1",
"hud/num_2",
"hud/num_3",
"hud/num_4",
"hud/num_5",
"hud/num_6",
"hud/num_7",
"hud/num_8",
"hud/num_9",
"hud/num_-",
};
static shader_t field_shaders[11];
/*
================
CL_FadeColor
@ -241,45 +222,6 @@ static void PF_ReadCoord (void){ PRVM_G_FLOAT(OFS_RETURN) = MSG_ReadBits( cls.mu
static void PF_ReadString (void){ PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString( MSG_ReadString( cls.multicast) ); }
static void PF_ReadEntity (void){ VM_RETURN_EDICT( PRVM_PROG_TO_EDICT( MSG_ReadShort( cls.multicast ))); } // entindex
/*
=========
PF_drawfield
void DrawField( float value, vector pos, vector size )
=========
*/
static void PF_drawfield( void )
{
char num[16], *ptr;
int l, frame;
float value, *pos, *size;
if(!VM_ValidateArgs( "drawpic", 3 ))
return;
value = PRVM_G_FLOAT(OFS_PARM0);
pos = PRVM_G_VECTOR(OFS_PARM1);
size = PRVM_G_VECTOR(OFS_PARM2);
com.snprintf( num, 16, "%i", (int)value );
l = com.strlen( num );
ptr = num;
if( size[0] == 0.0f ) size[0] = GIANTCHAR_WIDTH;
if( size[1] == 0.0f ) size[1] = GIANTCHAR_HEIGHT;
while( *ptr && l )
{
if( *ptr == '-' ) frame = STAT_MINUS;
else frame = *ptr -'0';
SCR_DrawPic( pos[0], pos[1], size[0], size[1], field_shaders[frame] );
pos[0] += size[0];
ptr++;
l--;
}
re->SetColor( NULL );
}
/*
=========
PF_drawnet
@ -292,14 +234,14 @@ static void PF_drawnet( void )
float *pos;
shader_t shader;
if(!VM_ValidateArgs( "drawnet", 2 ))
if(!VM_ValidateArgs( "DrawNet", 2 ))
return;
if(cls.netchan.outgoing_sequence - cls.netchan.incoming_acknowledged < CMD_BACKUP-1)
return;
VM_ValidateString(PRVM_G_STRING(OFS_PARM1));
pos = PRVM_G_VECTOR(OFS_PARM0);
shader = re->RegisterShader( va( "gfx/%s", PRVM_G_STRING(OFS_PARM1)), SHADER_NOMIP );
shader = re->RegisterShader( PRVM_G_STRING(OFS_PARM1), SHADER_NOMIP );
SCR_DrawPic( pos[0], pos[1], -1, -1, shader );
}
@ -712,7 +654,7 @@ VM_drawstring, // #114 float DrawString( vector pos, string text, vector scale
VM_drawpic, // #115 float DrawPic( vector pos, string pic, vector size, vector rgb, float alpha )
VM_drawfill, // #116 void DrawFill( vector pos, vector size, vector rgb, float alpha )
VM_drawmodel, // #117 void DrawModel( vector pos, vector size, string mod, vector org, vector ang, float seq )
PF_drawfield, // #118 void DrawField( float value, vector pos, vector size )
NULL, // #118 -- reserved --
VM_getimagesize, // #119 vector getimagesize( string pic )
PF_drawnet, // #120 void DrawNet( vector pos, string image )
PF_drawfps, // #121 void DrawFPS( vector pos )
@ -739,8 +681,6 @@ const int vm_cl_numbuiltins = sizeof(vm_cl_builtins) / sizeof(prvm_builtin_t); /
void CL_InitClientProgs( void )
{
int i;
Msg("\n");
PRVM_Begin;
@ -775,9 +715,6 @@ void CL_InitClientProgs( void )
prog->globals.cl->mapname = PRVM_SetEngineString( cls.servername );
prog->globals.cl->playernum = cl.playernum;
for( i = 0; i < sizeof( field_nums ) / sizeof( field_nums[0] ); i++ )
field_shaders[i] = re->RegisterShader( va("gfx/%s", field_nums[i] ), SHADER_NOMIP );
// call the prog init
PRVM_ExecuteProgram( prog->globals.cl->HUD_Init, "HUD_Init" );
PRVM_End;

View File

@ -321,7 +321,7 @@ void SCR_UpdateScreen( void )
SCR_DrawCinematic();
break;
default:
Host_Error("SCR_UpdateScreen: bad cls.state" );
Host_Error( "SCR_UpdateScreen: bad cls.state\n" );
break;
}
@ -333,7 +333,7 @@ void SCR_RegisterShaders( void )
// register console images
cls.consoleFont = re->RegisterShader( va( "gfx/fonts/%s", con_font->string ), SHADER_FONT );
cls.clientFont = re->RegisterShader( va( "gfx/fonts/%s", cl_font->string ), SHADER_FONT );
cls.consoleBack = re->RegisterShader( "gfx/background/conback", SHADER_NOMIP );
cls.consoleBack = re->RegisterShader( "gfx/shell/conback", SHADER_NOMIP ); // hardcoded ...
}
/*
@ -348,7 +348,7 @@ void SCR_Init( void )
scr_showpause = Cvar_Get("scr_showpause", "1", 0, "show pause picture" );
scr_centertime = Cvar_Get("scr_centertime", "2.5", 0, "centerprint hold time" );
scr_printspeed = Cvar_Get("scr_printspeed", "8", 0, "centerprint speed of print" );
cl_levelshot_name = Cvar_Get("cl_levelshot_name", "common/black", 0, "contains path to current levelshot" );
cl_levelshot_name = Cvar_Get( "cl_levelshot_name", "", 0, "contains path to current levelshot" );
scr_loading = Cvar_Get("scr_loading", "0", 0, "loading bar progress" );
scr_download = Cvar_Get("scr_download", "0", 0, "downloading bar progress" );
cl_testentities = Cvar_Get ("cl_testentities", "0", 0, "test client entities" );

View File

@ -458,10 +458,10 @@ bool Cmd_GetGamesList( const char *s, char *completedname, int length )
bool Cmd_CheckMapsList( void )
{
byte *buffer;
wfile_t *wad;
search_t *t;
int i;
int i, bufsize;
byte *buffer = NULL;
if( FS_FileExists( "scripts/maps.lst" ))
return true; // exist
@ -469,7 +469,8 @@ bool Cmd_CheckMapsList( void )
t = FS_Search( "maps/*.bsp", false );
if( !t ) return false;
buffer = Z_Malloc( t->numfilenames * 2 * sizeof( MAX_STRING )); // should be enough...
bufsize = t->numfilenames * MAX_VALUE; // should be enough...
buffer = Z_Malloc( bufsize );
for( i = 0; i < t->numfilenames; i++ )
{
string mapname, message;
@ -485,6 +486,7 @@ bool Cmd_CheckMapsList( void )
int num_spawnpoints = 0;
int lumplen = 0;
dheader_t *header;
byte *lump;
com.strncpy( message, "No Title", MAX_STRING );
header = (dheader_t *)WAD_Read( wad, LUMP_MAPINFO, NULL, TYPE_BINDATA );
@ -500,8 +502,8 @@ bool Cmd_CheckMapsList( void )
}
else goto skip_map;
buffer = (byte *)WAD_Read( wad, LUMP_ENTITIES, &lumplen, TYPE_SCRIPT );
ents = Com_OpenScript( LUMP_ENTITIES, buffer, lumplen + 1 );
lump = (byte *)WAD_Read( wad, LUMP_ENTITIES, &lumplen, TYPE_SCRIPT );
ents = Com_OpenScript( LUMP_ENTITIES, lump, lumplen + 1 );
if( ents )
{
@ -511,11 +513,10 @@ bool Cmd_CheckMapsList( void )
while( Com_ReadToken( ents, SC_ALLOW_NEWLINES|SC_PARSE_GENERIC, &token ))
{
if( !com.strcmp( token.string, "{" )) continue;
else if( !com.strcmp( token.string, "}" )) break;
else if( !com.strcmp( token.string, "classname" ))
if( !com.strcmp( token.string, "classname" ))
{
Com_ReadToken( ents, 0, &token );
Msg("read token: %s\n", token.string );
if(!com.strcmp( token.string, "info_player_deatchmatch" ))
num_spawnpoints++;
else if(!com.strcmp( token.string, "info_player_start" ))
@ -529,7 +530,7 @@ bool Cmd_CheckMapsList( void )
else goto skip_map;
// format: mapname "maptitle"\n
com.strcat( buffer, va( "%s \"%s\"\n", mapname, message )); // add new string
com.strncat( buffer, va( "%s \"%s\"\n", mapname, message ), bufsize ); // add new string
skip_map:
if( wad ) WAD_Close( wad );
}

View File

@ -1128,7 +1128,7 @@ void VM_precache_pic( void )
return;
VM_ValidateString(PRVM_G_STRING(OFS_PARM0));
if( re->RegisterShader( va( "gfx/%s", PRVM_G_STRING(OFS_PARM0)), SHADER_NOMIP ))
if( re->RegisterShader( PRVM_G_STRING(OFS_PARM0), SHADER_NOMIP ))
PRVM_G_FLOAT(OFS_RETURN) = true;
else PRVM_G_FLOAT(OFS_RETURN) = false;
}
@ -1216,7 +1216,7 @@ void VM_drawpic( void )
return;
VM_ValidateString(PRVM_G_STRING(OFS_PARM1));
shader = re->RegisterShader( va("gfx/%s", PRVM_G_STRING( OFS_PARM1 )), SHADER_NOMIP );
shader = re->RegisterShader( PRVM_G_STRING( OFS_PARM1 ), SHADER_NOMIP );
if( !shader )
{
VM_Warning( "PF_drawpic: %s passed null picture name!\n", PRVM_NAME );
@ -1332,7 +1332,7 @@ void VM_getimagesize( void )
VM_ValidateString(PRVM_G_STRING(OFS_PARM0));
p = PRVM_G_STRING(OFS_PARM0);
shader = re->RegisterShader( va( "gfx/%s", p ), SHADER_NOMIP );
shader = re->RegisterShader( p, SHADER_NOMIP );
re->DrawGetPicSize( &w, &h, shader );
VectorSet(PRVM_G_VECTOR(OFS_RETURN), w, h, 0 );
}

View File

@ -327,7 +327,9 @@ static void SV_AddEntitiesToPacket( vec3_t origin, client_frame_t *frame, sv_ent
{
// too many leafs for individual check, go by headnode
if( !pe->HeadnodeVisible( svent->headnode, bitvector ))
{
continue;
}
}
else
{

View File

@ -4,6 +4,7 @@
//=======================================================================
#include "common.h"
#include "render_api.h"
#include "server.h"
#include "matrix_lib.h"
#include "const.h"
@ -1054,7 +1055,16 @@ bool SV_CheckWater( edict_t *ent )
ent->progs.sv->waterlevel = 2;
point[2] = ent->progs.sv->origin[2] + ent->progs.sv->view_ofs[2];
if(SV_PointContents(point) & (MASK_WATER))
{
ent->progs.sv->waterlevel = 3;
if( ent->priv.sv->s.ed_type == ED_CLIENT )
ent->progs.sv->renderfx = (int)ent->progs.sv->renderfx | RDF_UNDERWATER;
}
else
{
if( ent->priv.sv->s.ed_type == ED_CLIENT )
ent->progs.sv->renderfx = (int)ent->progs.sv->renderfx & ~RDF_UNDERWATER;
}
}
}
return ent->progs.sv->waterlevel > 1;

View File

@ -449,11 +449,18 @@ void Image_GetPaletteD1( void )
{
image.d_rendermode = LUMP_NORMAL;
if(!d1palette_init)
if( !d1palette_init )
{
byte temp[4];
Image_SetPalette( palette_d1, d_8toD1table );
d_8toD1table[247] = 0; // Image_LoadFLT will be convert transparency from 247 into 255 color
d1palette_init = true;
// also swap palette colors: from 247 to 255
Mem_Copy( temp, &d_8toD1table[255], 4 );
Mem_Copy( &d_8toD1table[255], &d_8toD1table[247], 4 );
Mem_Copy( &d_8toD1table[247], temp, 4 );
}
image.d_currentpal = d_8toD1table;
}

View File

@ -278,16 +278,6 @@ bool Image_LoadFLT( const char *name, const byte *buffer, size_t filesize )
image.type = PF_INDEXED_32; // 32-bit palete
Image_GetPaletteD1();
// also swap palette colors: from 247 to 255
if( image.d_currentpal )
{
byte temp[4];
Mem_Copy( temp, &image.d_currentpal[247], 4 );
Mem_Copy( &image.d_currentpal[247], &image.d_currentpal[255], 4 );
Mem_Copy( &image.d_currentpal[247], temp, 4 );
}
result = FS_AddMipmapToPack( Data, image.width, image.height );
if( Data ) Mem_Free( Data );
return result;
@ -413,9 +403,9 @@ bool Image_LoadMIP( const char *name, const byte *buffer, size_t filesize )
// qlumpy used this color for transparent textures, otherwise it's decals
if( pal[255*3+0] == 0 && pal[255*3+1] == 0 && pal[255*3+2] == 255 );
else if( Sys.app_name == HOST_NORMAL )
else if(!( image.cmd_flags & IL_KEEP_8BIT ))
{
// render requires setup special palette
// apply decal palette immediately
image.flags |= IMAGE_COLORINDEX;
rendermode = LUMP_DECAL;
}

View File

@ -242,9 +242,9 @@ typedef struct leaflist_s
int maxcount;
bool overflowed;
int *list;
vec3_t bounds[2];
int lastleaf; // for overflows where each leaf can't be stored individually
void (*storeleafs)( struct leaflist_s *ll, cnode_t *node );
vec3_t mins;
vec3_t maxs;
int topnode; // for overflows where each leaf can't be stored individually
} leaflist_t;
extern clipmap_t cm;

View File

@ -64,24 +64,6 @@ LEAF LISTING
======================================================================
*/
void CM_StoreLeafs( leaflist_t *ll, cnode_t *node )
{
cleaf_t *leaf = (cleaf_t *)node;
// store the lastLeaf even if the list is overflowed
if( leaf->cluster != -1 )
{
ll->lastleaf = leaf - cm.leafs;
}
if( ll->count >= ll->maxcount )
{
ll->overflowed = true;
return;
}
ll->list[ll->count++] = leaf - cm.leafs;
}
/*
=============
CM_BoxLeafnums
@ -98,13 +80,20 @@ void CM_BoxLeafnums_r( leaflist_t *ll, cnode_t *node )
{
if( node->plane == NULL )
{
cleaf_t *leaf = (cleaf_t *)node;
// it's a leaf!
ll->storeleafs( ll, node );
if( ll->count >= ll->maxcount)
{
ll->overflowed = true;
return;
}
ll->list[ll->count++] = leaf - cm.leafs;
return;
}
plane = node->plane;
s = BoxOnPlaneSide( ll->bounds[0], ll->bounds[1], plane );
s = BoxOnPlaneSide( ll->mins, ll->maxs, plane );
if( s == 1 )
{
node = node->children[0];
@ -116,6 +105,8 @@ void CM_BoxLeafnums_r( leaflist_t *ll, cnode_t *node )
else
{
// go down both
if( ll->topnode == -1 )
ll->topnode = node - cm.nodes;
CM_BoxLeafnums_r( ll, node->children[0] );
node = node->children[1];
}
@ -127,23 +118,22 @@ void CM_BoxLeafnums_r( leaflist_t *ll, cnode_t *node )
CM_BoxLeafnums
==================
*/
int CM_BoxLeafnums( const vec3_t mins, const vec3_t maxs, int *list, int listsize, int *lastleaf )
int CM_BoxLeafnums( const vec3_t mins, const vec3_t maxs, int *list, int listsize, int *topnode )
{
leaflist_t ll;
cms.checkcount++;
VectorCopy( mins, ll.bounds[0] );
VectorCopy( maxs, ll.bounds[1] );
VectorCopy( mins, ll.mins );
VectorCopy( maxs, ll.maxs );
ll.count = 0;
ll.maxcount = listsize;
ll.list = list;
ll.storeleafs = CM_StoreLeafs;
ll.lastleaf = -1;
ll.topnode = -1;
ll.overflowed = false;
CM_BoxLeafnums_r( &ll, cm.nodes );
if( lastleaf ) *lastleaf = ll.lastleaf;
if( topnode ) *topnode = ll.topnode;
return ll.count;
}

View File

@ -64,5 +64,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 3 -log +map qctest
quake.exe -game tmpQuArK -dev 3 -log +map dm7
:done

View File

@ -187,6 +187,7 @@ typedef struct
// builtin shaders
ref_shader_t *defaultShader;
ref_shader_t *nodrawShader;
ref_shader_t *blackShader;
ref_shader_t *lightmapShader;
ref_shader_t *skyboxShader;
ref_shader_t *particleShader;

View File

@ -1354,20 +1354,6 @@ shader_t Mod_RegisterShader( const char *name, int shaderType )
return shader;
}
/*
=================
R_PrecachePic
prefetching 2d graphics
=================
*/
bool R_PrecachePic( const char *name )
{
if( R_FindTexture(va( "gfx/%s", name ), NULL, 0, TF_STATIC|TF_NOPICMIP, TF_LINEAR, TW_REPEAT ))
return true;
return false;
}
/*
=================
R_Init

View File

@ -4876,7 +4876,7 @@ ref_shader_t *R_FindShader( const char *name, int shaderType, uint surfaceParm )
}
// create the shader
shader = R_CreateShader( name, shaderType, surfaceParm, shaderScript );
shader = R_CreateShader( name, shaderType, surfaceParm, shaderScript );
// load it in
return R_LoadShader( shader );
@ -5091,6 +5091,20 @@ static void R_CreateBuiltInShaders( void )
tr.nodrawShader = R_LoadShader( shader );
// black shader
shader = R_NewShader();
// gfx black image
com.strncpy( shader->name, "<black>", sizeof( shader->name ));
shader->type = SHADER_NOMIP;
shader->flags = SHADER_STATIC;
shader->stages[0]->bundles[0]->textures[0] = r_blackTexture;
shader->stages[0]->bundles[0]->numTextures++;
shader->stages[0]->numBundles++;
shader->numStages++;
tr.blackShader = R_LoadShader( shader );
// lightmap shader
shader = R_NewShader();

View File

@ -22,6 +22,10 @@ Beta 13.12.08
1. Xash 0.45 ents
2. qc->newton
3. newton->qc
4.
gfx->env
gfx->shell
gfx->
0. bmodels.c, items.c
1. animation