14 Nov 2011

This commit is contained in:
g-cont 2011-11-14 00:00:00 +04:00 committed by Alibek Omarov
parent b7f64580ed
commit 1eb063a0ad
12 changed files with 171 additions and 50 deletions

View File

@ -109,17 +109,17 @@
#define EF_NOINTERP 32 // don't interpolate the next frame
#define EF_LIGHT 64 // rocket flare glow sprite
#define EF_NODRAW 128 // don't draw entity
#define EF_NOREFLECT 256 // Entity won't reflecting in mirrors
#define EF_REFLECTONLY 512 // Entity will be drawing only in mirrors
#define EF_NOWATERCSG 1024 // Do not remove sides for func_water entity
// Reserved bit
#define EF_FULLBRIGHT 4096 // Just get fullbright
#define EF_NOSHADOW 8192 // ignore shadow for this entity
#define EF_MERGE_VISIBILITY 16384 // this entity allowed to merge vis (e.g. env_sky or portal camera)
#define EF_REQUEST_PHS 32768 // This entity requested phs bitvector instead of pvsbitvector in AddToFullPack calls
// user-specified entity effects
#define EF_LASERSPOT 65536 // tempentity laserspot at attachment #1 from player or npc
#define EF_NOREFLECT (1<<24) // Entity won't reflecting in mirrors
#define EF_REFLECTONLY (1<<25) // Entity will be drawing only in mirrors
#define EF_NOWATERCSG (1<<26) // Do not remove sides for func_water entity
#define EF_FULLBRIGHT (1<<27) // Just get fullbright
#define EF_NOSHADOW (1<<28) // ignore shadow for this entity
#define EF_MERGE_VISIBILITY (1<<29) // this entity allowed to merge vis (e.g. env_sky or portal camera)
#define EF_REQUEST_PHS (1<<30) // This entity requested phs bitvector instead of pvsbitvector in AddToFullPack calls
// g-cont. one reserved bit here for me
// entity flags
#define EFLAG_SLERP 1 // do studio interpolation of this entity

View File

@ -1117,10 +1117,10 @@ void CL_PrepVideo( void )
R_NewMap(); // tell the render about new map
V_SetupOverviewState(); // set overview bounds
Msg( "VidInit()\n" );
// must be called after lightmap loading!
clgame.dllFuncs.pfnVidInit();
Msg( "VidInit: end()\n" );
// release unused SpriteTextures
for( i = 1; i < MAX_IMAGES; i++ )
{
@ -1178,6 +1178,8 @@ void CL_PrepVideo( void )
cl.video_prepped = true;
cl.force_refdef = true;
Msg( "PrepVideo: end()\n" );
}
/*

View File

@ -859,7 +859,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
int i, alpha, type;
float angle, dot, sr, cr, flAlpha;
float lerp = 1.0f, ilerp, scale;
vec3_t v_forward, v_right, v_up, tmp;
vec3_t v_forward, v_right, v_up;
vec3_t origin, color, color2;
if( RI.params & RP_ENVVIEW )
@ -973,13 +973,8 @@ void R_DrawSpriteModel( cl_entity_t *e )
VectorSubtract( origin, v_forward, origin );
break;
case SPR_FACING_UPRIGHT:
VectorNegate( e->origin, tmp );
VectorNormalize( tmp );
dot = tmp[2];
if(( dot > 0.999848 ) || ( dot < -0.999848 )) // cos(1 degree) = 0.999848
return; // invisible
VectorSet( v_up, 0.0f, 0.0f, 1.0f );
VectorSet( v_right, tmp[1], -tmp[0], 0.0f );
VectorSet( v_right, origin[1] - RI.vieworg[1], -(origin[0] - RI.vieworg[0]), 0.0f );
VectorSet( v_up, 0.0f, 0.0f, 1.0f );
VectorNormalize( v_right );
break;
case SPR_FWD_PARALLEL_UPRIGHT:

View File

@ -119,15 +119,17 @@ vidmode_t vidmode[] =
{ "Mode 9: 4x3", 2048, 1536, false },
{ "Mode 10: 16x9", 800, 480, true },
{ "Mode 11: 16x9", 856, 480, true },
{ "Mode 12: 16x9", 1024, 576, true },
{ "Mode 13: 16x9", 1024, 600, true },
{ "Mode 14: 16x9", 1280, 720, true },
{ "Mode 15: 16x9", 1360, 768, true },
{ "Mode 16: 16x9", 1366, 768, true },
{ "Mode 17: 16x9", 1440, 900, true },
{ "Mode 18: 16x9", 1680, 1050, true },
{ "Mode 19: 16x9", 1920, 1200, true },
{ "Mode 20: 16x9", 2560, 1600, true },
{ "Mode 12: 16x9", 960, 540, true },
{ "Mode 13: 16x9", 1024, 576, true },
{ "Mode 14: 16x9", 1024, 600, true },
{ "Mode 15: 16x9", 1280, 720, true },
{ "Mode 16: 16x9", 1360, 768, true },
{ "Mode 17: 16x9", 1366, 768, true },
{ "Mode 18: 16x9", 1440, 900, true },
{ "Mode 19: 16x9", 1680, 1050, true },
{ "Mode 20: 16x9", 1920, 1080, true },
{ "Mode 21: 16x9", 1920, 1200, true },
{ "Mode 22: 16x9", 2560, 1600, true },
{ NULL, 0, 0, 0 },
};

View File

@ -39,7 +39,7 @@ void Matrix3x4_VectorTransform( const matrix3x4 in, const float v[3], float out[
void Matrix3x4_VectorITransform( const matrix3x4 in, const float v[3], float out[3] )
{
float dir[3];
vec3_t dir;
dir[0] = v[0] - in[0][3];
dir[1] = v[1] - in[1][3];
@ -255,9 +255,15 @@ void Matrix4x4_VectorTransform( const matrix4x4 in, const float v[3], float out[
void Matrix4x4_VectorITransform( const matrix4x4 in, const float v[3], float out[3] )
{
out[0] = v[0] * in[0][0] + v[1] * in[1][0] + v[2] * in[2][0] - in[0][3];
out[1] = v[0] * in[0][1] + v[1] * in[1][1] + v[2] * in[2][1] - in[1][3];
out[2] = v[0] * in[0][2] + v[1] * in[1][2] + v[2] * in[2][2] - in[2][3];
vec3_t dir;
dir[0] = v[0] - in[0][3];
dir[1] = v[1] - in[1][3];
dir[2] = v[2] - in[2][3];
out[0] = dir[0] * in[0][0] + dir[1] * in[1][0] + dir[2] * in[2][0];
out[1] = dir[0] * in[0][1] + dir[1] * in[1][1] + dir[2] * in[2][1];
out[2] = dir[0] * in[0][2] + dir[1] * in[1][2] + dir[2] * in[2][2];
}
void Matrix4x4_VectorRotate( const matrix4x4 in, const float v[3], float out[3] )

View File

@ -454,12 +454,6 @@ static void Mod_LoadSubmodels( const dlump_t *l )
out->firstface = in->firstface;
out->numfaces = in->numfaces;
if( VectorIsNull( out->origin ))
{
// NOTE: zero origin after recalculating is indicated included origin brush
VectorAverage( out->mins, out->maxs, out->origin );
}
if( i == 0 || !world.loading )
continue; // skip the world
@ -1450,6 +1444,64 @@ static void Mod_LoadClipnodes( const dlump_t *l )
}
}
/*
=================
Mod_FindModelOrigin
routine to detect bmodels with origin-brush
=================
*/
static void Mod_FindModelOrigin( const char *entities, const char *modelname, vec3_t origin )
{
char *pfile;
string keyname;
char token[2048];
qboolean model_found;
qboolean origin_found;
if( !entities || !modelname || !*modelname || !origin )
return;
pfile = (char *)entities;
while(( pfile = COM_ParseFile( pfile, token )) != NULL )
{
if( token[0] != '{' )
Host_Error( "Mod_FindModelOrigin: found %s when expecting {\n", token );
model_found = origin_found = false;
VectorClear( origin );
while( 1 )
{
// parse key
if(( pfile = COM_ParseFile( pfile, token )) == NULL )
Host_Error( "Mod_FindModelOrigin: EOF without closing brace\n" );
if( token[0] == '}' ) break; // end of desc
Q_strncpy( keyname, token, sizeof( keyname ));
// parse value
if(( pfile = COM_ParseFile( pfile, token )) == NULL )
Host_Error( "Mod_FindModelOrigin: EOF without closing brace\n" );
if( token[0] == '}' )
Host_Error( "Mod_FindModelOrigin: closing brace without data\n" );
if( !Q_stricmp( keyname, "model" ) && !Q_stricmp( modelname, token ))
model_found = true;
if( !Q_stricmp( keyname, "origin" ))
{
Q_atov( origin, token, 3 );
origin_found = true;
}
}
if( model_found ) break;
}
}
/*
=================
Mod_MakeHull0
@ -1663,6 +1715,7 @@ Mod_LoadBrushModel
static void Mod_LoadBrushModel( model_t *mod, const void *buffer, qboolean *loaded )
{
int i, j;
char *ents;
dheader_t *header;
dmodel_t *bm;
@ -1723,6 +1776,7 @@ static void Mod_LoadBrushModel( model_t *mod, const void *buffer, qboolean *load
Mod_MakeHull0 ();
loadmodel->numframes = 2; // regular and alternate animation
ents = loadmodel->entities;
// set up the submodels
for( i = 0; i < mod->numsubmodels; i++ )
@ -1744,9 +1798,15 @@ static void Mod_LoadBrushModel( model_t *mod, const void *buffer, qboolean *load
mod->radius = RadiusFromBounds( mod->mins, mod->maxs );
mod->numleafs = bm->visleafs;
mod->flags = 0;
// flag 1 is indicated model with origin brush!
mod->flags = VectorIsNull( bm->origin ) ? MODEL_HAS_ORIGIN : 0;
if( i != 0 )
{
Mod_FindModelOrigin( ents, va( "*%i", i ), bm->origin );
// flag 2 is indicated model with origin brush!
if( !VectorIsNull( bm->origin )) mod->flags |= MODEL_HAS_ORIGIN;
}
for( j = 0; i != 0 && j < mod->nummodelsurfaces; j++ )
{

View File

@ -95,6 +95,9 @@ int PM_HullPointContents( hull_t *hull, int num, const vec3_t p )
{
mplane_t *plane;
if( !hull || !hull->planes ) // fantom bmodels?
return CONTENTS_NONE;
while( num >= 0 )
{
plane = &hull->planes[hull->clipnodes[num].planenum];

View File

@ -758,6 +758,43 @@ void SV_EdictsInfo_f( void )
Msg( "%5i total\n", svgame.globals->maxEntities );
}
void SV_EntityInfo_f( void )
{
edict_t *ent;
int i;
if( sv.state != ss_active )
{
Msg( "^3no server running.\n" );
return;
}
for( i = 0; i < svgame.numEntities; i++ )
{
ent = EDICT_NUM( i );
if( !SV_IsValidEdict( ent )) continue;
Msg( "%5i origin: %.f %.f %.f", i, ent->v.origin[0], ent->v.origin[1], ent->v.origin[2] );
if( ent->v.classname )
Msg( ", class: %s", STRING( ent->v.classname ));
if( ent->v.globalname )
Msg( ", global: %s", STRING( ent->v.globalname ));
if( ent->v.targetname )
Msg( ", name: %s", STRING( ent->v.targetname ));
if( ent->v.target )
Msg( ", target: %s", STRING( ent->v.target ));
if( ent->v.model )
Msg( ", model: %s", STRING( ent->v.model ));
Msg( "\n" );
}
}
/*
==================
SV_InitOperatorCommands
@ -783,6 +820,7 @@ void SV_InitOperatorCommands( void )
Cmd_AddCommand( "entpatch", SV_EntPatch_f, "write entity patch to allow external editing" );
Cmd_AddCommand( "map_background", SV_MapBackground_f, "set background map" );
Cmd_AddCommand( "edicts_info", SV_EdictsInfo_f, "show info about edicts" );
Cmd_AddCommand( "entity_info", SV_EntityInfo_f, "show more info about edicts" );
if( host.type == HOST_DEDICATED )
{
@ -818,6 +856,7 @@ void SV_KillOperatorCommands( void )
Cmd_RemoveCommand( "entpatch" );
Cmd_RemoveCommand( "map_background" );
Cmd_RemoveCommand( "edicts_info" );
Cmd_RemoveCommand( "entity_info" );
if( host.type == HOST_DEDICATED )
{

View File

@ -531,15 +531,17 @@ char *SV_ReadEntityScript( const char *filename, int *flags )
{
file_t *f;
dheader_t *header;
string entfilename;
char *ents = NULL;
string bspfilename, entfilename;
int ver = -1, lumpofs = 0, lumplen = 0;
byte buf[MAX_SYSPATH]; // 1 kb
qboolean result = false;
size_t ft1, ft2;
ASSERT( flags != NULL );
f = FS_Open( va( "maps/%s.bsp", filename ), "rb", false );
Q_strncpy( bspfilename, va( "maps/%s.bsp", filename ), sizeof( entfilename ));
f = FS_Open( bspfilename, "rb", false );
if( !f ) return NULL;
*flags |= MAP_IS_EXIST;
@ -573,7 +575,16 @@ char *SV_ReadEntityScript( const char *filename, int *flags )
// check for entfile too
Q_strncpy( entfilename, va( "maps/%s.ent", filename ), sizeof( entfilename ));
ents = FS_LoadFile( entfilename, NULL, true ); // grab .ent files only from gamedir
// make sure what entity patch is never than bsp
ft1 = FS_FileTime( bspfilename, false );
ft2 = FS_FileTime( entfilename, true );
if( ft2 != -1 && ft1 < ft2 )
{
// grab .ent files only from gamedir
ents = FS_LoadFile( entfilename, NULL, true );
}
if( !ents && lumplen >= 10 )
{
@ -696,7 +707,7 @@ void SV_FreeEdict( edict_t *pEdict )
if( pEdict->pvPrivateData )
{
// NOTE: new interface can be missing
if( svgame.dllFuncs2.pfnOnFreeEntPrivateData && sv.state != ss_dead )
if( svgame.dllFuncs2.pfnOnFreeEntPrivateData )
svgame.dllFuncs2.pfnOnFreeEntPrivateData( pEdict );
if( Mem_IsAllocated( pEdict->pvPrivateData ))
@ -4418,7 +4429,7 @@ void SV_LoadFromFile( const char *mapname, char *entities )
ASSERT( entities != NULL );
// user dll can override movement type (Xash3D extension)
// user dll can override spawn entities function (Xash3D extension)
if( !svgame.physFuncs.SV_LoadEntities || !svgame.physFuncs.SV_LoadEntities( mapname, entities ))
{
inhibited = 0;

View File

@ -307,7 +307,6 @@ void SV_ActivateServer( void )
}
numFrames = (sv.loadgame) ? 1 : 2;
svgame.globals->force_retouch++; // g-cont. this is correct ?
if( !sv.loadgame || svgame.globals->changelevel )
host.frametime = 0.1f;

View File

@ -1279,7 +1279,9 @@ int SV_LoadGameState( char const *level, qboolean createPlayers )
// restore camera view here
pent = pSaveData->pTable[bound( 0, (word)header.viewentity, pSaveData->tableCount )].pent;
if( SV_IsValidEdict( pent )) sv.viewentity = NUM_FOR_EDICT( pent );
if( SV_IsValidEdict( pent ))
sv.viewentity = NUM_FOR_EDICT( pent );
else sv.viewentity = 0;
// just use normal client view
@ -1307,8 +1309,8 @@ int SV_CreateEntityTransitionList( SAVERESTOREDATA *pSaveData, int levelMask )
// create entity list
for( i = 0; i < pSaveData->tableCount; i++ )
{
pent = NULL;
pEntInfo = &pSaveData->pTable[i];
pent = NULL;
if( pEntInfo->size && pEntInfo->id != 0 )
{

View File

@ -51,6 +51,7 @@ static const char *uiVideoModes[] =
"2048 x 1536",
"800 x 480 (wide)",
"856 x 480 (wide)",
"960 x 540 (wide)",
"1024 x 576 (wide)",
"1024 x 600 (wide)",
"1280 x 720 (wide)",
@ -58,6 +59,7 @@ static const char *uiVideoModes[] =
"1366 x 768 (wide)",
"1440 x 900 (wide)",
"1680 x 1050 (wide)",
"1920 x 1080 (wide)",
"1920 x 1200 (wide)",
"2560 x 1600 (wide)",
};