Skip to content

Commit 8b57dd9

Browse files
committed
Merge branch 'master' into bshift
2 parents 9f490a5 + c461624 commit 8b57dd9

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
@@ -628,6 +628,14 @@ void ClientCommand( edict_t *pEntity )
628628
strncpy( command, pcmd, sizeof(command) - 1);
629629
command[sizeof(command) - 1] = '\0';
630630

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

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
Vector m_SaveVelocity;
9495
float m_idealDist;
@@ -106,6 +107,9 @@ class CIchthyosaur : public CFlyingMonster
106107

107108
float m_flNextAlert;
108109

110+
float m_flLastPitchTime; // Last frame time pitch was changed
111+
float m_flLastZYawTime; // Last frame time Z was changed when yaw was changed
112+
109113
static const char *pIdleSounds[];
110114
static const char *pAlertSounds[];
111115
static const char *pAttackSounds[];
@@ -780,7 +784,7 @@ float CIchthyosaur::FlPitchDiff( void )
780784
return flPitchDiff;
781785
}
782786

783-
float CIchthyosaur::ChangePitch( int speed )
787+
float CIchthyosaur::ChangePitch( int pitchSpeed )
784788
{
785789
if( pev->movetype == MOVETYPE_FLY )
786790
{
@@ -793,12 +797,28 @@ float CIchthyosaur::ChangePitch( int speed )
793797
else if( diff > 20 )
794798
target = -45;
795799
}
796-
pev->angles.x = UTIL_Approach(target, pev->angles.x, 220.0f * 0.1f );
800+
801+
float speed = 220.f;
802+
803+
if( monsteryawspeedfix.value )
804+
{
805+
if( m_flLastPitchTime == 0.f )
806+
m_flLastPitchTime = gpGlobals->time - gpGlobals->frametime;
807+
808+
float delta = Q_min( gpGlobals->time - m_flLastPitchTime, 0.25f );
809+
m_flLastPitchTime = gpGlobals->time;
810+
811+
speed *= delta;
812+
}
813+
else
814+
speed *= 0.1f;
815+
816+
pev->angles.x = UTIL_Approach(target, pev->angles.x, speed );
797817
}
798818
return 0;
799819
}
800820

801-
float CIchthyosaur::ChangeYaw( int speed )
821+
float CIchthyosaur::ChangeYaw( int yawSpeed )
802822
{
803823
if( pev->movetype == MOVETYPE_FLY )
804824
{
@@ -812,9 +832,25 @@ float CIchthyosaur::ChangeYaw( int speed )
812832
else if( diff > 20 )
813833
target = -20;
814834
}
815-
pev->angles.z = UTIL_Approach( target, pev->angles.z, 220.0f * 0.1f );
835+
836+
float speed = 220.f;
837+
838+
if( monsteryawspeedfix.value )
839+
{
840+
if( m_flLastZYawTime == 0.f )
841+
m_flLastZYawTime = gpGlobals->time - gpGlobals->frametime;
842+
843+
float delta = Q_min( gpGlobals->time - m_flLastZYawTime, 0.25f );
844+
m_flLastZYawTime = gpGlobals->time;
845+
846+
speed *= delta;
847+
}
848+
else
849+
speed *= 0.1f;
850+
851+
pev->angles.z = UTIL_Approach( target, pev->angles.z, speed );
816852
}
817-
return CFlyingMonster::ChangeYaw( speed );
853+
return CFlyingMonster::ChangeYaw( yawSpeed );
818854
}
819855

820856
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
@@ -2023,8 +2023,6 @@ void CBaseMonster::MonsterInit( void )
20232023
SetThink( &CBaseMonster::MonsterInitThink );
20242024
pev->nextthink = gpGlobals->time + 0.1f;
20252025
SetUse( &CBaseMonster::MonsterUse );
2026-
2027-
m_flLastYawTime = gpGlobals->time;
20282026
}
20292027

20302028
//=========================================================
@@ -2509,9 +2507,12 @@ float CBaseMonster::ChangeYaw( int yawSpeed )
25092507
{
25102508
if( monsteryawspeedfix.value )
25112509
{
2512-
float delta;
2510+
if( m_flLastYawTime == 0.f )
2511+
m_flLastYawTime = gpGlobals->time - gpGlobals->frametime;
2512+
2513+
float delta = Q_min( gpGlobals->time - m_flLastYawTime, 0.25f );
25132514

2514-
delta = Q_min( gpGlobals->time - m_flLastYawTime, 0.25f );
2515+
m_flLastYawTime = gpGlobals->time;
25152516

25162517
speed = (float)yawSpeed * delta * 2;
25172518
}
@@ -2561,8 +2562,6 @@ float CBaseMonster::ChangeYaw( int yawSpeed )
25612562
else
25622563
move = 0;
25632564

2564-
m_flLastYawTime = gpGlobals->time;
2565-
25662565
return move;
25672566
}
25682567

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)