From 23b1b76dced374de4e230d9bc9ed6d38ac874d98 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Wed, 6 Sep 2023 05:11:41 +0300 Subject: [PATCH] Next set of write-string fixes --- cl_dll/thewastes/hl_baseentity.cpp | 6 +++--- common/thewastes.h | 2 +- common/tw_common.h | 6 +++--- dlls/activity.h | 2 +- dlls/buttons.cpp | 12 ++++++------ dlls/cbase.cpp | 2 +- dlls/cbase.h | 6 +++--- dlls/client.cpp | 4 ++-- dlls/decals.h | 2 +- dlls/doors.cpp | 4 ++-- dlls/func_break.cpp | 6 +++--- dlls/h_cycler.cpp | 4 ++-- dlls/player.cpp | 6 +++--- dlls/player.h | 2 +- dlls/sound.cpp | 6 +++--- dlls/util.cpp | 4 ++-- dlls/util.h | 4 ++-- dlls/weapons.cpp | 2 +- dlls/weapons.h | 2 +- dlls/world.cpp | 2 +- dlls/wpn_shared/tw_explosives.cpp | 8 ++++---- dlls/wpn_shared/tw_melee.cpp | 6 +++--- 22 files changed, 49 insertions(+), 49 deletions(-) diff --git a/cl_dll/thewastes/hl_baseentity.cpp b/cl_dll/thewastes/hl_baseentity.cpp index bce901e..1d3ce0f 100644 --- a/cl_dll/thewastes/hl_baseentity.cpp +++ b/cl_dll/thewastes/hl_baseentity.cpp @@ -52,7 +52,7 @@ int CBaseEntity :: IsDormant( void ) { return 0; } BOOL CBaseEntity :: IsInWorld( void ) { return TRUE; } int CBaseEntity::ShouldToggle( USE_TYPE useType, BOOL currentState ) { return 0; } int CBaseEntity :: DamageDecal( int bitsDamageType ) { return -1; } -CBaseEntity * CBaseEntity::Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) { return NULL; } +CBaseEntity * CBaseEntity::Create( const char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) { return NULL; } void CBaseEntity::SUB_Remove( void ) { } // CBaseDelay Stubs @@ -77,7 +77,7 @@ void UTIL_MakeVectors( const Vector &vecAngles ) { } BOOL UTIL_IsValidEntity( edict_t *pent ) { return TRUE; } void UTIL_SetOrigin( entvars_t *, const Vector &org ) { } BOOL UTIL_GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ) { return TRUE; } -void UTIL_LogPrintf(char *,...) { } +void UTIL_LogPrintf(const char *,...) { } void UTIL_ClientPrintAll( int,char const *,char const *,char const *,char const *,char const *) { } void ClientPrint( entvars_t *client, int msg_dest, const char *msg_name, const char *param1, const char *param2, const char *param3, const char *param4 ) { } @@ -291,7 +291,7 @@ BOOL CBasePlayer::HasPlayerItem( CBasePlayerItem *pCheckItem ) { return FALSE; } BOOL CBasePlayer :: SwitchWeapon( CBasePlayerItem *pWeapon ) { return FALSE; } Vector CBasePlayer :: GetGunPosition( void ) { return g_vecZero; } const char *CBasePlayer::TeamID( void ) { return ""; } -int CBasePlayer :: GiveAmmo( int iCount, char *szName, int iMax ) { return 0; } +int CBasePlayer :: GiveAmmo( int iCount, const char *szName, int iMax ) { return 0; } void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) { } void CBasePlayer::AddPointsToTeam( int score, BOOL bAllowNegativeScore ) { } diff --git a/common/thewastes.h b/common/thewastes.h index beaee8e..d963da1 100644 --- a/common/thewastes.h +++ b/common/thewastes.h @@ -965,7 +965,7 @@ public: float m_flFuseTimer; // How long does the fuse last on this explosive? float m_flDamage; // How much damage do our explosives dish out ? float m_flResistance; // Air resistance - char *m_pszExplosiveModel; // What does our explosive look like ? + const char *m_pszExplosiveModel; // What does our explosive look like ? BOOL m_bFusePrimed; // TRUE if the bomb we are holding is ticking! int m_iExplosiveType; // Explosive class to use diff --git a/common/tw_common.h b/common/tw_common.h index c18f4d0..116f52d 100644 --- a/common/tw_common.h +++ b/common/tw_common.h @@ -352,8 +352,8 @@ enum e_weapcategory { typedef struct playeritem_s { - char *weapon_classname; - char *ammo_classname; + const char *weapon_classname; + const char *ammo_classname; int num_ammospawns; int category; } playeritem_t; @@ -451,4 +451,4 @@ enum penetration_types_e #define DRC_FLAG_FINAL (1<<9) // is a final scene #define DRC_FLAG_NO_RANDOM (1<<10) // don't randomize event data -#endif \ No newline at end of file +#endif diff --git a/dlls/activity.h b/dlls/activity.h index 01a4867..d0c9f22 100644 --- a/dlls/activity.h +++ b/dlls/activity.h @@ -100,7 +100,7 @@ typedef enum { typedef struct { int type; - char *name; + const char *name; } activity_map_t; extern activity_map_t activity_map[]; diff --git a/dlls/buttons.cpp b/dlls/buttons.cpp index 01e4684..732c600 100644 --- a/dlls/buttons.cpp +++ b/dlls/buttons.cpp @@ -288,7 +288,7 @@ IMPLEMENT_SAVERESTORE( CBaseButton, CBaseToggle ); void CBaseButton::Precache( void ) { - char *pszSound; + const char *pszSound; if ( FBitSet ( pev->spawnflags, SF_BUTTON_SPARK_IF_OFF ) )// this button should spark in OFF state { @@ -441,7 +441,7 @@ LINK_ENTITY_TO_CLASS( func_button, CBaseButton ); void CBaseButton::Spawn( ) { - char *pszSound; + const char *pszSound; //---------------------------------------------------- //determine sounds for buttons @@ -508,9 +508,9 @@ void CBaseButton::Spawn( ) // Button sound table. // Also used by CBaseDoor to get 'touched' door lock/unlock sounds -char *ButtonSound( int sound ) +const char *ButtonSound( int sound ) { - char *pszSound; + const char *pszSound; switch ( sound ) { @@ -809,7 +809,7 @@ LINK_ENTITY_TO_CLASS( func_rot_button, CRotButton ); void CRotButton::Spawn( void ) { - char *pszSound; + const char *pszSound; //---------------------------------------------------- //determine sounds for buttons //a sound of 0 should not make a sound @@ -951,7 +951,7 @@ void CMomentaryRotButton::Spawn( void ) UTIL_SetOrigin(pev, pev->origin); SET_MODEL(ENT(pev), STRING(pev->model) ); - char *pszSound = ButtonSound( m_sounds ); + const char *pszSound = ButtonSound( m_sounds ); PRECACHE_SOUND(pszSound); pev->noise = ALLOC_STRING(pszSound); m_lastUsed = 0; diff --git a/dlls/cbase.cpp b/dlls/cbase.cpp index 5799b89..b0acca4 100644 --- a/dlls/cbase.cpp +++ b/dlls/cbase.cpp @@ -752,7 +752,7 @@ int CBaseEntity :: DamageDecal( int bitsDamageType ) // NOTE: szName must be a pointer to constant memory, e.g. "monster_class" because the entity // will keep a pointer to it after this call. -CBaseEntity * CBaseEntity::Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) +CBaseEntity * CBaseEntity::Create( const char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) { edict_t *pent; CBaseEntity *pEntity; diff --git a/dlls/cbase.h b/dlls/cbase.h index 49dda3f..da33bcc 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -176,7 +176,7 @@ public: virtual void AddPointsToTeam( int score, BOOL bAllowNegativeScore ) {} virtual BOOL AddPlayerItem( CBasePlayerItem *pItem ) { return 0; } virtual BOOL RemovePlayerItem( CBasePlayerItem *pItem ) { return 0; } - virtual int GiveAmmo( int iAmount, char *szName, int iMax ) { return -1; }; + virtual int GiveAmmo( int iAmount, const char *szName, int iMax ) { return -1; }; virtual float GetDelay( void ) { return 0; } virtual int IsMoving( void ) { return pev->velocity != g_vecZero; } virtual void OverrideReset( void ) {} @@ -319,7 +319,7 @@ public: // - static CBaseEntity *Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner = NULL ); + static CBaseEntity *Create( const char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner = NULL ); virtual BOOL FBecomeProne( void ) {return FALSE;}; edict_t *edict() { return ENT( pev ); }; @@ -659,7 +659,7 @@ class CSound; #include "basemonster.h" -char *ButtonSound( int sound ); // get string of button sound number +const char *ButtonSound( int sound ); // get string of button sound number // diff --git a/dlls/client.cpp b/dlls/client.cpp index 32edf5d..a1f34be 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -221,7 +221,7 @@ void ClientPutInServer( edict_t *pEntity ) pPlayer->pev->effects |= EF_NOINTERP; } -void SendMsgTo(CBasePlayer *client,edict_t *pEntity, int teamonly,char text[128],char *classname) +void SendMsgTo(CBasePlayer *client,edict_t *pEntity, int teamonly,char text[128],const char *classname) { client = NULL; @@ -360,7 +360,7 @@ void Host_Say( edict_t *pEntity, int teamonly ) // echo to server console g_engfuncs.pfnServerPrint( text ); - char * temp; + const char * temp; if ( teamonly ) temp = "say_team"; else diff --git a/dlls/decals.h b/dlls/decals.h index e18ab71..6a4f1be 100644 --- a/dlls/decals.h +++ b/dlls/decals.h @@ -66,7 +66,7 @@ enum decal_e typedef struct { - char *name; + const char *name; int index; } DLL_DECALLIST; diff --git a/dlls/doors.cpp b/dlls/doors.cpp index 354ddbb..2e6e78b 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -335,7 +335,7 @@ void CBaseDoor :: SetToggleState( int state ) void CBaseDoor::Precache( void ) { - char *pszSound; + const char *pszSound; // set the door's "in-motion" sound switch (m_bMoveSnd) @@ -1023,4 +1023,4 @@ void CMomentaryDoor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP LinearMove( move, speed ); } -} \ No newline at end of file +} diff --git a/dlls/func_break.cpp b/dlls/func_break.cpp index a37fb6c..c1dbf0a 100644 --- a/dlls/func_break.cpp +++ b/dlls/func_break.cpp @@ -360,7 +360,7 @@ void CBreakable::DamageSound( void ) { int pitch; float fvol; - char *rgpsz[6]; + const char *rgpsz[6]; int i; int material = m_Material; @@ -802,7 +802,7 @@ public: static TYPEDESCRIPTION m_SaveData[]; - static char *m_soundNames[3]; + static const char *m_soundNames[3]; int m_lastSound; // no need to save/restore, just keeps the same sound from playing twice in a row float m_maxSpeed; float m_soundTime; @@ -818,7 +818,7 @@ IMPLEMENT_SAVERESTORE( CPushable, CBreakable ); LINK_ENTITY_TO_CLASS( func_pushable, CPushable ); -char *CPushable :: m_soundNames[3] = { "debris/pushbox1.wav", "debris/pushbox2.wav", "debris/pushbox3.wav" }; +const char *CPushable :: m_soundNames[3] = { "debris/pushbox1.wav", "debris/pushbox2.wav", "debris/pushbox3.wav" }; void CPushable :: Spawn( void ) diff --git a/dlls/h_cycler.cpp b/dlls/h_cycler.cpp index 77a8cdf..db829dd 100644 --- a/dlls/h_cycler.cpp +++ b/dlls/h_cycler.cpp @@ -35,7 +35,7 @@ class CCycler : public CBaseMonster { public: - void GenericCyclerSpawn(char *szModel, Vector vecMin, Vector vecMax); + void GenericCyclerSpawn(const char *szModel, Vector vecMin, Vector vecMax); virtual int ObjectCaps( void ) { return (CBaseEntity :: ObjectCaps() | FCAP_IMPULSE_USE); } int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); void Spawn( void ); @@ -96,7 +96,7 @@ void CCyclerProbe :: Spawn( void ) // Cycler member functions -void CCycler :: GenericCyclerSpawn(char *szModel, Vector vecMin, Vector vecMax) +void CCycler :: GenericCyclerSpawn(const char *szModel, Vector vecMin, Vector vecMax) { if (!szModel || !*szModel) { diff --git a/dlls/player.cpp b/dlls/player.cpp index 07c19cc..57a3820 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -291,8 +291,8 @@ void CPlayerInventory::SpawnInventory( CBasePlayer *pPlayer ) if( index < 0 ) continue; - char *weapon_classname = pList->array[index].weapon_classname; - char *ammo_classname = pList->array[index].ammo_classname; + const char *weapon_classname = pList->array[index].weapon_classname; + const char *ammo_classname = pList->array[index].ammo_classname; int ammo_count = pList->array[index].num_ammospawns; // Spawn ammo for weapon @@ -3690,7 +3690,7 @@ int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) // // Returns the unique ID for the ammo, or -1 if error // -int CBasePlayer :: GiveAmmo( int iCount, char *szName, int iMax ) +int CBasePlayer :: GiveAmmo( int iCount, const char *szName, int iMax ) { if ( !szName ) { diff --git a/dlls/player.h b/dlls/player.h index dd5a257..dc1ff75 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -315,7 +315,7 @@ public: void GiveNamedItem( const char *szName ); void EnableControl(BOOL fControl); - int GiveAmmo( int iAmount, char *szName, int iMax ); + int GiveAmmo( int iAmount, const char *szName, int iMax ); void SendAmmoUpdate(void); void WaterMove( void ); diff --git a/dlls/sound.cpp b/dlls/sound.cpp index fff956a..a62b633 100644 --- a/dlls/sound.cpp +++ b/dlls/sound.cpp @@ -1618,7 +1618,7 @@ float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int const char *pTextureName; float rgfl1[3]; float rgfl2[3]; - char *rgsz[4]; + const char *rgsz[4]; int cnt; float fattn = ATTN_NORM; @@ -1838,7 +1838,7 @@ void CSpeaker :: Precache( void ) } void CSpeaker :: SpeakerThink( void ) { - char* szSoundFile; + const char* szSoundFile; float flvolume = pev->health * 0.1; float flattenuation = 0.3; int flags = 0; @@ -1951,4 +1951,4 @@ void CSpeaker :: KeyValue( KeyValueData *pkvd ) } else CBaseEntity::KeyValue( pkvd ); -} \ No newline at end of file +} diff --git a/dlls/util.cpp b/dlls/util.cpp index 4476923..fee6c42 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -1078,7 +1078,7 @@ float UTIL_SplineFraction( float value, float scale ) } -char* UTIL_VarArgs( char *format, ... ) +char* UTIL_VarArgs( const char *format, ... ) { va_list argptr; static char string[1024]; @@ -1609,7 +1609,7 @@ void UTIL_PrecacheOther( const char *szClassname ) // UTIL_LogPrintf - Prints a logged message to console. // Preceded by LOG: ( timestamp ) < message > //========================================================= -void UTIL_LogPrintf( char *fmt, ... ) +void UTIL_LogPrintf( const char *fmt, ... ) { va_list argptr; static char string[1024]; diff --git a/dlls/util.h b/dlls/util.h index 3db0614..89940ca 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -270,7 +270,7 @@ extern float UTIL_Approach( float target, float value, float speed ); extern float UTIL_ApproachAngle( float target, float value, float speed ); extern float UTIL_AngleDistance( float next, float cur ); -extern char *UTIL_VarArgs( char *format, ... ); +extern char *UTIL_VarArgs(const char *format, ... ); extern void UTIL_Remove( CBaseEntity *pEntity ); extern BOOL UTIL_IsValidEntity( edict_t *pent ); extern BOOL UTIL_TeamsMatch( const char *pTeamName1, const char *pTeamName2 ); @@ -330,7 +330,7 @@ extern char *UTIL_dtos3( int d ); extern char *UTIL_dtos4( int d ); // Writes message to console with timestamp and FragLog header. -extern void UTIL_LogPrintf( char *fmt, ... ); +extern void UTIL_LogPrintf(const char *fmt, ... ); // Sorta like FInViewCone, but for nonmonsters. extern float UTIL_DotPoints ( const Vector &vecSrc, const Vector &vecCheck, const Vector &vecDir ); diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index cae7dee..0da742d 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -894,7 +894,7 @@ BOOL CBasePlayerWeapon :: CanDeploy( void ) return TRUE; } -BOOL CBasePlayerWeapon :: DefaultDeploy( char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal /* = 0 */, int body ) +BOOL CBasePlayerWeapon :: DefaultDeploy( const char *szViewModel, const char *szWeaponModel, int iAnim, const char *szAnimExt, int skiplocal /* = 0 */, int body ) { if (!CanDeploy( )) return FALSE; diff --git a/dlls/weapons.h b/dlls/weapons.h index 23dc309..5179a97 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -217,7 +217,7 @@ public: virtual BOOL CanDeploy( void ); virtual BOOL IsUseable( void ); - BOOL DefaultDeploy( char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal = 0, int body = 0 ); + BOOL DefaultDeploy( const char *szViewModel, const char *szWeaponModel, int iAnim, const char *szAnimExt, int skiplocal = 0, int body = 0 ); virtual BOOL DefaultReload( int iClipSize, int iAnim, float fDelay, int body = 0 ); virtual void ItemPostFrame( void ); // called each frame by the player PostThink diff --git a/dlls/world.cpp b/dlls/world.cpp index ee2c786..197af18 100644 --- a/dlls/world.cpp +++ b/dlls/world.cpp @@ -302,7 +302,7 @@ globalentity_t *CGlobalState :: Find( string_t globalname ) //#ifdef _DEBUG void CGlobalState :: DumpGlobals( void ) { - static char *estates[] = { "Off", "On", "Dead" }; + static const char *estates[] = { "Off", "On", "Dead" }; globalentity_t *pTest; ALERT( at_console, "-- Globals --\n" ); diff --git a/dlls/wpn_shared/tw_explosives.cpp b/dlls/wpn_shared/tw_explosives.cpp index 739deed..e9fa9f3 100644 --- a/dlls/wpn_shared/tw_explosives.cpp +++ b/dlls/wpn_shared/tw_explosives.cpp @@ -40,14 +40,14 @@ class CThrownFrag : public CGrenade public: void Spawn(); - static CThrownFrag *ThrowFrag( unsigned int usEvent, entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time, char *pszExplosiveModel, float flDamage, float flResistance) + static CThrownFrag *ThrowFrag( unsigned int usEvent, entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time, const char *pszExplosiveModel, float flDamage, float flResistance) { return ThrowExplosive( GetClassPtr((CThrownFrag*)NULL), usEvent, pevOwner, vecStart, vecVelocity, time, pszExplosiveModel, flDamage, flResistance ); } - static CThrownFrag *ThrowExplosive(CThrownFrag *PtrFrag, unsigned int usEvent, entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time, char *pszExplosiveModel, float flDamage, float flResistance); + static CThrownFrag *ThrowExplosive(CThrownFrag *PtrFrag, unsigned int usEvent, entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time, const char *pszExplosiveModel, float flDamage, float flResistance); virtual void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType,int PenetrationValue = 0) { @@ -81,7 +81,7 @@ public: pev->classname = MAKE_STRING("pipe_bomb"); } - static CThrownPipeBomb *ThrowPipeBomb( unsigned int usEvent, entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time, char *pszExplosiveModel, float flDamage, float flResistance) + static CThrownPipeBomb *ThrowPipeBomb( unsigned int usEvent, entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time, const char *pszExplosiveModel, float flDamage, float flResistance) { return (CThrownPipeBomb*)ThrowExplosive( GetClassPtr((CThrownPipeBomb*)NULL), usEvent, pevOwner, vecStart, vecVelocity, time, @@ -836,7 +836,7 @@ void CThrownFrag::Spawn() UTIL_SetSize(pev, Vector( 0, 0, 0), Vector(0, 0, 0)); } -CThrownFrag *CThrownFrag::ThrowExplosive(CThrownFrag *PtrFrag, unsigned int usEvent,entvars_t *pevOwner,Vector vecStart,Vector vecVelocity,float time,char *pszExplosiveModel,float flDamage, float flResistance) +CThrownFrag *CThrownFrag::ThrowExplosive(CThrownFrag *PtrFrag, unsigned int usEvent,entvars_t *pevOwner,Vector vecStart,Vector vecVelocity,float time,const char *pszExplosiveModel,float flDamage, float flResistance) { CThrownFrag *pRetExplosive = PtrFrag; diff --git a/dlls/wpn_shared/tw_melee.cpp b/dlls/wpn_shared/tw_melee.cpp index 7318480..3fe602a 100644 --- a/dlls/wpn_shared/tw_melee.cpp +++ b/dlls/wpn_shared/tw_melee.cpp @@ -43,7 +43,7 @@ public: void Spawn(); void Precache(); - static CThrownMelee *ThrowObject(CBasePlayer *pPlayer,Vector vecOrigin,Vector vecVelocity,float flDmg,char *pszModel,char *pszClassname); + static CThrownMelee *ThrowObject(CBasePlayer *pPlayer,Vector vecOrigin,Vector vecVelocity,float flDmg,const char *pszModel,const char *pszClassname); // Thinks void EXPORT ThrownTouch(CBaseEntity *pOther); @@ -51,7 +51,7 @@ public: private: CBasePlayer *m_pPlayer; - char *m_pszGiveClassname; + const char *m_pszGiveClassname; float m_flDieTime; }; LINK_ENTITY_TO_CLASS(thrown_object,CThrownMelee); @@ -1174,7 +1174,7 @@ void CThrownMelee::Precache() PRECACHE_SOUND("weapons/knife_hitbod2.wav"); } -CThrownMelee *CThrownMelee::ThrowObject(CBasePlayer *pPlayer,Vector vecOrigin,Vector vecVelocity,float flDmg,char *pszModel,char *pszGiveClass) +CThrownMelee *CThrownMelee::ThrowObject(CBasePlayer *pPlayer,Vector vecOrigin,Vector vecVelocity,float flDmg,const char *pszModel,const char *pszGiveClass) { CThrownMelee *pRetObject = GetClassPtr((CThrownMelee*)NULL);