Skip to content

Commit 261d421

Browse files
committed
Merge branch 'opfor' into opforfixed
2 parents 3823683 + ead3b77 commit 261d421

File tree

13 files changed

+111
-29
lines changed

13 files changed

+111
-29
lines changed

cl_dll/ammo.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,9 @@ int CHudAmmo::MsgFunc_WeaponList( const char *pszName, int iSize, void *pbuf )
647647

648648
WEAPON Weapon;
649649

650-
strcpy( Weapon.szName, READ_STRING() );
650+
strncpy( Weapon.szName, READ_STRING(), sizeof(Weapon.szName) );
651+
Weapon.szName[sizeof(Weapon.szName) - 1] = '\0';
652+
651653
Weapon.iAmmoType = (int)READ_CHAR();
652654

653655
Weapon.iMax1 = READ_BYTE();
@@ -665,6 +667,21 @@ int CHudAmmo::MsgFunc_WeaponList( const char *pszName, int iSize, void *pbuf )
665667
Weapon.iFlags = READ_BYTE();
666668
Weapon.iClip = 0;
667669

670+
if( Weapon.iId < 0 || Weapon.iId >= MAX_WEAPONS )
671+
return 0;
672+
if( Weapon.iSlot < 0 || Weapon.iSlot >= MAX_WEAPON_SLOTS + 1 )
673+
return 0;
674+
if( Weapon.iSlotPos < 0 || Weapon.iSlotPos >= MAX_WEAPON_POSITIONS + 1 )
675+
return 0;
676+
if( Weapon.iAmmoType < -1 || Weapon.iAmmoType >= MAX_AMMO_TYPES )
677+
return 0;
678+
if( Weapon.iAmmo2Type < -1 || Weapon.iAmmo2Type >= MAX_AMMO_TYPES )
679+
return 0;
680+
if( Weapon.iAmmoType >= 0 && Weapon.iMax1 == 0 )
681+
return 0;
682+
if( Weapon.iAmmo2Type >= 0 && Weapon.iMax2 == 0 )
683+
return 0;
684+
668685
gWR.AddWeapon( &Weapon );
669686

670687
return 1;

cl_dll/hud_spectator.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ void UTIL_StringToVector( float * pVector, const char *pString )
218218
char *pstr, *pfront, tempString[128];
219219
int j;
220220

221-
strcpy( tempString, pString );
221+
strncpy( tempString, pString, sizeof( tempString ) );
222+
tempString[sizeof( tempString ) - 1] = '\0';
223+
222224
pstr = pfront = tempString;
223225

224226
for( j = 0; j < 3; j++ )

dlls/basemonster.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class CBaseMonster : public CBaseToggle
129129
virtual BOOL ShouldFadeOnDeath( void );
130130

131131
// Basic Monster AI functions
132-
virtual float ChangeYaw( int speed );
132+
virtual float ChangeYaw( int yawSpeed );
133133
float VecToYaw( Vector vecDir );
134134
float FlYawDiff( void );
135135

dlls/client.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,14 @@ void ClientCommand( edict_t *pEntity )
630630
strncpy( command, pcmd, sizeof(command) - 1);
631631
command[sizeof(command) - 1] = '\0';
632632

633+
// First parse the name and remove any %'s
634+
for( char *pApersand = command; *pApersand; pApersand++ )
635+
{
636+
// Replace it with a space
637+
if( *pApersand == '%' )
638+
*pApersand = ' ';
639+
}
640+
633641
// tell the user they entered an unknown command
634642
ClientPrint( &pEntity->v, HUD_PRINTCONSOLE, UTIL_VarArgs( "Unknown command: %s\n", command ) );
635643
}

dlls/flyingmonster.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "extdll.h"
1717
#include "util.h"
1818
#include "cbase.h"
19+
#include "game.h"
1920
#include "monsters.h"
2021
#include "schedule.h"
2122
#include "flyingmonster.h"
@@ -83,7 +84,7 @@ void CFlyingMonster::Stop( void )
8384
m_vecTravel = g_vecZero;
8485
}
8586

86-
float CFlyingMonster::ChangeYaw( int speed )
87+
float CFlyingMonster::ChangeYaw( int yawSpeed )
8788
{
8889
if( pev->movetype == MOVETYPE_FLY )
8990
{
@@ -97,9 +98,25 @@ float CFlyingMonster::ChangeYaw( int speed )
9798
else if( diff > 20.0f )
9899
target = -90.0f;
99100
}
100-
pev->angles.z = UTIL_Approach( target, pev->angles.z, 220.0f * gpGlobals->frametime );
101+
102+
float speed = 220.f;
103+
104+
if( monsteryawspeedfix.value )
105+
{
106+
if( m_flLastZYawTime == 0.f )
107+
m_flLastZYawTime = gpGlobals->time - gpGlobals->frametime;
108+
109+
float delta = Q_min( gpGlobals->time - m_flLastZYawTime, 0.25f );
110+
m_flLastZYawTime = gpGlobals->time;
111+
112+
speed *= delta;
113+
}
114+
else
115+
speed *= gpGlobals->frametime;
116+
117+
pev->angles.z = UTIL_Approach( target, pev->angles.z, speed );
101118
}
102-
return CBaseMonster::ChangeYaw( speed );
119+
return CBaseMonster::ChangeYaw( yawSpeed );
103120
}
104121

105122
void CFlyingMonster::Killed( entvars_t *pevAttacker, int iGib )

dlls/flyingmonster.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class CFlyingMonster : public CBaseMonster
2525
Activity GetStoppedActivity( void );
2626
void Killed( entvars_t *pevAttacker, int iGib );
2727
void Stop( void );
28-
float ChangeYaw( int speed );
28+
float ChangeYaw( int yawSpeed );
2929
void HandleAnimEvent( MonsterEvent_t *pEvent );
3030
void MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, float flInterval );
3131
void Move( float flInterval = 0.1 );
@@ -45,5 +45,6 @@ class CFlyingMonster : public CBaseMonster
4545
float m_stopTime; // Last time we stopped (to avoid switching states too soon)
4646
float m_momentum; // Weight for desired vs. momentum velocity
4747
const char *m_pFlapSound;
48+
float m_flLastZYawTime; // Last frame time Z was changed when yaw was changed
4849
};
4950
#endif //FLYINGMONSTER_H

dlls/ichthyosaur.cpp

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "extdll.h"
2222
#include "util.h"
2323
#include "cbase.h"
24+
#include "game.h"
2425
#include "monsters.h"
2526
#include "schedule.h"
2627
#include "flyingmonster.h"
@@ -76,7 +77,7 @@ class CIchthyosaur : public CFlyingMonster
7677
BOOL CheckMeleeAttack1( float flDot, float flDist );
7778
BOOL CheckRangeAttack1( float flDot, float flDist );
7879

79-
float ChangeYaw( int speed );
80+
float ChangeYaw( int yawSpeed );
8081
Activity GetStoppedActivity( void );
8182

8283
void Move( float flInterval );
@@ -88,7 +89,7 @@ class CIchthyosaur : public CFlyingMonster
8889

8990
float VectorToPitch( const Vector &vec );
9091
float FlPitchDiff( void );
91-
float ChangePitch( int speed );
92+
float ChangePitch( int pitchSpeed );
9293

9394
virtual int SizeForGrapple() { return GRAPPLE_LARGE; }
9495

@@ -108,6 +109,9 @@ class CIchthyosaur : public CFlyingMonster
108109

109110
float m_flNextAlert;
110111

112+
float m_flLastPitchTime; // Last frame time pitch was changed
113+
float m_flLastZYawTime; // Last frame time Z was changed when yaw was changed
114+
111115
static const char *pIdleSounds[];
112116
static const char *pAlertSounds[];
113117
static const char *pAttackSounds[];
@@ -782,7 +786,7 @@ float CIchthyosaur::FlPitchDiff( void )
782786
return flPitchDiff;
783787
}
784788

785-
float CIchthyosaur::ChangePitch( int speed )
789+
float CIchthyosaur::ChangePitch( int pitchSpeed )
786790
{
787791
if( pev->movetype == MOVETYPE_FLY )
788792
{
@@ -795,12 +799,28 @@ float CIchthyosaur::ChangePitch( int speed )
795799
else if( diff > 20 )
796800
target = -45;
797801
}
798-
pev->angles.x = UTIL_Approach(target, pev->angles.x, 220.0f * 0.1f );
802+
803+
float speed = 220.f;
804+
805+
if( monsteryawspeedfix.value )
806+
{
807+
if( m_flLastPitchTime == 0.f )
808+
m_flLastPitchTime = gpGlobals->time - gpGlobals->frametime;
809+
810+
float delta = Q_min( gpGlobals->time - m_flLastPitchTime, 0.25f );
811+
m_flLastPitchTime = gpGlobals->time;
812+
813+
speed *= delta;
814+
}
815+
else
816+
speed *= 0.1f;
817+
818+
pev->angles.x = UTIL_Approach(target, pev->angles.x, speed );
799819
}
800820
return 0;
801821
}
802822

803-
float CIchthyosaur::ChangeYaw( int speed )
823+
float CIchthyosaur::ChangeYaw( int yawSpeed )
804824
{
805825
if( pev->movetype == MOVETYPE_FLY )
806826
{
@@ -814,9 +834,25 @@ float CIchthyosaur::ChangeYaw( int speed )
814834
else if( diff > 20 )
815835
target = -20;
816836
}
817-
pev->angles.z = UTIL_Approach( target, pev->angles.z, 220.0f * 0.1f );
837+
838+
float speed = 220.f;
839+
840+
if( monsteryawspeedfix.value )
841+
{
842+
if( m_flLastZYawTime == 0.f )
843+
m_flLastZYawTime = gpGlobals->time - gpGlobals->frametime;
844+
845+
float delta = Q_min( gpGlobals->time - m_flLastZYawTime, 0.25f );
846+
m_flLastZYawTime = gpGlobals->time;
847+
848+
speed *= delta;
849+
}
850+
else
851+
speed *= 0.1f;
852+
853+
pev->angles.z = UTIL_Approach( target, pev->angles.z, speed );
818854
}
819-
return CFlyingMonster::ChangeYaw( speed );
855+
return CFlyingMonster::ChangeYaw( yawSpeed );
820856
}
821857

822858
Activity CIchthyosaur::GetStoppedActivity( void )

dlls/maprules.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ void CGamePlayerEquip::KeyValue( KeyValueData *pkvd )
764764
{
765765
char tmp[128];
766766

767-
UTIL_StripToken( pkvd->szKeyName, tmp );
767+
UTIL_StripToken( pkvd->szKeyName, tmp, sizeof( tmp ));
768768

769769
m_weaponNames[i] = ALLOC_STRING( tmp );
770770
m_weaponCount[i] = atoi( pkvd->szValue );

dlls/monsters.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,8 +2034,6 @@ void CBaseMonster::MonsterInit( void )
20342034
SetThink( &CBaseMonster::MonsterInitThink );
20352035
pev->nextthink = gpGlobals->time + 0.1f;
20362036
SetUse( &CBaseMonster::MonsterUse );
2037-
2038-
m_flLastYawTime = gpGlobals->time;
20392037
}
20402038

20412039
//=========================================================
@@ -2523,9 +2521,12 @@ float CBaseMonster::ChangeYaw( int yawSpeed )
25232521
{
25242522
if( monsteryawspeedfix.value )
25252523
{
2526-
float delta;
2524+
if( m_flLastYawTime == 0.f )
2525+
m_flLastYawTime = gpGlobals->time - gpGlobals->frametime;
2526+
2527+
float delta = Q_min( gpGlobals->time - m_flLastYawTime, 0.25f );
25272528

2528-
delta = Q_min( gpGlobals->time - m_flLastYawTime, 0.25f );
2529+
m_flLastYawTime = gpGlobals->time;
25292530

25302531
speed = (float)yawSpeed * delta * 2;
25312532
}
@@ -2575,8 +2576,6 @@ float CBaseMonster::ChangeYaw( int yawSpeed )
25752576
else
25762577
move = 0;
25772578

2578-
m_flLastYawTime = gpGlobals->time;
2579-
25802579
return move;
25812580
}
25822581

dlls/mpstubb.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ int CGraph::FindNearestNode( const Vector &vecOrigin, int afNodeTypes ) { return
3737
/*********************************************************/
3838

3939
void CBaseMonster::ReportAIState( void ) { }
40-
float CBaseMonster::ChangeYaw( int speed ) { return 0; }
40+
float CBaseMonster::ChangeYaw( int yawSpeed ) { return 0; }
4141
void CBaseMonster::MakeIdealYaw( Vector vecTarget ) { }
4242

4343
void CBaseMonster::CorpseFallThink( void )

0 commit comments

Comments
 (0)