29 Jul 2010

This commit is contained in:
g-cont 2010-07-29 00:00:00 +04:00 committed by Alibek Omarov
parent 7f43108130
commit 9febd39250
20 changed files with 182 additions and 55 deletions

View File

@ -1190,13 +1190,10 @@ void CSprite::Precache( void )
PRECACHE_MODEL( (char *)STRING(pev->model) );
// Reset attachment after save/restore
if ( pev->aiment )
SetAttachment( pev->aiment, pev->body );
else
if( !pev->aiment )
{
// Clear attachment
pev->skin = 0;
pev->body = 0;
pev->colormap = 0;
}
}

View File

@ -11,7 +11,9 @@ Input: disable mouse events when level is loading
GameUI: adding some missed dialogs
Render: fix interpolation on flying monsters
Render: fix wrong sprite attachments
Render: fix invalid frustum culling for studiomodels ( e.g. barnacle.mdl )
Render: fix invalid frustum culling for studiomodels ( e.g. barnacle.mdl )
Physic: fix trace for rotating bmodels
Engine: fixup physinfo save\restore bug
build 1262

View File

@ -422,7 +422,7 @@ void CL_AdjustAngles( void )
if( up || down ) V_StopPitchDrift();
cl_viewangles[PITCH] = bound( -70, cl_viewangles[PITCH], 89 );
cl_viewangles[PITCH] = bound( -89, cl_viewangles[PITCH], 89 );
cl_viewangles[ROLL] = bound( -50, cl_viewangles[ROLL], 50 );
}

View File

@ -504,6 +504,57 @@ void _MSG_WriteString( sizebuf_t *sb, const char *src, const char *filename, int
}
}
void _MSG_WriteStringLine( sizebuf_t *sb, const char *src, const char *filename, int fileline )
{
if( !src )
{
_MSG_WriteData( sb, "", 1, filename, fileline );
}
else
{
int l;
char *dst, string[MAX_SYSPATH];
l = com.strlen( src ) + 1;
if( l >= MAX_SYSPATH )
{
MsgDev( D_ERROR, "MSG_WriteString: exceeds %i symbols (called at %s:%i\n", MAX_SYSPATH, filename, fileline );
_MSG_WriteData( sb, "", 1, filename, fileline );
return;
}
dst = string;
while( 1 )
{
// some escaped chars parsed as two symbols - merge it here
if( src[0] == '\\' && src[1] == 'n' )
{
*dst++ = '\n';
src += 2;
l -= 1;
}
if( src[0] == '\\' && src[1] == 'r' )
{
*dst++ = '\r';
src += 2;
l -= 1;
}
if( src[0] == '\\' && src[1] == 't' )
{
*dst++ = '\t';
src += 2;
l -= 1;
}
else if(( *dst++ = *src++ ) == 0 )
break;
}
*dst = '\0'; // string end
_MSG_WriteData( sb, string, l, filename, fileline );
}
}
void _MSG_WritePos( sizebuf_t *sb, const vec3_t pos, const char *filename, int fileline )
{
_MSG_WriteFloat( sb, pos[0], filename, fileline );

View File

@ -193,6 +193,7 @@ void _MSG_WriteBits( sizebuf_t *msg, long value, const char *name, int bits, con
long _MSG_ReadBits( sizebuf_t *msg, const char *name, int bits, const char *filename, const int fileline );
void _MSG_Begin( int dest, const char *filename, int fileline );
void _MSG_WriteString( sizebuf_t *sb, const char *s, const char *filename, int fileline );
void _MSG_WriteStringLine( sizebuf_t *sb, const char *src, const char *filename, int fileline );
void _MSG_WriteFloat( sizebuf_t *sb, float f, const char *filename, int fileline );
void _MSG_WriteDouble( sizebuf_t *sb, double f, const char *filename, int fileline );
void _MSG_WriteAngle8( sizebuf_t *sb, float f, const char *filename, int fileline );
@ -215,6 +216,7 @@ bool _MSG_Send( int dest, const vec3_t origin, const edict_t *ent, bool direct,
#define MSG_WriteFloat(x,y) _MSG_WriteFloat(x, y, __FILE__, __LINE__)
#define MSG_WriteDouble(x,y) _MSG_WriteDouble(x, y, __FILE__, __LINE__)
#define MSG_WriteString(x,y) _MSG_WriteString (x, y, __FILE__, __LINE__)
#define MSG_WriteStringLine(x,y) _MSG_WriteStringLine (x, y, __FILE__, __LINE__)
#define MSG_WriteCoord16(x, y) _MSG_WriteCoord16(x, y, __FILE__, __LINE__)
#define MSG_WriteCoord32(x, y) _MSG_WriteFloat(x, y, __FILE__, __LINE__)
#define MSG_WriteAngle8(x, y) _MSG_WriteAngle8(x, y, __FILE__, __LINE__)

View File

@ -69,10 +69,10 @@ A connection request that did not come from the master
*/
void SV_DirectConnect( netadr_t from )
{
char physinfo[512];
char userinfo[MAX_INFO_STRING];
sv_client_t temp, *cl, *newcl;
edict_t *ent;
client_frame_t *frames;
int i, edictnum;
int version;
int qport, count = 0;
@ -117,11 +117,13 @@ void SV_DirectConnect( netadr_t from )
break; // valid challenge
}
}
if( i == MAX_CHALLENGES )
{
Netchan_OutOfBandPrint( NS_SERVER, from, "print\nNo or bad challenge for address.\n" );
return;
}
// force the IP key/value pair so the game can filter based on ip
Info_SetValueForKey( userinfo, "ip", NET_AdrToString( from ));
svs.challenges[i].connected = true;
@ -130,10 +132,7 @@ void SV_DirectConnect( netadr_t from )
else Info_SetValueForKey( userinfo, "ip", "127.0.0.1" ); // force the "ip" info key to "localhost"
newcl = &temp;
frames = newcl->frames; // keep frames pointer
Mem_Set( newcl, 0, sizeof( sv_client_t ));
newcl->frames = frames; // restore it
// if there is already a slot for this ip, reuse it
for( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ )
@ -157,6 +156,7 @@ void SV_DirectConnect( netadr_t from )
break;
}
}
if( !newcl )
{
Netchan_OutOfBandPrint( NS_SERVER, from, "print\nServer is full.\n" );
@ -168,7 +168,14 @@ gotnewcl:
// build a new connection
// accept the new client
// this is the only place a sv_client_t is ever initialized
if( sv_maxclients->integer == 1 ) // save physinfo for singleplayer
com.strncpy( physinfo, newcl->physinfo, sizeof( physinfo ));
*newcl = temp;
if( sv_maxclients->integer == 1 ) // restore physinfo for singleplayer
com.strncpy( newcl->physinfo, physinfo, sizeof( physinfo ));
sv_client = newcl;
edictnum = (newcl - svs.clients) + 1;

View File

@ -2087,7 +2087,7 @@ void pfnWriteString( const char *sz )
int cur_size = sv.multicast.cursize;
int total_size;
MSG_WriteString( &sv.multicast, sz );
MSG_WriteStringLine( &sv.multicast, sz ); // allow \n, \r, \t
total_size = sv.multicast.cursize - cur_size;
// NOTE: some messages with constant string length can be marked as known sized

View File

@ -469,6 +469,7 @@ void SV_InitGame( void )
ent->pvServerData->client = svs.clients + i;
ent->pvServerData->client->edict = ent;
Mem_Set( &svs.clients[i].lastcmd, 0, sizeof( svs.clients[i].lastcmd ));
Mem_Set( &svs.clients[i].physinfo, 0, sizeof( svs.clients[i].physinfo ));
}
svgame.globals->numEntities = svgame.globals->maxClients + 1; // clients + world

View File

@ -807,7 +807,7 @@ static edict_t *SV_PushMove( edict_t *pusher, float movetime )
pusher->v.solid = oldsolid;
// if it is still inside the pusher, block
if( block || SV_TestEntityPosition( check ))
if( block )// || SV_TestEntityPosition( check ))
{
if( !SV_CanBlock( check ))
continue;

View File

@ -139,6 +139,39 @@ void SV_UnlinkEdict( edict_t *ent )
ent->pvServerData->linked = false;
}
/*
===============
SV_CheckForOutside
Remove entity out of level
===============
*/
void SV_CheckForOutside( edict_t *ent )
{
// not solid edicts can be fly through walls
if( ent->v.solid == SOLID_NOT ) return;
// other ents probably may travels across the void
if( ent->v.movetype != MOVETYPE_NONE ) return;
// clients can flying outside
if( ent->v.flags & FL_CLIENT ) return;
// sprites and brushes can be stucks in the walls normally
if( CM_GetModelType( ent->v.modelindex ) != mod_studio )
return;
if( SV_PointContents( ent->v.origin ) == CONTENTS_SOLID )
{
const float *org = ent->v.origin;
MsgDev( D_ERROR, "%s outside of the world at %g %g %g\n", SV_ClassName( ent ), org[0], org[1], org[2] );
ent->v.flags |= FL_KILLME;
}
}
int EntityInSolid( edict_t *ent );
/*
===============
SV_LinkEntity
@ -173,7 +206,11 @@ void SV_LinkEdict( edict_t *ent, bool touch_triggers )
// if none of the leafs were inside the map, the
// entity is outside the world and can be considered unlinked
if( !num_leafs ) return;
if( !num_leafs )
{
SV_CheckForOutside( ent );
return;
}
if( num_leafs >= MAX_ENT_LEAFS )
{
@ -585,8 +622,12 @@ edict_t *SV_TestPlayerPosition( const vec3_t origin, edict_t *pass, TraceResult
mins = svgame.pmove->player_mins[svgame.pmove->usehull];
maxs = svgame.pmove->player_maxs[svgame.pmove->usehull];
if( pass ) SV_SetMinMaxSize( pass, mins, maxs );
result = SV_Move( origin, mins, maxs, origin, MOVE_NORMAL, pass );
if( tr ) *tr = result;
return result.pHit;
if( result.pHit )
return result.pHit;
return NULL;
}

View File

@ -2475,6 +2475,12 @@ Open a file. The syntax is the same as fopen
*/
file_t* _FS_Open( const char* filepath, const char* mode, bool quiet )
{
if( Sys.app_name == HOST_NORMAL || Sys.app_name == HOST_DEDICATED || Sys.app_name == HOST_BSPLIB )
{
// some stupid mappers used leading '/' in path to models or sounds
if( filepath[0] == '/' ) filepath++;
}
if( FS_CheckNastyPath( filepath, false ))
{
MsgDev( D_NOTE, "FS_Open: (\"%s\", \"%s\"): nasty filename rejected\n", filepath, mode );

View File

@ -495,7 +495,7 @@ static void BSP_LoadMarkFaces( const dlump_t *l )
for( i = 0; i < count; i++ )
{
j = LittleLong( in[i] );
if( j < 0 || j >= count )
if( j < 0 || j >= loadmodel->numsurfaces )
Host_Error( "BSP_LoadMarkFaces: bad surface number in '%s'\n", loadmodel->name );
loadmodel->marksurfaces[i] = loadmodel->surfaces + j;
}

View File

@ -207,8 +207,11 @@ loc0:
// put the crosspoint DIST_EPSILON pixels on the near side
side = (t1 < 0);
if( side ) frac = bound( 0, ( t1 + DIST_EPSILON ) / ( t1 - t2 ), 1 );
else frac = bound( 0, ( t1 - DIST_EPSILON ) / ( t1 - t2 ), 1 );
if( side ) frac = ( t1 + DIST_EPSILON ) / ( t1 - t2 );
else frac = ( t1 - DIST_EPSILON ) / ( t1 - t2 );
if( frac < 0 ) frac = 0;
if( frac > 1 ) frac = 1;
midf = p1f + ( p2f - p1f ) * frac;
VectorLerp( p1, frac, p2, mid );
@ -273,9 +276,10 @@ eventually rotation) of the end points
*/
trace_t CM_ClipMoveToEntity( edict_t *ent, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, int flags )
{
vec3_t offset;
vec3_t offset, temp;
vec3_t start_l, end_l;
trace_t trace;
matrix4x4 matrix;
chull_t *hull;
// fill in a default trace
@ -294,21 +298,21 @@ trace_t CM_ClipMoveToEntity( edict_t *ent, const vec3_t start, vec3_t mins, vec3
// rotate start and end into the models frame of reference
if( ent->v.solid == SOLID_BSP && !VectorIsNull( ent->v.angles ))
{
vec3_t forward, right, up;
vec3_t temp;
VectorCopy( ent->v.angles, temp );
AngleVectors( temp, forward, right, up );
matrix4x4 imatrix;
Matrix4x4_CreateFromEntity( matrix, ent->v.origin[0], ent->v.origin[1], ent->v.origin[2], ent->v.angles[PITCH], ent->v.angles[YAW], ent->v.angles[ROLL], 1.0f );
Matrix4x4_Invert_Simple( imatrix, matrix );
Matrix4x4_VectorTransform( imatrix, start, start_l );
Matrix4x4_VectorTransform( imatrix, end, end_l );
#if 1
// calc hull offsets (monsters use this)
VectorCopy( start_l, temp );
start_l[0] = DotProduct( temp, forward );
start_l[1] = -DotProduct( temp, right );
start_l[2] = DotProduct( temp, up );
VectorMAMAM( 1, temp, 1, mins, -1, hull->clip_mins, start_l );
VectorCopy( end_l, temp );
end_l[0] = DotProduct( temp, forward );
end_l[1] = -DotProduct( temp, right );
end_l[2] = DotProduct( temp, up );
VectorMAMAM( 1, temp, 1, mins, -1, hull->clip_mins, end_l );
#endif
}
if(!( flags & FMOVE_SIMPLEBOX ) && CM_ModelType( ent->v.modelindex ) == mod_studio )
@ -325,30 +329,29 @@ trace_t CM_ClipMoveToEntity( edict_t *ent, const vec3_t start, vec3_t mins, vec3
// rotate endpos back to world frame of reference
if( ent->v.solid == SOLID_BSP && !VectorIsNull( ent->v.angles ))
{
vec3_t forward, right, up;
vec3_t temp;
if( trace.flFraction != 1.0f )
{
VectorNegate( ent->v.angles, temp );
AngleVectors( temp, forward, right, up );
vec3_t temp;
VectorCopy( trace.vecEndPos, temp );
trace.vecEndPos[0] = DotProduct( temp, forward );
trace.vecEndPos[1] = -DotProduct( temp, right );
trace.vecEndPos[2] = DotProduct( temp, up );
// compute endpos
trace.vecEndPos[0] = start[0] + trace.flFraction * ( end[0] - start[0] );
trace.vecEndPos[1] = start[1] + trace.flFraction * ( end[1] - start[1] );
trace.vecEndPos[2] = start[2] + trace.flFraction * ( end[2] - start[2] );
VectorCopy( trace.vecPlaneNormal, temp );
trace.vecPlaneNormal[0] = DotProduct( temp, forward );
trace.vecPlaneNormal[1] = -DotProduct( temp, right );
trace.vecPlaneNormal[2] = DotProduct( temp, up );
Matrix4x4_TransformPositivePlane( matrix, temp, trace.flPlaneDist, trace.vecPlaneNormal, &trace.flPlaneDist );
}
}
else
{
// special case for non-rotated bmodels
// fix trace up by the offset when we hit bmodel
if( trace.flFraction != 1.0f && trace.iHitgroup == -1 )
VectorAdd( trace.vecEndPos, offset, trace.vecEndPos );
// fix trace up by the offset when we hit bmodel
if( trace.flFraction != 1.0f && trace.iHitgroup == -1 )
VectorAdd( trace.vecEndPos, offset, trace.vecEndPos );
trace.flPlaneDist = DotProduct( trace.vecEndPos, trace.vecPlaneNormal );
}
// did we clip the move?
if( trace.flFraction < 1.0f || trace.fStartSolid )
trace.pHit = ent;

View File

@ -17,7 +17,7 @@
#define MAX_DECALNAMES 1024 // server decal indexes (different decalnames, not a render limit)
#define MAX_USER_MESSAGES 200 // another 56 messages reserved for engine routines
#define MAX_EVENTS 1024 // playback events that can be queued (a byte range, don't touch)
#define MAX_MSGLEN 8000 // max length of network message
#define MAX_MSGLEN 16384 // max length of network message
#define MAX_GENERICS 1024 // generic files that can download from server
#define MAX_CLASSNAMES 512 // maxcount of various edicts classnames
#define MAX_SOUNDS 2048 // max unique loaded sounds (not counting sequences)

View File

@ -72,6 +72,7 @@
#define VectorNegate(x, y) ((y)[0] = -(x)[0], (y)[1] = -(x)[1], (y)[2] = -(x)[2])
#define VectorM(scale1, b1, c) ((c)[0] = (scale1) * (b1)[0],(c)[1] = (scale1) * (b1)[1],(c)[2] = (scale1) * (b1)[2])
#define VectorMA(a, scale, b, c) ((c)[0] = (a)[0] + (scale) * (b)[0],(c)[1] = (a)[1] + (scale) * (b)[1],(c)[2] = (a)[2] + (scale) * (b)[2])
#define VectorMAMAM(scale1, b1, scale2, b2, scale3, b3, c) ((c)[0] = (scale1) * (b1)[0] + (scale2) * (b2)[0] + (scale3) * (b3)[0],(c)[1] = (scale1) * (b1)[1] + (scale2) * (b2)[1] + (scale3) * (b3)[1],(c)[2] = (scale1) * (b1)[2] + (scale2) * (b2)[2] + (scale3) * (b3)[2])
#define MakeRGBA( out, x, y, z, w ) Vector4Set( out, x, y, z, w )
_inline float anglemod(const float a){ return(360.0/65536) * ((int)(a*(65536/360.0)) & 65535); }

View File

@ -997,6 +997,24 @@ _inline void Matrix4x4_CreateModelview( matrix4x4 out )
#endif
}
_inline void Matrix4x4_TransformPositivePlane( const matrix4x4 in, const vec3_t normal, float d, vec3_t out, float *dist )
{
float scale = com.sqrt( in[0][0] * in[0][0] + in[0][1] * in[0][1] + in[0][2] * in[0][2] );
float iscale = 1.0f / scale;
#ifdef OPENGL_STYLE
out[0] = (normal[0] * in[0][0] + normal[1] * in[1][0] + normal[2] * in[2][0]) * iscale;
out[1] = (normal[0] * in[0][1] + normal[1] * in[1][1] + normal[2] * in[2][1]) * iscale;
out[2] = (normal[0] * in[0][2] + normal[1] * in[1][2] + normal[2] * in[2][2]) * iscale;
*dist = d * scale + ( out[0] * in[3][0] + out[1] * in[3][1] + out[2] * in[3][2] );
#else
out[0] = (normal[0] * in[0][0] + normal[1] * in[0][1] + normal[2] * in[0][2]) * iscale;
out[1] = (normal[0] * in[1][0] + normal[1] * in[1][1] + normal[2] * in[1][2]) * iscale;
out[2] = (normal[0] * in[2][0] + normal[1] * in[2][1] + normal[2] * in[2][2]) * iscale;
*dist = d * scale + ( out[0] * in[0][3] + out[1] * in[1][3] + out[2] * in[2][3] );
#endif
}
_inline void Matrix4x4_ToArrayFloatGL( const matrix4x4 in, float out[16] )
{
#ifdef OPENGL_STYLE

View File

@ -6,6 +6,7 @@
#define RENDER_API_H
#include "ref_params.h"
#include "trace_def.h"
// shader types used for shader loading
#define SHADER_SKY 1 // sky box shader

View File

@ -1507,13 +1507,10 @@ void CSprite::Precache( void )
PRECACHE_MODEL( (char *)STRING(pev->model) );
// Reset attachment after save/restore
if ( pev->aiment )
SetAttachment( pev->aiment, pev->body );
else
if( !pev->aiment )
{
// Clear attachment
pev->skin = 0;
pev->body = 0;
pev->colormap = 0;
}
}

View File

@ -3194,8 +3194,8 @@ bool VID_ScreenShot( const char *filename, int shot_type )
break;
case VID_MINISHOT:
flags |= IMAGE_RESAMPLE;
height = 192;
width = 256;
height = 200;
width = 230;
break;
}

View File

@ -1657,7 +1657,7 @@ static void Mod_LoadMarkFaces( const dlump_t *l )
for( i = 0; i < count; i++ )
{
j = LittleLong( in[i] );
if( j < 0 || j >= count )
if( j < 0 || j >= loadbmodel->numsurfaces )
Host_Error( "Mod_LoadMarkFaces: bad surface number in '%s'\n", loadmodel->name );
loadbmodel->marksurfaces[i] = loadbmodel->surfaces + j;
}