Browse Source

Apply some valve's fixes

foolsday
mittorn 9 years ago
parent
commit
ac857199cf
  1. 4
      cl_dll/util_vector.h
  2. 4
      common/const.h
  3. 3
      dlls/animation.cpp
  4. 10
      dlls/bmodels.cpp
  5. 11
      dlls/client.cpp
  6. 5
      dlls/combat.cpp
  7. 12
      dlls/doors.cpp
  8. 2
      dlls/effects.cpp
  9. 4
      dlls/extdll.h
  10. 9
      dlls/func_break.cpp
  11. 2
      dlls/saverestore.h
  12. 2
      dlls/sound.cpp
  13. 42
      dlls/util.cpp
  14. 2
      pm_shared/pm_shared.c

4
cl_dll/util_vector.h

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

4
common/const.h

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

3
dlls/animation.cpp

@ -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 ) float SetController( void *pmodel, entvars_t *pev, int iController, float flValue )
{ {
studiohdr_t *pstudiohdr; studiohdr_t *pstudiohdr;
int i;
pstudiohdr = (studiohdr_t *)pmodel; pstudiohdr = (studiohdr_t *)pmodel;
if (! pstudiohdr) 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); mstudiobonecontroller_t *pbonecontroller = (mstudiobonecontroller_t *)((byte *)pstudiohdr + pstudiohdr->bonecontrollerindex);
// find first controller that matches the index // 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) if (pbonecontroller->index == iController)
break; break;

10
dlls/bmodels.cpp

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

11
dlls/client.cpp

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

5
dlls/combat.cpp

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

12
dlls/doors.cpp

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

2
dlls/effects.cpp

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

4
dlls/extdll.h

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

9
dlls/func_break.cpp

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

2
dlls/saverestore.h

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

2
dlls/sound.cpp

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

42
dlls/util.cpp

@ -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 * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * 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 // ripped this out of the engine
float UTIL_AngleMod(float a) float UTIL_AngleMod(float a)
{ {
if (a < 0) /*if (a < 0)
{ {
a = a + 360 * ((int)(a / 360) + 1); a = a + 360 * ((int)(a / 360) + 1);
} }
else if (a >= 360) else if (a >= 360)
{ {
a = a - 360 * ((int)(a / 360)); a = a - 360 * ((int)(a / 360));
} }*/
// a = (360.0/65536) * ((int)(a*(65536/360.0)) & 65535); // a = (360.0/65536) * ((int)(a*(65536/360.0)) & 65535);
a = fmod( a, 360.0f );
if( a < 0 ) a += 360;
return a; return a;
} }
@ -1003,7 +1005,9 @@ float UTIL_VecToYaw( const Vector &vec )
void UTIL_SetOrigin( entvars_t *pev, const Vector &vecOrigin ) 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 ) 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(float)*3, // FIELD_POSITION_VECTOR
sizeof(int *), // FIELD_POINTER sizeof(int *), // FIELD_POINTER
sizeof(int), // FIELD_INTEGER sizeof(int), // FIELD_INTEGER
#ifdef GNUC
sizeof(int *)*2, // FIELD_FUNCTION
#else
sizeof(int *), // FIELD_FUNCTION sizeof(int *), // FIELD_FUNCTION
#endif
sizeof(int), // FIELD_BOOLEAN sizeof(int), // FIELD_BOOLEAN
sizeof(short), // FIELD_SHORT sizeof(short), // FIELD_SHORT
sizeof(char), // FIELD_CHARACTER 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; const char *functionName;
@ -2133,7 +2141,7 @@ int CSave :: WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *p
break; break;
case FIELD_FUNCTION: case FIELD_FUNCTION:
WriteFunction( pTest->fieldName, (int *)(char *)pOutputData, pTest->fieldSize ); WriteFunction( pTest->fieldName, (void **)pOutputData, pTest->fieldSize );
break; break;
default: default:
ALERT( at_error, "Bad field type\n" ); ALERT( at_error, "Bad field type\n" );
@ -2241,13 +2249,20 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou
switch( pTest->fieldType ) switch( pTest->fieldType )
{ {
case FIELD_TIME: case FIELD_TIME:
#ifdef __VFP_FP__
memcpy(&timeData, pInputData, 4);
// Re-base time variables
timeData += time;
memcpy(pOutputData, &timeData, 4);
#else
timeData = *(float *)pInputData; timeData = *(float *)pInputData;
// Re-base time variables // Re-base time variables
timeData += time; timeData += time;
*((float *)pOutputData) = timeData; *((float *)pOutputData) = timeData;
#endif
break; break;
case FIELD_FLOAT: case FIELD_FLOAT:
*((float *)pOutputData) = *(float *)pInputData; memcpy(pOutputData, pInputData, 4);
break; break;
case FIELD_MODELNAME: case FIELD_MODELNAME:
case FIELD_SOUNDNAME: case FIELD_SOUNDNAME:
@ -2325,9 +2340,22 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou
((float *)pOutputData)[2] = ((float *)pInputData)[2]; ((float *)pOutputData)[2] = ((float *)pInputData)[2];
break; break;
case FIELD_POSITION_VECTOR: 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)[0] = ((float *)pInputData)[0] + position.x;
((float *)pOutputData)[1] = ((float *)pInputData)[1] + position.y; ((float *)pOutputData)[1] = ((float *)pInputData)[1] + position.y;
((float *)pOutputData)[2] = ((float *)pInputData)[2] + position.z; ((float *)pOutputData)[2] = ((float *)pInputData)[2] + position.z;
#endif
break; break;
case FIELD_BOOLEAN: case FIELD_BOOLEAN:

2
pm_shared/pm_shared.c

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

Loading…
Cancel
Save