mirror of
https://github.com/FWGS/hlsdk-xash3d
synced 2024-11-22 09:57:21 +01:00
Apply some valve's fixes
This commit is contained in:
parent
0f599684c5
commit
ac857199cf
@ -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
|
||||
|
||||
//=========================================================
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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),
|
||||
|
@ -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 );
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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"))
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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 );
|
||||
|
||||
|
@ -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;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
* Copyright (c) 1996-2001, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
@ -354,15 +354,17 @@ BOOL UTIL_GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeap
|
||||
// ripped this out of the engine
|
||||
float UTIL_AngleMod(float a)
|
||||
{
|
||||
if (a < 0)
|
||||
/*if (a < 0)
|
||||
{
|
||||
a = a + 360 * ((int)(a / 360) + 1);
|
||||
}
|
||||
else if (a >= 360)
|
||||
{
|
||||
a = a - 360 * ((int)(a / 360));
|
||||
}
|
||||
}*/
|
||||
// a = (360.0/65536) * ((int)(a*(65536/360.0)) & 65535);
|
||||
a = fmod( a, 360.0f );
|
||||
if( a < 0 ) a += 360;
|
||||
return a;
|
||||
}
|
||||
|
||||
@ -1003,7 +1005,9 @@ float UTIL_VecToYaw( const Vector &vec )
|
||||
|
||||
void UTIL_SetOrigin( entvars_t *pev, const Vector &vecOrigin )
|
||||
{
|
||||
SET_ORIGIN(ENT(pev), vecOrigin );
|
||||
edict_t *ent = ENT(pev);
|
||||
if ( ent )
|
||||
SET_ORIGIN( ent, vecOrigin );
|
||||
}
|
||||
|
||||
void UTIL_ParticleEffect( const Vector &vecOrigin, const Vector &vecDirection, ULONG ulColor, ULONG ulCount )
|
||||
@ -1655,7 +1659,11 @@ static int gSizes[FIELD_TYPECOUNT] =
|
||||
sizeof(float)*3, // FIELD_POSITION_VECTOR
|
||||
sizeof(int *), // FIELD_POINTER
|
||||
sizeof(int), // FIELD_INTEGER
|
||||
#ifdef GNUC
|
||||
sizeof(int *)*2, // FIELD_FUNCTION
|
||||
#else
|
||||
sizeof(int *), // FIELD_FUNCTION
|
||||
#endif
|
||||
sizeof(int), // FIELD_BOOLEAN
|
||||
sizeof(short), // FIELD_SHORT
|
||||
sizeof(char), // FIELD_CHARACTER
|
||||
@ -1965,7 +1973,7 @@ void CSave :: WritePositionVector( const char *pname, const float *value, int co
|
||||
}
|
||||
|
||||
|
||||
void CSave :: WriteFunction( const char *pname, const int *data, int count )
|
||||
void CSave :: WriteFunction( const char *pname, void **data, int count )
|
||||
{
|
||||
const char *functionName;
|
||||
|
||||
@ -2133,7 +2141,7 @@ int CSave :: WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *p
|
||||
break;
|
||||
|
||||
case FIELD_FUNCTION:
|
||||
WriteFunction( pTest->fieldName, (int *)(char *)pOutputData, pTest->fieldSize );
|
||||
WriteFunction( pTest->fieldName, (void **)pOutputData, pTest->fieldSize );
|
||||
break;
|
||||
default:
|
||||
ALERT( at_error, "Bad field type\n" );
|
||||
@ -2241,13 +2249,20 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou
|
||||
switch( pTest->fieldType )
|
||||
{
|
||||
case FIELD_TIME:
|
||||
#ifdef __VFP_FP__
|
||||
memcpy(&timeData, pInputData, 4);
|
||||
// Re-base time variables
|
||||
timeData += time;
|
||||
memcpy(pOutputData, &timeData, 4);
|
||||
#else
|
||||
timeData = *(float *)pInputData;
|
||||
// Re-base time variables
|
||||
timeData += time;
|
||||
*((float *)pOutputData) = timeData;
|
||||
#endif
|
||||
break;
|
||||
case FIELD_FLOAT:
|
||||
*((float *)pOutputData) = *(float *)pInputData;
|
||||
memcpy(pOutputData, pInputData, 4);
|
||||
break;
|
||||
case FIELD_MODELNAME:
|
||||
case FIELD_SOUNDNAME:
|
||||
@ -2325,9 +2340,22 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou
|
||||
((float *)pOutputData)[2] = ((float *)pInputData)[2];
|
||||
break;
|
||||
case FIELD_POSITION_VECTOR:
|
||||
#ifdef __VFP_FP__
|
||||
float tmp;
|
||||
memcpy(&tmp, (char *)pInputData + 0, 4);
|
||||
tmp += position.x;
|
||||
memcpy((char *)pOutputData + 0, &tmp, 4);
|
||||
memcpy(&tmp, (char *)pInputData + 4, 4);
|
||||
tmp += position.y;
|
||||
memcpy((char *)pOutputData + 4, &tmp, 4);
|
||||
memcpy(&tmp, (char *)pInputData + 8, 4);
|
||||
tmp += position.z;
|
||||
memcpy((char *)pOutputData + 8, &tmp, 4);
|
||||
#else
|
||||
((float *)pOutputData)[0] = ((float *)pInputData)[0] + position.x;
|
||||
((float *)pOutputData)[1] = ((float *)pInputData)[1] + position.y;
|
||||
((float *)pOutputData)[2] = ((float *)pInputData)[2] + position.z;
|
||||
#endif
|
||||
break;
|
||||
|
||||
case FIELD_BOOLEAN:
|
||||
|
@ -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 )
|
||||
|
Loading…
Reference in New Issue
Block a user