Apply some valve's fixes

This commit is contained in:
mittorn 2016-02-29 20:04:01 +00:00
parent 0f599684c5
commit ac857199cf
14 changed files with 2615 additions and 2569 deletions

View File

@ -22,8 +22,8 @@
#include "math.h"
// Header file containing definition of globalvars_t and entvars_t
typedef int func_t; //
typedef int string_t; // from engine's pr_comp.h;
typedef unsigned int func_t; //
typedef unsigned int string_t; // from engine's pr_comp.h;
typedef float vec_t; // needed before including progdefs.h
//=========================================================

View File

@ -727,8 +727,8 @@ enum
kRenderFxClampMinScale, // Keep this sprite from getting very small (SPRITES only!)
};
typedef int func_t;
typedef int string_t;
typedef unsigned int func_t;
typedef unsigned int string_t;
typedef unsigned char byte;
typedef unsigned short word;

View File

@ -319,6 +319,7 @@ int GetAnimationEvent( void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEve
float SetController( void *pmodel, entvars_t *pev, int iController, float flValue )
{
studiohdr_t *pstudiohdr;
int i;
pstudiohdr = (studiohdr_t *)pmodel;
if (! pstudiohdr)
@ -327,7 +328,7 @@ float SetController( void *pmodel, entvars_t *pev, int iController, float flValu
mstudiobonecontroller_t *pbonecontroller = (mstudiobonecontroller_t *)((byte *)pstudiohdr + pstudiohdr->bonecontrollerindex);
// find first controller that matches the index
for (int i = 0; i < pstudiohdr->numbonecontrollers; i++, pbonecontroller++)
for (i = 0; i < pstudiohdr->numbonecontrollers; i++, pbonecontroller++)
{
if (pbonecontroller->index == iController)
break;

View File

@ -550,13 +550,13 @@ void CFuncRotating :: RampPitchVol (int fUp)
// get current angular velocity
vecCur = abs(vecAVel.x != 0 ? vecAVel.x : (vecAVel.y != 0 ? vecAVel.y : vecAVel.z));
vecCur = fabs(vecAVel.x != 0 ? vecAVel.x : (vecAVel.y != 0 ? vecAVel.y : vecAVel.z));
// get target angular velocity
vecFinal = (pev->movedir.x != 0 ? pev->movedir.x : (pev->movedir.y != 0 ? pev->movedir.y : pev->movedir.z));
vecFinal *= pev->speed;
vecFinal = abs(vecFinal);
vecFinal = fabs(vecFinal);
// calc volume and pitch as % of final vol and pitch
@ -592,9 +592,9 @@ void CFuncRotating :: SpinUp( void )
vecAVel = pev->avelocity;// cache entity's rotational velocity
// if we've met or exceeded target speed, set target speed and stop thinking
if ( abs(vecAVel.x) >= abs(pev->movedir.x * pev->speed) &&
abs(vecAVel.y) >= abs(pev->movedir.y * pev->speed) &&
abs(vecAVel.z) >= abs(pev->movedir.z * pev->speed) )
if ( fabs(vecAVel.x) >= fabs(pev->movedir.x * pev->speed) &&
fabs(vecAVel.y) >= fabs(pev->movedir.y * pev->speed) &&
fabs(vecAVel.z) >= fabs(pev->movedir.z * pev->speed) )
{
pev->avelocity = pev->movedir * pev->speed;// set speed in case we overshot
EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning),

View File

@ -101,8 +101,9 @@ void ClientDisconnect( edict_t *pEntity )
if (g_fGameOver)
return;
char text[256];
sprintf( text, "- %s has left the game\n", STRING(pEntity->v.netname) );
char text[256] = "";
if ( pEntity->v.netname )
snprintf( text, sizeof(text), "- %s has left the game\n", STRING(pEntity->v.netname) );
MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL );
WRITE_BYTE( ENTINDEX(pEntity) );
WRITE_STRING( text );
@ -197,6 +198,10 @@ void ClientPutInServer( edict_t *pEntity )
// Reset interpolation during first frame
pPlayer->pev->effects |= EF_NOINTERP;
pPlayer->pev->iuser1 = 0;
pPlayer->pev->iuser2 = 0;
}
#include "voice_gamemgr.h"
@ -527,7 +532,7 @@ void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer )
g_engfuncs.pfnSetClientKeyValue( ENTINDEX(pEntity), infobuffer, "name", sName );
char text[256];
sprintf( text, "* %s changed name to %s\n", STRING(pEntity->v.netname), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) );
snprintf( text, 256, "* %s changed name to %s\n", STRING(pEntity->v.netname), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) );
MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL );
WRITE_BYTE( ENTINDEX(pEntity) );
WRITE_STRING( text );

View File

@ -1225,6 +1225,11 @@ BOOL CBaseEntity :: FVisible ( CBaseEntity *pEntity )
Vector vecLookerOrigin;
Vector vecTargetOrigin;
if(!pEntity)
return FALSE;
if(!pEntity->pev)
return FALSE;
if (FBitSet( pEntity->pev->flags, FL_NOTARGET ))
return FALSE;

View File

@ -571,7 +571,8 @@ void CBaseDoor::DoorGoUp( void )
// emit door moving and stop sounds on CHAN_STATIC so that the multicast doesn't
// filter them out and leave a client stuck with looping door sounds!
if ( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) )
EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving), 1, ATTN_NORM);
if ( m_toggle_state != TS_GOING_UP && m_toggle_state != TS_GOING_DOWN )
EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving), 1, ATTN_NORM);
m_toggle_state = TS_GOING_UP;
@ -652,7 +653,8 @@ void CBaseDoor::DoorHitTop( void )
void CBaseDoor::DoorGoDown( void )
{
if ( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) )
EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving), 1, ATTN_NORM);
if ( m_toggle_state != TS_GOING_UP && m_toggle_state != TS_GOING_DOWN )
EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving), 1, ATTN_NORM);
#ifdef DOOR_ASSERT
ASSERT(m_toggle_state == TS_AT_TOP);
@ -753,6 +755,9 @@ void CBaseDoor::Blocked( CBaseEntity *pOther )
pDoor->pev->avelocity = g_vecZero;
}
}
if ( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) )
STOP_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving) );
if ( pDoor->m_toggle_state == TS_GOING_DOWN)
pDoor->DoorGoUp();
@ -1054,6 +1059,9 @@ void CMomentaryDoor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP
if ( value > 1.0 )
value = 1.0;
if ( value < 0.0 )
value = 0.0;
Vector move = m_vecPosition1 + (value * (m_vecPosition2 - m_vecPosition1));
Vector delta = move - pev->origin;

View File

@ -1003,7 +1003,7 @@ void CLaser::KeyValue( KeyValueData *pkvd )
}
else if (FStrEq(pkvd->szKeyName, "width"))
{
SetWidth( atof(pkvd->szValue) );
SetWidth( (int)atof(pkvd->szValue) );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "NoiseAmplitude"))

View File

@ -64,8 +64,8 @@ typedef int BOOL;
#include "math.h"
// Header file containing definition of globalvars_t and entvars_t
typedef int func_t; //
typedef int string_t; // from engine's pr_comp.h;
typedef unsigned int func_t; //
typedef unsigned int string_t; // from engine's pr_comp.h;
typedef float vec_t; // needed before including progdefs.h
// Vector class

View File

@ -596,7 +596,7 @@ void CBreakable::Die( void )
// The more negative pev->health, the louder
// the sound should be.
fvol = RANDOM_FLOAT(0.85, 1.0) + (abs(pev->health) / 100.0);
fvol = RANDOM_FLOAT(0.85, 1.0) + (fabs(pev->health) / 100.0);
if (fvol > 1.0)
fvol = 1.0;
@ -931,14 +931,13 @@ void CPushable :: Move( CBaseEntity *pOther, int push )
return;
}
// g-cont. fix pushable acceleration bug
// g-cont. fix pushable acceleration bug (reverted as it used in mods)
if ( pOther->IsPlayer() )
{
// Don't push unless the player is pushing forward and NOT use (pull)
if ( push && !(pevToucher->button & (IN_FORWARD|IN_MOVERIGHT|IN_MOVELEFT|IN_BACK)) )
if ( push && !(pevToucher->button & (IN_FORWARD|IN_USE)) )
return;
if ( !push && !(pevToucher->button & (IN_BACK)) ) return;
playerTouch = 1;
playerTouch = 1;
}
float factor;

View File

@ -60,7 +60,7 @@ public:
void WriteVector( const char *pname, const float *value, int count ); // Save a vector
void WritePositionVector( const char *pname, const Vector &value ); // Offset for landmark if necessary
void WritePositionVector( const char *pname, const float *value, int count ); // array of pos vectors
void WriteFunction( const char *pname, const int *value, int count ); // Save a function pointer
void WriteFunction( const char *pname, void **value, int count ); // Save a function pointer
int WriteEntVars( const char *pname, entvars_t *pev ); // Save entvars_t (entvars_t)
int WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount );

View File

@ -1537,7 +1537,7 @@ void TEXTURETYPE_Init()
char buffer[512];
int i, j;
byte *pMemFile;
int fileSize, filePos;
int fileSize, filePos = 0;
if (fTextureTypeInit)
return;

File diff suppressed because it is too large Load Diff

View File

@ -186,7 +186,7 @@ void PM_InitTextureTypes()
char buffer[512];
int i, j;
byte *pMemFile;
int fileSize, filePos;
int fileSize, filePos = 0;
static qboolean bTextureTypeInit = false;
if ( bTextureTypeInit )