From e099224bc5948dd604632f1602017b99cb29cc90 Mon Sep 17 00:00:00 2001 From: mittorn Date: Wed, 29 Mar 2017 19:59:50 +0000 Subject: [PATCH 001/144] Use vgui2 functions for utf-8 print --- cl_dll/MOTD.cpp | 2 +- cl_dll/cl_util.h | 2 ++ cl_dll/hud_redraw.cpp | 29 +++++++++++++++++++++++++++++ cl_dll/scoreboard.cpp | 24 ++++++++++++------------ 4 files changed, 44 insertions(+), 13 deletions(-) diff --git a/cl_dll/MOTD.cpp b/cl_dll/MOTD.cpp index 6ab3a161..179ae4a8 100644 --- a/cl_dll/MOTD.cpp +++ b/cl_dll/MOTD.cpp @@ -103,7 +103,7 @@ int CHudMOTD::Draw( float fTime ) // find where to start drawing the line if( ( ypos > ROW_RANGE_MIN ) && ( ypos + LINE_HEIGHT <= ypos_r + height ) ) - gHUD.DrawHudString( xpos, ypos, xmax, ch, 255, 180, 0 ); + DrawUtfString( xpos, ypos, xmax, ch, 255, 180, 0 ); ypos += LINE_HEIGHT; diff --git a/cl_dll/cl_util.h b/cl_dll/cl_util.h index 84488050..54dcede0 100644 --- a/cl_dll/cl_util.h +++ b/cl_dll/cl_util.h @@ -115,6 +115,8 @@ inline void GetConsoleStringSize( const char *string, int *width, int *height ) gEngfuncs.pfnDrawConsoleStringLen( (char*)string, width, height ); } +int DrawUtfString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b ); + inline int ConsoleStringLen( const char *string ) { int _width = 0, _height = 0; diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index aed98455..b5314961 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -226,6 +226,35 @@ int CHud::DrawHudString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g return xpos; } + + +int DrawUtfString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b ) +{ + // xash3d: reset unicode state + gEngfuncs.pfnVGUI2DrawCharacterAdditive( 0, 0, 0, 0, 0, 0, 0 ); + + // draw the string until we hit the null character or a newline character + for( ; *szIt != 0 && *szIt != '\n'; szIt++ ) + { + int w = gHUD.m_scrinfo.charWidths['M']; + if( xpos + w > iMaxX ) + return xpos; + if( ( *szIt == '^' ) && ( *( szIt + 1 ) >= '0') && ( *( szIt + 1 ) <= '7') ) + { + szIt++; + r = colors[*szIt - '0'][0]; + g = colors[*szIt - '0'][1]; + b = colors[*szIt - '0'][2]; + if( !*(++szIt) ) + return xpos; + } + int c = (unsigned int)(unsigned char)*szIt; + xpos += gEngfuncs.pfnVGUI2DrawCharacterAdditive( xpos, ypos, c, r, g, b, 0 ); + } + + return xpos; +} + int CHud::DrawHudStringLen( char *szIt ) { int l = 0; diff --git a/cl_dll/scoreboard.cpp b/cl_dll/scoreboard.cpp index 2e0722f9..3a780baf 100644 --- a/cl_dll/scoreboard.cpp +++ b/cl_dll/scoreboard.cpp @@ -146,18 +146,18 @@ int CHudScoreboard::Draw( float fTime ) FAR_RIGHT += 5; gHUD.DrawDarkRectangle( xpos - 5, ypos - 5, FAR_RIGHT, ROW_RANGE_MAX ); if( !gHUD.m_Teamplay ) - gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Player", 255, 140, 0 ); + DrawUtfString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Player", 255, 140, 0 ); else - gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Teams", 255, 140, 0 ); + DrawUtfString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Teams", 255, 140, 0 ); gHUD.DrawHudStringReverse( KILLS_RANGE_MAX + xpos_rel, ypos, 0, "kills", 255, 140, 0 ); - gHUD.DrawHudString( DIVIDER_POS + xpos_rel, ypos, ScreenWidth, "/", 255, 140, 0 ); - gHUD.DrawHudString( DEATHS_RANGE_MIN + xpos_rel + 5, ypos, ScreenWidth, "deaths", 255, 140, 0 ); - gHUD.DrawHudString( PING_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "latency", 255, 140, 0 ); + DrawUtfString( DIVIDER_POS + xpos_rel, ypos, ScreenWidth, "/", 255, 140, 0 ); + DrawUtfString( DEATHS_RANGE_MIN + xpos_rel + 5, ypos, ScreenWidth, "deaths", 255, 140, 0 ); + DrawUtfString( PING_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "latency", 255, 140, 0 ); if( can_show_packetloss ) { - gHUD.DrawHudString( PL_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "pkt loss", 255, 140, 0 ); + DrawUtfString( PL_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "pkt loss", 255, 140, 0 ); } list_slot += 1.2; @@ -272,7 +272,7 @@ int CHudScoreboard::Draw( float fTime ) } // draw their name (left to right) - gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, team_info->name, r, g, b ); + DrawUtfString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, team_info->name, r, g, b ); // draw kills (right to left) xpos = KILLS_RANGE_MAX + xpos_rel; @@ -280,7 +280,7 @@ int CHudScoreboard::Draw( float fTime ) // draw divider xpos = DIVIDER_POS + xpos_rel; - gHUD.DrawHudString( xpos, ypos, xpos + 20, "/", r, g, b ); + DrawUtfString( xpos, ypos, xpos + 20, "/", r, g, b ); // draw deaths xpos = DEATHS_RANGE_MAX + xpos_rel; @@ -300,7 +300,7 @@ int CHudScoreboard::Draw( float fTime ) xpos = ( ( PL_RANGE_MAX - PL_RANGE_MIN ) / 2) + PL_RANGE_MIN + xpos_rel + 25; sprintf( buf, " %d", team_info->packetloss ); - gHUD.DrawHudString( xpos, ypos, xpos+50, buf, r, g, b ); + DrawUtfString( xpos, ypos, xpos+50, buf, r, g, b ); } team_info->already_drawn = TRUE; // set the already_drawn to be TRUE, so this team won't get drawn again @@ -400,7 +400,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, } // draw their name (left to right) - gHUD.DrawHudString( xpos + nameoffset, ypos, NAME_RANGE_MAX + xpos_rel, pl_info->name, r, g, b ); + DrawUtfString( xpos + nameoffset, ypos, NAME_RANGE_MAX + xpos_rel, pl_info->name, r, g, b ); // draw kills (right to left) xpos = KILLS_RANGE_MAX + xpos_rel; @@ -408,7 +408,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, // draw divider xpos = DIVIDER_POS + xpos_rel; - gHUD.DrawHudString( xpos, ypos, xpos + 20, "/", r, g, b ); + DrawUtfString( xpos, ypos, xpos + 20, "/", r, g, b ); // draw deaths xpos = DEATHS_RANGE_MAX + xpos_rel; @@ -435,7 +435,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, xpos = ( ( PL_RANGE_MAX - PL_RANGE_MIN ) / 2 ) + PL_RANGE_MIN + xpos_rel + 25; - gHUD.DrawHudString( xpos, ypos, xpos+50, buf, r, g, b ); + DrawUtfString( xpos, ypos, xpos+50, buf, r, g, b ); } pl_info->name = NULL; // set the name to be NULL, so this client won't get drawn again From 409848b80fd02893f6eb34cd97e18cd93c2ada04 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 3 Apr 2017 21:16:25 +0500 Subject: [PATCH 002/144] Do not break menuselect behavior. --- dlls/client.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/client.cpp b/dlls/client.cpp index 21e5d810..5fb7c221 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -466,10 +466,10 @@ void ClientCommand( edict_t *pEntity ) edict_t *pentSpawnSpot = g_pGameRules->GetPlayerSpawnSpot( pPlayer ); pPlayer->StartObserver( pev->origin, VARS( pentSpawnSpot )->angles ); } - /*else if( g_pGameRules->ClientCommand( GetClassPtr( (CBasePlayer *)pev ), pcmd ) ) + else if( g_pGameRules->ClientCommand( GetClassPtr( (CBasePlayer *)pev ), pcmd ) ) { // MenuSelect returns true only if the command is properly handled, so don't print a warning - }*/ + } else if( FStrEq( pcmd, "VModEnable" ) ) { // clear 'Unknown command: VModEnable' in singleplayer From 4fbb070e7d59c8dc660f5895ba8470fe869cd49a Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 4 Apr 2017 01:15:16 +0500 Subject: [PATCH 003/144] Implement cl_scoreboard_bg cvar. --- cl_dll/scoreboard.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cl_dll/scoreboard.cpp b/cl_dll/scoreboard.cpp index 3a780baf..507e0415 100644 --- a/cl_dll/scoreboard.cpp +++ b/cl_dll/scoreboard.cpp @@ -26,6 +26,7 @@ #include #include +cvar_t *cl_scoreboard_bg; cvar_t *cl_showpacketloss; hud_player_info_t g_PlayerInfoList[MAX_PLAYERS + 1]; // player info from the engine extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS + 1]; // additional player info sent directly to the client dll @@ -59,6 +60,7 @@ int CHudScoreboard::Init( void ) InitHUDData(); + cl_scoreboard_bg = CVAR_CREATE( "cl_scoreboard_bg", "1", 0 ); cl_showpacketloss = CVAR_CREATE( "cl_showpacketloss", "0", FCVAR_ARCHIVE ); return 1; @@ -144,7 +146,8 @@ int CHudScoreboard::Draw( float fTime ) FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX; FAR_RIGHT += 5; - gHUD.DrawDarkRectangle( xpos - 5, ypos - 5, FAR_RIGHT, ROW_RANGE_MAX ); + if( cl_scoreboard_bg && cl_scoreboard_bg->value ) + gHUD.DrawDarkRectangle( xpos - 5, ypos - 5, FAR_RIGHT, ROW_RANGE_MAX ); if( !gHUD.m_Teamplay ) DrawUtfString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Player", 255, 140, 0 ); else From 6f8d64df898ba58f1d5c3cd6f81951f38d6f74dd Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 4 Apr 2017 01:43:21 +0500 Subject: [PATCH 004/144] Make cl_scoreboard_bg cvar archive. --- cl_dll/scoreboard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cl_dll/scoreboard.cpp b/cl_dll/scoreboard.cpp index 507e0415..b20e316c 100644 --- a/cl_dll/scoreboard.cpp +++ b/cl_dll/scoreboard.cpp @@ -60,7 +60,7 @@ int CHudScoreboard::Init( void ) InitHUDData(); - cl_scoreboard_bg = CVAR_CREATE( "cl_scoreboard_bg", "1", 0 ); + cl_scoreboard_bg = CVAR_CREATE( "cl_scoreboard_bg", "1", FCVAR_ARCHIVE ); cl_showpacketloss = CVAR_CREATE( "cl_showpacketloss", "0", FCVAR_ARCHIVE ); return 1; From 8163bced2c29e22629b3c3c3541d131fed00bfdf Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 12 Apr 2017 02:02:18 +0500 Subject: [PATCH 005/144] Do not break hud_takesshots cvar behavior. --- cl_dll/hud_redraw.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index b5314961..c30df36d 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -93,6 +93,13 @@ int CHud::Redraw( float flTime, int intermission ) if( m_flTimeDelta < 0 ) m_flTimeDelta = 0; + if( !m_iIntermission && intermission ) + { + // Take a screenshot if the client's got the cvar set + if( CVAR_GET_FLOAT( "hud_takesshots" ) != 0 ) + m_flShotTime = flTime + 1.0; // Take a screenshot in a second + } + if( m_flShotTime && m_flShotTime < flTime ) { gEngfuncs.pfnClientCmd( "snapshot\n" ); From fc276ad52f51ec128352ac680ef9cbac038e6b23 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Fri, 16 Jun 2017 19:18:24 +0500 Subject: [PATCH 006/144] Do not use -frtti flag. --- dlls/Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/Android.mk b/dlls/Android.mk index 7f107a12..7fcdf581 100644 --- a/dlls/Android.mk +++ b/dlls/Android.mk @@ -16,7 +16,7 @@ endif LOCAL_CFLAGS += -D_LINUX -DCLIENT_WEAPONS -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf \ -fno-exceptions -DNO_VOICEGAMEMGR -w -LOCAL_CPPFLAGS := $(LOCAL_CFLAGS) -frtti +LOCAL_CPPFLAGS := $(LOCAL_CFLAGS) LOCAL_C_INCLUDES := $(SDL_PATH)/include \ $(LOCAL_PATH)/. \ From a522ae20c3dcb7b48381205254021796db914d14 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 26 Jun 2017 05:47:19 +0500 Subject: [PATCH 007/144] Merge some changes from git version of hlsdk. --- common/const.h | 11 +- common/cvardef.h | 3 +- dlls/buttons.cpp | 6 +- dlls/cbase.h | 4 +- dlls/client.cpp | 238 ++++++++++++++++++++++++++++------- dlls/crossbow.cpp | 4 +- dlls/crowbar.cpp | 9 +- dlls/doors.cpp | 9 +- dlls/extdll.h | 2 +- dlls/game.cpp | 2 + dlls/gauss.cpp | 4 +- dlls/handgrenade.cpp | 4 +- dlls/mp5.cpp | 4 +- dlls/multiplay_gamerules.cpp | 4 +- dlls/nihilanth.cpp | 18 ++- dlls/player.cpp | 115 +++++++++++++++-- dlls/player.h | 12 ++ dlls/rpg.cpp | 4 +- dlls/satchel.cpp | 6 +- dlls/saverestore.h | 2 +- dlls/shotgun.cpp | 10 +- dlls/squeakgrenade.cpp | 2 +- dlls/subs.cpp | 8 ++ dlls/triggers.cpp | 2 +- dlls/tripmine.cpp | 2 +- dlls/util.cpp | 4 +- dlls/util.h | 2 +- dlls/weapons.cpp | 36 ++++++ dlls/weapons.h | 5 + dlls/zombie.cpp | 6 +- engine/eiface.h | 17 +-- engine/shake.h | 4 +- engine/studio.h | 10 +- pm_shared/pm_defs.h | 2 +- pm_shared/pm_materials.h | 1 + pm_shared/pm_shared.c | 24 ++-- 36 files changed, 473 insertions(+), 123 deletions(-) diff --git a/common/const.h b/common/const.h index b885e44e..d29816e6 100644 --- a/common/const.h +++ b/common/const.h @@ -110,7 +110,9 @@ #define EF_NOINTERP 32 // don't interpolate the next frame #define EF_LIGHT 64 // rocket flare glow sprite #define EF_NODRAW 128 // don't draw entity - +#define EF_NIGHTVISION 256 // player nightvision +#define EF_SNIPERLASER 512 // sniper laser effect +#define EF_FIBERCAMERA 1024 // fiber camera #define EF_NOREFLECT (1<<24) // Entity won't reflecting in mirrors @@ -531,6 +533,7 @@ #define TEFIRE_FLAG_LOOP 4 // if set, sprite plays at 15 fps, otherwise plays at whatever rate stretches the animation over the sprite's duration. #define TEFIRE_FLAG_ALPHA 8 // if set, sprite is rendered alpha blended at 50% else, opaque #define TEFIRE_FLAG_PLANAR 16 // if set, all fire sprites have same initial Z instead of randomly filling a cube. +#define TEFIRE_FLAG_ADDITIVE 32 // if set, sprite is rendered non-opaque with additive #define TE_PLAYERATTACHMENT 124 // attaches a TENT to a player (this is a high-priority tent) // byte (entity index of player) @@ -621,8 +624,9 @@ #define CHAN_BODY 4 #define CHAN_STREAM 5 // allocate stream channel from the static or dynamic area #define CHAN_STATIC 6 // allocate channel from the static area -#define CHAN_NETWORKVOICE_BASE 7 // voice data coming across the network +#define CHAN_NETWORKVOICE_BASE 7 // voice data coming across the network #define CHAN_NETWORKVOICE_END 500 // network voice data reserves slots (CHAN_NETWORKVOICE_BASE through CHAN_NETWORKVOICE_END). +#define CHAN_BOT 501 // channel used for bot chatter. // attenuation values #define ATTN_NONE 0 @@ -724,7 +728,8 @@ enum kRenderFxDeadPlayer, // kRenderAmt is the player index kRenderFxExplode, // Scale up really big! kRenderFxGlowShell, // Glowing Shell - kRenderFxClampMinScale // Keep this sprite from getting very small (SPRITES only!) + kRenderFxClampMinScale, // Keep this sprite from getting very small (SPRITES only!) + kRenderFxLightMultiplier //CTM !!!CZERO added to tell the studiorender that the value in iuser2 is a lightmultiplier }; typedef unsigned int func_t; diff --git a/common/cvardef.h b/common/cvardef.h index f822cc7a..c57b97a7 100644 --- a/common/cvardef.h +++ b/common/cvardef.h @@ -24,6 +24,7 @@ #define FCVAR_SPONLY (1<<6) // This cvar cannot be changed by clients connected to a multiplayer server. #define FCVAR_PRINTABLEONLY (1<<7) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ). #define FCVAR_UNLOGGED (1<<8) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log +#define FCVAR_NOEXTRAWHITEPACE (1<<9) // strip trailing/leading white space from this cvar typedef struct cvar_s { @@ -34,4 +35,4 @@ typedef struct cvar_s struct cvar_s *next; } cvar_t; -#endif//CVARDEF_H \ No newline at end of file +#endif//CVARDEF_H diff --git a/dlls/buttons.cpp b/dlls/buttons.cpp index 7b050add..3027f10e 100644 --- a/dlls/buttons.cpp +++ b/dlls/buttons.cpp @@ -1045,7 +1045,11 @@ void CMomentaryRotButton::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, US pev->ideal_yaw = CBaseToggle::AxisDelta( pev->spawnflags, pev->angles, m_start ) / m_flMoveDistance; UpdateAllButtons( pev->ideal_yaw, 1 ); - UpdateTarget( pev->ideal_yaw ); + + // Calculate destination angle and use it to predict value, this prevents sending target in wrong direction on retriggering + Vector dest = pev->angles + pev->avelocity * ( pev->nextthink - pev->ltime ); + float value1 = CBaseToggle::AxisDelta( pev->spawnflags, dest, m_start ) / m_flMoveDistance; + UpdateTarget( value1 ); } void CMomentaryRotButton::UpdateAllButtons( float value, int start ) diff --git a/dlls/cbase.h b/dlls/cbase.h index 47ce7595..617bbab9 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -280,8 +280,8 @@ public: #ifdef _DEBUG void FunctionCheck( void *pFunction, char *name ) { - if( pFunction && !NAME_FOR_FUNCTION( (unsigned long)( pFunction ) ) ) - ALERT( at_error, "No EXPORT: %s:%s (%08lx)\n", STRING( pev->classname ), name, (unsigned long)pFunction ); + if( pFunction && !NAME_FOR_FUNCTION( (size_t)( pFunction ) ) ) + ALERT( at_error, "No EXPORT: %s:%s (%08lx)\n", STRING( pev->classname ), name, (size_t)pFunction ); } BASEPTR ThinkSet( BASEPTR func, char *name ) diff --git a/dlls/client.cpp b/dlls/client.cpp index 5fb7c221..74be0ea3 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -48,6 +48,8 @@ extern void CopyToBodyQue( entvars_t* pev ); extern int giPrecacheGrunt; extern int gmsgSayText; +extern cvar_t allow_spectators; + extern int g_teamplay; void LinkUserMessages( void ); @@ -204,6 +206,97 @@ void ClientPutInServer( edict_t *pEntity ) #include "voice_gamemgr.h" extern CVoiceGameMgr g_VoiceGameMgr; #endif + +//----------------------------------------------------------------------------- +// Purpose: determine if a uchar32 represents a valid Unicode code point +//----------------------------------------------------------------------------- +bool Q_IsValidUChar32( unsigned int uVal ) +{ + // Values > 0x10FFFF are explicitly invalid; ditto for UTF-16 surrogate halves, + // values ending in FFFE or FFFF, or values in the 0x00FDD0-0x00FDEF reserved range + return ( uVal < 0x110000u ) && ( ( uVal - 0x00D800u ) > 0x7FFu ) && ( ( uVal & 0xFFFFu ) < 0xFFFEu ) && ( ( uVal - 0x00FDD0u ) > 0x1Fu ); +} + +// Decode one character from a UTF-8 encoded string. Treats 6-byte CESU-8 sequences +// as a single character, as if they were a correctly-encoded 4-byte UTF-8 sequence. +int Q_UTF8ToUChar32( const char *pUTF8_, unsigned int &uValueOut, bool &bErrorOut ) +{ + const unsigned char *pUTF8 = (const unsigned char*)pUTF8_; + + int nBytes = 1; + unsigned int uValue = pUTF8[0]; + unsigned int uMinValue = 0; + + // 0....... single byte + if( uValue < 0x80 ) + goto decodeFinishedNoCheck; + + // Expecting at least a two-byte sequence with 0xC0 <= first <= 0xF7 (110...... and 11110...) + if( ( uValue - 0xC0u ) > 0x37u || ( pUTF8[1] & 0xC0 ) != 0x80 ) + goto decodeError; + + uValue = ( uValue << 6 ) - ( 0xC0 << 6 ) + pUTF8[1] - 0x80; + nBytes = 2; + uMinValue = 0x80; + + // 110..... two-byte lead byte + if( !( uValue & ( 0x20 << 6 ) ) ) + goto decodeFinished; + + // Expecting at least a three-byte sequence + if( ( pUTF8[2] & 0xC0 ) != 0x80 ) + goto decodeError; + + uValue = ( uValue << 6 ) - ( 0x20 << 12 ) + pUTF8[2] - 0x80; + nBytes = 3; + uMinValue = 0x800; + + // 1110.... three-byte lead byte +decodeFinished: + if( uValue >= uMinValue && Q_IsValidUChar32( uValue ) ) + { +decodeFinishedNoCheck: + uValueOut = uValue; + bErrorOut = false; + return nBytes; + } +decodeError: + uValueOut = '?'; + bErrorOut = true; + return nBytes; + +decodeFinishedMaybeCESU8: + // Do we have a full UTF-16 surrogate pair that's been UTF-8 encoded afterwards? + // That is, do we have 0xD800-0xDBFF followed by 0xDC00-0xDFFF? If so, decode it all. + if( ( uValue - 0xD800u ) < 0x400u && pUTF8[3] == 0xED && (unsigned char)( pUTF8[4] - 0xB0 ) < 0x10 && ( pUTF8[5] & 0xC0 ) == 0x80 ) + { + uValue = 0x10000 + ( ( uValue - 0xD800u ) << 10 ) + ( (unsigned char)( pUTF8[4] - 0xB0 ) << 6 ) + pUTF8[5] - 0x80; + nBytes = 6; + uMinValue = 0x10000; + } + goto decodeFinished; +} + +//----------------------------------------------------------------------------- +// Purpose: Returns true if UTF-8 string contains invalid sequences. +//----------------------------------------------------------------------------- +bool Q_UnicodeValidate( const char *pUTF8 ) +{ + bool bError = false; + while( *pUTF8 ) + { + unsigned int uVal; + // Our UTF-8 decoder silently fixes up 6-byte CESU-8 (improperly re-encoded UTF-16) sequences. + // However, these are technically not valid UTF-8. So if we eat 6 bytes at once, it's an error. + int nCharSize = Q_UTF8ToUChar32( pUTF8, uVal, bError ); + if( bError || nCharSize == 6 ) + return false; + pUTF8 += nCharSize; + } + return true; +} + + //// HOST_SAY // String comes in as // say blah blah blah @@ -265,20 +358,13 @@ void Host_Say( edict_t *pEntity, int teamonly ) p[strlen( p ) - 1] = 0; } - // make sure the text has content - for( pc = p; pc != NULL && *pc != 0; pc++ ) - { - if( !isspace( *pc ) ) - { - pc = NULL; // we've found an alphanumeric character, so text is valid - break; - } - } - if( pc != NULL ) + if( !p || !p[0] || !Q_UnicodeValidate ( p ) ) return; // no character found, so say nothing // turn on color set 2 (color on, no sound) - if( teamonly ) + if( player->IsObserver() && ( teamonly ) ) + sprintf( text, "%c(SPEC) %s: ", 2, STRING( pEntity->v.netname ) ); + else if( teamonly ) sprintf( text, "%c(TEAM) %s: ", 2, STRING( pEntity->v.netname ) ); else sprintf( text, "%c%s: ", 2, STRING( pEntity->v.netname ) ); @@ -313,9 +399,14 @@ void Host_Say( edict_t *pEntity, int teamonly ) if( g_VoiceGameMgr.PlayerHasBlockedPlayer( client, player ) ) continue; #endif - if( teamonly && g_pGameRules->PlayerRelationship( client, CBaseEntity::Instance( pEntity ) ) != GR_TEAMMATE ) + if( !player->IsObserver() && teamonly && g_pGameRules->PlayerRelationship( client, CBaseEntity::Instance( pEntity ) ) != GR_TEAMMATE ) continue; + // Spectators can only talk to other specs + if( player->IsObserver() && teamonly ) + if ( !client->IsObserver() ) + continue; + MESSAGE_BEGIN( MSG_ONE, gmsgSayText, NULL, client->pev ); WRITE_BYTE( ENTINDEX( pEntity ) ); WRITE_STRING( text ); @@ -459,12 +550,40 @@ void ClientCommand( edict_t *pEntity ) { GetClassPtr( (CBasePlayer *)pev )->SelectLastItem(); } - else if( FStrEq( pcmd, "spectate" ) && ( pev->flags & FL_PROXY ) ) // added for proxy support + else if( FStrEq( pcmd, "spectate" ) // clients wants to become a spectator { - CBasePlayer * pPlayer = GetClassPtr( (CBasePlayer *)pev ); + // always allow proxies to become a spectator + if( ( pev->flags & FL_PROXY ) || allow_spectators.value ) + { + CBasePlayer *pPlayer = GetClassPtr( (CBasePlayer *)pev ); + + edict_t *pentSpawnSpot = g_pGameRules->GetPlayerSpawnSpot( pPlayer ); + pPlayer->StartObserver( pev->origin, VARS( pentSpawnSpot )->angles ); + + // notify other clients of player switching to spectator mode + UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s switched to spectator mode\n", + ( pev->netname && STRING(pev->netname)[0] != 0 ) ? STRING(pev->netname) : "unconnected" ) ); + } + else + ClientPrint( pev, HUD_PRINTCONSOLE, "Spectator mode is disabled.\n" ); + } + else if( FStrEq( pcmd, "specmode" ) ) // new spectator mode + { + CBasePlayer *pPlayer = GetClassPtr( (CBasePlayer *)pev ); - edict_t *pentSpawnSpot = g_pGameRules->GetPlayerSpawnSpot( pPlayer ); - pPlayer->StartObserver( pev->origin, VARS( pentSpawnSpot )->angles ); + if( pPlayer->IsObserver() ) + pPlayer->Observer_SetMode( atoi( CMD_ARGV( 1 ) ) ); + } + else if( FStrEq( pcmd, "closemenus" ) ) + { + // just ignore it + } + else if( FStrEq( pcmd, "follownext" ) ) // follow next player + { + CBasePlayer *pPlayer = GetClassPtr( (CBasePlayer *)pev ); + + if( pPlayer->IsObserver() ) + pPlayer->Observer_FindNextPlayer( atoi( CMD_ARGV( 1 ) ) ? true : false ); } else if( g_pGameRules->ClientCommand( GetClassPtr( (CBasePlayer *)pev ), pcmd ) ) { @@ -524,12 +643,15 @@ void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ) // Set the name g_engfuncs.pfnSetClientKeyValue( ENTINDEX( pEntity ), infobuffer, "name", sName ); - char text[256]; - 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 ); - MESSAGE_END(); + if( gpGlobals->maxClients > 1 ) + { + char text[256]; + 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 ); + MESSAGE_END(); + } // team match? if( g_teamplay ) @@ -983,7 +1105,7 @@ int AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *h int i; // don't send if flagged for NODRAW and it's not the host getting the message - if( ( ent->v.effects == EF_NODRAW ) && ( ent != host ) ) + if( ( ent->v.effects & EF_NODRAW ) && ( ent != host ) ) return 0; // Ignore ents without valid / visible models @@ -1553,41 +1675,67 @@ engine sets cd to 0 before calling. */ void UpdateClientData( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ) { - cd->flags = ent->v.flags; - cd->health = ent->v.health; + if( !ent || !ent->pvPrivateData ) + return; + entvars_t *pev = (entvars_t *)&ent->v; + CBasePlayer *pl = (CBasePlayer *)( CBasePlayer::Instance( pev ) ); + entvars_t *pevOrg = NULL; + + // if user is spectating different player in First person, override some vars + if( pl && pl->pev->iuser1 == OBS_IN_EYE ) + { + if( pl->m_hObserverTarget ) + { + pevOrg = pev; + pev = pl->m_hObserverTarget->pev; + pl = (CBasePlayer *)(CBasePlayer::Instance( pev ) ); + } + } - cd->viewmodel = MODEL_INDEX( STRING( ent->v.viewmodel ) ); + cd->flags = pev->flags; + cd->health = pev->health; - cd->waterlevel = ent->v.waterlevel; - cd->watertype = ent->v.watertype; - cd->weapons = ent->v.weapons; + cd->viewmodel = MODEL_INDEX( STRING( pev->viewmodel ) ); + + cd->waterlevel = pev->waterlevel; + cd->watertype = pev->watertype; + cd->weapons = pev->weapons; // Vectors - cd->origin = ent->v.origin; - cd->velocity = ent->v.velocity; - cd->view_ofs = ent->v.view_ofs; - cd->punchangle = ent->v.punchangle; + cd->origin = pev->origin; + cd->velocity = pev->velocity; + cd->view_ofs = pev->view_ofs; + cd->punchangle = pev->punchangle; - cd->bInDuck = ent->v.bInDuck; - cd->flTimeStepSound = ent->v.flTimeStepSound; - cd->flDuckTime = ent->v.flDuckTime; - cd->flSwimTime = ent->v.flSwimTime; - cd->waterjumptime = ent->v.teleport_time; + cd->bInDuck = pev->bInDuck; + cd->flTimeStepSound = pev->flTimeStepSound; + cd->flDuckTime = pev->flDuckTime; + cd->flSwimTime = pev->flSwimTime; + cd->waterjumptime = pev->teleport_time; strcpy( cd->physinfo, ENGINE_GETPHYSINFO( ent ) ); - cd->maxspeed = ent->v.maxspeed; - cd->fov = ent->v.fov; - cd->weaponanim = ent->v.weaponanim; + cd->maxspeed = pev->maxspeed; + cd->fov = pev->fov; + cd->weaponanim = pev->weaponanim; - cd->pushmsec = ent->v.pushmsec; + cd->pushmsec = pev->pushmsec; + // Spectator mode + if( pevOrg != NULL ) + { + // don't use spec vars from chased player + cd->iuser1 = pevOrg->iuser1; + cd->iuser2 = pevOrg->iuser2; + } + else + { + cd->iuser1 = pev->iuser1; + cd->iuser2 = pev->iuser2; + } #if defined( CLIENT_WEAPONS ) if( sendweapons ) { - entvars_t *pev = (entvars_t *)&ent->v; - CBasePlayer *pl = (CBasePlayer *)CBasePlayer::Instance( pev ); - if( pl ) { cd->m_flNextAttack = pl->m_flNextAttack; diff --git a/dlls/crossbow.cpp b/dlls/crossbow.cpp index 45fd922c..7a4686e7 100644 --- a/dlls/crossbow.cpp +++ b/dlls/crossbow.cpp @@ -353,7 +353,7 @@ void CCrossbow::PrimaryAttack( void ) // this function only gets called in multiplayer void CCrossbow::FireSniperBolt() { - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.75; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.75 ); if( m_iClip == 0 ) { @@ -451,7 +451,7 @@ void CCrossbow::FireBolt() // HEV suit - indicate out of ammo condition m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.75; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.75 ); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.75; diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index 94f0066b..80a18d65 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -27,7 +27,7 @@ LINK_ENTITY_TO_CLASS( weapon_crowbar, CCrowbar ) -enum gauss_e +enum crowbar_e { CROWBAR_IDLE = 0, CROWBAR_DRAW, @@ -40,8 +40,7 @@ enum gauss_e CROWBAR_ATTACK3HIT }; - -void CCrowbar::Spawn( ) +void CCrowbar::Spawn() { Precache(); m_iId = WEAPON_CROWBAR; @@ -191,7 +190,7 @@ int CCrowbar::Swing( int fFirst ) if( fFirst ) { // miss - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); @@ -297,7 +296,7 @@ int CCrowbar::Swing( int fFirst ) m_pPlayer->m_iWeaponVolume = flVol * CROWBAR_WALLHIT_VOLUME; #endif - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.25; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.25 ); SetThink( &CCrowbar::Smack ); pev->nextthink = UTIL_WeaponTimeBase() + 0.2; diff --git a/dlls/doors.cpp b/dlls/doors.cpp index bf7205ee..bdc82f06 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -1100,19 +1100,22 @@ void CMomentaryDoor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP Vector move = m_vecPosition1 + ( value * ( m_vecPosition2 - m_vecPosition1 ) ); Vector delta = move - pev->origin; - float speed = delta.Length() * 10; + //float speed = delta.Length() * 10; + float speed = delta.Length() / 0.1; // move there in 0.1 sec if( speed != 0 ) { // This entity only thinks when it moves, so if it's thinking, it's in the process of moving - // play the sound when it starts moving + // play the sound when it starts moving(not yet thinking) if( pev->nextthink < pev->ltime || pev->nextthink == 0 ) EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ), 1, ATTN_NORM ); + // If we already moving to designated point, return + else if( move == m_vecFinalDest ) + return; LinearMove( move, speed ); SetMoveDone( &CMomentaryDoor::MomentaryMoveDone ); } - } void CMomentaryDoor::MomentaryMoveDone( void ) diff --git a/dlls/extdll.h b/dlls/extdll.h index cbc7ebb9..58349e32 100644 --- a/dlls/extdll.h +++ b/dlls/extdll.h @@ -44,7 +44,7 @@ #else // _WIN32 #define FALSE 0 #define TRUE (!FALSE) -typedef unsigned long ULONG; +typedef unsigned int ULONG; typedef unsigned char BYTE; typedef int BOOL; #define MAX_PATH PATH_MAX diff --git a/dlls/game.cpp b/dlls/game.cpp index 3aec1810..fb247903 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -39,6 +39,8 @@ cvar_t teamoverride = { "mp_teamoverride","1" }; cvar_t defaultteam = { "mp_defaultteam","0" }; cvar_t allowmonsters = { "mp_allowmonsters","0", FCVAR_SERVER }; +cvar_t allow_spectators = { "allow_spectators", "0", FCVAR_SERVER }; // 0 prevents players from being spectators + cvar_t mp_chattime = { "mp_chattime","10", FCVAR_SERVER }; // Engine Cvars diff --git a/dlls/gauss.cpp b/dlls/gauss.cpp index 14aac39b..10149202 100644 --- a/dlls/gauss.cpp +++ b/dlls/gauss.cpp @@ -145,7 +145,7 @@ void CGauss::PrimaryAttack() if( m_pPlayer->pev->waterlevel == 3 ) { PlayEmptySound(); - m_flNextSecondaryAttack = m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15; + m_flNextSecondaryAttack = m_flNextPrimaryAttack = GetNextAttackDelay( 0.15 ); return; } @@ -183,7 +183,7 @@ void CGauss::SecondaryAttack() PlayEmptySound(); } - m_flNextSecondaryAttack = m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flNextSecondaryAttack = m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); return; } diff --git a/dlls/handgrenade.cpp b/dlls/handgrenade.cpp index 063b2886..96119b6b 100644 --- a/dlls/handgrenade.cpp +++ b/dlls/handgrenade.cpp @@ -170,7 +170,7 @@ void CHandGrenade::WeaponIdle( void ) m_flReleaseThrow = 0; m_flStartThrow = 0; - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; @@ -180,7 +180,7 @@ void CHandGrenade::WeaponIdle( void ) // just threw last grenade // set attack times in the future, and weapon idle in the future so we can see the whole throw // animation, weapon idle will automatically retire the weapon for us. - m_flTimeWeaponIdle = m_flNextSecondaryAttack = m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5;// ensure that the animation can finish playing + m_flTimeWeaponIdle = m_flNextSecondaryAttack = m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 );// ensure that the animation can finish playing } return; } diff --git a/dlls/mp5.cpp b/dlls/mp5.cpp index 7d05d5e1..7131f888 100644 --- a/dlls/mp5.cpp +++ b/dlls/mp5.cpp @@ -177,7 +177,7 @@ void CMP5::PrimaryAttack() // HEV suit - indicate out of ammo condition m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.1 ); if( m_flNextPrimaryAttack < UTIL_WeaponTimeBase() ) m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1; @@ -227,7 +227,7 @@ void CMP5::SecondaryAttack( void ) #endif PLAYBACK_EVENT( flags, m_pPlayer->edict(), m_usMP52 ); - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1; + m_flNextPrimaryAttack = GetNextAttackDelay( 1 ); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5;// idle pretty soon after shooting. diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index 929c2bf6..ebef51de 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -92,7 +92,7 @@ CHalfLifeMultiplay::CHalfLifeMultiplay() if( IS_DEDICATED_SERVER() ) { // dedicated server - char *servercfgfile = (char *)CVAR_GET_STRING( "servercfgfile" ); + /*char *servercfgfile = (char *)CVAR_GET_STRING( "servercfgfile" ); if( servercfgfile && servercfgfile[0] ) { @@ -102,6 +102,8 @@ CHalfLifeMultiplay::CHalfLifeMultiplay() sprintf( szCommand, "exec %s\n", servercfgfile ); SERVER_COMMAND( szCommand ); } + */ + // this code has been moved into engine, to only run server.cfg once } else { diff --git a/dlls/nihilanth.cpp b/dlls/nihilanth.cpp index 58317b3c..ba1c6192 100644 --- a/dlls/nihilanth.cpp +++ b/dlls/nihilanth.cpp @@ -1185,8 +1185,22 @@ void CNihilanth::CommandUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ case USE_OFF: { CBaseEntity *pTouch = UTIL_FindEntityByTargetname( NULL, m_szDeadTouch ); - if( pTouch && m_hEnemy != NULL ) - pTouch->Touch( m_hEnemy ); + if( pTouch ) + { + if( m_hEnemy != NULL ) + { + pTouch->Touch( m_hEnemy ); + } + // if the player is using "notarget", the ending sequence won't fire unless we catch it here + else + { + CBaseEntity *pEntity = UTIL_FindEntityByClassname( NULL, "player" ); + if( pEntity != NULL && pEntity->IsAlive() ) + { + pTouch->Touch( pEntity ); + } + } + } } break; case USE_ON: diff --git a/dlls/player.cpp b/dlls/player.cpp index 2f097072..7d7363b5 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -34,6 +34,7 @@ #include "decals.h" #include "gamerules.h" #include "game.h" +#include "pm_shared.h" #include "hltv.h" // #define DUCKFIX @@ -201,7 +202,8 @@ void LinkUserMessages( void ) gmsgDamage = REG_USER_MSG( "Damage", 12 ); gmsgBattery = REG_USER_MSG( "Battery", 2); gmsgTrain = REG_USER_MSG( "Train", 1 ); - gmsgHudText = REG_USER_MSG( "HudText", -1 ); + //gmsgHudText = REG_USER_MSG( "HudTextPro", -1 ); + gmsgHudText = REG_USER_MSG( "HudText", -1 ); // we don't use the message but 3rd party addons may! gmsgSayText = REG_USER_MSG( "SayText", -1 ); gmsgTextMsg = REG_USER_MSG( "TextMsg", -1 ); gmsgWeaponList = REG_USER_MSG( "WeaponList", -1 ); @@ -785,6 +787,12 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) m_pLastItem = NULL; + if( m_pTank != NULL ) + { + m_pTank->Use( this, this, USE_OFF, 0 ); + m_pTank = NULL; + } + int i; CBasePlayerItem *pPendingItem; for( i = 0; i < MAX_ITEM_TYPES; i++ ) @@ -1297,6 +1305,9 @@ void CBasePlayer::PlayerDeathThink( void ) StartDeathCam(); } + if( pev->iuser1 ) // player is in spectator mode + return; + // wait for any button down, or mp_forcerespawn is set and the respawn time is up if( !fAnyButtonDown && !( g_pGameRules->IsMultiplayer() && forcerespawn.value > 0 && ( gpGlobals->time > ( m_fDeadTime + 5 ) ) ) ) return; @@ -1345,7 +1356,9 @@ void CBasePlayer::StartDeathCam( void ) } CopyToBodyQue( pev ); - StartObserver( pSpot->v.origin, pSpot->v.v_angle ); + + UTIL_SetOrigin( pev, pSpot->v.origin ); + pev->angles = pev->v_angle = pSpot->v.v_angle; } else { @@ -1353,23 +1366,89 @@ void CBasePlayer::StartDeathCam( void ) TraceResult tr; CopyToBodyQue( pev ); UTIL_TraceLine( pev->origin, pev->origin + Vector( 0, 0, 128 ), ignore_monsters, edict(), &tr ); - StartObserver( tr.vecEndPos, UTIL_VecToAngles( tr.vecEndPos - pev->origin ) ); - return; + + UTIL_SetOrigin( pev, tr.vecEndPos ); + pev->angles = pev->v_angle = UTIL_VecToAngles( tr.vecEndPos - pev->origin ); } + + // start death cam + m_afPhysicsFlags |= PFLAG_OBSERVER; + pev->view_ofs = g_vecZero; + pev->fixangle = TRUE; + pev->solid = SOLID_NOT; + pev->takedamage = DAMAGE_NO; + pev->movetype = MOVETYPE_NONE; + pev->modelindex = 0; } void CBasePlayer::StartObserver( Vector vecPosition, Vector vecViewAngle ) { - m_afPhysicsFlags |= PFLAG_OBSERVER; + // clear any clientside entities attached to this player + MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); + WRITE_BYTE( TE_KILLPLAYERATTACHMENTS ); + WRITE_BYTE( (BYTE)entindex() ); + MESSAGE_END(); + + // Holster weapon immediately, to allow it to cleanup + if( m_pActiveItem ) + m_pActiveItem->Holster(); + + if( m_pTank != NULL ) + { + m_pTank->Use( this, this, USE_OFF, 0 ); + m_pTank = NULL; + } + + // clear out the suit message cache so we don't keep chattering + SetSuitUpdate( NULL, FALSE, 0 ); + + // Tell Ammo Hud that the player is dead + MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pev ); + WRITE_BYTE( 0 ); + WRITE_BYTE( 0XFF ); + WRITE_BYTE( 0xFF ); + MESSAGE_END(); + + // reset FOV + m_iFOV = m_iClientFOV = 0; + pev->fov = m_iFOV; + MESSAGE_BEGIN( MSG_ONE, gmsgSetFOV, NULL, pev ); + WRITE_BYTE( 0 ); + MESSAGE_END(); + // Setup flags + m_iHideHUD = ( HIDEHUD_HEALTH | HIDEHUD_WEAPONS ); + m_afPhysicsFlags |= PFLAG_OBSERVER; + pev->effects = EF_NODRAW; pev->view_ofs = g_vecZero; pev->angles = pev->v_angle = vecViewAngle; pev->fixangle = TRUE; pev->solid = SOLID_NOT; pev->takedamage = DAMAGE_NO; pev->movetype = MOVETYPE_NONE; - pev->modelindex = 0; + ClearBits( m_afPhysicsFlags, PFLAG_DUCKING ); + ClearBits( pev->flags, FL_DUCKING ); + pev->deadflag = DEAD_RESPAWNABLE; + pev->health = 1; + + // Clear out the status bar + m_fInitHUD = TRUE; + + pev->team = 0; + MESSAGE_BEGIN( MSG_ALL, gmsgTeamInfo ); + WRITE_BYTE( ENTINDEX(edict()) ); + WRITE_STRING( "" ); + MESSAGE_END(); + + // Remove all the player's stuff + RemoveAllItems( FALSE ); + + // Move them to the new position UTIL_SetOrigin( pev, vecPosition ); + + // Find a player to watch + m_flNextObserverInput = 0; + Observer_SetMode( m_iObserverLastMode ); } // @@ -1379,6 +1458,9 @@ void CBasePlayer::StartObserver( Vector vecPosition, Vector vecViewAngle ) void CBasePlayer::PlayerUse( void ) { + if( IsObserver() ) + return; + // Was use pressed or released? if( !( ( pev->button | m_afButtonPressed | m_afButtonReleased) & IN_USE ) ) return; @@ -1747,6 +1829,16 @@ void CBasePlayer::PreThink( void ) CheckSuitUpdate(); + // Observer Button Handling + if( IsObserver() ) + { + Observer_HandleButtons(); + Observer_CheckTarget(); + Observer_CheckProperties(); + pev->impulse = 0; + return; + } + if( pev->deadflag >= DEAD_DYING ) { PlayerDeathThink(); @@ -3767,6 +3859,9 @@ void CBasePlayer::UpdateClientData( void ) g_pGameRules->InitHUD( this ); m_fGameHUDInitialized = TRUE; + + m_iObserverLastMode = OBS_ROAMING; + if( g_pGameRules->IsMultiplayer() ) { FireTargets( "game_playerjoin", this, this, USE_TOGGLE, 0 ); @@ -3807,7 +3902,10 @@ void CBasePlayer::UpdateClientData( void ) if( pev->health != m_iClientHealth ) { - int iHealth = max( pev->health, 0 ); // make sure that no negative health values are sent +#define clamp( val, min, max ) ( ((val) > (max)) ? (max) : ( ((val) < (min)) ? (min) : (val) ) ) + int iHealth = clamp( pev->health, 0, 255 ); // make sure that no negative health values are sent + if( pev->health > 0.0f && pev->health <= 1.0f ) + iHealth = 1; // send "health" update message MESSAGE_BEGIN( MSG_ONE, gmsgHealth, NULL, pev ); @@ -4336,7 +4434,8 @@ void CBasePlayer::DropPlayerItem( char *pszItemName ) // item we want to drop and hit a BREAK; pWeapon is the item. if( pWeapon ) { - g_pGameRules->GetNextBestWeapon( this, pWeapon ); + if( !g_pGameRules->GetNextBestWeapon( this, pWeapon ) ) + return; // can't drop the item they asked for, may be our last item or something we can't holster UTIL_MakeVectors( pev->angles ); diff --git a/dlls/player.h b/dlls/player.h index e75787ee..cb2bddf8 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -86,6 +86,18 @@ enum sbar_data class CBasePlayer : public CBaseMonster { public: + // Spectator camera + void Observer_FindNextPlayer( bool bReverse ); + void Observer_HandleButtons(); + void Observer_SetMode( int iMode ); + void Observer_CheckTarget(); + void Observer_CheckProperties(); + EHANDLE m_hObserverTarget; + float m_flNextObserverInput; + int m_iObserverWeapon; // weapon of current tracked target + int m_iObserverLastMode;// last used observer mode + int IsObserver() { return pev->iuser1; }; + int random_seed; // See that is shared between client & server for shared weapons code int m_iPlayerSound;// the index of the sound list slot reserved for this player diff --git a/dlls/rpg.cpp b/dlls/rpg.cpp index 1fec5cf1..95c9132a 100644 --- a/dlls/rpg.cpp +++ b/dlls/rpg.cpp @@ -297,7 +297,7 @@ void CRpg::Reload( void ) // Set the next attack time into the future so that WeaponIdle will get called more often // than reload, allowing the RPG LTD to be updated - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); if( m_cActiveRockets && m_fSpotActive ) { @@ -463,7 +463,7 @@ void CRpg::PrimaryAttack() m_iClip--; - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.5; + m_flNextPrimaryAttack = GetNextAttackDelay( 1.5 ); m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5; } else diff --git a/dlls/satchel.cpp b/dlls/satchel.cpp index 48ec5b9a..05d1fc8c 100644 --- a/dlls/satchel.cpp +++ b/dlls/satchel.cpp @@ -354,7 +354,7 @@ void CSatchel::PrimaryAttack() } m_chargeReady = 2; - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; break; @@ -401,7 +401,7 @@ void CSatchel::Throw( void ) m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.0; + m_flNextPrimaryAttack = GetNextAttackDelay( 1.0 ); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; } } @@ -442,7 +442,7 @@ void CSatchel::WeaponIdle( void ) // use tripmine animations strcpy( m_pPlayer->m_szAnimExtention, "trip" ); - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; m_chargeReady = 0; break; diff --git a/dlls/saverestore.h b/dlls/saverestore.h index f76613e8..a9ad2c54 100644 --- a/dlls/saverestore.h +++ b/dlls/saverestore.h @@ -59,7 +59,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 ); diff --git a/dlls/shotgun.cpp b/dlls/shotgun.cpp index 8c96e99c..595561e2 100644 --- a/dlls/shotgun.cpp +++ b/dlls/shotgun.cpp @@ -119,7 +119,7 @@ void CShotgun::PrimaryAttack() if( m_pPlayer->pev->waterlevel == 3 ) { PlayEmptySound(); - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.15 ); return; } @@ -172,7 +172,7 @@ void CShotgun::PrimaryAttack() if( m_iClip != 0 ) m_flPumpTime = gpGlobals->time + 0.5; - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.75; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.75 ); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.75; if( m_iClip != 0 ) m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0; @@ -187,7 +187,7 @@ void CShotgun::SecondaryAttack( void ) if( m_pPlayer->pev->waterlevel == 3 ) { PlayEmptySound(); - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.15 ); return; } @@ -243,7 +243,7 @@ void CShotgun::SecondaryAttack( void ) if( m_iClip != 0 ) m_flPumpTime = gpGlobals->time + 0.95; - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.5; + m_flNextPrimaryAttack = GetNextAttackDelay( 1.5 ); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.5; if( m_iClip != 0 ) m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 6.0; @@ -269,7 +269,7 @@ void CShotgun::Reload( void ) m_fInSpecialReload = 1; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.6; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.6; - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.0; + m_flNextPrimaryAttack = GetNextAttackDelay( 1.0 ); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0; return; } diff --git a/dlls/squeakgrenade.cpp b/dlls/squeakgrenade.cpp index 22200b74..30ddda62 100644 --- a/dlls/squeakgrenade.cpp +++ b/dlls/squeakgrenade.cpp @@ -533,7 +533,7 @@ void CSqueak::PrimaryAttack() m_fJustThrown = 1; - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.3; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.3 ); m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; } } diff --git a/dlls/subs.cpp b/dlls/subs.cpp index bc7baf18..5ebe757b 100644 --- a/dlls/subs.cpp +++ b/dlls/subs.cpp @@ -415,6 +415,14 @@ After moving, set origin to exact final destination, call "move done" function */ void CBaseToggle::LinearMoveDone( void ) { + Vector delta = m_vecFinalDest - pev->origin; + float error = delta.Length(); + if( error > 0.03125 ) + { + LinearMove( m_vecFinalDest, 100 ); + return; + } + UTIL_SetOrigin( pev, m_vecFinalDest ); pev->velocity = g_vecZero; pev->nextthink = -1; diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index d7f9483c..958f899f 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -688,7 +688,7 @@ void PlayCDTrack( int iTrack ) if( iTrack == -1 ) { - CLIENT_COMMAND( pClient, "cd pause\n" ); + CLIENT_COMMAND( pClient, "cd stop\n" ); } else { diff --git a/dlls/tripmine.cpp b/dlls/tripmine.cpp index f04d906a..e2ed0817 100644 --- a/dlls/tripmine.cpp +++ b/dlls/tripmine.cpp @@ -470,7 +470,7 @@ void CTripmine::PrimaryAttack( void ) }*/ - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.3; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.3 ); m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } diff --git a/dlls/util.cpp b/dlls/util.cpp index d1fceb0a..4fc0d51a 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -1886,7 +1886,7 @@ void CSave::WritePositionVector( const char *pname, const float *value, int coun } } -void CSave::WriteFunction( const char *pname, const int *data, int count ) +void CSave::WriteFunction( const char *pname, void **data, int count ) { const char *functionName; @@ -2042,7 +2042,7 @@ int CSave::WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFi WriteInt( pTest->fieldName, (int *)(char *)pOutputData, pTest->fieldSize ); break; case FIELD_FUNCTION: - WriteFunction( pTest->fieldName, (int *)pOutputData, pTest->fieldSize ); + WriteFunction( pTest->fieldName, (void **)pOutputData, pTest->fieldSize ); break; default: ALERT( at_error, "Bad field type\n" ); diff --git a/dlls/util.h b/dlls/util.h index e8aee878..f8ae0b6a 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -37,7 +37,7 @@ extern globalvars_t *gpGlobals; #define STRING(offset) (const char *)(gpGlobals->pStringBase + (int)offset) #if !defined __amd64__ || defined(CLIENT_DLL) -#define MAKE_STRING(str) ((int)(size_t)str - (int)(size_t)STRING(0)) +#define MAKE_STRING(str) ((size_t)str - (size_t)STRING(0)) #else #define MAKE_STRING ALLOC_STRING #endif diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index ff03bbfc..ee2a8547 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -612,6 +612,11 @@ void CBasePlayerWeapon::ItemPostFrame( void ) m_fInReload = FALSE; } + if( !(m_pPlayer->pev->button & IN_ATTACK ) ) + { + m_flLastFireTime = 0.0f; + } + if( ( m_pPlayer->pev->button & IN_ATTACK2 ) && CanAttack( m_flNextSecondaryAttack, gpGlobals->time, UseDecrement() ) ) { if( pszAmmo2() && !m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] ) @@ -943,6 +948,7 @@ BOOL CBasePlayerWeapon::DefaultDeploy( char *szViewModel, char *szWeaponModel, i m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; + m_flLastFireTime = 0.0f; return TRUE; } @@ -1130,6 +1136,36 @@ void CBasePlayerWeapon::RetireWeapon( void ) g_pGameRules->GetNextBestWeapon( m_pPlayer, this ); } +//========================================================================= +// GetNextAttackDelay - An accurate way of calcualting the next attack time. +//========================================================================= +float CBasePlayerWeapon::GetNextAttackDelay( float delay ) +{ + if( m_flLastFireTime == 0 || m_flNextPrimaryAttack == -1 ) + { + // At this point, we are assuming that the client has stopped firing + // and we are going to reset our book keeping variables. + m_flLastFireTime = gpGlobals->time; + m_flPrevPrimaryAttack = delay; + } + // calculate the time between this shot and the previous + float flTimeBetweenFires = gpGlobals->time - m_flLastFireTime; + float flCreep = 0.0f; + if( flTimeBetweenFires > 0 ) + flCreep = flTimeBetweenFires - m_flPrevPrimaryAttack; // postive or negative + + // save the last fire time + m_flLastFireTime = gpGlobals->time; + + float flNextAttack = UTIL_WeaponTimeBase() + delay - flCreep; + // we need to remember what the m_flNextPrimaryAttack time is set to for each shot, + // store it as m_flPrevPrimaryAttack. + m_flPrevPrimaryAttack = flNextAttack - UTIL_WeaponTimeBase(); + //char szMsg[256]; + //_snprintf( szMsg, sizeof(szMsg), "next attack time: %0.4f\n", gpGlobals->time + flNextAttack ); + //OutputDebugString( szMsg ); + return flNextAttack; +} //********************************************************* // weaponbox code: //********************************************************* diff --git a/dlls/weapons.h b/dlls/weapons.h index 5112254a..3e6fc5ce 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -331,6 +331,7 @@ public: void PrintState( void ); virtual CBasePlayerItem *GetWeaponPtr( void ) { return (CBasePlayerItem *)this; }; + float GetNextAttackDelay( float delay ); float m_flPumpTime; int m_fInSpecialReload; // Are we in the middle of a reload for the shotguns @@ -345,6 +346,10 @@ public: int m_fInReload; // Are we in the middle of a reload; int m_iDefaultAmmo;// how much ammo you get when you pick up this weapon as placed by a level designer. + + // hle time creep vars + float m_flPrevPrimaryAttack; + float m_flLastFireTime; }; class CBasePlayerAmmo : public CBaseEntity diff --git a/dlls/zombie.cpp b/dlls/zombie.cpp index 7fe416c7..b20293c1 100644 --- a/dlls/zombie.cpp +++ b/dlls/zombie.cpp @@ -169,13 +169,15 @@ void CZombie::IdleSound( void ) int pitch = 95 + RANDOM_LONG( 0, 9 ); // Play a random idle sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pIdleSounds[RANDOM_LONG( 0, ARRAYSIZE( pIdleSounds ) -1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pIdleSounds[RANDOM_LONG( 0, ARRAYSIZE( pIdleSounds ) -1 )], 1.0, ATTN_NORM, 0, pitch ); } void CZombie::AttackSound( void ) { + int pitch = 95 + RANDOM_LONG( 0, 9 ); + // Play a random attack sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pAttackSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pAttackSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackSounds ) - 1 )], 1.0, ATTN_NORM, 0, pitch ); } //========================================================= diff --git a/engine/eiface.h b/engine/eiface.h index 903451f5..3419e5bd 100644 --- a/engine/eiface.h +++ b/engine/eiface.h @@ -57,7 +57,8 @@ typedef enum { force_exactfile, // File on client must exactly match server's file force_model_samebounds, // For model files only, the geometry must fit in the same bbox - force_model_specifybounds // For model files only, the geometry must fit in the specified bbox + force_model_specifybounds, // For model files only, the geometry must fit in the specified bbox + force_model_specifybounds_if_avail // For Steam model files only, the geometry must fit in the specified bbox (if the file is available) } FORCE_TYPE; // Returned by TraceLine @@ -88,7 +89,7 @@ typedef struct int fPlayTrack; } CDStatus; -typedef unsigned long CRC32_t; +typedef unsigned int CRC32_t; // Engine hands this to DLLs for functionality callbacks typedef struct enginefuncs_s @@ -156,7 +157,7 @@ typedef struct enginefuncs_s void (*pfnCVarSetString)( const char *szVarName, const char *szValue ); void (*pfnAlertMessage)( ALERT_TYPE atype, char *szFmt, ... ); void (*pfnEngineFprintf)( FILE *pfile, char *szFmt, ... ); - void* (*pfnPvAllocEntPrivateData)( edict_t *pEdict, long cb ); + void* (*pfnPvAllocEntPrivateData)( edict_t *pEdict, int cb ); void* (*pfnPvEntPrivateData)( edict_t *pEdict ); void (*pfnFreeEntPrivateData)( edict_t *pEdict ); const char *(*pfnSzFromIndex)( int iString ); @@ -171,8 +172,8 @@ typedef struct enginefuncs_s int (*pfnRegUserMsg)( const char *pszName, int iSize ); void (*pfnAnimationAutomove)( const edict_t* pEdict, float flTime ); void (*pfnGetBonePosition)( const edict_t* pEdict, int iBone, float *rgflOrigin, float *rgflAngles ); - unsigned long (*pfnFunctionFromName)( const char *pName ); - const char *(*pfnNameForFunction)( unsigned long function ); + unsigned int (*pfnFunctionFromName)( const char *pName ); + const char *(*pfnNameForFunction)( unsigned int function ); void (*pfnClientPrintf)( edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg ); // JOHN: engine callbacks so game DLL can print messages to individual clients void (*pfnServerPrint)( const char *szMsg ); const char *(*pfnCmd_Args)( void ); // these 3 added @@ -183,7 +184,7 @@ typedef struct enginefuncs_s void (*pfnCRC32_ProcessBuffer)( CRC32_t *pulCRC, void *p, int len ); void (*pfnCRC32_ProcessByte)( CRC32_t *pulCRC, unsigned char ch ); CRC32_t (*pfnCRC32_Final)( CRC32_t pulCRC ); - long (*pfnRandomLong)( long lLow, long lHigh ); + int (*pfnRandomLong)( int lLow, int lHigh ); float (*pfnRandomFloat)( float flLow, float flHigh ); void (*pfnSetView)( const edict_t *pClient, const edict_t *pViewent ); float (*pfnTime)( void ); @@ -276,7 +277,7 @@ typedef struct KeyValueData_s char *szClassName; // in: entity classname char *szKeyName; // in: name of key char *szValue; // in: value of key - long fHandled; // out: DLL sets to true if key-value pair was understood + int fHandled; // out: DLL sets to true if key-value pair was understood } KeyValueData; @@ -354,7 +355,7 @@ typedef enum _fieldtypes FIELD_TYPECOUNT // MUST BE LAST } FIELDTYPE; -#ifndef offsetof +#if !defined(offsetof) && !defined(GNUC) #define offsetof(s,m) (size_t)&(((s *)0)->m) #endif diff --git a/engine/shake.h b/engine/shake.h index c644a476..b2e88a33 100644 --- a/engine/shake.h +++ b/engine/shake.h @@ -36,7 +36,7 @@ extern int gmsgFade; #define FFADE_OUT 0x0001 // Fade out (not in) #define FFADE_MODULATE 0x0002 // Modulate (don't blend) #define FFADE_STAYOUT 0x0004 // ignores the duration, stays faded out until new ScreenFade message received - +#define FFADE_LONGFADE 0x0008 // used to indicate the fade can be longer than 16 seconds (added for czero) // This structure is sent over the net to describe a screen fade event typedef struct @@ -47,4 +47,4 @@ typedef struct byte r, g, b, a; // fade to color ( max alpha ) } ScreenFade; -#endif // SHAKE_H \ No newline at end of file +#endif // SHAKE_H diff --git a/engine/studio.h b/engine/studio.h index b5b709bb..cd572419 100644 --- a/engine/studio.h +++ b/engine/studio.h @@ -33,14 +33,14 @@ Studio models are position independent, so the cache manager can move them. // studio limits #define MAXSTUDIOTRIANGLES 32768 // max triangles per model #define MAXSTUDIOVERTS 4096 // max vertices per submodel -#define MAXSTUDIOSEQUENCES 256 // total animation sequences +#define MAXSTUDIOSEQUENCES 2048 // total animation sequences #define MAXSTUDIOSKINS 256 // total textures #define MAXSTUDIOSRCBONES 512 // bones allowed at source movement #define MAXSTUDIOBONES 128 // total bones actually used #define MAXSTUDIOMODELS 32 // sub-models per model #define MAXSTUDIOBODYPARTS 32 // body parts per submodel #define MAXSTUDIOGROUPS 16 // sequence groups (e.g. barney01.mdl, barney02.mdl, e.t.c) -#define MAXSTUDIOANIMATIONS 512 // max frames per sequence +#define MAXSTUDIOANIMATIONS 2048 // max frames per sequence #define MAXSTUDIOMESHES 256 // max textures per model #define MAXSTUDIOEVENTS 1024 // events per model #define MAXSTUDIOPIVOTS 256 // pivot points @@ -214,10 +214,8 @@ typedef struct { char label[32]; // textual name char name[64]; // file name - cache_user_t cache; // cache index pointer -#ifndef __amd64 - int data; // hack for group 0 -#endif + int unused1; // // was "cache" - index pointer + int unused2; // was "data" - hack for group 0 } mstudioseqgroup_t; // sequence descriptions diff --git a/pm_shared/pm_defs.h b/pm_shared/pm_defs.h index d29bff19..cd17ce54 100644 --- a/pm_shared/pm_defs.h +++ b/pm_shared/pm_defs.h @@ -201,7 +201,7 @@ typedef struct playermove_s pmtrace_t (*PM_PlayerTrace)( float *start, float *end, int traceFlags, int ignore_pe ); #endif struct pmtrace_s *(*PM_TraceLine)( float *start, float *end, int flags, int usehulll, int ignore_pe ); - long (*RandomLong)( long lLow, long lHigh ); + int (*RandomLong)( int lLow, int lHigh ); float (*RandomFloat)( float flLow, float flHigh ); int (*PM_GetModelType)( struct model_s *mod ); void (*PM_GetModelBounds)( struct model_s *mod, float *mins, float *maxs ); diff --git a/pm_shared/pm_materials.h b/pm_shared/pm_materials.h index cd1051d2..e625b4fc 100644 --- a/pm_shared/pm_materials.h +++ b/pm_shared/pm_materials.h @@ -28,4 +28,5 @@ #define CHAR_TEX_COMPUTER 'P' #define CHAR_TEX_GLASS 'Y' #define CHAR_TEX_FLESH 'F' +#define CHAR_TEX_SNOW 'N' #endif//PM_MATERIALS_H diff --git a/pm_shared/pm_shared.c b/pm_shared/pm_shared.c index de855a50..7a1fb966 100644 --- a/pm_shared/pm_shared.c +++ b/pm_shared/pm_shared.c @@ -87,6 +87,8 @@ playermove_t *pmove = NULL; #define PLAYER_LONGJUMP_SPEED 350 // how fast we longjump +#define PLAYER_DUCKING_MULTIPLIER 0.333 + // double to float warning #pragma warning(disable : 4244) #define max(a, b) (((a) > (b)) ? (a) : (b)) @@ -2017,9 +2019,9 @@ void PM_Duck( void ) if( pmove->flags & FL_DUCKING ) { - pmove->cmd.forwardmove *= 0.333; - pmove->cmd.sidemove *= 0.333; - pmove->cmd.upmove *= 0.333; + pmove->cmd.forwardmove *= PLAYER_DUCKING_MULTIPLIER; + pmove->cmd.sidemove *= PLAYER_DUCKING_MULTIPLIER; + pmove->cmd.upmove *= PLAYER_DUCKING_MULTIPLIER; } if( ( pmove->cmd.buttons & IN_DUCK ) || ( pmove->bInDuck ) || ( pmove->flags & FL_DUCKING ) ) @@ -2110,16 +2112,24 @@ void PM_LadderMove( physent_t *pLadder ) { float forward = 0, right = 0; vec3_t vpn, v_right; + float flSpeed = MAX_CLIMB_SPEED; + + // they shouldn't be able to move faster than their maxspeed + if( flSpeed > pmove->maxspeed ) + flSpeed = pmove->maxspeed; AngleVectors( pmove->angles, vpn, v_right, NULL ); + + if( pmove->flags & FL_DUCKING ) + flSpeed *= PLAYER_DUCKING_MULTIPLIER; if( pmove->cmd.buttons & IN_BACK ) - forward -= MAX_CLIMB_SPEED; + forward -= flSpeed; if( pmove->cmd.buttons & IN_FORWARD ) - forward += MAX_CLIMB_SPEED; + forward += flSpeed; if( pmove->cmd.buttons & IN_MOVELEFT ) - right -= MAX_CLIMB_SPEED; + right -= flSpeed; if( pmove->cmd.buttons & IN_MOVERIGHT ) - right += MAX_CLIMB_SPEED; + right += flSpeed; if( pmove->cmd.buttons & IN_JUMP ) { From ecaba0de22483417add665dfbd47271ed058ff10 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 26 Jun 2017 07:06:27 +0500 Subject: [PATCH 008/144] Upload missing file. Fix build. --- cl_dll/com_weapons.cpp | 2 +- cl_dll/com_weapons.h | 2 +- cl_dll/hl/hl_baseentity.cpp | 1 + cl_dll/hl/hl_weapons.cpp | 21 --- dlls/Android.mk | 1 + dlls/CMakeLists.txt | 1 + dlls/Makefile | 1 + dlls/observer.cpp | 268 ++++++++++++++++++++++++++++++++++++ engine/cdll_int.h | 4 +- engine/menu_int.h | 4 +- 10 files changed, 278 insertions(+), 27 deletions(-) create mode 100644 dlls/observer.cpp diff --git a/cl_dll/com_weapons.cpp b/cl_dll/com_weapons.cpp index 4f539df9..cc693b88 100644 --- a/cl_dll/com_weapons.cpp +++ b/cl_dll/com_weapons.cpp @@ -283,7 +283,7 @@ unsigned short stub_PrecacheEvent( int type, const char *s ) return 0; } -const char *stub_NameForFunction( unsigned long function ) +const char *stub_NameForFunction( unsigned int function ) { return "func"; } diff --git a/cl_dll/com_weapons.h b/cl_dll/com_weapons.h index 7e1fdd77..4dd75203 100644 --- a/cl_dll/com_weapons.h +++ b/cl_dll/com_weapons.h @@ -34,7 +34,7 @@ void HUD_SetMaxSpeed( const struct edict_s *ed, float speed ); int stub_PrecacheModel( char* s ); int stub_PrecacheSound( char* s ); unsigned short stub_PrecacheEvent( int type, const char *s ); -const char *stub_NameForFunction( unsigned long function ); +const char *stub_NameForFunction( unsigned int function ); void stub_SetModel( struct edict_s *e, const char *m ); extern cvar_t *cl_lw; diff --git a/cl_dll/hl/hl_baseentity.cpp b/cl_dll/hl/hl_baseentity.cpp index 9a47110f..fc306838 100644 --- a/cl_dll/hl/hl_baseentity.cpp +++ b/cl_dll/hl/hl_baseentity.cpp @@ -314,6 +314,7 @@ int CBasePlayerItem::Restore( class CRestore & ) { return 1; } int CBasePlayerItem::Save( class CSave & ) { return 1; } int CBasePlayerWeapon::Restore( class CRestore & ) { return 1; } int CBasePlayerWeapon::Save( class CSave & ) { return 1; } +float CBasePlayerWeapon::GetNextAttackDelay( float flTime ) { return flTime; } void CBasePlayerItem::SetObjectCollisionBox( void ) { } void CBasePlayerItem::FallInit( void ) { } void CBasePlayerItem::FallThink( void ) { } diff --git a/cl_dll/hl/hl_weapons.cpp b/cl_dll/hl/hl_weapons.cpp index 6d555b4c..8c6909e3 100644 --- a/cl_dll/hl/hl_weapons.cpp +++ b/cl_dll/hl/hl_weapons.cpp @@ -560,27 +560,6 @@ void UTIL_ParticleLine( CBasePlayer *player, float *start, float *end, float lif gEngfuncs.pEfxAPI->R_ParticleLine( start, end, r, g, b, life ); } -/* -===================== -CBasePlayerWeapon::PrintState - -For debugging, print out state variables to log file -===================== -*/ -void CBasePlayerWeapon::PrintState( void ) -{ - COM_Log( "c:\\hl.log", "%.4f ", gpGlobals->time ); - COM_Log( "c:\\hl.log", "%.4f ", m_pPlayer->m_flNextAttack ); - COM_Log( "c:\\hl.log", "%.4f ", m_flNextPrimaryAttack ); - COM_Log( "c:\\hl.log", "%.4f ", m_flTimeWeaponIdle - gpGlobals->time ); - COM_Log( "c:\\hl.log", "%i ", m_iClip ); -} - -int RandomLong( int a, int b ) -{ - return gEngfuncs.pfnRandomLong( a, b ); -} - /* ===================== HUD_InitClientWeapons diff --git a/dlls/Android.mk b/dlls/Android.mk index 7fcdf581..b160c424 100644 --- a/dlls/Android.mk +++ b/dlls/Android.mk @@ -90,6 +90,7 @@ LOCAL_SRC_FILES := agrunt.cpp airtank.cpp \ multiplay_gamerules.cpp \ nihilanth.cpp \ nodes.cpp \ + observer.cpp \ osprey.cpp \ pathcorner.cpp \ plane.cpp \ diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index cc0063b4..e0b6a8b3 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -92,6 +92,7 @@ set (SVDLL_SOURCES multiplay_gamerules.cpp nihilanth.cpp nodes.cpp + observer.cpp osprey.cpp pathcorner.cpp plane.cpp diff --git a/dlls/Makefile b/dlls/Makefile index c75731d5..9c3a84f2 100644 --- a/dlls/Makefile +++ b/dlls/Makefile @@ -129,6 +129,7 @@ OBJ = \ $(DLL_OBJDIR)/multiplay_gamerules.o \ $(DLL_OBJDIR)/nihilanth.o \ $(DLL_OBJDIR)/nodes.o \ + $(DLL_OBJDIR)/observer.cpp \^M $(DLL_OBJDIR)/osprey.o \ $(DLL_OBJDIR)/pathcorner.o \ $(DLL_OBJDIR)/plane.o \ diff --git a/dlls/observer.cpp b/dlls/observer.cpp new file mode 100644 index 00000000..0eda7490 --- /dev/null +++ b/dlls/observer.cpp @@ -0,0 +1,268 @@ +//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. =========== +// +// The copyright to the contents herein is the property of Valve, L.L.C. +// The contents may be used and/or copied only with the written permission of +// Valve, L.L.C., or in accordance with the terms and conditions stipulated in +// the agreement/contract under which the contents have been supplied. +// +// Purpose: Functionality for the observer chase camera +// +// $Workfile: $ +// $Date: $ +// +//----------------------------------------------------------------------------- +// $Log: $ +// +// $NoKeywords: $ +//============================================================================= +#include "extdll.h" +#include "util.h" +#include "cbase.h" +#include "player.h" +#include "weapons.h" +#include "pm_shared.h" + +extern int gmsgCurWeapon; +extern int gmsgSetFOV; +// Find the next client in the game for this player to spectate +void CBasePlayer::Observer_FindNextPlayer( bool bReverse ) +{ + // MOD AUTHORS: Modify the logic of this function if you want to restrict the observer to watching + // only a subset of the players. e.g. Make it check the target's team. + int iStart; + if( m_hObserverTarget ) + iStart = ENTINDEX( m_hObserverTarget->edict() ); + else + iStart = ENTINDEX( edict() ); + int iCurrent = iStart; + m_hObserverTarget = NULL; + int iDir = bReverse ? -1 : 1; + + do + { + iCurrent += iDir; + + // Loop through the clients + if( iCurrent > gpGlobals->maxClients ) + iCurrent = 1; + if( iCurrent < 1 ) + iCurrent = gpGlobals->maxClients; + + CBaseEntity *pEnt = UTIL_PlayerByIndex( iCurrent ); + if( !pEnt ) + continue; + if( pEnt == this ) + continue; + // Don't spec observers or players who haven't picked a class yet + if( ( (CBasePlayer*)pEnt )->IsObserver() || ( pEnt->pev->effects & EF_NODRAW ) ) + continue; + + // MOD AUTHORS: Add checks on target here. + m_hObserverTarget = pEnt; + break; + }while( iCurrent != iStart ); + + // Did we find a target? + if( m_hObserverTarget ) + { + // Move to the target + UTIL_SetOrigin( pev, m_hObserverTarget->pev->origin ); + + // ALERT( at_console, "Now Tracking %s\n", STRING( m_hObserverTarget->pev->netname ) ); + + // Store the target in pev so the physics DLL can get to it + if( pev->iuser1 != OBS_ROAMING ) + pev->iuser2 = ENTINDEX( m_hObserverTarget->edict() ); + } +} + +// Handle buttons in observer mode +void CBasePlayer::Observer_HandleButtons() +{ + // Slow down mouse clicks + if( m_flNextObserverInput > gpGlobals->time ) + return; + + // Jump changes from modes: Chase to Roaming + if( m_afButtonPressed & IN_JUMP ) + { + if( pev->iuser1 == OBS_CHASE_LOCKED ) + Observer_SetMode( OBS_CHASE_FREE ); + else if( pev->iuser1 == OBS_CHASE_FREE ) + Observer_SetMode( OBS_IN_EYE ); + else if( pev->iuser1 == OBS_IN_EYE ) + Observer_SetMode( OBS_ROAMING ); + else if( pev->iuser1 == OBS_ROAMING ) + Observer_SetMode( OBS_MAP_FREE ); + else if( pev->iuser1 == OBS_MAP_FREE ) + Observer_SetMode( OBS_MAP_CHASE ); + else + Observer_SetMode( OBS_CHASE_FREE ); // don't use OBS_CHASE_LOCKED anymore + + m_flNextObserverInput = gpGlobals->time + 0.2; + } + + // Attack moves to the next player + if ( m_afButtonPressed & IN_ATTACK )//&& pev->iuser1 != OBS_ROAMING ) + { + Observer_FindNextPlayer( false ); + + m_flNextObserverInput = gpGlobals->time + 0.2; + } + + // Attack2 moves to the prev player + if ( m_afButtonPressed & IN_ATTACK2)// && pev->iuser1 != OBS_ROAMING ) + { + Observer_FindNextPlayer( true ); + + m_flNextObserverInput = gpGlobals->time + 0.2; + } +} + +void CBasePlayer::Observer_CheckTarget() +{ + if( pev->iuser1 == OBS_ROAMING ) + return; + + // try to find a traget if we have no current one + if( m_hObserverTarget == NULL ) + { + Observer_FindNextPlayer( false ); + + if( m_hObserverTarget == NULL ) + { + // no target found at all + + int lastMode = pev->iuser1; + + Observer_SetMode( OBS_ROAMING ); + + m_iObserverLastMode = lastMode; // don't overwrite users lastmode + + return; // we still have np target return + } + } + + CBasePlayer* target = (CBasePlayer*)( UTIL_PlayerByIndex( ENTINDEX( m_hObserverTarget->edict() ) ) ); + + if( !target ) + { + Observer_FindNextPlayer( false ); + return; + } + + // check taget + if( target->pev->deadflag == DEAD_DEAD ) + { + if( ( target->m_fDeadTime + 2.0f ) < gpGlobals->time ) + { + // 3 secs after death change target + Observer_FindNextPlayer( false ); + return; + } + } +} + +void CBasePlayer::Observer_CheckProperties() +{ + // try to find a traget if we have no current one + if( pev->iuser1 == OBS_IN_EYE && m_hObserverTarget != NULL ) + { + CBasePlayer* target = (CBasePlayer*)( UTIL_PlayerByIndex( ENTINDEX( m_hObserverTarget->edict() ) ) ); + + if( !target ) + return; + + int weapon = ( target->m_pActiveItem != NULL ) ? target->m_pActiveItem->m_iId : 0; + // use fov of tracked client + if( m_iFOV != target->m_iFOV || m_iObserverWeapon != weapon ) + { + m_iFOV = target->m_iFOV; + m_iClientFOV = m_iFOV; + // write fov before wepon data, so zoomed crosshair is set correctly + MESSAGE_BEGIN( MSG_ONE, gmsgSetFOV, NULL, pev ); + WRITE_BYTE( m_iFOV ); + MESSAGE_END(); + + m_iObserverWeapon = weapon; + //send weapon update + MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pev ); + WRITE_BYTE( 1 ); // 1 = current weapon, not on target + WRITE_BYTE( m_iObserverWeapon ); + WRITE_BYTE( 0 ); // clip + MESSAGE_END(); + } + } + else + { + m_iFOV = 90; + + if( m_iObserverWeapon != 0 ) + { + m_iObserverWeapon = 0; + + MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pev ); + WRITE_BYTE( 1 ); // 1 = current weapon + WRITE_BYTE( m_iObserverWeapon ); + WRITE_BYTE( 0 ); // clip + MESSAGE_END(); + } + } +} + +// Attempt to change the observer mode +void CBasePlayer::Observer_SetMode( int iMode ) +{ + + // Just abort if we're changing to the mode we're already in + if( iMode == pev->iuser1 ) + return; + + // is valid mode ? + if( iMode < OBS_CHASE_LOCKED || iMode > OBS_MAP_CHASE ) + iMode = OBS_IN_EYE; // now it is + // verify observer target again + if( m_hObserverTarget != NULL ) + { + CBaseEntity *pEnt = m_hObserverTarget; + + if( ( pEnt == this ) || ( pEnt == NULL ) ) + m_hObserverTarget = NULL; + else if( ( (CBasePlayer*)pEnt )->IsObserver() || ( pEnt->pev->effects & EF_NODRAW ) ) + m_hObserverTarget = NULL; + } + + // set spectator mode + pev->iuser1 = iMode; + + // if we are not roaming, we need a valid target to track + if( ( iMode != OBS_ROAMING ) && ( m_hObserverTarget == NULL ) ) + { + Observer_FindNextPlayer( false ); + + // if we didn't find a valid target switch to roaming + if( m_hObserverTarget == NULL ) + { + ClientPrint( pev, HUD_PRINTCENTER, "#Spec_NoTarget" ); + pev->iuser1 = OBS_ROAMING; + } + } + + // set target if not roaming + if( pev->iuser1 == OBS_ROAMING ) + { + pev->iuser2 = 0; + } + else + pev->iuser2 = ENTINDEX( m_hObserverTarget->edict() ); + + pev->iuser3 = 0; // clear second target from death cam + + // print spepctaor mode on client screen + + char modemsg[16]; + sprintf( modemsg,"#Spec_Mode%i", pev->iuser1 ); + ClientPrint( pev, HUD_PRINTCENTER, modemsg ); + + m_iObserverLastMode = iMode; +} diff --git a/engine/cdll_int.h b/engine/cdll_int.h index eaa7f4e8..a0dc59c2 100644 --- a/engine/cdll_int.h +++ b/engine/cdll_int.h @@ -211,7 +211,7 @@ typedef struct cl_enginefuncs_s void (*pfnPlaybackEvent)( int flags, const struct edict_s *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); void (*pfnWeaponAnim)( int iAnim, int body ); float (*pfnRandomFloat)( float flLow, float flHigh ); - long (*pfnRandomLong)( long lLow, long lHigh ); + int (*pfnRandomLong)( int lLow, int lHigh ); void (*pfnHookEvent)( char *name, void ( *pfnEvent )( struct event_args_s *args )); int (*Con_IsVisible) (); const char *(*pfnGetGameDirectory)( void ); @@ -311,4 +311,4 @@ typedef struct cl_enginefuncs_s } #endif -#endif//CDLL_INT_H \ No newline at end of file +#endif//CDLL_INT_H diff --git a/engine/menu_int.h b/engine/menu_int.h index 53b0725a..69c10ce4 100644 --- a/engine/menu_int.h +++ b/engine/menu_int.h @@ -155,7 +155,7 @@ typedef struct ui_enginefuncs_s // menu interface is freezed at version 0.75 // new functions starts here float (*pfnRandomFloat)( float flLow, float flHigh ); - long (*pfnRandomLong)( long lLow, long lHigh ); + int (*pfnRandomLong)( int lLow, int lHigh ); void (*pfnSetCursor)( void *hCursor ); // change cursor int (*pfnIsMapValid)( char *filename ); @@ -185,4 +185,4 @@ typedef struct typedef int (*MENUAPI)( UI_FUNCTIONS *pFunctionTable, ui_enginefuncs_t* engfuncs, ui_globalvars_t *pGlobals ); -#endif//MENU_INT_H \ No newline at end of file +#endif//MENU_INT_H From d217780789a2ca207bde3e8f50f7ec142f274b92 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 26 Jun 2017 07:41:01 +0500 Subject: [PATCH 009/144] Try fix build again. --- dlls/client.cpp | 3 ++- dlls/util.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dlls/client.cpp b/dlls/client.cpp index 74be0ea3..72538b02 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -38,6 +38,7 @@ #include "weaponinfo.h" #include "usercmd.h" #include "netadr.h" +#include "pm_shared.h" extern DLL_GLOBAL ULONG g_ulModelIndexPlayer; extern DLL_GLOBAL BOOL g_fGameOver; @@ -550,7 +551,7 @@ void ClientCommand( edict_t *pEntity ) { GetClassPtr( (CBasePlayer *)pev )->SelectLastItem(); } - else if( FStrEq( pcmd, "spectate" ) // clients wants to become a spectator + else if( FStrEq( pcmd, "spectate" ) ) // clients wants to become a spectator { // always allow proxies to become a spectator if( ( pev->flags & FL_PROXY ) || allow_spectators.value ) diff --git a/dlls/util.cpp b/dlls/util.cpp index 4fc0d51a..9c7d9803 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -1890,7 +1890,7 @@ void CSave::WriteFunction( const char *pname, void **data, int count ) { const char *functionName; - functionName = NAME_FOR_FUNCTION( *data ); + functionName = NAME_FOR_FUNCTION( (unsigned int)(size_t)*data ); if( functionName ) BufferField( pname, strlen( functionName ) + 1, functionName ); else From 2faa732aa1d3fa90937c0aac01e82cb836e2f34c Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 29 Jun 2017 18:56:03 +0500 Subject: [PATCH 010/144] Apply some @AlliedModders's patches. --- cl_dll/ammo.cpp | 4 +-- cl_dll/com_weapons.cpp | 8 ++--- cl_dll/com_weapons.h | 8 ++--- cl_dll/death.cpp | 17 +++++----- cl_dll/entity.cpp | 16 ++++----- cl_dll/ev_hldm.cpp | 30 ++++++++-------- cl_dll/geiger.cpp | 56 +++++++++++++++--------------- cl_dll/hl/hl_baseentity.cpp | 12 +++---- cl_dll/hl/hl_weapons.cpp | 8 ++--- cl_dll/hud.h | 12 +++---- cl_dll/hud_redraw.cpp | 10 +++--- cl_dll/message.cpp | 6 ++-- cl_dll/status_icons.cpp | 4 +-- cl_dll/text_message.cpp | 20 +++++------ cl_dll/view.cpp | 8 ++--- common/cvardef.h | 4 +-- dlls/activity.h | 2 +- dlls/activitymap.h | 2 +- dlls/aflock.cpp | 1 - dlls/agrunt.cpp | 6 ++-- dlls/animation.cpp | 6 ++-- dlls/apache.cpp | 5 ++- dlls/barnacle.cpp | 6 ++-- dlls/barney.cpp | 16 ++++----- dlls/basemonster.h | 4 +-- dlls/bigmomma.cpp | 7 ++-- dlls/bmodels.cpp | 4 +-- dlls/bullsquid.cpp | 12 +++---- dlls/buttons.cpp | 20 +++++------ dlls/cbase.cpp | 4 +-- dlls/cbase.h | 7 ++-- dlls/client.cpp | 26 ++++++-------- dlls/combat.cpp | 19 ++++++----- dlls/controller.cpp | 9 +++-- dlls/crossbow.cpp | 3 +- dlls/crowbar.cpp | 4 +-- dlls/decals.h | 2 +- dlls/doors.cpp | 24 ++++++------- dlls/effects.cpp | 18 +++++----- dlls/effects.h | 8 ++--- dlls/egon.cpp | 10 +++--- dlls/enginecallback.h | 8 +++++ dlls/extdll.h | 6 ++++ dlls/func_break.cpp | 13 ++++--- dlls/func_tank.cpp | 24 ++++++------- dlls/gargantua.cpp | 3 +- dlls/gauss.cpp | 9 +++-- dlls/genericmonster.cpp | 2 +- dlls/ggrenade.cpp | 14 ++++---- dlls/gman.cpp | 8 ++--- dlls/h_battery.cpp | 6 ++-- dlls/h_cine.cpp | 4 +-- dlls/h_cycler.cpp | 6 ++-- dlls/hassassin.cpp | 6 ++-- dlls/headcrab.cpp | 4 +-- dlls/healthkit.cpp | 6 ++-- dlls/hgrunt.cpp | 26 +++++++------- dlls/hornet.cpp | 6 ++-- dlls/houndeye.cpp | 2 +- dlls/ichthyosaur.cpp | 8 ++--- dlls/islave.cpp | 20 +++++------ dlls/leech.cpp | 2 +- dlls/lights.cpp | 17 +++++----- dlls/maprules.cpp | 14 ++++---- dlls/monsters.cpp | 22 ++++++------ dlls/monsterstate.cpp | 6 ++-- dlls/mpstubb.cpp | 4 +-- dlls/multiplay_gamerules.cpp | 16 ++++----- dlls/nihilanth.cpp | 44 ++++++++++++------------ dlls/nodes.cpp | 19 +++++++---- dlls/nodes.h | 4 ++- dlls/observer.cpp | 18 +++++----- dlls/osprey.cpp | 8 ++--- dlls/plats.cpp | 8 ++--- dlls/player.cpp | 66 ++++++++++++++++++------------------ dlls/player.h | 4 +-- dlls/satchel.cpp | 4 +-- dlls/saverestore.h | 11 ++++-- dlls/schedule.cpp | 22 ++++++------ dlls/scientist.cpp | 18 +++++----- dlls/scripted.cpp | 4 +-- dlls/skill.cpp | 5 ++- dlls/skill.h | 2 +- dlls/sound.cpp | 12 +++---- dlls/squadmonster.cpp | 12 +++---- dlls/squadmonster.h | 2 +- dlls/squeakgrenade.cpp | 18 +++++----- dlls/talkmonster.cpp | 32 ++++++++--------- dlls/talkmonster.h | 4 +-- dlls/teamplay_gamerules.cpp | 10 +++--- dlls/tentacle.cpp | 9 ++--- dlls/triggers.cpp | 10 +++--- dlls/tripmine.cpp | 8 ++--- dlls/turret.cpp | 18 +++++----- dlls/util.cpp | 20 +++++------ dlls/util.h | 9 ++--- dlls/vector.h | 14 ++++---- dlls/weapons.cpp | 4 +-- dlls/weapons.h | 8 +++-- dlls/world.cpp | 4 +-- dlls/xen.cpp | 6 ++-- dlls/zombie.cpp | 2 +- engine/custom.h | 6 ++++ engine/edict.h | 8 ++++- engine/eiface.h | 50 ++++++++++++++------------- engine/progdefs.h | 8 ++++- pm_shared/pm_debug.c | 2 ++ pm_shared/pm_debug.h | 6 ++++ pm_shared/pm_defs.h | 6 ++++ pm_shared/pm_info.h | 6 ++++ pm_shared/pm_math.c | 2 ++ pm_shared/pm_shared.c | 26 +++++++++----- pm_shared/pm_shared.h | 6 ++++ 113 files changed, 671 insertions(+), 604 deletions(-) diff --git a/cl_dll/ammo.cpp b/cl_dll/ammo.cpp index 988bd6fa..860cde42 100644 --- a/cl_dll/ammo.cpp +++ b/cl_dll/ammo.cpp @@ -877,11 +877,11 @@ int CHudAmmo::Draw( float flTime ) x = ScreenWidth - ( 8 * AmmoWidth ) - iIconWidth; x = gHUD.DrawHudNumber( x, y, iFlags | DHN_3DIGITS, pw->iClip, r, g, b ); - wrect_t rc; + /*wrect_t rc; rc.top = 0; rc.left = 0; rc.right = AmmoWidth; - rc.bottom = 100; + rc.bottom = 100;*/ int iBarWidth = AmmoWidth / 10; diff --git a/cl_dll/com_weapons.cpp b/cl_dll/com_weapons.cpp index cc693b88..e50de419 100644 --- a/cl_dll/com_weapons.cpp +++ b/cl_dll/com_weapons.cpp @@ -41,7 +41,7 @@ COM_Log Log debug messages to file ( appends ) ==================== */ -void COM_Log( char *pszFile, char *fmt, ... ) +void COM_Log( const char *pszFile, const char *fmt, ... ) { va_list argptr; char string[1024]; @@ -111,7 +111,7 @@ HUD_PlaySound Play a sound, if we are seeing this command for the first time ===================== */ -void HUD_PlaySound( char *sound, float volume ) +void HUD_PlaySound( const char *sound, float volume ) { if( !g_runfuncs || !g_finalstate ) return; @@ -268,12 +268,12 @@ stub functions for such things as precaching. So we don't have to modify weapon is compiled into both game and client .dlls. ====================== */ -int stub_PrecacheModel( char* s ) +int stub_PrecacheModel( const char* s ) { return 0; } -int stub_PrecacheSound( char* s ) +int stub_PrecacheSound( const char* s ) { return 0; } diff --git a/cl_dll/com_weapons.h b/cl_dll/com_weapons.h index 4dd75203..8559e20b 100644 --- a/cl_dll/com_weapons.h +++ b/cl_dll/com_weapons.h @@ -20,7 +20,7 @@ extern "C" void _DLLEXPORT HUD_PostRunCmd( struct local_state_s *from, struct local_state_s *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int random_seed ); } -void COM_Log( char *pszFile, char *fmt, ... ); +void COM_Log( const char *pszFile, const char *fmt, ... ); int CL_IsDead( void ); float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ); @@ -28,11 +28,11 @@ int UTIL_SharedRandomLong( unsigned int seed, int low, int high ); int HUD_GetWeaponAnim( void ); void HUD_SendWeaponAnim( int iAnim, int body, int force ); -void HUD_PlaySound( char *sound, float volume ); +void HUD_PlaySound( const char *sound, float volume ); void HUD_PlaybackEvent( int flags, const struct edict_s *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); void HUD_SetMaxSpeed( const struct edict_s *ed, float speed ); -int stub_PrecacheModel( char* s ); -int stub_PrecacheSound( char* s ); +int stub_PrecacheModel( const char* s ); +int stub_PrecacheSound( const char* s ); unsigned short stub_PrecacheEvent( int type, const char *s ); const char *stub_NameForFunction( unsigned int function ); void stub_SetModel( struct edict_s *e, const char *m ); diff --git a/cl_dll/death.cpp b/cl_dll/death.cpp index 455dfd36..579fc255 100644 --- a/cl_dll/death.cpp +++ b/cl_dll/death.cpp @@ -187,7 +187,8 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu gHUD.m_Scoreboard.GetAllPlayersInfo(); // Get the Killer's name - char *killer_name = g_PlayerInfoList[killer].name; + const char *killer_name = ""; + killer_name = g_PlayerInfoList[killer].name; if( !killer_name ) { killer_name = ""; @@ -201,11 +202,11 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu } // Get the Victim's name - char *victim_name = NULL; + const char *victim_name = ""; // If victim is -1, the killer killed a specific, non-player object (like a sentrygun) - if ( ( (char)victim ) != -1 ) + if( ( (char)victim ) != -1 ) victim_name = g_PlayerInfoList[victim].name; - if ( !victim_name ) + if( !victim_name ) { victim_name = ""; rgDeathNoticeList[i].szVictim[0] = 0; @@ -218,7 +219,7 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu } // Is it a non-player object kill? - if ( ( (char)victim ) == -1 ) + if( ( (char)victim ) == -1 ) { rgDeathNoticeList[i].iNonPlayerKill = TRUE; @@ -227,10 +228,10 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu } else { - if ( killer == victim || killer == 0 ) + if( killer == victim || killer == 0 ) rgDeathNoticeList[i].iSuicide = TRUE; - if ( !strcmp( killedwith, "d_teammate" ) ) + if( !strcmp( killedwith, "d_teammate" ) ) rgDeathNoticeList[i].iTeamKill = TRUE; } @@ -285,7 +286,7 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu // replace the code names with the 'real' names if( !strcmp( killedwith + 2, "egon" ) ) strcpy( killedwith, "d_gluon gun" ); - if ( !strcmp( killedwith + 2, "gauss" ) ) + if( !strcmp( killedwith + 2, "gauss" ) ) strcpy( killedwith, "d_tau cannon" ); ConsolePrint( killedwith + 2 ); // skip over the "d_" part diff --git a/cl_dll/entity.cpp b/cl_dll/entity.cpp index 07bd0ff3..303a9d25 100644 --- a/cl_dll/entity.cpp +++ b/cl_dll/entity.cpp @@ -585,10 +585,10 @@ void DLLEXPORT HUD_TempEntUpdate ( static int gTempEntFrame = 0; int i; TEMPENTITY *pTemp, *pnext, *pprev; - float freq, gravity, gravitySlow, life, fastFreq; + float /*freq,*/ gravity, gravitySlow, life, fastFreq; // Nothing to simulate - if ( !*ppTempEntActive ) + if( !*ppTempEntActive ) return; // in order to have tents collide with players, we have to run the player prediction code so @@ -601,7 +601,7 @@ void DLLEXPORT HUD_TempEntUpdate ( gEngfuncs.pEventAPI->EV_PushPMStates(); // Now add in all of the players. - gEngfuncs.pEventAPI->EV_SetSolidPlayers( -1 ); + gEngfuncs.pEventAPI->EV_SetSolidPlayers( -1 ); // !!!BUGBUG -- This needs to be time based gTempEntFrame = ( gTempEntFrame + 1 ) & 31; @@ -623,7 +623,7 @@ void DLLEXPORT HUD_TempEntUpdate ( } pprev = NULL; - freq = client_time * 0.01; + //freq = client_time * 0.01; fastFreq = client_time * 5.5; gravity = -frametime * cl_gravity; gravitySlow = gravity * 0.5; @@ -709,12 +709,12 @@ void DLLEXPORT HUD_TempEntUpdate ( } else if( pTemp->flags & FTENT_SPIRAL ) { - float s, c; + /*float s, c; s = sin( pTemp->entity.baseline.origin[2] + fastFreq ); - c = cos( pTemp->entity.baseline.origin[2] + fastFreq ); + c = cos( pTemp->entity.baseline.origin[2] + fastFreq );*/ - pTemp->entity.origin[0] += pTemp->entity.baseline.origin[0] * frametime + 8 * sin( client_time * 20 + (int)(size_t)pTemp ); - pTemp->entity.origin[1] += pTemp->entity.baseline.origin[1] * frametime + 4 * sin( client_time * 30 + (int)(size_t)pTemp ); + pTemp->entity.origin[0] += pTemp->entity.baseline.origin[0] * frametime + 8 * sin( client_time * 20 + (size_t)pTemp ); + pTemp->entity.origin[1] += pTemp->entity.baseline.origin[1] * frametime + 4 * sin( client_time * 30 + (size_t)pTemp ); pTemp->entity.origin[2] += pTemp->entity.baseline.origin[2] * frametime; } else diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 9787a839..787e1be8 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -94,7 +94,7 @@ float EV_HLDM_PlayTextureSound( int idx, pmtrace_t *ptr, float *vecSrc, float *v char chTextureType = CHAR_TEX_CONCRETE; float fvol; float fvolbar; - char *rgsz[4]; + const char *rgsz[4]; int cnt; float fattn = ATTN_NORM; int entity; @@ -568,7 +568,7 @@ void EV_FireShotGunDouble( event_args_t *args ) vec3_t vecSrc, vecAiming; vec3_t vecSpread; vec3_t up, right, forward; - float flSpread = 0.01; + //float flSpread = 0.01; idx = args->entindex; VectorCopy( args->origin, origin ); @@ -622,7 +622,7 @@ void EV_FireShotGunSingle( event_args_t *args ) vec3_t vecSrc, vecAiming; vec3_t vecSpread; vec3_t up, right, forward; - float flSpread = 0.01; + //float flSpread = 0.01; idx = args->entindex; VectorCopy( args->origin, origin ); @@ -679,7 +679,7 @@ void EV_FireMP5( event_args_t *args ) int shell; vec3_t vecSrc, vecAiming; vec3_t up, right, forward; - float flSpread = 0.01; + //float flSpread = 0.01; idx = args->entindex; VectorCopy( args->origin, origin ); @@ -769,7 +769,7 @@ void EV_FirePython( event_args_t *args ) vec3_t vecSrc, vecAiming; vec3_t up, right, forward; - float flSpread = 0.01; + //float flSpread = 0.01; idx = args->entindex; VectorCopy( args->origin, origin ); @@ -860,16 +860,16 @@ void EV_FireGauss( event_args_t *args ) vec3_t angles; vec3_t velocity; float flDamage = args->fparam1; - int primaryfire = args->bparam1; + //int primaryfire = args->bparam1; int m_fPrimaryFire = args->bparam1; - int m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME; + //int m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME; vec3_t vecSrc; vec3_t vecDest; - edict_t *pentIgnore; + //edict_t *pentIgnore; pmtrace_t tr, beam_tr; float flMaxFrac = 1.0; - int nTotal = 0; + //int nTotal = 0; int fHasPunched = 0; int fFirstBeam = 1; int nMaxHits = 10; @@ -980,7 +980,7 @@ void EV_FireGauss( event_args_t *args ) { float n; - pentIgnore = NULL; + //pentIgnore = NULL; n = -DotProduct( tr.plane.normal, forward ); @@ -1412,12 +1412,12 @@ BEAM *pBeam2; void EV_EgonFire( event_args_t *args ) { - int idx, iFireState, iFireMode; + int idx, /*iFireState,*/ iFireMode; vec3_t origin; idx = args->entindex; VectorCopy( args->origin, origin ); - iFireState = args->iparam1; + //iFireState = args->iparam1; iFireMode = args->iparam2; int iStartup = args->bparam1; @@ -1539,13 +1539,13 @@ enum hgun_e void EV_HornetGunFire( event_args_t *args ) { - int idx, iFireMode; + int idx; //, iFireMode; vec3_t origin, angles, vecSrc, forward, right, up; idx = args->entindex; VectorCopy( args->origin, origin ); VectorCopy( args->angles, angles ); - iFireMode = args->iparam1; + //iFireMode = args->iparam1; //Only play the weapon anims if I shot it. if( EV_IsLocal( idx ) ) @@ -1554,7 +1554,7 @@ void EV_HornetGunFire( event_args_t *args ) gEngfuncs.pEventAPI->EV_WeaponAnimation( HGUN_SHOOT, 1 ); } - switch( gEngfuncs.pfnRandomLong( 0 , 2 ) ) + switch( gEngfuncs.pfnRandomLong( 0, 2 ) ) { case 0: gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "agrunt/ag_fire1.wav", 1, ATTN_NORM, 0, 100 ); diff --git a/cl_dll/geiger.cpp b/cl_dll/geiger.cpp index 7ccaf1d3..097889b9 100644 --- a/cl_dll/geiger.cpp +++ b/cl_dll/geiger.cpp @@ -65,7 +65,7 @@ int CHudGeiger::Draw( float flTime ) { int pct; float flvol = 0.0f; - int rg[3]; + //int rg[3]; int i; if( m_iGeigerRange < 1000 && m_iGeigerRange > 0 ) @@ -79,61 +79,61 @@ int CHudGeiger::Draw( float flTime ) { pct = 2; flvol = 0.4; //Con_Printf( "range > 600\n" ); - rg[0] = 1; - rg[1] = 1; + //rg[0] = 1; + //rg[1] = 1; i = 2; } else if( m_iGeigerRange > 500 ) { pct = 4; flvol = 0.5; //Con_Printf( "range > 500\n" ); - rg[0] = 1; - rg[1] = 2; + //rg[0] = 1; + //rg[1] = 2; i = 2; } else if( m_iGeigerRange > 400 ) { pct = 8; flvol = 0.6; //Con_Printf( "range > 400\n" ); - rg[0] = 1; - rg[1] = 2; - rg[2] = 3; + //rg[0] = 1; + //rg[1] = 2; + //rg[2] = 3; i = 3; } else if( m_iGeigerRange > 300 ) { pct = 8; flvol = 0.7; //Con_Printf( "range > 300\n" ); - rg[0] = 2; - rg[1] = 3; - rg[2] = 4; + //rg[0] = 2; + //rg[1] = 3; + //rg[2] = 4; i = 3; } else if( m_iGeigerRange > 200 ) { pct = 28; flvol = 0.78; //Con_Printf( "range > 200\n" ); - rg[0] = 2; - rg[1] = 3; - rg[2] = 4; + //rg[0] = 2; + //rg[1] = 3; + //rg[2] = 4; i = 3; } else if( m_iGeigerRange > 150 ) { pct = 40; flvol = 0.80; //Con_Printf( "range > 150\n" ); - rg[0] = 3; - rg[1] = 4; - rg[2] = 5; + //rg[0] = 3; + //rg[1] = 4; + //rg[2] = 5; i = 3; } else if( m_iGeigerRange > 100 ) { pct = 60; flvol = 0.85; //Con_Printf( "range > 100\n" ); - rg[0] = 3; - rg[1] = 4; - rg[2] = 5; + //rg[0] = 3; + //rg[1] = 4; + //rg[2] = 5; i = 3; } else if( m_iGeigerRange > 75 ) @@ -141,29 +141,29 @@ int CHudGeiger::Draw( float flTime ) pct = 80; flvol = 0.9; //Con_Printf( "range > 75\n" ); //gflGeigerDelay = cl.time + GEIGERDELAY * 0.75; - rg[0] = 4; - rg[1] = 5; - rg[2] = 6; + //rg[0] = 4; + //rg[1] = 5; + //rg[2] = 6; i = 3; } else if( m_iGeigerRange > 50 ) { pct = 90; flvol = 0.95; //Con_Printf( "range > 50\n" ); - rg[0] = 5; - rg[1] = 6; + //rg[0] = 5; + //rg[1] = 6; i = 2; } else { pct = 95; flvol = 1.0; //Con_Printf( "range < 50\n" ); - rg[0] = 5; - rg[1] = 6; + //rg[0] = 5; + //rg[1] = 6; i = 2; } - flvol = ( flvol * ( (rand() & 127) ) / 255) + 0.25; // UTIL_RandomFloat(0.25, 0.5); + flvol = ( flvol * ( ( rand() & 127 ) ) / 255 ) + 0.25; // UTIL_RandomFloat( 0.25, 0.5 ); if( ( rand() & 127 ) < pct || ( rand() & 127 ) < pct ) { diff --git a/cl_dll/hl/hl_baseentity.cpp b/cl_dll/hl/hl_baseentity.cpp index fc306838..d24c0ef4 100644 --- a/cl_dll/hl/hl_baseentity.cpp +++ b/cl_dll/hl/hl_baseentity.cpp @@ -54,7 +54,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 @@ -146,7 +146,7 @@ int CBaseMonster::CheckEnemy( CBaseEntity *pEnemy ) { return 0; } void CBaseMonster::PushEnemy( CBaseEntity *pEnemy, Vector &vecLastKnownPos ) { } BOOL CBaseMonster::PopEnemy() { return FALSE; } void CBaseMonster::SetActivity( Activity NewActivity ) { } -void CBaseMonster::SetSequenceByName( char *szSequence ) { } +void CBaseMonster::SetSequenceByName( const char *szSequence ) { } int CBaseMonster::CheckLocalMove( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist ) { return 0; } float CBaseMonster::OpenDoorAndWait( entvars_t *pevDoor ) { return 0.0; } void CBaseMonster::AdvanceRoute( float distance ) { } @@ -214,7 +214,7 @@ void CBaseMonster::MonsterInitDead( void ) { } BOOL CBaseMonster::BBoxFlat( void ) { return TRUE; } BOOL CBaseMonster::GetEnemy( void ) { return FALSE; } void CBaseMonster::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { } -CBaseEntity* CBaseMonster::DropItem( char *pszItemName, const Vector &vecPos, const Vector &vecAng ) { return NULL; } +CBaseEntity* CBaseMonster::DropItem( const char *pszItemName, const Vector &vecPos, const Vector &vecAng ) { return NULL; } BOOL CBaseMonster::ShouldFadeOnDeath( void ) { return FALSE; } void CBaseMonster::RadiusDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { } void CBaseMonster::RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { } @@ -258,8 +258,8 @@ void CBasePlayer::PreThink(void) { } void CBasePlayer::CheckTimeBasedDamage() { } void CBasePlayer::UpdateGeigerCounter( void ) { } void CBasePlayer::CheckSuitUpdate() { } -void CBasePlayer::SetSuitUpdate(char *name, int fgroup, int iNoRepeatTime) { } -void CBasePlayer::UpdatePlayerSound ( void ) { } +void CBasePlayer::SetSuitUpdate( const char *name, int fgroup, int iNoRepeatTime ) { } +void CBasePlayer::UpdatePlayerSound( void ) { } void CBasePlayer::PostThink() { } void CBasePlayer::Precache( void ) { } int CBasePlayer::Save( CSave &save ) { return 0; } @@ -298,7 +298,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/cl_dll/hl/hl_weapons.cpp b/cl_dll/hl/hl_weapons.cpp index 8c6909e3..8f8baea7 100644 --- a/cl_dll/hl/hl_weapons.cpp +++ b/cl_dll/hl/hl_weapons.cpp @@ -75,7 +75,7 @@ AlertMessage Print debug messages to console ====================== */ -void AlertMessage( ALERT_TYPE atype, char *szFmt, ... ) +void AlertMessage( ALERT_TYPE atype, const char *szFmt, ... ) { va_list argptr; static char string[1024]; @@ -96,7 +96,7 @@ bool bIsMultiplayer( void ) } //Just loads a v_ model. -void LoadVModel( char *szViewModel, CBasePlayer *m_pPlayer ) +void LoadVModel( const char *szViewModel, CBasePlayer *m_pPlayer ) { gEngfuncs.CL_LoadModel( szViewModel, &m_pPlayer->pev->viewmodel ); } @@ -208,7 +208,7 @@ CBasePlayerWeapon::DefaultDeploy ===================== */ -BOOL CBasePlayerWeapon::DefaultDeploy( char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal, int body ) +BOOL CBasePlayerWeapon::DefaultDeploy( const char *szViewModel, const char *szWeaponModel, int iAnim, const char *szAnimExt, int skiplocal, int body ) { if( !CanDeploy() ) return FALSE; @@ -288,7 +288,7 @@ Only produces random numbers to match the server ones. */ Vector CBaseEntity::FireBulletsPlayer ( ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker, int shared_rand ) { - float x = 0, y = 0, z; + float x = 0.0f, y = 0.0f, z; for( ULONG iShot = 1; iShot <= cShots; iShot++ ) { diff --git a/cl_dll/hud.h b/cl_dll/hud.h index ec236003..ab179bbb 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -480,7 +480,7 @@ public: int Init( void ); static char *LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size ); static char *BufferedLocaliseTextString( const char *msg ); - char *LookupString( const char *msg_name, int *msg_dest = NULL ); + const char *LookupString( const char *msg_name, int *msg_dest = NULL ); int MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf ); }; @@ -541,8 +541,8 @@ public: //had to make these public so CHud could access them (to enable concussion icon) //could use a friend declaration instead... - void EnableIcon( char *pszIconName, unsigned char red, unsigned char green, unsigned char blue ); - void DisableIcon( char *pszIconName ); + void EnableIcon( const char *pszIconName, unsigned char red, unsigned char green, unsigned char blue ); + void DisableIcon( const char *pszIconName ); private: typedef struct @@ -588,11 +588,11 @@ public: int m_iFontHeight; int DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g, int b ); - int DrawHudString( int x, int y, int iMaxX, char *szString, int r, int g, int b ); - int DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b ); + int DrawHudString( int x, int y, int iMaxX, const char *szString, int r, int g, int b ); + int DrawHudStringReverse( int xpos, int ypos, int iMinX, const char *szString, int r, int g, int b ); int DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b ); int GetNumWidth( int iNumber, int iFlags ); - int DrawHudStringLen( char *szIt ); + int DrawHudStringLen( const char *szIt ); void DrawDarkRectangle( int x, int y, int wide, int tall ); private: diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index c30df36d..5182b484 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -199,7 +199,7 @@ const unsigned char colors[8][3] = {240, 180, 24} }; -int CHud::DrawHudString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b ) +int CHud::DrawHudString( int xpos, int ypos, int iMaxX, const char *szIt, int r, int g, int b ) { if( hud_textmode->value == 2 ) { @@ -233,9 +233,7 @@ int CHud::DrawHudString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g return xpos; } - - -int DrawUtfString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b ) +int DrawUtfString( int xpos, int ypos, int iMaxX, const char *szIt, int r, int g, int b ) { // xash3d: reset unicode state gEngfuncs.pfnVGUI2DrawCharacterAdditive( 0, 0, 0, 0, 0, 0, 0 ); @@ -262,7 +260,7 @@ int DrawUtfString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int return xpos; } -int CHud::DrawHudStringLen( char *szIt ) +int CHud::DrawHudStringLen( const char *szIt ) { int l = 0; for( ; *szIt != 0 && *szIt != '\n'; szIt++ ) @@ -280,7 +278,7 @@ int CHud::DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r } // draws a string from right to left (right-aligned) -int CHud::DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b ) +int CHud::DrawHudStringReverse( int xpos, int ypos, int iMinX, const char *szString, int r, int g, int b ) { // find the end of the string for( char *szIt = szString; *szIt != 0; szIt++ ) diff --git a/cl_dll/message.cpp b/cl_dll/message.cpp index 5d52d413..ff8d97bf 100644 --- a/cl_dll/message.cpp +++ b/cl_dll/message.cpp @@ -29,7 +29,7 @@ DECLARE_MESSAGE( m_Message, GameTitle ) // 1 Global client_textmessage_t for custom messages that aren't in the titles.txt client_textmessage_t g_pCustomMessage; -char *g_pCustomName = "Custom"; +const char *g_pCustomName = "Custom"; char g_pCustomText[1024]; int CHudMessage::Init( void ) @@ -260,7 +260,7 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time ) width = 0; } else - width += gHUD.m_scrinfo.charWidths[*pText]; + width += gHUD.m_scrinfo.charWidths[(unsigned char)*pText]; pText++; length++; } @@ -310,7 +310,7 @@ int CHudMessage::Draw( float fTime ) { int i, drawn; client_textmessage_t *pMessage; - float endTime = 0; + float endTime = 0.0f; drawn = 0; diff --git a/cl_dll/status_icons.cpp b/cl_dll/status_icons.cpp index c960d5ef..4b2d9726 100644 --- a/cl_dll/status_icons.cpp +++ b/cl_dll/status_icons.cpp @@ -104,7 +104,7 @@ int CHudStatusIcons::MsgFunc_StatusIcon( const char *pszName, int iSize, void *p } // add the icon to the icon list, and set it's drawing color -void CHudStatusIcons::EnableIcon( char *pszIconName, unsigned char red, unsigned char green, unsigned char blue ) +void CHudStatusIcons::EnableIcon( const char *pszIconName, unsigned char red, unsigned char green, unsigned char blue ) { int i; @@ -149,7 +149,7 @@ void CHudStatusIcons::EnableIcon( char *pszIconName, unsigned char red, unsigned } } -void CHudStatusIcons::DisableIcon( char *pszIconName ) +void CHudStatusIcons::DisableIcon( const char *pszIconName ) { // find the sprite is in the current list for( int i = 0; i < MAX_ICONSPRITES; i++ ) diff --git a/cl_dll/text_message.cpp b/cl_dll/text_message.cpp index af62a915..13b62577 100644 --- a/cl_dll/text_message.cpp +++ b/cl_dll/text_message.cpp @@ -45,7 +45,7 @@ int CHudTextMessage::Init( void ) char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size ) { char *dst = dst_buffer; - for( char *src = (char*)msg; *src != 0 && buffer_size > 0; buffer_size-- ) + for( char *src = msg; *src != 0 && buffer_size > 0; buffer_size-- ) { if( *src == '#' ) { @@ -91,12 +91,12 @@ char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, in char *CHudTextMessage::BufferedLocaliseTextString( const char *msg ) { static char dst_buffer[1024]; - LocaliseTextString( msg, dst_buffer, 1024 ); + LocaliseTextString( msg, dst_buffer, sizeof(dst_buffer) ); return dst_buffer; } // Simplified version of LocaliseTextString; assumes string is only one word -char *CHudTextMessage::LookupString( const char *msg, int *msg_dest ) +const char *CHudTextMessage::LookupString( const char *msg, int *msg_dest ) { if( !msg ) return ""; @@ -108,7 +108,7 @@ char *CHudTextMessage::LookupString( const char *msg, int *msg_dest ) client_textmessage_t *clmsg = TextMessageGet( msg + 1 ); if( !clmsg || !(clmsg->pMessage) ) - return (char*)msg; // lookup failed, so return the original string + return msg; // lookup failed, so return the original string if( msg_dest ) { @@ -118,12 +118,12 @@ char *CHudTextMessage::LookupString( const char *msg, int *msg_dest ) *msg_dest = -clmsg->effect; } - return (char*)clmsg->pMessage; + return clmsg->pMessage; } else { // nothing special about this message, so just return the same string - return (char*)msg; + return msg; } } @@ -167,16 +167,16 @@ int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf msg_text = strcpy( szBuf[0], msg_text ); // keep reading strings and using C format strings for subsituting the strings into the localised text string - char *sstr1 = LookupString( READ_STRING() ); + const char *sstr1 = LookupString( READ_STRING() ); sstr1 = strcpy( szBuf[1], sstr1 ); StripEndNewlineFromString( sstr1 ); // these strings are meant for subsitution into the main strings, so cull the automatic end newlines - char *sstr2 = LookupString( READ_STRING() ); + const char *sstr2 = LookupString( READ_STRING() ); sstr2 = strcpy( szBuf[2], sstr2 ); StripEndNewlineFromString( sstr2 ); - char *sstr3 = LookupString( READ_STRING() ); + const char *sstr3 = LookupString( READ_STRING() ); sstr3 = strcpy( szBuf[3], sstr3 ); StripEndNewlineFromString( sstr3 ); - char *sstr4 = LookupString( READ_STRING() ); + const char *sstr4 = LookupString( READ_STRING() ); sstr4 = strcpy( szBuf[4], sstr4 ); StripEndNewlineFromString( sstr4 ); char *psz = szBuf[5]; diff --git a/cl_dll/view.cpp b/cl_dll/view.cpp index b581cc82..dcd2b1af 100644 --- a/cl_dll/view.cpp +++ b/cl_dll/view.cpp @@ -351,11 +351,11 @@ V_CalcIntermissionRefdef */ void V_CalcIntermissionRefdef( struct ref_params_s *pparams ) { - cl_entity_t *ent, *view; + cl_entity_t /**ent,*/ *view; float old; // ent is the player model ( visible when out of body ) - ent = gEngfuncs.GetLocalPlayer(); + //ent = gEngfuncs.GetLocalPlayer(); // view is the weapon model (only visible from inside body ) view = gEngfuncs.GetViewModel(); @@ -1307,7 +1307,7 @@ void V_GetMapChasePosition( int target, float *cl_angles, float *origin, float * int V_FindViewModelByWeaponModel( int weaponindex ) { - static char *modelmap[][2] = + static const char *modelmap[][2] = { { "models/p_crossbow.mdl", "models/v_crossbow.mdl" }, { "models/p_crowbar.mdl", "models/v_crowbar.mdl" }, @@ -1327,7 +1327,7 @@ int V_FindViewModelByWeaponModel( int weaponindex ) { NULL, NULL } }; - struct model_s * weaponModel = IEngineStudio.GetModelByIndex( weaponindex ); + struct model_s *weaponModel = IEngineStudio.GetModelByIndex( weaponindex ); if( weaponModel ) { diff --git a/common/cvardef.h b/common/cvardef.h index c57b97a7..e8a24581 100644 --- a/common/cvardef.h +++ b/common/cvardef.h @@ -28,8 +28,8 @@ typedef struct cvar_s { - char *name; - char *string; + const char *name; + const char *string; int flags; float value; struct cvar_s *next; diff --git a/dlls/activity.h b/dlls/activity.h index 58b2d8cd..5382d70d 100644 --- a/dlls/activity.h +++ b/dlls/activity.h @@ -99,7 +99,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/activitymap.h b/dlls/activitymap.h index 92cadae7..5f77c55a 100644 --- a/dlls/activitymap.h +++ b/dlls/activitymap.h @@ -93,5 +93,5 @@ _A( ACT_FLINCH_LEFTARM ), _A( ACT_FLINCH_RIGHTARM ), _A( ACT_FLINCH_LEFTLEG ), _A( ACT_FLINCH_RIGHTLEG ), -0, NULL +{ 0, NULL } }; diff --git a/dlls/aflock.cpp b/dlls/aflock.cpp index 1e317632..19998a9d 100644 --- a/dlls/aflock.cpp +++ b/dlls/aflock.cpp @@ -567,7 +567,6 @@ void CFlockingFlyer::FlockLeaderThink( void ) TraceResult tr; Vector vecDist;// used for general measurements Vector vecDir;// used for general measurements - int cProcessed = 0;// keep track of how many other boids we've processed float flLeftSide; float flRightSide; diff --git a/dlls/agrunt.cpp b/dlls/agrunt.cpp index 97804f68..c6583fb7 100644 --- a/dlls/agrunt.cpp +++ b/dlls/agrunt.cpp @@ -608,7 +608,7 @@ void CAGrunt::Spawn() //========================================================= void CAGrunt::Precache() { - int i; + size_t i; PRECACHE_MODEL( "models/agrunt.mdl" ); @@ -909,7 +909,7 @@ BOOL CAGrunt::FCanCheckAttacks( void ) //========================================================= BOOL CAGrunt::CheckMeleeAttack1( float flDot, float flDist ) { - if( HasConditions( bits_COND_SEE_ENEMY ) && flDist <= AGRUNT_MELEE_DIST && flDot >= 0.6 && m_hEnemy != NULL ) + if( HasConditions( bits_COND_SEE_ENEMY ) && flDist <= AGRUNT_MELEE_DIST && flDot >= 0.6 && m_hEnemy != 0 ) { return TRUE; } @@ -1160,7 +1160,7 @@ Schedule_t *CAGrunt::GetScheduleOfType( int Type ) case SCHED_FAIL: // no fail schedule specified, so pick a good generic one. { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { // I have an enemy // !!!LATER - what if this enemy is really far away and i'm chasing him? diff --git a/dlls/animation.cpp b/dlls/animation.cpp index 86cb78ae..5454f0e8 100644 --- a/dlls/animation.cpp +++ b/dlls/animation.cpp @@ -268,8 +268,6 @@ int GetAnimationEvent( void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEve if( !pstudiohdr || pev->sequence >= pstudiohdr->numseq || !pMonsterEvent ) return 0; - int events = 0; - mstudioseqdesc_t *pseqdesc; mstudioevent_t *pevent; @@ -351,7 +349,7 @@ float SetController( void *pmodel, entvars_t *pev, int iController, float flValu } } - int setting = 255 * ( flValue - pbonecontroller->start ) / ( pbonecontroller->end - pbonecontroller->start ); + int setting = (int)( 255 * ( flValue - pbonecontroller->start ) / ( pbonecontroller->end - pbonecontroller->start ) ); if( setting < 0 ) setting = 0; @@ -393,7 +391,7 @@ float SetBlending( void *pmodel, entvars_t *pev, int iBlender, float flValue ) } } - int setting = 255 * ( flValue - pseqdesc->blendstart[iBlender] ) / ( pseqdesc->blendend[iBlender] - pseqdesc->blendstart[iBlender] ); + int setting = (int)( 255 * ( flValue - pseqdesc->blendstart[iBlender] ) / ( pseqdesc->blendend[iBlender] - pseqdesc->blendstart[iBlender] ) ); if( setting < 0 ) setting = 0; diff --git a/dlls/apache.cpp b/dlls/apache.cpp index b64a8bae..aeeea30e 100644 --- a/dlls/apache.cpp +++ b/dlls/apache.cpp @@ -458,7 +458,7 @@ void CApache::HuntThink( void ) if( m_flGoalSpeed < 800 ) m_flGoalSpeed += 5; - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { // ALERT( at_console, "%s\n", STRING( m_hEnemy->pev->classname ) ); if( FVisible( m_hEnemy ) ) @@ -552,7 +552,7 @@ void CApache::HuntThink( void ) { if( m_flLastSeen + 60 > gpGlobals->time ) { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { // make sure it's a good shot if( DotProduct( m_vecTarget, vecEst ) > .965 ) @@ -732,7 +732,6 @@ void CApache::Flight( void ) void CApache::FireRocket( void ) { static float side = 1.0; - static int count; if( m_iRockets <= 0 ) return; diff --git a/dlls/barnacle.cpp b/dlls/barnacle.cpp index 1e2aa785..ecc1f5d4 100644 --- a/dlls/barnacle.cpp +++ b/dlls/barnacle.cpp @@ -170,7 +170,7 @@ void CBarnacle::BarnacleThink( void ) #endif pev->nextthink = gpGlobals->time + 0.1; - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { // barnacle has prey. if( !m_hEnemy->IsAlive() ) @@ -183,7 +183,7 @@ void CBarnacle::BarnacleThink( void ) if( m_fLiftingPrey ) { - if( m_hEnemy != NULL && m_hEnemy->pev->deadflag != DEAD_NO ) + if( m_hEnemy != 0 && m_hEnemy->pev->deadflag != DEAD_NO ) { // crap, someone killed the prey on the way up. m_hEnemy = NULL; @@ -352,7 +352,7 @@ void CBarnacle::Killed( entvars_t *pevAttacker, int iGib ) pev->solid = SOLID_NOT; pev->takedamage = DAMAGE_NO; - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { pVictim = m_hEnemy->MyMonsterPointer(); diff --git a/dlls/barney.cpp b/dlls/barney.cpp index b1c97090..3fc5aef0 100644 --- a/dlls/barney.cpp +++ b/dlls/barney.cpp @@ -221,7 +221,7 @@ void CBarney::RunTask( Task_t *pTask ) switch( pTask->iTask ) { case TASK_RANGE_ATTACK1: - if( m_hEnemy != NULL && ( m_hEnemy->IsPlayer() ) ) + if( m_hEnemy != 0 && ( m_hEnemy->IsPlayer() ) ) { pev->framerate = 1.5; } @@ -262,7 +262,7 @@ int CBarney::Classify( void ) //========================================================= void CBarney::AlertSound( void ) { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( FOkToSpeak() ) { @@ -504,7 +504,7 @@ int CBarney::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float // This is a heurstic to determine if the player intended to harm me // If I have an enemy, we can't establish intent (may just be crossfire) - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { // If the player was facing directly at me, or I'm already suspicious, get mad if( ( m_afMemory & bits_MEMORY_SUSPICIOUS ) || IsFacing( pevAttacker, pev->origin ) ) @@ -616,7 +616,7 @@ void CBarney::Killed( entvars_t *pevAttacker, int iGib ) GetAttachment( 0, vecGunPos, vecGunAngles ); - CBaseEntity *pGun = DropItem( "weapon_9mmhandgun", vecGunPos, vecGunAngles ); + DropItem( "weapon_9mmhandgun", vecGunPos, vecGunAngles ); } SetUse( NULL ); @@ -633,7 +633,7 @@ Schedule_t *CBarney::GetScheduleOfType( int Type ) switch( Type ) { case SCHED_ARM_WEAPON: - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { // face enemy, then draw. return slBarneyEnemyDraw; @@ -721,7 +721,7 @@ Schedule_t *CBarney::GetSchedule( void ) return GetScheduleOfType( SCHED_SMALL_FLINCH ); } - if( m_hEnemy == NULL && IsFollowing() ) + if( m_hEnemy == 0 && IsFollowing() ) { if( !m_hTargetEnt->IsAlive() ) { @@ -783,10 +783,10 @@ public: void KeyValue( KeyValueData *pkvd ); int m_iPose;// which sequence to display -- temporary, don't need to save - static char *m_szPoses[3]; + static const char *m_szPoses[3]; }; -char *CDeadBarney::m_szPoses[] = { "lying_on_back", "lying_on_side", "lying_on_stomach" }; +const char *CDeadBarney::m_szPoses[] = { "lying_on_back", "lying_on_side", "lying_on_stomach" }; void CDeadBarney::KeyValue( KeyValueData *pkvd ) { diff --git a/dlls/basemonster.h b/dlls/basemonster.h index ad05fccf..0d22104f 100644 --- a/dlls/basemonster.h +++ b/dlls/basemonster.h @@ -195,7 +195,7 @@ public: Task_t *GetTask( void ); virtual MONSTERSTATE GetIdealState( void ); virtual void SetActivity( Activity NewActivity ); - void SetSequenceByName( char *szSequence ); + void SetSequenceByName( const char *szSequence ); void SetState( MONSTERSTATE State ); virtual void ReportAIState( void ); @@ -327,6 +327,6 @@ public: BOOL ExitScriptedSequence(); BOOL CineCleanup(); - CBaseEntity* DropItem ( char *pszItemName, const Vector &vecPos, const Vector &vecAng );// drop an item. + CBaseEntity* DropItem( const char *pszItemName, const Vector &vecPos, const Vector &vecAng );// drop an item. }; #endif // BASEMONSTER_H diff --git a/dlls/bigmomma.cpp b/dlls/bigmomma.cpp index 59f6cae2..a038c776 100644 --- a/dlls/bigmomma.cpp +++ b/dlls/bigmomma.cpp @@ -677,7 +677,7 @@ void CBigMomma::Precache() void CBigMomma::Activate( void ) { - if( m_hTargetEnt == NULL ) + if( m_hTargetEnt == 0 ) Remember( bits_MEMORY_ADVANCE_NODE ); // Start 'er up } @@ -985,7 +985,7 @@ void CBigMomma::RunTask( Task_t *pTask ) { float distance; - if( m_hTargetEnt == NULL ) + if( m_hTargetEnt == 0 ) TaskFail(); else { @@ -1002,7 +1002,7 @@ void CBigMomma::RunTask( Task_t *pTask ) } break; case TASK_WAIT_NODE: - if( m_hTargetEnt != NULL && ( m_hTargetEnt->pev->spawnflags & SF_INFOBM_WAIT ) ) + if( m_hTargetEnt != 0 && ( m_hTargetEnt->pev->spawnflags & SF_INFOBM_WAIT ) ) return; if( gpGlobals->time > m_flWaitFinished ) @@ -1056,7 +1056,6 @@ Vector VecCheckSplatToss( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot float time = speed / flGravity; vecGrenadeVel = vecSpot2 - vecSpot1; vecGrenadeVel.z = 0; - float distance = vecGrenadeVel.Length(); // Travel half the distance to the target in that time (apex is at the midpoint) vecGrenadeVel = vecGrenadeVel * ( 0.5 / time ); diff --git a/dlls/bmodels.cpp b/dlls/bmodels.cpp index ee676679..6e8526f9 100644 --- a/dlls/bmodels.cpp +++ b/dlls/bmodels.cpp @@ -210,7 +210,7 @@ void CFuncIllusionary::KeyValue( KeyValueData *pkvd ) { if( FStrEq( pkvd->szKeyName, "skin" ) )//skin is used for content type { - pev->skin = atof( pkvd->szValue ); + pev->skin = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -614,7 +614,7 @@ void CFuncRotating::SpinDown( void ) // stop sound, we're done EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning /* Stop */ ), - 0, 0, SND_STOP, m_pitch ); + 0, 0, SND_STOP, (int)m_pitch ); SetThink( &CFuncRotating::Rotate ); Rotate(); diff --git a/dlls/bullsquid.cpp b/dlls/bullsquid.cpp index 18026b43..af3ab88a 100644 --- a/dlls/bullsquid.cpp +++ b/dlls/bullsquid.cpp @@ -248,7 +248,7 @@ int CBullsquid::IgnoreConditions( void ) iIgnore = bits_COND_SMELL | bits_COND_SMELL_FOOD; } - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( FClassnameIs( m_hEnemy->pev, "monster_headcrab" ) ) { @@ -287,7 +287,7 @@ int CBullsquid::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, flo // if the squid is running, has an enemy, was hurt by the enemy, hasn't been hurt in the last 3 seconds, and isn't too close to the enemy, // it will swerve. (whew). - if( m_hEnemy != NULL && IsMoving() && pevAttacker == m_hEnemy->pev && gpGlobals->time - m_flLastHurtTime > 3 ) + if( m_hEnemy != 0 && IsMoving() && pevAttacker == m_hEnemy->pev && gpGlobals->time - m_flLastHurtTime > 3 ) { flDist = ( pev->origin - m_hEnemy->pev->origin ).Length2D(); @@ -324,7 +324,7 @@ BOOL CBullsquid::CheckRangeAttack1( float flDot, float flDist ) if( flDist > 64 && flDist <= 784 && flDot >= 0.5 && gpGlobals->time >= m_flNextSpitTime ) { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( fabs( pev->origin.z - m_hEnemy->pev->origin.z ) > 256 ) { @@ -383,7 +383,7 @@ BOOL CBullsquid::CheckMeleeAttack2( float flDot, float flDist ) //========================================================= BOOL CBullsquid::FValidateHintType( short sHint ) { - int i; + size_t i; static short sSquidHints[] = { @@ -784,7 +784,7 @@ void CBullsquid::RunAI( void ) pev->skin = 1; } - if( m_hEnemy != NULL && m_Activity == ACT_RUN ) + if( m_hEnemy != 0 && m_Activity == ACT_RUN ) { // chasing enemy. Sprint for last bit if( ( pev->origin - m_hEnemy->pev->origin).Length2D() < SQUID_SPRINT_DIST ) @@ -1247,7 +1247,7 @@ MONSTERSTATE CBullsquid::GetIdealState( void ) COMBAT goes to ALERT upon death of enemy */ { - if( m_hEnemy != NULL && ( iConditions & bits_COND_LIGHT_DAMAGE || iConditions & bits_COND_HEAVY_DAMAGE ) && FClassnameIs( m_hEnemy->pev, "monster_headcrab" ) ) + if( m_hEnemy != 0 && ( iConditions & bits_COND_LIGHT_DAMAGE || iConditions & bits_COND_HEAVY_DAMAGE ) && FClassnameIs( m_hEnemy->pev, "monster_headcrab" ) ) { // if the squid has a headcrab enemy and something hurts it, it's going to forget about the crab for a while. m_hEnemy = NULL; diff --git a/dlls/buttons.cpp b/dlls/buttons.cpp index 3027f10e..76f4ad91 100644 --- a/dlls/buttons.cpp +++ b/dlls/buttons.cpp @@ -275,7 +275,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 { @@ -381,22 +381,22 @@ void CBaseButton::KeyValue( KeyValueData *pkvd ) } else if( FStrEq( pkvd->szKeyName, "locked_sound" ) ) { - m_bLockedSound = atof( pkvd->szValue ); + m_bLockedSound = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "locked_sentence" ) ) { - m_bLockedSentence = atof( pkvd->szValue ); + m_bLockedSentence = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "unlocked_sound" ) ) { - m_bUnlockedSound = atof( pkvd->szValue ); + m_bUnlockedSound = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "unlocked_sentence" ) ) { - m_bUnlockedSentence = atof( pkvd->szValue ); + m_bUnlockedSentence = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "sounds" ) ) @@ -421,7 +421,7 @@ int CBaseButton::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, fl SetTouch( NULL ); m_hActivator = CBaseEntity::Instance( pevAttacker ); - if( m_hActivator == NULL ) + if( m_hActivator == 0 ) return 0; if( code == BUTTON_RETURN ) @@ -461,7 +461,7 @@ LINK_ENTITY_TO_CLASS( func_button, CBaseButton ) void CBaseButton::Spawn() { - char *pszSound; + const char *pszSound; //---------------------------------------------------- //determine sounds for buttons @@ -527,7 +527,7 @@ void CBaseButton::Spawn() char *ButtonSound( int sound ) { - char *pszSound; + const char *pszSound; switch( sound ) { @@ -869,7 +869,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 @@ -1010,7 +1010,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 62b4eaa1..0cc10bdb 100644 --- a/dlls/cbase.cpp +++ b/dlls/cbase.cpp @@ -26,7 +26,7 @@ void EntvarsKeyvalue( entvars_t *pev, KeyValueData *pkvd ); extern "C" void PM_Move ( struct playermove_s *ppmove, int server ); extern "C" void PM_Init ( struct playermove_s *ppmove ); -extern "C" char PM_FindTextureType( char *name ); +extern "C" char PM_FindTextureType( const char *name ); extern Vector VecBModelOrigin( entvars_t* pevBModel ); extern DLL_GLOBAL Vector g_vecAttackDir; @@ -739,7 +739,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 617bbab9..6c738bf5 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -177,7 +177,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 ) {} @@ -314,7 +314,7 @@ public: // used by monsters that are created by the MonsterMaker virtual void UpdateOwner( void ) { return; }; - 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 ); }; @@ -655,8 +655,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 // // Generic Button diff --git a/dlls/client.cpp b/dlls/client.cpp index 72538b02..99f1913b 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -215,7 +215,7 @@ bool Q_IsValidUChar32( unsigned int uVal ) { // Values > 0x10FFFF are explicitly invalid; ditto for UTF-16 surrogate halves, // values ending in FFFE or FFFF, or values in the 0x00FDD0-0x00FDEF reserved range - return ( uVal < 0x110000u ) && ( ( uVal - 0x00D800u ) > 0x7FFu ) && ( ( uVal & 0xFFFFu ) < 0xFFFEu ) && ( ( uVal - 0x00FDD0u ) > 0x1Fu ); + return ( ( uVal - 0x0u ) < 0x110000u ) && ( (uVal - 0x00D800u) > 0x7FFu ) && ( (uVal & 0xFFFFu) < 0xFFFEu ) && ( ( uVal - 0x00FDD0u ) > 0x1Fu ); } // Decode one character from a UTF-8 encoded string. Treats 6-byte CESU-8 sequences @@ -423,7 +423,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 @@ -744,7 +744,6 @@ void PlayerPreThink( edict_t *pEntity ) { //ALERT( at_console, "PreThink( %g, frametime %g )\n", gpGlobals->time, gpGlobals->frametime ); - entvars_t *pev = &pEntity->v; CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE( pEntity ); if( pPlayer ) @@ -762,7 +761,6 @@ void PlayerPostThink( edict_t *pEntity ) { //ALERT( at_console, "PostThink( %g, frametime %g )\n", gpGlobals->time, gpGlobals->frametime ); - entvars_t *pev = &pEntity->v; CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE( pEntity ); if( pPlayer ) @@ -950,7 +948,6 @@ animation right now. */ void PlayerCustomization( edict_t *pEntity, customization_t *pCust ) { - entvars_t *pev = &pEntity->v; CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE( pEntity ); if( !pPlayer ) @@ -990,7 +987,6 @@ A spectator has joined the game */ void SpectatorConnect( edict_t *pEntity ) { - entvars_t *pev = &pEntity->v; CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE( pEntity ); if( pPlayer ) @@ -1006,7 +1002,6 @@ A spectator has left the game */ void SpectatorDisconnect( edict_t *pEntity ) { - entvars_t *pev = &pEntity->v; CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE( pEntity ); if( pPlayer ) @@ -1022,7 +1017,6 @@ A spectator has sent a usercmd */ void SpectatorThink( edict_t *pEntity ) { - entvars_t *pev = &pEntity->v; CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE( pEntity ); if( pPlayer ) @@ -1235,11 +1229,11 @@ int AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *h } state->rendermode = ent->v.rendermode; - state->renderamt = ent->v.renderamt; + state->renderamt = (int)ent->v.renderamt; state->renderfx = ent->v.renderfx; - state->rendercolor.r = ent->v.rendercolor.x; - state->rendercolor.g = ent->v.rendercolor.y; - state->rendercolor.b = ent->v.rendercolor.z; + state->rendercolor.r = (byte)ent->v.rendercolor.x; + state->rendercolor.g = (byte)ent->v.rendercolor.y; + state->rendercolor.b = (byte)ent->v.rendercolor.z; state->aiment = 0; if( ent->v.aiment ) @@ -1286,7 +1280,7 @@ int AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *h //state->team = ent->v.team; state->usehull = ( ent->v.flags & FL_DUCKING ) ? 1 : 0; - state->health = ent->v.health; + state->health = (int)ent->v.health; } return 1; @@ -1834,7 +1828,7 @@ ConnectionlessPacket int ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ) { // Parse stuff from args - int max_buffer_size = *response_buffer_size; + //int max_buffer_size = *response_buffer_size; // Zero it out since we aren't going to respond. // If we wanted to response, we'd write data into response_buffer @@ -1888,10 +1882,10 @@ to be created during play ( e.g., grenades, ammo packs, projectiles, corpses, et */ void CreateInstancedBaselines( void ) { - int iret = 0; + /*int iret = 0; entity_state_t state; - memset( &state, 0, sizeof(state) ); + memset( &state, 0, sizeof(state) );*/ // Create any additional baselines here for things like grendates, etc. // iret = ENGINE_INSTANCE_BASELINE( pc->pev->classname, &state ); diff --git a/dlls/combat.cpp b/dlls/combat.cpp index 3a59844f..d8830c20 100644 --- a/dlls/combat.cpp +++ b/dlls/combat.cpp @@ -460,11 +460,11 @@ Activity CBaseMonster::GetSmallFlinchActivity( void ) { Activity flinchActivity; BOOL fTriedDirection; - float flDot; + //float flDot; fTriedDirection = FALSE; UTIL_MakeVectors( pev->angles ); - flDot = DotProduct( gpGlobals->v_forward, g_vecAttackDir * -1 ); + //flDot = DotProduct( gpGlobals->v_forward, g_vecAttackDir * -1 ); switch( m_LastHitGroup ) { @@ -576,8 +576,8 @@ Killed */ void CBaseMonster::Killed( entvars_t *pevAttacker, int iGib ) { - unsigned int cCount = 0; - BOOL fDone = FALSE; + //unsigned int cCount = 0; + //BOOL fDone = FALSE; if( HasMemory( bits_MEMORY_KILLED ) ) { @@ -920,7 +920,7 @@ int CBaseMonster::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, f // enemy's last known position is somewhere down the vector that the attack came from. if( pevInflictor ) { - if( m_hEnemy == NULL || pevInflictor == m_hEnemy->pev || !HasConditions( bits_COND_SEE_ENEMY ) ) + if( m_hEnemy == 0 || pevInflictor == m_hEnemy->pev || !HasConditions( bits_COND_SEE_ENEMY ) ) { m_vecEnemyLKP = pevInflictor->origin; } @@ -1463,7 +1463,7 @@ void CBaseEntity::FireBullets( ULONG cShots, Vector vecSrc, Vector vecDirShootin } } // make bullet trails - UTIL_BubbleTrail( vecSrc, tr.vecEndPos, ( flDistance * tr.flFraction ) / 64.0 ); + UTIL_BubbleTrail( vecSrc, tr.vecEndPos, (int)( ( flDistance * tr.flFraction ) / 64.0 ); } ApplyMultiDamage( pev, pevAttacker ); } @@ -1483,7 +1483,8 @@ Vector CBaseEntity::FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDi TraceResult tr; Vector vecRight = gpGlobals->v_right; Vector vecUp = gpGlobals->v_up; - float x, y, z; + float x = 0.0f, y = 0.0f; + float z; if( pevAttacker == NULL ) pevAttacker = pev; // the default attacker is ourselves @@ -1497,7 +1498,7 @@ Vector CBaseEntity::FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDi // get circular gaussian spread x = UTIL_SharedRandomFloat( shared_rand + iShot, -0.5, 0.5 ) + UTIL_SharedRandomFloat( shared_rand + ( 1 + iShot ) , -0.5, 0.5 ); y = UTIL_SharedRandomFloat( shared_rand + ( 2 + iShot ), -0.5, 0.5 ) + UTIL_SharedRandomFloat( shared_rand + ( 3 + iShot ), -0.5, 0.5 ); - z = x * x + y * y; + //z = x * x + y * y; Vector vecDir = vecDirShooting + x * vecSpread.x * vecRight + @@ -1548,7 +1549,7 @@ Vector CBaseEntity::FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDi } } // make bullet trails - UTIL_BubbleTrail( vecSrc, tr.vecEndPos, ( flDistance * tr.flFraction ) / 64.0 ); + UTIL_BubbleTrail( vecSrc, tr.vecEndPos, (int)( ( flDistance * tr.flFraction ) / 64.0 ) ); } ApplyMultiDamage( pev, pevAttacker ); diff --git a/dlls/controller.cpp b/dlls/controller.cpp index 3d56325f..bfa119d3 100644 --- a/dlls/controller.cpp +++ b/dlls/controller.cpp @@ -614,7 +614,7 @@ void CController::RunTask( Task_t *pTask ) Vector vecSrc = vecHand + pev->velocity * ( m_flShootTime - gpGlobals->time ); Vector vecDir; - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( HasConditions( bits_COND_SEE_ENEMY ) ) { @@ -707,7 +707,7 @@ Schedule_t *CController::GetSchedule( void ) { case MONSTERSTATE_COMBAT: { - Vector vecTmp = Intersect( Vector( 0, 0, 0 ), Vector( 100, 4, 7 ), Vector( 2, 10, -3 ), 20.0 ); + // Vector vecTmp = Intersect( Vector( 0, 0, 0 ), Vector( 100, 4, 7 ), Vector( 2, 10, -3 ), 20.0 ); // dead enemy if( HasConditions( bits_COND_LIGHT_DAMAGE ) ) @@ -1095,7 +1095,6 @@ class CControllerHeadBall : public CBaseMonster void EXPORT BounceTouch( CBaseEntity *pOther ); void MovetoTarget( Vector vecTarget ); void Crawl( void ); - int m_iTrail; int m_flNextAttack; Vector m_vecIdeal; EHANDLE m_hOwner; @@ -1160,7 +1159,7 @@ void CControllerHeadBall::HuntThink( void ) MESSAGE_END(); // check world boundaries - if( gpGlobals->time - pev->dmgtime > 5 || pev->renderamt < 64 || m_hEnemy == NULL || m_hOwner == NULL || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096 ) + if( gpGlobals->time - pev->dmgtime > 5 || pev->renderamt < 64 || m_hEnemy == 0 || m_hOwner == 0 || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096 ) { SetTouch( NULL ); UTIL_Remove( this ); @@ -1340,7 +1339,7 @@ void CControllerZapBall::ExplodeTouch( CBaseEntity *pOther ) entvars_t *pevOwner; - if( m_hOwner != NULL ) + if( m_hOwner != 0 ) { pevOwner = m_hOwner->pev; } diff --git a/dlls/crossbow.cpp b/dlls/crossbow.cpp index 7a4686e7..d749c785 100644 --- a/dlls/crossbow.cpp +++ b/dlls/crossbow.cpp @@ -425,10 +425,11 @@ void CCrossbow::FireBolt() UTIL_MakeVectors( anglesAim ); anglesAim.x = -anglesAim.x; + +#ifndef CLIENT_DLL Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 2; Vector vecDir = gpGlobals->v_forward; -#ifndef CLIENT_DLL CCrossbowBolt *pBolt = CCrossbowBolt::BoltCreate(); pBolt->pev->origin = vecSrc; pBolt->pev->angles = anglesAim; diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index 80a18d65..00b16d57 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -183,7 +183,7 @@ int CCrowbar::Swing( int fFirst ) #endif PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usCrowbar, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0, - 0.0, 0, 0.0 ); + 0, 0, 0 ); if( tr.flFraction >= 1.0 ) { @@ -294,7 +294,7 @@ int CCrowbar::Swing( int fFirst ) m_trHit = tr; } - m_pPlayer->m_iWeaponVolume = flVol * CROWBAR_WALLHIT_VOLUME; + m_pPlayer->m_iWeaponVolume = (int)( flVol * CROWBAR_WALLHIT_VOLUME ); #endif m_flNextPrimaryAttack = GetNextAttackDelay( 0.25 ); diff --git a/dlls/decals.h b/dlls/decals.h index ce5a2b53..97f5f29f 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 bdc82f06..dcb04e00 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -189,42 +189,42 @@ void CBaseDoor::KeyValue( KeyValueData *pkvd ) { if( FStrEq( pkvd->szKeyName, "skin" ) )//skin is used for content type { - pev->skin = atof( pkvd->szValue ); + pev->skin = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "movesnd" ) ) { - m_bMoveSnd = atof( pkvd->szValue ); + m_bMoveSnd = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "stopsnd" ) ) { - m_bStopSnd = atof( pkvd->szValue ); + m_bStopSnd = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "healthvalue" ) ) { - m_bHealthValue = atof( pkvd->szValue ); + m_bHealthValue = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "locked_sound" ) ) { - m_bLockedSound = atof( pkvd->szValue ); + m_bLockedSound = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "locked_sentence" ) ) { - m_bLockedSentence = atof( pkvd->szValue ); + m_bLockedSentence = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "unlocked_sound" ) ) { - m_bUnlockedSound = atof( pkvd->szValue ); + m_bUnlockedSound = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "unlocked_sentence" ) ) { - m_bUnlockedSentence = atof( pkvd->szValue ); + m_bUnlockedSentence = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "WaveHeight" ) ) @@ -328,7 +328,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 ) @@ -581,7 +581,7 @@ int CBaseDoor::DoorActivate() else { // door should open - if( m_hActivator != NULL && m_hActivator->IsPlayer() ) + if( m_hActivator != 0 && m_hActivator->IsPlayer() ) { // give health if player opened the door (medikit) //VARS( m_eoActivator )->health += m_bHealthValue; @@ -623,7 +623,7 @@ void CBaseDoor::DoorGoUp( void ) { float sign = 1.0; - if( m_hActivator != NULL ) + if( m_hActivator != 0 ) { pevActivator = m_hActivator->pev; @@ -1070,7 +1070,7 @@ void CMomentaryDoor::KeyValue( KeyValueData *pkvd ) if( FStrEq( pkvd->szKeyName, "movesnd" ) ) { - m_bMoveSnd = atof( pkvd->szValue ); + m_bMoveSnd = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "stopsnd" ) ) diff --git a/dlls/effects.cpp b/dlls/effects.cpp index ecc04a19..2977a3ed 100644 --- a/dlls/effects.cpp +++ b/dlls/effects.cpp @@ -75,7 +75,7 @@ void CBubbling::Spawn( void ) pev->solid = SOLID_NOT; // Remove model & collisions pev->renderamt = 0; // The engine won't draw this model if this is set to 0 and blending is on pev->rendermode = kRenderTransTexture; - int speed = pev->speed > 0 ? pev->speed : -pev->speed; + int speed = fabs( pev->speed ); // HACKHACK!!! - Speed in rendercolor pev->rendercolor.x = speed >> 8; @@ -701,7 +701,7 @@ void CLightning::StrikeThink( void ) WRITE_BYTE( (int)pev->rendercolor.x ); // r, g, b WRITE_BYTE( (int)pev->rendercolor.y ); // r, g, b WRITE_BYTE( (int)pev->rendercolor.z ); // r, g, b - WRITE_BYTE( pev->renderamt ); // brightness + WRITE_BYTE( (int)pev->renderamt ); // brightness WRITE_BYTE( m_speed ); // speed MESSAGE_END(); DoSparks( pStart->pev->origin, pEnd->pev->origin ); @@ -763,7 +763,7 @@ void CLightning::Zap( const Vector &vecSrc, const Vector &vecDest ) WRITE_BYTE( (int)pev->rendercolor.x ); // r, g, b WRITE_BYTE( (int)pev->rendercolor.y ); // r, g, b WRITE_BYTE( (int)pev->rendercolor.z ); // r, g, b - WRITE_BYTE( pev->renderamt ); // brightness + WRITE_BYTE( (int)pev->renderamt ); // brightness WRITE_BYTE( m_speed ); // speed MESSAGE_END(); #else @@ -944,7 +944,7 @@ void CLaser::Spawn( void ) m_pSprite = NULL; if( m_pSprite ) - m_pSprite->SetTransparency( kRenderGlow, pev->rendercolor.x, pev->rendercolor.y, pev->rendercolor.z, pev->renderamt, pev->renderfx ); + m_pSprite->SetTransparency( kRenderGlow, (int)pev->rendercolor.x, (int)pev->rendercolor.y, (int)pev->rendercolor.z, (int)pev->renderamt, (int)pev->renderfx ); if( pev->targetname && !( pev->spawnflags & SF_BEAM_STARTON ) ) TurnOff(); @@ -1619,7 +1619,7 @@ void CTestEffect::TestThink( void ) for( i = 0; i < m_iBeam; i++ ) { t = ( gpGlobals->time - m_flBeamTime[i] ) / ( 3 + m_flStartTime - m_flBeamTime[i] ); - m_pBeam[i]->SetBrightness( 255 * t ); + m_pBeam[i]->SetBrightness( (int)( 255 * t ) ); // m_pBeam[i]->SetScrollRate( 20 * t ); } pev->nextthink = gpGlobals->time + 0.1; @@ -1749,9 +1749,9 @@ Vector CBlood::BloodPosition( CBaseEntity *pActivator ) void CBlood::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if( pev->spawnflags & SF_BLOOD_STREAM ) - UTIL_BloodStream( BloodPosition( pActivator ), Direction(), ( Color() == BLOOD_COLOR_RED ) ? 70 : Color(), BloodAmount() ); + UTIL_BloodStream( BloodPosition( pActivator ), Direction(), ( Color() == BLOOD_COLOR_RED ) ? 70 : Color(), (int)BloodAmount() ); else - UTIL_BloodDrips( BloodPosition( pActivator ), Direction(), Color(), BloodAmount() ); + UTIL_BloodDrips( BloodPosition( pActivator ), Direction(), Color(), (int)BloodAmount() ); if( pev->spawnflags & SF_BLOOD_DECAL ) { @@ -1947,12 +1947,12 @@ void CFade::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType { if( pActivator->IsNetClient() ) { - UTIL_ScreenFade( pActivator, pev->rendercolor, Duration(), HoldTime(), pev->renderamt, fadeFlags ); + UTIL_ScreenFade( pActivator, pev->rendercolor, Duration(), HoldTime(), (int)pev->renderamt, fadeFlags ); } } else { - UTIL_ScreenFadeAll( pev->rendercolor, Duration(), HoldTime(), pev->renderamt, fadeFlags ); + UTIL_ScreenFadeAll( pev->rendercolor, Duration(), HoldTime(), (int)pev->renderamt, fadeFlags ); } SUB_UseTargets( this, USE_TOGGLE, 0 ); } diff --git a/dlls/effects.h b/dlls/effects.h index 031b8273..68f0ea29 100644 --- a/dlls/effects.h +++ b/dlls/effects.h @@ -238,7 +238,7 @@ public: inline int GetWidth( void ) { - return pev->scale; + return (int)pev->scale; } inline int GetNoise( void ) @@ -255,17 +255,17 @@ public: inline int GetBrightness( void ) { - return pev->renderamt; + return (int)pev->renderamt; } inline int GetFrame( void ) { - return pev->frame; + return (int)pev->frame; } inline int GetScrollRate( void ) { - return pev->animtime; + return (int)pev->animtime; } // Call after you change start/end positions diff --git a/dlls/egon.cpp b/dlls/egon.cpp index 433704ce..9a4de49b 100644 --- a/dlls/egon.cpp +++ b/dlls/egon.cpp @@ -270,7 +270,7 @@ void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) } } #endif - float timedist; + float timedist = 0.0f; switch( m_fireMode ) { @@ -380,13 +380,13 @@ void CEgon::UpdateEffect( const Vector &startPoint, const Vector &endPoint, floa } m_pBeam->SetStartPos( endPoint ); - m_pBeam->SetBrightness( 255 - ( timeBlend * 180 ) ); - m_pBeam->SetWidth( 40 - ( timeBlend * 20 ) ); + m_pBeam->SetBrightness( (int)( 255 - ( timeBlend * 180 )) ); + m_pBeam->SetWidth( (int)( 40 - ( timeBlend * 20 ) ) ); if( m_fireMode == FIRE_WIDE ) - m_pBeam->SetColor( 30 + ( 25 * timeBlend ), 30 + ( 30 * timeBlend ), 64 + 80 * fabs( sin( gpGlobals->time * 10 ) ) ); + m_pBeam->SetColor( (int)( 30 + ( 25 * timeBlend ) ), (int)( 30 + ( 30 * timeBlend ) ), (int)( 64 + 80 * fabs( sin( gpGlobals->time * 10 ) ) ) ); else - m_pBeam->SetColor( 60 + ( 25 * timeBlend ), 120 + ( 30 * timeBlend ), 64 + 80 * fabs( sin( gpGlobals->time *10 ) ) ); + m_pBeam->SetColor( (int)( 60 + ( 25 * timeBlend ) ), (int)( 120 + ( 30 * timeBlend ) ), (int)( 64 + 80 * fabs( sin( gpGlobals->time *10 ) ) ) ); UTIL_SetOrigin( m_pSprite->pev, endPoint ); m_pSprite->pev->frame += 8 * gpGlobals->frametime; diff --git a/dlls/enginecallback.h b/dlls/enginecallback.h index 1c5ec1b2..9bef0d48 100644 --- a/dlls/enginecallback.h +++ b/dlls/enginecallback.h @@ -14,10 +14,18 @@ ****/ #ifndef ENGINECALLBACK_H #define ENGINECALLBACK_H + +#ifdef _WIN32 +#ifndef __MINGW32__ #pragma once +#endif /* not __MINGW32__ */ +#endif #include "event_flags.h" +// Fix warning in MSVC8 +#undef SERVER_EXECUTE + // Must be provided by user of this code extern enginefuncs_t g_engfuncs; diff --git a/dlls/extdll.h b/dlls/extdll.h index 58349e32..ea176aab 100644 --- a/dlls/extdll.h +++ b/dlls/extdll.h @@ -25,11 +25,13 @@ #endif // Silence certain warnings +#ifdef _MSC_VER #pragma warning(disable : 4244) // int or float down-conversion #pragma warning(disable : 4305) // int or float data truncation #pragma warning(disable : 4201) // nameless struct/union #pragma warning(disable : 4514) // unreferenced inline function removed #pragma warning(disable : 4100) // unreferenced formal parameter +#endif // Prevent tons of unused windows definitions #ifdef _WIN32 @@ -42,8 +44,12 @@ #include "windows.h" #undef HSPRITE #else // _WIN32 +#ifndef FALSE #define FALSE 0 +#endif +#ifndef TRUE #define TRUE (!FALSE) +#endif typedef unsigned int ULONG; typedef unsigned char BYTE; typedef int BOOL; diff --git a/dlls/func_break.cpp b/dlls/func_break.cpp index 38b05f7b..6abf1b44 100644 --- a/dlls/func_break.cpp +++ b/dlls/func_break.cpp @@ -104,7 +104,7 @@ void CBreakable::KeyValue( KeyValueData* pkvd ) else if( FStrEq( pkvd->szKeyName, "spawnobject" ) ) { int object = atoi( pkvd->szValue ); - if( object > 0 && object < ARRAYSIZE( pSpawnObjects ) ) + if( object > 0 && object < (int)ARRAYSIZE( pSpawnObjects ) ) m_iszSpawnObject = MAKE_STRING( pSpawnObjects[object] ); pkvd->fHandled = TRUE; } @@ -353,7 +353,7 @@ void CBreakable::DamageSound( void ) { int pitch; float fvol; - char *rgpsz[6]; + const char *rgpsz[6]; int i = 0; int material = m_Material; @@ -574,7 +574,6 @@ void CBreakable::Die( void ) { Vector vecSpot;// shard origin Vector vecVelocity;// shard velocity - CBaseEntity *pEntity = NULL; char cFlag = 0; int pitch; float fvol; @@ -794,7 +793,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; @@ -810,7 +809,7 @@ IMPLEMENT_SAVERESTORE( CPushable, CBreakable ) LINK_ENTITY_TO_CLASS( func_pushable, CPushable ) -char *CPushable::m_soundNames[3] = +const char *CPushable::m_soundNames[3] = { "debris/pushbox1.wav", "debris/pushbox2.wav", @@ -839,7 +838,7 @@ void CPushable::Spawn( void ) UTIL_SetOrigin( pev, pev->origin ); // Multiply by area of the box's cross-section (assume 1000 units^3 standard volume) - pev->skin = ( pev->skin * ( pev->maxs.x - pev->mins.x ) * ( pev->maxs.y - pev->mins.y ) ) * 0.0005; + pev->skin = (int)( ( pev->skin * ( pev->maxs.x - pev->mins.x ) * ( pev->maxs.y - pev->mins.y ) ) * 0.0005 ); m_soundTime = 0; } @@ -882,7 +881,7 @@ void CPushable::KeyValue( KeyValueData *pkvd ) } else if( FStrEq( pkvd->szKeyName, "buoyancy" ) ) { - pev->skin = atof( pkvd->szValue ); + pev->skin = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp index eab9e621..ab295e0c 100644 --- a/dlls/func_tank.cpp +++ b/dlls/func_tank.cpp @@ -190,7 +190,7 @@ void CFuncTank::Spawn( void ) if( m_fireRate <= 0 ) m_fireRate = 1; - if( m_spread > MAX_FIRING_SPREADS ) + if( m_spread > (int)MAX_FIRING_SPREADS ) m_spread = 0; pev->oldorigin = pev->origin; @@ -328,7 +328,7 @@ BOOL CFuncTank::OnControls( entvars_t *pevTest ) if( !( pev->spawnflags & SF_TANK_CANCONTROL ) ) return FALSE; - Vector offset = pevTest->origin - pev->origin; + //Vector offset = pevTest->origin - pev->origin; if( ( m_vecControllerUsePos - pevTest->origin ).Length() < 30 ) return TRUE; @@ -476,9 +476,9 @@ void CFuncTank::TrackTarget( void ) { TraceResult tr; edict_t *pPlayer = FIND_CLIENT_IN_PVS( edict() ); - BOOL updateTime = FALSE, lineOfSight; + BOOL updateTime = FALSE; Vector angles, direction, targetPosition, barrelEnd; - edict_t *pTarget; + edict_t *pTarget = NULL; // Get a position to aim for if( m_pController ) @@ -515,12 +515,8 @@ void CFuncTank::TrackTarget( void ) UTIL_TraceLine( barrelEnd, targetPosition, dont_ignore_monsters, edict(), &tr ); - lineOfSight = FALSE; - // No line of sight, don't track if( tr.flFraction == 1.0 || tr.pHit == pTarget ) { - lineOfSight = TRUE; - CBaseEntity *pInstance = CBaseEntity::Instance(pTarget); if( InRange( range ) && pInstance && pInstance->IsAlive() ) { @@ -644,7 +640,7 @@ void CFuncTank::Fire( const Vector &barrelEnd, const Vector &forward, entvars_t { CSprite *pSprite = CSprite::SpriteCreate( STRING( m_iszSpriteSmoke ), barrelEnd, TRUE ); pSprite->AnimateAndDie( RANDOM_FLOAT( 15.0, 20.0 ) ); - pSprite->SetTransparency( kRenderTransAlpha, pev->rendercolor.x, pev->rendercolor.y, pev->rendercolor.z, 255, kRenderFxNone ); + pSprite->SetTransparency( kRenderTransAlpha, (int)pev->rendercolor.x, (int)pev->rendercolor.y, (int)pev->rendercolor.z, 255, kRenderFxNone ); pSprite->pev->velocity.z = RANDOM_FLOAT( 40, 80 ); pSprite->SetScale( m_spriteScale ); } @@ -714,7 +710,7 @@ void CFuncTankGun::Fire( const Vector &barrelEnd, const Vector &forward, entvars // FireBullets needs gpGlobals->v_up, etc. UTIL_MakeAimVectors( pev->angles ); - int bulletCount = ( gpGlobals->time - m_fireLast ) * m_fireRate; + int bulletCount = (int)( ( gpGlobals->time - m_fireLast ) * m_fireRate ); if( bulletCount > 0 ) { for( i = 0; i < bulletCount; i++ ) @@ -835,7 +831,7 @@ void CFuncTankLaser::Fire( const Vector &barrelEnd, const Vector &forward, entva // TankTrace needs gpGlobals->v_up, etc. UTIL_MakeAimVectors( pev->angles ); - int bulletCount = ( gpGlobals->time - m_fireLast ) * m_fireRate; + int bulletCount = (int)( ( gpGlobals->time - m_fireLast ) * m_fireRate ); if( bulletCount ) { for( i = 0; i < bulletCount; i++ ) @@ -879,12 +875,12 @@ void CFuncTankRocket::Fire( const Vector &barrelEnd, const Vector &forward, entv if( m_fireLast != 0 ) { - int bulletCount = ( gpGlobals->time - m_fireLast ) * m_fireRate; + int bulletCount = (int)( ( gpGlobals->time - m_fireLast ) * m_fireRate ); if( bulletCount > 0 ) { for( i = 0; i < bulletCount; i++ ) { - CBaseEntity *pRocket = CBaseEntity::Create( "rpg_rocket", barrelEnd, pev->angles, edict() ); + CBaseEntity::Create( "rpg_rocket", barrelEnd, pev->angles, edict() ); } CFuncTank::Fire( barrelEnd, forward, pev ); } @@ -917,7 +913,7 @@ void CFuncTankMortar::Fire( const Vector &barrelEnd, const Vector &forward, entv { if( m_fireLast != 0 ) { - int bulletCount = ( gpGlobals->time - m_fireLast ) * m_fireRate; + int bulletCount = (int)( ( gpGlobals->time - m_fireLast ) * m_fireRate ); // Only create 1 explosion if( bulletCount > 0 ) { diff --git a/dlls/gargantua.cpp b/dlls/gargantua.cpp index 6c65b06f..7f60b401 100644 --- a/dlls/gargantua.cpp +++ b/dlls/gargantua.cpp @@ -538,7 +538,6 @@ void CGargantua::FlameControls( float angleX, float angleY ) void CGargantua::FlameUpdate( void ) { int i; - static float offset[2] = { 60, -60 }; TraceResult trace; Vector vecStart, angleGun; BOOL streaks = FALSE; @@ -759,7 +758,7 @@ void CGargantua::Spawn() //========================================================= void CGargantua::Precache() { - int i; + size_t i; PRECACHE_MODEL( "models/garg.mdl" ); PRECACHE_MODEL( GARG_EYE_SPRITE_NAME ); diff --git a/dlls/gauss.cpp b/dlls/gauss.cpp index 10149202..93352b57 100644 --- a/dlls/gauss.cpp +++ b/dlls/gauss.cpp @@ -259,7 +259,7 @@ void CGauss::SecondaryAttack() m_pPlayer->m_flNextAmmoBurn = 1000; } - int pitch = ( gpGlobals->time - m_pPlayer->m_flStartCharge ) * ( 150 / GetFullChargeTime() ) + 100; + int pitch = (int)( ( gpGlobals->time - m_pPlayer->m_flStartCharge ) * ( 150 / GetFullChargeTime() ) + 100 ); if( pitch > 250 ) pitch = 250; @@ -359,11 +359,11 @@ void CGauss::StartFire( void ) void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) { m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME; - + TraceResult tr, beam_tr; +#ifndef CLIENT_DLL Vector vecSrc = vecOrigSrc; Vector vecDest = vecSrc + vecDir * 8192; edict_t *pentIgnore; - TraceResult tr, beam_tr; float flMaxFrac = 1.0; int nTotal = 0; int fHasPunched = 0; @@ -371,8 +371,7 @@ void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) int nMaxHits = 10; pentIgnore = ENT( m_pPlayer->pev ); - -#ifdef CLIENT_DLL +#else if( m_fPrimaryFire == false ) g_irunninggausspred = true; #endif diff --git a/dlls/genericmonster.cpp b/dlls/genericmonster.cpp index c40bb802..23622120 100644 --- a/dlls/genericmonster.cpp +++ b/dlls/genericmonster.cpp @@ -88,7 +88,7 @@ void CGenericMonster::HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= int CGenericMonster::ISoundMask( void ) { - return NULL; + return 0; } //========================================================= diff --git a/dlls/ggrenade.cpp b/dlls/ggrenade.cpp index 64d9f3cf..0ca516c4 100644 --- a/dlls/ggrenade.cpp +++ b/dlls/ggrenade.cpp @@ -49,7 +49,7 @@ void CGrenade::Explode( Vector vecSrc, Vector vecAim ) // UNDONE: temporary scorching for PreAlpha - find a less sleazy permenant solution. void CGrenade::Explode( TraceResult *pTrace, int bitsDamageType ) { - float flRndSound;// sound randomizer + // float flRndSound;// sound randomizer pev->model = iStringNull;//invisible pev->solid = SOLID_NOT;// intangible @@ -102,7 +102,7 @@ void CGrenade::Explode( TraceResult *pTrace, int bitsDamageType ) UTIL_DecalTrace( pTrace, DECAL_SCORCH2 ); } - flRndSound = RANDOM_FLOAT( 0, 1 ); + //flRndSound = RANDOM_FLOAT( 0, 1 ); switch( RANDOM_LONG( 0, 2 ) ) { @@ -144,8 +144,8 @@ void CGrenade::Smoke( void ) WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); WRITE_SHORT( g_sModelIndexSmoke ); - WRITE_BYTE( ( pev->dmg - 50 ) * 0.80 ); // scale * 10 - WRITE_BYTE( 12 ); // framerate + WRITE_BYTE( (int)( ( pev->dmg - 50 ) * 0.80 ) ); // scale * 10 + WRITE_BYTE( 12 ); // framerate MESSAGE_END(); } UTIL_Remove( this ); @@ -165,7 +165,7 @@ void CGrenade::DetonateUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T void CGrenade::PreDetonate( void ) { - CSoundEnt::InsertSound ( bits_SOUND_DANGER, pev->origin, 400, 0.3 ); + CSoundEnt::InsertSound( bits_SOUND_DANGER, pev->origin, 400, 0.3 ); SetThink( &CGrenade::Detonate ); pev->nextthink = gpGlobals->time + 1; @@ -207,7 +207,7 @@ void CGrenade::DangerSoundThink( void ) return; } - CSoundEnt::InsertSound ( bits_SOUND_DANGER, pev->origin + pev->velocity * 0.5, pev->velocity.Length(), 0.2 ); + CSoundEnt::InsertSound( bits_SOUND_DANGER, pev->origin + pev->velocity * 0.5, (int)pev->velocity.Length(), 0.2 ); pev->nextthink = gpGlobals->time + 0.2; if( pev->waterlevel != 0 ) @@ -253,7 +253,7 @@ void CGrenade::BounceTouch( CBaseEntity *pOther ) // go ahead and emit the danger sound. // register a radius louder than the explosion, so we make sure everyone gets out of the way - CSoundEnt::InsertSound( bits_SOUND_DANGER, pev->origin, pev->dmg / 0.4, 0.3 ); + CSoundEnt::InsertSound( bits_SOUND_DANGER, pev->origin, (int)( pev->dmg / 0.4 ), 0.3 ); m_fRegisteredSound = TRUE; } diff --git a/dlls/gman.cpp b/dlls/gman.cpp index bdfb60d4..377755f6 100644 --- a/dlls/gman.cpp +++ b/dlls/gman.cpp @@ -109,7 +109,7 @@ void CGMan::HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= int CGMan::ISoundMask( void ) { - return NULL; + return 0; } //========================================================= @@ -149,7 +149,7 @@ void CGMan::StartTask( Task_t *pTask ) switch( pTask->iTask ) { case TASK_WAIT: - if( m_hPlayer == NULL ) + if( m_hPlayer == 0 ) { m_hPlayer = UTIL_FindEntityByClassname( NULL, "player" ); } @@ -164,7 +164,7 @@ void CGMan::RunTask( Task_t *pTask ) { case TASK_WAIT: // look at who I'm talking to - if( m_flTalkTime > gpGlobals->time && m_hTalkTarget != NULL ) + if( m_flTalkTime > gpGlobals->time && m_hTalkTarget != 0 ) { float yaw = VecToYaw( m_hTalkTarget->pev->origin - pev->origin ) - pev->angles.y; @@ -177,7 +177,7 @@ void CGMan::RunTask( Task_t *pTask ) SetBoneController( 0, yaw ); } // look at player, but only if playing a "safe" idle animation - else if( m_hPlayer != NULL && pev->sequence == 0 ) + else if( m_hPlayer != 0 && pev->sequence == 0 ) { float yaw = VecToYaw( m_hPlayer->pev->origin - pev->origin ) - pev->angles.y; diff --git a/dlls/h_battery.cpp b/dlls/h_battery.cpp index fdb7c645..976a5733 100644 --- a/dlls/h_battery.cpp +++ b/dlls/h_battery.cpp @@ -91,7 +91,7 @@ void CRecharge::Spawn() UTIL_SetOrigin( pev, pev->origin ); // set size and link into world UTIL_SetSize( pev, pev->mins, pev->maxs ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); - m_iJuice = gSkillData.suitchargerCapacity; + m_iJuice = (int)gSkillData.suitchargerCapacity; pev->frame = 0; } @@ -172,7 +172,7 @@ void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use void CRecharge::Recharge( void ) { - m_iJuice = gSkillData.suitchargerCapacity; + m_iJuice = (int)gSkillData.suitchargerCapacity; pev->frame = 0; SetThink( &CBaseEntity::SUB_DoNothing ); } @@ -185,7 +185,7 @@ void CRecharge::Off( void ) m_iOn = 0; - if( ( !m_iJuice ) && ( ( m_iReactivate = g_pGameRules->FlHEVChargerRechargeTime() ) > 0 ) ) + if( ( !m_iJuice ) && ( ( m_iReactivate = (int)g_pGameRules->FlHEVChargerRechargeTime() ) > 0 ) ) { pev->nextthink = pev->ltime + m_iReactivate; SetThink( &CRecharge::Recharge ); diff --git a/dlls/h_cine.cpp b/dlls/h_cine.cpp index fc503171..bb07e02c 100644 --- a/dlls/h_cine.cpp +++ b/dlls/h_cine.cpp @@ -31,7 +31,7 @@ class CLegacyCineMonster : public CBaseMonster { public: - void CineSpawn( char *szModel ); + void CineSpawn( const char *szModel ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void EXPORT CineThink( void ); void Pain( void ); @@ -103,7 +103,7 @@ LINK_ENTITY_TO_CLASS( monster_cine3_barney, CCine3Barney ) // ********** Scientist SPAWN ********** // -void CLegacyCineMonster :: CineSpawn( char *szModel ) +void CLegacyCineMonster :: CineSpawn( const char *szModel ) { PRECACHE_MODEL(szModel); SET_MODEL(ENT(pev), szModel); diff --git a/dlls/h_cycler.cpp b/dlls/h_cycler.cpp index d685ac36..e920abfa 100644 --- a/dlls/h_cycler.cpp +++ b/dlls/h_cycler.cpp @@ -34,7 +34,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 ); @@ -92,7 +92,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 ) { @@ -406,7 +406,7 @@ void CWreckage::Spawn( void ) } // pev->scale = 5.0; - m_flStartTime = gpGlobals->time; + m_flStartTime = (int)gpGlobals->time; } void CWreckage::Precache() diff --git a/dlls/hassassin.cpp b/dlls/hassassin.cpp index 5aac1e53..ff053595 100644 --- a/dlls/hassassin.cpp +++ b/dlls/hassassin.cpp @@ -185,7 +185,7 @@ void CHAssassin::SetYawSpeed( void ) //========================================================= void CHAssassin::Shoot( void ) { - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { return; } @@ -597,7 +597,7 @@ IMPLEMENT_CUSTOM_SCHEDULES( CHAssassin, CBaseMonster ) //========================================================= BOOL CHAssassin::CheckMeleeAttack1( float flDot, float flDist ) { - if( m_flNextJump < gpGlobals->time && ( flDist <= 128 || HasMemory( bits_MEMORY_BADJUMP ) ) && m_hEnemy != NULL ) + if( m_flNextJump < gpGlobals->time && ( flDist <= 128 || HasMemory( bits_MEMORY_BADJUMP ) ) && m_hEnemy != 0 ) { TraceResult tr; @@ -687,7 +687,7 @@ void CHAssassin::RunAI( void ) // always visible if moving // always visible is not on hard - if( g_iSkillLevel != SKILL_HARD || m_hEnemy == NULL || pev->deadflag != DEAD_NO || m_Activity == ACT_RUN || m_Activity == ACT_WALK || !( pev->flags & FL_ONGROUND ) ) + if( g_iSkillLevel != SKILL_HARD || m_hEnemy == 0 || pev->deadflag != DEAD_NO || m_Activity == ACT_RUN || m_Activity == ACT_WALK || !( pev->flags & FL_ONGROUND ) ) m_iTargetRanderamt = 255; else m_iTargetRanderamt = 20; diff --git a/dlls/headcrab.cpp b/dlls/headcrab.cpp index d84a692e..60e03c10 100644 --- a/dlls/headcrab.cpp +++ b/dlls/headcrab.cpp @@ -226,7 +226,7 @@ void CHeadCrab::HandleAnimEvent( MonsterEvent_t *pEvent ) UTIL_MakeVectors( pev->angles ); Vector vecJumpDir; - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { float gravity = g_psv_gravity->value; if( gravity <= 1 ) @@ -538,7 +538,7 @@ Schedule_t *CBabyCrab::GetScheduleOfType( int Type ) switch( Type ) { case SCHED_FAIL: // If you fail, try to jump! - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) return slHCRangeAttack1Fast; break; case SCHED_RANGE_ATTACK1: diff --git a/dlls/healthkit.cpp b/dlls/healthkit.cpp index e1b22467..99d53d35 100644 --- a/dlls/healthkit.cpp +++ b/dlls/healthkit.cpp @@ -159,7 +159,7 @@ void CWallHealth::Spawn() UTIL_SetOrigin( pev, pev->origin ); // set size and link into world UTIL_SetSize( pev, pev->mins, pev->maxs ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); - m_iJuice = gSkillData.healthchargerCapacity; + m_iJuice = (int)gSkillData.healthchargerCapacity; pev->frame = 0; } @@ -230,7 +230,7 @@ void CWallHealth::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE u void CWallHealth::Recharge( void ) { EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/medshot4.wav", 1.0, ATTN_NORM ); - m_iJuice = gSkillData.healthchargerCapacity; + m_iJuice = (int)gSkillData.healthchargerCapacity; pev->frame = 0; SetThink( &CBaseEntity::SUB_DoNothing ); } @@ -243,7 +243,7 @@ void CWallHealth::Off( void ) m_iOn = 0; - if( ( !m_iJuice ) && ( ( m_iReactivate = g_pGameRules->FlHealthChargerRechargeTime() ) > 0 ) ) + if( ( !m_iJuice ) && ( ( m_iReactivate = (int)g_pGameRules->FlHealthChargerRechargeTime() ) > 0 ) ) { pev->nextthink = pev->ltime + m_iReactivate; SetThink( &CWallHealth::Recharge ); diff --git a/dlls/hgrunt.cpp b/dlls/hgrunt.cpp index 7b0eaa2c..4cb85c2c 100644 --- a/dlls/hgrunt.cpp +++ b/dlls/hgrunt.cpp @@ -217,7 +217,7 @@ const char *CHGrunt::pGruntSentences[] = "HG_TAUNT", // say rude things }; -enum +typedef enum { HGRUNT_SENT_NONE = -1, HGRUNT_SENT_GREN = 0, @@ -366,7 +366,7 @@ void CHGrunt::JustSpoke( void ) //========================================================= void CHGrunt::PrescheduleThink( void ) { - if( InSquad() && m_hEnemy != NULL ) + if( InSquad() && m_hEnemy != 0 ) { if( HasConditions( bits_COND_SEE_ENEMY ) ) { @@ -413,9 +413,9 @@ BOOL CHGrunt::FCanCheckAttacks( void ) //========================================================= BOOL CHGrunt::CheckMeleeAttack1( float flDot, float flDist ) { - CBaseMonster *pEnemy; + CBaseMonster *pEnemy = 0; - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { pEnemy = m_hEnemy->MyMonsterPointer(); @@ -787,7 +787,7 @@ Vector CHGrunt::GetGunPosition() //========================================================= void CHGrunt::Shoot( void ) { - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { return; } @@ -814,7 +814,7 @@ void CHGrunt::Shoot( void ) //========================================================= void CHGrunt::Shotgun( void ) { - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { return; } @@ -1834,7 +1834,7 @@ IMPLEMENT_CUSTOM_SCHEDULES( CHGrunt, CSquadMonster ) void CHGrunt::SetActivity( Activity NewActivity ) { int iSequence = ACTIVITY_NOT_AVAILABLE; - void *pmodel = GET_MODEL_PTR( ENT( pev ) ); + //void *pmodel = GET_MODEL_PTR( ENT( pev ) ); switch( NewActivity ) { @@ -2032,10 +2032,10 @@ Schedule_t *CHGrunt::GetSchedule( void ) // before he starts pluggin away. if( FOkToSpeak() )// && RANDOM_LONG( 0, 1 ) ) { - if( ( m_hEnemy != NULL ) && m_hEnemy->IsPlayer() ) + if( ( m_hEnemy != 0 ) && m_hEnemy->IsPlayer() ) // player SENTENCEG_PlayRndSz( ENT( pev ), "HG_ALERT", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch ); - else if( ( m_hEnemy != NULL ) && + else if( ( m_hEnemy != 0 ) && ( m_hEnemy->Classify() != CLASS_PLAYER_ALLY ) && ( m_hEnemy->Classify() != CLASS_HUMAN_PASSIVE ) && ( m_hEnemy->Classify() != CLASS_MACHINE ) ) @@ -2072,7 +2072,7 @@ Schedule_t *CHGrunt::GetSchedule( void ) // 10% chance of flinch. int iPercent = RANDOM_LONG( 0, 99 ); - if( iPercent <= 90 && m_hEnemy != NULL ) + if( iPercent <= 90 && m_hEnemy != 0 ) { // only try to take cover if we actually have an enemy! @@ -2308,7 +2308,7 @@ Schedule_t *CHGrunt::GetScheduleOfType( int Type ) } case SCHED_FAIL: { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { // grunt has an enemy, so pick a different default fail schedule most likely to help recover. return &slGruntCombatFail[0]; @@ -2408,10 +2408,10 @@ public: void KeyValue( KeyValueData *pkvd ); int m_iPose;// which sequence to display -- temporary, don't need to save - static char *m_szPoses[3]; + static const char *m_szPoses[3]; }; -char *CDeadHGrunt::m_szPoses[] = { "deadstomach", "deadside", "deadsitting" }; +const char *CDeadHGrunt::m_szPoses[] = { "deadstomach", "deadside", "deadsitting" }; void CDeadHGrunt::KeyValue( KeyValueData *pkvd ) { diff --git a/dlls/hornet.cpp b/dlls/hornet.cpp index 1e7025a0..d968b79b 100644 --- a/dlls/hornet.cpp +++ b/dlls/hornet.cpp @@ -258,14 +258,14 @@ void CHornet::TrackTarget( void ) } // UNDONE: The player pointer should come back after returning from another level - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { // enemy is dead. Look( 512 ); m_hEnemy = BestVisibleEnemy(); } - if( m_hEnemy != NULL && FVisible( m_hEnemy ) ) + if( m_hEnemy != 0 && FVisible( m_hEnemy ) ) { m_vecEnemyLKP = m_hEnemy->BodyTarget( pev->origin ); } @@ -335,7 +335,7 @@ void CHornet::TrackTarget( void ) // if hornet is close to the enemy, jet in a straight line for a half second. // (only in the single player game) - if( m_hEnemy != NULL && !g_pGameRules->IsMultiplayer() ) + if( m_hEnemy != 0 && !g_pGameRules->IsMultiplayer() ) { if( flDelta >= 0.4 && ( pev->origin - m_vecEnemyLKP ).Length() <= 300 ) { diff --git a/dlls/houndeye.cpp b/dlls/houndeye.cpp index f35b0740..cedee258 100644 --- a/dlls/houndeye.cpp +++ b/dlls/houndeye.cpp @@ -137,7 +137,7 @@ int CHoundeye::Classify( void ) //========================================================= BOOL CHoundeye::FValidateHintType( short sHint ) { - int i; + size_t i; static short sHoundHints[] = { diff --git a/dlls/ichthyosaur.cpp b/dlls/ichthyosaur.cpp index cbc86d50..53f57a27 100644 --- a/dlls/ichthyosaur.cpp +++ b/dlls/ichthyosaur.cpp @@ -416,7 +416,7 @@ void CIchthyosaur::HandleAnimEvent( MonsterEvent_t *pEvent ) case ICHTHYOSAUR_AE_SHAKE_RIGHT: case ICHTHYOSAUR_AE_SHAKE_LEFT: { - if( m_hEnemy != NULL && FVisible( m_hEnemy ) ) + if( m_hEnemy != 0 && FVisible( m_hEnemy ) ) { CBaseEntity *pHurt = m_hEnemy; @@ -622,7 +622,7 @@ void CIchthyosaur::RunTask( Task_t *pTask ) switch( pTask->iTask ) { case TASK_ICHTHYOSAUR_CIRCLE_ENEMY: - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { TaskComplete(); } @@ -864,7 +864,7 @@ void CIchthyosaur::Stop( void ) void CIchthyosaur::Swim() { - int retValue = 0; + //int retValue = 0; Vector start = pev->origin; @@ -1072,7 +1072,7 @@ Vector CIchthyosaur::DoProbe( const Vector &Probe ) } } - if( bBumpedSomething && ( m_hEnemy == NULL || tr.pHit != m_hEnemy->edict() ) ) + if( bBumpedSomething && ( m_hEnemy == 0 || tr.pHit != m_hEnemy->edict() ) ) { Vector ProbeDir = Probe - pev->origin; diff --git a/dlls/islave.cpp b/dlls/islave.cpp index cfb1df1b..3b4343d3 100644 --- a/dlls/islave.cpp +++ b/dlls/islave.cpp @@ -51,7 +51,7 @@ public: void HandleAnimEvent( MonsterEvent_t *pEvent ); BOOL CheckRangeAttack1( float flDot, float flDist ); BOOL CheckRangeAttack2( float flDot, float flDist ); - void CallForHelp( char *szClassname, float flDist, EHANDLE hEnemy, Vector &vecLocation ); + void CallForHelp( const char *szClassname, float flDist, EHANDLE hEnemy, Vector &vecLocation ); void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ); int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); @@ -155,7 +155,7 @@ int CISlave::IRelationship( CBaseEntity *pTarget ) return CBaseMonster::IRelationship( pTarget ); } -void CISlave::CallForHelp( char *szClassname, float flDist, EHANDLE hEnemy, Vector &vecLocation ) +void CISlave::CallForHelp( const char *szClassname, float flDist, EHANDLE hEnemy, Vector &vecLocation ) { // ALERT( at_aiconsole, "help " ); @@ -185,7 +185,7 @@ void CISlave::CallForHelp( char *szClassname, float flDist, EHANDLE hEnemy, Vect //========================================================= void CISlave::AlertSound( void ) { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { SENTENCEG_PlayRndSz( ENT( pev ), "SLV_ALERT", 0.85, ATTN_NORM, 0, m_voicePitch ); @@ -365,7 +365,7 @@ void CISlave::HandleAnimEvent( MonsterEvent_t *pEvent ) WRITE_BYTE( 0 ); // decay * 0.1 MESSAGE_END(); } - if( m_hDead != NULL ) + if( m_hDead != 0 ) { WackBeam( -1, m_hDead ); WackBeam( 1, m_hDead ); @@ -385,7 +385,7 @@ void CISlave::HandleAnimEvent( MonsterEvent_t *pEvent ) { ClearBeams(); - if( m_hDead != NULL ) + if( m_hDead != 0 ) { Vector vecDest = m_hDead->pev->origin + Vector( 0, 0, 38 ); TraceResult trace; @@ -394,7 +394,7 @@ void CISlave::HandleAnimEvent( MonsterEvent_t *pEvent ) if( !trace.fStartSolid ) { CBaseEntity *pNew = Create( "monster_alien_slave", m_hDead->pev->origin, m_hDead->pev->angles ); - CBaseMonster *pNewMonster = pNew->MyMonsterPointer( ); + //CBaseMonster *pNewMonster = pNew->MyMonsterPointer(); pNew->pev->spawnflags |= 1; WackBeam( -1, pNew ); WackBeam( 1, pNew ); @@ -484,7 +484,7 @@ BOOL CISlave::CheckRangeAttack2( float flDot, float flDist ) } } } - if( m_hDead != NULL ) + if( m_hDead != 0 ) return TRUE; else return FALSE; @@ -530,7 +530,7 @@ void CISlave::Spawn() //========================================================= void CISlave::Precache() { - int i; + size_t i; PRECACHE_MODEL( "models/islave.mdl" ); PRECACHE_MODEL( "sprites/lgtning.spr" ); @@ -756,8 +756,8 @@ void CISlave::BeamGlow() //========================================================= void CISlave::WackBeam( int side, CBaseEntity *pEntity ) { - Vector vecDest; - float flDist = 1.0; + //Vector vecDest; + //float flDist = 1.0; if( m_iBeams >= ISLAVE_MAX_BEAMS ) return; diff --git a/dlls/leech.cpp b/dlls/leech.cpp index ea524aaa..dccffcf4 100644 --- a/dlls/leech.cpp +++ b/dlls/leech.cpp @@ -271,7 +271,7 @@ void CLeech::AlertSound( void ) void CLeech::Precache( void ) { - int i; + size_t i; //PRECACHE_MODEL( "models/icky.mdl" ); PRECACHE_MODEL( "models/leech.mdl" ); diff --git a/dlls/lights.cpp b/dlls/lights.cpp index 2a8b0683..e6b03125 100644 --- a/dlls/lights.cpp +++ b/dlls/lights.cpp @@ -99,7 +99,7 @@ void CLight::Spawn( void ) if( FBitSet( pev->spawnflags, SF_LIGHT_START_OFF ) ) LIGHT_STYLE( m_iStyle, "a" ); else if( m_iszPattern ) - LIGHT_STYLE( m_iStyle, (char *)STRING( m_iszPattern ) ); + LIGHT_STYLE( m_iStyle, STRING( m_iszPattern ) ); else LIGHT_STYLE( m_iStyle, "m" ); } @@ -115,7 +115,7 @@ void CLight::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTyp if( FBitSet( pev->spawnflags, SF_LIGHT_START_OFF ) ) { if( m_iszPattern ) - LIGHT_STYLE( m_iStyle, (char *)STRING( m_iszPattern ) ); + LIGHT_STYLE( m_iStyle, STRING( m_iszPattern ) ); else LIGHT_STYLE( m_iStyle, "m" ); ClearBits( pev->spawnflags, SF_LIGHT_START_OFF ); @@ -155,15 +155,16 @@ void CEnvLight::KeyValue( KeyValueData* pkvd ) } else if( j == 4 ) { - r = r * ( v / 255.0 ); - g = g * ( v / 255.0 ); - b = b * ( v / 255.0 ); + v /= 255; + r *= v; + g *= v; + b *= v; } // simulate qrad direct, ambient,and gamma adjustments, as well as engine scaling - r = pow( r / 114.0, 0.6 ) * 264; - g = pow( g / 114.0, 0.6 ) * 264; - b = pow( b / 114.0, 0.6 ) * 264; + r = (int)( pow( r / 114.0, 0.6 ) * 264.0 ); + g = (int)( pow( g / 114.0, 0.6 ) * 264.0 ); + b = (int)( pow( b / 114.0, 0.6 ) * 264.0 ); pkvd->fHandled = TRUE; sprintf( szColor, "%d", r ); diff --git a/dlls/maprules.cpp b/dlls/maprules.cpp index 3eea7486..2230acac 100644 --- a/dlls/maprules.cpp +++ b/dlls/maprules.cpp @@ -64,9 +64,9 @@ void CRuleEntity::Spawn( void ) void CRuleEntity::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "master")) + if( FStrEq(pkvd->szKeyName, "master" ) ) { - SetMaster( ALLOC_STRING(pkvd->szValue) ); + SetMaster( ALLOC_STRING( pkvd->szValue ) ); pkvd->fHandled = TRUE; } else @@ -75,9 +75,9 @@ void CRuleEntity::KeyValue( KeyValueData *pkvd ) BOOL CRuleEntity::CanFireForActivator( CBaseEntity *pActivator ) { - if ( m_iszMaster ) + if( m_iszMaster ) { - if ( UTIL_IsMasterTriggered( m_iszMaster, pActivator ) ) + if( UTIL_IsMasterTriggered( m_iszMaster, pActivator ) ) return TRUE; else return FALSE; @@ -135,7 +135,7 @@ public: void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void KeyValue( KeyValueData *pkvd ); - inline int Points( void ) { return pev->frags; } + inline int Points( void ) { return (int)pev->frags; } inline BOOL AllowNegativeScore( void ) { return pev->spawnflags & SF_SCORE_NEGATIVE; } inline BOOL AwardToTeam( void ) { return pev->spawnflags & SF_SCORE_TEAM; } @@ -643,8 +643,8 @@ public: inline void CountUp( void ) { pev->frags++; } inline void CountDown( void ) { pev->frags--; } inline void ResetCount( void ) { pev->frags = pev->dmg; } - inline int CountValue( void ) { return pev->frags; } - inline int LimitValue( void ) { return pev->health; } + inline int CountValue( void ) { return (int)pev->frags; } + inline int LimitValue( void ) { return (int)pev->health; } inline BOOL HitLimit( void ) { return CountValue() == LimitValue(); } diff --git a/dlls/monsters.cpp b/dlls/monsters.cpp index d034abd6..cfe4c561 100644 --- a/dlls/monsters.cpp +++ b/dlls/monsters.cpp @@ -133,7 +133,7 @@ int CBaseMonster::Restore( CRestore &restore ) m_Activity = ACT_RESET; // If we don't have an enemy, clear conditions like see enemy, etc. - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) m_afConditions = 0; return status; @@ -672,7 +672,7 @@ BOOL CBaseMonster::FRefreshRoute( void ) returnCode = BuildRoute( m_vecMoveGoal, bits_MF_TO_LOCATION, NULL ); break; case MOVEGOAL_TARGETENT: - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) { returnCode = BuildRoute( m_hTargetEnt->pev->origin, bits_MF_TO_TARGETENT, m_hTargetEnt ); } @@ -954,7 +954,7 @@ BOOL CBaseMonster::CheckRangeAttack2( float flDot, float flDist ) BOOL CBaseMonster::CheckMeleeAttack1( float flDot, float flDist ) { // Decent fix to keep folks from kicking/punching hornets and snarks is to check the onground flag(sjb) - if( flDist <= 64 && flDot >= 0.7 && m_hEnemy != NULL && FBitSet( m_hEnemy->pev->flags, FL_ONGROUND ) ) + if( flDist <= 64 && flDot >= 0.7 && m_hEnemy != 0 && FBitSet( m_hEnemy->pev->flags, FL_ONGROUND ) ) { return TRUE; } @@ -1165,7 +1165,7 @@ void CBaseMonster::PushEnemy( CBaseEntity *pEnemy, Vector &vecLastKnownPos ) { if( m_hOldEnemy[i] == pEnemy ) return; - if( m_hOldEnemy[i] == NULL ) // someone died, reuse their slot + if( m_hOldEnemy[i] == 0 ) // someone died, reuse their slot break; } if( i >= MAX_OLD_ENEMIES ) @@ -1183,7 +1183,7 @@ BOOL CBaseMonster::PopEnemy() // UNDONE: blah, this is bad, we should use a stack but I'm too lazy to code one. for( int i = MAX_OLD_ENEMIES - 1; i >= 0; i-- ) { - if( m_hOldEnemy[i] != NULL ) + if( m_hOldEnemy[i] != 0 ) { if( m_hOldEnemy[i]->IsAlive()) // cheat and know when they die { @@ -1240,7 +1240,7 @@ void CBaseMonster::SetActivity( Activity NewActivity ) //========================================================= // SetSequenceByName //========================================================= -void CBaseMonster::SetSequenceByName( char *szSequence ) +void CBaseMonster::SetSequenceByName( const char *szSequence ) { int iSequence; @@ -2863,7 +2863,7 @@ void CBaseMonster::ReportAIState( void ) else ALERT( level, "No Schedule, " ); - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) ALERT( level, "\nEnemy is %s", STRING( m_hEnemy->pev->classname ) ); else ALERT( level, "No enemy" ); @@ -2950,7 +2950,7 @@ BOOL CBaseMonster::FCheckAITrigger( void ) switch( m_iTriggerCondition ) { case AITRIGGER_SEEPLAYER_ANGRY_AT_PLAYER: - if( m_hEnemy != NULL && m_hEnemy->IsPlayer() && HasConditions( bits_COND_SEE_ENEMY ) ) + if( m_hEnemy != 0 && m_hEnemy->IsPlayer() && HasConditions( bits_COND_SEE_ENEMY ) ) { fFireTarget = TRUE; } @@ -3321,7 +3321,7 @@ BOOL CBaseMonster::GetEnemy( void ) } // remember old enemies - if( m_hEnemy == NULL && PopEnemy() ) + if( m_hEnemy == 0 && PopEnemy() ) { if( m_pSchedule ) { @@ -3332,7 +3332,7 @@ BOOL CBaseMonster::GetEnemy( void ) } } - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { // monster has an enemy. return TRUE; @@ -3344,7 +3344,7 @@ BOOL CBaseMonster::GetEnemy( void ) //========================================================= // DropItem - dead monster drops named item //========================================================= -CBaseEntity *CBaseMonster::DropItem( char *pszItemName, const Vector &vecPos, const Vector &vecAng ) +CBaseEntity *CBaseMonster::DropItem( const char *pszItemName, const Vector &vecPos, const Vector &vecAng ) { if( !pszItemName ) { diff --git a/dlls/monsterstate.cpp b/dlls/monsterstate.cpp index f29664dc..cec29b79 100644 --- a/dlls/monsterstate.cpp +++ b/dlls/monsterstate.cpp @@ -42,7 +42,7 @@ void CBaseMonster::SetState( MONSTERSTATE State ) // Drop enemy pointers when going to idle case MONSTERSTATE_IDLE: - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { m_hEnemy = NULL;// not allowed to have an enemy anymore. ALERT( at_aiconsole, "Stripped\n" ); @@ -92,7 +92,7 @@ void CBaseMonster::RunAI( void ) } // do these calculations if monster has an enemy. - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { CheckEnemy( m_hEnemy ); } @@ -198,7 +198,7 @@ MONSTERSTATE CBaseMonster::GetIdealState( void ) COMBAT goes to ALERT upon death of enemy */ { - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { m_IdealMonsterState = MONSTERSTATE_ALERT; // pev->effects = EF_BRIGHTFIELD; diff --git a/dlls/mpstubb.cpp b/dlls/mpstubb.cpp index 703a4dba..12b3a82f 100644 --- a/dlls/mpstubb.cpp +++ b/dlls/mpstubb.cpp @@ -230,7 +230,7 @@ CBaseEntity *CBaseMonster::BestVisibleEnemy( void ) // currently think is the best visible enemy. No need to do // a distance check, just get mad at this one for now. iBestRelationship = IRelationship( pNextEnt ); - iNearest = ( pNextEnt->pev->origin - pev->origin ).Length(); + (int)iNearest = ( pNextEnt->pev->origin - pev->origin ).Length(); pReturn = pNextEnt; } else if( IRelationship( pNextEnt ) == iBestRelationship ) @@ -238,7 +238,7 @@ CBaseEntity *CBaseMonster::BestVisibleEnemy( void ) // this entity is disliked just as much as the entity that // we currently think is the best visible enemy, so we only // get mad at it if it is closer. - iDist = ( pNextEnt->pev->origin - pev->origin ).Length(); + (int)iDist = ( pNextEnt->pev->origin - pev->origin ).Length(); if( iDist <= iNearest ) { diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index ebef51de..9da8d0b4 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -256,7 +256,7 @@ void CHalfLifeMultiplay::Think( void ) if( pPlayer ) { - remain = flFragLimit - pPlayer->pev->frags; + remain = (int)( flFragLimit - pPlayer->pev->frags ); if( remain < bestfrags ) { bestfrags = remain; @@ -300,7 +300,7 @@ BOOL CHalfLifeMultiplay::IsDeathmatch( void ) //========================================================= BOOL CHalfLifeMultiplay::IsCoOp( void ) { - return gpGlobals->coop; + return gpGlobals->coop ? TRUE : FALSE; } //========================================================= @@ -467,7 +467,7 @@ void CHalfLifeMultiplay::InitHUD( CBasePlayer *pl ) { MESSAGE_BEGIN( MSG_ONE, gmsgScoreInfo, NULL, pl->edict() ); WRITE_BYTE( i ); // client number - WRITE_SHORT( plr->pev->frags ); + WRITE_SHORT( (int)plr->pev->frags ); WRITE_SHORT( plr->m_iDeaths ); WRITE_SHORT( 0 ); WRITE_SHORT( GetTeamIndex( plr->m_szTeamName ) + 1 ); @@ -652,7 +652,7 @@ void CHalfLifeMultiplay::PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, // killed scores MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo ); WRITE_BYTE( ENTINDEX(pVictim->edict()) ); - WRITE_SHORT( pVictim->pev->frags ); + WRITE_SHORT( (int)pVictim->pev->frags ); WRITE_SHORT( pVictim->m_iDeaths ); WRITE_SHORT( 0 ); WRITE_SHORT( GetTeamIndex( pVictim->m_szTeamName ) + 1 ); @@ -666,7 +666,7 @@ void CHalfLifeMultiplay::PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo ); WRITE_BYTE( ENTINDEX( PK->edict() ) ); - WRITE_SHORT( PK->pev->frags ); + WRITE_SHORT( (int)PK->pev->frags ); WRITE_SHORT( PK->m_iDeaths ); WRITE_SHORT( 0 ); WRITE_SHORT( GetTeamIndex( PK->m_szTeamName ) + 1 ); @@ -689,14 +689,14 @@ void CHalfLifeMultiplay::PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, void CHalfLifeMultiplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor ) { // Work out what killed the player, and send a message to all clients about it - CBaseEntity *Killer = CBaseEntity::Instance( pKiller ); + CBaseEntity::Instance( pKiller ); const char *killer_weapon_name = "world"; // by default, the player is killed by the world int killer_index = 0; // Hack to fix name change - char *tau = "tau_cannon"; - char *gluon = "gluon gun"; + const char *tau = "tau_cannon"; + const char *gluon = "gluon gun"; if( pKiller->flags & FL_CLIENT ) { diff --git a/dlls/nihilanth.cpp b/dlls/nihilanth.cpp index ba1c6192..479a2b34 100644 --- a/dlls/nihilanth.cpp +++ b/dlls/nihilanth.cpp @@ -587,7 +587,7 @@ void CNihilanth::ShootBalls( void ) while( m_flShootTime < m_flShootEnd && m_flShootTime < gpGlobals->time ) { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { Vector vecSrc, vecDir; CNihilanthHVR *pEntity; @@ -742,7 +742,7 @@ void CNihilanth::NextActivity() float flDist = ( m_posDesired - pev->origin ).Length(); float flDot = DotProduct( m_vecDesired, gpGlobals->v_forward ); - if( m_hRecharger != NULL ) + if( m_hRecharger != 0 ) { // at we at power up yet? if( flDist < 128.0 ) @@ -767,23 +767,23 @@ void CNihilanth::NextActivity() return; } - if( m_hEnemy != NULL && !m_hEnemy->IsAlive() ) + if( m_hEnemy != 0 && !m_hEnemy->IsAlive() ) { - m_hEnemy = NULL; + m_hEnemy = 0; } if( m_flLastSeen + 15 < gpGlobals->time ) { - m_hEnemy = NULL; + m_hEnemy = 0; } - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { Look( 4096 ); m_hEnemy = BestVisibleEnemy(); } - if( m_hEnemy != NULL && m_irritation != 0 ) + if( m_hEnemy != 0 && m_irritation != 0 ) { if( m_flLastSeen + 5 > gpGlobals->time && flDist < 256 && flDot > 0 ) { @@ -860,7 +860,7 @@ void CNihilanth::HuntThink( void ) } // look for current enemy - if( m_hEnemy != NULL && m_hRecharger == NULL ) + if( m_hEnemy != 0 && m_hRecharger == NULL ) { if( FVisible( m_hEnemy ) ) { @@ -928,7 +928,7 @@ void CNihilanth::Flight( void ) if( flDir < 0 ) flSpeed = -flSpeed; - float flDist = DotProduct( m_posDesired - vecEst, gpGlobals->v_forward ); + //float flDist = DotProduct( m_posDesired - vecEst, gpGlobals->v_forward ); // sideways drag m_velocity.x = m_velocity.x * ( 1.0 - fabs( gpGlobals->v_right.x ) * 0.05 ); @@ -959,7 +959,7 @@ BOOL CNihilanth::AbsorbSphere( void ) { for( int i = 0; i < N_SPHERES; i++ ) { - if( m_hSphere[i] != NULL ) + if( m_hSphere[i] != 0 ) { CNihilanthHVR *pSphere = (CNihilanthHVR *)( (CBaseEntity *)m_hSphere[i] ); pSphere->AbsorbInit(); @@ -978,7 +978,7 @@ BOOL CNihilanth::EmitSphere( void ) for( int i = 0; i < N_SPHERES; i++ ) { - if( m_hSphere[i] != NULL ) + if( m_hSphere[i] != 0 ) { m_iActiveSpheres++; } @@ -1007,10 +1007,10 @@ void CNihilanth::TargetSphere( USE_TYPE useType, float value ) for( i = 0; i < N_SPHERES; i++ ) { - if( m_hSphere[i] != NULL ) + if( m_hSphere[i] != 0 ) { pSphere = m_hSphere[i]->MyMonsterPointer(); - if( pSphere->m_hEnemy == NULL ) + if( pSphere->m_hEnemy == 0 ) break; } } @@ -1141,7 +1141,7 @@ void CNihilanth::HandleAnimEvent( MonsterEvent_t *pEvent ) case 4: // get a sphere { - if( m_hRecharger != NULL ) + if( m_hRecharger != 0 ) { if( !EmitSphere() ) { @@ -1340,7 +1340,7 @@ void CNihilanthHVR::HoverThink( void ) { pev->nextthink = gpGlobals->time + 0.1; - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) { CircleTarget( m_hTargetEnt->pev->origin + Vector( 0, 0, 16 * N_SCALE ) ); } @@ -1424,7 +1424,7 @@ void CNihilanthHVR::ZapThink( void ) pev->nextthink = gpGlobals->time + 0.05; // check world boundaries - if( m_hEnemy == NULL || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096 ) + if( m_hEnemy == 0 || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096 ) { SetTouch( NULL ); UTIL_Remove( this ); @@ -1561,7 +1561,7 @@ void CNihilanthHVR::TeleportThink( void ) pev->nextthink = gpGlobals->time + 0.1; // check world boundaries - if( m_hEnemy == NULL || !m_hEnemy->IsAlive() || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096 ) + if( m_hEnemy == 0 || !m_hEnemy->IsAlive() || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096 ) { STOP_SOUND( edict(), CHAN_WEAPON, "x/x_teleattack1.wav" ); UTIL_Remove( this ); @@ -1573,10 +1573,10 @@ void CNihilanthHVR::TeleportThink( void ) STOP_SOUND( edict(), CHAN_WEAPON, "x/x_teleattack1.wav" ); UTIL_Remove( this ); - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) m_hTargetEnt->Use( m_hEnemy, m_hEnemy, USE_ON, 1.0 ); - if( m_hTouch != NULL && m_hEnemy != NULL ) + if( m_hTouch != 0 && m_hEnemy != NULL ) m_hTouch->Touch( m_hEnemy ); } else @@ -1630,10 +1630,10 @@ void CNihilanthHVR::TeleportTouch( CBaseEntity *pOther ) if( pOther == pEnemy ) { - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) m_hTargetEnt->Use( pEnemy, pEnemy, USE_ON, 1.0 ); - if( m_hTouch != NULL && pEnemy != NULL ) + if( m_hTouch != 0 && pEnemy != NULL ) m_hTouch->Touch( pEnemy ); } else @@ -1656,7 +1656,7 @@ void CNihilanthHVR::DissipateThink( void ) pev->renderamt -= 2; pev->scale += 0.1; - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) { CircleTarget( m_hTargetEnt->pev->origin + Vector( 0, 0, 4096 ) ); } diff --git a/dlls/nodes.cpp b/dlls/nodes.cpp index a97b6a80..68a1c267 100644 --- a/dlls/nodes.cpp +++ b/dlls/nodes.cpp @@ -214,7 +214,7 @@ entvars_t *CGraph::LinkEntForLink( CLink *pLink, CNode *pNode ) //========================================================= int CGraph::HandleLinkEnt( int iNode, entvars_t *pevLinkEnt, int afCapMask, NODEQUERY queryType ) { - edict_t *pentWorld; + //edict_t *pentWorld; CBaseEntity *pDoor; TraceResult tr; @@ -230,7 +230,7 @@ int CGraph::HandleLinkEnt( int iNode, entvars_t *pevLinkEnt, int afCapMask, NODE ALERT( at_aiconsole, "dead path ent!\n" ); return TRUE; } - pentWorld = NULL; + //pentWorld = NULL; // func_door if( FClassnameIs( pevLinkEnt, "func_door" ) || FClassnameIs( pevLinkEnt, "func_door_rotating" ) ) @@ -586,7 +586,7 @@ int CGraph::FindShortestPath( int *piPath, int iStart, int iDest, int iHull, int int iVisitNode; int iCurrentNode; int iNumPathNodes; - int iHullMask; + int iHullMask = 0; if( !m_fGraphPresent || !m_fGraphPointersSet ) { @@ -1665,10 +1665,10 @@ void CTestHull::BuildNodeGraph( void ) int iBadNode;// this is the node that caused graph generation to fail - int cMaxInitialLinks = 0; - int cMaxValidLinks = 0; + //int cMaxInitialLinks = 0; + //int cMaxValidLinks = 0; - int iPoolIndex = 0; + //int iPoolIndex = 0; int cPoolLinks;// number of links in the pool. Vector vecDirToCheckNode; @@ -2058,11 +2058,16 @@ void CTestHull::BuildNodeGraph( void ) fprintf( file, "\nAll Connections are Paired!\n" ); } +#ifdef _MSC_VER +#define SIZET_FMT "%Iu" +#else +#define SIZET_FMT "%zu" +#endif fprintf( file, "-------------------------------------------------------------------------------\n" ); fprintf( file, "\n\n-------------------------------------------------------------------------------\n" ); fprintf( file, "Total Number of Connections in Pool: %d\n", cPoolLinks ); fprintf( file, "-------------------------------------------------------------------------------\n" ); - fprintf( file, "Connection Pool: %d bytes\n", sizeof(CLink) * cPoolLinks ); + fprintf( file, "Connection Pool: " SIZET_FMT " bytes\n", sizeof(CLink) * cPoolLinks ); fprintf( file, "-------------------------------------------------------------------------------\n" ); ALERT( at_aiconsole, "%d Nodes, %d Connections\n", WorldGraph.m_cNodes, cPoolLinks ); diff --git a/dlls/nodes.h b/dlls/nodes.h index 27b890ed..2b582a6f 100644 --- a/dlls/nodes.h +++ b/dlls/nodes.h @@ -15,7 +15,8 @@ //========================================================= // nodes.h //========================================================= - +#ifndef NODES_H +#define NODES_H //========================================================= // DEFINE //========================================================= @@ -370,3 +371,4 @@ enum }; extern CGraph WorldGraph; +#endif // NODES_H diff --git a/dlls/observer.cpp b/dlls/observer.cpp index 0eda7490..f3fc54a0 100644 --- a/dlls/observer.cpp +++ b/dlls/observer.cpp @@ -35,7 +35,7 @@ void CBasePlayer::Observer_FindNextPlayer( bool bReverse ) else iStart = ENTINDEX( edict() ); int iCurrent = iStart; - m_hObserverTarget = NULL; + m_hObserverTarget = 0; int iDir = bReverse ? -1 : 1; do @@ -125,11 +125,11 @@ void CBasePlayer::Observer_CheckTarget() return; // try to find a traget if we have no current one - if( m_hObserverTarget == NULL ) + if( m_hObserverTarget == 0 ) { Observer_FindNextPlayer( false ); - if( m_hObserverTarget == NULL ) + if( m_hObserverTarget == 0 ) { // no target found at all @@ -166,7 +166,7 @@ void CBasePlayer::Observer_CheckTarget() void CBasePlayer::Observer_CheckProperties() { // try to find a traget if we have no current one - if( pev->iuser1 == OBS_IN_EYE && m_hObserverTarget != NULL ) + if( pev->iuser1 == OBS_IN_EYE && m_hObserverTarget != 0 ) { CBasePlayer* target = (CBasePlayer*)( UTIL_PlayerByIndex( ENTINDEX( m_hObserverTarget->edict() ) ) ); @@ -222,26 +222,26 @@ void CBasePlayer::Observer_SetMode( int iMode ) if( iMode < OBS_CHASE_LOCKED || iMode > OBS_MAP_CHASE ) iMode = OBS_IN_EYE; // now it is // verify observer target again - if( m_hObserverTarget != NULL ) + if( m_hObserverTarget != 0 ) { CBaseEntity *pEnt = m_hObserverTarget; if( ( pEnt == this ) || ( pEnt == NULL ) ) - m_hObserverTarget = NULL; + m_hObserverTarget = 0; else if( ( (CBasePlayer*)pEnt )->IsObserver() || ( pEnt->pev->effects & EF_NODRAW ) ) - m_hObserverTarget = NULL; + m_hObserverTarget = 0; } // set spectator mode pev->iuser1 = iMode; // if we are not roaming, we need a valid target to track - if( ( iMode != OBS_ROAMING ) && ( m_hObserverTarget == NULL ) ) + if( ( iMode != OBS_ROAMING ) && ( m_hObserverTarget == 0 ) ) { Observer_FindNextPlayer( false ); // if we didn't find a valid target switch to roaming - if( m_hObserverTarget == NULL ) + if( m_hObserverTarget == 0 ) { ClientPrint( pev, HUD_PRINTCENTER, "#Spec_NoTarget" ); pev->iuser1 = OBS_ROAMING; diff --git a/dlls/osprey.cpp b/dlls/osprey.cpp index 95088d2b..6a421645 100644 --- a/dlls/osprey.cpp +++ b/dlls/osprey.cpp @@ -261,7 +261,7 @@ BOOL COsprey::HasDead() { for( int i = 0; i < m_iUnits; i++ ) { - if( m_hGrunt[i] == NULL || !m_hGrunt[i]->IsAlive() ) + if( m_hGrunt[i] == 0 || !m_hGrunt[i]->IsAlive() ) { return TRUE; } @@ -285,9 +285,9 @@ CBaseMonster *COsprey::MakeGrunt( Vector vecSrc ) for( int i = 0; i < m_iUnits; i++ ) { - if( m_hGrunt[i] == NULL || !m_hGrunt[i]->IsAlive() ) + if( m_hGrunt[i] == 0 || !m_hGrunt[i]->IsAlive() ) { - if( m_hGrunt[i] != NULL && m_hGrunt[i]->pev->rendermode == kRenderNormal ) + if( m_hGrunt[i] != 0 && m_hGrunt[i]->pev->rendermode == kRenderNormal ) { m_hGrunt[i]->SUB_StartFadeOut(); } @@ -319,7 +319,7 @@ void COsprey::HoverThink( void ) int i; for( i = 0; i < 4; i++ ) { - if( m_hRepel[i] != NULL && m_hRepel[i]->pev->health > 0 && !( m_hRepel[i]->pev->flags & FL_ONGROUND ) ) + if( m_hRepel[i] != 0 && m_hRepel[i]->pev->health > 0 && !( m_hRepel[i]->pev->flags & FL_ONGROUND ) ) { break; } diff --git a/dlls/plats.cpp b/dlls/plats.cpp index 93fb22fe..8fecf684 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -82,12 +82,12 @@ void CBasePlatTrain::KeyValue( KeyValueData *pkvd ) } else if( FStrEq( pkvd->szKeyName, "movesnd" ) ) { - m_bMoveSnd = atof( pkvd->szValue ); + m_bMoveSnd = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "stopsnd" ) ) { - m_bStopSnd = atof( pkvd->szValue ); + m_bStopSnd = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "volume" ) ) @@ -1437,7 +1437,7 @@ void CFuncTrackTrain::Spawn( void ) pev->speed = 0; pev->velocity = g_vecZero; pev->avelocity = g_vecZero; - pev->impulse = m_speed; + pev->impulse = (int)m_speed; m_dir = 1; @@ -2212,7 +2212,7 @@ void CGunTarget::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE us { pev->takedamage = DAMAGE_AIM; m_hTargetEnt = GetNextTarget(); - if( m_hTargetEnt == NULL ) + if( m_hTargetEnt == 0 ) return; pev->health = pev->max_health; Next(); diff --git a/dlls/player.cpp b/dlls/player.cpp index 7d7363b5..51995acf 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -459,7 +459,7 @@ int CBasePlayer::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, fl } // keep track of amount of damage last sustained - m_lastDamageAmount = flDamage; + m_lastDamageAmount = (int)flDamage; // Armor. if( pev->armorvalue && !( bitsDamageType & ( DMG_FALL | DMG_DROWN ) ) )// armor doesn't protect against fall or drown damage! @@ -787,7 +787,7 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) m_pLastItem = NULL; - if( m_pTank != NULL ) + if( m_pTank != 0 ) { m_pTank->Use( this, this, USE_OFF, 0 ); m_pTank = NULL; @@ -847,7 +847,7 @@ void CBasePlayer::Killed( entvars_t *pevAttacker, int iGib ) g_pGameRules->PlayerKilled( this, pevAttacker, g_pevLastInflictor ); - if( m_pTank != NULL ) + if( m_pTank != 0 ) { m_pTank->Use( this, this, USE_OFF, 0 ); m_pTank = NULL; @@ -1172,7 +1172,7 @@ void CBasePlayer::WaterMove() // track drowning damage, give it back when // player finally takes a breath - m_idrowndmg += pev->dmg; + m_idrowndmg += (int)pev->dmg; } } else @@ -1393,7 +1393,7 @@ void CBasePlayer::StartObserver( Vector vecPosition, Vector vecViewAngle ) if( m_pActiveItem ) m_pActiveItem->Holster(); - if( m_pTank != NULL ) + if( m_pTank != 0 ) { m_pTank->Use( this, this, USE_OFF, 0 ); m_pTank = NULL; @@ -1468,7 +1468,7 @@ void CBasePlayer::PlayerUse( void ) // Hit Use on a train? if( m_afButtonPressed & IN_USE ) { - if( m_pTank != NULL ) + if( m_pTank != 0 ) { // Stop controlling the tank // TODO: Send HUD Update @@ -1491,7 +1491,7 @@ void CBasePlayer::PlayerUse( void ) if( pTrain && !( pev->button & IN_JUMP ) && FBitSet( pev->flags, FL_ONGROUND ) && (pTrain->ObjectCaps() & FCAP_DIRECTIONAL_USE ) && pTrain->OnControls( pev ) ) { m_afPhysicsFlags |= PFLAG_ONTRAIN; - m_iTrain = TrainSpeed( pTrain->pev->speed, pTrain->pev->impulse ); + m_iTrain = TrainSpeed( (int)pTrain->pev->speed, pTrain->pev->impulse ); m_iTrain |= TRAIN_NEW; EMIT_SOUND( ENT( pev ), CHAN_ITEM, "plats/train_use1.wav", 0.8, ATTN_NORM ); return; @@ -1662,7 +1662,7 @@ void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) if( -score > pev->frags ) // Will this go negative? { - score = -pev->frags; // Sum will be 0 + score = (int)( -pev->frags ); // Sum will be 0 } } } @@ -1671,7 +1671,7 @@ void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo ); WRITE_BYTE( ENTINDEX( edict() ) ); - WRITE_SHORT( pev->frags ); + WRITE_SHORT( (int)pev->frags ); WRITE_SHORT( m_iDeaths ); WRITE_SHORT( 0 ); WRITE_SHORT( g_pGameRules->GetTeamIndex( m_szTeamName ) + 1 ); @@ -1733,8 +1733,8 @@ void CBasePlayer::UpdateStatusBar() // allies and medics get to see the targets health if( g_pGameRules->PlayerRelationship( this, pEntity ) == GR_TEAMMATE ) { - newSBarState[SBAR_ID_TARGETHEALTH] = 100 * ( pEntity->pev->health / pEntity->pev->max_health ); - newSBarState[SBAR_ID_TARGETARMOR] = pEntity->pev->armorvalue; //No need to get it % based since 100 it's the max. + newSBarState[SBAR_ID_TARGETHEALTH] = (int)( 100 * ( pEntity->pev->health / pEntity->pev->max_health ) ); + newSBarState[SBAR_ID_TARGETARMOR] = (int)pEntity->pev->armorvalue; //No need to get it % based since 100 it's the max. } m_flStatusBarDisappearDelay = gpGlobals->time + 1.0; @@ -1899,7 +1899,7 @@ void CBasePlayer::PreThink( void ) if( vel ) { - m_iTrain = TrainSpeed( pTrain->pev->speed, pTrain->pev->impulse ); + m_iTrain = TrainSpeed( (int)pTrain->pev->speed, pTrain->pev->impulse ); m_iTrain |= TRAIN_ACTIVE|TRAIN_NEW; } } @@ -2010,7 +2010,7 @@ void CBasePlayer::CheckTimeBasedDamage() int i; BYTE bDuration = 0; - static float gtbdPrev = 0.0; + //static float gtbdPrev = 0.0; if( !( m_bitsDamageType & DMG_TIMEBASED ) ) return; @@ -2271,7 +2271,7 @@ void CBasePlayer::CheckSuitUpdate() // seconds, then we won't repeat playback of this word or sentence // for at least that number of seconds. -void CBasePlayer::SetSuitUpdate( char *name, int fgroup, int iNoRepeatTime ) +void CBasePlayer::SetSuitUpdate( const char *name, int fgroup, int iNoRepeatTime ) { int i; int isentence; @@ -2399,7 +2399,7 @@ void CBasePlayer::UpdatePlayerSound( void ) // is louder than his body/movement, use the weapon volume, else, use the body volume. if( FBitSet( pev->flags, FL_ONGROUND ) ) { - iBodyVolume = pev->velocity.Length(); + iBodyVolume = (int)pev->velocity.Length(); // clamp the noise that can be made by the body, in case a push trigger, // weapon recoil, or anything shoves the player abnormally fast. @@ -2432,7 +2432,7 @@ void CBasePlayer::UpdatePlayerSound( void ) } // decay weapon volume over time so bits_SOUND_COMBAT stays set for a while - m_iWeaponVolume -= 250 * gpGlobals->frametime; + m_iWeaponVolume -= (int)( 250 * gpGlobals->frametime ); if( m_iWeaponVolume < 0 ) { iVolume = 0; @@ -2450,7 +2450,7 @@ void CBasePlayer::UpdatePlayerSound( void ) } else if( iVolume > m_iTargetVolume ) { - iVolume -= 250 * gpGlobals->frametime; + iVolume -= (int)( 250 * gpGlobals->frametime ); if( iVolume < m_iTargetVolume ) { @@ -2479,7 +2479,7 @@ void CBasePlayer::UpdatePlayerSound( void ) } // keep track of virtual muzzle flash - m_iWeaponFlash -= 256 * gpGlobals->frametime; + m_iWeaponFlash -= (int)( 256 * gpGlobals->frametime ); if( m_iWeaponFlash < 0 ) m_iWeaponFlash = 0; @@ -2501,7 +2501,7 @@ void CBasePlayer::PostThink() goto pt_end; // Handle Tank controlling - if( m_pTank != NULL ) + if( m_pTank != 0 ) { // if they've moved too far from the gun, or selected a weapon, unuse the gun if( m_pTank->OnControls( pev ) && !pev->weaponmodel ) @@ -2565,7 +2565,7 @@ void CBasePlayer::PostThink() { if( m_flFallVelocity > 64 && !g_pGameRules->IsMultiplayer() ) { - CSoundEnt::InsertSound( bits_SOUND_PLAYER, pev->origin, m_flFallVelocity, 0.2 ); + CSoundEnt::InsertSound( bits_SOUND_PLAYER, pev->origin, (int)m_flFallVelocity, 0.2 ); // ALERT( at_console, "fall %f\n", m_flFallVelocity ); } m_flFallVelocity = 0; @@ -3195,7 +3195,7 @@ void CSprayCan::Think( void ) } else { - UTIL_PlayerDecalTrace( &tr, playernum, pev->frame, TRUE ); + UTIL_PlayerDecalTrace( &tr, playernum, (int)pev->frame, TRUE ); // Just painted last custom frame. if( pev->frame++ >= ( nFrames - 1 ) ) UTIL_Remove( this ); @@ -3682,7 +3682,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 ) { @@ -3756,10 +3756,10 @@ Called every frame by the player PostThink */ void CBasePlayer::ItemPostFrame() { - static int fInSelect = FALSE; + //static int fInSelect = FALSE; // check if the player is using a tank - if( m_pTank != NULL ) + if( m_pTank != 0 ) return; #if defined( CLIENT_WEAPONS ) @@ -3912,12 +3912,12 @@ void CBasePlayer::UpdateClientData( void ) WRITE_BYTE( iHealth ); MESSAGE_END(); - m_iClientHealth = pev->health; + m_iClientHealth = (int)pev->health; } if( pev->armorvalue != m_iClientBattery ) { - m_iClientBattery = pev->armorvalue; + m_iClientBattery = (int)pev->armorvalue; ASSERT( gmsgBattery > 0 ); @@ -3945,8 +3945,8 @@ void CBasePlayer::UpdateClientData( void ) int visibleDamageBits = m_bitsDamageType & DMG_SHOWNHUD; MESSAGE_BEGIN( MSG_ONE, gmsgDamage, NULL, pev ); - WRITE_BYTE( pev->dmg_save ); - WRITE_BYTE( pev->dmg_take ); + WRITE_BYTE( (int)pev->dmg_save ); + WRITE_BYTE( (int)pev->dmg_take ); WRITE_LONG( visibleDamageBits ); WRITE_COORD( damageOrigin.x ); WRITE_COORD( damageOrigin.y ); @@ -4211,8 +4211,8 @@ Vector CBasePlayer::GetAutoaimVector( float flDelta ) { SET_CROSSHAIRANGLE( edict(), -m_vecAutoAim.x, m_vecAutoAim.y ); - m_lastx = m_vecAutoAim.x; - m_lasty = m_vecAutoAim.y; + m_lastx = (int)m_vecAutoAim.x; + m_lasty = (int)m_vecAutoAim.y; } } @@ -4556,10 +4556,10 @@ public: void KeyValue( KeyValueData *pkvd ); int m_iPose;// which sequence to display -- temporary, don't need to save - static char *m_szPoses[4]; + static const char *m_szPoses[4]; }; -char *CDeadHEV::m_szPoses[] = +const char *CDeadHEV::m_szPoses[] = { "deadback", "deadsitting", @@ -4701,7 +4701,7 @@ void CRevertSaved::KeyValue( KeyValueData *pkvd ) void CRevertSaved::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - UTIL_ScreenFadeAll( pev->rendercolor, Duration(), HoldTime(), pev->renderamt, FFADE_OUT ); + UTIL_ScreenFadeAll( pev->rendercolor, Duration(), HoldTime(), (int)pev->renderamt, FFADE_OUT ); pev->nextthink = gpGlobals->time + MessageTime(); SetThink( &CRevertSaved::MessageThink ); } diff --git a/dlls/player.h b/dlls/player.h index cb2bddf8..b2dce868 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -273,7 +273,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 ); @@ -281,7 +281,7 @@ public: void PlayerUse( void ); void CheckSuitUpdate(); - void SetSuitUpdate(char *name, int fgroup, int iNoRepeat); + void SetSuitUpdate( const char *name, int fgroup, int iNoRepeat ); void UpdateGeigerCounter( void ); void CheckTimeBasedDamage( void ); diff --git a/dlls/satchel.cpp b/dlls/satchel.cpp index 05d1fc8c..458ac532 100644 --- a/dlls/satchel.cpp +++ b/dlls/satchel.cpp @@ -92,7 +92,7 @@ void CSatchelCharge::Spawn( void ) void CSatchelCharge::SatchelSlide( CBaseEntity *pOther ) { - entvars_t *pevOther = pOther->pev; + //entvars_t *pevOther = pOther->pev; // don't hit the guy that launched this grenade if( pOther->edict() == pev->owner ) @@ -377,11 +377,11 @@ void CSatchel::Throw( void ) { if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { +#ifndef CLIENT_DLL Vector vecSrc = m_pPlayer->pev->origin; Vector vecThrow = gpGlobals->v_forward * 274 + m_pPlayer->pev->velocity; -#ifndef CLIENT_DLL CBaseEntity *pSatchel = Create( "monster_satchel", vecSrc, Vector( 0, 0, 0 ), m_pPlayer->edict() ); pSatchel->pev->velocity = vecThrow; pSatchel->pev->avelocity.y = 400; diff --git a/dlls/saverestore.h b/dlls/saverestore.h index a9ad2c54..4295871d 100644 --- a/dlls/saverestore.h +++ b/dlls/saverestore.h @@ -23,7 +23,7 @@ class CSaveRestoreBuffer public: CSaveRestoreBuffer( void ); CSaveRestoreBuffer( SAVERESTOREDATA *pdata ); - ~CSaveRestoreBuffer( void ); + virtual ~CSaveRestoreBuffer( void ); int EntityIndex( entvars_t *pevLookup ); int EntityIndex( edict_t *pentLookup ); @@ -41,6 +41,10 @@ protected: SAVERESTOREDATA *m_pdata; void BufferRewind( int size ); unsigned int HashString( const char *pszToken ); +private: + // effc++ rule 11 + void operator = ( CSaveRestoreBuffer& ); + CSaveRestoreBuffer( const CSaveRestoreBuffer& ); }; class CSave : public CSaveRestoreBuffer @@ -81,7 +85,7 @@ typedef struct class CRestore : public CSaveRestoreBuffer { public: - CRestore( SAVERESTOREDATA *pdata ) : CSaveRestoreBuffer( pdata ) { m_global = 0; m_precache = TRUE; } + CRestore( SAVERESTOREDATA *pdata ) : CSaveRestoreBuffer( pdata ), m_global(0), m_precache( TRUE ) { } int ReadEntVars( const char *pname, entvars_t *pev ); // entvars_t int ReadFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); int ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount, int startField, int size, char *pName, void *pData ); @@ -160,6 +164,9 @@ private: globalentity_t *Find( string_t globalname ); globalentity_t *m_pList; int m_listCount; + // effc++ rule 11 + void operator = ( CGlobalState& ); + CGlobalState( const CGlobalState& ); }; extern CGlobalState gGlobalState; diff --git a/dlls/schedule.cpp b/dlls/schedule.cpp index c28a88fa..4a5cefca 100644 --- a/dlls/schedule.cpp +++ b/dlls/schedule.cpp @@ -238,7 +238,7 @@ void CBaseMonster::MaintainSchedule( void ) { if( (m_afConditions && !HasConditions( bits_COND_SCHEDULE_DONE ) ) || ( m_pSchedule && (m_pSchedule->iInterruptMask & bits_COND_SCHEDULE_DONE ) ) || - ( ( m_MonsterState == MONSTERSTATE_COMBAT ) && ( m_hEnemy == NULL ) ) ) + ( ( m_MonsterState == MONSTERSTATE_COMBAT ) && ( m_hEnemy == 0 ) ) ) { GetIdealState(); } @@ -407,7 +407,7 @@ void CBaseMonster::RunTask( Task_t *pTask ) { float distance; - if( m_hTargetEnt == NULL ) + if( m_hTargetEnt == 0 ) TaskFail(); else { @@ -675,7 +675,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) } case TASK_FIND_NEAR_NODE_COVER_FROM_ENEMY: { - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { TaskFail(); return; @@ -695,7 +695,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) } case TASK_FIND_FAR_NODE_COVER_FROM_ENEMY: { - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { TaskFail(); return; @@ -715,7 +715,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) } case TASK_FIND_NODE_COVER_FROM_ENEMY: { - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { TaskFail(); return; @@ -737,7 +737,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) { entvars_t *pevCover; - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { // Find cover from self if no enemy available pevCover = pev; @@ -821,7 +821,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) SetTurnActivity(); break; case TASK_FACE_TARGET: - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) { MakeIdealYaw( m_hTargetEnt->pev->origin ); SetTurnActivity(); @@ -904,7 +904,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) TaskComplete(); else { - if( m_hTargetEnt == NULL || !MoveToTarget( newActivity, 2 ) ) + if( m_hTargetEnt == 0 || !MoveToTarget( newActivity, 2 ) ) { TaskFail(); ALERT( at_aiconsole, "%s Failed to reach target!!!\n", STRING( pev->classname ) ); @@ -1043,7 +1043,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) case TASK_GET_PATH_TO_TARGET: { RouteClear(); - if( m_hTargetEnt != NULL && MoveToTarget( m_movementActivity, 1 ) ) + if( m_hTargetEnt != 0 && MoveToTarget( m_movementActivity, 1 ) ) { TaskComplete(); } @@ -1272,7 +1272,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) } case TASK_PLANT_ON_SCRIPT: { - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) { pev->origin = m_hTargetEnt->pev->origin; // Plant on target } @@ -1282,7 +1282,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) } case TASK_FACE_SCRIPT: { - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) { pev->ideal_yaw = UTIL_AngleMod( m_hTargetEnt->pev->angles.y ); } diff --git a/dlls/scientist.cpp b/dlls/scientist.cpp index 4e60c58e..d7659c61 100644 --- a/dlls/scientist.cpp +++ b/dlls/scientist.cpp @@ -434,7 +434,7 @@ void CScientist::Scream( void ) Activity CScientist::GetStoppedActivity( void ) { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) return ACT_EXCITED; return CTalkMonster::GetStoppedActivity(); } @@ -510,7 +510,7 @@ void CScientist::RunTask( Task_t *pTask ) if( RANDOM_LONG( 0, 63 ) < 8 ) Scream(); - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { TaskFail(); } @@ -893,8 +893,8 @@ Schedule_t *CScientist::GetSchedule( void ) m_fearTime = gpGlobals->time; else if( DisregardEnemy( pEnemy ) ) // After 15 seconds of being hidden, return to alert { - m_hEnemy = NULL; - pEnemy = NULL; + m_hEnemy = 0; + pEnemy = 0; } } @@ -1021,12 +1021,12 @@ MONSTERSTATE CScientist::GetIdealState( void ) { // Strip enemy when going to alert m_IdealMonsterState = MONSTERSTATE_ALERT; - m_hEnemy = NULL; + m_hEnemy = 0; return m_IdealMonsterState; } // Follow if only scared a little - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) { m_IdealMonsterState = MONSTERSTATE_ALERT; return m_IdealMonsterState; @@ -1050,7 +1050,7 @@ MONSTERSTATE CScientist::GetIdealState( void ) BOOL CScientist::CanHeal( void ) { - if( ( m_healTime > gpGlobals->time ) || ( m_hTargetEnt == NULL ) || ( m_hTargetEnt->pev->health > ( m_hTargetEnt->pev->max_health * 0.5 ) ) ) + if( ( m_healTime > gpGlobals->time ) || ( m_hTargetEnt == 0 ) || ( m_hTargetEnt->pev->health > ( m_hTargetEnt->pev->max_health * 0.5 ) ) ) return FALSE; return TRUE; @@ -1093,10 +1093,10 @@ public: void KeyValue( KeyValueData *pkvd ); int m_iPose;// which sequence to display - static char *m_szPoses[7]; + static const char *m_szPoses[7]; }; -char *CDeadScientist::m_szPoses[] = +const char *CDeadScientist::m_szPoses[] = { "lying_on_back", "lying_on_stomach", diff --git a/dlls/scripted.cpp b/dlls/scripted.cpp index f3cf37c5..da9708d1 100644 --- a/dlls/scripted.cpp +++ b/dlls/scripted.cpp @@ -1068,7 +1068,7 @@ BOOL CScriptedSentence::AcceptableSpeaker( CBaseMonster *pMonster ) { if( pev->spawnflags & SF_SENTENCE_FOLLOWERS ) { - if( pMonster->m_hTargetEnt == NULL || !FClassnameIs( pMonster->m_hTargetEnt->pev, "player" ) ) + if( pMonster->m_hTargetEnt == 0 || !FClassnameIs( pMonster->m_hTargetEnt->pev, "player" ) ) return FALSE; } BOOL override; @@ -1124,7 +1124,7 @@ BOOL CScriptedSentence::StartSentence( CBaseMonster *pTarget ) if( !pTarget ) { ALERT( at_aiconsole, "Not Playing sentence %s\n", STRING( m_iszSentence ) ); - return NULL; + return FALSE; } BOOL bConcurrent = FALSE; diff --git a/dlls/skill.cpp b/dlls/skill.cpp index 2a68e1a5..689bbadb 100644 --- a/dlls/skill.cpp +++ b/dlls/skill.cpp @@ -25,13 +25,12 @@ skilldata_t gSkillData; // take the name of a cvar, tack a digit for the skill level // on, and return the value.of that Cvar //========================================================= -float GetSkillCvar( char *pName ) +float GetSkillCvar( const char *pName ) { - int iCount; float flValue; char szBuffer[64]; - iCount = sprintf( szBuffer, "%s%d",pName, gSkillData.iSkillLevel ); + sprintf( szBuffer, "%s%d",pName, gSkillData.iSkillLevel ); flValue = CVAR_GET_FLOAT( szBuffer ); diff --git a/dlls/skill.h b/dlls/skill.h index 5e784bed..12b784e3 100644 --- a/dlls/skill.h +++ b/dlls/skill.h @@ -136,7 +136,7 @@ struct skilldata_t }; extern DLL_GLOBAL skilldata_t gSkillData; -float GetSkillCvar( char *pName ); +float GetSkillCvar( const char *pName ); extern DLL_GLOBAL int g_iSkillLevel; diff --git a/dlls/sound.cpp b/dlls/sound.cpp index b97eee12..f6110a8d 100644 --- a/dlls/sound.cpp +++ b/dlls/sound.cpp @@ -448,7 +448,7 @@ void CAmbientGeneric::InitModulationParms( void ) { int pitchinc; - m_dpv.volrun = pev->health * 10; // 0 - 100 + m_dpv.volrun = (int)( pev->health * 10 ); // 0 - 100 if( m_dpv.volrun > 100 ) m_dpv.volrun = 100; if( m_dpv.volrun < 0 ) @@ -553,7 +553,7 @@ void CAmbientGeneric::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, if( fraction < 0.0 ) fraction = 0.01; - m_dpv.pitch = fraction * 255; + m_dpv.pitch = (int)( fraction * 255 ); UTIL_EmitAmbientSound( ENT( pev ), pev->origin, szSoundFile, 0, 0, SND_CHANGE_PITCH, m_dpv.pitch ); return; @@ -1610,7 +1610,7 @@ float TEXTURETYPE_PlaySound( TraceResult *ptr, Vector vecSrc, Vector vecEnd, in const char *pTextureName; float rgfl1[3]; float rgfl2[3]; - char *rgsz[4]; + const char *rgsz[4]; int cnt; float fattn = ATTN_NORM; @@ -1822,7 +1822,7 @@ IMPLEMENT_SAVERESTORE( CSpeaker, CBaseEntity ) // void CSpeaker::Spawn( void ) { - char *szSoundFile = (char*) STRING( pev->message ); + const char *szSoundFile = STRING( pev->message ); if( !m_preset && ( FStringNull( pev->message ) || strlen( szSoundFile ) < 1 ) ) { @@ -1854,7 +1854,7 @@ void CSpeaker::Precache( void ) } void CSpeaker::SpeakerThink( void ) { - char* szSoundFile; + const char* szSoundFile = NULL; float flvolume = pev->health * 0.1; float flattenuation = 0.3; int flags = 0; @@ -1911,7 +1911,7 @@ void CSpeaker::SpeakerThink( void ) } } else - szSoundFile = (char*)STRING( pev->message ); + szSoundFile = STRING( pev->message ); if( szSoundFile[0] == '!' ) { diff --git a/dlls/squadmonster.cpp b/dlls/squadmonster.cpp index a89f39f9..3d476b50 100644 --- a/dlls/squadmonster.cpp +++ b/dlls/squadmonster.cpp @@ -192,7 +192,7 @@ BOOL CSquadMonster::SquadAdd( CSquadMonster *pAdd ) for( int i = 0; i < MAX_SQUAD_MEMBERS - 1; i++ ) { - if( m_hSquadMember[i] == NULL ) + if( m_hSquadMember[i] == 0 ) { m_hSquadMember[i] = pAdd; pAdd->m_hSquadLeader = this; @@ -258,7 +258,7 @@ void CSquadMonster::SquadMakeEnemy( CBaseEntity *pEnemy ) // reset members who aren't activly engaged in fighting if( pMember->m_hEnemy != pEnemy && !pMember->HasConditions( bits_COND_SEE_ENEMY ) ) { - if( pMember->m_hEnemy != NULL ) + if( pMember->m_hEnemy != 0 ) { // remember their current enemy pMember->PushEnemy( pMember->m_hEnemy, pMember->m_vecEnemyLKP ); @@ -459,7 +459,7 @@ BOOL CSquadMonster::NoFriendlyFire( void ) Vector v_left; //!!!BUGBUG - to fix this, the planes must be aligned to where the monster will be firing its gun, not the direction it is facing!!! - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { UTIL_MakeVectors( UTIL_VecToAngles( m_hEnemy->Center() - pev->origin ) ); } @@ -508,9 +508,7 @@ BOOL CSquadMonster::NoFriendlyFire( void ) //========================================================= MONSTERSTATE CSquadMonster::GetIdealState ( void ) { - int iConditions; - - iConditions = IScheduleFlags(); + IScheduleFlags(); // If no schedule conditions, the new ideal state is probably the reason we're in here. switch( m_MonsterState ) @@ -565,7 +563,7 @@ BOOL CSquadMonster::SquadEnemySplit( void ) for( int i = 0; i < MAX_SQUAD_MEMBERS; i++ ) { CSquadMonster *pMember = pSquadLeader->MySquadMember( i ); - if( pMember != NULL && pMember->m_hEnemy != NULL && pMember->m_hEnemy != pEnemy ) + if( pMember != NULL && pMember->m_hEnemy != 0 && pMember->m_hEnemy != pEnemy ) { return TRUE; } diff --git a/dlls/squadmonster.h b/dlls/squadmonster.h index ecd75ee5..707910c2 100644 --- a/dlls/squadmonster.h +++ b/dlls/squadmonster.h @@ -88,7 +88,7 @@ public: else return (CSquadMonster *)( (CBaseEntity *)m_hSquadMember[i] ); } - int InSquad( void ) { return m_hSquadLeader != NULL; } + int InSquad( void ) { return m_hSquadLeader != 0; } int IsLeader( void ) { return m_hSquadLeader == this; } int SquadJoin( int searchRadius ); int SquadRecruit( int searchRadius, int maxMembers ); diff --git a/dlls/squeakgrenade.cpp b/dlls/squeakgrenade.cpp index 30ddda62..830cfab8 100644 --- a/dlls/squeakgrenade.cpp +++ b/dlls/squeakgrenade.cpp @@ -94,7 +94,7 @@ int CSqueakGrenade::Classify( void ) if( m_iMyClass != 0 ) return m_iMyClass; // protect against recursion - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { m_iMyClass = CLASS_INSECT; // no one cares about it switch( m_hEnemy->Classify() ) @@ -180,13 +180,13 @@ void CSqueakGrenade::Killed( entvars_t *pevAttacker, int iGib ) UTIL_BloodDrips( pev->origin, g_vecZero, BloodColor(), 80 ); - if( m_hOwner != NULL ) + if( m_hOwner != 0 ) RadiusDamage( pev, m_hOwner->pev, pev->dmg, CLASS_NONE, DMG_BLAST ); else RadiusDamage( pev, pev, pev->dmg, CLASS_NONE, DMG_BLAST ); // reset owner so death message happens - if( m_hOwner != NULL ) + if( m_hOwner != 0 ) pev->owner = m_hOwner->edict(); CBaseMonster::Killed( pevAttacker, GIB_ALWAYS ); @@ -230,7 +230,7 @@ void CSqueakGrenade::HuntThink( void ) pev->velocity = pev->velocity * 0.9; pev->velocity.z += 8.0; } - else if( ( pev->movetype = MOVETYPE_FLY ) ) + else if( pev->movetype == MOVETYPE_FLY ) { pev->movetype = MOVETYPE_BOUNCE; } @@ -241,7 +241,7 @@ void CSqueakGrenade::HuntThink( void ) m_flNextHunt = gpGlobals->time + 2.0; - CBaseEntity *pOther = NULL; + //CBaseEntity *pOther = NULL; Vector vecDir; TraceResult tr; @@ -251,7 +251,7 @@ void CSqueakGrenade::HuntThink( void ) UTIL_MakeVectors( pev->angles ); - if( m_hEnemy == NULL || !m_hEnemy->IsAlive() ) + if( m_hEnemy == 0 || !m_hEnemy->IsAlive() ) { // find target, bounce a bit towards it. Look( 512 ); @@ -270,7 +270,7 @@ void CSqueakGrenade::HuntThink( void ) if( flpitch < 80 ) flpitch = 80; - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( FVisible( m_hEnemy ) ) { @@ -350,9 +350,9 @@ void CSqueakGrenade::SuperBounceTouch( CBaseEntity *pOther ) if( tr.pHit->v.modelindex != pev->modelindex ) { // ALERT( at_console, "hit enemy\n" ); - ClearMultiDamage( ); + ClearMultiDamage(); pOther->TraceAttack( pev, gSkillData.snarkDmgBite, gpGlobals->v_forward, &tr, DMG_SLASH ); - if( m_hOwner != NULL ) + if( m_hOwner != 0 ) ApplyMultiDamage( pev, m_hOwner->pev ); else ApplyMultiDamage( pev, pev ); diff --git a/dlls/talkmonster.cpp b/dlls/talkmonster.cpp index d832c2cc..35bf3856 100644 --- a/dlls/talkmonster.cpp +++ b/dlls/talkmonster.cpp @@ -51,7 +51,7 @@ TYPEDESCRIPTION CTalkMonster::m_SaveData[] = IMPLEMENT_SAVERESTORE( CTalkMonster, CBaseMonster ) // array of friend names -char *CTalkMonster::m_szFriends[TLK_CFRIENDS] = +const char *CTalkMonster::m_szFriends[TLK_CFRIENDS] = { "monster_barney", "monster_scientist", @@ -391,7 +391,7 @@ void CTalkMonster::StartTask( Task_t *pTask ) case TASK_TLK_EYECONTACT: break; case TASK_TLK_IDEALYAW: - if( m_hTalkTarget != NULL ) + if( m_hTalkTarget != 0 ) { pev->yaw_speed = 60; float yaw = VecToYaw( m_hTalkTarget->pev->origin - pev->origin ) - pev->angles.y; @@ -536,7 +536,7 @@ void CTalkMonster::RunTask( Task_t *pTask ) } break; case TASK_TLK_EYECONTACT: - if( !IsMoving() && IsTalking() && m_hTalkTarget != NULL ) + if( !IsMoving() && IsTalking() && m_hTalkTarget != 0 ) { // ALERT( at_console, "waiting %f\n", m_flStopTalkTime - gpGlobals->time ); IdleHeadTurn( m_hTalkTarget->pev->origin ); @@ -561,7 +561,7 @@ void CTalkMonster::RunTask( Task_t *pTask ) } break; case TASK_WAIT_FOR_MOVEMENT: - if( IsTalking() && m_hTalkTarget != NULL ) + if( IsTalking() && m_hTalkTarget != 0 ) { // ALERT( at_console, "walking, talking\n" ); IdleHeadTurn( m_hTalkTarget->pev->origin ); @@ -582,7 +582,7 @@ void CTalkMonster::RunTask( Task_t *pTask ) IdleHeadTurn( pev->origin ); break; default: - if( IsTalking() && m_hTalkTarget != NULL ) + if( IsTalking() && m_hTalkTarget != 0 ) { IdleHeadTurn( m_hTalkTarget->pev->origin ); } @@ -603,7 +603,7 @@ void CTalkMonster::Killed( entvars_t *pevAttacker, int iGib ) LimitFollowers( CBaseEntity::Instance( pevAttacker ), 0 ); } - m_hTargetEnt = NULL; + m_hTargetEnt = 0; // Don't finish that sentence StopTalking(); SetUse( NULL ); @@ -613,7 +613,7 @@ void CTalkMonster::Killed( entvars_t *pevAttacker, int iGib ) CBaseEntity *CTalkMonster::EnumFriends( CBaseEntity *pPrevious, int listNumber, BOOL bTrace ) { CBaseEntity *pFriend = pPrevious; - char *pszFriend; + const char *pszFriend; TraceResult tr; Vector vecCheck; @@ -712,7 +712,7 @@ void CTalkMonster::LimitFollowers( CBaseEntity *pPlayer, int maxFollowers ) float CTalkMonster::TargetDistance( void ) { // If we lose the player, or he dies, return a really large distance - if( m_hTargetEnt == NULL || !m_hTargetEnt->IsAlive() ) + if( m_hTargetEnt == 0 || !m_hTargetEnt->IsAlive() ) return 1e6; return ( m_hTargetEnt->pev->origin - pev->origin ).Length(); @@ -764,7 +764,7 @@ CBaseEntity *CTalkMonster::FindNearestFriend( BOOL fPlayer ) Vector vecStart = pev->origin; Vector vecCheck; int i; - char *pszFriend; + const char *pszFriend; int cfriends; vecStart.z = pev->absmax.z; @@ -855,7 +855,7 @@ void CTalkMonster::Touch( CBaseEntity *pOther ) //========================================================= void CTalkMonster::IdleRespond( void ) { - int pitch = GetVoicePitch(); + //int pitch = GetVoicePitch(); // play response PlaySentence( m_szGrp[TLK_ANSWER], RANDOM_FLOAT( 2.8, 3.2 ), VOL_NORM, ATTN_IDLE ); @@ -890,7 +890,7 @@ int CTalkMonster::FOkToSpeak( void ) return FALSE; // don't talk if you're in combat - if( m_hEnemy != NULL && FVisible( m_hEnemy ) ) + if( m_hEnemy != 0 && FVisible( m_hEnemy ) ) return FALSE; return TRUE; @@ -977,7 +977,7 @@ void CTalkMonster::IdleHeadTurn( Vector &vecFriend ) int CTalkMonster::FIdleSpeak( void ) { // try to start a conversation, or make statement - int pitch; + //int pitch; const char *szIdleGroup; const char *szQuestionGroup; float duration; @@ -1001,7 +1001,7 @@ int CTalkMonster::FIdleSpeak( void ) duration = RANDOM_FLOAT( 2.8, 3.2 ); } - pitch = GetVoicePitch(); + //pitch = GetVoicePitch(); // player using this entity is alive and wounded? CBaseEntity *pTarget = m_hTargetEnt; @@ -1315,10 +1315,10 @@ void CTalkMonster::StopFollowing( BOOL clearSchedule ) if( m_movementGoal == MOVEGOAL_TARGETENT ) RouteClear(); // Stop him from walking toward the player - m_hTargetEnt = NULL; + m_hTargetEnt = 0; if( clearSchedule ) ClearSchedule(); - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) m_IdealMonsterState = MONSTERSTATE_COMBAT; } } @@ -1328,7 +1328,7 @@ void CTalkMonster::StartFollowing( CBaseEntity *pLeader ) if( m_pCine ) m_pCine->CancelScript(); - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) m_IdealMonsterState = MONSTERSTATE_ALERT; m_hTargetEnt = pLeader; diff --git a/dlls/talkmonster.h b/dlls/talkmonster.h index 57c417e4..72222aae 100644 --- a/dlls/talkmonster.h +++ b/dlls/talkmonster.h @@ -138,7 +138,7 @@ public: // For following BOOL CanFollow( void ); - BOOL IsFollowing( void ) { return m_hTargetEnt != NULL && m_hTargetEnt->IsPlayer(); } + BOOL IsFollowing( void ) { return m_hTargetEnt != 0 && m_hTargetEnt->IsPlayer(); } void StopFollowing( BOOL clearSchedule ); void StartFollowing( CBaseEntity *pLeader ); virtual void DeclineFollowing( void ) {} @@ -154,7 +154,7 @@ public: static TYPEDESCRIPTION m_SaveData[]; - static char *m_szFriends[TLK_CFRIENDS]; // array of friend names + static const char *m_szFriends[TLK_CFRIENDS]; // array of friend names static float g_talkWaitTime; int m_bitsSaid; // set bits for sentences we don't want repeated diff --git a/dlls/teamplay_gamerules.cpp b/dlls/teamplay_gamerules.cpp index 614bd7bb..87b695e7 100644 --- a/dlls/teamplay_gamerules.cpp +++ b/dlls/teamplay_gamerules.cpp @@ -116,7 +116,7 @@ void CHalfLifeTeamplay::Think( void ) return; } - remain = flFragLimit - team_scores[i]; + remain = (int)( flFragLimit - team_scores[i] ); if( remain < bestfrags ) { bestfrags = remain; @@ -157,7 +157,7 @@ BOOL CHalfLifeTeamplay::ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) if( CMD_ARGC() < 2 ) return TRUE; - int slot = atoi( CMD_ARGV( 1 ) ); + //int slot = atoi( CMD_ARGV( 1 ) ); // select the item from the current menu return TRUE; @@ -241,7 +241,7 @@ void CHalfLifeTeamplay::InitHUD( CBasePlayer *pPlayer ) ChangePlayerTeam( pPlayer, pPlayer->m_szTeamName, FALSE, FALSE ); UTIL_SayText( text, pPlayer ); - int clientIndex = pPlayer->entindex(); + //int clientIndex = pPlayer->entindex(); RecountTeams(); // update this player with all the other players team info // loop through all active players and send their team info to the new client @@ -300,7 +300,7 @@ void CHalfLifeTeamplay::ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTea MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo ); WRITE_BYTE( clientIndex ); - WRITE_SHORT( pPlayer->pev->frags ); + WRITE_SHORT( (int)pPlayer->pev->frags ); WRITE_SHORT( pPlayer->m_iDeaths ); WRITE_SHORT( 0 ); WRITE_SHORT( g_pGameRules->GetTeamIndex( pPlayer->m_szTeamName ) + 1 ); @@ -607,7 +607,7 @@ void CHalfLifeTeamplay::RecountTeams( bool bResendInfo ) if( tm >= 0 ) { - team_scores[tm] += plr->pev->frags; + team_scores[tm] += (int)plr->pev->frags; } if( bResendInfo ) //Someone's info changed, let's send the team info again. diff --git a/dlls/tentacle.cpp b/dlls/tentacle.cpp index 637b8946..44b8b45b 100644 --- a/dlls/tentacle.cpp +++ b/dlls/tentacle.cpp @@ -486,12 +486,12 @@ void CTentacle::Cycle( void ) m_flSoundYaw += 360; if( m_flSoundYaw > 180 ) m_flSoundYaw -= 360; - +#if 0 // ALERT( at_console, "sound %d %.0f\n", m_iSoundLevel, m_flSoundYaw ); if( m_flSoundTime < gpGlobals->time ) { // play "I hear new something" sound - char *sound; + const char *sound; switch( RANDOM_LONG( 0, 1 ) ) { @@ -505,6 +505,7 @@ void CTentacle::Cycle( void ) // UTIL_EmitAmbientSound( ENT( pev ), pev->origin + Vector( 0, 0, MyHeight() ), sound, 1.0, ATTN_NORM, 0, 100 ); } +#endif m_flSoundTime = gpGlobals->time + RANDOM_FLOAT( 5.0, 10.0 ); } @@ -591,7 +592,7 @@ void CTentacle::Cycle( void ) if( m_flNextSong < gpGlobals->time ) { // play "I hear new something" sound - char *sound; + const char *sound; switch( RANDOM_LONG( 0, 1 ) ) { @@ -791,7 +792,7 @@ void CTentacle::DieThink( void ) void CTentacle::HandleAnimEvent( MonsterEvent_t *pEvent ) { - char *sound; + const char *sound; switch( pEvent->event ) { diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index 958f899f..2959d96d 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -1265,7 +1265,7 @@ void CTriggerVolume::Spawn( void ) pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_NONE; SET_MODEL( ENT(pev), STRING( pev->model ) ); // set size and link into world - pev->model = NULL; + pev->model = 0; pev->modelindex = 0; } @@ -1438,7 +1438,7 @@ void CChangeLevel::UseChangeLevel( CBaseEntity *pActivator, CBaseEntity *pCaller void CChangeLevel::ChangeLevelNow( CBaseEntity *pActivator ) { edict_t *pentLandmark; - LEVELLIST levels[16]; + //LEVELLIST levels[16]; ASSERT( !FStrEq( m_szMapName, "" ) ); @@ -2224,7 +2224,7 @@ void CTriggerCamera::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP } // Nothing to look at! - if( m_hTarget == NULL ) + if( m_hTarget == 0 ) { return; } @@ -2280,10 +2280,10 @@ void CTriggerCamera::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP void CTriggerCamera::FollowTarget() { - if( m_hPlayer == NULL ) + if( m_hPlayer == 0 ) return; - if( m_hTarget == NULL || m_flReturnTime < gpGlobals->time ) + if( m_hTarget == 0 || m_flReturnTime < gpGlobals->time ) { if( m_hPlayer->IsAlive() ) { diff --git a/dlls/tripmine.cpp b/dlls/tripmine.cpp index e2ed0817..520206dd 100644 --- a/dlls/tripmine.cpp +++ b/dlls/tripmine.cpp @@ -162,7 +162,7 @@ void CTripmineGrenade::PowerupThink( void ) { TraceResult tr; - if( m_hOwner == NULL ) + if( m_hOwner == 0 ) { // find an owner edict_t *oldowner = pev->owner; @@ -217,7 +217,7 @@ void CTripmineGrenade::PowerupThink( void ) MakeBeam(); // play enabled sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "weapons/mine_activate.wav", 0.5, ATTN_NORM, 1.0, 75 ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "weapons/mine_activate.wav", 0.5, ATTN_NORM, 1, 75 ); } pev->nextthink = gpGlobals->time + 0.1; } @@ -280,7 +280,7 @@ void CTripmineGrenade::BeamBreakThink( void ) } else { - if( m_hOwner == NULL ) + if( m_hOwner == 0 ) bBlowup = 1; else if( m_posOwner != m_hOwner->pev->origin ) bBlowup = 1; @@ -446,7 +446,7 @@ void CTripmine::PrimaryAttack( void ) { Vector angles = UTIL_VecToAngles( tr.vecPlaneNormal ); - CBaseEntity *pEnt = CBaseEntity::Create( "monster_tripmine", tr.vecEndPos + tr.vecPlaneNormal * 8, angles, m_pPlayer->edict() ); + CBaseEntity::Create( "monster_tripmine", tr.vecEndPos + tr.vecPlaneNormal * 8, angles, m_pPlayer->edict() ); m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; diff --git a/dlls/turret.cpp b/dlls/turret.cpp index 2dce87fb..5b9e1b77 100644 --- a/dlls/turret.cpp +++ b/dlls/turret.cpp @@ -456,7 +456,7 @@ void CBaseTurret::ActiveThink( void ) pev->nextthink = gpGlobals->time + 0.1; StudioFrameAdvance(); - if( ( !m_iOn ) || ( m_hEnemy == NULL ) ) + if( ( !m_iOn ) || ( m_hEnemy == 0 ) ) { m_hEnemy = NULL; m_flLastSight = gpGlobals->time + m_flMaxWait; @@ -826,21 +826,21 @@ void CBaseTurret::SearchThink( void ) Ping(); // If we have a target and we're still healthy - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( !m_hEnemy->IsAlive() ) m_hEnemy = NULL;// Dead enemy forces a search for new one } // Acquire Target - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { Look( TURRET_RANGE ); m_hEnemy = BestVisibleEnemy(); } // If we've found a target, spin up the barrel and start to attack - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { m_flLastSight = 0; m_flSpinUpTime = 0; @@ -881,20 +881,20 @@ void CBaseTurret::AutoSearchThink( void ) pev->nextthink = gpGlobals->time + 0.3; // If we have a target and we're still healthy - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( !m_hEnemy->IsAlive() ) m_hEnemy = NULL;// Dead enemy forces a search for new one } // Acquire Target - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { Look( TURRET_RANGE ); m_hEnemy = BestVisibleEnemy(); } - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { SetThink( &CBaseTurret::Deploy ); EMIT_SOUND( ENT( pev ), CHAN_BODY, "turret/tu_alert.wav", TURRET_MACHINE_VOLUME, ATTN_NORM ); @@ -903,7 +903,7 @@ void CBaseTurret::AutoSearchThink( void ) void CBaseTurret::TurretDeath( void ) { - BOOL iActive = FALSE; + //BOOL iActive = FALSE; StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; @@ -1222,7 +1222,7 @@ void CSentry::SentryTouch( CBaseEntity *pOther ) void CSentry::SentryDeath( void ) { - BOOL iActive = FALSE; + //BOOL iActive = FALSE; StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; diff --git a/dlls/util.cpp b/dlls/util.cpp index 9c7d9803..d79c9f5a 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -118,7 +118,7 @@ float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ) U_Random(); U_Random(); - range = high - low; + range = (int)( high - low ); if( !range ) { return low; @@ -625,7 +625,7 @@ static unsigned short FixedUnsigned16( float value, float scale ) { int output; - output = value * scale; + output = (int)( value * scale ); if( output < 0 ) output = 0; if( output > 0xFFFF ) @@ -638,7 +638,7 @@ static short FixedSigned16( float value, float scale ) { int output; - output = value * scale; + output = (int)( value * scale ); if( output > 32767 ) output = 32767; @@ -937,10 +937,10 @@ TraceResult UTIL_GetGlobalTrace( ) { TraceResult tr; - tr.fAllSolid = gpGlobals->trace_allsolid; - tr.fStartSolid = gpGlobals->trace_startsolid; - tr.fInOpen = gpGlobals->trace_inopen; - tr.fInWater = gpGlobals->trace_inwater; + tr.fAllSolid = (int)gpGlobals->trace_allsolid; + tr.fStartSolid = (int)gpGlobals->trace_startsolid; + tr.fInOpen = (int)gpGlobals->trace_inopen; + tr.fInWater = (int)gpGlobals->trace_inwater; tr.flFraction = gpGlobals->trace_fraction; tr.flPlaneDist = gpGlobals->trace_plane_dist; tr.pHit = gpGlobals->trace_ent; @@ -1033,7 +1033,7 @@ float UTIL_SplineFraction( float value, float scale ) return 3 * valueSquared - 2 * valueSquared * value; } -char *UTIL_VarArgs( char *format, ... ) +char *UTIL_VarArgs( const char *format, ... ) { va_list argptr; static char string[1024]; @@ -1536,7 +1536,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]; @@ -1902,7 +1902,7 @@ void EntvarsKeyvalue( entvars_t *pev, KeyValueData *pkvd ) int i; TYPEDESCRIPTION *pField; - for( i = 0; i < ENTVARS_COUNT; i++ ) + for( i = 0; i < (int)ENTVARS_COUNT; i++ ) { pField = &gEntvarsDescription[i]; diff --git a/dlls/util.h b/dlls/util.h index f8ae0b6a..fc345ae4 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -87,8 +87,9 @@ typedef int EOFFSET; typedef int BOOL; // In case this ever changes +#ifndef M_PI #define M_PI 3.14159265358979323846 - +#endif // Keeps clutter down a bit, when declaring external entity/global method prototypes #define DECLARE_GLOBAL_METHOD(MethodName) extern void DLLEXPORT MethodName( void ) #define GLOBAL_METHOD(funcname) void DLLEXPORT funcname(void) @@ -304,7 +305,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 ); @@ -364,7 +365,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 ); @@ -534,7 +535,7 @@ void EMIT_GROUPID_SUIT(edict_t *entity, int isentenceg); void EMIT_GROUPNAME_SUIT(edict_t *entity, const char *groupname); #define PRECACHE_SOUND_ARRAY( a ) \ - { for (int i = 0; i < ARRAYSIZE( a ); i++ ) PRECACHE_SOUND((char *) a [i]); } + { for (int i = 0; i < (int)ARRAYSIZE( a ); i++ ) PRECACHE_SOUND((char *) a [i]); } #define EMIT_SOUND_ARRAY_DYN( chan, array ) \ EMIT_SOUND_DYN ( ENT(pev), chan , array [ RANDOM_LONG(0,ARRAYSIZE( array )-1) ], 1.0, ATTN_NORM, 0, RANDOM_LONG(95,105) ); diff --git a/dlls/vector.h b/dlls/vector.h index d3347983..265a9b00 100644 --- a/dlls/vector.h +++ b/dlls/vector.h @@ -22,8 +22,8 @@ class Vector2D { public: - inline Vector2D(void) { } - inline Vector2D(float X, float Y) { x = X; y = Y; } + inline Vector2D(void): x( 0.0f ), y( 0.0f ) { } + inline Vector2D(float X, float Y): x( 0.0f ), y( 0.0f ) { x = X; y = Y; } inline Vector2D operator+(const Vector2D& v) const { return Vector2D( x + v.x, y + v.y ); } inline Vector2D operator-(const Vector2D& v) const { return Vector2D( x - v.x, y - v.y ); } inline Vector2D operator*(float fl) const { return Vector2D( x * fl, y * fl ); } @@ -33,7 +33,7 @@ public: inline Vector2D Normalize ( void ) const { - Vector2D vec2; + //Vector2D vec2; float flLen = Length(); if( flLen == 0 ) @@ -60,12 +60,12 @@ class Vector // same data-layout as engine's vec3_t, { // which is a vec_t[3] public: // Construction/destruction - inline Vector( void ) { } - inline Vector( float X, float Y, float Z ) { x = X; y = Y; z = Z; } + inline Vector( void ): x( 0.0f ), y( 0.0f ), z( 0.0f ) { } + inline Vector( float X, float Y, float Z ): x( 0.0f ), y( 0.0f ), z( 0.0f ) { x = X; y = Y; z = Z; } //inline Vector( double X, double Y, double Z ) { x = (float)X; y = (float)Y; z = (float)Z; } //inline Vector( int X, int Y, int Z ) { x = (float)X; y = (float)Y; z = (float)Z; } - inline Vector( const Vector& v ) { x = v.x; y = v.y; z = v.z; } - inline Vector( float rgfl[3] ) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; } + inline Vector( const Vector& v ): x( 0.0f ), y( 0.0f ), z( 0.0f ) { x = v.x; y = v.y; z = v.z; } + inline Vector( float rgfl[3] ): x( 0.0f ), y( 0.0f ), z( 0.0f ) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; } // Operators inline Vector operator-( void ) const { return Vector( -x, -y, -z ); } diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index ee2a8547..0b6f7de6 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -935,7 +935,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, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal /* = 0 */, int body ) { if( !CanDeploy() ) return FALSE; @@ -1400,7 +1400,7 @@ BOOL CWeaponBox::PackAmmo( int iszName, int iCount ) //========================================================= // CWeaponBox - GiveAmmo //========================================================= -int CWeaponBox::GiveAmmo( int iCount, char *szName, int iMax, int *pIndex/* = NULL*/ ) +int CWeaponBox::GiveAmmo( int iCount, const char *szName, int iMax, int *pIndex/* = NULL*/ ) { int i; diff --git a/dlls/weapons.h b/dlls/weapons.h index 3e6fc5ce..8d60bad8 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -310,7 +310,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, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal = 0, int body = 0 ); int DefaultReload( int iClipSize, int iAnim, float fDelay, int body = 0 ); virtual void ItemPostFrame( void ); // called each frame by the player PostThink @@ -430,7 +430,7 @@ class CWeaponBox : public CBaseEntity void Touch( CBaseEntity *pOther ); void KeyValue( KeyValueData *pkvd ); BOOL IsEmpty( void ); - int GiveAmmo( int iCount, char *szName, int iMax, int *pIndex = NULL ); + int GiveAmmo( int iCount, const char *szName, int iMax, int *pIndex = NULL ); void SetObjectCollisionBox( void ); public: @@ -453,7 +453,7 @@ public: #ifdef CLIENT_DLL bool bIsMultiplayer ( void ); -void LoadVModel ( char *szViewModel, CBasePlayer *m_pPlayer ); +void LoadVModel ( const char *szViewModel, CBasePlayer *m_pPlayer ); #endif class CGlock : public CBasePlayerWeapon @@ -828,7 +828,9 @@ public: unsigned short m_usEgonStop; private: +#ifndef CLIENT_DLL float m_shootTime; +#endif EGON_FIREMODE m_fireMode; float m_shakeTime; BOOL m_deployed; diff --git a/dlls/world.cpp b/dlls/world.cpp index a065b5be..f352bd52 100644 --- a/dlls/world.cpp +++ b/dlls/world.cpp @@ -292,7 +292,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" ); @@ -582,7 +582,7 @@ void CWorld::Precache( void ) // 63 testing LIGHT_STYLE( 63, "a" ); - for( int i = 0; i < ARRAYSIZE( gDecals ); i++ ) + for( int i = 0; i < (int)ARRAYSIZE( gDecals ); i++ ) gDecals[i].index = DECAL_INDEX( gDecals[i].name ); // init the WorldGraph. diff --git a/dlls/xen.cpp b/dlls/xen.cpp index 8e9c771c..4e9e1685 100644 --- a/dlls/xen.cpp +++ b/dlls/xen.cpp @@ -98,7 +98,7 @@ void CXenPLight::Spawn( void ) pev->frame = RANDOM_FLOAT( 0, 255 ); m_pGlow = CSprite::SpriteCreate( XEN_PLANT_GLOW_SPRITE, pev->origin + Vector(0,0,(pev->mins.z+pev->maxs.z)*0.5), FALSE ); - m_pGlow->SetTransparency( kRenderGlow, pev->rendercolor.x, pev->rendercolor.y, pev->rendercolor.z, pev->renderamt, pev->renderfx ); + m_pGlow->SetTransparency( kRenderGlow, (int)pev->rendercolor.x, (int)pev->rendercolor.y, (int)pev->rendercolor.z, (int)pev->renderamt, (int)pev->renderfx ); m_pGlow->SetAttachment( edict(), 1 ); } @@ -497,7 +497,7 @@ void CXenSporeLarge::Spawn( void ) UTIL_MakeVectorsPrivate( pev->angles, forward, right, NULL ); // Rotate the leg hulls into position - for( int i = 0; i < ARRAYSIZE( m_hullSizes ); i++ ) + for( int i = 0; i < (int)ARRAYSIZE( m_hullSizes ); i++ ) CXenHull::CreateHull( this, Vector( -12, -12, 0 ), Vector( 12, 12, 120 ), ( m_hullSizes[i].x * forward ) + ( m_hullSizes[i].y * right ) ); } @@ -536,7 +536,7 @@ void CXenSpore::Touch( CBaseEntity *pOther ) void CXenSpore::Think( void ) { - float flInterval = StudioFrameAdvance(); + StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; #if 0 DispatchAnimEvents( flInterval ); diff --git a/dlls/zombie.cpp b/dlls/zombie.cpp index b20293c1..2611f881 100644 --- a/dlls/zombie.cpp +++ b/dlls/zombie.cpp @@ -286,7 +286,7 @@ void CZombie::Spawn() //========================================================= void CZombie::Precache() { - int i; + size_t i; PRECACHE_MODEL( "models/zombie.mdl" ); diff --git a/engine/custom.h b/engine/custom.h index d48ee72d..8f644e00 100644 --- a/engine/custom.h +++ b/engine/custom.h @@ -16,6 +16,12 @@ #ifndef CUSTOM_H #define CUSTOM_H +#ifdef _WIN32 +#ifndef __MINGW32__ +#pragma once +#endif /* not __MINGW32__ */ +#endif + #include "const.h" ///////////////// diff --git a/engine/edict.h b/engine/edict.h index b0469b86..e89b6926 100644 --- a/engine/edict.h +++ b/engine/edict.h @@ -16,6 +16,12 @@ #ifndef EDICT_H #define EDICT_H +#ifdef _WIN32 +#ifndef __MINGW32__ +#pragma once +#endif /* not __MINGW32__ */ +#endif + #define MAX_ENT_LEAFS 48 #include "progdefs.h" @@ -39,4 +45,4 @@ struct edict_s // other fields from progs come immediately after }; -#endif//EDICT_H \ No newline at end of file +#endif//EDICT_H diff --git a/engine/eiface.h b/engine/eiface.h index 3419e5bd..30f8a82a 100644 --- a/engine/eiface.h +++ b/engine/eiface.h @@ -94,13 +94,13 @@ typedef unsigned int CRC32_t; // Engine hands this to DLLs for functionality callbacks typedef struct enginefuncs_s { - int (*pfnPrecacheModel)( char* s ); - int (*pfnPrecacheSound)( char* s ); + int (*pfnPrecacheModel)( const char *s ); + int (*pfnPrecacheSound)( const char *s ); void (*pfnSetModel)( edict_t *e, const char *m ); int (*pfnModelIndex)( const char *m ); int (*pfnModelFrames)( int modelIndex ); void (*pfnSetSize)( edict_t *e, const float *rgflMin, const float *rgflMax ); - void (*pfnChangeLevel)( char* s1, char* s2 ); + void (*pfnChangeLevel)( const char *s1, const char *s2 ); void (*pfnGetSpawnParms)( edict_t *ent ); void (*pfnSaveSpawnParms)( edict_t *ent ); float (*pfnVecToYaw)( const float *rgflVector ); @@ -132,12 +132,12 @@ typedef struct enginefuncs_s void (*pfnTraceModel)( const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr ); const char *(*pfnTraceTexture)( edict_t *pTextureEntity, const float *v1, const float *v2 ); void (*pfnTraceSphere)( const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr ); - void (*pfnGetAimVector)( edict_t* ent, float speed, float *rgflReturn ); - void (*pfnServerCommand)( char* str ); + void (*pfnGetAimVector)( edict_t *ent, float speed, float *rgflReturn ); + void (*pfnServerCommand)( const char *str ); void (*pfnServerExecute)( void ); - void (*pfnClientCommand)( edict_t* pEdict, char* szFmt, ... ); + void (*pfnClientCommand)( edict_t* pEdict, const char *szFmt, ... ); void (*pfnParticleEffect)( const float *org, const float *dir, float color, float count ); - void (*pfnLightStyle)( int style, char* val ); + void (*pfnLightStyle)( int style, const char *val ); int (*pfnDecalIndex)( const char *name ); int (*pfnPointContents)( const float *rgflVector ); void (*pfnMessageBegin)( int msg_dest, int msg_type, const float *pOrigin, edict_t *ed ); @@ -155,8 +155,8 @@ typedef struct enginefuncs_s const char* (*pfnCVarGetString)( const char *szVarName ); void (*pfnCVarSetFloat)( const char *szVarName, float flValue ); void (*pfnCVarSetString)( const char *szVarName, const char *szValue ); - void (*pfnAlertMessage)( ALERT_TYPE atype, char *szFmt, ... ); - void (*pfnEngineFprintf)( FILE *pfile, char *szFmt, ... ); + void (*pfnAlertMessage)( ALERT_TYPE atype, const char *szFmt, ... ); + void (*pfnEngineFprintf)( FILE *pfile, const char *szFmt, ... ); void* (*pfnPvAllocEntPrivateData)( edict_t *pEdict, int cb ); void* (*pfnPvEntPrivateData)( edict_t *pEdict ); void (*pfnFreeEntPrivateData)( edict_t *pEdict ); @@ -189,7 +189,7 @@ typedef struct enginefuncs_s void (*pfnSetView)( const edict_t *pClient, const edict_t *pViewent ); float (*pfnTime)( void ); void (*pfnCrosshairAngle)( const edict_t *pClient, float pitch, float yaw ); - byte* (*pfnLoadFileForMe)( char *filename, int *pLength ); + byte* (*pfnLoadFileForMe)( const char *filename, int *pLength ); void (*pfnFreeFile)( void *buffer ); void (*pfnEndSection)( const char *pszSectionName ); // trigger_endsection int (*pfnCompareFileTime)( char *filename1, char *filename2, int *iCompare ); @@ -201,12 +201,12 @@ typedef struct enginefuncs_s void (*pfnRunPlayerMove)( edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec ); int (*pfnNumberOfEntities)( void ); char* (*pfnGetInfoKeyBuffer)( edict_t *e ); // passing in NULL gets the serverinfo - char* (*pfnInfoKeyValue)( char *infobuffer, char *key ); - void (*pfnSetKeyValue)( char *infobuffer, char *key, char *value ); - void (*pfnSetClientKeyValue)( int clientIndex, char *infobuffer, char *key, char *value ); - int (*pfnIsMapValid)( char *filename ); + char* (*pfnInfoKeyValue)( char *infobuffer, const char *key ); + void (*pfnSetKeyValue)( char *infobuffer, const char *key, const char *value ); + void (*pfnSetClientKeyValue)( int clientIndex, char *infobuffer, const char *key, const char *value ); + int (*pfnIsMapValid)( const char *filename ); void (*pfnStaticDecal)( const float *origin, int decalIndex, int entityIndex, int modelIndex ); - int (*pfnPrecacheGeneric)( char *s ); + int (*pfnPrecacheGeneric)( const char *s ); int (*pfnGetPlayerUserId)( edict_t *e ); // returns the server assigned userid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients void (*pfnBuildSoundMsg)( edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed ); int (*pfnIsDedicatedServer)( void ); // is this a dedicated server? @@ -228,7 +228,7 @@ typedef struct enginefuncs_s void (*pfnDeltaSetField) ( struct delta_s *pFields, const char *fieldname ); void (*pfnDeltaUnsetField)( struct delta_s *pFields, const char *fieldname ); - void (*pfnDeltaAddEncoder)( char *name, void (*conditionalencode)( struct delta_s *pFields, const unsigned char *from, const unsigned char *to ) ); + void (*pfnDeltaAddEncoder)( const char *name, void (*conditionalencode)( struct delta_s *pFields, const unsigned char *from, const unsigned char *to ) ); int (*pfnGetCurrentPlayer)( void ); int (*pfnCanSkipPlayer)( const edict_t *player ); int (*pfnDeltaFindField)( struct delta_s *pFields, const char *fieldname ); @@ -236,7 +236,7 @@ typedef struct enginefuncs_s void (*pfnDeltaUnsetFieldByIndex)( struct delta_s *pFields, int fieldNumber ); void (*pfnSetGroupMask)( int mask, int op ); int (*pfnCreateInstancedBaseline)( int classname, struct entity_state_s *baseline ); - void (*pfnCvar_DirectSet)( struct cvar_s *var, char *value ); + void (*pfnCvar_DirectSet)( struct cvar_s *var, const char *value ); // Forces the client and server to be running with the same version of the specified file // ( e.g., a player model ). @@ -245,7 +245,7 @@ typedef struct enginefuncs_s void (*pfnGetPlayerStats)( const edict_t *pClient, int *ping, int *packet_loss ); - void (*pfnAddServerCommand)( char *cmd_name, void (*function) (void) ); + void (*pfnAddServerCommand)( const char *cmd_name, void (*function) (void) ); // For voice communications, set which clients hear eachother. // NOTE: these functions take player entity indices (starting at 1). @@ -256,7 +256,7 @@ typedef struct enginefuncs_s void *(*pfnSequenceGet)( const char *fileName, const char *entryName ); void *(*pfnSequencePickSentence)( const char *groupName, int pickMethod, int *picked ); - int (*pfnGetFileSize)( char *filename ); + int (*pfnGetFileSize)( const char *filename ); unsigned int (*pfnGetApproxWavePlayLen)( const char *filepath ); int (*pfnIsCareerMatch)( void ); int (*pfnGetLocalizedStringLength)( const char *label ); @@ -274,9 +274,9 @@ typedef struct enginefuncs_s // Passed to pfnKeyValue typedef struct KeyValueData_s { - char *szClassName; // in: entity classname - char *szKeyName; // in: name of key - char *szValue; // in: value of key + const char *szClassName; // in: entity classname + const char *szKeyName; // in: name of key + const char *szValue; // in: value of key int fHandled; // out: DLL sets to true if key-value pair was understood } KeyValueData; @@ -374,13 +374,15 @@ typedef enum _fieldtypes typedef struct { FIELDTYPE fieldType; - char *fieldName; + const char *fieldName; int fieldOffset; short fieldSize; short flags; } TYPEDESCRIPTION; +#ifndef ARRAYSIZE #define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0])) +#endif typedef struct { @@ -434,7 +436,7 @@ typedef struct void (*pfnPM_Move)( struct playermove_s *ppmove, qboolean server ); void (*pfnPM_Init)( struct playermove_s *ppmove ); - char (*pfnPM_FindTextureType)( char *name ); + char (*pfnPM_FindTextureType)( const char *name ); void (*pfnSetupVisibility)( struct edict_s *pViewEntity, struct edict_s *pClient, unsigned char **pvs, unsigned char **pas ); void (*pfnUpdateClientData) ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ); int (*pfnAddToFullPack)( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet ); diff --git a/engine/progdefs.h b/engine/progdefs.h index 74004a27..cdbcc006 100644 --- a/engine/progdefs.h +++ b/engine/progdefs.h @@ -16,6 +16,12 @@ #ifndef PROGDEFS_H #define PROGDEFS_H +#ifdef _WIN32 +#ifndef __MINGW32__ +#pragma once +#endif /* not __MINGW32__ */ +#endif + typedef struct { float time; @@ -215,4 +221,4 @@ typedef struct entvars_s edict_t *euser4; } entvars_t; -#endif//PROGDEFS_H \ No newline at end of file +#endif//PROGDEFS_H diff --git a/pm_shared/pm_debug.c b/pm_shared/pm_debug.c index 3baccaef..3b0879c7 100644 --- a/pm_shared/pm_debug.c +++ b/pm_shared/pm_debug.c @@ -23,8 +23,10 @@ #include +#ifdef _MSC_VER #pragma warning(disable : 4244) #pragma warning(disable : 4305) +#endif extern playermove_t *pmove; diff --git a/pm_shared/pm_debug.h b/pm_shared/pm_debug.h index 4959d165..cc130598 100644 --- a/pm_shared/pm_debug.h +++ b/pm_shared/pm_debug.h @@ -15,6 +15,12 @@ #ifndef PM_DEBUG_H #define PM_DEBUG_H +#ifdef _WIN32 +#ifndef __MINGW32__ +#pragma once +#endif /* not __MINGW32__ */ +#endif + void PM_ViewEntity( void ); void PM_DrawBBox( vec3_t mins, vec3_t maxs, vec3_t origin, int pcolor, float life ); void PM_ParticleLine( vec3_t start, vec3_t end, int pcolor, float life, float vert ); diff --git a/pm_shared/pm_defs.h b/pm_shared/pm_defs.h index cd17ce54..b4c652ba 100644 --- a/pm_shared/pm_defs.h +++ b/pm_shared/pm_defs.h @@ -16,6 +16,12 @@ #ifndef PM_DEFS_H #define PM_DEFS_H +#ifdef _WIN32 +#ifndef __MINGW32__ +#pragma once +#endif /* not __MINGW32__ */ +#endif + #define MAX_PHYSENTS 600 // Must have room for all entities in the world. #define MAX_MOVEENTS 64 #define MAX_CLIP_PLANES 5 diff --git a/pm_shared/pm_info.h b/pm_shared/pm_info.h index 321527f2..d9dbc03d 100644 --- a/pm_shared/pm_info.h +++ b/pm_shared/pm_info.h @@ -15,5 +15,11 @@ #ifndef PM_INFO_H #define PM_INFO_H +#ifdef _WIN32 +#ifndef __MINGW32__ +#pragma once +#endif /* not __MINGW32__ */ +#endif + #define MAX_PHYSINFO_STRING 256 #endif//PM_INFO_H diff --git a/pm_shared/pm_math.c b/pm_shared/pm_math.c index 3718dc63..5bbe0068 100644 --- a/pm_shared/pm_math.c +++ b/pm_shared/pm_math.c @@ -25,7 +25,9 @@ // fall over #define ROLL 2 +#ifdef _MSC_VER #pragma warning(disable : 4244) +#endif vec3_t vec3_origin = { 0,0,0 }; int nanmask = 255 << 23; diff --git a/pm_shared/pm_shared.c b/pm_shared/pm_shared.c index 7a1fb966..c709ba14 100644 --- a/pm_shared/pm_shared.c +++ b/pm_shared/pm_shared.c @@ -36,7 +36,9 @@ extern float vJumpAngles[3]; static int pm_shared_initialized = 0; +#ifdef _MSC_VER #pragma warning( disable : 4305 ) +#endif playermove_t *pmove = NULL; @@ -90,7 +92,10 @@ playermove_t *pmove = NULL; #define PLAYER_DUCKING_MULTIPLIER 0.333 // double to float warning +#ifdef _MSC_VER #pragma warning(disable : 4244) +#endif + #define max(a, b) (((a) > (b)) ? (a) : (b)) #define min(a, b) (((a) < (b)) ? (a) : (b)) // up / down @@ -549,7 +554,7 @@ void PM_UpdateStepSound( void ) float fvol; vec3_t knee; vec3_t feet; - vec3_t center; + //vec3_t center; float height; float speed; float velrun; @@ -592,7 +597,7 @@ void PM_UpdateStepSound( void ) { fWalking = speed < velrun; - VectorCopy( pmove->origin, center ); + //VectorCopy( pmove->origin, center ); VectorCopy( pmove->origin, knee ); VectorCopy( pmove->origin, feet ); @@ -1062,7 +1067,7 @@ Only used by players. Moves along the ground when player is a MOVETYPE_WALK. */ void PM_WalkMove() { - int clip; + //int clip; int oldonground; int i; @@ -1072,7 +1077,7 @@ void PM_WalkMove() vec3_t wishdir; float wishspeed; - vec3_t dest, start; + vec3_t dest; //, start; vec3_t original, originalvel; vec3_t down, downvel; float downdist, updist; @@ -1135,7 +1140,7 @@ void PM_WalkMove() dest[2] = pmove->origin[2]; // first try moving directly to the next spot - VectorCopy( dest, start ); + //VectorCopy( dest, start ); trace = pmove->PM_PlayerTrace( pmove->origin, dest, PM_NORMAL, -1 ); // If we made it all the way, then copy trace end // as new player position. @@ -1158,7 +1163,8 @@ void PM_WalkMove() VectorCopy( pmove->velocity, originalvel ); // velocity. // Slide move - clip = PM_FlyMove(); + //clip = PM_FlyMove(); + PM_FlyMove(); // Copy the results out VectorCopy( pmove->origin, down ); @@ -1183,7 +1189,8 @@ void PM_WalkMove() } // slide move the rest of the way. - clip = PM_FlyMove(); + //clip = PM_FlyMove(); + PM_FlyMove(); // Now try going back down from the end point // press down the stepheight @@ -1994,8 +2001,8 @@ void PM_Duck( void ) int buttonsChanged = ( pmove->oldbuttons ^ pmove->cmd.buttons ); // These buttons have changed this frame int nButtonPressed = buttonsChanged & pmove->cmd.buttons; // The changed ones still down are "pressed" - int duckchange = buttonsChanged & IN_DUCK ? 1 : 0; - int duckpressed = nButtonPressed & IN_DUCK ? 1 : 0; + //int duckchange = buttonsChanged & IN_DUCK ? 1 : 0; + //int duckpressed = nButtonPressed & IN_DUCK ? 1 : 0; if( pmove->cmd.buttons & IN_DUCK ) { @@ -2261,6 +2268,7 @@ void PM_AddGravity() pmove->basevelocity[2] = 0; PM_CheckVelocity(); } + /* ============ PM_PushEntity diff --git a/pm_shared/pm_shared.h b/pm_shared/pm_shared.h index 124d37ba..1d0e4f38 100644 --- a/pm_shared/pm_shared.h +++ b/pm_shared/pm_shared.h @@ -16,6 +16,12 @@ #ifndef PM_SHARED_H #define PM_SHARED_H +#ifdef _WIN32 +#ifndef __MINGW32__ +#pragma once +#endif /* not __MINGW32__ */ +#endif + void PM_Init( struct playermove_s *ppmove ); void PM_Move( struct playermove_s *ppmove, int server ); char PM_FindTextureType( char *name ); From d20c4ff32980ad5cfd999533165ed2f90a61075e Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 2 Jul 2017 02:36:56 +0500 Subject: [PATCH 011/144] Fix build. --- cl_dll/cl_util.h | 10 +++++++--- cl_dll/com_weapons.cpp | 2 +- cl_dll/hud_redraw.cpp | 2 +- cl_dll/text_message.cpp | 12 ++++++------ dlls/buttons.cpp | 2 +- dlls/combat.cpp | 2 +- dlls/weapons.cpp | 2 +- dlls/weapons.h | 2 +- engine/cdll_int.h | 2 +- 9 files changed, 20 insertions(+), 16 deletions(-) diff --git a/cl_dll/cl_util.h b/cl_dll/cl_util.h index 54dcede0..22555caa 100644 --- a/cl_dll/cl_util.h +++ b/cl_dll/cl_util.h @@ -94,8 +94,12 @@ inline void DrawSetTextColor( float r, float g, float b ) inline int SPR_Height( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Height(x, f); } inline int SPR_Width( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Width(x, f); } -inline client_textmessage_t *TextMessageGet( const char *pName ) { return gEngfuncs.pfnTextMessageGet( pName ); } -inline int TextMessageDrawChar( int x, int y, int number, int r, int g, int b ) +inline client_textmessage_t *TextMessageGet( const char *pName ) +{ + return gEngfuncs.pfnTextMessageGet( pName ); +} + +inline int TextMessageDrawChar( int x, int y, int number, int r, int g, int b ) { return gEngfuncs.pfnDrawCharacter( x, y, number, r, g, b ); } @@ -115,7 +119,7 @@ inline void GetConsoleStringSize( const char *string, int *width, int *height ) gEngfuncs.pfnDrawConsoleStringLen( (char*)string, width, height ); } -int DrawUtfString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b ); +int DrawUtfString( int xpos, int ypos, int iMaxX, const char *szIt, int r, int g, int b ); inline int ConsoleStringLen( const char *string ) { diff --git a/cl_dll/com_weapons.cpp b/cl_dll/com_weapons.cpp index e50de419..774df091 100644 --- a/cl_dll/com_weapons.cpp +++ b/cl_dll/com_weapons.cpp @@ -46,7 +46,7 @@ void COM_Log( const char *pszFile, const char *fmt, ... ) va_list argptr; char string[1024]; FILE *fp; - char *pfilename; + const char *pfilename; if( !pszFile ) { diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index 5182b484..829fd4b2 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -281,7 +281,7 @@ int CHud::DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r int CHud::DrawHudStringReverse( int xpos, int ypos, int iMinX, const char *szString, int r, int g, int b ) { // find the end of the string - for( char *szIt = szString; *szIt != 0; szIt++ ) + for( const char *szIt = szString; *szIt != 0; szIt++ ) xpos -= gHUD.m_scrinfo.charWidths[(unsigned char)*szIt]; if( xpos < iMinX ) xpos = iMinX; diff --git a/cl_dll/text_message.cpp b/cl_dll/text_message.cpp index 13b62577..58dae6f7 100644 --- a/cl_dll/text_message.cpp +++ b/cl_dll/text_message.cpp @@ -45,7 +45,7 @@ int CHudTextMessage::Init( void ) char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size ) { char *dst = dst_buffer; - for( char *src = msg; *src != 0 && buffer_size > 0; buffer_size-- ) + for( char *src = (char*)msg; *src != 0 && buffer_size > 0; buffer_size-- ) { if( *src == '#' ) { @@ -163,22 +163,22 @@ int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf int msg_dest = READ_BYTE(); static char szBuf[6][128]; - char *msg_text = LookupString( READ_STRING(), &msg_dest ); + const char *msg_text = LookupString( READ_STRING(), &msg_dest ); msg_text = strcpy( szBuf[0], msg_text ); // keep reading strings and using C format strings for subsituting the strings into the localised text string const char *sstr1 = LookupString( READ_STRING() ); sstr1 = strcpy( szBuf[1], sstr1 ); - StripEndNewlineFromString( sstr1 ); // these strings are meant for subsitution into the main strings, so cull the automatic end newlines + StripEndNewlineFromString( (char*)sstr1 ); // these strings are meant for subsitution into the main strings, so cull the automatic end newlines const char *sstr2 = LookupString( READ_STRING() ); sstr2 = strcpy( szBuf[2], sstr2 ); - StripEndNewlineFromString( sstr2 ); + StripEndNewlineFromString( (char*)sstr2 ); const char *sstr3 = LookupString( READ_STRING() ); sstr3 = strcpy( szBuf[3], sstr3 ); - StripEndNewlineFromString( sstr3 ); + StripEndNewlineFromString( (char*)sstr3 ); const char *sstr4 = LookupString( READ_STRING() ); sstr4 = strcpy( szBuf[4], sstr4 ); - StripEndNewlineFromString( sstr4 ); + StripEndNewlineFromString( (char*)sstr4 ); char *psz = szBuf[5]; switch( msg_dest ) diff --git a/dlls/buttons.cpp b/dlls/buttons.cpp index 76f4ad91..df7c51f3 100644 --- a/dlls/buttons.cpp +++ b/dlls/buttons.cpp @@ -525,7 +525,7 @@ 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 ) { const char *pszSound; diff --git a/dlls/combat.cpp b/dlls/combat.cpp index d8830c20..35e4ffcf 100644 --- a/dlls/combat.cpp +++ b/dlls/combat.cpp @@ -1463,7 +1463,7 @@ void CBaseEntity::FireBullets( ULONG cShots, Vector vecSrc, Vector vecDirShootin } } // make bullet trails - UTIL_BubbleTrail( vecSrc, tr.vecEndPos, (int)( ( flDistance * tr.flFraction ) / 64.0 ); + UTIL_BubbleTrail( vecSrc, tr.vecEndPos, (int)( ( flDistance * tr.flFraction ) / 64.0 ) ); } ApplyMultiDamage( pev, pevAttacker ); } diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 0b6f7de6..989c32a8 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -935,7 +935,7 @@ BOOL CBasePlayerWeapon::CanDeploy( void ) return TRUE; } -BOOL CBasePlayerWeapon::DefaultDeploy( const 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 8d60bad8..7bb1b486 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -310,7 +310,7 @@ public: virtual BOOL CanDeploy( void ); virtual BOOL IsUseable( void ); - BOOL DefaultDeploy( const 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 ); int DefaultReload( int iClipSize, int iAnim, float fDelay, int body = 0 ); virtual void ItemPostFrame( void ); // called each frame by the player PostThink diff --git a/engine/cdll_int.h b/engine/cdll_int.h index a0dc59c2..056146b4 100644 --- a/engine/cdll_int.h +++ b/engine/cdll_int.h @@ -205,7 +205,7 @@ typedef struct cl_enginefuncs_s int (*CL_CreateVisibleEntity)( int type, struct cl_entity_s *ent ); const struct model_s* (*GetSpritePointer)( HSPRITE hSprite ); - void (*pfnPlaySoundByNameAtLocation)( char *szSound, float volume, float *origin ); + void (*pfnPlaySoundByNameAtLocation)( const char *szSound, float volume, float *origin ); unsigned short (*pfnPrecacheEvent)( int type, const char* psz ); void (*pfnPlaybackEvent)( int flags, const struct edict_s *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); From c28d86f748362565baa82a522404e1ae7476fac8 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 2 Jul 2017 02:42:30 +0500 Subject: [PATCH 012/144] Fix wrong check. --- dlls/cbase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/cbase.cpp b/dlls/cbase.cpp index 0cc10bdb..cdf9a00f 100644 --- a/dlls/cbase.cpp +++ b/dlls/cbase.cpp @@ -511,7 +511,7 @@ int CBaseEntity::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, fl // (that is, no actual entity projectile was involved in the attack so use the shooter's origin). if( pevAttacker == pevInflictor ) { - vecTemp = pevInflictor->origin - VecBModelOrigin( pev ); + vecTemp = pevAttacker->origin - VecBModelOrigin( pev ); } else // an actual missile was involved. From 4ae58b4170bc0f05e27baea53262ccbfc22e7fd4 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 2 Jul 2017 05:37:14 +0500 Subject: [PATCH 013/144] Fix weapon reload bug. Use macros instead of magic numbers. --- dlls/crossbow.cpp | 4 ++-- dlls/egon.cpp | 2 +- dlls/glock.cpp | 8 ++++---- dlls/python.cpp | 4 ++-- dlls/rpg.cpp | 9 ++------- dlls/shotgun.cpp | 2 +- 6 files changed, 12 insertions(+), 17 deletions(-) diff --git a/dlls/crossbow.cpp b/dlls/crossbow.cpp index d749c785..12d0ff8c 100644 --- a/dlls/crossbow.cpp +++ b/dlls/crossbow.cpp @@ -481,7 +481,7 @@ void CCrossbow::SecondaryAttack() void CCrossbow::Reload( void ) { - if( m_pPlayer->ammo_bolts <= 0 ) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == CROSSBOW_MAX_CLIP ) return; if( m_pPlayer->pev->fov != 0 ) @@ -489,7 +489,7 @@ void CCrossbow::Reload( void ) SecondaryAttack(); } - if( DefaultReload( 5, CROSSBOW_RELOAD, 4.5 ) ) + if( DefaultReload( CROSSBOW_MAX_CLIP, CROSSBOW_RELOAD, 4.5 ) ) { EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/xbow_reload1.wav", RANDOM_FLOAT( 0.95, 1.0 ), ATTN_NORM, 0, 93 + RANDOM_LONG( 0, 0xF ) ); } diff --git a/dlls/egon.cpp b/dlls/egon.cpp index 9a4de49b..b83c9086 100644 --- a/dlls/egon.cpp +++ b/dlls/egon.cpp @@ -143,7 +143,7 @@ float CEgon::GetDischargeInterval( void ) BOOL CEgon::HasAmmo( void ) { - if( m_pPlayer->ammo_uranium <= 0 ) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) return FALSE; return TRUE; diff --git a/dlls/glock.cpp b/dlls/glock.cpp index 1f4517e7..4e679750 100644 --- a/dlls/glock.cpp +++ b/dlls/glock.cpp @@ -169,15 +169,15 @@ void CGlock::GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim ) void CGlock::Reload( void ) { - if( m_pPlayer->ammo_9mm <= 0 ) - return; + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == GLOCK_MAX_CLIP ) + return; int iResult; if( m_iClip == 0 ) - iResult = DefaultReload( 17, GLOCK_RELOAD, 1.5 ); + iResult = DefaultReload( GLOCK_MAX_CLIP, GLOCK_RELOAD, 1.5 ); else - iResult = DefaultReload( 17, GLOCK_RELOAD_NOT_EMPTY, 1.5 ); + iResult = DefaultReload( GLOCK_MAX_CLIP, GLOCK_RELOAD_NOT_EMPTY, 1.5 ); if( iResult ) { diff --git a/dlls/python.cpp b/dlls/python.cpp index 7bb71325..b7e48386 100644 --- a/dlls/python.cpp +++ b/dlls/python.cpp @@ -212,7 +212,7 @@ void CPython::PrimaryAttack() void CPython::Reload( void ) { - if( m_pPlayer->ammo_357 <= 0 ) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == PYTHON_MAX_CLIP ) return; if( m_pPlayer->pev->fov != 0 ) @@ -227,7 +227,7 @@ void CPython::Reload( void ) #else bUseScope = g_pGameRules->IsMultiplayer(); #endif - if( DefaultReload( 6, PYTHON_RELOAD, 2.0, bUseScope ) ) + if( DefaultReload( PYTHON_MAX_CLIP, PYTHON_RELOAD, 2.0, bUseScope ) ) { m_flSoundDelay = 1.5; } diff --git a/dlls/rpg.cpp b/dlls/rpg.cpp index 95c9132a..fb2b39c8 100644 --- a/dlls/rpg.cpp +++ b/dlls/rpg.cpp @@ -278,13 +278,8 @@ void CRpg::Reload( void ) { int iResult = 0; - if( m_iClip == 1 ) - { - // don't bother with any of this if don't need to reload. - return; - } - - if( m_pPlayer->ammo_rockets <= 0 ) + // don't bother with any of this if don't need to reload. + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == RPG_MAX_CLIP ) return; // because the RPG waits to autoreload when no missiles are active while the LTD is on, the diff --git a/dlls/shotgun.cpp b/dlls/shotgun.cpp index 595561e2..d6be007a 100644 --- a/dlls/shotgun.cpp +++ b/dlls/shotgun.cpp @@ -320,7 +320,7 @@ void CShotgun::WeaponIdle( void ) } else if( m_fInSpecialReload != 0 ) { - if( m_iClip != 8 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) + if( m_iClip != SHOTGUN_MAX_CLIP && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { Reload(); } From cabb03ad45de13063b0dc42255455d1eaab22eda Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 2 Jul 2017 16:11:40 +0500 Subject: [PATCH 014/144] Merge https://github.com/ValveSoftware/halflife/pull/1598/commits/2257fa14e7b1cd1fffd0c9d058b7368799b8b2a3 --- dlls/hornet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/hornet.cpp b/dlls/hornet.cpp index d968b79b..758ba7e9 100644 --- a/dlls/hornet.cpp +++ b/dlls/hornet.cpp @@ -407,7 +407,7 @@ void CHornet::DartTouch( CBaseEntity *pOther ) void CHornet::DieTouch( CBaseEntity *pOther ) { - if( pOther && pOther->pev->takedamage ) + if( pOther && pOther->pev->takedamage && pev->owner ) { // do the damage switch( RANDOM_LONG( 0, 2 ) ) From 7113204d5133ed67975bd9220fe50b6ae8b1fda9 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 2 Jul 2017 16:42:54 +0500 Subject: [PATCH 015/144] Merge https://github.com/ValveSoftware/halflife/pull/1600/commits/8903b33ef34cbe7e33bfbaa15f5c418bf9d01a02 --- dlls/crowbar.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index 00b16d57..051d2309 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -220,8 +220,14 @@ int CCrowbar::Swing( int fFirst ) CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); ClearMultiDamage(); - + // If building with the clientside weapon prediction system, + // UTIL_WeaponTimeBase() is always 0 and m_flNextPrimaryAttack is >= -1.0f, thus making + // m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() always evaluate to false. +#ifdef CLIENT_WEAPONS + if( ( m_flNextPrimaryAttack + 1 == UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() ) +#else if( ( m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() ) +#endif { // first swing does full damage pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar, gpGlobals->v_forward, &tr, DMG_CLUB ); From 13a691bdd85c692da49eb66cc1ea04cedd012950 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 2 Jul 2017 19:02:52 +0500 Subject: [PATCH 016/144] Fix GetHullBounds() Same as in https://github.com/FWGS/cs16-client/commit/8d4515be429bfbff90b702d968ea9d57690b9ef4 --- cl_dll/cdll_int.cpp | 12 ++++++------ dlls/client.cpp | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index 13200a89..ffd342d2 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -76,18 +76,18 @@ int DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs ) switch( hullnumber ) { case 0: // Normal player - mins = Vector( -16, -16, -36 ); - maxs = Vector( 16, 16, 36 ); + Vector( -16, -16, -36 ).CopyToArray(mins); + Vector( 16, 16, 36 ).CopyToArray(maxs); iret = 1; break; case 1: // Crouched player - mins = Vector( -16, -16, -18 ); - maxs = Vector( 16, 16, 18 ); + Vector( -16, -16, -18 ).CopyToArray(mins); + Vector( 16, 16, 18 ).CopyToArray(maxs); iret = 1; break; case 2: // Point based hull - mins = Vector( 0, 0, 0 ); - maxs = Vector( 0, 0, 0 ); + Vector( 0, 0, 0 ).CopyToArray(mins); + Vector( 0, 0, 0 ).CopyToArray(maxs); iret = 1; break; } diff --git a/dlls/client.cpp b/dlls/client.cpp index 99f1913b..ea4eb590 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -1853,18 +1853,18 @@ int GetHullBounds( int hullnumber, float *mins, float *maxs ) switch( hullnumber ) { case 0: // Normal player - mins = VEC_HULL_MIN; - maxs = VEC_HULL_MAX; + VEC_HULL_MIN.CopyToArray(mins); + VEC_HULL_MAX.CopyToArray(maxs); iret = 1; break; case 1: // Crouched player - mins = VEC_DUCK_HULL_MIN; - maxs = VEC_DUCK_HULL_MAX; + VEC_DUCK_HULL_MIN.CopyToArray(mins); + VEC_DUCK_HULL_MAX.CopyToArray(maxs); iret = 1; break; case 2: // Point based hull - mins = Vector( 0, 0, 0 ); - maxs = Vector( 0, 0, 0 ); + Vector( 0, 0, 0 ).CopyToArray(mins); + Vector( 0, 0, 0 ).CopyToArray(maxs); iret = 1; break; } From 3dfbd2a41f550b39acc382bac1bf436504577143 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 2 Jul 2017 19:31:49 +0500 Subject: [PATCH 017/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/14fa5e81d0c327d3e2b43d2804b6c9377ce96ec4 --- dlls/world.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dlls/world.cpp b/dlls/world.cpp index f352bd52..1cc645c9 100644 --- a/dlls/world.cpp +++ b/dlls/world.cpp @@ -484,9 +484,12 @@ void CWorld::Precache( void ) ///!!!LATER - do we want a sound ent in deathmatch? (sjb) //pSoundEnt = CBaseEntity::Create( "soundent", g_vecZero, g_vecZero, edict() ); pSoundEnt = GetClassPtr( ( CSoundEnt *)NULL ); - pSoundEnt->Spawn(); - if( !pSoundEnt ) + if( pSoundEnt ) + { + pSoundEnt->Spawn(); + } + else { ALERT ( at_console, "**COULD NOT CREATE SOUNDENT**\n" ); } From ac6d7c4384d12ce7ff59162db892139fc91109c1 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 2 Jul 2017 19:35:16 +0500 Subject: [PATCH 018/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/5cade5b7607da186349ad4c49fd778cff40ea3ee --- dlls/monsters.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dlls/monsters.cpp b/dlls/monsters.cpp index cfe4c561..5f112a62 100644 --- a/dlls/monsters.cpp +++ b/dlls/monsters.cpp @@ -334,12 +334,10 @@ void CBaseMonster::Look( int iDistance ) { if( pev->spawnflags & SF_MONSTER_WAIT_TILL_SEEN ) { - CBaseMonster *pClient; - - pClient = pSightEnt->MyMonsterPointer(); + CBaseMonster *pClient = pSightEnt->MyMonsterPointer(); // don't link this client in the list if the monster is wait till seen and the player isn't facing the monster - if( pSightEnt && !pClient->FInViewCone( this ) ) + if( pClient && !pClient->FInViewCone( this ) ) { // we're not in the player's view cone. continue; From d3ebe0ac46aedfd75a4ccafadfd70e3665361ac5 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 2 Jul 2017 19:52:18 +0500 Subject: [PATCH 019/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/e7b5c6be5153ac402fc771d164808d2752105299 --- dlls/bigmomma.cpp | 2 +- dlls/crowbar.cpp | 44 ++++++++++++++++++++++---------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/dlls/bigmomma.cpp b/dlls/bigmomma.cpp index a038c776..6b594983 100644 --- a/dlls/bigmomma.cpp +++ b/dlls/bigmomma.cpp @@ -411,7 +411,7 @@ void CBigMomma::SetYawSpeed( void ) { int ys; - switch ( m_Activity ) + switch( m_Activity ) { case ACT_IDLE: ys = 100; diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index 051d2309..b00a0ad3 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -219,32 +219,32 @@ int CCrowbar::Swing( int fFirst ) fDidHit = TRUE; CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); - ClearMultiDamage(); - // If building with the clientside weapon prediction system, - // UTIL_WeaponTimeBase() is always 0 and m_flNextPrimaryAttack is >= -1.0f, thus making - // m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() always evaluate to false. -#ifdef CLIENT_WEAPONS - if( ( m_flNextPrimaryAttack + 1 == UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() ) -#else - if( ( m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() ) -#endif - { - // first swing does full damage - pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar, gpGlobals->v_forward, &tr, DMG_CLUB ); - } - else - { - // subsequent swings do half - pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar / 2, gpGlobals->v_forward, &tr, DMG_CLUB ); - } - ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev ); - // play thwack, smack, or dong sound - float flVol = 1.0; - int fHitWorld = TRUE; + float flVol = 1.0; + int fHitWorld = TRUE; if( pEntity ) { + ClearMultiDamage(); + // If building with the clientside weapon prediction system, + // UTIL_WeaponTimeBase() is always 0 and m_flNextPrimaryAttack is >= -1.0f, thus making + // m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() always evaluate to false. +#ifdef CLIENT_WEAPONS + if( ( m_flNextPrimaryAttack + 1 == UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() ) +#else + if( ( m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() ) +#endif + { + // first swing does full damage + pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar, gpGlobals->v_forward, &tr, DMG_CLUB ); + } + else + { + // subsequent swings do half + pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar / 2, gpGlobals->v_forward, &tr, DMG_CLUB ); + } + ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev ); + if( pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE ) { // play thwack or smack sound From 391c2aa2175d8e5511d80f68bac6d4b511739ca6 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 2 Jul 2017 20:09:34 +0500 Subject: [PATCH 020/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/5a13e06f522b1aff363fd0b1d360c2ed725cc6e4 --- dlls/aflock.cpp | 6 +++--- dlls/client.cpp | 2 +- dlls/plats.cpp | 24 +++++++++++++----------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/dlls/aflock.cpp b/dlls/aflock.cpp index 19998a9d..d50a8165 100644 --- a/dlls/aflock.cpp +++ b/dlls/aflock.cpp @@ -839,11 +839,11 @@ void CFlockingFlyer::SquadRemove( CFlockingFlyer *pRemove ) { CFlockingFlyer *pLeader = m_pSquadNext; - // copy the enemy LKP to the new leader - pLeader->m_vecEnemyLKP = m_vecEnemyLKP; - if( pLeader ) { + // copy the enemy LKP to the new leader + pLeader->m_vecEnemyLKP = m_vecEnemyLKP; + CFlockingFlyer *pList = pLeader; while( pList ) diff --git a/dlls/client.cpp b/dlls/client.cpp index ea4eb590..5d41d6ad 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -353,7 +353,7 @@ void Host_Say( edict_t *pEntity, int teamonly ) } // remove quotes if present - if( *p == '"' ) + if( p && *p == '"' ) { p++; p[strlen( p ) - 1] = 0; diff --git a/dlls/plats.cpp b/dlls/plats.cpp index 8fecf684..203f5d9b 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -743,21 +743,21 @@ void CFuncTrain::Next( void ) pev->target = pTarg->pev->target; m_flWait = pTarg->GetDelay(); - if ( m_pevCurrentTarget && m_pevCurrentTarget->speed != 0 ) + if( m_pevCurrentTarget && m_pevCurrentTarget->speed != 0 ) { // don't copy speed from target if it is 0 (uninitialized) pev->speed = m_pevCurrentTarget->speed; - ALERT( at_aiconsole, "Train %s speed to %4.2f\n", STRING(pev->targetname), pev->speed ); + ALERT( at_aiconsole, "Train %s speed to %4.2f\n", STRING( pev->targetname ), pev->speed ); } m_pevCurrentTarget = pTarg->pev;// keep track of this since path corners change our target for us. pev->enemy = pTarg->edict();//hack - if(FBitSet(m_pevCurrentTarget->spawnflags, SF_CORNER_TELEPORT)) + if( FBitSet( m_pevCurrentTarget->spawnflags, SF_CORNER_TELEPORT ) ) { // Path corner has indicated a teleport to the next corner. - SetBits(pev->effects, EF_NOINTERP); - UTIL_SetOrigin(pev, pTarg->pev->origin - (pev->mins + pev->maxs)* 0.5); + SetBits( pev->effects, EF_NOINTERP ); + UTIL_SetOrigin( pev, pTarg->pev->origin - ( pev->mins + pev->maxs ) * 0.5 ); Wait(); // Get on with doing the next path corner. } else @@ -767,13 +767,15 @@ void CFuncTrain::Next( void ) // CHANGED this from CHAN_VOICE to CHAN_STATIC around OEM beta time because trains should // use CHAN_STATIC for their movement sounds to prevent sound field problems. // this is not a hack or temporary fix, this is how things should be. (sjb). - if ( pev->noiseMovement ) - STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING(pev->noiseMovement) ); - if ( pev->noiseMovement ) - EMIT_SOUND (ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMovement), m_volume, ATTN_NORM); - ClearBits(pev->effects, EF_NOINTERP); + if( pev->noiseMovement ) + { + STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ), m_volume, ATTN_NORM ); + } + + ClearBits( pev->effects, EF_NOINTERP ); SetMoveDone( &CFuncTrain::Wait ); - LinearMove (pTarg->pev->origin - (pev->mins + pev->maxs)* 0.5, pev->speed); + LinearMove( pTarg->pev->origin - ( pev->mins + pev->maxs )* 0.5, pev->speed ); } } From 98a562c20e2add40c34973ed1be95f167120c10f Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 2 Jul 2017 21:17:51 +0500 Subject: [PATCH 021/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/9d2ae368aae3207dc9f66aca8a3c1505d5c3014a --- dlls/scientist.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dlls/scientist.cpp b/dlls/scientist.cpp index d7659c61..7cf9cc4d 100644 --- a/dlls/scientist.cpp +++ b/dlls/scientist.cpp @@ -464,7 +464,10 @@ void CScientist::StartTask( Task_t *pTask ) { Talk( 2 ); m_hTalkTarget = m_hEnemy; - if( m_hEnemy->IsPlayer() ) + + //The enemy can be null here. - Solokiller + //Discovered while testing the barnacle grapple on headcrabs with scientists in view. + if( m_hEnemy && m_hEnemy->IsPlayer() ) PlaySentence( "SC_PLFEAR", 5, VOL_NORM, ATTN_NORM ); else PlaySentence( "SC_FEAR", 5, VOL_NORM, ATTN_NORM ); From 4800c0d54ca8a9c5de8e0aa2b2f448b7c8b164ff Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 3 Jul 2017 03:24:14 +0500 Subject: [PATCH 022/144] Deactivate satchels on disconnect. --- dlls/client.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/dlls/client.cpp b/dlls/client.cpp index 5d41d6ad..7354f68f 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -110,14 +110,12 @@ void ClientDisconnect( edict_t *pEntity ) WRITE_STRING( text ); MESSAGE_END(); - CSound *pSound; - pSound = CSoundEnt::SoundPointerForIndex( CSoundEnt::ClientSoundIndex( pEntity ) ); + CSound *pSound = CSoundEnt::SoundPointerForIndex( CSoundEnt::ClientSoundIndex( pEntity ) ); + + // since this client isn't around to think anymore, reset their sound. + if( pSound ) { - // since this client isn't around to think anymore, reset their sound. - if( pSound ) - { - pSound->Reset(); - } + pSound->Reset(); } // since the edict doesn't get deleted, fix it so it doesn't interfere. @@ -125,6 +123,12 @@ void ClientDisconnect( edict_t *pEntity ) pEntity->v.solid = SOLID_NOT;// nonsolid UTIL_SetOrigin( &pEntity->v, pEntity->v.origin ); + CBasePlayer *pl = (CBasePlayer *)CBaseEntity::Instance( pEntity ); + if( pl->HasNamedPlayerItem( "weapon_satchel" ) ) + { + DeactivateSatchels( pl ); + } + g_pGameRules->ClientDisconnected( pEntity ); } From 780b4616fe420f3d9ab24d68bcc51ab172e4b1d0 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 02:41:23 +0500 Subject: [PATCH 023/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/c98747a35e324dca2d88c13036f1f74947caba96 --- dlls/rpg.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dlls/rpg.cpp b/dlls/rpg.cpp index fb2b39c8..021ad534 100644 --- a/dlls/rpg.cpp +++ b/dlls/rpg.cpp @@ -460,6 +460,8 @@ void CRpg::PrimaryAttack() m_flNextPrimaryAttack = GetNextAttackDelay( 1.5 ); m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5; + + ResetEmptySound(); } else { @@ -487,13 +489,13 @@ void CRpg::WeaponIdle( void ) { UpdateSpot(); - ResetEmptySound(); - if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return; if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { + ResetEmptySound(); + int iAnim; float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); if( flRand <= 0.75 || m_fSpotActive ) From 2cb20f7b7556306d08306e6615a93bf5d4f25a7a Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 02:43:50 +0500 Subject: [PATCH 024/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/274bd297f9af9cc251447dafc97de26019f0ed20 --- dlls/python.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/python.cpp b/dlls/python.cpp index b7e48386..90606c50 100644 --- a/dlls/python.cpp +++ b/dlls/python.cpp @@ -169,7 +169,7 @@ void CPython::PrimaryAttack() Reload(); else { - EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/357_cock1.wav", 0.8, ATTN_NORM ); + PlayEmptySound(); m_flNextPrimaryAttack = 0.15; } From c4820ad0df7bda569275452ad8f25c60d00301f9 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 03:12:53 +0500 Subject: [PATCH 025/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/89efd616d6aed0304db5bf63bfecd311c1cedbdd --- dlls/subs.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dlls/subs.cpp b/dlls/subs.cpp index 5ebe757b..4654363a 100644 --- a/dlls/subs.cpp +++ b/dlls/subs.cpp @@ -107,6 +107,13 @@ void CBaseEntity::UpdateOnRemove( void ) if( pev->globalname ) gGlobalState.EntitySetState( pev->globalname, GLOBAL_DEAD ); + + // tell owner ( if any ) that we're dead.This is mostly for MonsterMaker functionality. + //Killtarget didn't do this before, so the counter broke. - Solokiller + if( CBaseEntity* pOwner = pev->owner ? Instance( pev->owner ) : 0 ) + { + pOwner->DeathNotice( this ); + } } // Convenient way to delay removing oneself From f22f1331afc052a70921e3bb0421c7c205a14bb2 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 03:25:39 +0500 Subject: [PATCH 026/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/2219190a09711ecbb441ec7160315eccac194dea --- dlls/controller.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/dlls/controller.cpp b/dlls/controller.cpp index bfa119d3..b042949e 100644 --- a/dlls/controller.cpp +++ b/dlls/controller.cpp @@ -47,6 +47,7 @@ public: void Spawn( void ); void Precache( void ); + void UpdateOnRemove(); void SetYawSpeed( void ); int Classify( void ); void HandleAnimEvent( MonsterEvent_t *pEvent ); @@ -384,6 +385,23 @@ void CController::Precache() UTIL_PrecacheOther( "controller_head_ball" ); } +void CController::UpdateOnRemove() +{ + CBaseEntity::UpdateOnRemove(); + + if( m_pBall[0] ) + { + UTIL_Remove( m_pBall[0] ); + m_pBall[0] = nullptr; + } + + if( m_pBall[1] ) + { + UTIL_Remove( m_pBall[1] ); + m_pBall[1] = nullptr; + } +} + //========================================================= // AI Schedules Specific to this monster //========================================================= From 6379954153e2c0c0001139b7f7dce9835b17da15 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 03:32:53 +0500 Subject: [PATCH 027/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/e41b164fdffef1b89aa5286ae15c9617dfcf2188 https://github.com/SamVanheer/HLEnhanced/commit/2da0a12d353f2078f1e2f6d931deb9c0f04e5b43 --- dlls/gargantua.cpp | 14 ++++++++++++++ dlls/islave.cpp | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/dlls/gargantua.cpp b/dlls/gargantua.cpp index 7f60b401..6aa6a738 100644 --- a/dlls/gargantua.cpp +++ b/dlls/gargantua.cpp @@ -200,6 +200,7 @@ class CGargantua : public CBaseMonster public: void Spawn( void ); void Precache( void ); + void UpdateOnRemove(); void SetYawSpeed( void ); int Classify( void ); int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); @@ -802,6 +803,19 @@ void CGargantua::Precache() PRECACHE_SOUND( (char *)pBreatheSounds[i] ); } +void CGargantua::UpdateOnRemove() +{ + CBaseEntity::UpdateOnRemove(); + + if( m_pEyeGlow ) + { + UTIL_Remove( m_pEyeGlow ); + m_pEyeGlow = 0; + } + + FlameDestroy(); +} + void CGargantua::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { ALERT( at_aiconsole, "CGargantua::TraceAttack\n" ); diff --git a/dlls/islave.cpp b/dlls/islave.cpp index 3b4343d3..51def5d3 100644 --- a/dlls/islave.cpp +++ b/dlls/islave.cpp @@ -44,6 +44,7 @@ class CISlave : public CSquadMonster public: void Spawn( void ); void Precache( void ); + void UpdateOnRemove(); void SetYawSpeed( void ); int ISoundMask( void ); int Classify( void ); @@ -557,6 +558,13 @@ void CISlave::Precache() UTIL_PrecacheOther( "test_effect" ); } +void CISlave::UpdateOnRemove() +{ + CBaseEntity::UpdateOnRemove(); + + ClearBeams(); +} + //========================================================= // TakeDamage - get provoked when injured //========================================================= From 95d81733fcc5cb152d9b71224fe4a60de52263bc Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 03:41:48 +0500 Subject: [PATCH 028/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/29947a0558967e43ead0c4558251c6f77924b3ea --- dlls/tripmine.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dlls/tripmine.cpp b/dlls/tripmine.cpp index 520206dd..60190604 100644 --- a/dlls/tripmine.cpp +++ b/dlls/tripmine.cpp @@ -43,6 +43,7 @@ class CTripmineGrenade : public CGrenade { void Spawn( void ); void Precache( void ); + void UpdateOnRemove(); virtual int Save( CSave &save ); virtual int Restore( CRestore &restore ); @@ -148,6 +149,13 @@ void CTripmineGrenade::Precache( void ) PRECACHE_SOUND( "weapons/mine_charge.wav" ); } +void CTripmineGrenade::UpdateOnRemove() +{ + CBaseEntity::UpdateOnRemove(); + + KillBeam(); +} + void CTripmineGrenade::WarningThink( void ) { // play warning sound From 9c85e5eb77e81b642836bad53ddeaa72a6284c02 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 03:46:20 +0500 Subject: [PATCH 029/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/b3cf83bbf11e0f098382f27f63d0364043306a03 --- dlls/turret.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dlls/turret.cpp b/dlls/turret.cpp index 5b9e1b77..ae95db14 100644 --- a/dlls/turret.cpp +++ b/dlls/turret.cpp @@ -56,6 +56,7 @@ class CBaseTurret : public CBaseMonster public: void Spawn( void ); virtual void Precache( void ); + void UpdateOnRemove(); void KeyValue( KeyValueData *pkvd ); void EXPORT TurretUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); @@ -279,6 +280,17 @@ void CBaseTurret::Precache() PRECACHE_SOUND( "turret/tu_alert.wav" ); } +void CBaseTurret::UpdateOnRemove() +{ + CBaseEntity::UpdateOnRemove(); + + if( m_pEyeGlow ) + { + UTIL_Remove( m_pEyeGlow ); + m_pEyeGlow = 0; + } +} + #define TURRET_GLOW_SPRITE "sprites/flare3.spr" void CTurret::Spawn() From 9bb5cb2f05391097453a27b51b671044189f320e Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 03:56:48 +0500 Subject: [PATCH 030/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/46ea4af5f8dc168d048b2cada03308e9c4c3069d --- dlls/nihilanth.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/dlls/nihilanth.cpp b/dlls/nihilanth.cpp index 479a2b34..82b31e13 100644 --- a/dlls/nihilanth.cpp +++ b/dlls/nihilanth.cpp @@ -34,6 +34,7 @@ public: void Spawn( void ); void Precache( void ); + void UpdateOnRemove(); int Classify( void ) { return CLASS_ALIEN_MILITARY; }; int BloodColor( void ) { return BLOOD_COLOR_YELLOW; } void Killed( entvars_t *pevAttacker, int iGib ); @@ -345,6 +346,26 @@ void CNihilanth::Precache( void ) PRECACHE_SOUND( "debris/beamstart7.wav" ); } +void CNihilanth::UpdateOnRemove() +{ + CBaseEntity::UpdateOnRemove(); + + if( m_pBall ) + { + UTIL_Remove( m_pBall ); + m_pBall = 0; + } + + for( int i = 0; i < N_SPHERES, i++ ) + { + if( CBaseEntity* pSphere = (CBaseEntity *)m_hSphere[i] ) + { + UTIL_Remove( pSphere ); + m_hSphere[i] = 0; + } + } +} + void CNihilanth::PainSound( void ) { if( m_flNextPainSound > gpGlobals->time ) From 3ad3004dd900f5bfaecf2d57bead3e34d2fc5785 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 04:03:22 +0500 Subject: [PATCH 031/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/3e2f7e1e81af06d092f6350e58b26dfeb699ebc6 --- dlls/controller.cpp | 4 ++-- dlls/crowbar.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dlls/controller.cpp b/dlls/controller.cpp index b042949e..e1d57517 100644 --- a/dlls/controller.cpp +++ b/dlls/controller.cpp @@ -392,13 +392,13 @@ void CController::UpdateOnRemove() if( m_pBall[0] ) { UTIL_Remove( m_pBall[0] ); - m_pBall[0] = nullptr; + m_pBall[0] = 0; } if( m_pBall[1] ) { UTIL_Remove( m_pBall[1] ); - m_pBall[1] = nullptr; + m_pBall[1] = 0; } } diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index b00a0ad3..65e21162 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -139,8 +139,10 @@ void CCrowbar::PrimaryAttack() { if( !Swing( 1 ) ) { +#ifndef CLIENT_DLL SetThink( &CCrowbar::SwingAgain ); pev->nextthink = gpGlobals->time + 0.1; +#endif } } @@ -301,11 +303,11 @@ int CCrowbar::Swing( int fFirst ) } m_pPlayer->m_iWeaponVolume = (int)( flVol * CROWBAR_WALLHIT_VOLUME ); -#endif - m_flNextPrimaryAttack = GetNextAttackDelay( 0.25 ); SetThink( &CCrowbar::Smack ); pev->nextthink = UTIL_WeaponTimeBase() + 0.2; +#endif + m_flNextPrimaryAttack = GetNextAttackDelay( 0.25 ); } return fDidHit; } From 740a5a2c31b799dd3f8bd4e5312451489e3cafbe Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 16:42:08 +0500 Subject: [PATCH 032/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/2baa8fe118db844968b2868d378d93b9f7f4f742 --- dlls/weapons.cpp | 7 +++++++ dlls/weapons.h | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 989c32a8..854425ad 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -1557,6 +1557,13 @@ TYPEDESCRIPTION CEgon::m_SaveData[] = IMPLEMENT_SAVERESTORE( CEgon, CBasePlayerWeapon ) +TYPEDESCRIPTION CHgun::m_SaveData[] = +{ + DEFINE_FIELD( CHgun, m_flRechargeTime, FIELD_FLOAT ), +}; + +IMPLEMENT_SAVERESTORE( CHgun, CBasePlayerWeapon ) + TYPEDESCRIPTION CSatchel::m_SaveData[] = { DEFINE_FIELD( CSatchel, m_chargeReady, FIELD_INTEGER ), diff --git a/dlls/weapons.h b/dlls/weapons.h index 7bb1b486..6f5de37a 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -841,6 +841,11 @@ private: class CHgun : public CBasePlayerWeapon { public: +#ifndef CLIENT_DLL + int Save( CSave &save ); + int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; +#endif void Spawn( void ); void Precache( void ); int iItemSlot( void ) { return 4; } From 4024c29caf23984191d601bce7e17c5276b83632 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 16:45:48 +0500 Subject: [PATCH 033/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/7002f8fb477c03b44ec2251b1308f4e5432cb50e --- cl_dll/ammo.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cl_dll/ammo.cpp b/cl_dll/ammo.cpp index 860cde42..3d214280 100644 --- a/cl_dll/ammo.cpp +++ b/cl_dll/ammo.cpp @@ -542,7 +542,7 @@ int CHudAmmo::MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf ) } else { - if ( m_pWeapon ) + if( m_pWeapon ) SetCrosshair( m_pWeapon->hCrosshair, m_pWeapon->rcCrosshair, 255, 255, 255 ); } @@ -574,6 +574,8 @@ int CHudAmmo::MsgFunc_CurWeapon( const char *pszName, int iSize, void *pbuf ) if( iId < 1 ) { SetCrosshair( 0, nullrc, 0, 0, 0 ); + // Clear out the weapon so we don't keep drawing the last active weapon's ammo. - Solokiller + m_pWeapon = 0; return 0; } From ca7464b158c5ad69c504168cd249dce4135d1a5d Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 16:51:43 +0500 Subject: [PATCH 034/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/60a45fb6cd027168e2c546d64f1176ed830070d8 --- dlls/weapons.cpp | 2 ++ dlls/weapons.h | 1 + 2 files changed, 3 insertions(+) diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 854425ad..ff083ee7 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -598,6 +598,8 @@ BOOL CanAttack( float attack_time, float curtime, BOOL isPredicted ) void CBasePlayerWeapon::ItemPostFrame( void ) { + WeaponTick(); + if( ( m_fInReload ) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) ) { // complete the reload. diff --git a/dlls/weapons.h b/dlls/weapons.h index 6f5de37a..a7c40678 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -318,6 +318,7 @@ public: virtual void PrimaryAttack( void ) { return; } // do "+ATTACK" virtual void SecondaryAttack( void ) { return; } // do "+ATTACK2" virtual void Reload( void ) { return; } // do "+RELOAD" + virtual void WeaponTick() {} // Always called at beginning of ItemPostFrame. - Solokiller virtual void WeaponIdle( void ) { return; } // called when no buttons pressed virtual int UpdateClientData( CBasePlayer *pPlayer ); // sends hud info to client dll, if things have changed virtual void RetireWeapon( void ); From e5f6f7d9acbc35795cb20cbd7e09bd6e45afd6b9 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 16:58:26 +0500 Subject: [PATCH 035/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/0cbbe099f3170170d41683c2a4288d1f06aad048 --- dlls/shotgun.cpp | 17 ++++++++++------- dlls/weapons.h | 1 + 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/dlls/shotgun.cpp b/dlls/shotgun.cpp index d6be007a..12e73ede 100644 --- a/dlls/shotgun.cpp +++ b/dlls/shotgun.cpp @@ -169,7 +169,7 @@ void CShotgun::PrimaryAttack() // HEV suit - indicate out of ammo condition m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); - if( m_iClip != 0 ) + //if( m_iClip != 0 ) m_flPumpTime = gpGlobals->time + 0.5; m_flNextPrimaryAttack = GetNextAttackDelay( 0.75 ); @@ -240,7 +240,7 @@ void CShotgun::SecondaryAttack( void ) // HEV suit - indicate out of ammo condition m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); - if( m_iClip != 0 ) + //if( m_iClip != 0 ) m_flPumpTime = gpGlobals->time + 0.95; m_flNextPrimaryAttack = GetNextAttackDelay( 1.5 ); @@ -299,18 +299,21 @@ void CShotgun::Reload( void ) } } -void CShotgun::WeaponIdle( void ) +void CShotgun::WeaponTick() { - ResetEmptySound(); - - m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES ); - if( m_flPumpTime && m_flPumpTime < gpGlobals->time ) { // play pumping sound EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/scock1.wav", 1, ATTN_NORM, 0, 95 + RANDOM_LONG( 0, 0x1f ) ); m_flPumpTime = 0; } +} + +void CShotgun::WeaponIdle( void ) +{ + ResetEmptySound(); + + m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES ); if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() ) { diff --git a/dlls/weapons.h b/dlls/weapons.h index a7c40678..7d99e8a6 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -632,6 +632,7 @@ public: void SecondaryAttack( void ); BOOL Deploy( ); void Reload( void ); + void WeaponTick(); void WeaponIdle( void ); int m_fInReload; float m_flNextReload; From 689316912ac98dbd928caacaf73436130e391a28 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 17:06:23 +0500 Subject: [PATCH 036/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/19396936af13e417e7f9eaf48c48c49699da03fb --- cl_dll/ev_hldm.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 787e1be8..381c9179 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -1430,6 +1430,12 @@ void EV_EgonFire( event_args_t *args ) } else { + // If there is any sound playing already, kill it. - Solokiller + // This is necessary because multiple sounds can play on the same channel at the same time. + // In some cases, more than 1 run sound plays when the egon stops firing, in which case only the earliest entry in the list is stopped. + // This ensures no more than 1 of those is ever active at the same time. + gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, EGON_SOUND_RUN ); + if( iFireMode == FIRE_WIDE ) gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_STATIC, EGON_SOUND_RUN, 0.98, ATTN_NORM, 0, 125 ); else @@ -1438,7 +1444,7 @@ void EV_EgonFire( event_args_t *args ) //Only play the weapon anims if I shot it. if( EV_IsLocal( idx ) ) - gEngfuncs.pEventAPI->EV_WeaponAnimation ( g_fireAnims1[gEngfuncs.pfnRandomLong( 0, 3 )], 1 ); + gEngfuncs.pEventAPI->EV_WeaponAnimation( g_fireAnims1[gEngfuncs.pfnRandomLong( 0, 3 )], 1 ); if( iStartup == 1 && EV_IsLocal( idx ) && !pBeam && !pBeam2 && cl_lw->value ) //Adrian: Added the cl_lw check for those lital people that hate weapon prediction. { From 55c3eb674c83cd511a34ea769885cbd6e43f09ad Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 17:39:50 +0500 Subject: [PATCH 037/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/35fd286ccaf7426a95baf30e682410510fe77083 --- dlls/monsters.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dlls/monsters.cpp b/dlls/monsters.cpp index 5f112a62..a9796a80 100644 --- a/dlls/monsters.cpp +++ b/dlls/monsters.cpp @@ -3357,6 +3357,9 @@ CBaseEntity *CBaseMonster::DropItem( const char *pszItemName, const Vector &vecP // do we want this behavior to be default?! (sjb) pItem->pev->velocity = pev->velocity; pItem->pev->avelocity = Vector( 0, RANDOM_FLOAT( 0, 100 ), 0 ); + + // Dropped items should never respawn (unless this rule changes in the future). - Solokiller + pItem->pev->spawnflags |= SF_NORESPAWN; return pItem; } else From 33ba064b88d9b0e818009049aef13f53bd16ae20 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 17:53:04 +0500 Subject: [PATCH 038/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/4dfa6b8710a0a30761b298a02bee21c65f056327 --- cl_dll/ev_hldm.cpp | 2 -- dlls/crowbar.cpp | 9 ++++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 381c9179..7d2464e8 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -1159,8 +1159,6 @@ void EV_Crowbar( event_args_t *args ) if( EV_IsLocal( idx ) ) { - gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK1MISS, 1 ); - switch( (g_iSwing++) % 3 ) { case 0: diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index 65e21162..98808e14 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -183,9 +183,12 @@ int CCrowbar::Swing( int fFirst ) } } #endif - PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usCrowbar, - 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0, - 0, 0, 0 ); + if( fFirst ) + { + PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usCrowbar, + 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0, + 0, 0, 0 ); + } if( tr.flFraction >= 1.0 ) { From 033bbbcd80bce28b4a5b25f5362e28d43b909474 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 18:04:09 +0500 Subject: [PATCH 039/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/3680342c619bf2efef9a8e2e99c72f4469a89bbd --- cl_dll/ammo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cl_dll/ammo.cpp b/cl_dll/ammo.cpp index 3d214280..f439520e 100644 --- a/cl_dll/ammo.cpp +++ b/cl_dll/ammo.cpp @@ -536,7 +536,7 @@ int CHudAmmo::MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf ) if( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) ) { - static wrect_t nullrc; + wrect_t nullrc = {}; gpActiveSel = NULL; SetCrosshair( 0, nullrc, 0, 0, 0 ); } @@ -556,7 +556,7 @@ int CHudAmmo::MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf ) // int CHudAmmo::MsgFunc_CurWeapon( const char *pszName, int iSize, void *pbuf ) { - static wrect_t nullrc; + wrect_t nullrc = {}; int fOnTarget = FALSE; BEGIN_READ( pbuf, iSize ); From 6f44185a645266d2fb7ea8bc5136b6b57f650a61 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 18:31:35 +0500 Subject: [PATCH 040/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/0398781544bce0766545fbbb8ac8367e3db6c86b --- cl_dll/ev_hldm.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 7d2464e8..7bb3a797 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -521,16 +521,17 @@ void EV_FireGlock2( event_args_t *args ) VectorCopy( args->origin, origin ); VectorCopy( args->angles, angles ); VectorCopy( args->velocity, velocity ); + int empty = args->bparam1; AngleVectors( angles, forward, right, up ); - shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/shell.mdl");// brass shell + shell = gEngfuncs.pEventAPI->EV_FindModelIndex( "models/shell.mdl" );// brass shell if( EV_IsLocal( idx ) ) { // Add muzzle flash to current weapon model EV_MuzzleFlash(); - gEngfuncs.pEventAPI->EV_WeaponAnimation( GLOCK_SHOOT, 2 ); + gEngfuncs.pEventAPI->EV_WeaponAnimation( empty ? GLOCK_SHOOT_EMPTY : GLOCK_SHOOT, 2 ); V_PunchAxis( 0, -2.0 ); } From e7b324da5ebd26b0eae9c080911fd40c6ca478fb Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 19:17:59 +0500 Subject: [PATCH 041/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/19c8e45d8f92d0e09171f9f1b5b3fd0f25d109b6 --- dlls/mp5.cpp | 6 ++++++ dlls/weapons.h | 1 + 2 files changed, 7 insertions(+) diff --git a/dlls/mp5.cpp b/dlls/mp5.cpp index 7131f888..a13257a1 100644 --- a/dlls/mp5.cpp +++ b/dlls/mp5.cpp @@ -270,6 +270,12 @@ void CMP5::WeaponIdle( void ) m_flTimeWeaponIdle = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); // how long till we do this again. } +BOOL CMP5::IsUseable() +{ + //Can be used if the player has AR grenades. - Solokiller + return CBasePlayerWeapon::IsUseable() || m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] > 0; +} + class CMP5AmmoClip : public CBasePlayerAmmo { void Spawn( void ) diff --git a/dlls/weapons.h b/dlls/weapons.h index 7d99e8a6..86e9c7f6 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -563,6 +563,7 @@ public: BOOL Deploy( void ); void Reload( void ); void WeaponIdle( void ); + BOOL IsUseable(); float m_flNextAnimTime; int m_iShell; From 19bdc1d01b7287cd61b58fb7b7bdb6953caa50a8 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 19:48:01 +0500 Subject: [PATCH 042/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/33413807d0ca23f3d9121e45f5584cb5be98751b --- dlls/gauss.cpp | 36 ++++++++++++++++++++++++++---------- dlls/weapons.h | 2 +- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/dlls/gauss.cpp b/dlls/gauss.cpp index 93352b57..0ebb876c 100644 --- a/dlls/gauss.cpp +++ b/dlls/gauss.cpp @@ -123,6 +123,12 @@ int CGauss::GetItemInfo( ItemInfo *p ) return 1; } +BOOL CGauss::IsUseable() +{ + // Currently charging, allow the player to fire it first. - Solokiller + return CBasePlayerWeapon::IsUseable() || m_InAttack != 0; +} + BOOL CGauss::Deploy() { m_pPlayer->m_flPlayAftershock = 0.0; @@ -224,6 +230,22 @@ void CGauss::SecondaryAttack() } else { + // Moved to before the ammo burn. + // Because we drained 1 when m_InAttack == 0, then 1 again now before checking if we're out of ammo, + // this resuled in the player having -1 ammo, which in turn caused CanDeploy to think it could be deployed. + // This will need to be fixed further down the line by preventing negative ammo unless explicitly required (infinite ammo?), + // But this check will prevent the problem for now. - Solokiller + // TODO: investigate further. + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) + { + // out of ammo! force the gun to fire + StartFire(); + m_fInAttack = 0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1; + return; + } + // during the charging process, eat one bit of ammo every once in a while if( UTIL_WeaponTimeBase() >= m_pPlayer->m_flNextAmmoBurn && m_pPlayer->m_flNextAmmoBurn != 1000 ) { @@ -243,16 +265,6 @@ void CGauss::SecondaryAttack() } } - if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) - { - // out of ammo! force the gun to fire - StartFire(); - m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1; - return; - } - if( UTIL_WeaponTimeBase() >= m_pPlayer->m_flAmmoStartCharge ) { // don't eat any more ammo after gun is fully charged. @@ -558,6 +570,10 @@ void CGauss::WeaponIdle( void ) StartFire(); m_fInAttack = 0; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0; + + // Need to set m_flNextPrimaryAttack so the weapon gets a chance to complete its secondary fire animation. - Solokiller + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; } else { diff --git a/dlls/weapons.h b/dlls/weapons.h index 86e9c7f6..736dadd4 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -741,7 +741,7 @@ public: int iItemSlot( void ) { return 4; } int GetItemInfo(ItemInfo *p); int AddToPlayer( CBasePlayer *pPlayer ); - + BOOL IsUseable(); BOOL Deploy( void ); void Holster( int skiplocal = 0 ); From 9ef79aee9ef6924dfdfe2ec1538dc0d26fe8a0f8 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 21:44:06 +0500 Subject: [PATCH 043/144] Merge https://github.com/ValveSoftware/halflife/pull/1720/commits/6f020090bd75706174012bb080fce8f4b6a2d187 --- dlls/rpg.cpp | 8 ++++---- dlls/weapons.cpp | 2 +- dlls/weapons.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dlls/rpg.cpp b/dlls/rpg.cpp index 021ad534..5fb8cc70 100644 --- a/dlls/rpg.cpp +++ b/dlls/rpg.cpp @@ -109,8 +109,8 @@ CRpgRocket *CRpgRocket::CreateRpgRocket( Vector vecOrigin, Vector vecAngles, CBa pRocket->pev->angles = vecAngles; pRocket->Spawn(); pRocket->SetTouch( &CRpgRocket::RocketTouch ); - pRocket->m_pLauncher = pLauncher;// remember what RPG fired me. - pRocket->m_pLauncher->m_cActiveRockets++;// register this missile as active for the launcher + pRocket->m_hLauncher = pLauncher;// remember what RPG fired me. + pLauncher->m_cActiveRockets++;// register this missile as active for the launcher pRocket->pev->owner = pOwner->edict(); return pRocket; @@ -150,10 +150,10 @@ void CRpgRocket::Spawn( void ) //========================================================= void CRpgRocket::RocketTouch( CBaseEntity *pOther ) { - if( m_pLauncher ) + if( CRpg* pLauncher = (CRpg*)( (CBaseEntity*)( m_hLauncher ) ) ) { // my launcher is still around, tell it I'm dead. - m_pLauncher->m_cActiveRockets--; + pLauncher->m_cActiveRockets--; } STOP_SOUND( edict(), CHAN_VOICE, "weapons/rocket1.wav" ); diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index ff083ee7..bc508c6a 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -1518,7 +1518,7 @@ IMPLEMENT_SAVERESTORE( CRpg, CBasePlayerWeapon ) TYPEDESCRIPTION CRpgRocket::m_SaveData[] = { DEFINE_FIELD( CRpgRocket, m_flIgniteTime, FIELD_TIME ), - DEFINE_FIELD( CRpgRocket, m_pLauncher, FIELD_CLASSPTR ), + DEFINE_FIELD( CRpgRocket, m_hLauncher, FIELD_EHANDLE ), }; IMPLEMENT_SAVERESTORE( CRpgRocket, CGrenade ) diff --git a/dlls/weapons.h b/dlls/weapons.h index 736dadd4..3d8dd6ad 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -725,7 +725,7 @@ public: int m_iTrail; float m_flIgniteTime; - CRpg *m_pLauncher;// pointer back to the launcher that fired me. + EHANDLE m_hLauncher; // handle back to the launcher that fired me. }; class CGauss : public CBasePlayerWeapon From e98f45b2796670989b9ac219cbe99f4df9845e51 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 21:53:57 +0500 Subject: [PATCH 044/144] Merge https://github.com/ValveSoftware/halflife/pull/1599 --- dlls/weapons.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index bc508c6a..61b038c0 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -578,6 +578,13 @@ void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther ) } SUB_UseTargets( pOther, USE_TOGGLE, 0 ); // UNDONE: when should this happen? + + // If the item is falling and its Think remains FallItem after the player picks it up, + // then after the item touches the ground its Touch will be set back to DefaultTouch, + // so the player will pick it up again, this time Kill-ing the item (since we already have it in the inventory), + // which will make the pointer bad and crash the game. + if( m_pfnThink == &CBasePlayerItem::FallThink ) + SetThink( NULL ); } BOOL CanAttack( float attack_time, float curtime, BOOL isPredicted ) From cf5b2f9e14fdc87f3c58b8780834fffd9cec8fd7 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 23:50:55 +0500 Subject: [PATCH 045/144] Merge https://github.com/ValveSoftware/halflife/pull/1601 --- cl_dll/cdll_int.cpp | 14 ++++++++++++++ dlls/client.cpp | 14 +++++++++++++- dlls/game.cpp | 2 ++ dlls/player.cpp | 13 +++++++++++++ dlls/player.h | 10 ++++++---- pm_shared/pm_shared.c | 13 ++++++++----- 6 files changed, 56 insertions(+), 10 deletions(-) diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index ffd342d2..d71659e9 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -21,6 +21,7 @@ #include "hud.h" #include "cl_util.h" #include "netadr.h" +#include "parsemsg.h" extern "C" { @@ -32,10 +33,21 @@ extern "C" cl_enginefunc_t gEngfuncs; CHud gHUD; mobile_engfuncs_t *gMobileEngfuncs = NULL; + +extern "C" int g_bhopcap; void InitInput( void ); void EV_HookEvents( void ); void IN_Commands( void ); +int __MsgFunc_Bhopcap( const char *pszName, int iSize, void *pbuf ) +{ + BEGIN_READ( pbuf, iSize ); + + g_bhopcap = READ_BYTE(); + + return 1; +} + /* ========================== Initialize @@ -196,6 +208,8 @@ void DLLEXPORT HUD_Init( void ) { InitInput(); gHUD.Init(); + + gEngfuncs.pfnHookUserMsg( "Bhopcap", __MsgFunc_Bhopcap ); } /* diff --git a/dlls/client.cpp b/dlls/client.cpp index 7354f68f..1fead362 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -48,11 +48,15 @@ extern DLL_GLOBAL ULONG g_ulFrameCount; extern void CopyToBodyQue( entvars_t* pev ); extern int giPrecacheGrunt; extern int gmsgSayText; +extern int gmsgBhopcap; extern cvar_t allow_spectators; extern int g_teamplay; +extern cvar_t bhopcap; +extern "C" int g_bhopcap; + void LinkUserMessages( void ); /* @@ -799,8 +803,16 @@ void StartFrame( void ) gpGlobals->teamplay = teamplay.value; g_ulFrameCount++; -} + int oldBhopcap = g_bhopcap; + g_bhopcap = ( g_pGameRules->IsMultiplayer() && bhopcap.value != 0.0f ) ? 1 : 0; + if( g_bhopcap != oldBhopcap ) + { + MESSAGE_BEGIN( MSG_ALL, gmsgBhopcap, NULL ); + WRITE_BYTE( g_bhopcap ); + MESSAGE_END(); + } +} void ClientPrecache( void ) { diff --git a/dlls/game.cpp b/dlls/game.cpp index fb247903..7905075a 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -38,6 +38,7 @@ cvar_t teamlist = { "mp_teamlist","hgrunt;scientist", FCVAR_SERVER }; cvar_t teamoverride = { "mp_teamoverride","1" }; cvar_t defaultteam = { "mp_defaultteam","0" }; cvar_t allowmonsters = { "mp_allowmonsters","0", FCVAR_SERVER }; +cvar_t bhopcap = { "mp_bhopcap", "1", FCVAR_SERVER }; cvar_t allow_spectators = { "allow_spectators", "0", FCVAR_SERVER }; // 0 prevents players from being spectators @@ -473,6 +474,7 @@ void GameDLLInit( void ) CVAR_REGISTER( &teamoverride ); CVAR_REGISTER( &defaultteam ); CVAR_REGISTER( &allowmonsters ); + CVAR_REGISTER( &bhopcap ); CVAR_REGISTER( &mp_chattime ); diff --git a/dlls/player.cpp b/dlls/player.cpp index 51995acf..b838f35f 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -45,6 +45,8 @@ extern DLL_GLOBAL BOOL g_fDrawLines; int gEvilImpulse101; extern DLL_GLOBAL int g_iSkillLevel, gDisplayTitle; +extern "C" int g_bhopcap; + BOOL gInitHUD = TRUE; extern void CopyToBodyQue( entvars_t *pev); @@ -181,6 +183,7 @@ int gmsgSetFOV = 0; int gmsgShowMenu = 0; int gmsgGeigerRange = 0; int gmsgTeamNames = 0; +int gmsgBhopcap = 0; int gmsgStatusText = 0; int gmsgStatusValue = 0; @@ -227,6 +230,7 @@ void LinkUserMessages( void ) gmsgFade = REG_USER_MSG( "ScreenFade", sizeof(ScreenFade) ); gmsgAmmoX = REG_USER_MSG( "AmmoX", 2 ); gmsgTeamNames = REG_USER_MSG( "TeamNames", -1 ); + gmsgBhopcap = REG_USER_MSG( "Bhopcap", 1 ); gmsgStatusText = REG_USER_MSG( "StatusText", -1 ); gmsgStatusValue = REG_USER_MSG( "StatusValue", 3 ); @@ -4072,6 +4076,15 @@ void CBasePlayer::UpdateClientData( void ) UpdateStatusBar(); m_flNextSBarUpdateTime = gpGlobals->time + 0.2; } + + // Send the current bhopcap state. + if( !m_bSentBhopcap ) + { + m_bSentBhopcap = true; + MESSAGE_BEGIN( MSG_ONE, gmsgBhopcap, NULL, pev ); + WRITE_BYTE( g_bhopcap ); + MESSAGE_END(); + } } //========================================================= diff --git a/dlls/player.h b/dlls/player.h index b2dce868..8ff312ea 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -313,13 +313,15 @@ public: //Player ID void InitStatusBar( void ); void UpdateStatusBar( void ); - int m_izSBarState[ SBAR_END ]; + int m_izSBarState[SBAR_END]; float m_flNextSBarUpdateTime; float m_flStatusBarDisappearDelay; - char m_SbarString0[ SBAR_STRING_SIZE ]; - char m_SbarString1[ SBAR_STRING_SIZE ]; + char m_SbarString0[SBAR_STRING_SIZE]; + char m_SbarString1[SBAR_STRING_SIZE]; float m_flNextChatTime; + + bool m_bSentBhopcap; // If false, the player just joined and needs a bhopcap message. }; #define AUTOAIM_2DEGREES 0.0348994967025 @@ -327,7 +329,7 @@ public: #define AUTOAIM_8DEGREES 0.1391731009601 #define AUTOAIM_10DEGREES 0.1736481776669 -extern int gmsgHudText; +extern int gmsgHudText; extern BOOL gInitHUD; #endif // PLAYER_H diff --git a/pm_shared/pm_shared.c b/pm_shared/pm_shared.c index c709ba14..9aed8093 100644 --- a/pm_shared/pm_shared.c +++ b/pm_shared/pm_shared.c @@ -27,11 +27,13 @@ #include // atoi #include // isspace +int g_bhopcap = 1; + #ifdef CLIENT_DLL - // Spectator Mode - int iJumpSpectator; -extern float vJumpOrigin[3]; -extern float vJumpAngles[3]; +// Spectator Mode +int iJumpSpectator; +extern float vJumpOrigin[3]; +extern float vJumpAngles[3]; #endif static int pm_shared_initialized = 0; @@ -2556,7 +2558,8 @@ void PM_Jump( void ) // In the air now. pmove->onground = -1; - PM_PreventMegaBunnyJumping(); + if( g_bhopcap ) + PM_PreventMegaBunnyJumping(); if( tfc ) { From 85edea072b35d0dce99f60ad5fb11a1cd82e3e67 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 6 Jul 2017 00:10:06 +0500 Subject: [PATCH 046/144] Merge https://github.com/ValveSoftware/halflife/pull/1590/commits/136de25b61689ee30ca0206e6737c7d06be77567 --- cl_dll/menu.cpp | 10 ++++++---- cl_dll/text_message.cpp | 12 ++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/cl_dll/menu.cpp b/cl_dll/menu.cpp index 5f710a33..fc24b917 100644 --- a/cl_dll/menu.cpp +++ b/cl_dll/menu.cpp @@ -83,7 +83,7 @@ int CHudMenu::Draw( float flTime ) int nlc = 0; for( i = 0; i < MAX_MENU_STRING && g_szMenuString[i] != '\0'; i++ ) { - if ( g_szMenuString[i] == '\n' ) + if( g_szMenuString[i] == '\n' ) nlc++; } @@ -153,19 +153,21 @@ int CHudMenu::MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf ) else { // append to the current menu string - strncat( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING - strlen( g_szPrelocalisedMenuString ) ); + strncat( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING - strlen( g_szPrelocalisedMenuString ) - 1 ); } g_szPrelocalisedMenuString[MAX_MENU_STRING - 1] = 0; // ensure null termination (strncat/strncpy does not) if( !NeedMore ) { // we have the whole string, so we can localise it now - strcpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ) ); + strncpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ), MAX_MENU_STRING ); + g_szMenuString[MAX_MENU_STRING - 1] = '\0'; // Swap in characters if( KB_ConvertString( g_szMenuString, &temp ) ) { - strcpy( g_szMenuString, temp ); + strncpy( g_szMenuString, temp, MAX_MENU_STRING ); + g_szMenuString[MAX_MENU_STRING - 1] = '\0'; free( temp ); } } diff --git a/cl_dll/text_message.cpp b/cl_dll/text_message.cpp index 58dae6f7..9452cebb 100644 --- a/cl_dll/text_message.cpp +++ b/cl_dll/text_message.cpp @@ -45,14 +45,15 @@ int CHudTextMessage::Init( void ) char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size ) { char *dst = dst_buffer; - for( char *src = (char*)msg; *src != 0 && buffer_size > 0; buffer_size-- ) + for( char *src = (char*)msg; *src != 0 && ( buffer_size - 1 ) > 0; buffer_size-- ) { if( *src == '#' ) { // cut msg name out of string static char word_buf[255]; char *wdst = word_buf, *word_start = src; - for( ++src; ( *src >= 'A' && *src <= 'z' ) || ( *src >= '0' && *src <= '9' ); wdst++, src++ ) + int wordbuf_size = (int)sizeof(word_buf); + for( ++src; ( ( *src >= 'A' && *src <= 'z' ) || ( *src >= '0' && *src <= '9' ) ) && ( wordbuf_size - 1 ) > 0; wdst++, src++, wordbuf_size-- ) { *wdst = *src; } @@ -69,21 +70,20 @@ char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, in } // copy string into message over the msg name - for( char *wsrc = (char*)clmsg->pMessage; *wsrc != 0; wsrc++, dst++ ) + for( char *wsrc = (char*)clmsg->pMessage; *wsrc != 0 && ( buffer_size - 1 ) > 0; wsrc++, dst++, buffer_size-- ) { *dst = *wsrc; } - *dst = 0; + buffer_size++; } else { *dst = *src; dst++, src++; - *dst = 0; } } - dst_buffer[buffer_size - 1] = 0; // ensure null termination + *dst = 0; // ensure null termination return dst_buffer; } From 495c7717242f0315fced701c57dee242b48f66af Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 6 Jul 2017 00:20:29 +0500 Subject: [PATCH 047/144] Update mp5.cpp. --- dlls/mp5.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/mp5.cpp b/dlls/mp5.cpp index a13257a1..403efa04 100644 --- a/dlls/mp5.cpp +++ b/dlls/mp5.cpp @@ -238,7 +238,7 @@ void CMP5::SecondaryAttack( void ) void CMP5::Reload( void ) { - if( m_pPlayer->ammo_9mm <= 0 ) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == MP5_MAX_CLIP ) return; DefaultReload( MP5_MAX_CLIP, MP5_RELOAD, 1.5 ); From b66f1cb39400e586d7a2ef8eca44c2f14c226e69 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 6 Jul 2017 00:25:22 +0500 Subject: [PATCH 048/144] Update glock.cpp. --- dlls/glock.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/glock.cpp b/dlls/glock.cpp index 4e679750..3eb08d6c 100644 --- a/dlls/glock.cpp +++ b/dlls/glock.cpp @@ -109,7 +109,7 @@ void CGlock::GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim ) if( m_fFireOnEmpty ) { PlayEmptySound(); - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.2; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.2 ); } return; @@ -158,7 +158,7 @@ void CGlock::GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim ) PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), fUseAutoAim ? m_usFireGlock1 : m_usFireGlock2, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, ( m_iClip == 0 ) ? 1 : 0, 0 ); - m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + flCycleTime; + m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay( flCycleTime ); if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) // HEV suit - indicate out of ammo condition From 6e1059026faa90c5bfe5e3b3f4f58fde398d4524 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 6 Jul 2017 00:41:13 +0500 Subject: [PATCH 049/144] Do not detonate hand grenade after weapon switch. --- dlls/handgrenade.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dlls/handgrenade.cpp b/dlls/handgrenade.cpp index 96119b6b..2a31fc84 100644 --- a/dlls/handgrenade.cpp +++ b/dlls/handgrenade.cpp @@ -103,6 +103,12 @@ void CHandGrenade::Holster( int skiplocal /* = 0 */ ) pev->nextthink = gpGlobals->time + 0.1; } + if( m_flStartThrow ) + { + m_flStartThrow = 0; + m_flReleaseThrow = 0; + } + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM ); } From b7d1bd3235790026cf0d3e66053ba155f2b0a07a Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 6 Jul 2017 00:44:14 +0500 Subject: [PATCH 050/144] Merge fix for blocked door sound from bubblemod. --- dlls/doors.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dlls/doors.cpp b/dlls/doors.cpp index dcb04e00..231a3753 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -750,6 +750,11 @@ void CBaseDoor::Blocked( CBaseEntity *pOther ) // so let it just squash the object to death real fast if( m_flWait >= 0 ) { + // BMod Start - Door sound fix. + if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) + STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ) ); + // BMod End + if( m_toggle_state == TS_GOING_DOWN ) { DoorGoUp(); From bdd3e74ebd3fbf7f7d4d20cdf2e85c8f981309a3 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 6 Jul 2017 02:30:10 +0500 Subject: [PATCH 051/144] Detonate satchels under blocked door. --- dlls/doors.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dlls/doors.cpp b/dlls/doors.cpp index 231a3753..3a8613ab 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -22,6 +22,7 @@ #include "util.h" #include "cbase.h" #include "doors.h" +#include "weapons.h" extern void SetMovedir( entvars_t *ev ); @@ -746,6 +747,10 @@ void CBaseDoor::Blocked( CBaseEntity *pOther ) if( pev->dmg ) pOther->TakeDamage( pev, pev, pev->dmg, DMG_CRUSH ); + // Detonate satchels + if( !strcmp( "monster_satchel", STRING( pOther->pev->classname ) ) ) + ( (CSatchel*)pOther )->Use( this, this, USE_ON, 0 ); + // if a door has a negative wait, it would never come back if blocked, // so let it just squash the object to death real fast if( m_flWait >= 0 ) From c6b353e09287048fb42cd4811b5854ded5ce93bc Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 6 Jul 2017 02:35:32 +0500 Subject: [PATCH 052/144] Fix build. --- dlls/gauss.cpp | 2 +- dlls/nihilanth.cpp | 2 +- dlls/subs.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dlls/gauss.cpp b/dlls/gauss.cpp index 0ebb876c..d3e005c2 100644 --- a/dlls/gauss.cpp +++ b/dlls/gauss.cpp @@ -126,7 +126,7 @@ int CGauss::GetItemInfo( ItemInfo *p ) BOOL CGauss::IsUseable() { // Currently charging, allow the player to fire it first. - Solokiller - return CBasePlayerWeapon::IsUseable() || m_InAttack != 0; + return CBasePlayerWeapon::IsUseable() || m_fInAttack != 0; } BOOL CGauss::Deploy() diff --git a/dlls/nihilanth.cpp b/dlls/nihilanth.cpp index 82b31e13..1f9b0f88 100644 --- a/dlls/nihilanth.cpp +++ b/dlls/nihilanth.cpp @@ -356,7 +356,7 @@ void CNihilanth::UpdateOnRemove() m_pBall = 0; } - for( int i = 0; i < N_SPHERES, i++ ) + for( int i = 0; i < N_SPHERES; i++ ) { if( CBaseEntity* pSphere = (CBaseEntity *)m_hSphere[i] ) { diff --git a/dlls/subs.cpp b/dlls/subs.cpp index 4654363a..2a299ce4 100644 --- a/dlls/subs.cpp +++ b/dlls/subs.cpp @@ -112,7 +112,7 @@ void CBaseEntity::UpdateOnRemove( void ) //Killtarget didn't do this before, so the counter broke. - Solokiller if( CBaseEntity* pOwner = pev->owner ? Instance( pev->owner ) : 0 ) { - pOwner->DeathNotice( this ); + pOwner->DeathNotice( pev ); } } From f575e78a9b7320db15025e94c1d1bb2cd1922a60 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 6 Jul 2017 03:47:59 +0500 Subject: [PATCH 053/144] Register allow_spectators cvar. --- dlls/game.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dlls/game.cpp b/dlls/game.cpp index 7905075a..9b69cac9 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -455,6 +455,7 @@ void GameDLLInit( void ) g_footsteps = CVAR_GET_POINTER( "mp_footsteps" ); CVAR_REGISTER( &displaysoundlist ); + CVAR_REGISTER( &allow_spectators ); CVAR_REGISTER( &teamplay ); CVAR_REGISTER( &fraglimit ); From 4d1dc131b924dedbb03bf40eb4bb64bd1c624f1a Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sat, 8 Jul 2017 20:06:00 +0500 Subject: [PATCH 054/144] Fix mistakes with saverestore after merge. --- dlls/util.cpp | 2 +- engine/eiface.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dlls/util.cpp b/dlls/util.cpp index d79c9f5a..f4b09cb1 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -1890,7 +1890,7 @@ void CSave::WriteFunction( const char *pname, void **data, int count ) { const char *functionName; - functionName = NAME_FOR_FUNCTION( (unsigned int)(size_t)*data ); + functionName = NAME_FOR_FUNCTION( (size_t)*data ); if( functionName ) BufferField( pname, strlen( functionName ) + 1, functionName ); else diff --git a/engine/eiface.h b/engine/eiface.h index 30f8a82a..23cb17f8 100644 --- a/engine/eiface.h +++ b/engine/eiface.h @@ -172,8 +172,8 @@ typedef struct enginefuncs_s int (*pfnRegUserMsg)( const char *pszName, int iSize ); void (*pfnAnimationAutomove)( const edict_t* pEdict, float flTime ); void (*pfnGetBonePosition)( const edict_t* pEdict, int iBone, float *rgflOrigin, float *rgflAngles ); - unsigned int (*pfnFunctionFromName)( const char *pName ); - const char *(*pfnNameForFunction)( unsigned int function ); + size_t (*pfnFunctionFromName)( const char *pName ); + const char *(*pfnNameForFunction)( size_t function ); void (*pfnClientPrintf)( edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg ); // JOHN: engine callbacks so game DLL can print messages to individual clients void (*pfnServerPrint)( const char *szMsg ); const char *(*pfnCmd_Args)( void ); // these 3 added From c16e1ecfef45f5a6b67ff470051c328cc7e760b6 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sat, 8 Jul 2017 20:13:41 +0500 Subject: [PATCH 055/144] A little fix for nodes on 64bit arches. --- dlls/nodes.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dlls/nodes.h b/dlls/nodes.h index 2b582a6f..f5ebcd84 100644 --- a/dlls/nodes.h +++ b/dlls/nodes.h @@ -104,7 +104,11 @@ typedef struct //========================================================= // CGraph //========================================================= +#if defined(__amd64__) || defined(__aarch64__) +#define GRAPH_VERSION (int)17// Was incremented for 64bit arches, because .nod-files have incombatibilities on different arches. +#else #define GRAPH_VERSION (int)16// !!!increment this whever graph/node/link classes change, to obsolesce older disk files. +#endif class CGraph { From 3bce17e3a04f8af10a927a07ceb8ab0f09152ec4 Mon Sep 17 00:00:00 2001 From: mittorn Date: Sat, 8 Jul 2017 20:26:21 +0000 Subject: [PATCH 056/144] Fix saverestore on LP64 --- dlls/saverestore.h | 2 +- dlls/util.cpp | 6 +++--- engine/eiface.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dlls/saverestore.h b/dlls/saverestore.h index f76613e8..a9ad2c54 100644 --- a/dlls/saverestore.h +++ b/dlls/saverestore.h @@ -59,7 +59,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 ); diff --git a/dlls/util.cpp b/dlls/util.cpp index d1fceb0a..1c229edd 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -1886,7 +1886,7 @@ void CSave::WritePositionVector( const char *pname, const float *value, int coun } } -void CSave::WriteFunction( const char *pname, const int *data, int count ) +void CSave::WriteFunction( const char *pname, void **data, int count ) { const char *functionName; @@ -1894,7 +1894,7 @@ void CSave::WriteFunction( const char *pname, const int *data, int count ) if( functionName ) BufferField( pname, strlen( functionName ) + 1, functionName ); else - ALERT( at_error, "Invalid function pointer in entity!" ); + ALERT( at_error, "Invalid function pointer in entity!\n" ); } void EntvarsKeyvalue( entvars_t *pev, KeyValueData *pkvd ) @@ -2042,7 +2042,7 @@ int CSave::WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFi WriteInt( pTest->fieldName, (int *)(char *)pOutputData, pTest->fieldSize ); break; case FIELD_FUNCTION: - WriteFunction( pTest->fieldName, (int *)pOutputData, pTest->fieldSize ); + WriteFunction( pTest->fieldName, (void **)pOutputData, pTest->fieldSize ); break; default: ALERT( at_error, "Bad field type\n" ); diff --git a/engine/eiface.h b/engine/eiface.h index 903451f5..b3b9d415 100644 --- a/engine/eiface.h +++ b/engine/eiface.h @@ -171,8 +171,8 @@ typedef struct enginefuncs_s int (*pfnRegUserMsg)( const char *pszName, int iSize ); void (*pfnAnimationAutomove)( const edict_t* pEdict, float flTime ); void (*pfnGetBonePosition)( const edict_t* pEdict, int iBone, float *rgflOrigin, float *rgflAngles ); - unsigned long (*pfnFunctionFromName)( const char *pName ); - const char *(*pfnNameForFunction)( unsigned long function ); + void* (*pfnFunctionFromName)( const char *pName ); + const char *(*pfnNameForFunction)( void *function ); void (*pfnClientPrintf)( edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg ); // JOHN: engine callbacks so game DLL can print messages to individual clients void (*pfnServerPrint)( const char *szMsg ); const char *(*pfnCmd_Args)( void ); // these 3 added From 9ebfc981773ec4c7a89ffe52d9c249e1fbef9634 Mon Sep 17 00:00:00 2001 From: mittorn Date: Sat, 8 Jul 2017 21:28:31 +0000 Subject: [PATCH 057/144] Fix field sizes --- dlls/util.cpp | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/dlls/util.cpp b/dlls/util.cpp index 1c229edd..0298487b 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -1584,6 +1584,33 @@ void UTIL_StripToken( const char *pKey, char *pDest ) // // -------------------------------------------------------------- static int gSizes[FIELD_TYPECOUNT] = +{ + sizeof(float), // FIELD_FLOAT + sizeof(int), // FIELD_STRING + sizeof(void*), // FIELD_ENTITY + sizeof(void*), // FIELD_CLASSPTR + sizeof(void*), // FIELD_EHANDLE + sizeof(void*), // FIELD_entvars_t + sizeof(void*), // FIELD_EDICT + sizeof(float) * 3, // FIELD_VECTOR + sizeof(float) * 3, // FIELD_POSITION_VECTOR + sizeof(void *), // FIELD_POINTER + sizeof(int), // FIELD_INTEGER +#ifdef GNUC + sizeof(void *) * 2, // FIELD_FUNCTION +#else + sizeof(void *), // FIELD_FUNCTION +#endif + sizeof(int), // FIELD_BOOLEAN + sizeof(short), // FIELD_SHORT + sizeof(char), // FIELD_CHARACTER + sizeof(float), // FIELD_TIME + sizeof(int), // FIELD_MODELNAME + sizeof(int), // FIELD_SOUNDNAME +}; + +// entities has different store size +static int gInputSizes[FIELD_TYPECOUNT] = { sizeof(float), // FIELD_FLOAT sizeof(int), // FIELD_STRING @@ -1594,12 +1621,12 @@ static int gSizes[FIELD_TYPECOUNT] = sizeof(int), // FIELD_EDICT sizeof(float) * 3, // FIELD_VECTOR sizeof(float) * 3, // FIELD_POSITION_VECTOR - sizeof(int *), // FIELD_POINTER + sizeof(void *), // FIELD_POINTER sizeof(int), // FIELD_INTEGER #ifdef GNUC - sizeof(int *) * 2, // FIELD_FUNCTION + sizeof(void *) * 2, // FIELD_FUNCTION #else - sizeof(int *), // FIELD_FUNCTION + sizeof(void *), // FIELD_FUNCTION #endif sizeof(int), // FIELD_BOOLEAN sizeof(short), // FIELD_SHORT @@ -2137,7 +2164,7 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou for( j = 0; j < pTest->fieldSize; j++ ) { void *pOutputData = ( (char *)pBaseData + pTest->fieldOffset + ( j * gSizes[pTest->fieldType] ) ); - void *pInputData = (char *)pData + j * gSizes[pTest->fieldType]; + void *pInputData = (char *)pData + j * gInputSizes[pTest->fieldType]; switch( pTest->fieldType ) { From 4d7d6f2c378f0b79fe9dd4eeb931cdb6daadd48f Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 10 Jul 2017 19:28:56 +0500 Subject: [PATCH 058/144] Turn off flashlight when player dead. --- dlls/player.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dlls/player.cpp b/dlls/player.cpp index b838f35f..5029ce97 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -820,6 +820,9 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) else pev->weapons &= ~WEAPON_ALLWEAPONS; + // Turn off flashlight + ClearBits( pev->effects, EF_DIMLIGHT ); + for( i = 0; i < MAX_AMMO_SLOTS; i++ ) m_rgAmmo[i] = 0; From 2324270cc27d818923391f6d34319fb4cd258795 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 10 Jul 2017 22:18:45 +0500 Subject: [PATCH 059/144] Do not reduce armor value when godmode is active. --- dlls/player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/player.cpp b/dlls/player.cpp index 5029ce97..852abca3 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -466,7 +466,7 @@ int CBasePlayer::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, fl m_lastDamageAmount = (int)flDamage; // Armor. - if( pev->armorvalue && !( bitsDamageType & ( DMG_FALL | DMG_DROWN ) ) )// armor doesn't protect against fall or drown damage! + if( !( pev->flags & FL_GODMODE ) && pev->armorvalue && !( bitsDamageType & ( DMG_FALL | DMG_DROWN ) ) )// armor doesn't protect against fall or drown damage! { float flNew = flDamage * flRatio; From 77d077c83dc3384ee6c6134a04657ea1259847f3 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 11 Jul 2017 01:32:53 +0500 Subject: [PATCH 060/144] Partially merge https://github.com/SamVanheer/HLEnhanced/commit/3563a1846fc8905bb7357c103212a6e10b5f048b --- dlls/plats.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/dlls/plats.cpp b/dlls/plats.cpp index 203f5d9b..a60e6706 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -248,7 +248,7 @@ public: virtual int ObjectCaps( void ) { return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DONT_SAVE; } void SpawnInsideTrigger( CFuncPlat *pPlatform ); void Touch( CBaseEntity *pOther ); - CFuncPlat *m_pPlatform; + EHANDLE m_pPlatform; }; /*QUAKED func_plat (0 .5 .8) ? PLAT_LOW_TRIGGER @@ -340,24 +340,24 @@ static void PlatSpawnInsideTrigger( entvars_t *pevPlatform ) // void CPlatTrigger::SpawnInsideTrigger( CFuncPlat *pPlatform ) { - m_pPlatform = pPlatform; + m_hPlatform = pPlatform; // Create trigger entity, "point" it at the owning platform, give it a touch method pev->solid = SOLID_TRIGGER; pev->movetype = MOVETYPE_NONE; pev->origin = pPlatform->pev->origin; // Establish the trigger field's size - Vector vecTMin = m_pPlatform->pev->mins + Vector( 25, 25, 0 ); - Vector vecTMax = m_pPlatform->pev->maxs + Vector( 25, 25, 8 ); - vecTMin.z = vecTMax.z - ( m_pPlatform->m_vecPosition1.z - m_pPlatform->m_vecPosition2.z + 8 ); - if( m_pPlatform->pev->size.x <= 50 ) + Vector vecTMin = pPlatform->pev->mins + Vector( 25, 25, 0 ); + Vector vecTMax = pPlatform->pev->maxs + Vector( 25, 25, 8 ); + vecTMin.z = vecTMax.z - ( pPlatform->m_vecPosition1.z - pPlatform->m_vecPosition2.z + 8 ); + if( pPlatform->pev->size.x <= 50 ) { - vecTMin.x = ( m_pPlatform->pev->mins.x + m_pPlatform->pev->maxs.x ) / 2; + vecTMin.x = ( pPlatform->pev->mins.x + pPlatform->pev->maxs.x ) / 2; vecTMax.x = vecTMin.x + 1; } - if( m_pPlatform->pev->size.y <= 50 ) + if( pPlatform->pev->size.y <= 50 ) { - vecTMin.y = ( m_pPlatform->pev->mins.y + m_pPlatform->pev->maxs.y ) / 2; + vecTMin.y = ( pPlatform->pev->mins.y + pPlatform->pev->maxs.y ) / 2; vecTMax.y = vecTMin.y + 1; } UTIL_SetSize( pev, vecTMin, vecTMax ); @@ -373,15 +373,17 @@ void CPlatTrigger::Touch( CBaseEntity *pOther ) if( !FClassnameIs( pevToucher, "player" ) ) return; + CFuncPlat *pPlatform = (CFuncPlat*)(CBaseEntity*)m_hPlatform; + // Ignore touches by corpses if( !pOther->IsAlive() ) return; // Make linked platform go up/down. - if( m_pPlatform->m_toggle_state == TS_AT_BOTTOM ) - m_pPlatform->GoUp(); - else if( m_pPlatform->m_toggle_state == TS_AT_TOP ) - m_pPlatform->pev->nextthink = m_pPlatform->pev->ltime + 1;// delay going down + if( pPlatform->m_toggle_state == TS_AT_BOTTOM ) + pPlatform->GoUp(); + else if( pPlatform->m_toggle_state == TS_AT_TOP ) + pPlatform->pev->nextthink = pPlatform->pev->ltime + 1;// delay going down } // From 2df762e705d4726d5017b670138660bc8079053a Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 11 Jul 2017 01:40:26 +0500 Subject: [PATCH 061/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/f8db63a45bcc62d6110051109daca77031699df8 --- dlls/plats.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/dlls/plats.cpp b/dlls/plats.cpp index a60e6706..5d5d1f07 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -375,6 +375,13 @@ void CPlatTrigger::Touch( CBaseEntity *pOther ) CFuncPlat *pPlatform = (CFuncPlat*)(CBaseEntity*)m_hPlatform; + if( FNullEnt( pPlatform ) ) + { + // The target platform has been removed, remove myself as well. - Solokiller + UTIL_Remove( this ); + return; + } + // Ignore touches by corpses if( !pOther->IsAlive() ) return; @@ -429,7 +436,7 @@ void CFuncPlat::GoDown( void ) } // -// Platform has hit bottom. Stops and waits forever. +// Platform has hit bottom. Stops and waits forever. // void CFuncPlat::HitBottom( void ) { @@ -458,7 +465,7 @@ void CFuncPlat::GoUp( void ) } // -// Platform has hit top. Pauses, then starts back down again. +// Platform has hit top. Pauses, then starts back down again. // void CFuncPlat::HitTop( void ) { @@ -556,7 +563,7 @@ void CFuncPlatRot::GoDown( void ) } // -// Platform has hit bottom. Stops and waits forever. +// Platform has hit bottom. Stops and waits forever. // void CFuncPlatRot::HitBottom( void ) { @@ -575,7 +582,7 @@ void CFuncPlatRot::GoUp( void ) } // -// Platform has hit top. Pauses, then starts back down again. +// Platform has hit top. Pauses, then starts back down again. // void CFuncPlatRot::HitTop( void ) { @@ -857,8 +864,8 @@ void CFuncTrain::Precache( void ) case 1: PRECACHE_SOUND( "plats/train2.wav" ); PRECACHE_SOUND( "plats/train1.wav" ); - pev->noise = MAKE_STRING("plats/train2.wav" ); - pev->noise1 = MAKE_STRING("plats/train1.wav" ); + pev->noise = MAKE_STRING( "plats/train2.wav" ); + pev->noise1 = MAKE_STRING( "plats/train1.wav" ); break; case 2: PRECACHE_SOUND( "plats/platmove1.wav" ); From 8455d693609863c48108aeaff11d9b8e3f59fb49 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 11 Jul 2017 01:58:22 +0500 Subject: [PATCH 062/144] Merge https://github.com/SamVanheer/HLEnhanced/commit/d6732ca0795e1be23bea808782eb4dfd13cbd1aa --- dlls/player.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dlls/player.cpp b/dlls/player.cpp index 852abca3..9680aaf6 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -3661,7 +3661,9 @@ int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) pev->viewmodel = 0; pev->weaponmodel = 0; } - else if( m_pLastItem == pItem ) + + // In some cases an item can be both the active and last item, like for instance dropping all weapons and only having an exhaustible weapon left. - Solokiller + if( m_pLastItem == pItem ) m_pLastItem = NULL; CBasePlayerItem *pPrev = m_rgpPlayerItems[pItem->iItemSlot()]; From 1c1d9ae18385f1a152c93f115289defbd64394ab Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 11 Jul 2017 02:24:19 +0500 Subject: [PATCH 063/144] Remove unneeded strcpy usage. --- cl_dll/com_weapons.cpp | 2 +- cl_dll/com_weapons.h | 2 +- cl_dll/ev_hldm.cpp | 19 +++++++++---------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/cl_dll/com_weapons.cpp b/cl_dll/com_weapons.cpp index 774df091..5621149b 100644 --- a/cl_dll/com_weapons.cpp +++ b/cl_dll/com_weapons.cpp @@ -283,7 +283,7 @@ unsigned short stub_PrecacheEvent( int type, const char *s ) return 0; } -const char *stub_NameForFunction( unsigned int function ) +const char *stub_NameForFunction( void *function ) { return "func"; } diff --git a/cl_dll/com_weapons.h b/cl_dll/com_weapons.h index 8559e20b..0a538f0f 100644 --- a/cl_dll/com_weapons.h +++ b/cl_dll/com_weapons.h @@ -34,7 +34,7 @@ void HUD_SetMaxSpeed( const struct edict_s *ed, float speed ); int stub_PrecacheModel( const char* s ); int stub_PrecacheSound( const char* s ); unsigned short stub_PrecacheEvent( int type, const char *s ); -const char *stub_NameForFunction( unsigned int function ); +const char *stub_NameForFunction( void *function ); void stub_SetModel( struct edict_s *e, const char *m ); extern cvar_t *cl_lw; diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 7bb3a797..d94f9fea 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -1695,7 +1695,7 @@ void EV_TrainPitchAdjust( event_args_t *args ) int pitch; int stop; - char sz[256]; + const char *pszSound; idx = args->entindex; @@ -1711,36 +1711,35 @@ void EV_TrainPitchAdjust( event_args_t *args ) switch( noise ) { case 1: - strcpy( sz, "plats/ttrain1.wav" ); + pszSound = "plats/ttrain1.wav"; break; case 2: - strcpy( sz, "plats/ttrain2.wav" ); + pszSound = "plats/ttrain2.wav"; break; case 3: - strcpy( sz, "plats/ttrain3.wav" ); + pszSound = "plats/ttrain3.wav"; break; case 4: - strcpy( sz, "plats/ttrain4.wav"); + pszSound = "plats/ttrain4.wav"; break; case 5: - strcpy( sz, "plats/ttrain6.wav"); + pszSound = "plats/ttrain6.wav"; break; case 6: - strcpy( sz, "plats/ttrain7.wav"); + pszSound = "plats/ttrain7.wav"; break; default: // no sound - strcpy( sz, "" ); return; } if( stop ) { - gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, sz ); + gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, pszSound ); } else { - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_STATIC, sz, m_flVolume, ATTN_NORM, SND_CHANGE_PITCH, pitch ); + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_STATIC, pszSound, m_flVolume, ATTN_NORM, SND_CHANGE_PITCH, pitch ); } } From a383a57a09351365b5b3beb78d26ec0c035df4ef Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 11 Jul 2017 02:43:24 +0500 Subject: [PATCH 064/144] Fix build. --- dlls/plats.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/plats.cpp b/dlls/plats.cpp index 5d5d1f07..00b05bec 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -248,7 +248,7 @@ public: virtual int ObjectCaps( void ) { return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DONT_SAVE; } void SpawnInsideTrigger( CFuncPlat *pPlatform ); void Touch( CBaseEntity *pOther ); - EHANDLE m_pPlatform; + EHANDLE m_hPlatform; }; /*QUAKED func_plat (0 .5 .8) ? PLAT_LOW_TRIGGER @@ -375,7 +375,7 @@ void CPlatTrigger::Touch( CBaseEntity *pOther ) CFuncPlat *pPlatform = (CFuncPlat*)(CBaseEntity*)m_hPlatform; - if( FNullEnt( pPlatform ) ) + if( !pPlatform ) { // The target platform has been removed, remove myself as well. - Solokiller UTIL_Remove( this ); From 4661b5c1a5245b27a5532745c11e44b5540e4172 Mon Sep 17 00:00:00 2001 From: mittorn Date: Fri, 14 Jul 2017 13:11:58 +0000 Subject: [PATCH 065/144] Increase graph version --- dlls/nodes.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dlls/nodes.h b/dlls/nodes.h index 27b890ed..cbf1e2a6 100644 --- a/dlls/nodes.h +++ b/dlls/nodes.h @@ -103,7 +103,11 @@ typedef struct //========================================================= // CGraph //========================================================= +#ifdef __amd64 +#define GRAPH_VERSION (int)16 * 10 +#else #define GRAPH_VERSION (int)16// !!!increment this whever graph/node/link classes change, to obsolesce older disk files. +#endif class CGraph { From a08bd614fe524d8c827ac34810a130b6f2dc90ba Mon Sep 17 00:00:00 2001 From: mittorn Date: Fri, 14 Jul 2017 13:15:17 +0000 Subject: [PATCH 066/144] Fix client build --- cl_dll/com_weapons.cpp | 2 +- cl_dll/com_weapons.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cl_dll/com_weapons.cpp b/cl_dll/com_weapons.cpp index 4f539df9..d359a3f1 100644 --- a/cl_dll/com_weapons.cpp +++ b/cl_dll/com_weapons.cpp @@ -283,7 +283,7 @@ unsigned short stub_PrecacheEvent( int type, const char *s ) return 0; } -const char *stub_NameForFunction( unsigned long function ) +const char *stub_NameForFunction( void *function ) { return "func"; } diff --git a/cl_dll/com_weapons.h b/cl_dll/com_weapons.h index 7e1fdd77..4ce861f4 100644 --- a/cl_dll/com_weapons.h +++ b/cl_dll/com_weapons.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // @@ -34,7 +34,7 @@ void HUD_SetMaxSpeed( const struct edict_s *ed, float speed ); int stub_PrecacheModel( char* s ); int stub_PrecacheSound( char* s ); unsigned short stub_PrecacheEvent( int type, const char *s ); -const char *stub_NameForFunction( unsigned long function ); +const char *stub_NameForFunction( void *function ); void stub_SetModel( struct edict_s *e, const char *m ); extern cvar_t *cl_lw; From 00833188dab87ef5746286479ba5aeb9d83b4a0c Mon Sep 17 00:00:00 2001 From: mittorn Date: Fri, 14 Jul 2017 13:42:47 +0000 Subject: [PATCH 067/144] Use real MAKE_STRING when possible --- dlls/util.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dlls/util.h b/dlls/util.h index e8aee878..5b00fe94 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -39,7 +39,14 @@ extern globalvars_t *gpGlobals; #if !defined __amd64__ || defined(CLIENT_DLL) #define MAKE_STRING(str) ((int)(size_t)str - (int)(size_t)STRING(0)) #else -#define MAKE_STRING ALLOC_STRING +static inline int MAKE_STRING(const char *szValue) +{ + long long ptrdiff = szValue - STRING(0); + if( ptrdiff > INT_MAX || ptrdiff < INT_MIN ) + return ALLOC_STRING(szValue); + else + return (int)ptrdiff; +} #endif inline edict_t *FIND_ENTITY_BY_CLASSNAME(edict_t *entStart, const char *pszName) From 1674a4b6d496b03da7efd689b739d721b83a9c8a Mon Sep 17 00:00:00 2001 From: mittorn Date: Fri, 14 Jul 2017 15:34:44 +0000 Subject: [PATCH 068/144] Use XASH_64BIT macro --- cl_dll/cl_dll.h | 4 ++++ dlls/extdll.h | 4 ++++ dlls/nodes.h | 2 +- dlls/util.h | 2 +- engine/studio.h | 2 +- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cl_dll/cl_dll.h b/cl_dll/cl_dll.h index fda4b812..24d1874b 100644 --- a/cl_dll/cl_dll.h +++ b/cl_dll/cl_dll.h @@ -41,6 +41,10 @@ typedef int ( *pfnUserMsgHook )( const char *pszName, int iSize, void *pbuf ); #include "exportdef.h" #include +#if defined(__LP64__) || defined(__LLP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) + #define XASH_64BIT +#endif + extern cl_enginefunc_t gEngfuncs; #include "../engine/mobility_int.h" extern mobile_engfuncs_t *gMobileEngfuncs; diff --git a/dlls/extdll.h b/dlls/extdll.h index cbc7ebb9..dda1cec5 100644 --- a/dlls/extdll.h +++ b/dlls/extdll.h @@ -57,6 +57,10 @@ typedef int BOOL; #include "stdlib.h" #include "math.h" +#if defined(__LP64__) || defined(__LLP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) + #define XASH_64BIT +#endif + // Header file containing definition of globalvars_t and entvars_t typedef unsigned int func_t; typedef unsigned int string_t; // from engine's pr_comp.h; diff --git a/dlls/nodes.h b/dlls/nodes.h index cbf1e2a6..c959dd2e 100644 --- a/dlls/nodes.h +++ b/dlls/nodes.h @@ -103,7 +103,7 @@ typedef struct //========================================================= // CGraph //========================================================= -#ifdef __amd64 +#ifdef XASH_64BIT #define GRAPH_VERSION (int)16 * 10 #else #define GRAPH_VERSION (int)16// !!!increment this whever graph/node/link classes change, to obsolesce older disk files. diff --git a/dlls/util.h b/dlls/util.h index 5b00fe94..a61240fd 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -36,7 +36,7 @@ extern globalvars_t *gpGlobals; // Use this instead of ALLOC_STRING on constant strings #define STRING(offset) (const char *)(gpGlobals->pStringBase + (int)offset) -#if !defined __amd64__ || defined(CLIENT_DLL) +#if !defined XASH_64BIT || defined(CLIENT_DLL) #define MAKE_STRING(str) ((int)(size_t)str - (int)(size_t)STRING(0)) #else static inline int MAKE_STRING(const char *szValue) diff --git a/engine/studio.h b/engine/studio.h index b5b709bb..5e5ec26c 100644 --- a/engine/studio.h +++ b/engine/studio.h @@ -215,7 +215,7 @@ typedef struct char label[32]; // textual name char name[64]; // file name cache_user_t cache; // cache index pointer -#ifndef __amd64 +#ifndef XASH_64BIT int data; // hack for group 0 #endif } mstudioseqgroup_t; From cbdf9b5d042bf695f85918ca8bee074ecec0d368 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 09:48:08 +0500 Subject: [PATCH 069/144] Fix knowledge bugs with satchels again. --- dlls/client.cpp | 6 ------ dlls/multiplay_gamerules.cpp | 6 ------ dlls/player.cpp | 1 + 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/dlls/client.cpp b/dlls/client.cpp index 1fead362..480a9506 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -127,12 +127,6 @@ void ClientDisconnect( edict_t *pEntity ) pEntity->v.solid = SOLID_NOT;// nonsolid UTIL_SetOrigin( &pEntity->v, pEntity->v.origin ); - CBasePlayer *pl = (CBasePlayer *)CBaseEntity::Instance( pEntity ); - if( pl->HasNamedPlayerItem( "weapon_satchel" ) ) - { - DeactivateSatchels( pl ); - } - g_pGameRules->ClientDisconnected( pEntity ); } diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index 9da8d0b4..494ac4f6 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -675,12 +675,6 @@ void CHalfLifeMultiplay::PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, // let the killer paint another decal as soon as he'd like. PK->m_flNextDecalTime = gpGlobals->time; } -#ifndef HLDEMO_BUILD - if( pVictim->HasNamedPlayerItem( "weapon_satchel" ) ) - { - DeactivateSatchels( pVictim ); - } -#endif } //========================================================= diff --git a/dlls/player.cpp b/dlls/player.cpp index 9680aaf6..1d198e84 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -826,6 +826,7 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) for( i = 0; i < MAX_AMMO_SLOTS; i++ ) m_rgAmmo[i] = 0; + DeactivateSatchels( this ); UpdateClientData(); // send Selected Weapon Message to our client From 004054586b0cc48863638a9505c3e139c3423148 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 10:01:32 +0500 Subject: [PATCH 070/144] Merge https://github.com/LevShisterov/BugfixedHL/commit/52209adc339fa21ee1c9564e5d82ad97d9a09374 --- dlls/func_tank.cpp | 4 +++- dlls/player.cpp | 11 ----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp index ab295e0c..cace610d 100644 --- a/dlls/func_tank.cpp +++ b/dlls/func_tank.cpp @@ -351,6 +351,7 @@ BOOL CFuncTank::StartControl( CBasePlayer *pController ) ALERT( at_console, "using TANK!\n"); m_pController = pController; + m_pController->m_pTank = this; if( m_pController->m_pActiveItem ) { m_pController->m_pActiveItem->Holster(); @@ -380,6 +381,8 @@ void CFuncTank::StopControl() m_pController->m_iHideHUD &= ~HIDEHUD_WEAPONS; pev->nextthink = 0; + + m_pController->m_pTank = NULL; m_pController = NULL; if( IsActive() ) @@ -426,7 +429,6 @@ void CFuncTank::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use } else if( !m_pController && useType != USE_OFF ) { - ( (CBasePlayer*)pActivator )->m_pTank = this; StartControl( (CBasePlayer*)pActivator ); } else diff --git a/dlls/player.cpp b/dlls/player.cpp index 1d198e84..10216734 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -792,10 +792,7 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) m_pLastItem = NULL; if( m_pTank != 0 ) - { m_pTank->Use( this, this, USE_OFF, 0 ); - m_pTank = NULL; - } int i; CBasePlayerItem *pPendingItem; @@ -856,10 +853,7 @@ void CBasePlayer::Killed( entvars_t *pevAttacker, int iGib ) g_pGameRules->PlayerKilled( this, pevAttacker, g_pevLastInflictor ); if( m_pTank != 0 ) - { m_pTank->Use( this, this, USE_OFF, 0 ); - m_pTank = NULL; - } // this client isn't going to be thinking for a while, so reset the sound until they respawn pSound = CSoundEnt::SoundPointerForIndex( CSoundEnt::ClientSoundIndex( edict() ) ); @@ -1402,10 +1396,7 @@ void CBasePlayer::StartObserver( Vector vecPosition, Vector vecViewAngle ) m_pActiveItem->Holster(); if( m_pTank != 0 ) - { m_pTank->Use( this, this, USE_OFF, 0 ); - m_pTank = NULL; - } // clear out the suit message cache so we don't keep chattering SetSuitUpdate( NULL, FALSE, 0 ); @@ -1481,7 +1472,6 @@ void CBasePlayer::PlayerUse( void ) // Stop controlling the tank // TODO: Send HUD Update m_pTank->Use( this, this, USE_OFF, 0 ); - m_pTank = NULL; return; } else @@ -2520,7 +2510,6 @@ void CBasePlayer::PostThink() { // they've moved off the platform m_pTank->Use( this, this, USE_OFF, 0 ); - m_pTank = NULL; } } From 2b2fdac7d056587cc8105f47ea67cec457c913fa Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 10:04:33 +0500 Subject: [PATCH 071/144] Merge https://github.com/LevShisterov/BugfixedHL/commit/336bc05c82c171f895656f913e9fbedfd8c8df54 --- dlls/rpg.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dlls/rpg.cpp b/dlls/rpg.cpp index 5fb8cc70..c87d345f 100644 --- a/dlls/rpg.cpp +++ b/dlls/rpg.cpp @@ -265,6 +265,11 @@ void CRpgRocket::FollowThink( void ) pev->velocity = pev->velocity * 0.2 + vecTarget * flSpeed * 0.798; if( pev->waterlevel == 0 && pev->velocity.Length() < 1500 ) { + if( m_pLauncher ) + { + // my launcher is still around, tell it I'm dead. + m_pLauncher->m_cActiveRockets--; + } Detonate(); } } From 6f8cd70328a9ec1ef1dc74ec07aed72e098f8fc9 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 10:11:39 +0500 Subject: [PATCH 072/144] Merge https://github.com/LevShisterov/BugfixedHL/commit/7a627bf8e3e13929afd7b23ae8435ea8784b4654 --- dlls/satchel.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/dlls/satchel.cpp b/dlls/satchel.cpp index 458ac532..8ddc41a3 100644 --- a/dlls/satchel.cpp +++ b/dlls/satchel.cpp @@ -42,6 +42,9 @@ enum satchel_radio_e class CSatchelCharge : public CGrenade { + Vector m_lastBounceOrigin; // Used to fix a bug in engine: when object isn't moving, but its speed isn't 0 and on ground isn't set + void Spawn( void ); + void Precache( void ); void Spawn( void ); void Precache( void ); void BounceSound( void ); @@ -114,14 +117,19 @@ void CSatchelCharge::SatchelSlide( CBaseEntity *pOther ) } if( !( pev->flags & FL_ONGROUND ) && pev->velocity.Length2D() > 10 ) { + // Fix for a bug in engine: when object isn't moving, but its speed isn't 0 and on ground isn't set + if( pev->origin != m_lastBounceOrigin ) BounceSound(); } - StudioFrameAdvance(); + m_lastBounceOrigin = pev->origin; + // There is no model animation so commented this out to prevent net traffic + // StudioFrameAdvance(); } void CSatchelCharge::SatchelThink( void ) { - StudioFrameAdvance(); + // There is no model animation so commented this out to prevent net traffic + // StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; if( !IsInWorld() ) @@ -149,7 +157,7 @@ void CSatchelCharge::SatchelThink( void ) void CSatchelCharge::Precache( void ) { - PRECACHE_MODEL( "models/grenade.mdl" ); + PRECACHE_MODEL( "models/w_satchel.mdl" ); PRECACHE_SOUND( "weapons/g_bounce1.wav" ); PRECACHE_SOUND( "weapons/g_bounce2.wav" ); PRECACHE_SOUND( "weapons/g_bounce3.wav" ); From 73a99df89420b7bf2939bdd0ddf53ad755ce8a3e Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 10:15:17 +0500 Subject: [PATCH 073/144] Merge https://github.com/LevShisterov/BugfixedHL/commit/c66ee97ade72db0f63d1357d7a0760702a1c92e8 --- dlls/cbase.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/dlls/cbase.cpp b/dlls/cbase.cpp index cdf9a00f..6009bfd5 100644 --- a/dlls/cbase.cpp +++ b/dlls/cbase.cpp @@ -441,9 +441,16 @@ edict_t *EHANDLE::Get( void ) edict_t *EHANDLE::Set( edict_t *pent ) { - m_pent = pent; - if( pent ) - m_serialnumber = m_pent->serialnumber; + if( pent ) + { + m_pent = pent; + m_serialnumber = m_pent->serialnumber; + } + else + { + m_pent = NULL; + m_serialnumber = 0; + } return pent; } From 38b223651533fd0ab984147f906e2fe174683eb9 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 12:01:53 +0500 Subject: [PATCH 074/144] Merge https://github.com/LevShisterov/BugfixedHL/commit/ee1ec9d64f96ecce0ab144cd86b246f5e7b00555 --- dlls/player.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/dlls/player.cpp b/dlls/player.cpp index 10216734..e94f5588 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -2583,11 +2583,10 @@ void CBasePlayer::PostThink() CheckPowerups( pev ); UpdatePlayerSound(); - +pt_end: // Track button info so we can detect 'pressed' and 'released' buttons next frame m_afButtonLast = pev->button; -pt_end: #if defined( CLIENT_WEAPONS ) // Decay timers on weapons // go through all of the weapons and make a list of the ones to pack @@ -4061,6 +4060,52 @@ void CBasePlayer::UpdateClientData( void ) m_rgpPlayerItems[i]->UpdateClientData( this ); } + if( m_pClientActiveItem != pPlayer->m_pActiveItem ) + { + if( pPlayer->m_pActiveItem == NULL ) + { + // If no weapon, we have to send update here + CBasePlayer *plr; + for( int i = 1; i <= gpGlobals->maxClients; i++ ) + { + plr = (CBasePlayer *)UTIL_PlayerByIndex( i ); + if( !plr || !plr->IsObserver() || plr->m_hObserverTarget != pPlayer ) + continue; + + MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, plr->pev ); + WRITE_BYTE( 0 ); + WRITE_BYTE( 0 ); + WRITE_BYTE( 0 ); + MESSAGE_END(); + } + + MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pPlayer->pev ); + WRITE_BYTE( 0 ); + WRITE_BYTE( 0 ); + WRITE_BYTE( 0 ); + MESSAGE_END(); + } + else if( this != pPlayer ) + { + // Special case for spectator + CBasePlayerWeapon *gun = (CBasePlayerWeapon *)pPlayer->m_pActiveItem->GetWeaponPtr(); + if( gun ) + { + int state; + if( pPlayer->m_fOnTarget ) + state = WEAPON_IS_ONTARGET; + else + state = 1; + + MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pev ); + WRITE_BYTE( state ); + WRITE_BYTE( gun->m_iId ); + WRITE_BYTE( gun->m_iClip ); + MESSAGE_END(); + } + } + } + // Cache and client weapon change m_pClientActiveItem = m_pActiveItem; m_iClientFOV = m_iFOV; From f318cab1c23d0060c36786763bc6d8c955745616 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 12:06:26 +0500 Subject: [PATCH 075/144] Merge https://github.com/LevShisterov/BugfixedHL/commit/d8daa2f16c30f31f2839fae03580dd213e4501c4 --- dlls/shotgun.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dlls/shotgun.cpp b/dlls/shotgun.cpp index 12e73ede..a08770b3 100644 --- a/dlls/shotgun.cpp +++ b/dlls/shotgun.cpp @@ -144,6 +144,9 @@ void CShotgun::PrimaryAttack() #endif m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH; + // player "shoot" animation + m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); + Vector vecSrc = m_pPlayer->GetGunPosition(); Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES ); From 0570769d35c39a8c4d6a249ac7b46bd5fb0a5b8f Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 12:17:26 +0500 Subject: [PATCH 076/144] Merge https://github.com/LevShisterov/BugfixedHL/commit/fd29683101f725c5aa41d6fb62d5217db45e8582 --- dlls/func_tank.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp index cace610d..4ee4e6d6 100644 --- a/dlls/func_tank.cpp +++ b/dlls/func_tank.cpp @@ -369,6 +369,9 @@ BOOL CFuncTank::StartControl( CBasePlayer *pController ) void CFuncTank::StopControl() { + if( m_pLaser ) + m_pLaser->TurnOff(); + // TODO: bring back the controllers current weapon if( !m_pController ) return; From 075fd2903075aaa28b0d4930d7d1ba0d1b73f492 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 12:56:33 +0500 Subject: [PATCH 077/144] Merge https://github.com/LevShisterov/BugfixedHL/commit/29c4d46ad02492a33ddd9bb4ace0c873855eebe7 --- dlls/items.cpp | 1 + dlls/weapons.cpp | 12 +++--------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/dlls/items.cpp b/dlls/items.cpp index d9cc7871..b0b2aa38 100644 --- a/dlls/items.cpp +++ b/dlls/items.cpp @@ -166,6 +166,7 @@ void CItem::Materialize( void ) } SetTouch( &CItem::ItemTouch ); + SetThink( NULL ); } #define SF_SUIT_SHORTLOGON 0x0001 diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 61b038c0..22b4a456 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -485,7 +485,7 @@ void CBasePlayerItem::Materialize( void ) pev->solid = SOLID_TRIGGER; UTIL_SetOrigin( pev, pev->origin );// link into world. - SetTouch( &CBasePlayerItem::DefaultTouch); + SetTouch( &CBasePlayerItem::DefaultTouch ); SetThink( NULL ); } @@ -578,13 +578,6 @@ void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther ) } SUB_UseTargets( pOther, USE_TOGGLE, 0 ); // UNDONE: when should this happen? - - // If the item is falling and its Think remains FallItem after the player picks it up, - // then after the item touches the ground its Touch will be set back to DefaultTouch, - // so the player will pick it up again, this time Kill-ing the item (since we already have it in the inventory), - // which will make the pointer bad and crash the game. - if( m_pfnThink == &CBasePlayerItem::FallThink ) - SetThink( NULL ); } BOOL CanAttack( float attack_time, float curtime, BOOL isPredicted ) @@ -734,7 +727,7 @@ void CBasePlayerItem::AttachToPlayer( CBasePlayer *pPlayer ) pev->modelindex = 0;// server won't send down to clients if modelindex == 0 pev->model = iStringNull; pev->owner = pPlayer->edict(); - pev->nextthink = gpGlobals->time + .1; + pev->nextthink = 0;// Remove think - prevents futher attempts to materialize SetTouch( NULL ); SetThink( NULL ); } @@ -1054,6 +1047,7 @@ void CBasePlayerAmmo::Materialize( void ) } SetTouch( &CBasePlayerAmmo::DefaultTouch ); + SetThink( NULL ); } void CBasePlayerAmmo::DefaultTouch( CBaseEntity *pOther ) From 5a2dccb978a7484db890c91f1ebd6fcfb9780194 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 12:58:28 +0500 Subject: [PATCH 078/144] Merge https://github.com/LevShisterov/BugfixedHL/commit/09a90f4a0095d6702f43c66ff27e9f4444866f3c --- dlls/player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/player.cpp b/dlls/player.cpp index e94f5588..e9ad5645 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -799,13 +799,13 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) for( i = 0; i < MAX_ITEM_TYPES; i++ ) { m_pActiveItem = m_rgpPlayerItems[i]; + m_rgpPlayerItems[i] = NULL; while( m_pActiveItem ) { pPendingItem = m_pActiveItem->m_pNext; m_pActiveItem->Drop(); m_pActiveItem = pPendingItem; } - m_rgpPlayerItems[i] = NULL; } m_pActiveItem = NULL; From 7e5145aaff6dbb0d734acb66a97c9e7247e21402 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 13:03:38 +0500 Subject: [PATCH 079/144] Merge https://github.com/LevShisterov/BugfixedHL/commit/b15a0f9d564d6f8e793617ebc88b41cd6940d90c --- dlls/crowbar.cpp | 12 ++++++++++++ dlls/glock.cpp | 12 ++++++++++++ dlls/weapons.h | 6 ++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index 98808e14..f9a91978 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -80,6 +80,18 @@ int CCrowbar::GetItemInfo( ItemInfo *p ) return 1; } +int CCrowbar::AddToPlayer( CBasePlayer *pPlayer ) +{ + if( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) + { + MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev ); + WRITE_BYTE( m_iId ); + MESSAGE_END(); + return TRUE; + } + return FALSE; +} + BOOL CCrowbar::Deploy() { return DefaultDeploy( "models/v_crowbar.mdl", "models/p_crowbar.mdl", CROWBAR_DRAW, "crowbar" ); diff --git a/dlls/glock.cpp b/dlls/glock.cpp index 3eb08d6c..1150d8b9 100644 --- a/dlls/glock.cpp +++ b/dlls/glock.cpp @@ -86,6 +86,18 @@ int CGlock::GetItemInfo( ItemInfo *p ) return 1; } +int CGlock::AddToPlayer( CBasePlayer *pPlayer ) +{ + if( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) + { + MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev ); + WRITE_BYTE( m_iId ); + MESSAGE_END(); + return TRUE; + } + return FALSE; +} + BOOL CGlock::Deploy() { // pev->body = 1; diff --git a/dlls/weapons.h b/dlls/weapons.h index 3d8dd6ad..f48767c8 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -463,7 +463,8 @@ public: void Spawn( void ); void Precache( void ); int iItemSlot( void ) { return 2; } - int GetItemInfo(ItemInfo *p); + int GetItemInfo( ItemInfo *p ); + int AddToPlayer( CBasePlayer *pPlayer ); void PrimaryAttack( void ); void SecondaryAttack( void ); @@ -496,7 +497,8 @@ public: int iItemSlot( void ) { return 1; } void EXPORT SwingAgain( void ); void EXPORT Smack( void ); - int GetItemInfo(ItemInfo *p); + int GetItemInfo( ItemInfo *p ); + int AddToPlayer( CBasePlayer *pPlayer ); void PrimaryAttack( void ); int Swing( int fFirst ); From 0af3a37151614429c13035c5dce0de3cf54f63c4 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 13:45:39 +0500 Subject: [PATCH 080/144] Fix build. Remove unneeded changes. --- dlls/func_tank.cpp | 4 ++-- dlls/player.cpp | 4 ++-- dlls/rpg.cpp | 5 ----- dlls/satchel.cpp | 2 -- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp index 4ee4e6d6..54f4755a 100644 --- a/dlls/func_tank.cpp +++ b/dlls/func_tank.cpp @@ -369,8 +369,8 @@ BOOL CFuncTank::StartControl( CBasePlayer *pController ) void CFuncTank::StopControl() { - if( m_pLaser ) - m_pLaser->TurnOff(); + //if( m_pLaser ) + //m_pLaser->TurnOff(); // TODO: bring back the controllers current weapon if( !m_pController ) diff --git a/dlls/player.cpp b/dlls/player.cpp index e9ad5645..d8ed7010 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -4060,7 +4060,7 @@ void CBasePlayer::UpdateClientData( void ) m_rgpPlayerItems[i]->UpdateClientData( this ); } - if( m_pClientActiveItem != pPlayer->m_pActiveItem ) + /*if( m_pClientActiveItem != pPlayer->m_pActiveItem ) { if( pPlayer->m_pActiveItem == NULL ) { @@ -4104,7 +4104,7 @@ void CBasePlayer::UpdateClientData( void ) MESSAGE_END(); } } - } + }*/ // Cache and client weapon change m_pClientActiveItem = m_pActiveItem; diff --git a/dlls/rpg.cpp b/dlls/rpg.cpp index c87d345f..5fb8cc70 100644 --- a/dlls/rpg.cpp +++ b/dlls/rpg.cpp @@ -265,11 +265,6 @@ void CRpgRocket::FollowThink( void ) pev->velocity = pev->velocity * 0.2 + vecTarget * flSpeed * 0.798; if( pev->waterlevel == 0 && pev->velocity.Length() < 1500 ) { - if( m_pLauncher ) - { - // my launcher is still around, tell it I'm dead. - m_pLauncher->m_cActiveRockets--; - } Detonate(); } } diff --git a/dlls/satchel.cpp b/dlls/satchel.cpp index 8ddc41a3..015b3483 100644 --- a/dlls/satchel.cpp +++ b/dlls/satchel.cpp @@ -43,8 +43,6 @@ enum satchel_radio_e class CSatchelCharge : public CGrenade { Vector m_lastBounceOrigin; // Used to fix a bug in engine: when object isn't moving, but its speed isn't 0 and on ground isn't set - void Spawn( void ); - void Precache( void ); void Spawn( void ); void Precache( void ); void BounceSound( void ); From 8bae5a5450e7f0c1040fb7c2329a92723a9fc584 Mon Sep 17 00:00:00 2001 From: mittorn Date: Tue, 18 Jul 2017 12:59:46 +0000 Subject: [PATCH 081/144] Fix infinite loop on mingw --- cl_dll/Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cl_dll/Android.mk b/cl_dll/Android.mk index 94489844..ecbae657 100755 --- a/cl_dll/Android.mk +++ b/cl_dll/Android.mk @@ -91,7 +91,7 @@ SRCS+=./input_xash3d.cpp SRCS+=./scoreboard.cpp SRCS+=./MOTD.cpp INCLUDES = -I../common -I. -I../game_shared -I../pm_shared -I../engine -I../dlls -DEFINES = -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w +DEFINES = -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w LOCAL_C_INCLUDES := $(LOCAL_PATH)/. \ $(LOCAL_PATH)/../common \ From 5dab1c1f1db1556a6648f3c66e1066888257ae51 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 18 Jul 2017 22:54:03 +0500 Subject: [PATCH 082/144] Revert "Merge https://github.com/LevShisterov/BugfixedHL/commit/29c4d46ad02492a33ddd9bb4ace0c873855eebe7" This reverts commit 075fd2903075aaa28b0d4930d7d1ba0d1b73f492. --- dlls/items.cpp | 1 - dlls/weapons.cpp | 12 +++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/dlls/items.cpp b/dlls/items.cpp index b0b2aa38..d9cc7871 100644 --- a/dlls/items.cpp +++ b/dlls/items.cpp @@ -166,7 +166,6 @@ void CItem::Materialize( void ) } SetTouch( &CItem::ItemTouch ); - SetThink( NULL ); } #define SF_SUIT_SHORTLOGON 0x0001 diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 22b4a456..61b038c0 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -485,7 +485,7 @@ void CBasePlayerItem::Materialize( void ) pev->solid = SOLID_TRIGGER; UTIL_SetOrigin( pev, pev->origin );// link into world. - SetTouch( &CBasePlayerItem::DefaultTouch ); + SetTouch( &CBasePlayerItem::DefaultTouch); SetThink( NULL ); } @@ -578,6 +578,13 @@ void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther ) } SUB_UseTargets( pOther, USE_TOGGLE, 0 ); // UNDONE: when should this happen? + + // If the item is falling and its Think remains FallItem after the player picks it up, + // then after the item touches the ground its Touch will be set back to DefaultTouch, + // so the player will pick it up again, this time Kill-ing the item (since we already have it in the inventory), + // which will make the pointer bad and crash the game. + if( m_pfnThink == &CBasePlayerItem::FallThink ) + SetThink( NULL ); } BOOL CanAttack( float attack_time, float curtime, BOOL isPredicted ) @@ -727,7 +734,7 @@ void CBasePlayerItem::AttachToPlayer( CBasePlayer *pPlayer ) pev->modelindex = 0;// server won't send down to clients if modelindex == 0 pev->model = iStringNull; pev->owner = pPlayer->edict(); - pev->nextthink = 0;// Remove think - prevents futher attempts to materialize + pev->nextthink = gpGlobals->time + .1; SetTouch( NULL ); SetThink( NULL ); } @@ -1047,7 +1054,6 @@ void CBasePlayerAmmo::Materialize( void ) } SetTouch( &CBasePlayerAmmo::DefaultTouch ); - SetThink( NULL ); } void CBasePlayerAmmo::DefaultTouch( CBaseEntity *pOther ) From 6d2a869ecdd0bc10b17733b78651c5528a099ec7 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 18 Jul 2017 22:56:45 +0500 Subject: [PATCH 083/144] Revert unneeded changes. --- dlls/satchel.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/dlls/satchel.cpp b/dlls/satchel.cpp index 015b3483..aeb9c5e6 100644 --- a/dlls/satchel.cpp +++ b/dlls/satchel.cpp @@ -117,17 +117,15 @@ void CSatchelCharge::SatchelSlide( CBaseEntity *pOther ) { // Fix for a bug in engine: when object isn't moving, but its speed isn't 0 and on ground isn't set if( pev->origin != m_lastBounceOrigin ) - BounceSound(); + BounceSound(); } m_lastBounceOrigin = pev->origin; - // There is no model animation so commented this out to prevent net traffic - // StudioFrameAdvance(); + StudioFrameAdvance(); } void CSatchelCharge::SatchelThink( void ) { - // There is no model animation so commented this out to prevent net traffic - // StudioFrameAdvance(); + StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; if( !IsInWorld() ) From c8ebe744c3311f1306f88fd88a467abd57029de5 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 19 Jul 2017 02:00:03 +0500 Subject: [PATCH 084/144] Fix my mistakes. Apply fixes for rpg and tank laser again. --- dlls/func_tank.cpp | 11 +++++++++-- dlls/player.cpp | 46 ---------------------------------------------- dlls/rpg.cpp | 5 +++++ 3 files changed, 14 insertions(+), 48 deletions(-) diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp index 54f4755a..c4e3cb42 100644 --- a/dlls/func_tank.cpp +++ b/dlls/func_tank.cpp @@ -93,6 +93,7 @@ public: BOOL StartControl( CBasePlayer* pController ); void StopControl( void ); void ControllerPostFrame( void ); + virtual void StopFire( void ){} protected: CBasePlayer* m_pController; @@ -369,8 +370,7 @@ BOOL CFuncTank::StartControl( CBasePlayer *pController ) void CFuncTank::StopControl() { - //if( m_pLaser ) - //m_pLaser->TurnOff(); + StopFire(); // TODO: bring back the controllers current weapon if( !m_pController ) @@ -755,6 +755,7 @@ public: virtual int Save( CSave &save ); virtual int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; + virtual void StopFire( void ); private: CLaser *m_pLaser; @@ -859,6 +860,12 @@ void CFuncTankLaser::Fire( const Vector &barrelEnd, const Vector &forward, entva } } +void CFuncTankLaser::StopFire( void ) +{ + if( m_pLaser ) + m_pLaser->TurnOff(); +} + class CFuncTankRocket : public CFuncTank { public: diff --git a/dlls/player.cpp b/dlls/player.cpp index d8ed7010..04da24c4 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -4060,52 +4060,6 @@ void CBasePlayer::UpdateClientData( void ) m_rgpPlayerItems[i]->UpdateClientData( this ); } - /*if( m_pClientActiveItem != pPlayer->m_pActiveItem ) - { - if( pPlayer->m_pActiveItem == NULL ) - { - // If no weapon, we have to send update here - CBasePlayer *plr; - for( int i = 1; i <= gpGlobals->maxClients; i++ ) - { - plr = (CBasePlayer *)UTIL_PlayerByIndex( i ); - if( !plr || !plr->IsObserver() || plr->m_hObserverTarget != pPlayer ) - continue; - - MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, plr->pev ); - WRITE_BYTE( 0 ); - WRITE_BYTE( 0 ); - WRITE_BYTE( 0 ); - MESSAGE_END(); - } - - MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pPlayer->pev ); - WRITE_BYTE( 0 ); - WRITE_BYTE( 0 ); - WRITE_BYTE( 0 ); - MESSAGE_END(); - } - else if( this != pPlayer ) - { - // Special case for spectator - CBasePlayerWeapon *gun = (CBasePlayerWeapon *)pPlayer->m_pActiveItem->GetWeaponPtr(); - if( gun ) - { - int state; - if( pPlayer->m_fOnTarget ) - state = WEAPON_IS_ONTARGET; - else - state = 1; - - MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pev ); - WRITE_BYTE( state ); - WRITE_BYTE( gun->m_iId ); - WRITE_BYTE( gun->m_iClip ); - MESSAGE_END(); - } - } - }*/ - // Cache and client weapon change m_pClientActiveItem = m_pActiveItem; m_iClientFOV = m_iFOV; diff --git a/dlls/rpg.cpp b/dlls/rpg.cpp index 5fb8cc70..fe1fd8a9 100644 --- a/dlls/rpg.cpp +++ b/dlls/rpg.cpp @@ -265,6 +265,11 @@ void CRpgRocket::FollowThink( void ) pev->velocity = pev->velocity * 0.2 + vecTarget * flSpeed * 0.798; if( pev->waterlevel == 0 && pev->velocity.Length() < 1500 ) { + if( CRpg *pLauncher = (CRpg*)( (CBaseEntity*)( m_hLauncher ) ) ) + { + // my launcher is still around, tell it I'm dead. + pLauncher->m_cActiveRockets--; + } Detonate(); } } From c2a1b013c2d7c9a9c3cb4268de52aa67e3cc2368 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 19 Jul 2017 02:47:31 +0500 Subject: [PATCH 085/144] Merge https://github.com/LevShisterov/BugfixedHL/commit/001e6a09fa9e016995d76aa9092a7656efb63b9e --- dlls/weapons.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 61b038c0..8a7898bf 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -295,6 +295,7 @@ void W_Precache( void ) // common world objects UTIL_PrecacheOther( "item_suit" ); + UTIL_PrecacheOther( "item_healthkit" ); UTIL_PrecacheOther( "item_battery" ); UTIL_PrecacheOther( "item_antidote" ); UTIL_PrecacheOther( "item_security" ); @@ -316,6 +317,9 @@ void W_Precache( void ) UTIL_PrecacheOther( "ammo_9mmAR" ); UTIL_PrecacheOther( "ammo_ARgrenades" ); + // 9mm ammo box + UTIL_PrecacheOther( "ammo_9mmbox" ); + #if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) // python UTIL_PrecacheOtherWeapon( "weapon_357" ); From 9dff875d32bd076a34ce379f3e785fa7636bf228 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 19 Jul 2017 02:51:17 +0500 Subject: [PATCH 086/144] Revert "Revert unneeded changes." This reverts commit 6d2a869ecdd0bc10b17733b78651c5528a099ec7. --- dlls/satchel.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dlls/satchel.cpp b/dlls/satchel.cpp index aeb9c5e6..015b3483 100644 --- a/dlls/satchel.cpp +++ b/dlls/satchel.cpp @@ -117,15 +117,17 @@ void CSatchelCharge::SatchelSlide( CBaseEntity *pOther ) { // Fix for a bug in engine: when object isn't moving, but its speed isn't 0 and on ground isn't set if( pev->origin != m_lastBounceOrigin ) - BounceSound(); + BounceSound(); } m_lastBounceOrigin = pev->origin; - StudioFrameAdvance(); + // There is no model animation so commented this out to prevent net traffic + // StudioFrameAdvance(); } void CSatchelCharge::SatchelThink( void ) { - StudioFrameAdvance(); + // There is no model animation so commented this out to prevent net traffic + // StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; if( !IsInWorld() ) From 426a0e7ab31ece52abe20436a64f4a5ce838bfe9 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 19 Jul 2017 02:52:11 +0500 Subject: [PATCH 087/144] Revert "Revert "Merge https://github.com/LevShisterov/BugfixedHL/commit/29c4d46ad02492a33ddd9bb4ace0c873855eebe7"" This reverts commit 5dab1c1f1db1556a6648f3c66e1066888257ae51. --- dlls/items.cpp | 1 + dlls/weapons.cpp | 12 +++--------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/dlls/items.cpp b/dlls/items.cpp index d9cc7871..b0b2aa38 100644 --- a/dlls/items.cpp +++ b/dlls/items.cpp @@ -166,6 +166,7 @@ void CItem::Materialize( void ) } SetTouch( &CItem::ItemTouch ); + SetThink( NULL ); } #define SF_SUIT_SHORTLOGON 0x0001 diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 8a7898bf..05db43da 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -489,7 +489,7 @@ void CBasePlayerItem::Materialize( void ) pev->solid = SOLID_TRIGGER; UTIL_SetOrigin( pev, pev->origin );// link into world. - SetTouch( &CBasePlayerItem::DefaultTouch); + SetTouch( &CBasePlayerItem::DefaultTouch ); SetThink( NULL ); } @@ -582,13 +582,6 @@ void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther ) } SUB_UseTargets( pOther, USE_TOGGLE, 0 ); // UNDONE: when should this happen? - - // If the item is falling and its Think remains FallItem after the player picks it up, - // then after the item touches the ground its Touch will be set back to DefaultTouch, - // so the player will pick it up again, this time Kill-ing the item (since we already have it in the inventory), - // which will make the pointer bad and crash the game. - if( m_pfnThink == &CBasePlayerItem::FallThink ) - SetThink( NULL ); } BOOL CanAttack( float attack_time, float curtime, BOOL isPredicted ) @@ -738,7 +731,7 @@ void CBasePlayerItem::AttachToPlayer( CBasePlayer *pPlayer ) pev->modelindex = 0;// server won't send down to clients if modelindex == 0 pev->model = iStringNull; pev->owner = pPlayer->edict(); - pev->nextthink = gpGlobals->time + .1; + pev->nextthink = 0;// Remove think - prevents futher attempts to materialize SetTouch( NULL ); SetThink( NULL ); } @@ -1058,6 +1051,7 @@ void CBasePlayerAmmo::Materialize( void ) } SetTouch( &CBasePlayerAmmo::DefaultTouch ); + SetThink( NULL ); } void CBasePlayerAmmo::DefaultTouch( CBaseEntity *pOther ) From 51c682c15e7d6e2abdf403ef096b9cecbd545211 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 19 Jul 2017 03:22:08 +0500 Subject: [PATCH 088/144] Merge https://github.com/LevShisterov/BugfixedHL/commit/adb616153729102975800edbbdcc8ed8a50ed8ad --- dlls/game.cpp | 4 +++- dlls/game.h | 1 + dlls/gauss.cpp | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dlls/game.cpp b/dlls/game.cpp index 9b69cac9..b109f376 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -25,11 +25,12 @@ cvar_t timeleft = { "mp_timeleft","0" , FCVAR_SERVER | FCVAR_UNLOGGED }; // " // multiplayer server rules cvar_t teamplay = { "mp_teamplay","0", FCVAR_SERVER }; -cvar_t fraglimit = {"mp_fraglimit","0", FCVAR_SERVER }; +cvar_t fraglimit = { "mp_fraglimit","0", FCVAR_SERVER }; cvar_t timelimit = { "mp_timelimit","0", FCVAR_SERVER }; cvar_t friendlyfire = { "mp_friendlyfire","0", FCVAR_SERVER }; cvar_t falldamage = { "mp_falldamage","0", FCVAR_SERVER }; cvar_t weaponstay = { "mp_weaponstay","0", FCVAR_SERVER }; +cvar_t selfgauss = { "mp_selfgauss", "1", FCVAR_SERVER }; cvar_t forcerespawn = { "mp_forcerespawn","1", FCVAR_SERVER }; cvar_t flashlight = { "mp_flashlight","0", FCVAR_SERVER }; cvar_t aimcrosshair = { "mp_autocrosshair","1", FCVAR_SERVER }; @@ -467,6 +468,7 @@ void GameDLLInit( void ) CVAR_REGISTER( &friendlyfire ); CVAR_REGISTER( &falldamage ); CVAR_REGISTER( &weaponstay ); + CVAR_REGISTER( &selfgauss ); CVAR_REGISTER( &forcerespawn ); CVAR_REGISTER( &flashlight ); CVAR_REGISTER( &aimcrosshair ); diff --git a/dlls/game.h b/dlls/game.h index 925010f3..e29b2563 100644 --- a/dlls/game.h +++ b/dlls/game.h @@ -27,6 +27,7 @@ extern cvar_t timelimit; extern cvar_t friendlyfire; extern cvar_t falldamage; extern cvar_t weaponstay; +extern cvar_t selfgauss; extern cvar_t forcerespawn; extern cvar_t flashlight; extern cvar_t aimcrosshair; diff --git a/dlls/gauss.cpp b/dlls/gauss.cpp index d3e005c2..62af08e1 100644 --- a/dlls/gauss.cpp +++ b/dlls/gauss.cpp @@ -24,6 +24,7 @@ #include "soundent.h" #include "shake.h" #include "gamerules.h" +#include "game.h" #define GAUSS_PRIMARY_CHARGE_VOLUME 256// how loud gauss is while charging #define GAUSS_PRIMARY_FIRE_VOLUME 450// how loud gauss is when discharged @@ -512,6 +513,10 @@ void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) vecSrc = beam_tr.vecEndPos + vecDir; } + else if( !selfgauss.value ) + { + flDamage = 0; + } } else { From 946e962f3c8e1429ab39a0e5e851ff5d1e13a211 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 19 Jul 2017 04:06:19 +0500 Subject: [PATCH 089/144] Merge https://github.com/LevShisterov/BugfixedHL/commit/1c71f33cb0978cfdcfc5167d9c8860654778f762 --- cl_dll/flashlight.cpp | 2 ++ dlls/player.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/cl_dll/flashlight.cpp b/cl_dll/flashlight.cpp index 8b8a8d0e..c3514c7d 100644 --- a/cl_dll/flashlight.cpp +++ b/cl_dll/flashlight.cpp @@ -49,6 +49,8 @@ void CHudFlashlight::Reset( void ) { m_fFade = 0; m_fOn = 0; + m_iBat = 100; + m_flBat = 1.0; } int CHudFlashlight::VidInit( void ) diff --git a/dlls/player.cpp b/dlls/player.cpp index 04da24c4..0d86caf8 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -3868,6 +3868,12 @@ void CBasePlayer::UpdateClientData( void ) FireTargets( "game_playerspawn", this, this, USE_TOGGLE, 0 ); + // Send flashlight status + MESSAGE_BEGIN( MSG_ONE, gmsgFlashlight, NULL, pev ); + WRITE_BYTE( FlashlightIsOn() ? 1 : 0 ); + WRITE_BYTE( m_iFlashBattery ); + MESSAGE_END(); + InitStatusBar(); } From a2e4a7ec03d987c0645742fde30a591452689245 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 19 Jul 2017 04:11:08 +0500 Subject: [PATCH 090/144] Fix crosshair. --- cl_dll/ammo.cpp | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/cl_dll/ammo.cpp b/cl_dll/ammo.cpp index f439520e..edc21652 100644 --- a/cl_dll/ammo.cpp +++ b/cl_dll/ammo.cpp @@ -305,6 +305,9 @@ void CHudAmmo::Reset( void ) gHR.Reset(); //VidInit(); + wrect_t nullrc = {}; + SetCrosshair( 0, nullrc, 0, 0, 0 ); // reset crosshair + m_pWeapon = NULL; // reset last weapon } int CHudAmmo::VidInit( void ) @@ -606,22 +609,24 @@ int CHudAmmo::MsgFunc_CurWeapon( const char *pszName, int iSize, void *pbuf ) m_pWeapon = pWeapon; - if( gHUD.m_iFOV >= 90 ) + if( !( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) ) ) { - // normal crosshairs - if( fOnTarget && m_pWeapon->hAutoaim ) - SetCrosshair( m_pWeapon->hAutoaim, m_pWeapon->rcAutoaim, 255, 255, 255 ); - else - SetCrosshair( m_pWeapon->hCrosshair, m_pWeapon->rcCrosshair, 255, 255, 255 ); - } - else - { - // zoomed crosshairs - if( fOnTarget && m_pWeapon->hZoomedAutoaim ) - SetCrosshair( m_pWeapon->hZoomedAutoaim, m_pWeapon->rcZoomedAutoaim, 255, 255, 255 ); + if( gHUD.m_iFOV >= 90 ) + { + // normal crosshairs + if( fOnTarget && m_pWeapon->hAutoaim ) + SetCrosshair( m_pWeapon->hAutoaim, m_pWeapon->rcAutoaim, 255, 255, 255 ); + else + SetCrosshair( m_pWeapon->hCrosshair, m_pWeapon->rcCrosshair, 255, 255, 255 ); + } else - SetCrosshair( m_pWeapon->hZoomedCrosshair, m_pWeapon->rcZoomedCrosshair, 255, 255, 255 ); - + { + // zoomed crosshairs + if( fOnTarget && m_pWeapon->hZoomedAutoaim ) + SetCrosshair( m_pWeapon->hZoomedAutoaim, m_pWeapon->rcZoomedAutoaim, 255, 255, 255 ); + else + SetCrosshair( m_pWeapon->hZoomedCrosshair, m_pWeapon->rcZoomedCrosshair, 255, 255, 255 ); + } } m_fFade = 200.0f; //!!! From d062757f5273e0ecdbf05f6a1ea599690ba8816a Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 19 Jul 2017 23:25:47 +0500 Subject: [PATCH 091/144] Use MAKE_STRING for literals. Remove duplicated code. --- dlls/bmodels.cpp | 40 ++++------ dlls/buttons.cpp | 10 +-- dlls/doors.cpp | 192 +++++++++++++++++++++------------------------- dlls/maprules.cpp | 160 +++++++++++++++++++------------------- dlls/plats.cpp | 119 ++++++++++++++-------------- dlls/triggers.cpp | 2 +- 6 files changed, 244 insertions(+), 279 deletions(-) diff --git a/dlls/bmodels.cpp b/dlls/bmodels.cpp index 6e8526f9..c48abbf9 100644 --- a/dlls/bmodels.cpp +++ b/dlls/bmodels.cpp @@ -430,15 +430,13 @@ void CFuncRotating::Spawn() void CFuncRotating::Precache( void ) { - char* szSoundFile = (char*)STRING( pev->message ); + const char* szSoundFile = STRING( pev->message ); + BOOL NullSound = FALSE; // set up fan sounds if( !FStringNull( pev->message ) && strlen( szSoundFile ) > 0 ) { // if a path is set for a wave, use it - PRECACHE_SOUND( szSoundFile ); - - pev->noiseRunning = ALLOC_STRING( szSoundFile ); } else { @@ -446,42 +444,32 @@ void CFuncRotating::Precache( void ) switch( m_sounds ) { case 1: - PRECACHE_SOUND( "fans/fan1.wav" ); - pev->noiseRunning = ALLOC_STRING( "fans/fan1.wav" ); + szSoundFile = "fans/fan1.wav"; break; case 2: - PRECACHE_SOUND( "fans/fan2.wav" ); - pev->noiseRunning = ALLOC_STRING( "fans/fan2.wav" ); + szSoundFile = "fans/fan2.wav"; break; case 3: - PRECACHE_SOUND( "fans/fan3.wav" ); - pev->noiseRunning = ALLOC_STRING( "fans/fan3.wav" ); + szSoundFile = "fans/fan3.wav"; break; case 4: - PRECACHE_SOUND( "fans/fan4.wav" ); - pev->noiseRunning = ALLOC_STRING( "fans/fan4.wav" ); + szSoundFile = "fans/fan4.wav"; break; case 5: - PRECACHE_SOUND( "fans/fan5.wav" ); - pev->noiseRunning = ALLOC_STRING( "fans/fan5.wav" ); + szSoundFile = "fans/fan5.wav"; break; case 0: default: - if( !FStringNull( pev->message ) && strlen( szSoundFile ) > 0 ) - { - PRECACHE_SOUND( szSoundFile ); - - pev->noiseRunning = ALLOC_STRING( szSoundFile ); - break; - } - else - { - pev->noiseRunning = ALLOC_STRING( "common/null.wav" ); - break; - } + szSoundFile = "common/null.wav"; + NullSound = TRUE; + break; } } + if( !NullSound ) + PRECACHE_SOUND( szSoundFile ); + pev->noiseRunning = MAKE_STRING( szSoundFile ); + if( pev->avelocity != g_vecZero ) { // if fan was spinning, and we went through transition or save/restore, diff --git a/dlls/buttons.cpp b/dlls/buttons.cpp index df7c51f3..7ea9082a 100644 --- a/dlls/buttons.cpp +++ b/dlls/buttons.cpp @@ -292,14 +292,14 @@ void CBaseButton::Precache( void ) { pszSound = ButtonSound( (int)m_bLockedSound ); PRECACHE_SOUND( pszSound ); - m_ls.sLockedSound = ALLOC_STRING( pszSound ); + m_ls.sLockedSound = MAKE_STRING( pszSound ); } if( m_bUnlockedSound ) { pszSound = ButtonSound( (int)m_bUnlockedSound ); PRECACHE_SOUND( pszSound ); - m_ls.sUnlockedSound = ALLOC_STRING( pszSound ); + m_ls.sUnlockedSound = MAKE_STRING( pszSound ); } // get sentence group names, for doors which are directly 'touched' to open @@ -469,7 +469,7 @@ void CBaseButton::Spawn() //---------------------------------------------------- pszSound = ButtonSound( m_sounds ); PRECACHE_SOUND( pszSound ); - pev->noise = ALLOC_STRING( pszSound ); + pev->noise = MAKE_STRING( pszSound ); Precache(); @@ -876,7 +876,7 @@ void CRotButton::Spawn( void ) //---------------------------------------------------- pszSound = ButtonSound( m_sounds ); PRECACHE_SOUND( pszSound ); - pev->noise = ALLOC_STRING( pszSound ); + pev->noise = MAKE_STRING( pszSound ); // set the axis of rotation CBaseToggle::AxisDir( pev ); @@ -1012,7 +1012,7 @@ void CMomentaryRotButton::Spawn( void ) const char *pszSound = ButtonSound( m_sounds ); PRECACHE_SOUND( pszSound ); - pev->noise = ALLOC_STRING( pszSound ); + pev->noise = MAKE_STRING( pszSound ); m_lastUsed = 0; } diff --git a/dlls/doors.cpp b/dlls/doors.cpp index 3a8613ab..ce901ee8 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -330,114 +330,104 @@ void CBaseDoor::SetToggleState( int state ) void CBaseDoor::Precache( void ) { const char *pszSound; + BOOL NullSound = FALSE; // set the door's "in-motion" sound switch( m_bMoveSnd ) { - case 0: - pev->noiseMoving = ALLOC_STRING( "common/null.wav" ); - break; case 1: - PRECACHE_SOUND( "doors/doormove1.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove1.wav" ); + pszSound = "doors/doormove1.wav"; break; case 2: - PRECACHE_SOUND( "doors/doormove2.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove2.wav" ); + pszSound = "doors/doormove2.wav"; break; case 3: - PRECACHE_SOUND( "doors/doormove3.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove3.wav" ); + pszSound = "doors/doormove3.wav"; break; case 4: - PRECACHE_SOUND( "doors/doormove4.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove4.wav" ); + pszSound = "doors/doormove4.wav"; break; case 5: - PRECACHE_SOUND( "doors/doormove5.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove5.wav" ); + pszSound = "doors/doormove5.wav"; break; case 6: - PRECACHE_SOUND( "doors/doormove6.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove6.wav" ); + pszSound = "doors/doormove6.wav"; break; case 7: - PRECACHE_SOUND( "doors/doormove7.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove7.wav" ); + pszSound = "doors/doormove7.wav"; break; case 8: - PRECACHE_SOUND( "doors/doormove8.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove8.wav" ); + pszSound = "doors/doormove8.wav"; break; case 9: - PRECACHE_SOUND( "doors/doormove9.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove9.wav" ); + pszSound = "doors/doormove9.wav"; break; case 10: - PRECACHE_SOUND( "doors/doormove10.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove10.wav" ); + pszSound = "doors/doormove10.wav"; break; + case 0: default: - pev->noiseMoving = ALLOC_STRING( "common/null.wav" ); + pszSound = "common/null.wav"; + NullSound = TRUE; break; } + if( !NullSound ) + PRECACHE_SOUND( pszSound ); + pev->noiseMoving = MAKE_STRING( pszSound ); + NullSound = FALSE; + // set the door's 'reached destination' stop sound switch( m_bStopSnd ) { - case 0: - pev->noiseArrived = ALLOC_STRING( "common/null.wav" ); - break; case 1: - PRECACHE_SOUND( "doors/doorstop1.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop1.wav" ); + pszSound = "doors/doorstop1.wav"; break; case 2: - PRECACHE_SOUND( "doors/doorstop2.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop2.wav" ); + pszSound = "doors/doorstop2.wav"; break; case 3: - PRECACHE_SOUND( "doors/doorstop3.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop3.wav" ); + pszSound = "doors/doorstop3.wav"; break; case 4: - PRECACHE_SOUND( "doors/doorstop4.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop4.wav" ); + pszSound = "doors/doorstop4.wav"; break; case 5: - PRECACHE_SOUND( "doors/doorstop5.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop5.wav" ); + pszSound = "doors/doorstop5.wav"; break; case 6: - PRECACHE_SOUND( "doors/doorstop6.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop6.wav"); + pszSound = "doors/doorstop6.wav" break; case 7: - PRECACHE_SOUND( "doors/doorstop7.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop7.wav" ); + pszSound = "doors/doorstop7.wav"; break; case 8: - PRECACHE_SOUND( "doors/doorstop8.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop8.wav" ); + pszSound = "doors/doorstop8.wav"; break; + case 0: default: - pev->noiseArrived = ALLOC_STRING( "common/null.wav" ); + pszSound = "common/null.wav"; + NullSound = TRUE; break; } + if( !NullSound ) + PRECACHE_SOUND( pszSound ); + pev->noiseArrived = MAKE_STRING( pszSound ); + // get door button sounds, for doors which are directly 'touched' to open if( m_bLockedSound ) { pszSound = ButtonSound( (int)m_bLockedSound ); PRECACHE_SOUND( pszSound ); - m_ls.sLockedSound = ALLOC_STRING( pszSound ); + m_ls.sLockedSound = MAKE_STRING( pszSound ); } if( m_bUnlockedSound ) { pszSound = ButtonSound( (int)m_bUnlockedSound ); PRECACHE_SOUND( pszSound ); - m_ls.sUnlockedSound = ALLOC_STRING( pszSound ); + m_ls.sUnlockedSound = MAKE_STRING( pszSound ); } // get sentence group names, for doors which are directly 'touched' to open @@ -445,39 +435,39 @@ void CBaseDoor::Precache( void ) { case 1: // access denied - m_ls.sLockedSentence = ALLOC_STRING( "NA" ); + m_ls.sLockedSentence = MAKE_STRING( "NA" ); break; case 2: // security lockout - m_ls.sLockedSentence = ALLOC_STRING( "ND" ); + m_ls.sLockedSentence = MAKE_STRING( "ND" ); break; case 3: // blast door - m_ls.sLockedSentence = ALLOC_STRING( "NF" ); + m_ls.sLockedSentence = MAKE_STRING( "NF" ); break; case 4: // fire door - m_ls.sLockedSentence = ALLOC_STRING( "NFIRE" ); + m_ls.sLockedSentence = MAKE_STRING( "NFIRE" ); break; case 5: // chemical door - m_ls.sLockedSentence = ALLOC_STRING( "NCHEM" ); + m_ls.sLockedSentence = MAKE_STRING( "NCHEM" ); break; case 6: // radiation door - m_ls.sLockedSentence = ALLOC_STRING( "NRAD" ); + m_ls.sLockedSentence = MAKE_STRING( "NRAD" ); break; case 7: // gen containment - m_ls.sLockedSentence = ALLOC_STRING( "NCON" ); + m_ls.sLockedSentence = MAKE_STRING( "NCON" ); break; case 8: // maintenance door - m_ls.sLockedSentence = ALLOC_STRING( "NH" ); + m_ls.sLockedSentence = MAKE_STRING( "NH" ); break; case 9: // broken door - m_ls.sLockedSentence = ALLOC_STRING( "NG" ); + m_ls.sLockedSentence = MAKE_STRING( "NG" ); break; default: m_ls.sLockedSentence = 0; @@ -488,35 +478,35 @@ void CBaseDoor::Precache( void ) { case 1: // access granted - m_ls.sUnlockedSentence = ALLOC_STRING( "EA" ); + m_ls.sUnlockedSentence = MAKE_STRING( "EA" ); break; case 2: // security door - m_ls.sUnlockedSentence = ALLOC_STRING( "ED" ); + m_ls.sUnlockedSentence = MAKE_STRING( "ED" ); break; case 3: // blast door - m_ls.sUnlockedSentence = ALLOC_STRING( "EF" ); + m_ls.sUnlockedSentence = MAKE_STRING( "EF" ); break; case 4: // fire door - m_ls.sUnlockedSentence = ALLOC_STRING( "EFIRE" ); + m_ls.sUnlockedSentence = MAKE_STRING( "EFIRE" ); break; case 5: // chemical door - m_ls.sUnlockedSentence = ALLOC_STRING( "ECHEM" ); + m_ls.sUnlockedSentence = MAKE_STRING( "ECHEM" ); break; case 6: // radiation door - m_ls.sUnlockedSentence = ALLOC_STRING( "ERAD" ); + m_ls.sUnlockedSentence = MAKE_STRING( "ERAD" ); break; case 7: // gen containment - m_ls.sUnlockedSentence = ALLOC_STRING( "ECON" ); + m_ls.sUnlockedSentence = MAKE_STRING( "ECON" ); break; case 8: // maintenance door - m_ls.sUnlockedSentence = ALLOC_STRING( "EH" ); + m_ls.sUnlockedSentence = MAKE_STRING( "EH" ); break; default: m_ls.sUnlockedSentence = 0; @@ -985,94 +975,88 @@ void CMomentaryDoor::Spawn( void ) Precache(); } - + void CMomentaryDoor::Precache( void ) { + const char *pszSound; + BOOL NullSound = FALSE; + // set the door's "in-motion" sound switch( m_bMoveSnd ) { - case 0: - pev->noiseMoving = ALLOC_STRING( "common/null.wav" ); - break; case 1: - PRECACHE_SOUND( "doors/doormove1.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove1.wav" ); + pszSound = "doors/doormove1.wav"; break; case 2: - PRECACHE_SOUND( "doors/doormove2.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove2.wav" ); + pszSound = "doors/doormove2.wav"; break; case 3: - PRECACHE_SOUND( "doors/doormove3.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove3.wav" ); + pszSound = "doors/doormove3.wav"; break; case 4: - PRECACHE_SOUND( "doors/doormove4.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove4.wav" ); + pszSound = "doors/doormove4.wav"; break; case 5: - PRECACHE_SOUND( "doors/doormove5.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove5.wav" ); + pszSound = "doors/doormove5.wav"; break; case 6: - PRECACHE_SOUND( "doors/doormove6.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove6.wav" ); + pszSound = "doors/doormove6.wav"; break; case 7: - PRECACHE_SOUND( "doors/doormove7.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove7.wav" ); + pszSound = "doors/doormove7.wav"; break; case 8: - PRECACHE_SOUND( "doors/doormove8.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove8.wav" ); + pszSound = "doors/doormove8.wav"; break; + case 0: default: - pev->noiseMoving = ALLOC_STRING( "common/null.wav" ); + pszSound = "common/null.wav"; + NullSound = TRUE; break; } + if( !NullSound ) + PRECACHE_SOUND( pszSound ); + pev->noiseMoving = MAKE_STRING( pszSound ); + NullSound = FALSE; + // set the door's 'reached destination' stop sound switch( m_bStopSnd ) { - case 0: - pev->noiseArrived = ALLOC_STRING( "common/null.wav" ); - break; case 1: - PRECACHE_SOUND( "doors/doorstop1.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop1.wav" ); + pszSound = "doors/doorstop1.wav"; break; case 2: - PRECACHE_SOUND( "doors/doorstop2.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop2.wav" ); + pszSound = "doors/doorstop2.wav"; break; case 3: - PRECACHE_SOUND( "doors/doorstop3.wav" ); - pev->noiseArrived = ALLOC_STRING("doors/doorstop3.wav"); + pszSound = "doors/doorstop3.wav"; break; case 4: - PRECACHE_SOUND( "doors/doorstop4.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop4.wav" ); + pszSound = "doors/doorstop4.wav"; break; case 5: - PRECACHE_SOUND( "doors/doorstop5.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop5.wav" ); + pszSound = "doors/doorstop5.wav"; break; case 6: - PRECACHE_SOUND( "doors/doorstop6.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop6.wav" ); + pszSound = "doors/doorstop6.wav"; break; case 7: - PRECACHE_SOUND( "doors/doorstop7.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop7.wav" ); + pszSound = "doors/doorstop7.wav"; break; case 8: - PRECACHE_SOUND( "doors/doorstop8.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop8.wav" ); + pszSound = "doors/doorstop8.wav"; break; + case 0: default: - pev->noiseArrived = ALLOC_STRING( "common/null.wav" ); + pszSound = "common/null.wav"; + NullSound = TRUE; break; } + + if( !NullSound ) + PRECACHE_SOUND( pszSound ); + pev->noiseArrived = MAKE_STRING( pszSound ); } void CMomentaryDoor::KeyValue( KeyValueData *pkvd ) diff --git a/dlls/maprules.cpp b/dlls/maprules.cpp index 2230acac..bfec93e2 100644 --- a/dlls/maprules.cpp +++ b/dlls/maprules.cpp @@ -153,9 +153,9 @@ void CGameScore::Spawn( void ) void CGameScore::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "points")) + if( FStrEq( pkvd->szKeyName, "points" ) ) { - SetPoints( atoi(pkvd->szValue) ); + SetPoints( atoi( pkvd->szValue ) ); pkvd->fHandled = TRUE; } else @@ -164,13 +164,13 @@ void CGameScore::KeyValue( KeyValueData *pkvd ) void CGameScore::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; // Only players can use this - if ( pActivator->IsPlayer() ) + if( pActivator->IsPlayer() ) { - if ( AwardToTeam() ) + if( AwardToTeam() ) { pActivator->AddPointsToTeam( Points(), AllowNegativeScore() ); } @@ -194,7 +194,7 @@ LINK_ENTITY_TO_CLASS( game_end, CGameEnd ) void CGameEnd::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; g_pGameRules->EndMultiplayerGame(); @@ -239,27 +239,27 @@ IMPLEMENT_SAVERESTORE( CGameText, CRulePointEntity ) void CGameText::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "channel")) + if( FStrEq( pkvd->szKeyName, "channel" ) ) { m_textParms.channel = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "x")) + else if( FStrEq( pkvd->szKeyName, "x" ) ) { m_textParms.x = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "y")) + else if( FStrEq(pkvd->szKeyName, "y" ) ) { m_textParms.y = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "effect")) + else if( FStrEq( pkvd->szKeyName, "effect" ) ) { m_textParms.effect = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "color")) + else if( FStrEq( pkvd->szKeyName, "color" ) ) { int color[4]; UTIL_StringToIntArray( color, 4, pkvd->szValue ); @@ -269,7 +269,7 @@ void CGameText::KeyValue( KeyValueData *pkvd ) m_textParms.a1 = color[3]; pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "color2")) + else if( FStrEq( pkvd->szKeyName, "color2" ) ) { int color[4]; UTIL_StringToIntArray( color, 4, pkvd->szValue ); @@ -279,22 +279,22 @@ void CGameText::KeyValue( KeyValueData *pkvd ) m_textParms.a2 = color[3]; pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "fadein")) + else if( FStrEq( pkvd->szKeyName, "fadein" ) ) { m_textParms.fadeinTime = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "fadeout")) + else if( FStrEq( pkvd->szKeyName, "fadeout" ) ) { m_textParms.fadeoutTime = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "holdtime")) + else if( FStrEq( pkvd->szKeyName, "holdtime" ) ) { m_textParms.holdTime = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "fxtime")) + else if( FStrEq(pkvd->szKeyName, "fxtime" ) ) { m_textParms.fxTime = atof( pkvd->szValue ); pkvd->fHandled = TRUE; @@ -305,16 +305,16 @@ void CGameText::KeyValue( KeyValueData *pkvd ) void CGameText::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; - if ( MessageToAll() ) + if( MessageToAll() ) { UTIL_HudMessageAll( m_textParms, MessageGet() ); } else { - if ( pActivator->IsNetClient() ) + if( pActivator->IsNetClient() ) { UTIL_HudMessage( pActivator, m_textParms, MessageGet() ); } @@ -356,12 +356,12 @@ LINK_ENTITY_TO_CLASS( game_team_master, CGameTeamMaster ) void CGameTeamMaster::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "teamindex")) + if( FStrEq( pkvd->szKeyName, "teamindex" ) ) { m_teamIndex = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "triggerstate")) + else if( FStrEq( pkvd->szKeyName, "triggerstate" ) ) { int type = atoi( pkvd->szValue ); switch( type ) @@ -384,12 +384,12 @@ void CGameTeamMaster::KeyValue( KeyValueData *pkvd ) void CGameTeamMaster::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; - if ( useType == USE_SET ) + if( useType == USE_SET ) { - if ( value < 0 ) + if( value < 0 ) { m_teamIndex = -1; } @@ -400,10 +400,10 @@ void CGameTeamMaster::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY return; } - if ( TeamMatch( pActivator ) ) + if( TeamMatch( pActivator ) ) { SUB_UseTargets( pActivator, triggerType, value ); - if ( RemoveOnFire() ) + if( RemoveOnFire() ) UTIL_Remove( this ); } } @@ -415,7 +415,7 @@ BOOL CGameTeamMaster::IsTriggered( CBaseEntity *pActivator ) const char *CGameTeamMaster::TeamID( void ) { - if ( m_teamIndex < 0 ) // Currently set to "no team" + if( m_teamIndex < 0 ) // Currently set to "no team" return ""; return g_pGameRules->GetIndexedTeamName( m_teamIndex ); // UNDONE: Fill this in with the team from the "teamlist" @@ -423,10 +423,10 @@ const char *CGameTeamMaster::TeamID( void ) BOOL CGameTeamMaster::TeamMatch( CBaseEntity *pActivator ) { - if ( m_teamIndex < 0 && AnyTeam() ) + if( m_teamIndex < 0 && AnyTeam() ) return TRUE; - if ( !pActivator ) + if( !pActivator ) return FALSE; return UTIL_TeamsMatch( pActivator->TeamID(), TeamID() ); @@ -443,7 +443,7 @@ BOOL CGameTeamMaster::TeamMatch( CBaseEntity *pActivator ) class CGameTeamSet : public CRulePointEntity { public: - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); inline BOOL RemoveOnFire( void ) { return (pev->spawnflags & SF_TEAMSET_FIREONCE) ? TRUE : FALSE; } inline BOOL ShouldClearTeam( void ) { return (pev->spawnflags & SF_TEAMSET_CLEARTEAM) ? TRUE : FALSE; } @@ -454,10 +454,10 @@ LINK_ENTITY_TO_CLASS( game_team_set, CGameTeamSet ) void CGameTeamSet::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; - if ( ShouldClearTeam() ) + if( ShouldClearTeam() ) { SUB_UseTargets( pActivator, USE_SET, -1 ); } @@ -466,7 +466,7 @@ void CGameTeamSet::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE SUB_UseTargets( pActivator, USE_SET, 0 ); } - if ( RemoveOnFire() ) + if( RemoveOnFire() ) { UTIL_Remove( this ); } @@ -506,22 +506,22 @@ IMPLEMENT_SAVERESTORE( CGamePlayerZone, CRuleBrushEntity ) void CGamePlayerZone::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "intarget")) + if( FStrEq(pkvd->szKeyName, "intarget" ) ) { m_iszInTarget = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "outtarget")) + else if( FStrEq( pkvd->szKeyName, "outtarget" ) ) { m_iszOutTarget = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "incount")) + else if( FStrEq( pkvd->szKeyName, "incount" ) ) { m_iszInCount = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "outcount")) + else if( FStrEq( pkvd->szKeyName, "outcount" ) ) { m_iszOutCount = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; @@ -535,12 +535,12 @@ void CGamePlayerZone::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY int playersInCount = 0; int playersOutCount = 0; - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; CBaseEntity *pPlayer = NULL; - for ( int i = 1; i <= gpGlobals->maxClients; i++ ) + for( int i = 1; i <= gpGlobals->maxClients; i++ ) { pPlayer = UTIL_PlayerByIndex( i ); if ( pPlayer ) @@ -549,40 +549,40 @@ void CGamePlayerZone::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY int hullNumber; hullNumber = human_hull; - if ( pPlayer->pev->flags & FL_DUCKING ) + if( pPlayer->pev->flags & FL_DUCKING ) { hullNumber = head_hull; } UTIL_TraceModel( pPlayer->pev->origin, pPlayer->pev->origin, hullNumber, edict(), &trace ); - if ( trace.fStartSolid ) + if( trace.fStartSolid ) { playersInCount++; - if ( m_iszInTarget ) + if( m_iszInTarget ) { - FireTargets( STRING(m_iszInTarget), pPlayer, pActivator, useType, value ); + FireTargets( STRING( m_iszInTarget ), pPlayer, pActivator, useType, value ); } } else { playersOutCount++; - if ( m_iszOutTarget ) + if( m_iszOutTarget ) { - FireTargets( STRING(m_iszOutTarget), pPlayer, pActivator, useType, value ); + FireTargets( STRING( m_iszOutTarget ), pPlayer, pActivator, useType, value ); } } } } - if ( m_iszInCount ) + if( m_iszInCount ) { - FireTargets( STRING(m_iszInCount), pActivator, this, USE_SET, playersInCount ); + FireTargets( STRING( m_iszInCount ), pActivator, this, USE_SET, playersInCount ); } - if ( m_iszOutCount ) + if( m_iszOutCount ) { - FireTargets( STRING(m_iszOutCount), pActivator, this, USE_SET, playersOutCount ); + FireTargets( STRING( m_iszOutCount ), pActivator, this, USE_SET, playersOutCount ); } } @@ -605,12 +605,12 @@ LINK_ENTITY_TO_CLASS( game_player_hurt, CGamePlayerHurt ) void CGamePlayerHurt::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; - if ( pActivator->IsPlayer() ) + if( pActivator->IsPlayer() ) { - if ( pev->dmg < 0 ) + if( pev->dmg < 0 ) pActivator->TakeHealth( -pev->dmg, DMG_GENERIC ); else pActivator->TakeDamage( pev, pev, pev->dmg, DMG_GENERIC ); @@ -618,7 +618,7 @@ void CGamePlayerHurt::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY SUB_UseTargets( pActivator, useType, value ); - if ( RemoveOnFire() ) + if( RemoveOnFire() ) { UTIL_Remove( this ); } @@ -665,7 +665,7 @@ void CGameCounter::Spawn( void ) void CGameCounter::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; switch( useType ) @@ -681,16 +681,16 @@ void CGameCounter::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE SetCountValue( (int)value ); break; } - - if ( HitLimit() ) + + if( HitLimit() ) { SUB_UseTargets( pActivator, USE_TOGGLE, 0 ); - if ( RemoveOnFire() ) + if( RemoveOnFire() ) { UTIL_Remove( this ); } - - if ( ResetOnFire() ) + + if( ResetOnFire() ) { ResetCount(); } @@ -716,12 +716,12 @@ LINK_ENTITY_TO_CLASS( game_counter_set, CGameCounterSet ) void CGameCounterSet::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; SUB_UseTargets( pActivator, USE_SET, pev->frags ); - if ( RemoveOnFire() ) + if( RemoveOnFire() ) { UTIL_Remove( this ); } @@ -756,19 +756,19 @@ void CGamePlayerEquip::KeyValue( KeyValueData *pkvd ) { CRulePointEntity::KeyValue( pkvd ); - if ( !pkvd->fHandled ) + if( !pkvd->fHandled ) { - for ( int i = 0; i < MAX_EQUIP; i++ ) + for( int i = 0; i < MAX_EQUIP; i++ ) { - if ( !m_weaponNames[i] ) + if( !m_weaponNames[i] ) { char tmp[128]; UTIL_StripToken( pkvd->szKeyName, tmp ); - m_weaponNames[i] = ALLOC_STRING(tmp); - m_weaponCount[i] = atoi(pkvd->szValue); - m_weaponCount[i] = max(1,m_weaponCount[i]); + m_weaponNames[i] = ALLOC_STRING( tmp ); + m_weaponCount[i] = atoi( pkvd->szValue ); + m_weaponCount[i] = max( 1, m_weaponCount[i] ); pkvd->fHandled = TRUE; break; } @@ -778,10 +778,10 @@ void CGamePlayerEquip::KeyValue( KeyValueData *pkvd ) void CGamePlayerEquip::Touch( CBaseEntity *pOther ) { - if ( !CanFireForActivator( pOther ) ) + if( !CanFireForActivator( pOther ) ) return; - if ( UseOnly() ) + if( UseOnly() ) return; EquipPlayer( pOther ); @@ -791,21 +791,21 @@ void CGamePlayerEquip::EquipPlayer( CBaseEntity *pEntity ) { CBasePlayer *pPlayer = NULL; - if ( pEntity->IsPlayer() ) + if( pEntity->IsPlayer() ) { pPlayer = (CBasePlayer *)pEntity; } - if ( !pPlayer ) + if( !pPlayer ) return; - for ( int i = 0; i < MAX_EQUIP; i++ ) + for( int i = 0; i < MAX_EQUIP; i++ ) { - if ( !m_weaponNames[i] ) + if( !m_weaponNames[i] ) break; - for ( int j = 0; j < m_weaponCount[i]; j++ ) + for( int j = 0; j < m_weaponCount[i]; j++ ) { - pPlayer->GiveNamedItem( STRING(m_weaponNames[i]) ); + pPlayer->GiveNamedItem( STRING( m_weaponNames[i] ) ); } } } @@ -844,9 +844,9 @@ const char *CGamePlayerTeam::TargetTeamName( const char *pszTargetName ) { CBaseEntity *pTeamEntity = NULL; - while ((pTeamEntity = UTIL_FindEntityByTargetname( pTeamEntity, pszTargetName )) != NULL) + while( ( pTeamEntity = UTIL_FindEntityByTargetname( pTeamEntity, pszTargetName ) ) != NULL ) { - if ( FClassnameIs( pTeamEntity->pev, "game_team_master" ) ) + if( FClassnameIs( pTeamEntity->pev, "game_team_master" ) ) return pTeamEntity->TeamID(); } @@ -855,10 +855,10 @@ const char *CGamePlayerTeam::TargetTeamName( const char *pszTargetName ) void CGamePlayerTeam::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; - if ( pActivator->IsPlayer() ) + if( pActivator->IsPlayer() ) { const char *pszTargetTeam = TargetTeamName( STRING(pev->target) ); if ( pszTargetTeam ) @@ -868,7 +868,7 @@ void CGamePlayerTeam::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY } } - if ( RemoveOnFire() ) + if( RemoveOnFire() ) { UTIL_Remove( this ); } diff --git a/dlls/plats.cpp b/dlls/plats.cpp index 00b05bec..3034fd93 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -104,111 +104,100 @@ void CBasePlatTrain::KeyValue( KeyValueData *pkvd ) void CBasePlatTrain::Precache( void ) { + const char *pszSound; + BOOL NullSound = FALSE; + // set the plat's "in-motion" sound switch( m_bMoveSnd ) { - case 0: - pev->noiseMoving = MAKE_STRING( "common/null.wav" ); - break; case 1: - PRECACHE_SOUND( "plats/bigmove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/bigmove1.wav" ); + pszSound = "plats/bigmove1.wav"; break; case 2: - PRECACHE_SOUND( "plats/bigmove2.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/bigmove2.wav" ); + pszSound = "plats/bigmove2.wav"; break; case 3: - PRECACHE_SOUND( "plats/elevmove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/elevmove1.wav" ); + pszSound = "plats/elevmove1.wav"; break; case 4: - PRECACHE_SOUND( "plats/elevmove2.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/elevmove2.wav" ); + pszSound = "plats/elevmove2.wav"; break; case 5: - PRECACHE_SOUND( "plats/elevmove3.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/elevmove3.wav" ); + pszSound = "plats/elevmove3.wav"; break; case 6: - PRECACHE_SOUND( "plats/freightmove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/freightmove1.wav" ); + pszSound = "plats/freightmove1.wav"; break; case 7: - PRECACHE_SOUND( "plats/freightmove2.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/freightmove2.wav" ); + pszSound = "plats/freightmove2.wav"; break; case 8: - PRECACHE_SOUND( "plats/heavymove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/heavymove1.wav" ); + pszSound = "plats/heavymove1.wav"; break; case 9: - PRECACHE_SOUND( "plats/rackmove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/rackmove1.wav" ); + pszSound = "plats/rackmove1.wav"; break; case 10: - PRECACHE_SOUND( "plats/railmove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/railmove1.wav" ); + pszSound = "plats/railmove1.wav"; break; case 11: - PRECACHE_SOUND( "plats/squeekmove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/squeekmove1.wav" ); + pszSound = "plats/squeekmove1.wav"; break; case 12: - PRECACHE_SOUND( "plats/talkmove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/talkmove1.wav" ); + pszSound = "plats/talkmove1.wav"; break; case 13: - PRECACHE_SOUND( "plats/talkmove2.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/talkmove2.wav" ); + pszSound = "plats/talkmove2.wav"; break; + case 0: default: - pev->noiseMoving = MAKE_STRING( "common/null.wav" ); + pszSound = "common/null.wav"; + NullSound = TRUE; break; } + if( !NullSound ) + PRECACHE_SOUND( pszSound ); + pev->noiseMoving = MAKE_STRING( pszSound ); + NullSound = FALSE; + // set the plat's 'reached destination' stop sound switch( m_bStopSnd ) { - case 0: - pev->noiseArrived = MAKE_STRING( "common/null.wav" ); - break; case 1: - PRECACHE_SOUND( "plats/bigstop1.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/bigstop1.wav" ); + pszSound = "plats/bigstop1.wav"; break; case 2: - PRECACHE_SOUND( "plats/bigstop2.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/bigstop2.wav" ); + pszSound = "plats/bigstop2.wav"; break; case 3: - PRECACHE_SOUND( "plats/freightstop1.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/freightstop1.wav" ); + pszSound = "plats/freightstop1.wav"; break; case 4: - PRECACHE_SOUND( "plats/heavystop2.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/heavystop2.wav" ); + pszSound = "plats/heavystop2.wav"; break; case 5: - PRECACHE_SOUND( "plats/rackstop1.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/rackstop1.wav" ); + pszSound = "plats/rackstop1.wav"; break; case 6: - PRECACHE_SOUND( "plats/railstop1.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/railstop1.wav" ); + pszSound = "plats/railstop1.wav"; break; case 7: - PRECACHE_SOUND( "plats/squeekstop1.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/squeekstop1.wav" ); + pszSound = "plats/squeekstop1.wav"; break; case 8: - PRECACHE_SOUND( "plats/talkstop1.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/talkstop1.wav" ); + pszSound = "plats/talkstop1.wav"; break; + case 0: default: - pev->noiseArrived = MAKE_STRING( "common/null.wav" ); + pszSound = "common/null.wav"; + NullSound = TRUE; break; } + + if( !NullSound ) + PRECACHE_SOUND( pszSound ); + pev->noiseArrived = MAKE_STRING( pszSound ); } // @@ -1482,6 +1471,8 @@ void CFuncTrackTrain::Spawn( void ) void CFuncTrackTrain::Precache( void ) { + const char *pszSound; + if( m_flVolume == 0.0 ) m_flVolume = 1.0; @@ -1489,34 +1480,36 @@ void CFuncTrackTrain::Precache( void ) { default: // no sound - pev->noise = 0; + pszSound = NULL; break; case 1: - PRECACHE_SOUND( "plats/ttrain1.wav" ); - pev->noise = MAKE_STRING("plats/ttrain1.wav" ); + pszSound = "plats/ttrain1.wav"; break; case 2: - PRECACHE_SOUND( "plats/ttrain2.wav" ); - pev->noise = MAKE_STRING( "plats/ttrain2.wav" ); + pszSound = "plats/ttrain2.wav"; break; case 3: - PRECACHE_SOUND( "plats/ttrain3.wav" ); - pev->noise = MAKE_STRING( "plats/ttrain3.wav" ); + pszSound = "plats/ttrain3.wav"; break; case 4: - PRECACHE_SOUND( "plats/ttrain4.wav" ); - pev->noise = MAKE_STRING( "plats/ttrain4.wav" ); + pszSound = "plats/ttrain4.wav"; break; case 5: - PRECACHE_SOUND( "plats/ttrain6.wav" ); - pev->noise = MAKE_STRING( "plats/ttrain6.wav" ); + pszSound = "plats/ttrain6.wav"; break; case 6: - PRECACHE_SOUND( "plats/ttrain7.wav" ); - pev->noise = MAKE_STRING( "plats/ttrain7.wav" ); + pszSound = "plats/ttrain7.wav"; break; } + if( !pszSound ) + { + PRECACHE_SOUND( pszSound ); + pev->noise = MAKE_STRING( pszSound ); + } + else + pev->noise = 0; + PRECACHE_SOUND( "plats/ttrain_brake1.wav" ); PRECACHE_SOUND( "plats/ttrain_start1.wav" ); diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index 2959d96d..57d8d031 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -1689,7 +1689,7 @@ void NextLevel( void ) // go back to start if no trigger_changelevel if( FNullEnt( pent ) ) { - gpGlobals->mapname = ALLOC_STRING( "start" ); + gpGlobals->mapname = MAKE_STRING( "start" ); pChange = GetClassPtr( (CChangeLevel *)NULL ); strcpy( pChange->m_szMapName, "start" ); } From 14e75025bb64f730fa42081fa594c397ca064b2d Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 20 Jul 2017 10:33:39 +0500 Subject: [PATCH 092/144] Show long nicknames in scoreboard. Show fulli nicknames in scoreboard. --- cl_dll/scoreboard.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cl_dll/scoreboard.cpp b/cl_dll/scoreboard.cpp index b20e316c..3adbaab6 100644 --- a/cl_dll/scoreboard.cpp +++ b/cl_dll/scoreboard.cpp @@ -92,7 +92,7 @@ We have a minimum width of 1-320 - we could have the field widths scale with it? // X positions // relative to the side of the scoreboard -#define NAME_RANGE_MIN 20 +#define NAME_RANGE_MIN -100 #define NAME_RANGE_MAX 145 #define KILLS_RANGE_MIN 130 #define KILLS_RANGE_MAX 170 @@ -145,7 +145,7 @@ int CHudScoreboard::Draw( float fTime ) int xpos = NAME_RANGE_MIN + xpos_rel; FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX; - FAR_RIGHT += 5; + FAR_RIGHT += 125; if( cl_scoreboard_bg && cl_scoreboard_bg->value ) gHUD.DrawDarkRectangle( xpos - 5, ypos - 5, FAR_RIGHT, ROW_RANGE_MAX ); if( !gHUD.m_Teamplay ) @@ -340,7 +340,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, } FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX; - FAR_RIGHT += 5; + FAR_RIGHT += 125; // draw the players, in order, and restricted to team if set while( 1 ) From 7a5c29cbc9f68bf1fbfe1a454ae351721155b640 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 20 Jul 2017 10:51:34 +0500 Subject: [PATCH 093/144] Clear any effects on disconnect. --- dlls/client.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dlls/client.cpp b/dlls/client.cpp index 480a9506..3e23821f 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -125,6 +125,7 @@ void ClientDisconnect( edict_t *pEntity ) // since the edict doesn't get deleted, fix it so it doesn't interfere. pEntity->v.takedamage = DAMAGE_NO;// don't attract autoaim pEntity->v.solid = SOLID_NOT;// nonsolid + pEntity->v.effects = 0;// clear any effects UTIL_SetOrigin( &pEntity->v, pEntity->v.origin ); g_pGameRules->ClientDisconnected( pEntity ); From ea8f2bed7715b48bdf012b1c6bcbcf8881e5400a Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 20 Jul 2017 12:13:04 +0500 Subject: [PATCH 094/144] Implement cl_viewbob cvar for viewmodel bobbing. Same as in http://am.half-lifecreations.com/forums/index.php?topic=288.0 --- cl_dll/hud.cpp | 2 ++ cl_dll/view.cpp | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index 0f3b45bc..05bda284 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -35,6 +35,7 @@ extern client_sprite_t *GetSpriteList( client_sprite_t *pList, const char *psz, extern cvar_t *sensitivity; cvar_t *cl_lw = NULL; +cvar_t *cl_viewbob = NULL; void ShutdownInput( void ); @@ -194,6 +195,7 @@ void CHud::Init( void ) m_pCvarStealMouse = CVAR_CREATE( "hud_capturemouse", "1", FCVAR_ARCHIVE ); m_pCvarDraw = CVAR_CREATE( "hud_draw", "1", FCVAR_ARCHIVE ); cl_lw = gEngfuncs.pfnGetCvarPointer( "cl_lw" ); + cl_viewbob = CVAR_CREATE( "cl_viewbob", "0", FCVAR_ARCHIVE ); m_pSpriteList = NULL; diff --git a/cl_dll/view.cpp b/cl_dll/view.cpp index dcd2b1af..efa4b104 100644 --- a/cl_dll/view.cpp +++ b/cl_dll/view.cpp @@ -78,6 +78,7 @@ extern cvar_t *cl_forwardspeed; extern cvar_t *chase_active; extern cvar_t *scr_ofsx, *scr_ofsy, *scr_ofsz; extern cvar_t *cl_vsmoothing; +extern cvar_t *cl_viewbob; extern Vector dead_viewangles; #define CAM_MODE_RELAX 1 @@ -527,7 +528,7 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) V_AddIdle( pparams ); // offsets - if ( pparams->health <= 0 ) + if( pparams->health <= 0 ) { VectorCopy( dead_viewangles, angles ); } @@ -598,6 +599,9 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) view->angles[ROLL] -= bob * 1; view->angles[PITCH] -= bob * 0.3; + if( cl_viewbob && cl_viewbob->value ) + VectorCopy( view->angles, view->curstate.angles ); + // pushing the view origin down off of the same X/Z plane as the ent's origin will give the // gun a very nice 'shifting' effect when the player looks up/down. If there is a problem // with view model distortion, this may be a cause. (SJB). From c9ac2c6dabf511a5b68526876d47a8579c2bf02c Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 20 Jul 2017 12:22:02 +0500 Subject: [PATCH 095/144] Implement mp_satchelfix cvar. --- dlls/doors.cpp | 10 +++++++--- dlls/game.cpp | 2 ++ dlls/game.h | 1 + dlls/player.cpp | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/dlls/doors.cpp b/dlls/doors.cpp index ce901ee8..61a04ed2 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -22,6 +22,7 @@ #include "util.h" #include "cbase.h" #include "doors.h" +#include "game.h" #include "weapons.h" extern void SetMovedir( entvars_t *ev ); @@ -737,9 +738,12 @@ void CBaseDoor::Blocked( CBaseEntity *pOther ) if( pev->dmg ) pOther->TakeDamage( pev, pev, pev->dmg, DMG_CRUSH ); - // Detonate satchels - if( !strcmp( "monster_satchel", STRING( pOther->pev->classname ) ) ) - ( (CSatchel*)pOther )->Use( this, this, USE_ON, 0 ); + if( satchelfix.value ) + { + // Detonate satchels + if( !strcmp( "monster_satchel", STRING( pOther->pev->classname ) ) ) + ( (CSatchel*)pOther )->Use( this, this, USE_ON, 0 ); + } // if a door has a negative wait, it would never come back if blocked, // so let it just squash the object to death real fast diff --git a/dlls/game.cpp b/dlls/game.cpp index b109f376..4354a63d 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -31,6 +31,7 @@ cvar_t friendlyfire = { "mp_friendlyfire","0", FCVAR_SERVER }; cvar_t falldamage = { "mp_falldamage","0", FCVAR_SERVER }; cvar_t weaponstay = { "mp_weaponstay","0", FCVAR_SERVER }; cvar_t selfgauss = { "mp_selfgauss", "1", FCVAR_SERVER }; +cvar_t satchelfix = { "mp_satchelfix", "0", FCVAR_SERVER }; cvar_t forcerespawn = { "mp_forcerespawn","1", FCVAR_SERVER }; cvar_t flashlight = { "mp_flashlight","0", FCVAR_SERVER }; cvar_t aimcrosshair = { "mp_autocrosshair","1", FCVAR_SERVER }; @@ -469,6 +470,7 @@ void GameDLLInit( void ) CVAR_REGISTER( &falldamage ); CVAR_REGISTER( &weaponstay ); CVAR_REGISTER( &selfgauss ); + CVAR_REGISTER( &satchelfix ); CVAR_REGISTER( &forcerespawn ); CVAR_REGISTER( &flashlight ); CVAR_REGISTER( &aimcrosshair ); diff --git a/dlls/game.h b/dlls/game.h index e29b2563..a6d0cd1c 100644 --- a/dlls/game.h +++ b/dlls/game.h @@ -28,6 +28,7 @@ extern cvar_t friendlyfire; extern cvar_t falldamage; extern cvar_t weaponstay; extern cvar_t selfgauss; +extern cvar_t satchelfix; extern cvar_t forcerespawn; extern cvar_t flashlight; extern cvar_t aimcrosshair; diff --git a/dlls/player.cpp b/dlls/player.cpp index 0d86caf8..1a7bc206 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -823,7 +823,9 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) for( i = 0; i < MAX_AMMO_SLOTS; i++ ) m_rgAmmo[i] = 0; - DeactivateSatchels( this ); + if( satchelfix.value ) + DeactivateSatchels( this ); + UpdateClientData(); // send Selected Weapon Message to our client From d1fbb99574d66c35de21a3b3b45a7c137b33f6e0 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 20 Jul 2017 23:32:06 +0500 Subject: [PATCH 096/144] Fix some warnings yet. --- cl_dll/cl_util.h | 2 +- cl_dll/hud_spectator.cpp | 10 +++---- cl_dll/hud_spectator.h | 4 +-- dlls/client.cpp | 4 +-- dlls/doors.cpp | 2 +- dlls/multiplay_gamerules.cpp | 2 +- dlls/nihilanth.cpp | 20 +++++++------- engine/cdll_int.h | 52 ++++++++++++++++++------------------ 8 files changed, 48 insertions(+), 48 deletions(-) diff --git a/cl_dll/cl_util.h b/cl_dll/cl_util.h index 22555caa..1996543d 100644 --- a/cl_dll/cl_util.h +++ b/cl_dll/cl_util.h @@ -144,7 +144,7 @@ inline void CenterPrint( const char *string ) #define GetPlayerInfo ( *gEngfuncs.pfnGetPlayerInfo ) // sound functions -inline void PlaySound( char *szSound, float vol ) { gEngfuncs.pfnPlaySoundByName( szSound, vol ); } +inline void PlaySound( const char *szSound, float vol ) { gEngfuncs.pfnPlaySoundByName( szSound, vol ); } inline void PlaySound( int iSound, float vol ) { gEngfuncs.pfnPlaySoundByIndex( iSound, vol ); } #define max(a, b) (((a) > (b)) ? (a) : (b)) diff --git a/cl_dll/hud_spectator.cpp b/cl_dll/hud_spectator.cpp index ff6eb8ff..5ffce74a 100644 --- a/cl_dll/hud_spectator.cpp +++ b/cl_dll/hud_spectator.cpp @@ -175,13 +175,13 @@ void UTIL_StringToVector( float * pVector, const char *pString ) } } -int UTIL_FindEntityInMap( char * name, float * origin, float * angle ) +int UTIL_FindEntityInMap( const char *name, float *origin, float *angle ) { int n, found = 0; char keyname[256]; char token[2048]; - cl_entity_t * pEnt = gEngfuncs.GetEntityByIndex( 0 ); // get world model + cl_entity_t *pEnt = gEngfuncs.GetEntityByIndex( 0 ); // get world model if( !pEnt ) return 0; @@ -189,7 +189,7 @@ int UTIL_FindEntityInMap( char * name, float * origin, float * angle ) if( !pEnt->model ) return 0; - char * data = pEnt->model->entities; + char *data = pEnt->model->entities; while( data ) { @@ -1374,12 +1374,12 @@ void CHudSpectator::DeathMessage( int victim ) AddOverviewEntityToList(m_hsprPlayerDead, pl, gEngfuncs.GetClientTime() + 2.0f ); } -bool CHudSpectator::AddOverviewEntityToList(HSPRITE sprite, cl_entity_t *ent, double killTime) +bool CHudSpectator::AddOverviewEntityToList( HSPRITE sprite, cl_entity_t *ent, double killTime ) { for( int i = 0; i < MAX_OVERVIEW_ENTITIES; i++ ) { // find empty entity slot - if( m_OverviewEntities[i].entity == NULL) + if( m_OverviewEntities[i].entity == NULL ) { m_OverviewEntities[i].entity = ent; m_OverviewEntities[i].hSprite = sprite; diff --git a/cl_dll/hud_spectator.h b/cl_dll/hud_spectator.h index f60353db..58026668 100644 --- a/cl_dll/hud_spectator.h +++ b/cl_dll/hud_spectator.h @@ -64,11 +64,11 @@ public: void CheckOverviewEntities(); void DrawOverview(); void DrawOverviewEntities(); - void GetMapPosition( float * returnvec ); + void GetMapPosition( float *returnvec ); void DrawOverviewLayer(); void LoadMapSprites(); bool ParseOverviewFile(); - bool IsActivePlayer( cl_entity_t * ent ); + bool IsActivePlayer( cl_entity_t *ent ); void SetModes( int iMainMode, int iInsetMode ); void HandleButtonsDown( int ButtonPressed ); void HandleButtonsUp( int ButtonPressed ); diff --git a/dlls/client.cpp b/dlls/client.cpp index 3e23821f..569b1a53 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -566,7 +566,7 @@ void ClientCommand( edict_t *pEntity ) // notify other clients of player switching to spectator mode UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s switched to spectator mode\n", - ( pev->netname && STRING(pev->netname)[0] != 0 ) ? STRING(pev->netname) : "unconnected" ) ); + ( pev->netname && ( STRING( pev->netname ) )[0] != 0 ) ? STRING( pev->netname ) : "unconnected" ) ); } else ClientPrint( pev, HUD_PRINTCONSOLE, "Spectator mode is disabled.\n" ); @@ -629,7 +629,7 @@ void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ) return; // msg everyone if someone changes their name, and it isn't the first time (changing no name to current name) - if( pEntity->v.netname && STRING( pEntity->v.netname )[0] != 0 && !FStrEq( STRING( pEntity->v.netname ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ) ) + if( pEntity->v.netname && ( STRING( pEntity->v.netname ) )[0] != 0 && !FStrEq( STRING( pEntity->v.netname ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ) ) { char sName[256]; char *pName = g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ); diff --git a/dlls/doors.cpp b/dlls/doors.cpp index 61a04ed2..90678df6 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -397,7 +397,7 @@ void CBaseDoor::Precache( void ) pszSound = "doors/doorstop5.wav"; break; case 6: - pszSound = "doors/doorstop6.wav" + pszSound = "doors/doorstop6.wav"; break; case 7: pszSound = "doors/doorstop7.wav"; diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index 494ac4f6..a898158f 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -423,7 +423,7 @@ void CHalfLifeMultiplay::InitHUD( CBasePlayer *pl ) { // notify other clients of player joining the game UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s has joined the game\n", - ( pl->pev->netname && STRING( pl->pev->netname )[0] != 0 ) ? STRING( pl->pev->netname ) : "unconnected" ) ); + ( pl->pev->netname && ( STRING( pl->pev->netname ) )[0] != 0 ) ? STRING( pl->pev->netname ) : "unconnected" ) ); // team match? if( g_teamplay ) diff --git a/dlls/nihilanth.cpp b/dlls/nihilanth.cpp index 1f9b0f88..34375a58 100644 --- a/dlls/nihilanth.cpp +++ b/dlls/nihilanth.cpp @@ -642,14 +642,14 @@ void CNihilanth::MakeFriend( Vector vecStart ) for( i = 0; i < 3; i++ ) { - if( m_hFriend[i] != NULL && !m_hFriend[i]->IsAlive() ) + if( m_hFriend[i] != 0 && !m_hFriend[i]->IsAlive() ) { if( pev->rendermode == kRenderNormal ) // don't do it if they are already fading m_hFriend[i]->MyMonsterPointer()->FadeMonster(); m_hFriend[i] = NULL; } - if( m_hFriend[i] == NULL ) + if( m_hFriend[i] == 0 ) { if( RANDOM_LONG( 0, 1 ) == 0 ) { @@ -675,7 +675,7 @@ void CNihilanth::MakeFriend( Vector vecStart ) m_hFriend[i] = Create( "monster_alien_slave", node.m_vecOrigin, pev->angles ); } } - if( m_hFriend[i] != NULL ) + if( m_hFriend[i] != 0 ) { EMIT_SOUND( m_hFriend[i]->edict(), CHAN_WEAPON, "debris/beamstart7.wav", 1.0, ATTN_NORM ); } @@ -722,7 +722,7 @@ void CNihilanth::NextActivity() } } - if( ( pev->health < gSkillData.nihilanthHealth / 2 || m_iActiveSpheres < N_SPHERES / 2 ) && m_hRecharger == NULL && m_iLevel <= 9 ) + if( ( pev->health < gSkillData.nihilanthHealth / 2 || m_iActiveSpheres < N_SPHERES / 2 ) && m_hRecharger == 0 && m_iLevel <= 9 ) { char szName[64]; @@ -881,7 +881,7 @@ void CNihilanth::HuntThink( void ) } // look for current enemy - if( m_hEnemy != 0 && m_hRecharger == NULL ) + if( m_hEnemy != 0 && m_hRecharger == 0 ) { if( FVisible( m_hEnemy ) ) { @@ -1057,7 +1057,7 @@ void CNihilanth::HandleAnimEvent( MonsterEvent_t *pEvent ) break; case 2: // zen - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( RANDOM_LONG( 0, 4 ) == 0 ) EMIT_SOUND( edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY( pAttackSounds ), 1.0, 0.2 ); @@ -1098,7 +1098,7 @@ void CNihilanth::HandleAnimEvent( MonsterEvent_t *pEvent ) break; case 3: // prayer - if (m_hEnemy != NULL) + if( m_hEnemy != 0 ) { char szText[32]; @@ -1178,7 +1178,7 @@ void CNihilanth::HandleAnimEvent( MonsterEvent_t *pEvent ) } break; case 6: - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { Vector vecSrc, vecAngles; GetAttachment( 2, vecSrc, vecAngles ); @@ -1208,7 +1208,7 @@ void CNihilanth::CommandUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ CBaseEntity *pTouch = UTIL_FindEntityByTargetname( NULL, m_szDeadTouch ); if( pTouch ) { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { pTouch->Touch( m_hEnemy ); } @@ -1597,7 +1597,7 @@ void CNihilanthHVR::TeleportThink( void ) if( m_hTargetEnt != 0 ) m_hTargetEnt->Use( m_hEnemy, m_hEnemy, USE_ON, 1.0 ); - if( m_hTouch != 0 && m_hEnemy != NULL ) + if( m_hTouch != 0 && m_hEnemy != 0 ) m_hTouch->Touch( m_hEnemy ); } else diff --git a/engine/cdll_int.h b/engine/cdll_int.h index 056146b4..d45bb9d5 100644 --- a/engine/cdll_int.h +++ b/engine/cdll_int.h @@ -128,7 +128,7 @@ typedef struct cl_enginefuncs_s void (*pfnSPR_DrawAdditive)( int frame, int x, int y, const wrect_t *prc ); void (*pfnSPR_EnableScissor)( int x, int y, int width, int height ); void (*pfnSPR_DisableScissor)( void ); - client_sprite_t *(*pfnSPR_GetList)( char *psz, int *piCount ); + client_sprite_t *(*pfnSPR_GetList)( const char *psz, int *piCount ); // screen handlers void (*pfnFillRGBA)( int x, int y, int width, int height, int r, int g, int b, int a ); @@ -136,20 +136,20 @@ typedef struct cl_enginefuncs_s void (*pfnSetCrosshair)( HSPRITE hspr, wrect_t rc, int r, int g, int b ); // cvar handlers - struct cvar_s *(*pfnRegisterVariable)( char *szName, char *szValue, int flags ); - float (*pfnGetCvarFloat)( char *szName ); - char* (*pfnGetCvarString)( char *szName ); + struct cvar_s *(*pfnRegisterVariable)( const char *szName, const char *szValue, int flags ); + float (*pfnGetCvarFloat)( const char *szName ); + char* (*pfnGetCvarString)( const char *szName ); // command handlers - int (*pfnAddCommand)( char *cmd_name, void (*function)(void) ); - int (*pfnHookUserMsg)( char *szMsgName, pfnUserMsgHook pfn ); - int (*pfnServerCmd)( char *szCmdString ); - int (*pfnClientCmd)( char *szCmdString ); + int (*pfnAddCommand)( const char *cmd_name, void (*function)(void) ); + int (*pfnHookUserMsg)( const char *szMsgName, pfnUserMsgHook pfn ); + int (*pfnServerCmd)( const char *szCmdString ); + int (*pfnClientCmd)( const char *szCmdString ); void (*pfnGetPlayerInfo)( int ent_num, hud_player_info_t *pinfo ); // sound handlers - void (*pfnPlaySoundByName)( char *szSound, float volume ); + void (*pfnPlaySoundByName)( const char *szSound, float volume ); void (*pfnPlaySoundByIndex)( int iSound, float volume ); // vector helpers @@ -158,7 +158,7 @@ typedef struct cl_enginefuncs_s // text message system client_textmessage_t *(*pfnTextMessageGet)( const char *pName ); int (*pfnDrawCharacter)( int x, int y, int number, int r, int g, int b ); - int (*pfnDrawConsoleString)( int x, int y, char *string ); + int (*pfnDrawConsoleString)( int x, int y, const char *string ); void (*pfnDrawSetTextColor)( float r, float g, float b ); void (*pfnDrawConsoleStringLen)( const char *string, int *length, int *height ); @@ -171,19 +171,19 @@ typedef struct cl_enginefuncs_s void (*GetViewAngles)( float * ); void (*SetViewAngles)( float * ); int (*GetMaxClients)( void ); - void (*Cvar_SetValue)( char *cvar, float value ); + void (*Cvar_SetValue)( const char *cvar, float value ); int (*Cmd_Argc)( void ); char *(*Cmd_Argv)( int arg ); - void (*Con_Printf)( char *fmt, ... ); - void (*Con_DPrintf)( char *fmt, ... ); - void (*Con_NPrintf)( int pos, char *fmt, ... ); - void (*Con_NXPrintf)( struct con_nprint_s *info, char *fmt, ... ); + void (*Con_Printf)( const char *fmt, ... ); + void (*Con_DPrintf)( const char *fmt, ... ); + void (*Con_NPrintf)( int pos, const char *fmt, ... ); + void (*Con_NXPrintf)( struct con_nprint_s *info, const char *fmt, ... ); const char* (*PhysInfo_ValueForKey)( const char *key ); const char* (*ServerInfo_ValueForKey)( const char *key ); float (*GetClientMaxspeed)( void ); - int (*CheckParm)( char *parm, char **ppnext ); + int (*CheckParm)( const char *parm, const char **ppnext ); void (*Key_Event)( int key, int down ); void (*GetMousePosition)( int *mx, int *my ); @@ -212,7 +212,7 @@ typedef struct cl_enginefuncs_s void (*pfnWeaponAnim)( int iAnim, int body ); float (*pfnRandomFloat)( float flLow, float flHigh ); int (*pfnRandomLong)( int lLow, int lHigh ); - void (*pfnHookEvent)( char *name, void ( *pfnEvent )( struct event_args_s *args )); + void (*pfnHookEvent)( const char *name, void ( *pfnEvent )( struct event_args_s *args )); int (*Con_IsVisible) (); const char *(*pfnGetGameDirectory)( void ); struct cvar_s *(*pfnGetCvarPointer)( const char *szName ); @@ -223,8 +223,8 @@ typedef struct cl_enginefuncs_s void* (*VGui_GetPanel)( ); void (*VGui_ViewportPaintBackground)( int extents[4] ); - byte* (*COM_LoadFile)( char *path, int usehunk, int *pLength ); - char* (*COM_ParseFile)( char *data, char *token ); + byte* (*COM_LoadFile)( const char *path, int usehunk, int *pLength ); + char* (*COM_ParseFile)( const char *data, const char *token ); void (*COM_FreeFile)( void *buffer ); struct triangleapi_s *pTriAPI; @@ -252,7 +252,7 @@ typedef struct cl_enginefuncs_s // Gets a unique ID for the specified player. This is the same even if you see the player on a different server. // iPlayer is an entity index, so client 0 would use iPlayer=1. // Returns false if there is no player on the server in the specified slot. - qboolean (*GetPlayerUniqueID)(int iPlayer, char playerID[16]); + qboolean (*GetPlayerUniqueID)(int iPlayer, const char playerID[16]); // TrackerID access int (*GetTrackerIDForPlayer)(int playerSlot); @@ -260,7 +260,7 @@ typedef struct cl_enginefuncs_s // Same as pfnServerCmd, but the message goes in the unreliable stream so it can't clog the net stream // (but it might not get there). - int ( *pfnServerCmdUnreliable )( char *szCmdString ); + int ( *pfnServerCmdUnreliable )( const char *szCmdString ); void (*pfnGetMousePos)( struct tagPOINT *ppt ); void (*pfnSetMousePos)( int x, int y ); @@ -285,12 +285,12 @@ typedef struct cl_enginefuncs_s const char *(*LocalPlayerInfo_ValueForKey)( const char* key ); int (*pfnVGUI2DrawCharacter)( int x, int y, int ch, unsigned int font ); int (*pfnVGUI2DrawCharacterAdditive)( int x, int y, int ch, int r, int g, int b, unsigned int font ); - unsigned int (*pfnGetApproxWavePlayLen)( char *filename ); + unsigned int (*pfnGetApproxWavePlayLen)( const char *filename ); void* (*GetCareerGameUI)( void ); // g-cont. !!!! potential crash-point! - void (*Cvar_Set)( char *name, char *value ); + void (*Cvar_Set)( const char *name, const char *value ); int (*pfnIsPlayingCareerMatch)( void ); - void (*pfnPlaySoundVoiceByName)( char *szSound, float volume, int pitch ); - void (*pfnPrimeMusicStream)( char *filename, int looping ); + void (*pfnPlaySoundVoiceByName)( const char *szSound, float volume, int pitch ); + void (*pfnPrimeMusicStream)( const char *filename, int looping ); double (*pfnSys_FloatTime)( void ); // decay funcs @@ -298,7 +298,7 @@ typedef struct cl_enginefuncs_s void (*pfnConstructTutorMessageDecayBuffer)( int *buffer, int buflen ); void (*pfnResetTutorMessageDecayData)( void ); - void (*pfnPlaySoundByNameAtPitch)( char *szSound, float volume, int pitch ); + void (*pfnPlaySoundByNameAtPitch)( const char *szSound, float volume, int pitch ); void (*pfnFillRGBABlend)( int x, int y, int width, int height, int r, int g, int b, int a ); int (*pfnGetAppID)( void ); cmdalias_t *(*pfnGetAliases)( void ); From 58a5ca48be81a8d12995d4bd71f4ad9fee274ba7 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 20 Jul 2017 23:42:00 +0500 Subject: [PATCH 097/144] Add protection for vec3_t definition. --- common/mathlib.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/mathlib.h b/common/mathlib.h index fadb97fb..12fb972f 100644 --- a/common/mathlib.h +++ b/common/mathlib.h @@ -18,7 +18,12 @@ typedef float vec_t; typedef vec_t vec2_t[2]; + +#ifndef DID_VEC3_T_DEFINE +#define DID_VEC3_T_DEFINE typedef vec_t vec3_t[3]; +#endif + typedef vec_t vec4_t[4]; // x,y,z,w #ifndef M_PI From 3dc0939b40960f1a3e0c7ff9d68849e2dff0ccd7 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Fri, 21 Jul 2017 00:00:38 +0500 Subject: [PATCH 098/144] Prevent buffer overflow. --- cl_dll/text_message.cpp | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/cl_dll/text_message.cpp b/cl_dll/text_message.cpp index 9452cebb..b959fc87 100644 --- a/cl_dll/text_message.cpp +++ b/cl_dll/text_message.cpp @@ -162,42 +162,39 @@ int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf int msg_dest = READ_BYTE(); - static char szBuf[6][128]; - const char *msg_text = LookupString( READ_STRING(), &msg_dest ); - msg_text = strcpy( szBuf[0], msg_text ); - - // keep reading strings and using C format strings for subsituting the strings into the localised text string - const char *sstr1 = LookupString( READ_STRING() ); - sstr1 = strcpy( szBuf[1], sstr1 ); - StripEndNewlineFromString( (char*)sstr1 ); // these strings are meant for subsitution into the main strings, so cull the automatic end newlines - const char *sstr2 = LookupString( READ_STRING() ); - sstr2 = strcpy( szBuf[2], sstr2 ); - StripEndNewlineFromString( (char*)sstr2 ); - const char *sstr3 = LookupString( READ_STRING() ); - sstr3 = strcpy( szBuf[3], sstr3 ); - StripEndNewlineFromString( (char*)sstr3 ); - const char *sstr4 = LookupString( READ_STRING() ); - sstr4 = strcpy( szBuf[4], sstr4 ); - StripEndNewlineFromString( (char*)sstr4 ); +#define MSG_BUF_SIZE 128 + char szBuf[6][MSG_BUF_SIZE]; + + strncpy( szBuf[0], LookupString( READ_STRING(), &msg_dest ), MSG_BUF_SIZE - 1 ); + szBuf[0][MSG_BUF_SIZE - 1] = '\0'; + + for( int i = 1; i <= 4; i++ ) + { + // keep reading strings and using C format strings for subsituting the strings into the localised text string + strncpy( szBuf[i], LookupString( READ_STRING() ), MSG_BUF_SIZE - 1 ); + szBuf[i][MSG_BUF_SIZE - 1] = '\0'; + StripEndNewlineFromString( szBuf[i] ); // these strings are meant for subsitution into the main strings, so cull the automatic end newlines + } + char *psz = szBuf[5]; switch( msg_dest ) { case HUD_PRINTCENTER: - sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 ); + snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); CenterPrint( ConvertCRtoNL( psz ) ); break; case HUD_PRINTNOTIFY: psz[0] = 1; // mark this message to go into the notify buffer - sprintf( psz + 1, msg_text, sstr1, sstr2, sstr3, sstr4 ); + snprintf( psz + 1, MSG_BUF_SIZE - 1, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); ConsolePrint( ConvertCRtoNL( psz ) ); break; case HUD_PRINTTALK: - sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 ); - gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), 128 ); + snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); + gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), MSG_BUF_SIZE ); break; case HUD_PRINTCONSOLE: - sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 ); + snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); ConsolePrint( ConvertCRtoNL( psz ) ); break; } From cf9ba716862eb50da691a4daff272a61f0a0b674 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Fri, 21 Jul 2017 00:52:09 +0500 Subject: [PATCH 099/144] Make UpdateOnRemove() virtual. --- cl_dll/hl/hl_baseentity.cpp | 1 + dlls/cbase.h | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cl_dll/hl/hl_baseentity.cpp b/cl_dll/hl/hl_baseentity.cpp index d24c0ef4..acd537e0 100644 --- a/cl_dll/hl/hl_baseentity.cpp +++ b/cl_dll/hl/hl_baseentity.cpp @@ -55,6 +55,7 @@ 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( const char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) { return NULL; } +void CBaseEntity::UpdateOnRemove( void ) { } void CBaseEntity::SUB_Remove( void ) { } // CBaseDelay Stubs diff --git a/dlls/cbase.h b/dlls/cbase.h index 6c738bf5..b78de883 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -12,6 +12,8 @@ * without written permission from Valve LLC. * ****/ +#ifndef CBASE_H +#define CBASE_H /* Class Hierachy @@ -229,7 +231,7 @@ public: }; #endif - void UpdateOnRemove( void ); + virtual void UpdateOnRemove( void ); // common member functions void EXPORT SUB_Remove( void ); @@ -780,3 +782,4 @@ public: void Precache( void ); void KeyValue( KeyValueData *pkvd ); }; +#endif From 70c6e429076e746b1be4492b0c6f468ef7ea2174 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 23 Jul 2017 21:41:05 +0500 Subject: [PATCH 100/144] Merge https://github.com/LevShisterov/BugfixedHL/commit/68c9b7cf6bdcacdf267c2e2dab2415dbbebdfcd2 --- cl_dll/hl/hl_baseentity.cpp | 2 +- dlls/handgrenade.cpp | 3 +- dlls/player.cpp | 20 +++++---- dlls/player.h | 2 +- dlls/satchel.cpp | 83 +++++++++++++++++-------------------- dlls/squeakgrenade.cpp | 3 +- dlls/tripmine.cpp | 3 +- dlls/weapons.cpp | 18 ++++++-- 8 files changed, 68 insertions(+), 66 deletions(-) diff --git a/cl_dll/hl/hl_baseentity.cpp b/cl_dll/hl/hl_baseentity.cpp index acd537e0..38978f6a 100644 --- a/cl_dll/hl/hl_baseentity.cpp +++ b/cl_dll/hl/hl_baseentity.cpp @@ -277,7 +277,7 @@ void CBasePlayer::ForceClientDllUpdate( void ) { } void CBasePlayer::ImpulseCommands() { } void CBasePlayer::CheatImpulseCommands( int iImpulse ) { } int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) { return FALSE; } -int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) { return FALSE; } +int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem, bool bCallHoster ) { return FALSE; } void CBasePlayer::ItemPreFrame() { } void CBasePlayer::ItemPostFrame() { } int CBasePlayer::AmmoInventory( int iAmmoIndex ) { return -1; } diff --git a/dlls/handgrenade.cpp b/dlls/handgrenade.cpp index 2a31fc84..c2bbd7f9 100644 --- a/dlls/handgrenade.cpp +++ b/dlls/handgrenade.cpp @@ -99,8 +99,7 @@ void CHandGrenade::Holster( int skiplocal /* = 0 */ ) { // no more grenades! m_pPlayer->pev->weapons &= ~( 1 << WEAPON_HANDGRENADE ); - SetThink( &CBasePlayerItem::DestroyItem ); - pev->nextthink = gpGlobals->time + 0.1; + DestroyItem(); } if( m_flStartThrow ) diff --git a/dlls/player.cpp b/dlls/player.cpp index 1a7bc206..38038b36 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -666,8 +666,8 @@ void CBasePlayer::PackDeadPlayerItems( void ) int iWeaponRules; int iAmmoRules; int i; - CBasePlayerWeapon *rgpPackWeapons[20] = {0};// 20 hardcoded for now. How to determine exactly how many weapons we have? - int iPackAmmo[MAX_AMMO_SLOTS + 1]; + CBasePlayerWeapon *rgpPackWeapons[MAX_WEAPONS] = {}; + int iPackAmmo[MAX_AMMO_SLOTS]; int iPW = 0;// index into packweapons array int iPA = 0;// index into packammo array @@ -675,7 +675,7 @@ void CBasePlayer::PackDeadPlayerItems( void ) // get the game rules iWeaponRules = g_pGameRules->DeadPlayerWeapons( this ); - iAmmoRules = g_pGameRules->DeadPlayerAmmo( this ); + iAmmoRules = g_pGameRules->DeadPlayerAmmo( this ); if( iWeaponRules == GR_PLR_DROP_GUN_NO && iAmmoRules == GR_PLR_DROP_AMMO_NO ) { @@ -685,14 +685,14 @@ void CBasePlayer::PackDeadPlayerItems( void ) } // go through all of the weapons and make a list of the ones to pack - for( i = 0; i < MAX_ITEM_TYPES; i++ ) + for( i = 0; i < MAX_ITEM_TYPES && iPW < MAX_WEAPONS; i++ ) { if( m_rgpPlayerItems[i] ) { // there's a weapon here. Should I pack it? CBasePlayerItem *pPlayerItem = m_rgpPlayerItems[i]; - while( pPlayerItem ) + while( pPlayerItem && iPW < MAX_WEAPONS ) { switch( iWeaponRules ) { @@ -3640,14 +3640,16 @@ int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) return FALSE; } -int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) +int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem, bool bCallHolster ) { + pItem->pev->nextthink = 0;// crowbar may be trying to swing again, etc. + pItem->SetThink( NULL ); + if( m_pActiveItem == pItem ) { ResetAutoaim(); - pItem->Holster(); - pItem->pev->nextthink = 0;// crowbar may be trying to swing again, etc. - pItem->SetThink( NULL ); + if( bCallHolster ) + pItem->Holster(); m_pActiveItem = NULL; pev->viewmodel = 0; pev->weaponmodel = 0; diff --git a/dlls/player.h b/dlls/player.h index 8ff312ea..1c17556c 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -259,7 +259,7 @@ public: void AddPoints( int score, BOOL bAllowNegativeScore ); void AddPointsToTeam( int score, BOOL bAllowNegativeScore ); BOOL AddPlayerItem( CBasePlayerItem *pItem ); - BOOL RemovePlayerItem( CBasePlayerItem *pItem ); + BOOL RemovePlayerItem( CBasePlayerItem *pItem, bool bCallHoster ); void DropPlayerItem ( char *pszItemName ); BOOL HasPlayerItem( CBasePlayerItem *pCheckItem ); BOOL HasNamedPlayerItem( const char *pszItemName ); diff --git a/dlls/satchel.cpp b/dlls/satchel.cpp index 015b3483..dc8724bd 100644 --- a/dlls/satchel.cpp +++ b/dlls/satchel.cpp @@ -23,6 +23,13 @@ #include "player.h" #include "gamerules.h" +enum satchel_state +{ + SATCHEL_IDLE = 0, + SATCHEL_READY, + SATCHEL_RELOAD +}; + enum satchel_e { SATCHEL_IDLE1 = 0, @@ -194,7 +201,7 @@ int CSatchel::AddDuplicate( CBasePlayerItem *pOriginal ) { pSatchel = (CSatchel *)pOriginal; - if( pSatchel->m_chargeReady != 0 ) + if( pSatchel->m_chargeReady != SATCHEL_IDLE ) { // player has some satchels deployed. Refuse to add more. return FALSE; @@ -211,7 +218,7 @@ int CSatchel::AddToPlayer( CBasePlayer *pPlayer ) int bResult = CBasePlayerItem::AddToPlayer( pPlayer ); pPlayer->pev->weapons |= ( 1 << m_iId ); - m_chargeReady = 0;// this satchel charge weapon now forgets that any satchels are deployed by it. + m_chargeReady = SATCHEL_IDLE;// this satchel charge weapon now forgets that any satchels are deployed by it. if( bResult ) { @@ -263,19 +270,7 @@ int CSatchel::GetItemInfo( ItemInfo *p ) //========================================================= BOOL CSatchel::IsUseable( void ) { - if( m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] > 0 ) - { - // player is carrying some satchels - return TRUE; - } - - if( m_chargeReady != 0 ) - { - // player isn't carrying any satchels, but has some out - return TRUE; - } - - return FALSE; + return CanDeploy(); } BOOL CSatchel::CanDeploy( void ) @@ -286,7 +281,7 @@ BOOL CSatchel::CanDeploy( void ) return TRUE; } - if( m_chargeReady != 0 ) + if( m_chargeReady ) { // player isn't carrying any satchels, but has some out return TRUE; @@ -322,11 +317,10 @@ void CSatchel::Holster( int skiplocal /* = 0 */ ) } EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM ); - if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] && !m_chargeReady ) + if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] && m_chargeReady != SATCHEL_READY ) { m_pPlayer->pev->weapons &= ~( 1 << WEAPON_SATCHEL ); - SetThink( &CBasePlayerItem::DestroyItem ); - pev->nextthink = gpGlobals->time + 0.1; + DestroyItem(); } } @@ -334,38 +328,37 @@ void CSatchel::PrimaryAttack() { switch( m_chargeReady ) { - case 0: + case SATCHEL_IDLE: { - Throw(); + Throw(); } break; - case 1: + case SATCHEL_READY: { - SendWeaponAnim( SATCHEL_RADIO_FIRE ); + SendWeaponAnim( SATCHEL_RADIO_FIRE ); - edict_t *pPlayer = m_pPlayer->edict(); + edict_t *pPlayer = m_pPlayer->edict(); - CBaseEntity *pSatchel = NULL; + CBaseEntity *pSatchel = NULL; - while( ( pSatchel = UTIL_FindEntityInSphere( pSatchel, m_pPlayer->pev->origin, 4096 ) ) != NULL ) - { - if( FClassnameIs( pSatchel->pev, "monster_satchel" ) ) + while( ( pSatchel = UTIL_FindEntityInSphere( pSatchel, m_pPlayer->pev->origin, 4096 ) ) != NULL ) { - if( pSatchel->pev->owner == pPlayer ) + if( FClassnameIs( pSatchel->pev, "monster_satchel" ) ) { - pSatchel->Use( m_pPlayer, m_pPlayer, USE_ON, 0 ); - m_chargeReady = 2; + if( pSatchel->pev->owner == pPlayer ) + { + pSatchel->Use( m_pPlayer, m_pPlayer, USE_ON, 0 ); + } } } - } - m_chargeReady = 2; - m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; - break; + m_chargeReady = SATCHEL_RELOAD; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; + break; } - case 2: + case SATCHEL_RELOAD: // we're reloading, don't allow fire break; } @@ -373,7 +366,7 @@ void CSatchel::PrimaryAttack() void CSatchel::SecondaryAttack( void ) { - if( m_chargeReady != 2 ) + if( m_chargeReady != SATCHEL_RELOAD ) { Throw(); } @@ -403,8 +396,8 @@ void CSatchel::Throw( void ) // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); - m_chargeReady = 1; - + m_chargeReady = SATCHEL_READY; + m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; m_flNextPrimaryAttack = GetNextAttackDelay( 1.0 ); @@ -419,17 +412,17 @@ void CSatchel::WeaponIdle( void ) switch( m_chargeReady ) { - case 0: + case SATCHEL_IDLE: SendWeaponAnim( SATCHEL_FIDGET1 ); // use tripmine animations strcpy( m_pPlayer->m_szAnimExtention, "trip" ); break; - case 1: + case SATCHEL_READY: SendWeaponAnim( SATCHEL_RADIO_FIDGET1 ); // use hivehand animations strcpy( m_pPlayer->m_szAnimExtention, "hive" ); break; - case 2: + case SATCHEL_RELOAD: if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { m_chargeReady = 0; @@ -450,7 +443,7 @@ void CSatchel::WeaponIdle( void ) m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; - m_chargeReady = 0; + m_chargeReady = SATCHEL_IDLE; break; } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );// how long till we do this again. diff --git a/dlls/squeakgrenade.cpp b/dlls/squeakgrenade.cpp index 830cfab8..bfe17ed1 100644 --- a/dlls/squeakgrenade.cpp +++ b/dlls/squeakgrenade.cpp @@ -475,8 +475,7 @@ void CSqueak::Holster( int skiplocal /* = 0 */ ) if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { m_pPlayer->pev->weapons &= ~( 1 << WEAPON_SNARK ); - SetThink( &CBasePlayerItem::DestroyItem ); - pev->nextthink = gpGlobals->time + 0.1; + DestroyItem(); return; } diff --git a/dlls/tripmine.cpp b/dlls/tripmine.cpp index 60190604..94907bcd 100644 --- a/dlls/tripmine.cpp +++ b/dlls/tripmine.cpp @@ -418,8 +418,7 @@ void CTripmine::Holster( int skiplocal /* = 0 */ ) { // out of mines m_pPlayer->pev->weapons &= ~( 1 << WEAPON_TRIPMINE ); - SetThink( &CBasePlayerItem::DestroyItem ); - pev->nextthink = gpGlobals->time + 0.1; + DestroyItem(); } SendWeaponAnim( TRIPMINE_HOLSTER ); diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 05db43da..06bb1796 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -688,8 +688,8 @@ void CBasePlayerItem::DestroyItem( void ) { if( m_pPlayer ) { - // if attached to a player, remove. - m_pPlayer->RemovePlayerItem( this ); + // if attached to a player, remove. + m_pPlayer->RemovePlayerItem( this, false ); } Kill(); @@ -1140,7 +1140,17 @@ void CBasePlayerWeapon::RetireWeapon( void ) m_pPlayer->pev->weaponmodel = iStringNull; //m_pPlayer->pev->viewmodelindex = NULL; - g_pGameRules->GetNextBestWeapon( m_pPlayer, this ); + if( !g_pGameRules->GetNextBestWeapon( m_pPlayer, this ) ) + { + // Another weapon wasn't selected. Get rid of current one + if( m_pPlayer->m_pActiveItem == this ) + { + m_pPlayer->ResetAutoaim(); + m_pPlayer->m_pActiveItem->Holster(); + m_pPlayer->m_pLastItem = NULL; + m_pPlayer->m_pActiveItem = NULL; + } + } } //========================================================================= @@ -1340,7 +1350,7 @@ BOOL CWeaponBox::PackWeapon( CBasePlayerItem *pWeapon ) if( pWeapon->m_pPlayer ) { - if( !pWeapon->m_pPlayer->RemovePlayerItem( pWeapon ) ) + if( !pWeapon->m_pPlayer->RemovePlayerItem( pWeapon, true ) ) { // failed to unhook the weapon from the player! return FALSE; From 49e740c6f132969f7881c21ad3bdecb6aad84568 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 24 Jul 2017 02:24:55 +0500 Subject: [PATCH 101/144] Remove unneeded casts. --- dlls/agrunt.cpp | 14 ++++++------- dlls/animation.cpp | 2 +- dlls/bmodels.cpp | 16 +++++++-------- dlls/buttons.cpp | 26 +++++++++++------------ dlls/cbase.cpp | 2 +- dlls/doors.cpp | 28 ++++++++++++------------- dlls/effects.cpp | 25 +++++++++++----------- dlls/func_break.cpp | 8 ++++---- dlls/func_tank.cpp | 10 ++++----- dlls/gargantua.cpp | 22 ++++++++++---------- dlls/genericmonster.cpp | 2 +- dlls/h_cycler.cpp | 10 ++++----- dlls/islave.cpp | 8 ++++---- dlls/leech.cpp | 4 ++-- dlls/multiplay_gamerules.cpp | 28 ++++++++++++------------- dlls/nodes.cpp | 8 ++++---- dlls/nodes.h | 6 +++--- dlls/plats.cpp | 40 ++++++++++++++++++------------------ dlls/prop.cpp | 6 +++--- dlls/scripted.cpp | 4 ++-- dlls/sound.cpp | 8 ++++---- dlls/stats.cpp | 4 ++-- dlls/triggers.cpp | 8 ++++---- dlls/util.cpp | 10 ++++----- dlls/util.h | 2 +- dlls/weapons.cpp | 8 ++++---- dlls/world.cpp | 4 ++-- dlls/xen.cpp | 6 +++--- dlls/zombie.cpp | 14 ++++++------- 29 files changed, 166 insertions(+), 167 deletions(-) diff --git a/dlls/agrunt.cpp b/dlls/agrunt.cpp index c6583fb7..cb47ac65 100644 --- a/dlls/agrunt.cpp +++ b/dlls/agrunt.cpp @@ -613,25 +613,25 @@ void CAGrunt::Precache() PRECACHE_MODEL( "models/agrunt.mdl" ); for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackHitSounds[i] ); + PRECACHE_SOUND( pAttackHitSounds[i] ); for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackMissSounds[i] ); + PRECACHE_SOUND( pAttackMissSounds[i] ); for( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) - PRECACHE_SOUND( (char *)pIdleSounds[i] ); + PRECACHE_SOUND( pIdleSounds[i] ); for( i = 0; i < ARRAYSIZE( pDieSounds ); i++ ) - PRECACHE_SOUND( (char *)pDieSounds[i] ); + PRECACHE_SOUND( pDieSounds[i] ); for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND( (char *)pPainSounds[i] ); + PRECACHE_SOUND( pPainSounds[i] ); for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackSounds[i] ); + PRECACHE_SOUND( pAttackSounds[i] ); for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) - PRECACHE_SOUND( (char *)pAlertSounds[i] ); + PRECACHE_SOUND( pAlertSounds[i] ); PRECACHE_SOUND( "hassault/hw_shoot1.wav" ); diff --git a/dlls/animation.cpp b/dlls/animation.cpp index 5454f0e8..f84ec380 100644 --- a/dlls/animation.cpp +++ b/dlls/animation.cpp @@ -208,7 +208,7 @@ void SequencePrecache( void *pmodel, const char *pSequenceName ) ALERT( at_error, "Bad sound event %d in sequence %s :: %s (sound is \"%s\")\n", pevent[i].event, pstudiohdr->name, pSequenceName, pevent[i].options ); } - PRECACHE_SOUND( (char *)( gpGlobals->pStringBase + ALLOC_STRING( pevent[i].options ) ) ); + PRECACHE_SOUND( gpGlobals->pStringBase + ALLOC_STRING( pevent[i].options ) ); } } } diff --git a/dlls/bmodels.cpp b/dlls/bmodels.cpp index c48abbf9..fe56b6ac 100644 --- a/dlls/bmodels.cpp +++ b/dlls/bmodels.cpp @@ -402,7 +402,7 @@ void CFuncRotating::Spawn() } UTIL_SetOrigin( pev, pev->origin ); - SET_MODEL( ENT(pev), STRING(pev->model) ); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); SetUse( &CFuncRotating::RotatingUse ); // did level designer forget to assign speed? @@ -538,7 +538,7 @@ void CFuncRotating::RampPitchVol( int fUp ) pitch = PITCH_NORM - 1; // change the fan's vol and pitch - EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning ), + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, STRING( pev->noiseRunning ), fvol, m_flAttenuation, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch ); } @@ -560,7 +560,7 @@ void CFuncRotating::SpinUp( void ) 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 ), + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, STRING( pev->noiseRunning ), m_flVolume, m_flAttenuation, SND_CHANGE_PITCH | SND_CHANGE_VOL, FANPITCHMAX ); SetThink( &CFuncRotating::Rotate ); @@ -601,7 +601,7 @@ void CFuncRotating::SpinDown( void ) pev->avelocity = g_vecZero;// set speed in case we overshot // stop sound, we're done - EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning /* Stop */ ), + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, STRING( pev->noiseRunning /* Stop */ ), 0, 0, SND_STOP, (int)m_pitch ); SetThink( &CFuncRotating::Rotate ); @@ -630,7 +630,7 @@ void CFuncRotating::RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller, if( pev->avelocity != g_vecZero ) { SetThink( &CFuncRotating::SpinDown ); - //EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, (char *)STRING( pev->noiseStop ), + //EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, STRING( pev->noiseStop ), // m_flVolume, m_flAttenuation, 0, m_pitch ); pev->nextthink = pev->ltime + 0.1; @@ -638,7 +638,7 @@ void CFuncRotating::RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller, else// fan is not moving, so start it { SetThink( &CFuncRotating::SpinUp ); - EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning ), + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, STRING( pev->noiseRunning ), 0.01, m_flAttenuation, 0, FANPITCHMIN ); pev->nextthink = pev->ltime + 0.1; @@ -651,7 +651,7 @@ void CFuncRotating::RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller, // play stopping sound here SetThink( &CFuncRotating::SpinDown ); - // EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, (char *)STRING( pev->noiseStop ), + // EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, STRING( pev->noiseStop ), // m_flVolume, m_flAttenuation, 0, m_pitch ); pev->nextthink = pev->ltime + 0.1; @@ -659,7 +659,7 @@ void CFuncRotating::RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller, } else { - EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning ), + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, STRING( pev->noiseRunning ), m_flVolume, m_flAttenuation, 0, FANPITCHMAX ); pev->avelocity = pev->movedir * pev->speed; diff --git a/dlls/buttons.cpp b/dlls/buttons.cpp index 7ea9082a..90bc42e5 100644 --- a/dlls/buttons.cpp +++ b/dlls/buttons.cpp @@ -343,25 +343,25 @@ void CBaseButton::Precache( void ) m_ls.sUnlockedSentence = MAKE_STRING( "EA" ); break; case 2: // security door - m_ls.sUnlockedSentence = MAKE_STRING("ED"); + m_ls.sUnlockedSentence = MAKE_STRING( "ED" ); break; case 3: // blast door - m_ls.sUnlockedSentence = MAKE_STRING("EF"); + m_ls.sUnlockedSentence = MAKE_STRING( "EF" ); break; case 4: // fire door - m_ls.sUnlockedSentence = MAKE_STRING("EFIRE"); + m_ls.sUnlockedSentence = MAKE_STRING( "EFIRE" ); break; case 5: // chemical door - m_ls.sUnlockedSentence = MAKE_STRING("ECHEM"); + m_ls.sUnlockedSentence = MAKE_STRING( "ECHEM" ); break; case 6: // radiation door - m_ls.sUnlockedSentence = MAKE_STRING("ERAD"); + m_ls.sUnlockedSentence = MAKE_STRING( "ERAD" ); break; case 7: // gen containment - m_ls.sUnlockedSentence = MAKE_STRING("ECON"); + m_ls.sUnlockedSentence = MAKE_STRING( "ECON" ); break; case 8: // maintenance door - m_ls.sUnlockedSentence = MAKE_STRING("EH"); + m_ls.sUnlockedSentence = MAKE_STRING( "EH" ); break; default: m_ls.sUnlockedSentence = 0; @@ -426,7 +426,7 @@ int CBaseButton::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, fl if( code == BUTTON_RETURN ) { - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM ); // Toggle buttons fire when they get back to their "home" position if( !( pev->spawnflags & SF_BUTTON_TOGGLE ) ) @@ -657,7 +657,7 @@ void CBaseButton::ButtonUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ { if( !m_fStayPushed && FBitSet( pev->spawnflags, SF_BUTTON_TOGGLE ) ) { - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM ); //SUB_UseTargets( m_eoActivator ); ButtonReturn(); @@ -716,7 +716,7 @@ void CBaseButton::ButtonTouch( CBaseEntity *pOther ) if( code == BUTTON_RETURN ) { - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM ); SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 ); ButtonReturn(); } @@ -729,7 +729,7 @@ void CBaseButton::ButtonTouch( CBaseEntity *pOther ) // void CBaseButton::ButtonActivate() { - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM ); if( !UTIL_IsMasterTriggered( m_sMaster, m_hActivator ) ) { @@ -815,7 +815,7 @@ void CBaseButton::ButtonBackHome( void ) if( FBitSet( pev->spawnflags, SF_BUTTON_TOGGLE ) ) { - //EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); + //EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM ); SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 ); } @@ -1034,7 +1034,7 @@ void CMomentaryRotButton::KeyValue( KeyValueData *pkvd ) void CMomentaryRotButton::PlaySound( void ) { - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM ); } // BUGBUG: This design causes a latentcy. When the button is retriggered, the first impulse diff --git a/dlls/cbase.cpp b/dlls/cbase.cpp index 6009bfd5..8750bddf 100644 --- a/dlls/cbase.cpp +++ b/dlls/cbase.cpp @@ -605,7 +605,7 @@ int CBaseEntity::Restore( CRestore &restore ) mins = pev->mins; // Set model is about to destroy these maxs = pev->maxs; - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); UTIL_SetSize( pev, mins, maxs ); // Reset them } diff --git a/dlls/doors.cpp b/dlls/doors.cpp index 90678df6..c12cc3a0 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -127,7 +127,7 @@ void PlayLockSounds( entvars_t *pev, locksound_t *pls, int flocked, int fbutton if( fplaysound ) { // play 'door locked' sound - EMIT_SOUND( ENT( pev ), CHAN_ITEM, (char*)STRING( pls->sLockedSound ), fvol, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, STRING( pls->sLockedSound ), fvol, ATTN_NORM ); pls->flwaitSound = gpGlobals->time + flsoundwait; } @@ -164,7 +164,7 @@ void PlayLockSounds( entvars_t *pev, locksound_t *pls, int flocked, int fbutton // play 'door unlocked' sound if set if( fplaysound ) { - EMIT_SOUND( ENT( pev ), CHAN_ITEM, (char*)STRING( pls->sUnlockedSound ), fvol, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, STRING( pls->sUnlockedSound ), fvol, ATTN_NORM ); pls->flwaitSound = gpGlobals->time + flsoundwait; } @@ -606,7 +606,7 @@ void CBaseDoor::DoorGoUp( void ) // filter them out and leave a client stuck with looping door sounds! if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) 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 ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ), 1, ATTN_NORM ); m_toggle_state = TS_GOING_UP; @@ -646,8 +646,8 @@ void CBaseDoor::DoorHitTop( void ) { if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) { - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ) ); - EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseArrived ), 1, ATTN_NORM ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ) ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseArrived ), 1, ATTN_NORM ); } ASSERT( m_toggle_state == TS_GOING_UP ); @@ -686,7 +686,7 @@ void CBaseDoor::DoorGoDown( void ) { if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) 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 ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ), 1, ATTN_NORM ); #ifdef DOOR_ASSERT ASSERT( m_toggle_state == TS_AT_TOP ); #endif // DOOR_ASSERT @@ -706,8 +706,8 @@ void CBaseDoor::DoorHitBottom( void ) { if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) { - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ) ); - EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseArrived ), 1, ATTN_NORM ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ) ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseArrived ), 1, ATTN_NORM ); } ASSERT( m_toggle_state == TS_GOING_DOWN ); @@ -751,7 +751,7 @@ void CBaseDoor::Blocked( CBaseEntity *pOther ) { // BMod Start - Door sound fix. if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ) ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ) ); // BMod End if( m_toggle_state == TS_GOING_DOWN ) @@ -767,7 +767,7 @@ void CBaseDoor::Blocked( CBaseEntity *pOther ) // Block all door pieces with the same targetname here. if( !FStringNull( pev->targetname ) ) { - for(;;) + for( ; ; ) { pentTarget = FIND_ENTITY_BY_TARGETNAME( pentTarget, STRING( pev->targetname ) ); @@ -799,7 +799,7 @@ void CBaseDoor::Blocked( CBaseEntity *pOther ) } } if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ) ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ) ); if( pDoor->m_toggle_state == TS_GOING_DOWN ) pDoor->DoorGoUp(); @@ -1106,7 +1106,7 @@ void CMomentaryDoor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP // This entity only thinks when it moves, so if it's thinking, it's in the process of moving // play the sound when it starts moving(not yet thinking) if( pev->nextthink < pev->ltime || pev->nextthink == 0 ) - EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ), 1, ATTN_NORM ); // If we already moving to designated point, return else if( move == m_vecFinalDest ) return; @@ -1118,6 +1118,6 @@ void CMomentaryDoor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP void CMomentaryDoor::MomentaryMoveDone( void ) { - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ) ); - EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseArrived ), 1, ATTN_NORM ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ) ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseArrived ), 1, ATTN_NORM ); } diff --git a/dlls/effects.cpp b/dlls/effects.cpp index 2977a3ed..c3216835 100644 --- a/dlls/effects.cpp +++ b/dlls/effects.cpp @@ -229,7 +229,7 @@ void CBeam::BeamInit( const char *pSpriteName, int width ) SetFrame( 0 ); SetScrollRate( 0 ); pev->model = MAKE_STRING( pSpriteName ); - SetTexture( PRECACHE_MODEL( (char *)pSpriteName ) ); + SetTexture( PRECACHE_MODEL( pSpriteName ) ); SetWidth( width ); pev->skin = 0; pev->sequence = 0; @@ -486,7 +486,7 @@ void CLightning::Spawn( void ) void CLightning::Precache( void ) { - m_spriteTexture = PRECACHE_MODEL( (char *)STRING( m_iszSpriteName ) ); + m_spriteTexture = PRECACHE_MODEL( STRING( m_iszSpriteName ) ); CBeam::Precache(); } @@ -954,9 +954,9 @@ void CLaser::Spawn( void ) void CLaser::Precache( void ) { - pev->modelindex = PRECACHE_MODEL( (char *)STRING( pev->model ) ); + pev->modelindex = PRECACHE_MODEL( STRING( pev->model ) ); if( m_iszSpriteName ) - PRECACHE_MODEL( (char *)STRING( m_iszSpriteName ) ); + PRECACHE_MODEL( STRING( m_iszSpriteName ) ); } void CLaser::KeyValue( KeyValueData *pkvd ) @@ -1100,7 +1100,7 @@ void CGlow::Spawn( void ) pev->effects = 0; pev->frame = 0; - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); m_maxFrame = (float) MODEL_FRAMES( pev->modelindex ) - 1; @@ -1160,7 +1160,7 @@ void CSprite::Spawn( void ) void CSprite::Precache( void ) { - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); // Reset attachment after save/restore if( pev->aiment ) @@ -1515,7 +1515,7 @@ void CEnvShooter::KeyValue( KeyValueData *pkvd ) void CEnvShooter::Precache( void ) { - m_iGibModelIndex = PRECACHE_MODEL( (char *)STRING( pev->model ) ); + m_iGibModelIndex = PRECACHE_MODEL( STRING( pev->model ) ); CBreakable::MaterialSoundPrecache( (Materials)m_iGibMaterial ); } @@ -2005,7 +2005,7 @@ void CMessage::Spawn( void ) void CMessage::Precache( void ) { if( pev->noise ) - PRECACHE_SOUND( (char *)STRING( pev->noise ) ); + PRECACHE_SOUND( STRING( pev->noise ) ); } void CMessage::KeyValue( KeyValueData *pkvd ) @@ -2040,16 +2040,15 @@ void CMessage::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useT if( pActivator && pActivator->IsPlayer() ) pPlayer = pActivator; else - { pPlayer = CBaseEntity::Instance( g_engfuncs.pfnPEntityOfEntIndex( 1 ) ); - } + if( pPlayer ) UTIL_ShowMessage( STRING( pev->message ), pPlayer ); } + if( pev->noise ) - { EMIT_SOUND( edict(), CHAN_BODY, STRING( pev->noise ), pev->scale, pev->speed ); - } + if( pev->spawnflags & SF_MESSAGE_ONCE ) UTIL_Remove( this ); @@ -2071,7 +2070,7 @@ public: void CEnvFunnel::Precache( void ) { - m_iSprite = PRECACHE_MODEL ( "sprites/flare6.spr" ); + m_iSprite = PRECACHE_MODEL( "sprites/flare6.spr" ); } LINK_ENTITY_TO_CLASS( env_funnel, CEnvFunnel ) diff --git a/dlls/func_break.cpp b/dlls/func_break.cpp index 6abf1b44..0cc3675f 100644 --- a/dlls/func_break.cpp +++ b/dlls/func_break.cpp @@ -259,7 +259,7 @@ void CBreakable::MaterialSoundPrecache( Materials precacheMaterial ) for( i = 0; i < soundCount; i++ ) { - PRECACHE_SOUND( (char *)pSoundList[i] ); + PRECACHE_SOUND( pSoundList[i] ); } } @@ -340,11 +340,11 @@ void CBreakable::Precache( void ) if( m_iszGibModel ) pGibName = STRING( m_iszGibModel ); - m_idShard = PRECACHE_MODEL( (char *)pGibName ); + m_idShard = PRECACHE_MODEL( pGibName ); // Precache the spawn item's data if( m_iszSpawnObject ) - UTIL_PrecacheOther( (char *)STRING( m_iszSpawnObject ) ); + UTIL_PrecacheOther( STRING( m_iszSpawnObject ) ); } // play shard sound when func_breakable takes damage. @@ -746,7 +746,7 @@ void CBreakable::Die( void ) SetThink( &CBaseEntity::SUB_Remove ); pev->nextthink = pev->ltime + 0.1; if( m_iszSpawnObject ) - CBaseEntity::Create( (char *)STRING( m_iszSpawnObject ), VecBModelOrigin( pev ), pev->angles, edict() ); + CBaseEntity::Create( STRING( m_iszSpawnObject ), VecBModelOrigin( pev ), pev->angles, edict() ); if( Explodable() ) { diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp index c4e3cb42..6eebc675 100644 --- a/dlls/func_tank.cpp +++ b/dlls/func_tank.cpp @@ -200,13 +200,13 @@ void CFuncTank::Spawn( void ) void CFuncTank::Precache( void ) { if( m_iszSpriteSmoke ) - PRECACHE_MODEL( (char *)STRING( m_iszSpriteSmoke ) ); + PRECACHE_MODEL( STRING( m_iszSpriteSmoke ) ); if( m_iszSpriteFlash ) - PRECACHE_MODEL( (char *)STRING( m_iszSpriteFlash ) ); + PRECACHE_MODEL( STRING( m_iszSpriteFlash ) ); if( pev->noise ) - PRECACHE_SOUND( (char *)STRING( pev->noise ) ); + PRECACHE_SOUND( STRING( pev->noise ) ); } void CFuncTank::KeyValue( KeyValueData *pkvd ) @@ -688,13 +688,13 @@ void CFuncTank::StartRotSound( void ) if( !pev->noise || ( pev->spawnflags & SF_TANK_SOUNDON ) ) return; pev->spawnflags |= SF_TANK_SOUNDON; - EMIT_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noise ), 0.85, ATTN_NORM ); + EMIT_SOUND( edict(), CHAN_STATIC, STRING( pev->noise ), 0.85, ATTN_NORM ); } void CFuncTank::StopRotSound( void ) { if( pev->spawnflags & SF_TANK_SOUNDON ) - STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noise ) ); + STOP_SOUND( edict(), CHAN_STATIC, STRING( pev->noise ) ); pev->spawnflags &= ~SF_TANK_SOUNDON; } diff --git a/dlls/gargantua.cpp b/dlls/gargantua.cpp index 6aa6a738..f3155d7f 100644 --- a/dlls/gargantua.cpp +++ b/dlls/gargantua.cpp @@ -770,37 +770,37 @@ void CGargantua::Precache() PRECACHE_SOUND( GARG_STOMP_BUZZ_SOUND ); for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackHitSounds[i] ); + PRECACHE_SOUND( pAttackHitSounds[i] ); for( i = 0; i < ARRAYSIZE( pBeamAttackSounds ); i++ ) - PRECACHE_SOUND( (char *)pBeamAttackSounds[i] ); + PRECACHE_SOUND( pBeamAttackSounds[i] ); for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackMissSounds[i] ); + PRECACHE_SOUND( pAttackMissSounds[i] ); for( i = 0; i < ARRAYSIZE( pRicSounds ); i++ ) - PRECACHE_SOUND( (char *)pRicSounds[i] ); + PRECACHE_SOUND( pRicSounds[i] ); for( i = 0; i < ARRAYSIZE( pFootSounds ); i++ ) - PRECACHE_SOUND( (char *)pFootSounds[i] ); + PRECACHE_SOUND( pFootSounds[i] ); for( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) - PRECACHE_SOUND( (char *)pIdleSounds[i] ); + PRECACHE_SOUND( pIdleSounds[i] ); for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) - PRECACHE_SOUND((char *)pAlertSounds[i]); + PRECACHE_SOUND( pAlertSounds[i] ); for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND( (char *)pPainSounds[i] ); + PRECACHE_SOUND( pPainSounds[i] ); for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackSounds[i] ); + PRECACHE_SOUND( pAttackSounds[i] ); for( i = 0; i < ARRAYSIZE( pStompSounds ); i++ ) - PRECACHE_SOUND( (char *)pStompSounds[i] ); + PRECACHE_SOUND( pStompSounds[i] ); for( i = 0; i < ARRAYSIZE( pBreatheSounds ); i++ ) - PRECACHE_SOUND( (char *)pBreatheSounds[i] ); + PRECACHE_SOUND( pBreatheSounds[i] ); } void CGargantua::UpdateOnRemove() diff --git a/dlls/genericmonster.cpp b/dlls/genericmonster.cpp index 23622120..3cc0acc6 100644 --- a/dlls/genericmonster.cpp +++ b/dlls/genericmonster.cpp @@ -131,7 +131,7 @@ void CGenericMonster::Spawn() //========================================================= void CGenericMonster::Precache() { - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); } //========================================================= diff --git a/dlls/h_cycler.cpp b/dlls/h_cycler.cpp index e920abfa..5daad4a2 100644 --- a/dlls/h_cycler.cpp +++ b/dlls/h_cycler.cpp @@ -67,7 +67,7 @@ class CGenericCycler : public CCycler public: void Spawn( void ) { - GenericCyclerSpawn( (char *)STRING( pev->model ), Vector( -16, -16, 0 ), Vector( 16, 16, 72 ) ); + GenericCyclerSpawn( STRING( pev->model ), Vector( -16, -16, 0 ), Vector( 16, 16, 72 ) ); } }; @@ -255,7 +255,7 @@ void CCyclerSprite::Spawn( void ) m_animate = 1; m_lastTime = gpGlobals->time; - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); m_maxFrame = (float)MODEL_FRAMES( pev->modelindex ) - 1; @@ -314,7 +314,7 @@ void CWeaponCycler::Spawn() pev->solid = SOLID_SLIDEBOX; pev->movetype = MOVETYPE_NONE; - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); m_iszModel = pev->model; m_iModel = pev->modelindex; @@ -401,7 +401,7 @@ void CWreckage::Spawn( void ) if( pev->model ) { - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); } // pev->scale = 5.0; @@ -412,7 +412,7 @@ void CWreckage::Spawn( void ) void CWreckage::Precache() { if( pev->model ) - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); } void CWreckage::Think( void ) diff --git a/dlls/islave.cpp b/dlls/islave.cpp index 51def5d3..b516c09b 100644 --- a/dlls/islave.cpp +++ b/dlls/islave.cpp @@ -544,16 +544,16 @@ void CISlave::Precache() PRECACHE_SOUND( "weapons/cbar_miss1.wav" ); for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackHitSounds[i] ); + PRECACHE_SOUND( pAttackHitSounds[i] ); for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackMissSounds[i] ); + PRECACHE_SOUND( pAttackMissSounds[i] ); for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND((char *)pPainSounds[i] ); + PRECACHE_SOUND( pPainSounds[i] ); for( i = 0; i < ARRAYSIZE( pDeathSounds ); i++ ) - PRECACHE_SOUND( (char *)pDeathSounds[i] ); + PRECACHE_SOUND( pDeathSounds[i] ); UTIL_PrecacheOther( "test_effect" ); } diff --git a/dlls/leech.cpp b/dlls/leech.cpp index dccffcf4..1d64eae1 100644 --- a/dlls/leech.cpp +++ b/dlls/leech.cpp @@ -277,9 +277,9 @@ void CLeech::Precache( void ) PRECACHE_MODEL( "models/leech.mdl" ); for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackSounds[i] ); + PRECACHE_SOUND( pAttackSounds[i] ); for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) - PRECACHE_SOUND( (char *)pAlertSounds[i] ); + PRECACHE_SOUND( pAlertSounds[i] ); } int CLeech::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index a898158f..5e06f909 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -92,7 +92,7 @@ CHalfLifeMultiplay::CHalfLifeMultiplay() if( IS_DEDICATED_SERVER() ) { // dedicated server - /*char *servercfgfile = (char *)CVAR_GET_STRING( "servercfgfile" ); + /*const char *servercfgfile = CVAR_GET_STRING( "servercfgfile" ); if( servercfgfile && servercfgfile[0] ) { @@ -108,7 +108,7 @@ CHalfLifeMultiplay::CHalfLifeMultiplay() else { // listen server - char *lservercfgfile = (char *)CVAR_GET_STRING( "lservercfgfile" ); + const char *lservercfgfile = CVAR_GET_STRING( "lservercfgfile" ); if( lservercfgfile && lservercfgfile[0] ) { @@ -1214,7 +1214,7 @@ COM_Parse Parse a token out of a string ============== */ -char *COM_Parse( char *data ) +const char *COM_Parse( const char *data ) { int c; int len; @@ -1290,9 +1290,9 @@ COM_TokenWaiting Returns 1 if additional data is waiting to be processed on this line ============== */ -int COM_TokenWaiting( char *buffer ) +int COM_TokenWaiting( const char *buffer ) { - char *p; + const char *p; p = buffer; while( *p && *p!='\n') @@ -1313,12 +1313,12 @@ ReloadMapCycleFile Parses mapcycle.txt file into mapcycle_t structure ============== */ -int ReloadMapCycleFile( char *filename, mapcycle_t *cycle ) +int ReloadMapCycleFile( const char *filename, mapcycle_t *cycle ) { char szMap[32]; int length; - char *pFileList; - char *aFileList = pFileList = (char*)LOAD_FILE_FOR_ME( filename, &length ); + const char *pFileList; + const char *aFileList = pFileList = (const char *)LOAD_FILE_FOR_ME( filename, &length ); int hasbuffer; mapcycle_item_s *item, *newlist = NULL, *next; @@ -1396,7 +1396,7 @@ int ReloadMapCycleFile( char *filename, mapcycle_t *cycle ) } } - FREE_FILE( aFileList ); + FREE_FILE( (void*)aFileList ); } // Fixup circular list pointer @@ -1532,7 +1532,7 @@ void CHalfLifeMultiplay::ChangeLevel( void ) BOOL do_cycle = TRUE; // find the map to change to - char *mapcfile = (char*)CVAR_GET_STRING( "mapcyclefile" ); + const char *mapcfile = CVAR_GET_STRING( "mapcyclefile" ); ASSERT( mapcfile != NULL ); szCommands[0] = '\0'; @@ -1650,8 +1650,8 @@ void CHalfLifeMultiplay::SendMOTDToClient( edict_t *client ) { // read from the MOTD.txt file int length, char_count = 0; - char *pFileList; - char *aFileList = pFileList = (char*)LOAD_FILE_FOR_ME( (char *)CVAR_GET_STRING( "motdfile" ), &length ); + const char *pFileList; + const char *aFileList = pFileList = (const char*)LOAD_FILE_FOR_ME( CVAR_GET_STRING( "motdfile" ), &length ); // send the server name MESSAGE_BEGIN( MSG_ONE, gmsgServerName, NULL, client ); @@ -1679,7 +1679,7 @@ void CHalfLifeMultiplay::SendMOTDToClient( edict_t *client ) if( char_count < MAX_MOTD_LENGTH ) pFileList = aFileList + char_count; else - *pFileList = 0; + pFileList = 0; MESSAGE_BEGIN( MSG_ONE, gmsgMOTD, NULL, client ); WRITE_BYTE( *pFileList ? FALSE : TRUE ); // FALSE means there is still more message to come @@ -1687,5 +1687,5 @@ void CHalfLifeMultiplay::SendMOTDToClient( edict_t *client ) MESSAGE_END(); } - FREE_FILE( aFileList ); + FREE_FILE( (void*)aFileList ); } diff --git a/dlls/nodes.cpp b/dlls/nodes.cpp index 68a1c267..b94f894b 100644 --- a/dlls/nodes.cpp +++ b/dlls/nodes.cpp @@ -2108,7 +2108,7 @@ void CTestHull::BuildNodeGraph( void ) WorldGraph.ComputeStaticRoutingTables(); // save the node graph for this level - WorldGraph.FSaveGraph( (char *)STRING( gpGlobals->mapname ) ); + WorldGraph.FSaveGraph( STRING( gpGlobals->mapname ) ); ALERT( at_console, "Done.\n" ); } @@ -2363,7 +2363,7 @@ void CQueuePriority::Heap_SiftUp( void ) // will be loaded. If file cannot be loaded, the node tree // will be created and saved to disk. //========================================================= -int CGraph::FLoadGraph( char *szMapName ) +int CGraph::FLoadGraph( const char *szMapName ) { char szFilename[MAX_PATH]; int iVersion; @@ -2542,7 +2542,7 @@ NoMemory: // CGraph - FSaveGraph - It's not rocket science. // this WILL overwrite existing files. //========================================================= -int CGraph::FSaveGraph( char *szMapName ) +int CGraph::FSaveGraph( const char *szMapName ) { int iVersion = GRAPH_VERSION; char szFilename[MAX_PATH]; @@ -2674,7 +2674,7 @@ int CGraph::FSetGraphPointers( void ) // though. ( I now suspect that we are getting GMT back from // these functions and must compensate for local time ) (sjb) //========================================================= -int CGraph::CheckNODFile( char *szMapName ) +int CGraph::CheckNODFile( const char *szMapName ) { int retValue; diff --git a/dlls/nodes.h b/dlls/nodes.h index 29440025..49036a39 100644 --- a/dlls/nodes.h +++ b/dlls/nodes.h @@ -182,9 +182,9 @@ public: void InitGraph( void ); int AllocNodes ( void ); - int CheckNODFile(char *szMapName); - int FLoadGraph(char *szMapName); - int FSaveGraph(char *szMapName); + int CheckNODFile(const char *szMapName); + int FLoadGraph(const char *szMapName); + int FSaveGraph(const char *szMapName); int FSetGraphPointers(void); void CheckNode(Vector vecOrigin, int iNode); diff --git a/dlls/plats.cpp b/dlls/plats.cpp index 3034fd93..1e6de4bf 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -416,7 +416,7 @@ void CFuncPlat::PlatUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE void CFuncPlat::GoDown( void ) { if( pev->noiseMovement ) - EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMovement ), m_volume, ATTN_NORM ); ASSERT( m_toggle_state == TS_AT_TOP || m_toggle_state == TS_GOING_UP ); m_toggle_state = TS_GOING_DOWN; @@ -430,10 +430,10 @@ void CFuncPlat::GoDown( void ) void CFuncPlat::HitBottom( void ) { if( pev->noiseMovement ) - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMovement ) ); if( pev->noiseStopMoving ) - EMIT_SOUND( ENT( pev ), CHAN_WEAPON, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); ASSERT( m_toggle_state == TS_GOING_DOWN ); m_toggle_state = TS_AT_BOTTOM; @@ -445,7 +445,7 @@ void CFuncPlat::HitBottom( void ) void CFuncPlat::GoUp( void ) { if( pev->noiseMovement ) - EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMovement ), m_volume, ATTN_NORM ); ASSERT( m_toggle_state == TS_AT_BOTTOM || m_toggle_state == TS_GOING_DOWN ); m_toggle_state = TS_GOING_UP; @@ -459,10 +459,10 @@ void CFuncPlat::GoUp( void ) void CFuncPlat::HitTop( void ) { if( pev->noiseMovement ) - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMovement ) ); if( pev->noiseStopMoving ) - EMIT_SOUND( ENT( pev ), CHAN_WEAPON, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); ASSERT( m_toggle_state == TS_GOING_UP ); m_toggle_state = TS_AT_TOP; @@ -482,7 +482,7 @@ void CFuncPlat::Blocked( CBaseEntity *pOther ) pOther->TakeDamage( pev, pev, 1, DMG_CRUSH ); if( pev->noiseMovement ) - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMovement ) ); // Send the platform back where it came from ASSERT( m_toggle_state == TS_GOING_UP || m_toggle_state == TS_GOING_DOWN ); @@ -670,7 +670,7 @@ void CFuncTrain::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE us pev->nextthink = 0; pev->velocity = g_vecZero; if( pev->noiseStopMoving ) - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); } } @@ -691,9 +691,9 @@ void CFuncTrain::Wait( void ) // clear the sound channel. if( pev->noiseMovement ) - STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); + STOP_SOUND( edict(), CHAN_STATIC, STRING( pev->noiseMovement ) ); if( pev->noiseStopMoving ) - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); pev->nextthink = 0; return; } @@ -704,9 +704,9 @@ void CFuncTrain::Wait( void ) // -1 wait will wait forever! pev->nextthink = pev->ltime + m_flWait; if( pev->noiseMovement ) - STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); + STOP_SOUND( edict(), CHAN_STATIC, STRING( pev->noiseMovement ) ); if( pev->noiseStopMoving ) - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); SetThink( &CFuncTrain::Next ); } else @@ -728,10 +728,10 @@ void CFuncTrain::Next( void ) if( !pTarg ) { if( pev->noiseMovement ) - STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); + STOP_SOUND( edict(), CHAN_STATIC, STRING( pev->noiseMovement ) ); // Play stop sound if( pev->noiseStopMoving ) - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); return; } @@ -767,8 +767,8 @@ void CFuncTrain::Next( void ) // this is not a hack or temporary fix, this is how things should be. (sjb). if( pev->noiseMovement ) { - STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); - EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ), m_volume, ATTN_NORM ); + STOP_SOUND( edict(), CHAN_STATIC, STRING( pev->noiseMovement ) ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMovement ), m_volume, ATTN_NORM ); } ClearBits( pev->effects, EF_NOINTERP ); @@ -1061,7 +1061,7 @@ void CFuncTrackTrain::StopSound( void ) PLAYBACK_EVENT_FULL( FEV_RELIABLE | FEV_UPDATE, edict(), m_usAdjustPitch, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, us_encode, 0, 1, 0 ); /* - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noise ) ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noise ) ); */ EMIT_SOUND_DYN( ENT( pev ), CHAN_ITEM, "plats/ttrain_brake1.wav", m_flVolume, ATTN_NORM, 0, 100 ); } @@ -1085,14 +1085,14 @@ void CFuncTrackTrain::UpdateSound( void ) { // play startup sound for train EMIT_SOUND_DYN( ENT( pev ), CHAN_ITEM, "plats/ttrain_start1.wav", m_flVolume, ATTN_NORM, 0, 100 ); - EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noise ), m_flVolume, ATTN_NORM, 0, (int)flpitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, STRING( pev->noise ), m_flVolume, ATTN_NORM, 0, (int)flpitch ); m_soundPlaying = 1; } else { /* // update pitch - EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noise ), m_flVolume, ATTN_NORM, SND_CHANGE_PITCH, (int)flpitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, STRING( pev->noise ), m_flVolume, ATTN_NORM, SND_CHANGE_PITCH, (int)flpitch ); */ // volume 0.0 - 1.0 - 6 bits // m_sounds 3 bits @@ -1322,7 +1322,7 @@ BOOL CFuncTrackTrain::OnControls( entvars_t *pevTest ) void CFuncTrackTrain::Find( void ) { - m_ppath = CPathTrack::Instance(FIND_ENTITY_BY_TARGETNAME( NULL, STRING( pev->target ) ) ); + m_ppath = CPathTrack::Instance( FIND_ENTITY_BY_TARGETNAME( NULL, STRING( pev->target ) ) ); if( !m_ppath ) return; diff --git a/dlls/prop.cpp b/dlls/prop.cpp index c6c4017e..7f7dba48 100644 --- a/dlls/prop.cpp +++ b/dlls/prop.cpp @@ -248,7 +248,7 @@ void CProp::MaterialSoundPrecache( Materials precacheMaterial ) for( i = 0; i < soundCount; i++ ) { - PRECACHE_SOUND( (char *)pSoundList[i] ); + PRECACHE_SOUND( pSoundList[i] ); } } @@ -327,8 +327,8 @@ void CProp::Precache( void ) if( m_iszGibModel ) pGibName = STRING( m_iszGibModel ); - m_idShard = PRECACHE_MODEL( (char *)pGibName ); - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + m_idShard = PRECACHE_MODEL( pGibName ); + PRECACHE_MODEL( STRING( pev->model ) ); } void CProp::DamageSound( void ) diff --git a/dlls/scripted.cpp b/dlls/scripted.cpp index da9708d1..678502f6 100644 --- a/dlls/scripted.cpp +++ b/dlls/scripted.cpp @@ -712,7 +712,7 @@ void CCineMonster::DelayStart( int state ) else { pTarget->m_iDelay--; - if (pTarget->m_iDelay <= 0) + if( pTarget->m_iDelay <= 0 ) pTarget->m_startTime = gpGlobals->time + 0.05; } } @@ -1177,7 +1177,7 @@ void CFurniture::Die( void ) //========================================================= void CFurniture::Spawn() { - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); pev->movetype = MOVETYPE_NONE; diff --git a/dlls/sound.cpp b/dlls/sound.cpp index f6110a8d..85b9f71d 100644 --- a/dlls/sound.cpp +++ b/dlls/sound.cpp @@ -182,7 +182,7 @@ void CAmbientGeneric::Spawn( void ) m_flAttenuation = ATTN_STATIC; } - char* szSoundFile = (char*)STRING( pev->message ); + const char *szSoundFile = STRING( pev->message ); if( FStringNull( pev->message ) || strlen( szSoundFile ) < 1 ) { @@ -216,7 +216,7 @@ void CAmbientGeneric::Spawn( void ) void CAmbientGeneric::Precache( void ) { - char* szSoundFile = (char*)STRING( pev->message ); + const char *szSoundFile = STRING( pev->message ); if( !FStringNull( pev->message ) && strlen( szSoundFile ) > 1 ) { @@ -248,7 +248,7 @@ void CAmbientGeneric::Precache( void ) // with lfo if active. void CAmbientGeneric::RampThink( void ) { - char* szSoundFile = (char*) STRING(pev->message); + const char *szSoundFile = STRING( pev->message ); int pitch = m_dpv.pitch; int vol = m_dpv.vol; int flags = 0; @@ -533,7 +533,7 @@ void CAmbientGeneric::InitModulationParms( void ) // void CAmbientGeneric::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - char* szSoundFile = (char*)STRING( pev->message ); + const char *szSoundFile = STRING( pev->message ); float fraction; if( useType != USE_TOGGLE ) diff --git a/dlls/stats.cpp b/dlls/stats.cpp index 9b21f792..1df298b2 100644 --- a/dlls/stats.cpp +++ b/dlls/stats.cpp @@ -48,7 +48,7 @@ float AmmoDamage( const char *pName ) return 0; } -void UpdateStatsFile( float dataTime, char *pMapname, float health, float ammo, int skillLevel ) +void UpdateStatsFile( float dataTime, const char *pMapname, float health, float ammo, int skillLevel ) { FILE *fp; @@ -136,7 +136,7 @@ void UpdateStats( CBasePlayer *pPlayer ) } else if( ( gStats.nextOutputTime != 0 && gStats.nextOutputTime < gStats.gameTime ) || forceWrite ) { - UpdateStatsFile( gStats.dataTime, (char *)STRING( gpGlobals->mapname ), health, ammo, (int)CVAR_GET_FLOAT( "skill" ) ); + UpdateStatsFile( gStats.dataTime, STRING( gpGlobals->mapname ), health, ammo, (int)CVAR_GET_FLOAT( "skill" ) ); gStats.lastAmmo = ammo; gStats.lastHealth = health; diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index 57d8d031..8171a195 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -527,7 +527,7 @@ void CBaseTrigger::InitTrigger() SetMovedir( pev ); pev->solid = SOLID_TRIGGER; pev->movetype = MOVETYPE_NONE; - SET_MODEL(ENT(pev), STRING( pev->model ) ); // set size and link into world + SET_MODEL( ENT( pev ), STRING( pev->model ) ); // set size and link into world if( CVAR_GET_FLOAT( "showtriggers" ) == 0 ) SetBits( pev->effects, EF_NODRAW ); } @@ -1135,7 +1135,7 @@ void CBaseTrigger::ActivateMultiTrigger( CBaseEntity *pActivator ) } if( !FStringNull( pev->noise ) ) - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM ); // don't trigger again until reset // pev->takedamage = DAMAGE_NO; @@ -1264,7 +1264,7 @@ void CTriggerVolume::Spawn( void ) { pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_NONE; - SET_MODEL( ENT(pev), STRING( pev->model ) ); // set size and link into world + SET_MODEL( ENT( pev ), STRING( pev->model ) ); // set size and link into world pev->model = 0; pev->modelindex = 0; } @@ -1338,7 +1338,7 @@ TYPEDESCRIPTION CChangeLevel::m_SaveData[] = DEFINE_FIELD( CChangeLevel, m_changeTargetDelay, FIELD_FLOAT ), }; -IMPLEMENT_SAVERESTORE(CChangeLevel,CBaseTrigger) +IMPLEMENT_SAVERESTORE( CChangeLevel, CBaseTrigger ) // // Cache user-entity-field values until spawn is called. diff --git a/dlls/util.cpp b/dlls/util.cpp index bca89948..68ba30cd 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -1052,7 +1052,7 @@ Vector UTIL_GetAimVector( edict_t *pent, float flSpeed ) return tmp; } -int UTIL_IsMasterTriggered(string_t sMaster, CBaseEntity *pActivator) +int UTIL_IsMasterTriggered( string_t sMaster, CBaseEntity *pActivator ) { if( sMaster ) { @@ -1340,7 +1340,7 @@ void UTIL_StringToVector( float *pVector, const char *pString ) while( *pstr && *pstr != ' ' ) pstr++; - if( !(*pstr) ) + if( !( *pstr ) ) break; pstr++; pfront = pstr; @@ -1858,7 +1858,7 @@ void CSave::WriteString( const char *pname, const int *stringId, int count ) #if 0 if( count != 1 ) ALERT( at_error, "No string arrays!\n" ); - WriteString( pname, (char *)STRING( *stringId ) ); + WriteString( pname, STRING( *stringId ) ); #endif size = 0; for( i = 0; i < count; i++ ) @@ -2209,9 +2209,9 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou if( !FStringNull( string ) && m_precache ) { if( pTest->fieldType == FIELD_MODELNAME ) - PRECACHE_MODEL( (char *)STRING( string ) ); + PRECACHE_MODEL( STRING( string ) ); else if( pTest->fieldType == FIELD_SOUNDNAME ) - PRECACHE_SOUND( (char *)STRING( string ) ); + PRECACHE_SOUND( STRING( string ) ); } } break; diff --git a/dlls/util.h b/dlls/util.h index c13271b0..2ffe536e 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -542,7 +542,7 @@ void EMIT_GROUPID_SUIT(edict_t *entity, int isentenceg); void EMIT_GROUPNAME_SUIT(edict_t *entity, const char *groupname); #define PRECACHE_SOUND_ARRAY( a ) \ - { for (int i = 0; i < (int)ARRAYSIZE( a ); i++ ) PRECACHE_SOUND((char *) a [i]); } + { for (int i = 0; i < (int)ARRAYSIZE( a ); i++ ) PRECACHE_SOUND( a[i] ); } #define EMIT_SOUND_ARRAY_DYN( chan, array ) \ EMIT_SOUND_DYN ( ENT(pev), chan , array [ RANDOM_LONG(0,ARRAYSIZE( array )-1) ], 1.0, ATTN_NORM, 0, RANDOM_LONG(95,105) ); diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 06bb1796..a1205f27 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -367,7 +367,7 @@ void W_Precache( void ) g_sModelIndexBloodSpray = PRECACHE_MODEL( "sprites/bloodspray.spr" ); // initial blood g_sModelIndexBloodDrop = PRECACHE_MODEL( "sprites/blood.spr" ); // splattered blood - g_sModelIndexLaser = PRECACHE_MODEL( (char *)g_pModelNameLaser ); + g_sModelIndexLaser = PRECACHE_MODEL( g_pModelNameLaser ); g_sModelIndexLaserDot = PRECACHE_MODEL( "sprites/laserdot.spr" ); // used by explosions @@ -535,7 +535,7 @@ CBaseEntity* CBasePlayerItem::Respawn( void ) { // make a copy of this weapon that is invisible and inaccessible to players (no touch function). The weapon spawn/respawn code // will decide when to make the weapon visible and touchable. - CBaseEntity *pNewWeapon = CBaseEntity::Create( (char *)STRING( pev->classname ), g_pGameRules->VecWeaponRespawnSpot( this ), pev->angles, pev->owner ); + CBaseEntity *pNewWeapon = CBaseEntity::Create( STRING( pev->classname ), g_pGameRules->VecWeaponRespawnSpot( this ), pev->angles, pev->owner ); if( pNewWeapon ) { @@ -1297,7 +1297,7 @@ void CWeaponBox::Touch( CBaseEntity *pOther ) if( !FStringNull( m_rgiszAmmo[i] ) ) { // there's some ammo of this type. - pPlayer->GiveAmmo( m_rgAmmo[i], (char *)STRING( m_rgiszAmmo[i] ), MaxAmmoCarry( m_rgiszAmmo[i] ) ); + pPlayer->GiveAmmo( m_rgAmmo[i], STRING( m_rgiszAmmo[i] ), MaxAmmoCarry( m_rgiszAmmo[i] ) ); //ALERT( at_console, "Gave %d rounds of %s\n", m_rgAmmo[i], STRING( m_rgiszAmmo[i] ) ); @@ -1407,7 +1407,7 @@ BOOL CWeaponBox::PackAmmo( int iszName, int iCount ) if( iMaxCarry != -1 && iCount > 0 ) { //ALERT( at_console, "Packed %d rounds of %s\n", iCount, STRING( iszName ) ); - GiveAmmo( iCount, (char *)STRING( iszName ), iMaxCarry ); + GiveAmmo( iCount, STRING( iszName ), iMaxCarry ); return TRUE; } diff --git a/dlls/world.cpp b/dlls/world.cpp index 1cc645c9..3b9a1f1e 100644 --- a/dlls/world.cpp +++ b/dlls/world.cpp @@ -592,7 +592,7 @@ void CWorld::Precache( void ) WorldGraph.InitGraph(); // make sure the .NOD file is newer than the .BSP file. - if( !WorldGraph.CheckNODFile( ( char * )STRING( gpGlobals->mapname ) ) ) + if( !WorldGraph.CheckNODFile( STRING( gpGlobals->mapname ) ) ) { // NOD file is not present, or is older than the BSP file. WorldGraph.AllocNodes(); @@ -600,7 +600,7 @@ void CWorld::Precache( void ) else { // Load the node graph for this level - if( !WorldGraph.FLoadGraph ( (char *)STRING( gpGlobals->mapname ) ) ) + if( !WorldGraph.FLoadGraph( STRING( gpGlobals->mapname ) ) ) { // couldn't load, so alloc and prepare to build a graph. ALERT( at_console, "*Error opening .NOD file\n" ); diff --git a/dlls/xen.cpp b/dlls/xen.cpp index 4e9e1685..1d86beb3 100644 --- a/dlls/xen.cpp +++ b/dlls/xen.cpp @@ -444,9 +444,9 @@ CXenHull *CXenHull::CreateHull( CBaseEntity *source, const Vector &mins, const V CXenHull *pHull = GetClassPtr( (CXenHull *)NULL ); UTIL_SetOrigin( pHull->pev, source->pev->origin + offset ); - SET_MODEL( pHull->edict(), STRING(source->pev->model) ); + SET_MODEL( pHull->edict(), STRING( source->pev->model ) ); pHull->pev->solid = SOLID_BBOX; - pHull->pev->classname = MAKE_STRING("xen_hull"); + pHull->pev->classname = MAKE_STRING( "xen_hull" ); pHull->pev->movetype = MOVETYPE_NONE; pHull->pev->owner = source->edict(); UTIL_SetSize( pHull->pev, mins, maxs ); @@ -527,7 +527,7 @@ const char *CXenSpore::pModelNames[] = void CXenSpore::Precache( void ) { - PRECACHE_MODEL( (char *)pModelNames[pev->skin] ); + PRECACHE_MODEL( pModelNames[pev->skin] ); } void CXenSpore::Touch( CBaseEntity *pOther ) diff --git a/dlls/zombie.cpp b/dlls/zombie.cpp index 2611f881..96f032e6 100644 --- a/dlls/zombie.cpp +++ b/dlls/zombie.cpp @@ -266,7 +266,7 @@ void CZombie::Spawn() { Precache(); - SET_MODEL( ENT(pev), "models/zombie.mdl" ); + SET_MODEL( ENT( pev ), "models/zombie.mdl" ); UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX ); pev->solid = SOLID_SLIDEBOX; @@ -291,22 +291,22 @@ void CZombie::Precache() PRECACHE_MODEL( "models/zombie.mdl" ); for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackHitSounds[i] ); + PRECACHE_SOUND( pAttackHitSounds[i] ); for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackMissSounds[i] ); + PRECACHE_SOUND( pAttackMissSounds[i] ); for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackSounds[i] ); + PRECACHE_SOUND( pAttackSounds[i] ); for( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) - PRECACHE_SOUND( (char *)pIdleSounds[i] ); + PRECACHE_SOUND( pIdleSounds[i] ); for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) - PRECACHE_SOUND( (char *)pAlertSounds[i] ); + PRECACHE_SOUND( pAlertSounds[i] ); for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND( (char *)pPainSounds[i] ); + PRECACHE_SOUND( pPainSounds[i] ); } //========================================================= From 4150b464a047d87f398c8a9838a6a27fa3646418 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 24 Jul 2017 16:38:38 +0500 Subject: [PATCH 102/144] Improve spectator. --- dlls/client.cpp | 28 +++++++++++++++++++--------- dlls/observer.cpp | 23 +++++++++++++++++++++++ dlls/player.h | 1 + 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/dlls/client.cpp b/dlls/client.cpp index 569b1a53..32b6bebd 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -556,20 +556,30 @@ void ClientCommand( edict_t *pEntity ) } else if( FStrEq( pcmd, "spectate" ) ) // clients wants to become a spectator { - // always allow proxies to become a spectator - if( ( pev->flags & FL_PROXY ) || allow_spectators.value ) + CBasePlayer *pPlayer = GetClassPtr( (CBasePlayer *)pev ); + if( !pPlayer->IsObserver() ) { - CBasePlayer *pPlayer = GetClassPtr( (CBasePlayer *)pev ); - - edict_t *pentSpawnSpot = g_pGameRules->GetPlayerSpawnSpot( pPlayer ); - pPlayer->StartObserver( pev->origin, VARS( pentSpawnSpot )->angles ); + // always allow proxies to become a spectator + if( ( pev->flags & FL_PROXY ) || allow_spectators.value ) + { + edict_t *pentSpawnSpot = g_pGameRules->GetPlayerSpawnSpot( pPlayer ); + pPlayer->StartObserver( pev->origin, VARS( pentSpawnSpot )->angles ); - // notify other clients of player switching to spectator mode - UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s switched to spectator mode\n", + // notify other clients of player switching to spectator mode + UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s switched to spectator mode\n", ( pev->netname && ( STRING( pev->netname ) )[0] != 0 ) ? STRING( pev->netname ) : "unconnected" ) ); + } + else + ClientPrint( pev, HUD_PRINTCONSOLE, "Spectator mode is disabled.\n" ); } else - ClientPrint( pev, HUD_PRINTCONSOLE, "Spectator mode is disabled.\n" ); + { + pPlayer->StopObserver(); + + // notify other clients of player left spectators + UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s has left spectator mode\n", + ( pev->netname && ( STRING( pev->netname ) )[0] != 0 ) ? STRING( pev->netname ) : "unconnected" ) ); + } } else if( FStrEq( pcmd, "specmode" ) ) // new spectator mode { diff --git a/dlls/observer.cpp b/dlls/observer.cpp index f3fc54a0..22fa3818 100644 --- a/dlls/observer.cpp +++ b/dlls/observer.cpp @@ -24,6 +24,10 @@ extern int gmsgCurWeapon; extern int gmsgSetFOV; +extern int gmsgTeamInfo; + +extern int g_teamplay; + // Find the next client in the game for this player to spectate void CBasePlayer::Observer_FindNextPlayer( bool bReverse ) { @@ -266,3 +270,22 @@ void CBasePlayer::Observer_SetMode( int iMode ) m_iObserverLastMode = iMode; } + +void CBasePlayer::StopObserver() +{ + // Turn off spectator + pev->iuser1 = pev->iuser2 = 0; + m_iHideHUD = 0; + + GetClassPtr( (CBasePlayer *)pev )->Spawn(); + pev->nextthink = -1; + + // Update Team Status + MESSAGE_BEGIN( MSG_ALL, gmsgTeamInfo ); + WRITE_BYTE( ENTINDEX( edict() ) ); // index number of primary entity + if( g_teamplay ) + WRITE_STRING( TeamID() ); + else + WRITE_STRING( "Players" ); + MESSAGE_END(); +} diff --git a/dlls/player.h b/dlls/player.h index 1c17556c..54e7fa85 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -255,6 +255,7 @@ public: void StartDeathCam( void ); void StartObserver( Vector vecPosition, Vector vecViewAngle ); + void StopObserver(); void AddPoints( int score, BOOL bAllowNegativeScore ); void AddPointsToTeam( int score, BOOL bAllowNegativeScore ); From aaf81c770994d179c43b39e4233299752dec7f44 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 24 Jul 2017 16:56:43 +0500 Subject: [PATCH 103/144] Merge https://github.com/LevShisterov/BugfixedHL/commit/ef7cecf654ccf7716a5646ff9498928905a266dc --- pm_shared/pm_math.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pm_shared/pm_math.c b/pm_shared/pm_math.c index 5bbe0068..4bb4b93f 100644 --- a/pm_shared/pm_math.c +++ b/pm_shared/pm_math.c @@ -239,7 +239,7 @@ float AngleBetweenVectors( const vec3_t v1, const vec3_t v2 ) if( !l1 || !l2 ) return 0.0f; - angle = acos( DotProduct( v1, v2 ) ) / ( l1 * l2 ); + angle = acos( DotProduct( v1, v2 ) / ( l1 * l2 ) ); angle = ( angle * 180.0f ) / M_PI; return angle; From 96b1f4c58e8d8be9c1f743275b3ab562e50111ea Mon Sep 17 00:00:00 2001 From: mittorn Date: Sun, 30 Jul 2017 12:30:47 +0300 Subject: [PATCH 104/144] Fix wrong -std=c99 --- cl_dll/Android.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/cl_dll/Android.mk b/cl_dll/Android.mk index ecbae657..a79b6363 100755 --- a/cl_dll/Android.mk +++ b/cl_dll/Android.mk @@ -13,7 +13,6 @@ LOCAL_MODULE := client #else APP_PLATFORM := android-8 #endif -LOCAL_CONLYFLAGS += -std=c99 include $(XASH3D_CONFIG) From f14d7cc552dadde3756edddbf72a04251b620c9c Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 24 Jul 2017 23:07:59 +0500 Subject: [PATCH 105/144] A little fix. --- dlls/multiplay_gamerules.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index 5e06f909..8d089696 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -1682,7 +1682,7 @@ void CHalfLifeMultiplay::SendMOTDToClient( edict_t *client ) pFileList = 0; MESSAGE_BEGIN( MSG_ONE, gmsgMOTD, NULL, client ); - WRITE_BYTE( *pFileList ? FALSE : TRUE ); // FALSE means there is still more message to come + WRITE_BYTE( pFileList ? FALSE : TRUE ); // FALSE means there is still more message to come WRITE_STRING( chunk ); MESSAGE_END(); } From e3f953064dfe57f407d5129b432705d5d184af02 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 25 Jul 2017 13:24:06 +0500 Subject: [PATCH 106/144] Remove unneeded macros. --- dlls/enginecallback.h | 4 ---- engine/custom.h | 5 ----- engine/edict.h | 4 ---- engine/progdefs.h | 5 ----- pm_shared/pm_debug.h | 4 ---- pm_shared/pm_defs.h | 5 ----- pm_shared/pm_info.h | 4 ---- pm_shared/pm_shared.h | 4 ---- 8 files changed, 35 deletions(-) diff --git a/dlls/enginecallback.h b/dlls/enginecallback.h index 9bef0d48..a9e37c26 100644 --- a/dlls/enginecallback.h +++ b/dlls/enginecallback.h @@ -15,11 +15,7 @@ #ifndef ENGINECALLBACK_H #define ENGINECALLBACK_H -#ifdef _WIN32 -#ifndef __MINGW32__ #pragma once -#endif /* not __MINGW32__ */ -#endif #include "event_flags.h" diff --git a/engine/custom.h b/engine/custom.h index 8f644e00..30ee8d53 100644 --- a/engine/custom.h +++ b/engine/custom.h @@ -12,15 +12,10 @@ * without written permission from Valve LLC. * ****/ - #ifndef CUSTOM_H #define CUSTOM_H -#ifdef _WIN32 -#ifndef __MINGW32__ #pragma once -#endif /* not __MINGW32__ */ -#endif #include "const.h" diff --git a/engine/edict.h b/engine/edict.h index e89b6926..3994c705 100644 --- a/engine/edict.h +++ b/engine/edict.h @@ -16,11 +16,7 @@ #ifndef EDICT_H #define EDICT_H -#ifdef _WIN32 -#ifndef __MINGW32__ #pragma once -#endif /* not __MINGW32__ */ -#endif #define MAX_ENT_LEAFS 48 diff --git a/engine/progdefs.h b/engine/progdefs.h index cdbcc006..56d904b1 100644 --- a/engine/progdefs.h +++ b/engine/progdefs.h @@ -12,15 +12,10 @@ * without written permission from Valve LLC. * ****/ - #ifndef PROGDEFS_H #define PROGDEFS_H -#ifdef _WIN32 -#ifndef __MINGW32__ #pragma once -#endif /* not __MINGW32__ */ -#endif typedef struct { diff --git a/pm_shared/pm_debug.h b/pm_shared/pm_debug.h index cc130598..417c3478 100644 --- a/pm_shared/pm_debug.h +++ b/pm_shared/pm_debug.h @@ -15,11 +15,7 @@ #ifndef PM_DEBUG_H #define PM_DEBUG_H -#ifdef _WIN32 -#ifndef __MINGW32__ #pragma once -#endif /* not __MINGW32__ */ -#endif void PM_ViewEntity( void ); void PM_DrawBBox( vec3_t mins, vec3_t maxs, vec3_t origin, int pcolor, float life ); diff --git a/pm_shared/pm_defs.h b/pm_shared/pm_defs.h index b4c652ba..eddb17b6 100644 --- a/pm_shared/pm_defs.h +++ b/pm_shared/pm_defs.h @@ -12,15 +12,10 @@ * without written permission from Valve LLC. * ****/ - #ifndef PM_DEFS_H #define PM_DEFS_H -#ifdef _WIN32 -#ifndef __MINGW32__ #pragma once -#endif /* not __MINGW32__ */ -#endif #define MAX_PHYSENTS 600 // Must have room for all entities in the world. #define MAX_MOVEENTS 64 diff --git a/pm_shared/pm_info.h b/pm_shared/pm_info.h index d9dbc03d..d75b67fc 100644 --- a/pm_shared/pm_info.h +++ b/pm_shared/pm_info.h @@ -15,11 +15,7 @@ #ifndef PM_INFO_H #define PM_INFO_H -#ifdef _WIN32 -#ifndef __MINGW32__ #pragma once -#endif /* not __MINGW32__ */ -#endif #define MAX_PHYSINFO_STRING 256 #endif//PM_INFO_H diff --git a/pm_shared/pm_shared.h b/pm_shared/pm_shared.h index 1d0e4f38..2fb947a2 100644 --- a/pm_shared/pm_shared.h +++ b/pm_shared/pm_shared.h @@ -16,11 +16,7 @@ #ifndef PM_SHARED_H #define PM_SHARED_H -#ifdef _WIN32 -#ifndef __MINGW32__ #pragma once -#endif /* not __MINGW32__ */ -#endif void PM_Init( struct playermove_s *ppmove ); void PM_Move( struct playermove_s *ppmove, int server ); From 65dc1997f7685b8cb6adc9ac1cb5594ca5f9c623 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 25 Jul 2017 23:52:50 +0500 Subject: [PATCH 107/144] Fix typo. --- dlls/plats.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/plats.cpp b/dlls/plats.cpp index 1e6de4bf..c1220f3c 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -1502,7 +1502,7 @@ void CFuncTrackTrain::Precache( void ) break; } - if( !pszSound ) + if( pszSound ) { PRECACHE_SOUND( pszSound ); pev->noise = MAKE_STRING( pszSound ); From 46ecb7e8eecc446472504f0112cb80fc0b64d4b4 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 9 Oct 2017 19:51:51 +0500 Subject: [PATCH 108/144] Fix shadowing variables. --- cl_dll/ev_hldm.cpp | 16 ++++++++-------- cl_dll/view.cpp | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index d94f9fea..80073b27 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -38,7 +38,7 @@ extern engine_studio_api_t IEngineStudio; -static int tracerCount[32]; +static int g_tracerCount[32]; extern "C" char PM_FindTextureType( char *name ); @@ -546,7 +546,7 @@ void EV_FireGlock2( event_args_t *args ) VectorCopy( forward, vecAiming ); - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_9MM, 0, &tracerCount[idx - 1], args->fparam1, args->fparam2 ); + EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_9MM, 0, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); } //====================== // GLOCK END @@ -602,11 +602,11 @@ void EV_FireShotGunDouble( event_args_t *args ) if( gEngfuncs.GetMaxClients() > 1 ) { - EV_HLDM_FireBullets( idx, forward, right, up, 8, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx - 1], 0.17365, 0.04362 ); + EV_HLDM_FireBullets( idx, forward, right, up, 8, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &g_tracerCount[idx - 1], 0.17365, 0.04362 ); } else { - EV_HLDM_FireBullets( idx, forward, right, up, 12, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx - 1], 0.08716, 0.08716 ); + EV_HLDM_FireBullets( idx, forward, right, up, 12, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &g_tracerCount[idx - 1], 0.08716, 0.08716 ); } } @@ -654,11 +654,11 @@ void EV_FireShotGunSingle( event_args_t *args ) if( gEngfuncs.GetMaxClients() > 1 ) { - EV_HLDM_FireBullets( idx, forward, right, up, 4, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx - 1], 0.08716, 0.04362 ); + EV_HLDM_FireBullets( idx, forward, right, up, 4, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &g_tracerCount[idx - 1], 0.08716, 0.04362 ); } else { - EV_HLDM_FireBullets( idx, forward, right, up, 6, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx - 1], 0.08716, 0.08716 ); + EV_HLDM_FireBullets( idx, forward, right, up, 6, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &g_tracerCount[idx - 1], 0.08716, 0.08716 ); } } //====================== @@ -719,11 +719,11 @@ void EV_FireMP5( event_args_t *args ) if( gEngfuncs.GetMaxClients() > 1 ) { - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_MP5, 2, &tracerCount[idx - 1], args->fparam1, args->fparam2 ); + EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_MP5, 2, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); } else { - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_MP5, 2, &tracerCount[idx - 1], args->fparam1, args->fparam2 ); + EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_MP5, 2, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); } } diff --git a/cl_dll/view.cpp b/cl_dll/view.cpp index efa4b104..a4abe91c 100644 --- a/cl_dll/view.cpp +++ b/cl_dll/view.cpp @@ -91,7 +91,7 @@ float v_cameraFocusAngle = 35.0f; int v_cameraMode = CAM_MODE_FOCUS; qboolean v_resetCamera = 1; -vec3_t ev_punchangle; +vec3_t g_ev_punchangle; cvar_t *scr_ofsx; cvar_t *scr_ofsy; @@ -630,9 +630,9 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) VectorAdd( pparams->viewangles, pparams->punchangle, pparams->viewangles ); // Include client side punch, too - VectorAdd( pparams->viewangles, (float *)&ev_punchangle, pparams->viewangles ); + VectorAdd( pparams->viewangles, (float *)&g_ev_punchangle, pparams->viewangles ); - V_DropPunchAngle( pparams->frametime, (float *)&ev_punchangle ); + V_DropPunchAngle( pparams->frametime, (float *)&g_ev_punchangle ); // smooth out stair step ups #if 1 @@ -1579,7 +1579,7 @@ Client side punch effect */ void V_PunchAxis( int axis, float punch ) { - ev_punchangle[axis] = punch; + g_ev_punchangle[axis] = punch; } /* From e7989d438a4eea04317fc4dd7b79b34c9c18f3d8 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 15 Oct 2017 00:12:26 +0500 Subject: [PATCH 109/144] Fix compatibility with MSVC 6. --- cl_dll/ammo.cpp | 6 +++--- dlls/player.cpp | 2 +- dlls/scientist.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cl_dll/ammo.cpp b/cl_dll/ammo.cpp index edc21652..4104acff 100644 --- a/cl_dll/ammo.cpp +++ b/cl_dll/ammo.cpp @@ -305,7 +305,7 @@ void CHudAmmo::Reset( void ) gHR.Reset(); //VidInit(); - wrect_t nullrc = {}; + wrect_t nullrc = {0,}; SetCrosshair( 0, nullrc, 0, 0, 0 ); // reset crosshair m_pWeapon = NULL; // reset last weapon } @@ -539,7 +539,7 @@ int CHudAmmo::MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf ) if( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) ) { - wrect_t nullrc = {}; + wrect_t nullrc = {0,}; gpActiveSel = NULL; SetCrosshair( 0, nullrc, 0, 0, 0 ); } @@ -559,7 +559,7 @@ int CHudAmmo::MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf ) // int CHudAmmo::MsgFunc_CurWeapon( const char *pszName, int iSize, void *pbuf ) { - wrect_t nullrc = {}; + wrect_t nullrc = {0,}; int fOnTarget = FALSE; BEGIN_READ( pbuf, iSize ); diff --git a/dlls/player.cpp b/dlls/player.cpp index 38038b36..e5a01bae 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -666,7 +666,7 @@ void CBasePlayer::PackDeadPlayerItems( void ) int iWeaponRules; int iAmmoRules; int i; - CBasePlayerWeapon *rgpPackWeapons[MAX_WEAPONS] = {}; + CBasePlayerWeapon *rgpPackWeapons[MAX_WEAPONS] = {0,}; int iPackAmmo[MAX_AMMO_SLOTS]; int iPW = 0;// index into packweapons array int iPA = 0;// index into packammo array diff --git a/dlls/scientist.cpp b/dlls/scientist.cpp index 7cf9cc4d..7e94b286 100644 --- a/dlls/scientist.cpp +++ b/dlls/scientist.cpp @@ -467,7 +467,7 @@ void CScientist::StartTask( Task_t *pTask ) //The enemy can be null here. - Solokiller //Discovered while testing the barnacle grapple on headcrabs with scientists in view. - if( m_hEnemy && m_hEnemy->IsPlayer() ) + if( m_hEnemy != 0 && m_hEnemy->IsPlayer() ) PlaySentence( "SC_PLFEAR", 5, VOL_NORM, ATTN_NORM ); else PlaySentence( "SC_FEAR", 5, VOL_NORM, ATTN_NORM ); From f78471ad1d562ba0a53a43981fba5a823ca3957f Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 15 Oct 2017 00:57:55 +0500 Subject: [PATCH 110/144] min->Q_min, max->Q_max. --- cl_dll/hl/hl_weapons.cpp | 2 +- dlls/apache.cpp | 8 ++++---- dlls/client.cpp | 8 ++++---- dlls/combat.cpp | 2 +- dlls/effects.cpp | 12 ++++++------ dlls/extdll.h | 8 ++++---- dlls/hassassin.cpp | 4 ++-- dlls/items.cpp | 2 +- dlls/maprules.cpp | 2 +- dlls/monsters.cpp | 2 +- dlls/multiplay_gamerules.cpp | 8 ++++---- dlls/nihilanth.cpp | 4 ++-- dlls/nodes.cpp | 14 +++++++------- dlls/player.cpp | 16 ++++++++-------- dlls/sound.cpp | 2 +- dlls/talkmonster.cpp | 4 ++-- dlls/turret.cpp | 2 +- dlls/util.cpp | 4 ++-- dlls/weapons.cpp | 8 ++++---- 19 files changed, 56 insertions(+), 56 deletions(-) diff --git a/cl_dll/hl/hl_weapons.cpp b/cl_dll/hl/hl_weapons.cpp index 8f8baea7..75161a9e 100644 --- a/cl_dll/hl/hl_weapons.cpp +++ b/cl_dll/hl/hl_weapons.cpp @@ -151,7 +151,7 @@ BOOL CBasePlayerWeapon::DefaultReload( int iClipSize, int iAnim, float fDelay, i if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) return FALSE; - int j = min( iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ); + int j = Q_min( iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ); if( j == 0 ) return FALSE; diff --git a/dlls/apache.cpp b/dlls/apache.cpp index aeeea30e..b3cfcf87 100644 --- a/dlls/apache.cpp +++ b/dlls/apache.cpp @@ -804,13 +804,13 @@ BOOL CApache::FireGun() angles.x = angles.x + 360; if( angles.x > m_angGun.x ) - m_angGun.x = min( angles.x, m_angGun.x + 12 ); + m_angGun.x = Q_min( angles.x, m_angGun.x + 12 ); if( angles.x < m_angGun.x ) - m_angGun.x = max( angles.x, m_angGun.x - 12 ); + m_angGun.x = Q_max( angles.x, m_angGun.x - 12 ); if( angles.y > m_angGun.y ) - m_angGun.y = min( angles.y, m_angGun.y + 12 ); + m_angGun.y = Q_min( angles.y, m_angGun.y + 12 ); if( angles.y < m_angGun.y ) - m_angGun.y = max( angles.y, m_angGun.y - 12 ); + m_angGun.y = Q_max( angles.y, m_angGun.y - 12 ); m_angGun.y = SetBoneController( 0, m_angGun.y ); m_angGun.x = SetBoneController( 1, m_angGun.x ); diff --git a/dlls/client.cpp b/dlls/client.cpp index 32b6bebd..578534e3 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -1656,12 +1656,12 @@ int GetWeaponData( struct edict_s *player, struct weapon_data_s *info ) item->m_iId = II.iId; item->m_iClip = gun->m_iClip; - item->m_flTimeWeaponIdle = max( gun->m_flTimeWeaponIdle, -0.001 ); - item->m_flNextPrimaryAttack = max( gun->m_flNextPrimaryAttack, -0.001 ); - item->m_flNextSecondaryAttack = max( gun->m_flNextSecondaryAttack, -0.001 ); + item->m_flTimeWeaponIdle = Q_max( gun->m_flTimeWeaponIdle, -0.001 ); + item->m_flNextPrimaryAttack = Q_max( gun->m_flNextPrimaryAttack, -0.001 ); + item->m_flNextSecondaryAttack = Q_max( gun->m_flNextSecondaryAttack, -0.001 ); item->m_fInReload = gun->m_fInReload; item->m_fInSpecialReload = gun->m_fInSpecialReload; - item->fuser1 = max( gun->pev->fuser1, -0.001 ); + item->fuser1 = Q_max( gun->pev->fuser1, -0.001 ); item->fuser2 = gun->m_flStartThrow; item->fuser3 = gun->m_flReleaseThrow; item->iuser1 = gun->m_chargeReady; diff --git a/dlls/combat.cpp b/dlls/combat.cpp index 35e4ffcf..9f221cc9 100644 --- a/dlls/combat.cpp +++ b/dlls/combat.cpp @@ -727,7 +727,7 @@ void CGib::BounceGibTouch( CBaseEntity *pOther ) float volume; float zvel = fabs( pev->velocity.z ); - volume = 0.8 * min( 1.0, ( (float)zvel ) / 450.0 ); + volume = 0.8 * Q_min( 1.0, ( (float)zvel ) / 450.0 ); CBreakable::MaterialSoundRandom( edict(), (Materials)m_material, volume ); } diff --git a/dlls/effects.cpp b/dlls/effects.cpp index c3216835..15df3bc3 100644 --- a/dlls/effects.cpp +++ b/dlls/effects.cpp @@ -280,12 +280,12 @@ void CBeam::RelinkBeam( void ) { const Vector &startPos = GetStartPos(), &endPos = GetEndPos(); - pev->mins.x = min( startPos.x, endPos.x ); - pev->mins.y = min( startPos.y, endPos.y ); - pev->mins.z = min( startPos.z, endPos.z ); - pev->maxs.x = max( startPos.x, endPos.x ); - pev->maxs.y = max( startPos.y, endPos.y ); - pev->maxs.z = max( startPos.z, endPos.z ); + pev->mins.x = Q_min( startPos.x, endPos.x ); + pev->mins.y = Q_min( startPos.y, endPos.y ); + pev->mins.z = Q_min( startPos.z, endPos.z ); + pev->maxs.x = Q_max( startPos.x, endPos.x ); + pev->maxs.y = Q_max( startPos.y, endPos.y ); + pev->maxs.z = Q_max( startPos.z, endPos.z ); pev->mins = pev->mins - pev->origin; pev->maxs = pev->maxs - pev->origin; diff --git a/dlls/extdll.h b/dlls/extdll.h index d9587bae..45c42309 100644 --- a/dlls/extdll.h +++ b/dlls/extdll.h @@ -88,11 +88,11 @@ typedef float vec_t; // needed before including progdefs.h // Shared header between the client DLL and the game DLLs #include "cdll_dll.h" -#ifndef min -#define min(a,b) (((a) < (b)) ? (a) : (b)) +#ifndef Q_min +#define Q_min(a,b) (((a) < (b)) ? (a) : (b)) #endif -#ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) +#ifndef Q_max +#define Q_max(a,b) (((a) > (b)) ? (a) : (b)) #endif #endif //EXTDLL_H diff --git a/dlls/hassassin.cpp b/dlls/hassassin.cpp index ff053595..f51ed4cb 100644 --- a/dlls/hassassin.cpp +++ b/dlls/hassassin.cpp @@ -699,12 +699,12 @@ void CHAssassin::RunAI( void ) EMIT_SOUND( ENT( pev ), CHAN_BODY, "debris/beamstart1.wav", 0.2, ATTN_NORM ); } - pev->renderamt = max( pev->renderamt - 50, m_iTargetRanderamt ); + pev->renderamt = Q_max( pev->renderamt - 50, m_iTargetRanderamt ); pev->rendermode = kRenderTransTexture; } else if( pev->renderamt < m_iTargetRanderamt ) { - pev->renderamt = min( pev->renderamt + 50, m_iTargetRanderamt ); + pev->renderamt = Q_min( pev->renderamt + 50, m_iTargetRanderamt ); if( pev->renderamt == 255 ) pev->rendermode = kRenderNormal; } diff --git a/dlls/items.cpp b/dlls/items.cpp index b0b2aa38..45edeb5e 100644 --- a/dlls/items.cpp +++ b/dlls/items.cpp @@ -227,7 +227,7 @@ class CItemBattery : public CItem char szcharge[64]; pPlayer->pev->armorvalue += gSkillData.batteryCapacity; - pPlayer->pev->armorvalue = min( pPlayer->pev->armorvalue, MAX_NORMAL_BATTERY ); + pPlayer->pev->armorvalue = Q_min( pPlayer->pev->armorvalue, MAX_NORMAL_BATTERY ); EMIT_SOUND( pPlayer->edict(), CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM ); diff --git a/dlls/maprules.cpp b/dlls/maprules.cpp index bfec93e2..519f7d2a 100644 --- a/dlls/maprules.cpp +++ b/dlls/maprules.cpp @@ -768,7 +768,7 @@ void CGamePlayerEquip::KeyValue( KeyValueData *pkvd ) m_weaponNames[i] = ALLOC_STRING( tmp ); m_weaponCount[i] = atoi( pkvd->szValue ); - m_weaponCount[i] = max( 1, m_weaponCount[i] ); + m_weaponCount[i] = Q_max( 1, m_weaponCount[i] ); pkvd->fHandled = TRUE; break; } diff --git a/dlls/monsters.cpp b/dlls/monsters.cpp index a9796a80..1e1d3de3 100644 --- a/dlls/monsters.cpp +++ b/dlls/monsters.cpp @@ -1959,7 +1959,7 @@ void CBaseMonster::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, f while( flTotal > 0.001 ) { // don't walk more than 16 units or stairs stop working - flStep = min( 16.0, flTotal ); + flStep = Q_min( 16.0, flTotal ); UTIL_MoveToOrigin( ENT( pev ), m_Route[m_iRouteIndex].vecLocation, flStep, MOVE_NORMAL ); flTotal -= flStep; } diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index 8d089696..7922d413 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -1368,15 +1368,15 @@ int ReloadMapCycleFile( const char *filename, mapcycle_t *cycle ) if( s && s[0] ) { item->minplayers = atoi( s ); - item->minplayers = max( item->minplayers, 0 ); - item->minplayers = min( item->minplayers, gpGlobals->maxClients ); + item->minplayers = Q_max( item->minplayers, 0 ); + item->minplayers = Q_min( item->minplayers, gpGlobals->maxClients ); } s = g_engfuncs.pfnInfoKeyValue( szBuffer, "maxplayers" ); if( s && s[0] ) { item->maxplayers = atoi( s ); - item->maxplayers = max( item->maxplayers, 0 ); - item->maxplayers = min( item->maxplayers, gpGlobals->maxClients ); + item->maxplayers = Q_max( item->maxplayers, 0 ); + item->maxplayers = Q_min( item->maxplayers, gpGlobals->maxClients ); } // Remove keys diff --git a/dlls/nihilanth.cpp b/dlls/nihilanth.cpp index 34375a58..1d072db4 100644 --- a/dlls/nihilanth.cpp +++ b/dlls/nihilanth.cpp @@ -478,7 +478,7 @@ void CNihilanth::DyingThink( void ) { if( m_pBall->pev->renderamt > 0 ) { - m_pBall->pev->renderamt = max( 0, m_pBall->pev->renderamt - 2 ); + m_pBall->pev->renderamt = Q_max( 0, m_pBall->pev->renderamt - 2 ); } else { @@ -895,7 +895,7 @@ void CNihilanth::HuntThink( void ) } else { - m_flAdj = min( m_flAdj + 10, 1000 ); + m_flAdj = Q_min( m_flAdj + 10, 1000 ); } } diff --git a/dlls/nodes.cpp b/dlls/nodes.cpp index b94f894b..04705638 100644 --- a/dlls/nodes.cpp +++ b/dlls/nodes.cpp @@ -793,12 +793,12 @@ void inline CalcBounds( int &Lower, int &Upper, int Goal, int Best ) int Temp = 2 * Goal - Best; if( Best > Goal ) { - Lower = max( 0, Temp ); + Lower = Q_max( 0, Temp ); Upper = Best; } else { - Upper = min( 255, Temp ); + Upper = Q_min( 255, Temp ); Lower = Best; } } @@ -962,7 +962,7 @@ int CGraph::FindNearestNode( const Vector &vecOrigin, int afNodeTypes ) } } - for( i = max( m_minY, halfY + 1 ); i <= m_maxY; i++ ) + for( i = Q_max( m_minY, halfY + 1 ); i <= m_maxY; i++ ) { for( j = m_RangeStart[1][i]; j <= m_RangeEnd[1][i]; j++ ) { @@ -987,7 +987,7 @@ int CGraph::FindNearestNode( const Vector &vecOrigin, int afNodeTypes ) } } - for( i = min( m_maxZ, halfZ ); i >= m_minZ; i-- ) + for( i = Q_min( m_maxZ, halfZ ); i >= m_minZ; i-- ) { for( j = m_RangeStart[2][i]; j <= m_RangeEnd[2][i]; j++ ) { @@ -1012,7 +1012,7 @@ int CGraph::FindNearestNode( const Vector &vecOrigin, int afNodeTypes ) } } - for( i = max( m_minX, halfX + 1 ); i <= m_maxX; i++ ) + for( i = Q_max( m_minX, halfX + 1 ); i <= m_maxX; i++ ) { for( j = m_RangeStart[0][i]; j <= m_RangeEnd[0][i]; j++ ) { @@ -1034,7 +1034,7 @@ int CGraph::FindNearestNode( const Vector &vecOrigin, int afNodeTypes ) } } - for( i = min( m_maxY, halfY ); i >= m_minY; i-- ) + for( i = Q_min( m_maxY, halfY ); i >= m_minY; i-- ) { for( j = m_RangeStart[1][i]; j <= m_RangeEnd[1][i]; j++ ) { @@ -1055,7 +1055,7 @@ int CGraph::FindNearestNode( const Vector &vecOrigin, int afNodeTypes ) } } - for( i = max( m_minZ, halfZ + 1 ); i <= m_maxZ; i++ ) + for( i = Q_max( m_minZ, halfZ + 1 ); i <= m_maxZ; i++ ) { for( j = m_RangeStart[2][i]; j <= m_RangeEnd[2][i]; j++ ) { diff --git a/dlls/player.cpp b/dlls/player.cpp index e5a01bae..757f03e4 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -2049,7 +2049,7 @@ void CBasePlayer::CheckTimeBasedDamage() // after the player has been drowning and finally takes a breath if( m_idrowndmg > m_idrownrestored ) { - int idif = min( m_idrowndmg - m_idrownrestored, 10 ); + int idif = Q_min( m_idrowndmg - m_idrownrestored, 10 ); TakeHealth( idif, DMG_GENERIC ); m_idrownrestored += idif; @@ -2606,23 +2606,23 @@ pt_end: if( gun && gun->UseDecrement() ) { - gun->m_flNextPrimaryAttack = max( gun->m_flNextPrimaryAttack - gpGlobals->frametime, -1.0 ); - gun->m_flNextSecondaryAttack = max( gun->m_flNextSecondaryAttack - gpGlobals->frametime, -0.001 ); + gun->m_flNextPrimaryAttack = Q_max( gun->m_flNextPrimaryAttack - gpGlobals->frametime, -1.0 ); + gun->m_flNextSecondaryAttack = Q_max( gun->m_flNextSecondaryAttack - gpGlobals->frametime, -0.001 ); if( gun->m_flTimeWeaponIdle != 1000 ) { - gun->m_flTimeWeaponIdle = max( gun->m_flTimeWeaponIdle - gpGlobals->frametime, -0.001 ); + gun->m_flTimeWeaponIdle = Q_max( gun->m_flTimeWeaponIdle - gpGlobals->frametime, -0.001 ); } if( gun->pev->fuser1 != 1000 ) { - gun->pev->fuser1 = max( gun->pev->fuser1 - gpGlobals->frametime, -0.001 ); + gun->pev->fuser1 = Q_max( gun->pev->fuser1 - gpGlobals->frametime, -0.001 ); } // Only decrement if not flagged as NO_DECREMENT /*if( gun->m_flPumpTime != 1000 ) { - gun->m_flPumpTime = max( gun->m_flPumpTime - gpGlobals->frametime, -0.001 ); + gun->m_flPumpTime = Q_max( gun->m_flPumpTime - gpGlobals->frametime, -0.001 ); }*/ } @@ -3705,7 +3705,7 @@ int CBasePlayer::GiveAmmo( int iCount, const char *szName, int iMax ) if( i < 0 || i >= MAX_AMMO_SLOTS ) return -1; - int iAdd = min( iCount, iMax - m_rgAmmo[i] ); + int iAdd = Q_min( iCount, iMax - m_rgAmmo[i] ); if( iAdd < 1 ) return i; @@ -3826,7 +3826,7 @@ void CBasePlayer::SendAmmoUpdate( void ) // send "Ammo" update message MESSAGE_BEGIN( MSG_ONE, gmsgAmmoX, NULL, pev ); WRITE_BYTE( i ); - WRITE_BYTE( max( min( m_rgAmmo[i], 254 ), 0 ) ); // clamp the value to one byte + WRITE_BYTE( Q_max( Q_min( m_rgAmmo[i], 254 ), 0 ) ); // clamp the value to one byte MESSAGE_END(); } } diff --git a/dlls/sound.cpp b/dlls/sound.cpp index 85b9f71d..31d0b7aa 100644 --- a/dlls/sound.cpp +++ b/dlls/sound.cpp @@ -1567,7 +1567,7 @@ void TEXTURETYPE_Init() continue; // null-terminate name and save in sentences array - j = min( j, CBTEXTURENAMEMAX - 1 + i ); + j = Q_min( j, CBTEXTURENAMEMAX - 1 + i ); buffer[j] = 0; strcpy( &( grgszTextureName[gcTextures++][0] ), &( buffer[i] ) ); } diff --git a/dlls/talkmonster.cpp b/dlls/talkmonster.cpp index 35bf3856..9180f037 100644 --- a/dlls/talkmonster.cpp +++ b/dlls/talkmonster.cpp @@ -403,11 +403,11 @@ void CTalkMonster::StartTask( Task_t *pTask ) if( yaw < 0 ) { - pev->ideal_yaw = min( yaw + 45, 0 ) + pev->angles.y; + pev->ideal_yaw = Q_min( yaw + 45, 0 ) + pev->angles.y; } else { - pev->ideal_yaw = max( yaw - 45, 0 ) + pev->angles.y; + pev->ideal_yaw = Q_max( yaw - 45, 0 ) + pev->angles.y; } } TaskComplete(); diff --git a/dlls/turret.cpp b/dlls/turret.cpp index ae95db14..093b2032 100644 --- a/dlls/turret.cpp +++ b/dlls/turret.cpp @@ -454,7 +454,7 @@ void CBaseTurret::EyeOff() { if( m_eyeBrightness > 0 ) { - m_eyeBrightness = max( 0, m_eyeBrightness - 30 ); + m_eyeBrightness = Q_max( 0, m_eyeBrightness - 30 ); m_pEyeGlow->SetBrightness( m_eyeBrightness ); } } diff --git a/dlls/util.cpp b/dlls/util.cpp index 68ba30cd..f382ac58 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -1112,7 +1112,7 @@ void UTIL_BloodStream( const Vector &origin, const Vector &direction, int color, WRITE_COORD( direction.y ); WRITE_COORD( direction.z ); WRITE_BYTE( color ); - WRITE_BYTE( min( amount, 255 ) ); + WRITE_BYTE( Q_min( amount, 255 ) ); MESSAGE_END(); } @@ -1144,7 +1144,7 @@ void UTIL_BloodDrips( const Vector &origin, const Vector &direction, int color, WRITE_SHORT( g_sModelIndexBloodSpray ); // initial sprite model WRITE_SHORT( g_sModelIndexBloodDrop ); // droplet sprite models WRITE_BYTE( color ); // color index into host_basepal - WRITE_BYTE( min( max( 3, amount / 10 ), 16 ) ); // size + WRITE_BYTE( Q_min( Q_max( 3, amount / 10 ), 16 ) ); // size MESSAGE_END(); } diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index a1205f27..80a45284 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -607,7 +607,7 @@ void CBasePlayerWeapon::ItemPostFrame( void ) if( ( m_fInReload ) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) ) { // complete the reload. - int j = min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); + int j = Q_min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); // Add them to the clip m_iClip += j; @@ -850,7 +850,7 @@ BOOL CBasePlayerWeapon::AddPrimaryAmmo( int iCount, char *szName, int iMaxClip, else if( m_iClip == 0 ) { int i; - i = min( m_iClip + iCount, iMaxClip ) - m_iClip; + i = Q_min( m_iClip + iCount, iMaxClip ) - m_iClip; m_iClip += i; iIdAmmo = m_pPlayer->GiveAmmo( iCount - i, szName, iMaxCarry ); } @@ -964,7 +964,7 @@ BOOL CBasePlayerWeapon::DefaultReload( int iClipSize, int iAnim, float fDelay, i if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) return FALSE; - int j = min( iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ); + int j = Q_min( iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ); if( j == 0 ) return FALSE; @@ -1428,7 +1428,7 @@ int CWeaponBox::GiveAmmo( int iCount, const char *szName, int iMax, int *pIndex/ if( pIndex ) *pIndex = i; - int iAdd = min( iCount, iMax - m_rgAmmo[i] ); + int iAdd = Q_min( iCount, iMax - m_rgAmmo[i] ); if( iCount == 0 || iAdd > 0 ) { m_rgAmmo[i] += iAdd; From 8e799fcf6d4fc6f3f685e07173d6e538968695ac Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 15 Oct 2017 14:22:14 +0500 Subject: [PATCH 111/144] Add crowbar idle animations under CROWBAR_IDLE_ANIM macro. --- cl_dll/ev_hldm.cpp | 6 ++++++ dlls/crowbar.cpp | 43 ++++++++++++++++++++++++++++++++++++++++++- dlls/weapons.h | 3 +++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 80073b27..628b5bfa 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -1138,7 +1138,13 @@ enum crowbar_e CROWBAR_ATTACK2MISS, CROWBAR_ATTACK2HIT, CROWBAR_ATTACK3MISS, +#ifndef CROWBAR_IDLE_ANIM CROWBAR_ATTACK3HIT +#else + CROWBAR_ATTACK3HIT, + CROWBAR_IDLE2, + CROWBAR_IDLE3 +#endif }; int g_iSwing; diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index f9a91978..4cc48d97 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -37,7 +37,13 @@ enum crowbar_e CROWBAR_ATTACK2MISS, CROWBAR_ATTACK2HIT, CROWBAR_ATTACK3MISS, +#ifndef CROWBAR_IDLE_ANIM CROWBAR_ATTACK3HIT +#else + CROWBAR_ATTACK3HIT, + CROWBAR_IDLE2, + CROWBAR_IDLE3 +#endif }; void CCrowbar::Spawn() @@ -208,7 +214,9 @@ int CCrowbar::Swing( int fFirst ) { // miss m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); - +#ifdef CROWBAR_IDLE_ANIM + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); +#endif // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); } @@ -324,5 +332,38 @@ int CCrowbar::Swing( int fFirst ) #endif m_flNextPrimaryAttack = GetNextAttackDelay( 0.25 ); } +#ifdef CROWBAR_IDLE_ANIM + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); +#endif return fDidHit; } + +#ifdef CROWBAR_IDLE_ANIM +void CCrowbar::WeaponIdle( void ) +{ + if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() ) + { + int iAnim; + float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); + if( flRand > 0.9 ) + { + iAnim = CROWBAR_IDLE2; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 160.0 / 30.0; + } + else + { + if( flRand > 0.5 ) + { + iAnim = CROWBAR_IDLE; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 70.0 / 30.0; + } + else + { + iAnim = CROWBAR_IDLE3; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 160.0 / 30.0; + } + } + SendWeaponAnim( iAnim ); + } +} +#endif diff --git a/dlls/weapons.h b/dlls/weapons.h index f48767c8..6c03105b 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -504,6 +504,9 @@ public: int Swing( int fFirst ); BOOL Deploy( void ); void Holster( int skiplocal = 0 ); +#ifdef CROWBAR_IDLE_ANIM + void WeaponIdle(); +#endif int m_iSwing; TraceResult m_trHit; From aaedd794c36cfae4bbecabf5ce9c55116307e3ee Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 15 Oct 2017 17:50:05 +0500 Subject: [PATCH 112/144] Merge https://github.com/LevShisterov/BugfixedHL/commit/293b41b8cd20f19179926284e4100f00e8e62fd7 --- dlls/player.cpp | 5 +++++ dlls/player.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/dlls/player.cpp b/dlls/player.cpp index 757f03e4..d0a1f763 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -2586,6 +2586,11 @@ void CBasePlayer::PostThink() UpdatePlayerSound(); pt_end: + if( pev->deadflag == DEAD_NO ) + m_vecLastViewAngles = pev->angles; + else + pev->angles = m_vecLastViewAngles; + // Track button info so we can detect 'pressed' and 'released' buttons next frame m_afButtonLast = pev->button; diff --git a/dlls/player.h b/dlls/player.h index 54e7fa85..fecaf3c9 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -306,6 +306,8 @@ public: void TabulateAmmo( void ); + Vector m_vecLastViewAngles; + float m_flStartCharge; float m_flAmmoStartCharge; float m_flPlayAftershock; From 5aa11a38b3148dd220321a745cbdb3194947f0ba Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Wed, 1 Nov 2017 16:43:29 +0300 Subject: [PATCH 113/144] Give player exhaustible weapons when taking ammo for them from weaponbox --- dlls/weapons.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 80a45284..5e4f8f78 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -1265,6 +1265,18 @@ void CWeaponBox::Kill( void ) UTIL_Remove( this ); } +static const char* IsAmmoForExhaustibleWeapon(const char* ammoName, int& weaponId) +{ + for (int i=0; im_rgpPlayerItems[j]; + while( pPlayerItem ) + { + if (pPlayerItem->m_iId == exhaustibleWeaponId) { + foundWeapon = true; + break; + } + pPlayerItem = pPlayerItem->m_pNext; + } + } + if (!foundWeapon) { + CBasePlayerWeapon* weapon = (CBasePlayerWeapon*)Create(weaponName, pev->origin, pev->angles); + if (weapon) { + weapon->pev->spawnflags |= SF_NORESPAWN; + weapon->m_iDefaultAmmo = 0; + if (pPlayer->AddPlayerItem(weapon)) { + weapon->AttachToPlayer(pPlayer); + } + } + } + } + // there's some ammo of this type. pPlayer->GiveAmmo( m_rgAmmo[i], STRING( m_rgiszAmmo[i] ), MaxAmmoCarry( m_rgiszAmmo[i] ) ); From 7d33351f77d7ac1f843c05a70bae8c9a8eabe8bf Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sat, 18 Nov 2017 14:49:01 +0500 Subject: [PATCH 114/144] Add missing file to build lists. --- dlls/Android.mk | 1 + dlls/CMakeLists.txt | 1 + dlls/Makefile | 1 + 3 files changed, 3 insertions(+) diff --git a/dlls/Android.mk b/dlls/Android.mk index b160c424..1dc79616 100644 --- a/dlls/Android.mk +++ b/dlls/Android.mk @@ -96,6 +96,7 @@ LOCAL_SRC_FILES := agrunt.cpp airtank.cpp \ plane.cpp \ plats.cpp \ player.cpp \ + playermonster.cpp \ python.cpp \ rat.cpp \ roach.cpp \ diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index e0b6a8b3..4e56ab44 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -98,6 +98,7 @@ set (SVDLL_SOURCES plane.cpp plats.cpp player.cpp + playermonster.cpp python.cpp rat.cpp roach.cpp diff --git a/dlls/Makefile b/dlls/Makefile index 9c3a84f2..60aad1b3 100644 --- a/dlls/Makefile +++ b/dlls/Makefile @@ -135,6 +135,7 @@ OBJ = \ $(DLL_OBJDIR)/plane.o \ $(DLL_OBJDIR)/plats.o \ $(DLL_OBJDIR)/player.o \ + $(DLL_OBJDIR)/playermonster.o \^M $(DLL_OBJDIR)/python.o \ $(DLL_OBJDIR)/rat.o \ $(DLL_OBJDIR)/roach.o \ From ad3a2141eb53a42b15dd6a994971900873530c9a Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sun, 3 Dec 2017 18:52:38 +0300 Subject: [PATCH 115/144] Change __MSC_VER to _MSC_VER to make the client buildable with VS 6 --- engine/cdll_int.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/cdll_int.h b/engine/cdll_int.h index d45bb9d5..20af4b55 100644 --- a/engine/cdll_int.h +++ b/engine/cdll_int.h @@ -93,7 +93,7 @@ typedef struct client_textmessage_s const char *pMessage; } client_textmessage_t; -#if __MSC_VER == 1200 +#if _MSC_VER == 1200 #define ulonglong_t __int64 #else #define ulonglong_t unsigned long long From 31b2a68d6d45bf4682043e9888b2f2b1f4f49df9 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Fri, 18 Nov 2016 01:05:05 +0300 Subject: [PATCH 116/144] goldsource mouse input --- CMakeLists.txt | 3 +- cl_dll/CMakeLists.txt | 42 +- cl_dll/input_goldsource.cpp | 1357 +++++++++++++++++++++++++++++++++++ cl_dll/inputw32.cpp | 901 ----------------------- 4 files changed, 1384 insertions(+), 919 deletions(-) create mode 100644 cl_dll/input_goldsource.cpp delete mode 100644 cl_dll/inputw32.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c2d6822..7719bac6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,7 @@ option(USE_VGUI2 "Enable VGUI2. UNDONE" OFF) option(USE_VOICEMGR "Enable VOICE MANAGER." OFF) option(BUILD_CLIENT "Build client dll" ON) option(BUILD_SERVER "Build server dll" ON) +option(GOLDSOURCE_SUPPORT "Build goldsource compatible client library" OFF) #----------------- # MAIN BUILD CODE \ @@ -59,4 +60,4 @@ endif() if(NOT BUILD_SERVER AND NOT BUILD_CLIENT) error("Nothing to build") -endif() \ No newline at end of file +endif() diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 7fffb29b..7bd04f77 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -26,24 +26,27 @@ project (CLDLL) set (CLDLL_LIBRARY client) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w") +if (GOLDSOURCE_SUPPORT) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -lSDL2 -Wl,--no-undefined") +endif() set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") -set (CLDLL_SOURCES - ../dlls/crossbow.cpp - ../dlls/crowbar.cpp - ../dlls/egon.cpp - ../dlls/gauss.cpp - ../dlls/handgrenade.cpp - ../dlls/hornetgun.cpp - ../dlls/mp5.cpp - ../dlls/python.cpp - ../dlls/rpg.cpp - ../dlls/satchel.cpp - ../dlls/shotgun.cpp - ../dlls/squeakgrenade.cpp - ../dlls/tripmine.cpp +set (CLDLL_SOURCES + ../dlls/crossbow.cpp + ../dlls/crowbar.cpp + ../dlls/egon.cpp + ../dlls/gauss.cpp + ../dlls/handgrenade.cpp + ../dlls/hornetgun.cpp + ../dlls/mp5.cpp + ../dlls/python.cpp + ../dlls/rpg.cpp + ../dlls/satchel.cpp + ../dlls/shotgun.cpp + ../dlls/squeakgrenade.cpp + ../dlls/tripmine.cpp ../dlls/glock.cpp - ev_hldm.cpp + ev_hldm.cpp hl/hl_baseentity.cpp hl/hl_events.cpp hl/hl_objects.cpp @@ -70,7 +73,6 @@ set (CLDLL_SOURCES hud_update.cpp in_camera.cpp input.cpp -#SRCS+=./inputw32.cpp menu.cpp message.cpp overview.cpp @@ -88,9 +90,15 @@ set (CLDLL_SOURCES tri.cpp util.cpp view.cpp - input_xash3d.cpp scoreboard.cpp MOTD.cpp) + +if (GOLDSOURCE_SUPPORT) + set (CLDLL_SOURCES "${CLDLL_SOURCES}" input_goldsource.cpp) +else() + set (CLDLL_SOURCES "${CLDLL_SOURCES}" input_xash3d.cpp) +endif() + include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public) if(USE_VOICEMGR) diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp new file mode 100644 index 00000000..70cd23c5 --- /dev/null +++ b/cl_dll/input_goldsource.cpp @@ -0,0 +1,1357 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +// in_win.c -- windows 95 mouse and joystick code +// 02/21/97 JCB Added extended DirectInput code to support external controllers. + +//#include "port.h" + +#include "hud.h" +#include "cl_util.h" +#include "camera.h" +#include "kbutton.h" +#include "cvardef.h" +#include "usercmd.h" +#include "const.h" +#include "camera.h" +#include "in_defs.h" +#include "keydefs.h" +#include "view.h" +//#include "Exports.h" + +#ifndef _WIN32 +#define USE_SDL2 +#endif + +#ifdef USE_SDL2 +#include +#include +#endif + +#ifdef _WIN32 +#include +#else +typedef unsigned int DWORD; +#endif + +#define MOUSE_BUTTON_COUNT 5 + +// use IN_SetVisibleMouse to set: +int iVisibleMouse = 0; + +extern cl_enginefunc_t gEngfuncs; + +extern int iMouseInUse; + +extern kbutton_t in_strafe; +extern kbutton_t in_mlook; +extern kbutton_t in_speed; +extern kbutton_t in_jlook; + +extern cvar_t *m_pitch; +extern cvar_t *m_yaw; +extern cvar_t *m_forward; +extern cvar_t *m_side; + +extern cvar_t *lookstrafe; +extern cvar_t *lookspring; +extern cvar_t *cl_pitchdown; +extern cvar_t *cl_pitchup; +extern cvar_t *cl_yawspeed; +extern cvar_t *cl_sidespeed; +extern cvar_t *cl_forwardspeed; +extern cvar_t *cl_pitchspeed; +extern cvar_t *cl_movespeedkey; + +#ifdef _WIN32 +static double s_flRawInputUpdateTime = 0.0f; +static bool m_bRawInput = false; +static bool m_bMouseThread = false; +bool isMouseRelative = false; +#endif + +#ifdef _WIN32 +#include "progdefs.h" +extern globalvars_t *gpGlobals; +#endif + +Vector dead_viewangles(0, 0, 0); + +void V_StopPitchDrift( void ) +{ + +} + +// mouse variables +cvar_t *m_filter; +cvar_t *sensitivity; + +// Custom mouse acceleration (0 disable, 1 to enable, 2 enable with separate yaw/pitch rescale) +static cvar_t *m_customaccel; +//Formula: mousesensitivity = ( rawmousedelta^m_customaccel_exponent ) * m_customaccel_scale + sensitivity +// If mode is 2, then x and y sensitivity are scaled by m_pitch and m_yaw respectively. +// Custom mouse acceleration value. +static cvar_t *m_customaccel_scale; +//Max mouse move scale factor, 0 for no limit +static cvar_t *m_customaccel_max; +//Mouse move is raised to this power before being scaled by scale factor +static cvar_t *m_customaccel_exponent; + +#ifdef _WIN32 +// if threaded mouse is enabled then the time to sleep between polls +static cvar_t *m_mousethread_sleep; +#endif + +int mouse_buttons; +int mouse_oldbuttonstate; +POINT current_pos; +int old_mouse_x, old_mouse_y, mx_accum, my_accum; +float mouse_x, mouse_y; + +static int restore_spi; +static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1}; +static int mouseactive = 0; +int mouseinitialized; +static int mouseparmsvalid; +static int mouseshowtoggle = 1; + +// joystick defines and variables +// where should defines be moved? +#define JOY_ABSOLUTE_AXIS 0x00000000 // control like a joystick +#define JOY_RELATIVE_AXIS 0x00000010 // control like a mouse, spinner, trackball +#define JOY_MAX_AXES 6 // X, Y, Z, R, U, V +#define JOY_AXIS_X 0 +#define JOY_AXIS_Y 1 +#define JOY_AXIS_Z 2 +#define JOY_AXIS_R 3 +#define JOY_AXIS_U 4 +#define JOY_AXIS_V 5 + +enum _ControlList +{ + AxisNada = 0, + AxisForward, + AxisLook, + AxisSide, + AxisTurn +}; + + +DWORD dwAxisMap[ JOY_MAX_AXES ]; +DWORD dwControlMap[ JOY_MAX_AXES ]; +int pdwRawValue[ JOY_MAX_AXES ]; +DWORD joy_oldbuttonstate, joy_oldpovstate; + +int joy_id; +DWORD joy_numbuttons; + +#ifdef USE_SDL2 +SDL_GameController *s_pJoystick = NULL; +#endif + +// none of these cvars are saved over a session +// this means that advanced controller configuration needs to be executed +// each time. this avoids any problems with getting back to a default usage +// or when changing from one controller to another. this way at least something +// works. +cvar_t *in_joystick; +cvar_t *joy_name; +cvar_t *joy_advanced; +cvar_t *joy_advaxisx; +cvar_t *joy_advaxisy; +cvar_t *joy_advaxisz; +cvar_t *joy_advaxisr; +cvar_t *joy_advaxisu; +cvar_t *joy_advaxisv; +cvar_t *joy_forwardthreshold; +cvar_t *joy_sidethreshold; +cvar_t *joy_pitchthreshold; +cvar_t *joy_yawthreshold; +cvar_t *joy_forwardsensitivity; +cvar_t *joy_sidesensitivity; +cvar_t *joy_pitchsensitivity; +cvar_t *joy_yawsensitivity; +cvar_t *joy_wwhack1; +cvar_t *joy_wwhack2; + +int joy_avail, joy_advancedinit, joy_haspov; + +#ifdef _WIN32 +unsigned int s_hMouseThreadId = 0; +HANDLE s_hMouseThread = 0; +HANDLE s_hMouseQuitEvent = 0; +HANDLE s_hMouseThreadActiveLock = 0; +#endif + +/* +=========== +Force_CenterView_f +=========== +*/ +void Force_CenterView_f (void) +{ + vec3_t viewangles; + + if (!iMouseInUse) + { + gEngfuncs.GetViewAngles( (float *)viewangles ); + viewangles[PITCH] = 0; + gEngfuncs.SetViewAngles( (float *)viewangles ); + } +} + +#ifdef _WIN32 + +LONG mouseThreadActive = 0; +LONG mouseThreadCenterX = 0; +LONG mouseThreadCenterY = 0; +LONG mouseThreadDeltaX = 0; +LONG mouseThreadDeltaY = 0; +LONG mouseThreadSleep = 0; + +bool MouseThread_ActiveLock_Enter( void ) +{ + if(!m_bMouseThread) + return true; + + return WAIT_OBJECT_0 == WaitForSingleObject( s_hMouseThreadActiveLock, INFINITE); +} + +void MouseThread_ActiveLock_Exit( void ) +{ + if(!m_bMouseThread) + return; + + SetEvent( s_hMouseThreadActiveLock ); +} + +unsigned __stdcall MouseThread_Function( void * pArg ) +{ + while ( true ) + { + DWORD sleepVal = (DWORD)InterlockedExchangeAdd(&mouseThreadSleep, 0); + if(0 > sleepVal) sleepVal = 0; + else if(1000 < sleepVal) sleepVal = 1000; + if(WAIT_OBJECT_0 == WaitForSingleObject( s_hMouseQuitEvent, sleepVal)) + { + break; + } + + if( MouseThread_ActiveLock_Enter() ) + { + if ( InterlockedExchangeAdd(&mouseThreadActive, 0) ) + { + POINT mouse_pos; + POINT center_pos; + + center_pos.x = InterlockedExchangeAdd(&mouseThreadCenterX, 0); + center_pos.y = InterlockedExchangeAdd(&mouseThreadCenterY, 0); + GetCursorPos(&mouse_pos); + + mouse_pos.x -= center_pos.x; + mouse_pos.y -= center_pos.y; + + if(mouse_pos.x || mouse_pos.y) SetCursorPos( center_pos.x, center_pos.y ); + + InterlockedExchangeAdd(&mouseThreadDeltaX, mouse_pos.x); + InterlockedExchangeAdd(&mouseThreadDeltaY, mouse_pos.y); + } + + MouseThread_ActiveLock_Exit(); + } + } + + return 0; +} + +/// Updates mouseThreadActive using the global variables mouseactive, iVisibleMouse and m_bRawInput. Should be called after any of these is changed. +/// Has to be interlocked manually by programmer! Use MouseThread_ActiveLock_Enter and MouseThread_ActiveLock_Exit. +void UpdateMouseThreadActive(void) +{ + InterlockedExchange(&mouseThreadActive, mouseactive && !iVisibleMouse && !m_bRawInput); +} + +#endif + +void IN_SetMouseMode(bool enable) +{ + static bool currentMouseMode = false; + + if(enable == currentMouseMode) + return; + + if(enable) + { +#ifdef _WIN32 + if (mouseparmsvalid) + restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0); + + m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0; + if(m_bRawInput) + { +#ifdef USE_SDL2 + SDL_SetRelativeMouseMode(SDL_TRUE); +#endif + isMouseRelative = true; + } +#else + SDL_SetRelativeMouseMode(SDL_TRUE); +#endif + + currentMouseMode = true; + } + else + { +#ifdef _WIN32 + if(isMouseRelative) + { +#ifdef USE_SDL2 + SDL_SetRelativeMouseMode(SDL_FALSE); +#endif + isMouseRelative = false; + } + + if (restore_spi) + SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0); +#else + SDL_SetRelativeMouseMode(SDL_FALSE); +#endif + + currentMouseMode = false; + } +} + +void IN_SetVisibleMouse(bool visible) +{ +#ifdef _WIN32 + bool lockEntered = MouseThread_ActiveLock_Enter(); +#endif + + iVisibleMouse = visible; + + IN_SetMouseMode(!visible); + +#ifdef _WIN32 + UpdateMouseThreadActive(); + if(lockEntered) MouseThread_ActiveLock_Exit(); +#endif +} + +void IN_ResetMouse( void ); + +/* +=========== +IN_ActivateMouse +=========== +*/ +extern "C" void DLLEXPORT IN_ActivateMouse (void) +{ + if (mouseinitialized) + { +#ifdef _WIN32 + bool lockEntered = MouseThread_ActiveLock_Enter(); +#endif + + IN_SetMouseMode(true); + + mouseactive = 1; + +#ifdef _WIN32 + UpdateMouseThreadActive(); + if(lockEntered) MouseThread_ActiveLock_Exit(); +#endif + + // now is a good time to reset mouse positon: + IN_ResetMouse(); + } +} + + +/* +=========== +IN_DeactivateMouse +=========== +*/ +extern "C" void DLLEXPORT IN_DeactivateMouse (void) +{ + if (mouseinitialized) + { +#ifdef _WIN32 + bool lockEntered = MouseThread_ActiveLock_Enter(); +#endif + + IN_SetMouseMode(false); + + mouseactive = 0; + +#ifdef _WIN32 + UpdateMouseThreadActive(); + if(lockEntered) MouseThread_ActiveLock_Exit(); +#endif + } +} + +/* +=========== +IN_StartupMouse +=========== +*/ +void IN_StartupMouse (void) +{ + if ( gEngfuncs.CheckParm ("-nomouse", NULL ) ) + return; + + mouseinitialized = 1; +#ifdef _WIN32 + mouseparmsvalid = SystemParametersInfo (SPI_GETMOUSE, 0, originalmouseparms, 0); + + if (mouseparmsvalid) + { + if ( gEngfuncs.CheckParm ("-noforcemspd", NULL ) ) + newmouseparms[2] = originalmouseparms[2]; + + if ( gEngfuncs.CheckParm ("-noforcemaccel", NULL ) ) + { + newmouseparms[0] = originalmouseparms[0]; + newmouseparms[1] = originalmouseparms[1]; + } + + if ( gEngfuncs.CheckParm ("-noforcemparms", NULL ) ) + { + newmouseparms[0] = originalmouseparms[0]; + newmouseparms[1] = originalmouseparms[1]; + newmouseparms[2] = originalmouseparms[2]; + } + } +#endif + + mouse_buttons = MOUSE_BUTTON_COUNT; +} + +/* +=========== +IN_Shutdown +=========== +*/ +void IN_Shutdown (void) +{ + IN_DeactivateMouse (); + +#ifdef _WIN32 + if ( s_hMouseQuitEvent ) + { + SetEvent( s_hMouseQuitEvent ); + } + + if ( s_hMouseThread ) + { + if(WAIT_OBJECT_0 != WaitForSingleObject( s_hMouseThread, 5000 )) + { + TerminateThread( s_hMouseThread, 0 ); + } + CloseHandle( s_hMouseThread ); + s_hMouseThread = (HANDLE)0; + } + + if ( s_hMouseQuitEvent ) + { + CloseHandle( s_hMouseQuitEvent ); + s_hMouseQuitEvent = (HANDLE)0; + } + + if( s_hMouseThreadActiveLock ) + { + CloseHandle( s_hMouseThreadActiveLock ); + s_hMouseThreadActiveLock = (HANDLE)0; + } +#endif +} + +/* +=========== +IN_GetMousePos + +Ask for mouse position from engine +=========== +*/ +void IN_GetMousePos( int *mx, int *my ) +{ + gEngfuncs.GetMousePosition( mx, my ); +} + +/* +=========== +IN_ResetMouse + +FIXME: Call through to engine? +=========== +*/ +void IN_ResetMouse( void ) +{ + // no work to do in SDL +#ifdef _WIN32 + // reset only if mouse is active and not in visible mode: + if(mouseactive && !iVisibleMouse) + { + if ( !m_bRawInput && gEngfuncs.GetWindowCenterX && gEngfuncs.GetWindowCenterY ) + { + bool lockEntered = MouseThread_ActiveLock_Enter(); + + int centerX = gEngfuncs.GetWindowCenterX(); + int centerY = gEngfuncs.GetWindowCenterY(); + + SetCursorPos ( centerX, centerY ); + InterlockedExchange( &mouseThreadCenterX, centerX ); + InterlockedExchange( &mouseThreadCenterY, centerY ); + InterlockedExchange( &mouseThreadDeltaX, 0 ); + InterlockedExchange( &mouseThreadDeltaY, 0 ); + + if(lockEntered) MouseThread_ActiveLock_Exit(); + } + } +#endif +} + +/* +=========== +IN_MouseEvent +=========== +*/ +extern "C" void DLLEXPORT IN_MouseEvent (int mstate) +{ + int i; + + if ( iMouseInUse || iVisibleMouse ) + return; + + // perform button actions + for (i=0 ; ivalue; + + // Using special accleration values + if ( m_customaccel->value != 0 ) + { + float raw_mouse_movement_distance = sqrt( mx * mx + my * my ); + float acceleration_scale = m_customaccel_scale->value; + float accelerated_sensitivity_max = m_customaccel_max->value; + float accelerated_sensitivity_exponent = m_customaccel_exponent->value; + float accelerated_sensitivity = ( (float)pow( raw_mouse_movement_distance, accelerated_sensitivity_exponent ) * acceleration_scale + mouse_senstivity ); + + if ( accelerated_sensitivity_max > 0.0001f && + accelerated_sensitivity > accelerated_sensitivity_max ) + { + accelerated_sensitivity = accelerated_sensitivity_max; + } + + *x *= accelerated_sensitivity; + *y *= accelerated_sensitivity; + + // Further re-scale by yaw and pitch magnitude if user requests alternate mode 2 + // This means that they will need to up their value for m_customaccel_scale greatly (>40x) since m_pitch/yaw default + // to 0.022 + if ( m_customaccel->value == 2 ) + { + *x *= m_yaw->value; + *y *= m_pitch->value; + } + } + else + { + // Just apply the default + *x *= mouse_senstivity; + *y *= mouse_senstivity; + } +} + +void IN_GetMouseDelta( int *pOutX, int *pOutY) +{ + bool active = mouseactive && !iVisibleMouse; + int mx, my; + + if(active) + { + int deltaX, deltaY; +#ifdef _WIN32 + if ( !m_bRawInput ) + { + if ( m_bMouseThread ) + { + // update mouseThreadSleep: + InterlockedExchange(&mouseThreadSleep, (LONG)m_mousethread_sleep->value); + + bool lockEntered = MouseThread_ActiveLock_Enter(); + + current_pos.x = InterlockedExchange( &mouseThreadDeltaX, 0 ); + current_pos.y = InterlockedExchange( &mouseThreadDeltaY, 0 ); + + if(lockEntered) MouseThread_ActiveLock_Exit(); + } + else + { + GetCursorPos (¤t_pos); + } + } + else +#endif + { +#ifdef USE_SDL2 + SDL_GetRelativeMouseState( &deltaX, &deltaY ); + current_pos.x = deltaX; + current_pos.y = deltaY; +#else + GetCursorPos (¤t_pos); + deltaX = current_pos.x - gEngfuncs.GetWindowCenterX(); + deltaY = current_pos.y - gEngfuncs.GetWindowCenterY(); +#endif + } + +#ifdef _WIN32 + if ( !m_bRawInput ) + { + if ( m_bMouseThread ) + { + mx = current_pos.x; + my = current_pos.y; + } + else + { + mx = current_pos.x - gEngfuncs.GetWindowCenterX() + mx_accum; + my = current_pos.y - gEngfuncs.GetWindowCenterY() + my_accum; + } + } + else +#endif + { + mx = deltaX + mx_accum; + my = deltaY + my_accum; + } + + mx_accum = 0; + my_accum = 0; + + // reset mouse position if required, so there is room to move: +#ifdef _WIN32 + // do not reset if mousethread would do it: + if ( m_bRawInput || !m_bMouseThread ) +#else + if(true) +#endif + IN_ResetMouse(); + +#ifdef _WIN32 + // update m_bRawInput occasionally: + if ( gpGlobals && gpGlobals->time - s_flRawInputUpdateTime > 1.0f ) + { + s_flRawInputUpdateTime = gpGlobals->time; + + bool lockEntered = MouseThread_ActiveLock_Enter(); + + m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0; + + if(m_bRawInput && !isMouseRelative) + { +#ifdef USE_SDL2 + SDL_SetRelativeMouseMode(SDL_TRUE); +#endif + isMouseRelative = true; + } + else if(!m_bRawInput && isMouseRelative) + { +#ifdef USE_SDL2 + SDL_SetRelativeMouseMode(SDL_FALSE); +#endif + isMouseRelative = false; + } + + UpdateMouseThreadActive(); + if(lockEntered) MouseThread_ActiveLock_Exit(); + } +#endif + } + else + { + mx = my = 0; + } + + if(pOutX) *pOutX = mx; + if(pOutY) *pOutY = my; +} + +/* +=========== +IN_MouseMove +=========== +*/ +void IN_MouseMove ( float frametime, usercmd_t *cmd) +{ + int mx, my; + vec3_t viewangles; + + gEngfuncs.GetViewAngles( (float *)viewangles ); + + if ( in_mlook.state & 1) + { + V_StopPitchDrift (); + } + + //jjb - this disbles normal mouse control if the user is trying to + // move the camera, or if the mouse cursor is visible or if we're in intermission + if ( !iMouseInUse && !gHUD.m_iIntermission && !iVisibleMouse ) + { + IN_GetMouseDelta( &mx, &my ); + + if (m_filter && m_filter->value) + { + mouse_x = (mx + old_mouse_x) * 0.5; + mouse_y = (my + old_mouse_y) * 0.5; + } + else + { + mouse_x = mx; + mouse_y = my; + } + + old_mouse_x = mx; + old_mouse_y = my; + + // Apply custom mouse scaling/acceleration + IN_ScaleMouse( &mouse_x, &mouse_y ); + + // add mouse X/Y movement to cmd + if ( (in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1) )) + cmd->sidemove += m_side->value * mouse_x; + else + viewangles[YAW] -= m_yaw->value * mouse_x; + + if ( (in_mlook.state & 1) && !(in_strafe.state & 1)) + { + viewangles[PITCH] += m_pitch->value * mouse_y; + if (viewangles[PITCH] > cl_pitchdown->value) + viewangles[PITCH] = cl_pitchdown->value; + if (viewangles[PITCH] < -cl_pitchup->value) + viewangles[PITCH] = -cl_pitchup->value; + } + else + { + if ((in_strafe.state & 1) && gEngfuncs.IsNoClipping() ) + { + cmd->upmove -= m_forward->value * mouse_y; + } + else + { + cmd->forwardmove -= m_forward->value * mouse_y; + } + } + } + + gEngfuncs.SetViewAngles( (float *)viewangles ); + +/* +//#define TRACE_TEST +#if defined( TRACE_TEST ) + { + int mx, my; + void V_Move( int mx, int my ); + IN_GetMousePos( &mx, &my ); + V_Move( mx, my ); + } +#endif +*/ +} + +/* +=========== +IN_Accumulate +=========== +*/ +extern "C" void DLLEXPORT IN_Accumulate (void) +{ + //only accumulate mouse if we are not moving the camera with the mouse + if ( !iMouseInUse && !iVisibleMouse) + { + if (mouseactive) + { +#ifdef _WIN32 + if ( !m_bRawInput ) + { + if ( !m_bMouseThread ) + { + GetCursorPos (¤t_pos); + + mx_accum += current_pos.x - gEngfuncs.GetWindowCenterX(); + my_accum += current_pos.y - gEngfuncs.GetWindowCenterY(); + } + } + else +#endif + { +#ifdef USE_SDL2 + int deltaX, deltaY; + SDL_GetRelativeMouseState( &deltaX, &deltaY ); + mx_accum += deltaX; + my_accum += deltaY; +#else + GetCursorPos (¤t_pos); + + mx_accum += current_pos.x - gEngfuncs.GetWindowCenterX(); + my_accum += current_pos.y - gEngfuncs.GetWindowCenterY(); +#endif + } + + // force the mouse to the center, so there's room to move +#ifdef _WIN32 + // do not reset if mousethread would do it: + if ( m_bRawInput || !m_bMouseThread ) +#else + if(true) +#endif + IN_ResetMouse(); + + } + } + +} + +/* +=================== +IN_ClearStates +=================== +*/ +extern "C" void DLLEXPORT IN_ClearStates (void) +{ + if ( !mouseactive ) + return; + + mx_accum = 0; + my_accum = 0; + mouse_oldbuttonstate = 0; +} + +/* +=============== +IN_StartupJoystick +=============== +*/ +void IN_StartupJoystick (void) +{ + // abort startup if user requests no joystick + if ( gEngfuncs.CheckParm ("-nojoy", NULL ) ) + return; + + // assume no joystick + joy_avail = 0; +#ifdef USE_SDL2 + int nJoysticks = SDL_NumJoysticks(); + if ( nJoysticks > 0 ) + { + for ( int i = 0; i < nJoysticks; i++ ) + { + if ( SDL_IsGameController( i ) ) + { + s_pJoystick = SDL_GameControllerOpen( i ); + if ( s_pJoystick ) + { + //save the joystick's number of buttons and POV status + joy_numbuttons = SDL_CONTROLLER_BUTTON_MAX; + joy_haspov = 0; + + // old button and POV states default to no buttons pressed + joy_oldbuttonstate = joy_oldpovstate = 0; + + // mark the joystick as available and advanced initialization not completed + // this is needed as cvars are not available during initialization + gEngfuncs.Con_Printf ("joystick found\n\n", SDL_GameControllerName(s_pJoystick)); + joy_avail = 1; + joy_advancedinit = 0; + break; + } + } + } + } + else + { + gEngfuncs.Con_DPrintf ("joystick not found -- driver not present\n\n"); + } +#else + gEngfuncs.Con_DPrintf ("joystick not found -- implement joystick without SDL2\n\n"); +#endif +} + +int RawValuePointer (int axis) +{ +#ifdef USE_SDL2 + switch (axis) + { + default: + case JOY_AXIS_X: + return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTX ); + case JOY_AXIS_Y: + return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTY ); + case JOY_AXIS_Z: + return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTX ); + case JOY_AXIS_R: + return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTY ); + + } +#else + // TODO: implement joystick without SDL2 + return 0; +#endif +} + +/* +=========== +Joy_AdvancedUpdate_f +=========== +*/ +void Joy_AdvancedUpdate_f (void) +{ + + // called once by IN_ReadJoystick and by user whenever an update is needed + // cvars are now available + int i; + DWORD dwTemp; + + // initialize all the maps + for (i = 0; i < JOY_MAX_AXES; i++) + { + dwAxisMap[i] = AxisNada; + dwControlMap[i] = JOY_ABSOLUTE_AXIS; + pdwRawValue[i] = RawValuePointer(i); + } + + if( joy_advanced->value == 0.0) + { + // default joystick initialization + // 2 axes only with joystick control + dwAxisMap[JOY_AXIS_X] = AxisTurn; + // dwControlMap[JOY_AXIS_X] = JOY_ABSOLUTE_AXIS; + dwAxisMap[JOY_AXIS_Y] = AxisForward; + // dwControlMap[JOY_AXIS_Y] = JOY_ABSOLUTE_AXIS; + } + else + { + if ( strcmp ( joy_name->string, "joystick") != 0 ) + { + // notify user of advanced controller + gEngfuncs.Con_Printf ("\n%s configured\n\n", joy_name->string); + } + + // advanced initialization here + // data supplied by user via joy_axisn cvars + dwTemp = (DWORD) joy_advaxisx->value; + dwAxisMap[JOY_AXIS_X] = dwTemp & 0x0000000f; + dwControlMap[JOY_AXIS_X] = dwTemp & JOY_RELATIVE_AXIS; + dwTemp = (DWORD) joy_advaxisy->value; + dwAxisMap[JOY_AXIS_Y] = dwTemp & 0x0000000f; + dwControlMap[JOY_AXIS_Y] = dwTemp & JOY_RELATIVE_AXIS; + dwTemp = (DWORD) joy_advaxisz->value; + dwAxisMap[JOY_AXIS_Z] = dwTemp & 0x0000000f; + dwControlMap[JOY_AXIS_Z] = dwTemp & JOY_RELATIVE_AXIS; + dwTemp = (DWORD) joy_advaxisr->value; + dwAxisMap[JOY_AXIS_R] = dwTemp & 0x0000000f; + dwControlMap[JOY_AXIS_R] = dwTemp & JOY_RELATIVE_AXIS; + dwTemp = (DWORD) joy_advaxisu->value; + dwAxisMap[JOY_AXIS_U] = dwTemp & 0x0000000f; + dwControlMap[JOY_AXIS_U] = dwTemp & JOY_RELATIVE_AXIS; + dwTemp = (DWORD) joy_advaxisv->value; + dwAxisMap[JOY_AXIS_V] = dwTemp & 0x0000000f; + dwControlMap[JOY_AXIS_V] = dwTemp & JOY_RELATIVE_AXIS; + } +} + + +/* +=========== +IN_Commands +=========== +*/ +void IN_Commands (void) +{ + int i, key_index; + + if (!joy_avail) + { + return; + } + + DWORD buttonstate, povstate; + + // loop through the joystick buttons + // key a joystick event or auxillary event for higher number buttons for each state change + buttonstate = 0; +#ifdef USE_SDL2 + for ( i = 0; i < SDL_CONTROLLER_BUTTON_MAX; i++ ) + { + if ( SDL_GameControllerGetButton( s_pJoystick, (SDL_GameControllerButton)i ) ) + { + buttonstate |= 1<value) + { + return; + } + + // collect the joystick data, if possible + if (IN_ReadJoystick () != 1) + { + return; + } + + if (in_speed.state & 1) + speed = cl_movespeedkey->value; + else + speed = 1; + + aspeed = speed * frametime; + + // loop through the axes + for (i = 0; i < JOY_MAX_AXES; i++) + { + // get the floating point zero-centered, potentially-inverted data for the current axis + fAxisValue = (float)pdwRawValue[i]; + + if (joy_wwhack2->value != 0.0) + { + if (dwAxisMap[i] == AxisTurn) + { + // this is a special formula for the Logitech WingMan Warrior + // y=ax^b; where a = 300 and b = 1.3 + // also x values are in increments of 800 (so this is factored out) + // then bounds check result to level out excessively high spin rates + fTemp = 300.0 * pow(abs(fAxisValue) / 800.0, 1.3); + if (fTemp > 14000.0) + fTemp = 14000.0; + // restore direction information + fAxisValue = (fAxisValue > 0.0) ? fTemp : -fTemp; + } + } + + // convert range from -32768..32767 to -1..1 + fAxisValue /= 32768.0; + + switch (dwAxisMap[i]) + { + case AxisForward: + if ((joy_advanced->value == 0.0) && (in_jlook.state & 1)) + { + // user wants forward control to become look control + if (fabs(fAxisValue) > joy_pitchthreshold->value) + { + // if mouse invert is on, invert the joystick pitch value + // only absolute control support here (joy_advanced is 0) + if (m_pitch->value < 0.0) + { + viewangles[PITCH] -= (fAxisValue * joy_pitchsensitivity->value) * aspeed * cl_pitchspeed->value; + } + else + { + viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity->value) * aspeed * cl_pitchspeed->value; + } + V_StopPitchDrift(); + } + else + { + // no pitch movement + // disable pitch return-to-center unless requested by user + // *** this code can be removed when the lookspring bug is fixed + // *** the bug always has the lookspring feature on + if(lookspring->value == 0.0) + { + V_StopPitchDrift(); + } + } + } + else + { + // user wants forward control to be forward control + if (fabs(fAxisValue) > joy_forwardthreshold->value) + { + cmd->forwardmove += (fAxisValue * joy_forwardsensitivity->value) * speed * cl_forwardspeed->value; + } + } + break; + + case AxisSide: + if (fabs(fAxisValue) > joy_sidethreshold->value) + { + cmd->sidemove += (fAxisValue * joy_sidesensitivity->value) * speed * cl_sidespeed->value; + } + break; + + case AxisTurn: + if ((in_strafe.state & 1) || (lookstrafe->value && (in_jlook.state & 1))) + { + // user wants turn control to become side control + if (fabs(fAxisValue) > joy_sidethreshold->value) + { + cmd->sidemove -= (fAxisValue * joy_sidesensitivity->value) * speed * cl_sidespeed->value; + } + } + else + { + // user wants turn control to be turn control + if (fabs(fAxisValue) > joy_yawthreshold->value) + { + if(dwControlMap[i] == JOY_ABSOLUTE_AXIS) + { + viewangles[YAW] += (fAxisValue * joy_yawsensitivity->value) * aspeed * cl_yawspeed->value; + } + else + { + viewangles[YAW] += (fAxisValue * joy_yawsensitivity->value) * speed * 180.0; + } + + } + } + break; + + case AxisLook: + if (in_jlook.state & 1) + { + if (fabs(fAxisValue) > joy_pitchthreshold->value) + { + // pitch movement detected and pitch movement desired by user + if(dwControlMap[i] == JOY_ABSOLUTE_AXIS) + { + viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity->value) * aspeed * cl_pitchspeed->value; + } + else + { + viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity->value) * speed * 180.0; + } + V_StopPitchDrift(); + } + else + { + // no pitch movement + // disable pitch return-to-center unless requested by user + // *** this code can be removed when the lookspring bug is fixed + // *** the bug always has the lookspring feature on + if( lookspring->value == 0.0 ) + { + V_StopPitchDrift(); + } + } + } + break; + + default: + break; + } + } + + // bounds check pitch + if (viewangles[PITCH] > cl_pitchdown->value) + viewangles[PITCH] = cl_pitchdown->value; + if (viewangles[PITCH] < -cl_pitchup->value) + viewangles[PITCH] = -cl_pitchup->value; + + gEngfuncs.SetViewAngles( (float *)viewangles ); +} + +/* +=========== +IN_Move +=========== +*/ +void IN_Move ( float frametime, usercmd_t *cmd) +{ + if ( !iMouseInUse && mouseactive ) + { + IN_MouseMove ( frametime, cmd); + } + + IN_JoyMove ( frametime, cmd); +} + +/* +=========== +IN_Init +=========== +*/ +void IN_Init (void) +{ + m_filter = gEngfuncs.pfnRegisterVariable ( "m_filter","0", FCVAR_ARCHIVE ); + sensitivity = gEngfuncs.pfnRegisterVariable ( "sensitivity","3", FCVAR_ARCHIVE ); // user mouse sensitivity setting. + + in_joystick = gEngfuncs.pfnRegisterVariable ( "joystick","0", FCVAR_ARCHIVE ); + joy_name = gEngfuncs.pfnRegisterVariable ( "joyname", "joystick", 0 ); + joy_advanced = gEngfuncs.pfnRegisterVariable ( "joyadvanced", "0", 0 ); + joy_advaxisx = gEngfuncs.pfnRegisterVariable ( "joyadvaxisx", "0", 0 ); + joy_advaxisy = gEngfuncs.pfnRegisterVariable ( "joyadvaxisy", "0", 0 ); + joy_advaxisz = gEngfuncs.pfnRegisterVariable ( "joyadvaxisz", "0", 0 ); + joy_advaxisr = gEngfuncs.pfnRegisterVariable ( "joyadvaxisr", "0", 0 ); + joy_advaxisu = gEngfuncs.pfnRegisterVariable ( "joyadvaxisu", "0", 0 ); + joy_advaxisv = gEngfuncs.pfnRegisterVariable ( "joyadvaxisv", "0", 0 ); + joy_forwardthreshold = gEngfuncs.pfnRegisterVariable ( "joyforwardthreshold", "0.15", 0 ); + joy_sidethreshold = gEngfuncs.pfnRegisterVariable ( "joysidethreshold", "0.15", 0 ); + joy_pitchthreshold = gEngfuncs.pfnRegisterVariable ( "joypitchthreshold", "0.15", 0 ); + joy_yawthreshold = gEngfuncs.pfnRegisterVariable ( "joyyawthreshold", "0.15", 0 ); + joy_forwardsensitivity = gEngfuncs.pfnRegisterVariable ( "joyforwardsensitivity", "-1.0", 0 ); + joy_sidesensitivity = gEngfuncs.pfnRegisterVariable ( "joysidesensitivity", "-1.0", 0 ); + joy_pitchsensitivity = gEngfuncs.pfnRegisterVariable ( "joypitchsensitivity", "1.0", 0 ); + joy_yawsensitivity = gEngfuncs.pfnRegisterVariable ( "joyyawsensitivity", "-1.0", 0 ); + joy_wwhack1 = gEngfuncs.pfnRegisterVariable ( "joywwhack1", "0.0", 0 ); + joy_wwhack2 = gEngfuncs.pfnRegisterVariable ( "joywwhack2", "0.0", 0 ); + + m_customaccel = gEngfuncs.pfnRegisterVariable ( "m_customaccel", "0", FCVAR_ARCHIVE ); + m_customaccel_scale = gEngfuncs.pfnRegisterVariable ( "m_customaccel_scale", "0.04", FCVAR_ARCHIVE ); + m_customaccel_max = gEngfuncs.pfnRegisterVariable ( "m_customaccel_max", "0", FCVAR_ARCHIVE ); + m_customaccel_exponent = gEngfuncs.pfnRegisterVariable ( "m_customaccel_exponent", "1", FCVAR_ARCHIVE ); + +#ifdef _WIN32 + m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0; + m_bMouseThread = gEngfuncs.CheckParm ("-mousethread", NULL ) != NULL; + m_mousethread_sleep = gEngfuncs.pfnRegisterVariable ( "m_mousethread_sleep", "1", FCVAR_ARCHIVE ); // default to less than 1000 Hz + + m_bMouseThread = m_bMouseThread && NULL != m_mousethread_sleep; + + if (m_bMouseThread) + { + // init mouseThreadSleep: +#if 0 // _beginthreadex is not defined on VS 6? + InterlockedExchange(&mouseThreadSleep, (LONG)m_mousethread_sleep->value); + + s_hMouseQuitEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); + s_hMouseThreadActiveLock = CreateEvent( NULL, FALSE, TRUE, NULL ); + if ( s_hMouseQuitEvent && s_hMouseThreadActiveLock) + { + s_hMouseThread = (HANDLE)_beginthreadex( NULL, 0, MouseThread_Function, NULL, 0, &s_hMouseThreadId ); + } + + m_bMouseThread = NULL != s_hMouseThread; +#else + m_bMouseThread = 0; +#endif + + // at this early stage this won't print anything: + // gEngfuncs.Con_DPrintf ("Mouse thread %s.\n", m_bMouseThread ? "initalized" : "failed to initalize"); + } +#endif + + gEngfuncs.pfnAddCommand ("force_centerview", Force_CenterView_f); + gEngfuncs.pfnAddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f); + + IN_StartupMouse (); + IN_StartupJoystick (); +} diff --git a/cl_dll/inputw32.cpp b/cl_dll/inputw32.cpp deleted file mode 100644 index 5c8210fa..00000000 --- a/cl_dll/inputw32.cpp +++ /dev/null @@ -1,901 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -// in_win.c -- windows 95 mouse and joystick code -// 02/21/97 JCB Added extended DirectInput code to support external controllers. - -#include "hud.h" -#include "cl_util.h" -#include "camera.h" -#include "kbutton.h" -#include "cvardef.h" -#include "usercmd.h" -#include "const.h" -#include "camera.h" -#include "in_defs.h" -#include "../engine/keydefs.h" -//#include "view.h" -#include "windows.h" - -#define MOUSE_BUTTON_COUNT 5 - -// Set this to 1 to show mouse cursor. Experimental -int g_iVisibleMouse = 0; - -extern "C" -{ - void DLLEXPORT IN_ActivateMouse( void ); - void DLLEXPORT IN_DeactivateMouse( void ); - void DLLEXPORT IN_MouseEvent( int mstate ); - void DLLEXPORT IN_Accumulate( void ); - void DLLEXPORT IN_ClearStates( void ); -} - -extern cl_enginefunc_t gEngfuncs; - -extern int iMouseInUse; - -extern kbutton_t in_strafe; -extern kbutton_t in_mlook; -extern kbutton_t in_speed; -extern kbutton_t in_jlook; - -extern cvar_t *m_pitch; -extern cvar_t *m_yaw; -extern cvar_t *m_forward; -extern cvar_t *m_side; - -extern cvar_t *lookstrafe; -extern cvar_t *lookspring; -extern cvar_t *cl_pitchdown; -extern cvar_t *cl_pitchup; -extern cvar_t *cl_yawspeed; -extern cvar_t *cl_sidespeed; -extern cvar_t *cl_forwardspeed; -extern cvar_t *cl_pitchspeed; -extern cvar_t *cl_movespeedkey; - -// mouse variables -cvar_t *m_filter; -cvar_t *sensitivity; - -int mouse_buttons; -int mouse_oldbuttonstate; -POINT current_pos; -int mouse_x, mouse_y, old_mouse_x, old_mouse_y, mx_accum, my_accum; - -static int restore_spi; -static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1}; -static int mouseactive; -int mouseinitialized; -static int mouseparmsvalid; -static int mouseshowtoggle = 1; - -// joystick defines and variables -// where should defines be moved? -#define JOY_ABSOLUTE_AXIS 0x00000000 // control like a joystick -#define JOY_RELATIVE_AXIS 0x00000010 // control like a mouse, spinner, trackball -#define JOY_MAX_AXES 6 // X, Y, Z, R, U, V -#define JOY_AXIS_X 0 -#define JOY_AXIS_Y 1 -#define JOY_AXIS_Z 2 -#define JOY_AXIS_R 3 -#define JOY_AXIS_U 4 -#define JOY_AXIS_V 5 - -enum _ControlList -{ - AxisNada = 0, - AxisForward, - AxisLook, - AxisSide, - AxisTurn -}; - -DWORD dwAxisFlags[JOY_MAX_AXES] = -{ - JOY_RETURNX, - JOY_RETURNY, - JOY_RETURNZ, - JOY_RETURNR, - JOY_RETURNU, - JOY_RETURNV -}; - -DWORD dwAxisMap[JOY_MAX_AXES]; -DWORD dwControlMap[JOY_MAX_AXES]; -PDWORD pdwRawValue[JOY_MAX_AXES]; - -// none of these cvars are saved over a session -// this means that advanced controller configuration needs to be executed -// each time. this avoids any problems with getting back to a default usage -// or when changing from one controller to another. this way at least something -// works. -cvar_t *in_joystick; -cvar_t *joy_name; -cvar_t *joy_advanced; -cvar_t *joy_advaxisx; -cvar_t *joy_advaxisy; -cvar_t *joy_advaxisz; -cvar_t *joy_advaxisr; -cvar_t *joy_advaxisu; -cvar_t *joy_advaxisv; -cvar_t *joy_forwardthreshold; -cvar_t *joy_sidethreshold; -cvar_t *joy_pitchthreshold; -cvar_t *joy_yawthreshold; -cvar_t *joy_forwardsensitivity; -cvar_t *joy_sidesensitivity; -cvar_t *joy_pitchsensitivity; -cvar_t *joy_yawsensitivity; -cvar_t *joy_wwhack1; -cvar_t *joy_wwhack2; - -int joy_avail, joy_advancedinit, joy_haspov; -DWORD joy_oldbuttonstate, joy_oldpovstate; - -int joy_id; -DWORD joy_flags; -DWORD joy_numbuttons; - -static JOYINFOEX ji; - -/* -=========== -Force_CenterView_f -=========== -*/ -void Force_CenterView_f( void ) -{ - vec3_t viewangles; - - if( !iMouseInUse ) - { - gEngfuncs.GetViewAngles( (float *)viewangles ); - viewangles[PITCH] = 0; - gEngfuncs.SetViewAngles( (float *)viewangles ); - } -} - -/* -=========== -IN_ActivateMouse -=========== -*/ -void DLLEXPORT IN_ActivateMouse( void ) -{ - if( mouseinitialized ) - { - if( mouseparmsvalid ) - restore_spi = SystemParametersInfo( SPI_SETMOUSE, 0, newmouseparms, 0 ); - mouseactive = 1; - } -} - -/* -=========== -IN_DeactivateMouse -=========== -*/ -void DLLEXPORT IN_DeactivateMouse( void ) -{ - if( mouseinitialized ) - { - if( restore_spi ) - SystemParametersInfo( SPI_SETMOUSE, 0, originalmouseparms, 0 ); - mouseactive = 0; - } -} - -/* -=========== -IN_StartupMouse -=========== -*/ -void IN_StartupMouse( void ) -{ - if( gEngfuncs.CheckParm( "-nomouse", NULL ) ) - return; - - mouseinitialized = 1; - mouseparmsvalid = SystemParametersInfo( SPI_GETMOUSE, 0, originalmouseparms, 0 ); - - if( mouseparmsvalid ) - { - if( gEngfuncs.CheckParm( "-noforcemspd", NULL ) ) - newmouseparms[2] = originalmouseparms[2]; - - if( gEngfuncs.CheckParm( "-noforcemaccel", NULL ) ) - { - newmouseparms[0] = originalmouseparms[0]; - newmouseparms[1] = originalmouseparms[1]; - } - - if( gEngfuncs.CheckParm( "-noforcemparms", NULL ) ) - { - newmouseparms[0] = originalmouseparms[0]; - newmouseparms[1] = originalmouseparms[1]; - newmouseparms[2] = originalmouseparms[2]; - } - } - - mouse_buttons = MOUSE_BUTTON_COUNT; -} - -/* -=========== -IN_Shutdown -=========== -*/ -void IN_Shutdown( void ) -{ - IN_DeactivateMouse (); -} - -/* -=========== -IN_GetMousePos - -Ask for mouse position from engine -=========== -*/ -void IN_GetMousePos( int *mx, int *my ) -{ - gEngfuncs.GetMousePosition( mx, my ); -} - -/* -=========== -IN_ResetMouse - -FIXME: Call through to engine? -=========== -*/ -void IN_ResetMouse( void ) -{ - SetCursorPos ( gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY() ); -} - -/* -=========== -IN_MouseEvent -=========== -*/ -void DLLEXPORT IN_MouseEvent( int mstate ) -{ - int i; - - if( iMouseInUse || g_iVisibleMouse ) - return; - - // perform button actions - for( i = 0; i < mouse_buttons; i++ ) - { - if( ( mstate & ( 1 << i ) ) && - !( mouse_oldbuttonstate & ( 1 << i ) ) ) - { - gEngfuncs.Key_Event( K_MOUSE1 + i, 1 ); - } - - if( !( mstate & ( 1 << i ) ) && - ( mouse_oldbuttonstate & ( 1 << i ) ) ) - { - gEngfuncs.Key_Event( K_MOUSE1 + i, 0 ); - } - } - - mouse_oldbuttonstate = mstate; -} - -/* -=========== -IN_MouseMove -=========== -*/ -void IN_MouseMove( float frametime, usercmd_t *cmd ) -{ - int mx, my; - vec3_t viewangles; - - gEngfuncs.GetViewAngles( (float *)viewangles ); - - //jjb - this disbles normal mouse control if the user is trying to - // move the camera, or if the mouse cursor is visible or if we're in intermission - if( !iMouseInUse && !g_iVisibleMouse && !gHUD.m_iIntermission ) - { - GetCursorPos( ¤t_pos ); - - mx = current_pos.x - gEngfuncs.GetWindowCenterX() + mx_accum; - my = current_pos.y - gEngfuncs.GetWindowCenterY() + my_accum; - - mx_accum = 0; - my_accum = 0; - - if( m_filter->value ) - { - mouse_x = ( mx + old_mouse_x ) * 0.5; - mouse_y = ( my + old_mouse_y ) * 0.5; - } - else - { - mouse_x = mx; - mouse_y = my; - } - - old_mouse_x = mx; - old_mouse_y = my; - - if( gHUD.GetSensitivity() != 0 ) - { - mouse_x *= gHUD.GetSensitivity(); - mouse_y *= gHUD.GetSensitivity(); - } - else - { - mouse_x *= sensitivity->value; - mouse_y *= sensitivity->value; - } - - // add mouse X/Y movement to cmd - if( ( in_strafe.state & 1 ) || ( lookstrafe->value && ( in_mlook.state & 1 ) ) ) - cmd->sidemove += m_side->value * mouse_x; - else - viewangles[YAW] -= m_yaw->value * mouse_x; - - if( ( in_mlook.state & 1 ) && !( in_strafe.state & 1 ) ) - { - viewangles[PITCH] += m_pitch->value * mouse_y; - if( viewangles[PITCH] > cl_pitchdown->value ) - viewangles[PITCH] = cl_pitchdown->value; - if( viewangles[PITCH] < -cl_pitchup->value ) - viewangles[PITCH] = -cl_pitchup->value; - } - else - { - if( ( in_strafe.state & 1 ) && gEngfuncs.IsNoClipping() ) - { - cmd->upmove -= m_forward->value * mouse_y; - } - else - { - cmd->forwardmove -= m_forward->value * mouse_y; - } - } - - // if the mouse has moved, force it to the center, so there's room to move - if( mx || my ) - { - IN_ResetMouse(); - } - } - - gEngfuncs.SetViewAngles( (float *)viewangles ); - -/* -//#define TRACE_TEST -#if defined( TRACE_TEST ) - { - int mx, my; - void V_Move( int mx, int my ); - IN_GetMousePos( &mx, &my ); - V_Move( mx, my ); - } -#endif -*/ -} - -/* -=========== -IN_Accumulate -=========== -*/ -void DLLEXPORT IN_Accumulate( void ) -{ - //only accumulate mouse if we are not moving the camera with the mouse - if( !iMouseInUse && !g_iVisibleMouse ) - { - if( mouseactive ) - { - GetCursorPos( ¤t_pos ); - - mx_accum += current_pos.x - gEngfuncs.GetWindowCenterX(); - my_accum += current_pos.y - gEngfuncs.GetWindowCenterY(); - - // force the mouse to the center, so there's room to move - IN_ResetMouse(); - } - } -} - -/* -=================== -IN_ClearStates -=================== -*/ -void DLLEXPORT IN_ClearStates( void ) -{ - if( !mouseactive ) - return; - - mx_accum = 0; - my_accum = 0; - mouse_oldbuttonstate = 0; -} - -/* -=============== -IN_StartupJoystick -=============== -*/ -void IN_StartupJoystick( void ) -{ - int numdevs; - JOYCAPS jc; - MMRESULT mmr; - - // assume no joystick - joy_avail = 0; - - // abort startup if user requests no joystick - if( gEngfuncs.CheckParm( "-nojoy", NULL ) ) - return; - - // verify joystick driver is present - if( ( numdevs = joyGetNumDevs() ) == 0 ) - { - gEngfuncs.Con_DPrintf( "joystick not found -- driver not present\n\n" ); - return; - } - - // cycle through the joystick ids for the first valid one - for( joy_id = 0; joy_id < numdevs; joy_id++ ) - { - memset( &ji, 0, sizeof(ji) ); - ji.dwSize = sizeof(ji); - ji.dwFlags = JOY_RETURNCENTERED; - - if( ( mmr = joyGetPosEx( joy_id, &ji ) ) == JOYERR_NOERROR ) - break; - } - - // abort startup if we didn't find a valid joystick - if( mmr != JOYERR_NOERROR ) - { - gEngfuncs.Con_DPrintf( "joystick not found -- no valid joysticks (%x)\n\n", mmr ); - return; - } - - // get the capabilities of the selected joystick - // abort startup if command fails - memset( &jc, 0, sizeof(jc) ); - if( ( mmr = joyGetDevCaps( joy_id, &jc, sizeof(jc) ) ) != JOYERR_NOERROR ) - { - gEngfuncs.Con_DPrintf( "joystick not found -- invalid joystick capabilities (%x)\n\n", mmr ); - return; - } - - // save the joystick's number of buttons and POV status - joy_numbuttons = jc.wNumButtons; - joy_haspov = jc.wCaps & JOYCAPS_HASPOV; - - // old button and POV states default to no buttons pressed - joy_oldbuttonstate = joy_oldpovstate = 0; - - // mark the joystick as available and advanced initialization not completed - // this is needed as cvars are not available during initialization - gEngfuncs.Con_Printf( "joystick found\n\n", mmr ); - joy_avail = 1; - joy_advancedinit = 0; -} - -/* -=========== -RawValuePointer -=========== -*/ -PDWORD RawValuePointer( int axis ) -{ - switch( axis ) - { - case JOY_AXIS_X: - return &ji.dwXpos; - case JOY_AXIS_Y: - return &ji.dwYpos; - case JOY_AXIS_Z: - return &ji.dwZpos; - case JOY_AXIS_R: - return &ji.dwRpos; - case JOY_AXIS_U: - return &ji.dwUpos; - case JOY_AXIS_V: - return &ji.dwVpos; - } - // FIX: need to do some kind of error - return &ji.dwXpos; -} - -/* -=========== -Joy_AdvancedUpdate_f -=========== -*/ -void Joy_AdvancedUpdate_f( void ) -{ - // called once by IN_ReadJoystick and by user whenever an update is needed - // cvars are now available - int i; - DWORD dwTemp; - - // initialize all the maps - for( i = 0; i < JOY_MAX_AXES; i++ ) - { - dwAxisMap[i] = AxisNada; - dwControlMap[i] = JOY_ABSOLUTE_AXIS; - pdwRawValue[i] = RawValuePointer(i); - } - - if( joy_advanced->value == 0.0 ) - { - // default joystick initialization - // 2 axes only with joystick control - dwAxisMap[JOY_AXIS_X] = AxisTurn; - // dwControlMap[JOY_AXIS_X] = JOY_ABSOLUTE_AXIS; - dwAxisMap[JOY_AXIS_Y] = AxisForward; - // dwControlMap[JOY_AXIS_Y] = JOY_ABSOLUTE_AXIS; - } - else - { - if( strcmp( joy_name->string, "joystick" ) != 0 ) - { - // notify user of advanced controller - gEngfuncs.Con_Printf( "\n%s configured\n\n", joy_name->string ); - } - - // advanced initialization here - // data supplied by user via joy_axisn cvars - dwTemp = (DWORD)joy_advaxisx->value; - dwAxisMap[JOY_AXIS_X] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_X] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD)joy_advaxisy->value; - dwAxisMap[JOY_AXIS_Y] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_Y] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD)joy_advaxisz->value; - dwAxisMap[JOY_AXIS_Z] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_Z] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD)joy_advaxisr->value; - dwAxisMap[JOY_AXIS_R] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_R] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD)joy_advaxisu->value; - dwAxisMap[JOY_AXIS_U] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_U] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD)joy_advaxisv->value; - dwAxisMap[JOY_AXIS_V] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_V] = dwTemp & JOY_RELATIVE_AXIS; - } - - // compute the axes to collect from DirectInput - joy_flags = JOY_RETURNCENTERED | JOY_RETURNBUTTONS | JOY_RETURNPOV; - for( i = 0; i < JOY_MAX_AXES; i++ ) - { - if( dwAxisMap[i] != AxisNada ) - { - joy_flags |= dwAxisFlags[i]; - } - } -} - -/* -=========== -IN_Commands -=========== -*/ -void IN_Commands( void ) -{ - int i, key_index; - DWORD buttonstate, povstate; - - if( !joy_avail ) - { - return; - } - - // loop through the joystick buttons - // key a joystick event or auxillary event for higher number buttons for each state change - buttonstate = ji.dwButtons; - for( i = 0; i < (int)joy_numbuttons; i++ ) - { - if( ( buttonstate & ( 1 << i ) ) && !( joy_oldbuttonstate & ( 1 << i ) ) ) - { - key_index = ( i < 4 ) ? K_JOY1 : K_AUX1; - gEngfuncs.Key_Event( key_index + i, 1 ); - } - - if( !( buttonstate & ( 1 << i ) ) && ( joy_oldbuttonstate & ( 1 << i ) ) ) - { - key_index = ( i < 4 ) ? K_JOY1 : K_AUX1; - gEngfuncs.Key_Event( key_index + i, 0 ); - } - } - joy_oldbuttonstate = buttonstate; - - if( joy_haspov ) - { - // convert POV information into 4 bits of state information - // this avoids any potential problems related to moving from one - // direction to another without going through the center position - povstate = 0; - if( ji.dwPOV != JOY_POVCENTERED ) - { - if( ji.dwPOV == JOY_POVFORWARD ) - povstate |= 0x01; - if( ji.dwPOV == JOY_POVRIGHT ) - povstate |= 0x02; - if( ji.dwPOV == JOY_POVBACKWARD ) - povstate |= 0x04; - if( ji.dwPOV == JOY_POVLEFT ) - povstate |= 0x08; - } - // determine which bits have changed and key an auxillary event for each change - for( i = 0; i < 4; i++ ) - { - if( ( povstate & ( 1 << i ) ) && !( joy_oldpovstate & ( 1 << i ) ) ) - { - gEngfuncs.Key_Event( K_AUX29 + i, 1 ); - } - - if( !( povstate & ( 1 << i ) ) && ( joy_oldpovstate & ( 1 << i ) ) ) - { - gEngfuncs.Key_Event( K_AUX29 + i, 0 ); - } - } - joy_oldpovstate = povstate; - } -} - -/* -=============== -IN_ReadJoystick -=============== -*/ -int IN_ReadJoystick( void ) -{ - memset( &ji, 0, sizeof(ji) ); - ji.dwSize = sizeof(ji); - ji.dwFlags = joy_flags; - - if( joyGetPosEx( joy_id, &ji ) == JOYERR_NOERROR ) - { - // this is a hack -- there is a bug in the Logitech WingMan Warrior DirectInput Driver - // rather than having 32768 be the zero point, they have the zero point at 32668 - // go figure -- anyway, now we get the full resolution out of the device - if( joy_wwhack1->value != 0.0 ) - { - ji.dwUpos += 100; - } - return 1; - } - else - { - // read error occurred - // turning off the joystick seems too harsh for 1 read error,\ - // but what should be done? - // Con_Printf( "IN_ReadJoystick: no response\n" ); - // joy_avail = 0; - return 0; - } -} - -/* -=========== -IN_JoyMove -=========== -*/ -void IN_JoyMove( float frametime, usercmd_t *cmd ) -{ - float speed, aspeed; - float fAxisValue, fTemp; - int i; - vec3_t viewangles; - - gEngfuncs.GetViewAngles( (float *)viewangles ); - - // complete initialization if first time in - // this is needed as cvars are not available at initialization time - if( joy_advancedinit != 1 ) - { - Joy_AdvancedUpdate_f(); - joy_advancedinit = 1; - } - - // verify joystick is available and that the user wants to use it - if( !joy_avail || !in_joystick->value ) - { - return; - } - - // collect the joystick data, if possible - if( IN_ReadJoystick () != 1 ) - { - return; - } - - if( in_speed.state & 1 ) - speed = cl_movespeedkey->value; - else - speed = 1; - - aspeed = speed * frametime; - - // loop through the axes - for( i = 0; i < JOY_MAX_AXES; i++ ) - { - // get the floating point zero-centered, potentially-inverted data for the current axis - fAxisValue = (float) *pdwRawValue[i]; - // move centerpoint to zero - fAxisValue -= 32768.0; - - if( joy_wwhack2->value != 0.0 ) - { - if( dwAxisMap[i] == AxisTurn ) - { - // this is a special formula for the Logitech WingMan Warrior - // y=ax^b; where a = 300 and b = 1.3 - // also x values are in increments of 800 (so this is factored out) - // then bounds check result to level out excessively high spin rates - fTemp = 300.0 * pow( abs( fAxisValue ) / 800.0, 1.3 ); - if( fTemp > 14000.0 ) - fTemp = 14000.0; - // restore direction information - fAxisValue = ( fAxisValue > 0.0 ) ? fTemp : -fTemp; - } - } - - // convert range from -32768..32767 to -1..1 - fAxisValue /= 32768.0; - - switch( dwAxisMap[i] ) - { - case AxisForward: - if( ( joy_advanced->value == 0.0 ) && ( in_jlook.state & 1 ) ) - { - // user wants forward control to become look control - if( fabs( fAxisValue ) > joy_pitchthreshold->value ) - { - // if mouse invert is on, invert the joystick pitch value - // only absolute control support here (joy_advanced is 0) - if( m_pitch->value < 0.0 ) - { - viewangles[PITCH] -= ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value; - } - else - { - viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value; - } - } - } - else - { - // user wants forward control to be forward control - if( fabs( fAxisValue ) > joy_forwardthreshold->value ) - { - cmd->forwardmove += ( fAxisValue * joy_forwardsensitivity->value ) * speed * cl_forwardspeed->value; - } - } - break; - case AxisSide: - if( fabs( fAxisValue ) > joy_sidethreshold->value ) - { - cmd->sidemove += ( fAxisValue * joy_sidesensitivity->value ) * speed * cl_sidespeed->value; - } - break; - case AxisTurn: - if( ( in_strafe.state & 1 ) || ( lookstrafe->value && ( in_jlook.state & 1 ) ) ) - { - // user wants turn control to become side control - if( fabs( fAxisValue ) > joy_sidethreshold->value ) - { - cmd->sidemove -= ( fAxisValue * joy_sidesensitivity->value ) * speed * cl_sidespeed->value; - } - } - else - { - // user wants turn control to be turn control - if( fabs( fAxisValue ) > joy_yawthreshold->value ) - { - if( dwControlMap[i] == JOY_ABSOLUTE_AXIS ) - { - viewangles[YAW] += ( fAxisValue * joy_yawsensitivity->value ) * aspeed * cl_yawspeed->value; - } - else - { - viewangles[YAW] += ( fAxisValue * joy_yawsensitivity->value ) * speed * 180.0; - } - } - } - break; - case AxisLook: - if( in_jlook.state & 1 ) - { - if( fabs( fAxisValue ) > joy_pitchthreshold->value ) - { - // pitch movement detected and pitch movement desired by user - if( dwControlMap[i] == JOY_ABSOLUTE_AXIS ) - { - viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value; - } - else - { - viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * speed * 180.0; - } - } - } - break; - default: - break; - } - } - - // bounds check pitch - if( viewangles[PITCH] > cl_pitchdown->value ) - viewangles[PITCH] = cl_pitchdown->value; - if( viewangles[PITCH] < -cl_pitchup->value ) - viewangles[PITCH] = -cl_pitchup->value; - - gEngfuncs.SetViewAngles( (float *)viewangles ); -} - -/* -=========== -IN_Move -=========== -*/ -void IN_Move( float frametime, usercmd_t *cmd ) -{ - if( !iMouseInUse && mouseactive ) - { - IN_MouseMove( frametime, cmd ); - } - - IN_JoyMove( frametime, cmd ); -} - -/* -=========== -IN_Init -=========== -*/ -void IN_Init( void ) -{ - m_filter = gEngfuncs.pfnRegisterVariable( "m_filter","0", FCVAR_ARCHIVE ); - sensitivity = gEngfuncs.pfnRegisterVariable( "sensitivity","3", FCVAR_ARCHIVE ); // user mouse sensitivity setting. - - in_joystick = gEngfuncs.pfnRegisterVariable( "joystick","0", FCVAR_ARCHIVE ); - joy_name = gEngfuncs.pfnRegisterVariable( "joyname", "joystick", 0 ); - joy_advanced = gEngfuncs.pfnRegisterVariable( "joyadvanced", "0", 0 ); - joy_advaxisx = gEngfuncs.pfnRegisterVariable( "joyadvaxisx", "0", 0 ); - joy_advaxisy = gEngfuncs.pfnRegisterVariable( "joyadvaxisy", "0", 0 ); - joy_advaxisz = gEngfuncs.pfnRegisterVariable( "joyadvaxisz", "0", 0 ); - joy_advaxisr = gEngfuncs.pfnRegisterVariable( "joyadvaxisr", "0", 0 ); - joy_advaxisu = gEngfuncs.pfnRegisterVariable( "joyadvaxisu", "0", 0 ); - joy_advaxisv = gEngfuncs.pfnRegisterVariable( "joyadvaxisv", "0", 0 ); - joy_forwardthreshold = gEngfuncs.pfnRegisterVariable( "joyforwardthreshold", "0.15", 0 ); - joy_sidethreshold = gEngfuncs.pfnRegisterVariable( "joysidethreshold", "0.15", 0 ); - joy_pitchthreshold = gEngfuncs.pfnRegisterVariable( "joypitchthreshold", "0.15", 0 ); - joy_yawthreshold = gEngfuncs.pfnRegisterVariable( "joyyawthreshold", "0.15", 0 ); - joy_forwardsensitivity = gEngfuncs.pfnRegisterVariable( "joyforwardsensitivity", "-1.0", 0 ); - joy_sidesensitivity = gEngfuncs.pfnRegisterVariable( "joysidesensitivity", "-1.0", 0 ); - joy_pitchsensitivity = gEngfuncs.pfnRegisterVariable( "joypitchsensitivity", "1.0", 0 ); - joy_yawsensitivity = gEngfuncs.pfnRegisterVariable( "joyyawsensitivity", "-1.0", 0 ); - joy_wwhack1 = gEngfuncs.pfnRegisterVariable( "joywwhack1", "0.0", 0 ); - joy_wwhack2 = gEngfuncs.pfnRegisterVariable( "joywwhack2", "0.0", 0 ); - - gEngfuncs.pfnAddCommand ("force_centerview", Force_CenterView_f); - gEngfuncs.pfnAddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f); - - IN_StartupMouse (); - IN_StartupJoystick (); -} From 1d8d1b5d2e7d804e41c844642bb541cc17be4001 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sun, 3 Dec 2017 23:52:35 +0300 Subject: [PATCH 117/144] Use mouse input backend depending on the current engine --- cl_dll/CMakeLists.txt | 11 ++--- cl_dll/cl_dll.h | 3 ++ cl_dll/hud.h | 4 +- cl_dll/input_goldsource.cpp | 43 +++++++++---------- cl_dll/input_mouse.cpp | 82 +++++++++++++++++++++++++++++++++++++ cl_dll/input_mouse.h | 77 ++++++++++++++++++++++++++++++++++ cl_dll/input_xash3d.cpp | 41 +++++++------------ 7 files changed, 204 insertions(+), 57 deletions(-) create mode 100644 cl_dll/input_mouse.cpp create mode 100644 cl_dll/input_mouse.h diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 7bd04f77..776f9bd9 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -27,7 +27,7 @@ set (CLDLL_LIBRARY client) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w") if (GOLDSOURCE_SUPPORT) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -lSDL2 -Wl,--no-undefined") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT -lSDL2 -Wl,--no-undefined") endif() set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") @@ -73,6 +73,9 @@ set (CLDLL_SOURCES hud_update.cpp in_camera.cpp input.cpp + input_goldsource.cpp + input_mouse.cpp + input_xash3d.cpp menu.cpp message.cpp overview.cpp @@ -93,12 +96,6 @@ set (CLDLL_SOURCES scoreboard.cpp MOTD.cpp) -if (GOLDSOURCE_SUPPORT) - set (CLDLL_SOURCES "${CLDLL_SOURCES}" input_goldsource.cpp) -else() - set (CLDLL_SOURCES "${CLDLL_SOURCES}" input_xash3d.cpp) -endif() - include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public) if(USE_VOICEMGR) diff --git a/cl_dll/cl_dll.h b/cl_dll/cl_dll.h index 24d1874b..0acd6860 100644 --- a/cl_dll/cl_dll.h +++ b/cl_dll/cl_dll.h @@ -25,6 +25,8 @@ // - Drawing the HUD graphics every frame // - Handling the custum HUD-update packets // +#ifndef CL_DLL_H +#define CL_DLL_H typedef unsigned char byte; typedef unsigned short word; typedef float vec_t; @@ -48,3 +50,4 @@ typedef int ( *pfnUserMsgHook )( const char *pszName, int iSize, void *pbuf ); extern cl_enginefunc_t gEngfuncs; #include "../engine/mobility_int.h" extern mobile_engfuncs_t *gMobileEngfuncs; +#endif diff --git a/cl_dll/hud.h b/cl_dll/hud.h index ab179bbb..1970753d 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -19,7 +19,8 @@ // // CHud handles the message, calculation, and drawing the HUD // - +#ifndef HUD_H +#define HUD_H #define RGB_YELLOWISH 0x00FFA000 //255,160,0 #define RGB_REDISH 0x00FF1010 //255,160,0 #define RGB_GREENISH 0x0000A000 //0,160,0 @@ -677,3 +678,4 @@ extern int g_iTeamNumber; extern int g_iUser1; extern int g_iUser2; extern int g_iUser3; +#endif diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp index 70cd23c5..5c2b0381 100644 --- a/cl_dll/input_goldsource.cpp +++ b/cl_dll/input_goldsource.cpp @@ -8,20 +8,20 @@ // in_win.c -- windows 95 mouse and joystick code // 02/21/97 JCB Added extended DirectInput code to support external controllers. -//#include "port.h" +#include "input_mouse.h" + +#ifdef SUPPORT_GOLDSOURCE_INPUT #include "hud.h" #include "cl_util.h" #include "camera.h" #include "kbutton.h" #include "cvardef.h" -#include "usercmd.h" #include "const.h" #include "camera.h" #include "in_defs.h" #include "keydefs.h" #include "view.h" -//#include "Exports.h" #ifndef _WIN32 #define USE_SDL2 @@ -79,7 +79,7 @@ bool isMouseRelative = false; extern globalvars_t *gpGlobals; #endif -Vector dead_viewangles(0, 0, 0); +extern Vector dead_viewangles; void V_StopPitchDrift( void ) { @@ -88,7 +88,7 @@ void V_StopPitchDrift( void ) // mouse variables cvar_t *m_filter; -cvar_t *sensitivity; +extern cvar_t *sensitivity; // Custom mouse acceleration (0 disable, 1 to enable, 2 enable with separate yaw/pitch rescale) static cvar_t *m_customaccel; @@ -106,16 +106,11 @@ static cvar_t *m_customaccel_exponent; static cvar_t *m_mousethread_sleep; #endif -int mouse_buttons; -int mouse_oldbuttonstate; -POINT current_pos; -int old_mouse_x, old_mouse_y, mx_accum, my_accum; float mouse_x, mouse_y; static int restore_spi; static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1}; static int mouseactive = 0; -int mouseinitialized; static int mouseparmsvalid; static int mouseshowtoggle = 1; @@ -158,7 +153,7 @@ SDL_GameController *s_pJoystick = NULL; // each time. this avoids any problems with getting back to a default usage // or when changing from one controller to another. this way at least something // works. -cvar_t *in_joystick; +extern cvar_t *in_joystick; cvar_t *joy_name; cvar_t *joy_advanced; cvar_t *joy_advaxisx; @@ -348,7 +343,7 @@ void IN_ResetMouse( void ); IN_ActivateMouse =========== */ -extern "C" void DLLEXPORT IN_ActivateMouse (void) +void GoldSourceInput::IN_ActivateMouse (void) { if (mouseinitialized) { @@ -376,7 +371,7 @@ extern "C" void DLLEXPORT IN_ActivateMouse (void) IN_DeactivateMouse =========== */ -extern "C" void DLLEXPORT IN_DeactivateMouse (void) +void GoldSourceInput::IN_DeactivateMouse (void) { if (mouseinitialized) { @@ -400,7 +395,7 @@ extern "C" void DLLEXPORT IN_DeactivateMouse (void) IN_StartupMouse =========== */ -void IN_StartupMouse (void) +void GoldSourceInput::IN_StartupMouse (void) { if ( gEngfuncs.CheckParm ("-nomouse", NULL ) ) return; @@ -437,7 +432,7 @@ void IN_StartupMouse (void) IN_Shutdown =========== */ -void IN_Shutdown (void) +void GoldSourceInput::IN_Shutdown (void) { IN_DeactivateMouse (); @@ -521,7 +516,7 @@ void IN_ResetMouse( void ) IN_MouseEvent =========== */ -extern "C" void DLLEXPORT IN_MouseEvent (int mstate) +void GoldSourceInput::IN_MouseEvent (int mstate) { int i; @@ -596,7 +591,7 @@ void IN_ScaleMouse( float *x, float *y ) } } -void IN_GetMouseDelta( int *pOutX, int *pOutY) +void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY) { bool active = mouseactive && !iVisibleMouse; int mx, my; @@ -715,7 +710,7 @@ void IN_GetMouseDelta( int *pOutX, int *pOutY) IN_MouseMove =========== */ -void IN_MouseMove ( float frametime, usercmd_t *cmd) +void GoldSourceInput::IN_MouseMove ( float frametime, usercmd_t *cmd) { int mx, my; vec3_t viewangles; @@ -797,7 +792,7 @@ void IN_MouseMove ( float frametime, usercmd_t *cmd) IN_Accumulate =========== */ -extern "C" void DLLEXPORT IN_Accumulate (void) +void GoldSourceInput::IN_Accumulate (void) { //only accumulate mouse if we are not moving the camera with the mouse if ( !iMouseInUse && !iVisibleMouse) @@ -850,7 +845,7 @@ extern "C" void DLLEXPORT IN_Accumulate (void) IN_ClearStates =================== */ -extern "C" void DLLEXPORT IN_ClearStates (void) +void GoldSourceInput::IN_ClearStates (void) { if ( !mouseactive ) return; @@ -999,7 +994,7 @@ void Joy_AdvancedUpdate_f (void) IN_Commands =========== */ -void IN_Commands (void) +void GoldSourceInput::IN_Commands (void) { int i, key_index; @@ -1274,7 +1269,7 @@ void IN_JoyMove ( float frametime, usercmd_t *cmd ) IN_Move =========== */ -void IN_Move ( float frametime, usercmd_t *cmd) +void GoldSourceInput::IN_Move ( float frametime, usercmd_t *cmd) { if ( !iMouseInUse && mouseactive ) { @@ -1289,7 +1284,7 @@ void IN_Move ( float frametime, usercmd_t *cmd) IN_Init =========== */ -void IN_Init (void) +void GoldSourceInput::IN_Init (void) { m_filter = gEngfuncs.pfnRegisterVariable ( "m_filter","0", FCVAR_ARCHIVE ); sensitivity = gEngfuncs.pfnRegisterVariable ( "sensitivity","3", FCVAR_ARCHIVE ); // user mouse sensitivity setting. @@ -1355,3 +1350,5 @@ void IN_Init (void) IN_StartupMouse (); IN_StartupJoystick (); } + +#endif diff --git a/cl_dll/input_mouse.cpp b/cl_dll/input_mouse.cpp new file mode 100644 index 00000000..724824cd --- /dev/null +++ b/cl_dll/input_mouse.cpp @@ -0,0 +1,82 @@ +#include "input_mouse.h" +#include "exportdef.h" +#include "hud.h" + +// shared between backends +Vector dead_viewangles(0, 0, 0); +cvar_t *sensitivity; +cvar_t *in_joystick; + +FWGSInput fwgsInput; + +#ifdef SUPPORT_GOLDSOURCE_INPUT +GoldSourceInput goldSourceInput; +AbstractInput* currentInput = &goldSourceInput; +#else +AbstractInput* currentInput = &fwgsInput; +#endif +extern "C" void DLLEXPORT IN_ClientMoveEvent( float forwardmove, float sidemove ) +{ + currentInput->IN_ClientMoveEvent(forwardmove, sidemove); +} + +extern "C" void DLLEXPORT IN_ClientLookEvent( float relyaw, float relpitch ) +{ + currentInput->IN_ClientLookEvent(relyaw, relpitch); +} + +void IN_Move( float frametime, usercmd_t *cmd ) +{ + currentInput->IN_Move(frametime, cmd); +} + +extern "C" void DLLEXPORT IN_MouseEvent( int mstate ) +{ + currentInput->IN_MouseEvent(mstate); +} + +extern "C" void DLLEXPORT IN_ClearStates( void ) +{ + currentInput->IN_ClearStates(); +} + +extern "C" void DLLEXPORT IN_ActivateMouse( void ) +{ + currentInput->IN_ActivateMouse(); +} + +extern "C" void DLLEXPORT IN_DeactivateMouse( void ) +{ + currentInput->IN_DeactivateMouse(); +} + +extern "C" void DLLEXPORT IN_Accumulate( void ) +{ + currentInput->IN_Accumulate(); +} + +void IN_Commands( void ) +{ + currentInput->IN_Commands(); +} + +void IN_Shutdown( void ) +{ + currentInput->IN_Shutdown(); +} + +void IN_Init( void ) +{ +#ifdef SUPPORT_GOLDSOURCE_INPUT + if (gMobileEngfuncs) { + gEngfuncs.Con_Printf( "FWGS Xash3D input is in use\n" ); + currentInput = &fwgsInput; + } else { + gEngfuncs.Con_Printf( "GoldSource input is in use\n" ); + currentInput = &goldSourceInput; + } +#else + currentInput = &fwgsInput; +#endif + currentInput->IN_Init(); +} diff --git a/cl_dll/input_mouse.h b/cl_dll/input_mouse.h new file mode 100644 index 00000000..6ddf54db --- /dev/null +++ b/cl_dll/input_mouse.h @@ -0,0 +1,77 @@ +#ifndef INPUT_MOUSE_H +#define INPUT_MOUSE_H +#include "cl_dll.h" +#include "usercmd.h" +#include "in_defs.h" + +class AbstractInput +{ +public: + virtual void IN_ClientMoveEvent( float forwardmove, float sidemove ) = 0; + virtual void IN_ClientLookEvent( float relyaw, float relpitch ) = 0; + virtual void IN_Move( float frametime, usercmd_t *cmd ) = 0; + virtual void IN_MouseEvent( int mstate ) = 0; + virtual void IN_ClearStates( void ) = 0; + virtual void IN_ActivateMouse( void ) = 0; + virtual void IN_DeactivateMouse( void ) = 0; + virtual void IN_Accumulate( void ) = 0; + virtual void IN_Commands( void ) = 0; + virtual void IN_Shutdown( void ) = 0; + virtual void IN_Init( void ) = 0; +}; + +class FWGSInput : public AbstractInput +{ +public: + virtual void IN_ClientMoveEvent( float forwardmove, float sidemove ); + virtual void IN_ClientLookEvent( float relyaw, float relpitch ); + virtual void IN_Move( float frametime, usercmd_t *cmd ); + virtual void IN_MouseEvent( int mstate ); + virtual void IN_ClearStates( void ); + virtual void IN_ActivateMouse( void ); + virtual void IN_DeactivateMouse( void ); + virtual void IN_Accumulate( void ); + virtual void IN_Commands( void ); + virtual void IN_Shutdown( void ); + virtual void IN_Init( void ); + +protected: + float ac_forwardmove; + float ac_sidemove; + int ac_movecount; + float rel_yaw; + float rel_pitch; +}; + +// No need for goldsource input support on the platforms that are not supported by GoldSource. +#if defined(GOLDSOURCE_SUPPORT) && (defined(_WIN32) || defined(__linux__) || defined(__APPLE__)) && (defined(__i386) || defined(_M_IX86)) +#define SUPPORT_GOLDSOURCE_INPUT +class GoldSourceInput : public AbstractInput +{ +public: + virtual void IN_ClientMoveEvent( float forwardmove, float sidemove ) {} + virtual void IN_ClientLookEvent( float relyaw, float relpitch ) {} + virtual void IN_Move( float frametime, usercmd_t *cmd ); + virtual void IN_MouseEvent( int mstate ); + virtual void IN_ClearStates( void ); + virtual void IN_ActivateMouse( void ); + virtual void IN_DeactivateMouse( void ); + virtual void IN_Accumulate( void ); + virtual void IN_Commands( void ); + virtual void IN_Shutdown( void ); + virtual void IN_Init( void ); + +protected: + void IN_GetMouseDelta( int *pOutX, int *pOutY); + void IN_MouseMove ( float frametime, usercmd_t *cmd); + void IN_StartupMouse (void); + + int mouse_buttons; + int mouse_oldbuttonstate; + POINT current_pos; + int old_mouse_x, old_mouse_y, mx_accum, my_accum; + int mouseinitialized; +}; +#endif + +#endif diff --git a/cl_dll/input_xash3d.cpp b/cl_dll/input_xash3d.cpp index 63cdfbeb..2ff572ee 100644 --- a/cl_dll/input_xash3d.cpp +++ b/cl_dll/input_xash3d.cpp @@ -3,14 +3,9 @@ #include "cvardef.h" #include "kbutton.h" #include "keydefs.h" -cvar_t *sensitivity; -cvar_t *in_joystick; -#define PITCH 0 -#define YAW 1 -#define ROLL 2 - -extern "C" void DLLEXPORT IN_ClientMoveEvent( float forwardmove, float sidemove ); -extern "C" void DLLEXPORT IN_ClientLookEvent( float relyaw, float relpitch ); +#include "input_mouse.h" +extern cvar_t *sensitivity; +extern cvar_t *in_joystick; extern kbutton_t in_strafe; extern kbutton_t in_mlook; @@ -37,12 +32,6 @@ extern cvar_t *cl_movespeedkey; cvar_t *cl_laddermode; -float ac_forwardmove; -float ac_sidemove; -int ac_movecount; -float rel_yaw; -float rel_pitch; - #define F 1U<<0 // Forward #define B 1U<<1 // Back #define L 1U<<2 // Left @@ -55,7 +44,7 @@ float rel_pitch; #define IMPULSE_UP 4 int CL_IsDead( void ); -Vector dead_viewangles(0, 0, 0); +extern Vector dead_viewangles; void IN_ToggleButtons( float forwardmove, float sidemove ) { @@ -135,7 +124,7 @@ void IN_ToggleButtons( float forwardmove, float sidemove ) } } -void IN_ClientMoveEvent( float forwardmove, float sidemove ) +void FWGSInput::IN_ClientMoveEvent( float forwardmove, float sidemove ) { //gEngfuncs.Con_Printf("IN_MoveEvent\n"); @@ -144,14 +133,14 @@ void IN_ClientMoveEvent( float forwardmove, float sidemove ) ac_movecount++; } -void IN_ClientLookEvent( float relyaw, float relpitch ) +void FWGSInput::IN_ClientLookEvent( float relyaw, float relpitch ) { rel_yaw += relyaw; rel_pitch += relpitch; } // Rotate camera and add move values to usercmd -void IN_Move( float frametime, usercmd_t *cmd ) +void FWGSInput::IN_Move( float frametime, usercmd_t *cmd ) { Vector viewangles; bool fLadder = false; @@ -235,7 +224,7 @@ void IN_Move( float frametime, usercmd_t *cmd ) ac_movecount = 0; } -extern "C" void DLLEXPORT IN_MouseEvent( int mstate ) +void FWGSInput::IN_MouseEvent( int mstate ) { static int mouse_oldbuttonstate; // perform button actions @@ -257,37 +246,37 @@ extern "C" void DLLEXPORT IN_MouseEvent( int mstate ) // Stubs -extern "C" void DLLEXPORT IN_ClearStates( void ) +void FWGSInput::IN_ClearStates( void ) { //gEngfuncs.Con_Printf( "IN_ClearStates\n" ); } -extern "C" void DLLEXPORT IN_ActivateMouse( void ) +void FWGSInput::IN_ActivateMouse( void ) { //gEngfuncs.Con_Printf( "IN_ActivateMouse\n" ); } -extern "C" void DLLEXPORT IN_DeactivateMouse( void ) +void FWGSInput::IN_DeactivateMouse( void ) { //gEngfuncs.Con_Printf( "IN_DeactivateMouse\n" ); } -extern "C" void DLLEXPORT IN_Accumulate( void ) +void FWGSInput::IN_Accumulate( void ) { //gEngfuncs.Con_Printf( "IN_Accumulate\n" ); } -void IN_Commands( void ) +void FWGSInput::IN_Commands( void ) { //gEngfuncs.Con_Printf( "IN_Commands\n" ); } -void IN_Shutdown( void ) +void FWGSInput::IN_Shutdown( void ) { } // Register cvars and reset data -void IN_Init( void ) +void FWGSInput::IN_Init( void ) { sensitivity = gEngfuncs.pfnRegisterVariable( "sensitivity", "3", FCVAR_ARCHIVE ); in_joystick = gEngfuncs.pfnRegisterVariable( "joystick", "0", FCVAR_ARCHIVE ); From 84e720eadcfa27434ee65335cb87c8e41a63a92f Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Mon, 4 Dec 2017 15:42:45 +0300 Subject: [PATCH 118/144] Add new input files and goldsource support flag to client makefiles --- cl_dll/Android.mk | 7 +++++++ cl_dll/Makefile | 11 ++++++++--- cl_dll/cl_dll.dsp | 14 +++++++++++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/cl_dll/Android.mk b/cl_dll/Android.mk index a79b6363..29aee174 100755 --- a/cl_dll/Android.mk +++ b/cl_dll/Android.mk @@ -68,6 +68,8 @@ SRCS+=./hud_spectator.cpp SRCS+=./hud_update.cpp SRCS+=./in_camera.cpp SRCS+=./input.cpp +SRCS+=./input_goldsource.cpp +SRCS+=./input_mouse.cpp #SRCS+=./inputw32.cpp SRCS+=./menu.cpp SRCS+=./message.cpp @@ -100,6 +102,11 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/. \ $(LOCAL_PATH)/../pm_shared LOCAL_CFLAGS += $(DEFINES) $(INCLUDES) +ifeq ($(GOLDSOURCE_SUPPORT),1) + DEFINES += -DGOLDSOURCE_SUPPORT + LOCAL_LDLIBS += -lSDL2 +endif + LOCAL_SRC_FILES := $(SRCS) $(SRCS_C) include $(BUILD_SHARED_LIBRARY) diff --git a/cl_dll/Makefile b/cl_dll/Makefile index 983b61c0..16427f8f 100644 --- a/cl_dll/Makefile +++ b/cl_dll/Makefile @@ -45,7 +45,8 @@ SRCS+=./hud_spectator.cpp SRCS+=./hud_update.cpp SRCS+=./in_camera.cpp SRCS+=./input.cpp -#SRCS+=./inputw32.cpp +SRCS+=./input_mouse.cpp +SRCS+=./input_goldsource.cpp SRCS+=./menu.cpp SRCS+=./message.cpp SRCS+=./overview.cpp @@ -72,9 +73,13 @@ CFLAGS = -m32 OBJS = $(SRCS:.cpp=.o) $(SRCS_C:.c=.o) LIBS=-lm +ifeq ($(GOLDSOURCE_SUPPORT),1) + DEFINES += -DGOLDSOURCE_SUPPORT + LIBS += -lSDL2 +endif ifeq ($(shell uname -s),Linux) - LIBS=$(LIBS) -ldl + LIBS += -ldl endif %.o : %.c @@ -83,7 +88,7 @@ endif %.o : %.cpp $(CXX) $(CFLAGS) $(INCLUDES) $(DEFINES) -fPIC -c $< -o $@ client.so : $(OBJS) - $(CXX) $(OBJS) -o client.so -shared -Wl,--no-undefined -fPIC $(LIBS) + $(CXX) $(CFLAGS) $(OBJS) -o client.so -shared -Wl,--no-undefined -fPIC $(LIBS) clean: $(RM) $(OBJS) diff --git a/cl_dll/cl_dll.dsp b/cl_dll/cl_dll.dsp index 6864326b..e8ae7d15 100644 --- a/cl_dll/cl_dll.dsp +++ b/cl_dll/cl_dll.dsp @@ -300,7 +300,15 @@ SOURCE=.\input.cpp # End Source File # Begin Source File -SOURCE=.\inputw32.cpp +SOURCE=.\input_goldsource.cpp +# End Source File +# Begin Source File + +SOURCE=.\input_mouse.cpp +# End Source File +# Begin Source File + +SOURCE=.\input_xash3d.cpp # End Source File # Begin Source File @@ -513,6 +521,10 @@ SOURCE=.\in_defs.h # End Source File # Begin Source File +SOURCE=.\input_mouse.h +# End Source File +# Begin Source File + SOURCE=..\common\itrackeruser.h # End Source File # Begin Source File From d904505f6a991532fd2eedff4e98b683347f71cd Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Wed, 6 Dec 2017 19:19:27 +0300 Subject: [PATCH 119/144] Get vgui back for goldsource fullscreen support --- cl_dll/CMakeLists.txt | 9 ++++-- cl_dll/cdll_int.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 72 insertions(+), 3 deletions(-) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 776f9bd9..2ad46949 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -27,7 +27,12 @@ set (CLDLL_LIBRARY client) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w") if (GOLDSOURCE_SUPPORT) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT -lSDL2 -Wl,--no-undefined") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT -L${CMAKE_CURRENT_SOURCE_DIR}/.. -lSDL2 -Wl,--no-undefined") + if (APPLE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -l:vgui.dylib") + else() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -l:vgui.so") + endif() endif() set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") @@ -96,7 +101,7 @@ set (CLDLL_SOURCES scoreboard.cpp MOTD.cpp) -include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public) +include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public ../utils/vgui/include) if(USE_VOICEMGR) #set(CLDLL_SOURCES diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index d71659e9..00496ea8 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -23,6 +23,13 @@ #include "netadr.h" #include "parsemsg.h" +#if defined(GOLDSOURCE_SUPPORT) && (defined(_WIN32) || defined(__linux__) || defined(__APPLE__)) && (defined(__i386) || defined(_M_IX86)) +#define USE_VGUI_FOR_GOLDSOURCE_SUPPORT +#include "VGUI_Panel.h" +#include "VGUI_BorderLayout.h" +#include "VGUI_App.h" +#endif + extern "C" { #include "pm_shared.h" @@ -177,6 +184,46 @@ int *HUD_GetRect( void ) return extent; } +#ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT +class TeamFortressViewport : public vgui::Panel +{ +public: + TeamFortressViewport(int x,int y,int wide,int tall); + void Initialize( void ); + + virtual void paintBackground(); + void *operator new( size_t stAllocateBlock ); +}; + +static TeamFortressViewport* gViewPort = NULL; + +TeamFortressViewport::TeamFortressViewport(int x, int y, int wide, int tall) +{ + gViewPort = this; + Initialize(); +} + +void TeamFortressViewport::Initialize() +{ + vgui::App::getInstance()->setCursorOveride( vgui::App::getInstance()->getScheme()->getCursor(vgui::Scheme::scu_none) ); +} + +void TeamFortressViewport::paintBackground() +{ + int wide, tall; + getParent()->getSize( wide, tall ); + setSize( wide, tall ); + gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect()); +} + +void *TeamFortressViewport::operator new( size_t stAllocateBlock ) +{ + void *mem = ::operator new( stAllocateBlock ); + memset( mem, 0, stAllocateBlock ); + return mem; +} +#endif + /* ========================== HUD_VidInit @@ -190,7 +237,21 @@ so the HUD can reinitialize itself. int DLLEXPORT HUD_VidInit( void ) { gHUD.VidInit(); +#ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT + vgui::Panel* root=(vgui::Panel*)gEngfuncs.VGui_GetPanel(); + root->setBgColor(128,128,0,0); + root->setLayout(new vgui::BorderLayout(0)); + if (gViewPort != NULL) + { + gViewPort->Initialize(); + } + else + { + gViewPort = new TeamFortressViewport(0,0,root->getWide(),root->getTall()); + gViewPort->setParent(root); + } +#endif return 1; } @@ -270,7 +331,10 @@ Called by engine every frame that client .dll is loaded */ void DLLEXPORT HUD_Frame( double time ) -{ gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect()); +{ +#ifndef USE_VGUI_FOR_GOLDSOURCE_SUPPORT + gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect()); +#endif } /* From 51bf51a840649165078226661ef790c0ed3971e4 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Wed, 6 Dec 2017 20:38:14 +0300 Subject: [PATCH 120/144] Provide vgui stub to avoid dependency of client of vgui lib --- cl_dll/CMakeLists.txt | 7 +- cl_dll/cdll_int.cpp | 39 ++-- utils/false_vgui/include/VGUI.h | 108 ++++++++++ utils/false_vgui/include/VGUI_App.h | 130 ++++++++++++ utils/false_vgui/include/VGUI_Bitmap.h | 37 ++++ utils/false_vgui/include/VGUI_Color.h | 44 +++++ utils/false_vgui/include/VGUI_Cursor.h | 57 ++++++ utils/false_vgui/include/VGUI_Dar.h | 194 ++++++++++++++++++ utils/false_vgui/include/VGUI_Image.h | 62 ++++++ utils/false_vgui/include/VGUI_KeyCode.h | 126 ++++++++++++ utils/false_vgui/include/VGUI_MouseCode.h | 24 +++ utils/false_vgui/include/VGUI_Panel.h | 229 ++++++++++++++++++++++ utils/false_vgui/include/VGUI_Scheme.h | 82 ++++++++ 13 files changed, 1115 insertions(+), 24 deletions(-) create mode 100644 utils/false_vgui/include/VGUI.h create mode 100644 utils/false_vgui/include/VGUI_App.h create mode 100644 utils/false_vgui/include/VGUI_Bitmap.h create mode 100644 utils/false_vgui/include/VGUI_Color.h create mode 100644 utils/false_vgui/include/VGUI_Cursor.h create mode 100644 utils/false_vgui/include/VGUI_Dar.h create mode 100644 utils/false_vgui/include/VGUI_Image.h create mode 100644 utils/false_vgui/include/VGUI_KeyCode.h create mode 100644 utils/false_vgui/include/VGUI_MouseCode.h create mode 100644 utils/false_vgui/include/VGUI_Panel.h create mode 100644 utils/false_vgui/include/VGUI_Scheme.h diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 2ad46949..e52a0d95 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -28,11 +28,6 @@ set (CLDLL_LIBRARY client) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w") if (GOLDSOURCE_SUPPORT) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT -L${CMAKE_CURRENT_SOURCE_DIR}/.. -lSDL2 -Wl,--no-undefined") - if (APPLE) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -l:vgui.dylib") - else() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -l:vgui.so") - endif() endif() set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") @@ -101,7 +96,7 @@ set (CLDLL_SOURCES scoreboard.cpp MOTD.cpp) -include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public ../utils/vgui/include) +include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public ../utils/false_vgui/include) if(USE_VOICEMGR) #set(CLDLL_SOURCES diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index 00496ea8..1901d9d2 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -26,7 +26,6 @@ #if defined(GOLDSOURCE_SUPPORT) && (defined(_WIN32) || defined(__linux__) || defined(__APPLE__)) && (defined(__i386) || defined(_M_IX86)) #define USE_VGUI_FOR_GOLDSOURCE_SUPPORT #include "VGUI_Panel.h" -#include "VGUI_BorderLayout.h" #include "VGUI_App.h" #endif @@ -197,7 +196,7 @@ public: static TeamFortressViewport* gViewPort = NULL; -TeamFortressViewport::TeamFortressViewport(int x, int y, int wide, int tall) +TeamFortressViewport::TeamFortressViewport(int x, int y, int wide, int tall) : Panel(x, y, wide, tall) { gViewPort = this; Initialize(); @@ -205,14 +204,14 @@ TeamFortressViewport::TeamFortressViewport(int x, int y, int wide, int tall) void TeamFortressViewport::Initialize() { - vgui::App::getInstance()->setCursorOveride( vgui::App::getInstance()->getScheme()->getCursor(vgui::Scheme::scu_none) ); + //vgui::App::getInstance()->setCursorOveride( vgui::App::getInstance()->getScheme()->getCursor(vgui::Scheme::scu_none) ); } void TeamFortressViewport::paintBackground() { - int wide, tall; - getParent()->getSize( wide, tall ); - setSize( wide, tall ); +// int wide, tall; +// getParent()->getSize( wide, tall ); +// setSize( wide, tall ); gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect()); } @@ -239,17 +238,18 @@ int DLLEXPORT HUD_VidInit( void ) gHUD.VidInit(); #ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT vgui::Panel* root=(vgui::Panel*)gEngfuncs.VGui_GetPanel(); - root->setBgColor(128,128,0,0); - root->setLayout(new vgui::BorderLayout(0)); - - if (gViewPort != NULL) - { - gViewPort->Initialize(); - } - else - { - gViewPort = new TeamFortressViewport(0,0,root->getWide(),root->getTall()); - gViewPort->setParent(root); + if (root) { + root->setBgColor(128,128,0,0); + + if (gViewPort != NULL) + { + gViewPort->Initialize(); + } + else + { + gViewPort = new TeamFortressViewport(0,0,root->getWide(),root->getTall()); + gViewPort->setParent(root); + } } #endif return 1; @@ -332,7 +332,10 @@ Called by engine every frame that client .dll is loaded void DLLEXPORT HUD_Frame( double time ) { -#ifndef USE_VGUI_FOR_GOLDSOURCE_SUPPORT +#ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT + if (!gViewPort) + gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect()); +#else gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect()); #endif } diff --git a/utils/false_vgui/include/VGUI.h b/utils/false_vgui/include/VGUI.h new file mode 100644 index 00000000..0dff607a --- /dev/null +++ b/utils/false_vgui/include/VGUI.h @@ -0,0 +1,108 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_H +#define VGUI_H + +//If you are going to add stuff to the vgui core... +// +//Keep it simple. +// +//Never put code in a header. +// +//The name of the class is the name of the the file +// +//Each class gets its own .cpp file for its definition and a .h for its header. Helper +//classes can be used but only within the .cpp and not referenceable from anywhere else. +// +//Don't add unneeded files. Keep the API clean. +// +//No platform specific code in vgui\lib-src\vgui dir. Code in vgui\lib-src\vgui should +//only include from vgui\include or standard C includes. ie, if I see windows.h included +//anywhere but vgui\lib-src\win32 I will hunt you down and kill you. Don't give me any crap +//that mfc is platform inspecific. +// +//Always use <> and not "" for includes +// +//Use minimum dependencies in headers. Don't include another header if you can get away +//with forward declaring (which is usually the case) +// +//No macros in headers. They are tools of satan. This also means no use of DEFINEs, use enum +// +//Minimize global functions +// +//No global variables. +// +//Panel is getting pretty plump, try and avoid adding junk to it if you can + +//TODO: Look and Feel support +// add Panel::setPaintProxy, if _paintProxy exists, it calls _paintProxy->paint +// instead of Panel::paint. Components should implement their painting in a seperate +// plugin class. Perhaps to encourage this, Panel::paint should just go away completely +// The other option is to have Panel have the interface Paintable +// class Paintable +// { +// public: +// virtual void paint()=0; +// }; +// Then a component can implement its paint in the class itself and then call +// setPaintProxy(this). If this is the case _paintProxy->paint should always be called +// and never Panel::paint from within paintTraverse +//TODO: Figure out the 'Valve' Look and Feel and implement that instead of a the Java one +//TODO: Determine ownership policy for Borders, Layouts, etc.. +//TODO: tooltips support +//TODO: ComboKey (hot key support) +//TODO: add Background.cpp, remove paintBackground from all components +// Panel implements setBackground, Panel::paintBackground calls _background->paintBackground +// similiar to the way Border works. +//TODO: Builtin components should never overide paintBackground, only paint +//TODO: All protected members should be converted to private +//TODO: All member variables should be moved to the top of the class prototype +//TODO: All private methods should be prepended with private +//TODO: Use of word internal in method names is not consistent and confusing +//TODO: Cleanup so bullshit publics are properly named, maybe even figure out +// a naming convention for them +//TODO: Breakup InputSignal into logical pieces +//TODO: Button is in a state of disarray, it should have ButtonModel support +//TODO: get rid of all the stupid strdup laziness, convert to vgui_strdup +//TODO: actually figure out policy on String and implement it consistently +//TODO: implement createLayoutInfo for other Layouts than need it +//TODO: BorderLayout should have option for a null LayoutInfo defaulting to center +//TODO: SurfaceBase should go away, put it in Surface +//TODO: ActionSignals and other Signals should just set a flag when they fire. +// then App can come along later and fire all the signals +//TODO: Change all method naming to starting with a capital letter. + +#ifdef _WIN32 +# define VGUIAPI __declspec( dllexport ) +#else +# define VGUIAPI __attribute__ ((visibility("default"))) +#include // size_t define +#endif + +#define null 0L + +typedef unsigned char uchar; +typedef unsigned short ushort; +typedef unsigned int uint; +typedef unsigned long ulong; + +namespace vgui +{ + +VGUIAPI void vgui_setMalloc(void *(*malloc)(size_t size) ); +VGUIAPI void vgui_setFree(void (*free)(void* memblock)); +VGUIAPI void vgui_strcpy(char* dst,int dstLen,const char* src); +VGUIAPI char* vgui_strdup(const char* src); +VGUIAPI int vgui_printf(const char* format,...); +VGUIAPI int vgui_dprintf(const char* format,...); +VGUIAPI int vgui_dprintf2(const char* format,...); + +} + +#endif + diff --git a/utils/false_vgui/include/VGUI_App.h b/utils/false_vgui/include/VGUI_App.h new file mode 100644 index 00000000..6e70f909 --- /dev/null +++ b/utils/false_vgui/include/VGUI_App.h @@ -0,0 +1,130 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_APP_H +#define VGUI_APP_H + +#include +#include +#include +#include +#include + +namespace vgui +{ + +class Panel; +class TickSignal; +class Scheme; +class TickSignal; +class SurfaceBase; + +class VGUIAPI App +{ +public: + App() {} + App(bool externalMain) {} +public: + static App* getInstance() {return 0;} + //TODO: the public and public bullshit are all messed up, need to organize + //TODO: actually all of the access needs to be properly thought out while you are at it +public: + virtual void start() {} + virtual void stop() {} + virtual void externalTick() {} + virtual bool wasMousePressed(MouseCode code,Panel* panel) {return false;} + virtual bool wasMouseDoublePressed(MouseCode code,Panel* panel) {return false;} + virtual bool isMouseDown(MouseCode code,Panel* panel) {return false;} + virtual bool wasMouseReleased(MouseCode code,Panel* panel) {return false;} + virtual bool wasKeyPressed(KeyCode code,Panel* panel) {return false;} + virtual bool isKeyDown(KeyCode code,Panel* panel) {return false;} + virtual bool wasKeyTyped(KeyCode code,Panel* panel) {return false;} + virtual bool wasKeyReleased(KeyCode code,Panel* panel) {return false;} + virtual void addTickSignal(TickSignal* s) {} + virtual void setCursorPos(int x,int y) {} + virtual void getCursorPos(int& x,int& y) {} + virtual void setMouseCapture(Panel* panel) {} + virtual void setMouseArena(int x0,int y0,int x1,int y1,bool enabled) {} + virtual void setMouseArena(Panel* panel) {} + virtual void requestFocus(Panel* panel) {} + virtual Panel* getFocus() {return 0;} + virtual void repaintAll() {} + virtual void setScheme(Scheme* scheme) {} + virtual Scheme* getScheme() {return 0;} + virtual void enableBuildMode() {} + virtual long getTimeMillis() {return 0;} + virtual char getKeyCodeChar(KeyCode code,bool shifted) {return '\0';} + virtual void getKeyCodeText(KeyCode code,char* buf,int buflen) {} + virtual int getClipboardTextCount() {return 0;} + virtual void setClipboardText(const char* text,int textLen) {} + virtual int getClipboardText(int offset,char* buf,int bufLen) {return 0;} + virtual void reset() {} + virtual void internalSetMouseArena(int x0,int y0,int x1,int y1,bool enabled) {} + virtual bool setRegistryString(const char* key,const char* value) {return false;} + virtual bool getRegistryString(const char* key,char* value,int valueLen) {return false;} + virtual bool setRegistryInteger(const char* key,int value) {return false;} + virtual bool getRegistryInteger(const char* key,int& value) {return false;} + virtual void setCursorOveride(Cursor* cursor) {} + virtual Cursor* getCursorOveride() {return 0;} + virtual void setMinimumTickMillisInterval(int interval) {} +public: //bullshit public stuff + virtual void main(int argc,char* argv[])=0; + virtual void run() {} + virtual void internalCursorMoved(int x,int y,SurfaceBase* surfaceBase) {} //expects input in surface space + virtual void internalMousePressed(MouseCode code,SurfaceBase* surfaceBase) {} + virtual void internalMouseDoublePressed(MouseCode code,SurfaceBase* surfaceBase) {} + virtual void internalMouseReleased(MouseCode code,SurfaceBase* surfaceBase) {} + virtual void internalMouseWheeled(int delta,SurfaceBase* surfaceBase) {} + virtual void internalKeyPressed(KeyCode code,SurfaceBase* surfaceBase) {} + virtual void internalKeyTyped(KeyCode code,SurfaceBase* surfaceBase) {} + virtual void internalKeyReleased(KeyCode code,SurfaceBase* surfaceBase) {} +private: + virtual void init() {} + virtual void updateMouseFocus(int x,int y,SurfaceBase* surfaceBase) {} + virtual void setMouseFocus(Panel* newMouseFocus) {} +protected: + virtual void surfaceBaseCreated(SurfaceBase* surfaceBase) {} + virtual void surfaceBaseDeleted(SurfaceBase* surfaceBase) {} + virtual void platTick() {} + virtual void internalTick() {} +protected: + static App* _instance; +protected: + bool _running; + bool _externalMain; + Dar _surfaceBaseDar; + Panel* _keyFocus; + Panel* _oldMouseFocus; + Panel* _mouseFocus; + Panel* _mouseCapture; + Panel* _wantedKeyFocus; + bool _mousePressed[MOUSE_LAST]; + bool _mouseDoublePressed[MOUSE_LAST]; + bool _mouseDown[MOUSE_LAST]; + bool _mouseReleased[MOUSE_LAST]; + bool _keyPressed[KEY_LAST]; + bool _keyTyped[KEY_LAST]; + bool _keyDown[KEY_LAST]; + bool _keyReleased[KEY_LAST]; + Dar _tickSignalDar; + Scheme* _scheme; + bool _buildMode; + bool _wantedBuildMode; + Panel* _mouseArenaPanel; + Cursor* _cursor[Cursor::dc_last]; + Cursor* _cursorOveride; +private: + long _nextTickMillis; + long _minimumTickMillisInterval; + friend class SurfaceBase; +}; +} + +#endif + + + diff --git a/utils/false_vgui/include/VGUI_Bitmap.h b/utils/false_vgui/include/VGUI_Bitmap.h new file mode 100644 index 00000000..a2cc7a45 --- /dev/null +++ b/utils/false_vgui/include/VGUI_Bitmap.h @@ -0,0 +1,37 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_BITMAP_H +#define VGUI_BITMAP_H + +#include +#include + +namespace vgui +{ + +class Panel; + +class VGUIAPI Bitmap : public Image +{ +private: + int _id; + bool _uploaded; +public: + Bitmap() {} +protected: + virtual void setSize(int wide,int tall) {} + virtual void setRGBA(int x,int y,uchar r,uchar g,uchar b,uchar a) {} +public: + virtual void paint(Panel* panel) {} +protected: + uchar* _rgba; +}; + +} + +#endif diff --git a/utils/false_vgui/include/VGUI_Color.h b/utils/false_vgui/include/VGUI_Color.h new file mode 100644 index 00000000..f3fec5c6 --- /dev/null +++ b/utils/false_vgui/include/VGUI_Color.h @@ -0,0 +1,44 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_COLOR_H +#define VGUI_COLOR_H + +#include +#include + +//TODO: rename getColor(r,g,b,a) to getRGBA(r,g,b,a) +//TODO: rename setColor(r,g,b,a) to setRGBA(r,g,b,a) +//TODO: rename getColor(sc) to getSchemeColor(sc) +//TODO: rename setColor(sc) to setSchemeColor(sc) + +namespace vgui +{ + +class VGUIAPI Color +{ +private: + uchar _color[4]; + Scheme::SchemeColor _schemeColor; +public: + Color() {} + Color(int r,int g,int b,int a) {} + Color(Scheme::SchemeColor sc) {} +private: + virtual void init() {} +public: + virtual void setColor(int r,int g,int b,int a) {} + virtual void setColor(Scheme::SchemeColor sc) {} + virtual void getColor(int& r,int& g,int& b,int& a) {} + virtual void getColor(Scheme::SchemeColor& sc) {} + virtual int operator[](int index) {return 0;} +}; + +} + + +#endif diff --git a/utils/false_vgui/include/VGUI_Cursor.h b/utils/false_vgui/include/VGUI_Cursor.h new file mode 100644 index 00000000..8419e2dd --- /dev/null +++ b/utils/false_vgui/include/VGUI_Cursor.h @@ -0,0 +1,57 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_CURSOR_H +#define VGUI_CURSOR_H + +#include + +namespace vgui +{ + +class Bitmap; + +class VGUIAPI Cursor +{ +public: + enum DefaultCursor + { + dc_user, + dc_none, + dc_arrow, + dc_ibeam, + dc_hourglass, + dc_crosshair, + dc_up, + dc_sizenwse, + dc_sizenesw, + dc_sizewe, + dc_sizens, + dc_sizeall, + dc_no, + dc_hand, + dc_last + }; +private: + int _hotspot[2]; + Bitmap* _bitmap; + DefaultCursor _dc; +public: + Cursor(DefaultCursor dc) {} + Cursor(Bitmap* bitmap,int hotspotX,int hotspotY) {} +public: + virtual void getHotspot(int& x,int& y) {} +private: + virtual void privateInit(Bitmap* bitmap,int hotspotX,int hotspotY) {} +public: + virtual Bitmap* getBitmap() {return 0;} + virtual DefaultCursor getDefaultCursor() {return dc_none;} +}; + +} + +#endif diff --git a/utils/false_vgui/include/VGUI_Dar.h b/utils/false_vgui/include/VGUI_Dar.h new file mode 100644 index 00000000..6f8eb513 --- /dev/null +++ b/utils/false_vgui/include/VGUI_Dar.h @@ -0,0 +1,194 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_DAR_H +#define VGUI_DAR_H + +#include +#include +#include + + + +namespace vgui +{ + +//Simple lightweight dynamic array implementation +template class VGUIAPI Dar +{ +public: + Dar() + { + _count=0; + _capacity=0; + _data=null; + ensureCapacity(4); + } + Dar(int initialCapacity) + { + _count=0; + _capacity=0; + _data=null; + ensureCapacity(initialCapacity); + } +public: + void ensureCapacity(int wantedCapacity) + { + if(wantedCapacity<=_capacity){return;} + + //double capacity until it is >= wantedCapacity + //this could be done with math, but iterative is just so much more fun + int newCapacity=_capacity; + if(newCapacity==0){newCapacity=1;} + while(newCapacity_capacity)) + { + return; + } + _count=count; + } + int getCount() + { + return _count; + } + void addElement(ELEMTYPE elem) + { + ensureCapacity(_count+1); + _data[_count]=elem; + _count++; + } + bool hasElement(ELEMTYPE elem) + { + for(int i=0;i<_count;i++) + { + if(_data[i]==elem) + { + return true; + } + } + return false; + } + void putElement(ELEMTYPE elem) + { + if(hasElement(elem)) + { + return; + } + addElement(elem); + } + void insertElementAt(ELEMTYPE elem,int index) + { + if((index<0)||(index>_count)) + { + return; + } + if((index==_count)||(_count==0)) + { + addElement(elem); + } + else + { + addElement(elem); //just to make sure it is big enough + for(int i=_count-1;i>index;i--) + { + _data[i]=_data[i-1]; + } + _data[index]=elem; + } + } + void setElementAt(ELEMTYPE elem,int index) + { + if((index<0)||(index>=_count)) + { + return; + } + _data[index]=elem; + } + void removeElementAt(int index) + { + if((index<0)||(index>=_count)) + { + return; + } + + //slide everything to the right of index, left one. + for(int i=index;i<(_count-1);i++) + { + _data[i]=_data[i+1]; + } + _count--; + } + void removeElement(ELEMTYPE elem) + { + for(int i=0;i<_count;i++) + { + if(_data[i]==elem) + { + removeElementAt(i); + break; + } + } + } + void removeAll() + { + _count=0; + } + ELEMTYPE operator[](int index) + { + if((index<0)||(index>=_count)) + { + return null; + } + return _data[index]; + } +protected: + int _count; + int _capacity; + ELEMTYPE* _data; +}; + +#ifdef _WIN32 +//forward referencing all the template types used so they get exported +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar*>; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +#endif + +} + + +#endif \ No newline at end of file diff --git a/utils/false_vgui/include/VGUI_Image.h b/utils/false_vgui/include/VGUI_Image.h new file mode 100644 index 00000000..ff83f047 --- /dev/null +++ b/utils/false_vgui/include/VGUI_Image.h @@ -0,0 +1,62 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_IMAGE_H +#define VGUI_IMAGE_H + +#include +#include +#include + +//TODO:: needs concept of insets + +namespace vgui +{ + +class Panel; + +class VGUIAPI Image +{ +friend class Panel; +private: + int _pos[2]; + int _size[2]; + Panel* _panel; + Color _color; +public: + Image(); +public: + virtual void setPos(int x,int y) {} + virtual void getPos(int& x,int& y) {} + virtual void getSize(int& wide,int& tall) {} + virtual void setColor(Color color) {} + virtual void getColor(Color& color) {} +protected: + virtual void setSize(int wide,int tall) {} + virtual void drawSetColor(Scheme::SchemeColor sc) {} + virtual void drawSetColor(int r,int g,int b,int a) {} + virtual void drawFilledRect(int x0,int y0,int x1,int y1) {} + virtual void drawOutlinedRect(int x0,int y0,int x1,int y1) {} + virtual void drawSetTextFont(Scheme::SchemeFont sf) {} + virtual void drawSetTextFont(Font* font) {} + virtual void drawSetTextColor(Scheme::SchemeColor sc) {} + virtual void drawSetTextColor(int r,int g,int b,int a) {} + virtual void drawSetTextPos(int x,int y) {} + virtual void drawPrintText(const char* str,int strlen) {} + virtual void drawPrintText(int x,int y,const char* str,int strlen) {} + virtual void drawPrintChar(char ch) {} + virtual void drawPrintChar(int x,int y,char ch) {} + virtual void drawSetTextureRGBA(int id,const char* rgba,int wide,int tall) {} + virtual void drawSetTexture(int id) {} + virtual void drawTexturedRect(int x0,int y0,int x1,int y1) {} + virtual void paint(Panel* panel) {} +public: + virtual void doPaint(Panel* panel) {} +}; +} + +#endif diff --git a/utils/false_vgui/include/VGUI_KeyCode.h b/utils/false_vgui/include/VGUI_KeyCode.h new file mode 100644 index 00000000..b6aea363 --- /dev/null +++ b/utils/false_vgui/include/VGUI_KeyCode.h @@ -0,0 +1,126 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_KEYCODE_H +#define VGUI_KEYCODE_H + +#include + +namespace vgui +{ +enum VGUIAPI KeyCode +{ + KEY_0=0, + KEY_1, + KEY_2, + KEY_3, + KEY_4, + KEY_5, + KEY_6, + KEY_7, + KEY_8, + KEY_9, + KEY_A, + KEY_B, + KEY_C, + KEY_D, + KEY_E, + KEY_F, + KEY_G, + KEY_H, + KEY_I, + KEY_J, + KEY_K, + KEY_L, + KEY_M, + KEY_N, + KEY_O, + KEY_P, + KEY_Q, + KEY_R, + KEY_S, + KEY_T, + KEY_U, + KEY_V, + KEY_W, + KEY_X, + KEY_Y, + KEY_Z, + KEY_PAD_0, + KEY_PAD_1, + KEY_PAD_2, + KEY_PAD_3, + KEY_PAD_4, + KEY_PAD_5, + KEY_PAD_6, + KEY_PAD_7, + KEY_PAD_8, + KEY_PAD_9, + KEY_PAD_DIVIDE, + KEY_PAD_MULTIPLY, + KEY_PAD_MINUS, + KEY_PAD_PLUS, + KEY_PAD_ENTER, + KEY_PAD_DECIMAL, + KEY_LBRACKET, + KEY_RBRACKET, + KEY_SEMICOLON, + KEY_APOSTROPHE, + KEY_BACKQUOTE, + KEY_COMMA, + KEY_PERIOD, + KEY_SLASH, + KEY_BACKSLASH, + KEY_MINUS, + KEY_EQUAL, + KEY_ENTER, + KEY_SPACE, + KEY_BACKSPACE, + KEY_TAB, + KEY_CAPSLOCK, + KEY_NUMLOCK, + KEY_ESCAPE, + KEY_SCROLLLOCK, + KEY_INSERT, + KEY_DELETE, + KEY_HOME, + KEY_END, + KEY_PAGEUP, + KEY_PAGEDOWN, + KEY_BREAK, + KEY_LSHIFT, + KEY_RSHIFT, + KEY_LALT, + KEY_RALT, + KEY_LCONTROL, + KEY_RCONTROL, + KEY_LWIN, + KEY_RWIN, + KEY_APP, + KEY_UP, + KEY_LEFT, + KEY_DOWN, + KEY_RIGHT, + KEY_F1, + KEY_F2, + KEY_F3, + KEY_F4, + KEY_F5, + KEY_F6, + KEY_F7, + KEY_F8, + KEY_F9, + KEY_F10, + KEY_F11, + KEY_F12, + KEY_LAST +}; +} + + +#endif + diff --git a/utils/false_vgui/include/VGUI_MouseCode.h b/utils/false_vgui/include/VGUI_MouseCode.h new file mode 100644 index 00000000..2de259db --- /dev/null +++ b/utils/false_vgui/include/VGUI_MouseCode.h @@ -0,0 +1,24 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_MOUSECODE_H +#define VGUI_MOUSECODE_H + +#include + +namespace vgui +{ +enum VGUIAPI MouseCode +{ + MOUSE_LEFT=0, + MOUSE_RIGHT, + MOUSE_MIDDLE, + MOUSE_LAST +}; +} + +#endif diff --git a/utils/false_vgui/include/VGUI_Panel.h b/utils/false_vgui/include/VGUI_Panel.h new file mode 100644 index 00000000..bec7ac25 --- /dev/null +++ b/utils/false_vgui/include/VGUI_Panel.h @@ -0,0 +1,229 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_PANEL_H +#define VGUI_PANEL_H + + +/* + +TODO: + +Maybe have the border know who they are added to. +A border can only be added to 1 thing, and will be +removed from the other. That way they can actually +be memory managed. Also do Layout's this way too. + +TODO: + outlinedRect should have a thickness arg + +*/ + + +#include +#include +#include +#include +#include +#include +#include +//#include + +namespace vgui +{ + +enum KeyCode; +enum MouseCode; +class SurfaceBase; +class FocusChangeSignal; +class InputSignal; +class Cursor; +class Layout; +class FocusNavGroup; +class Border; +class Font; +class BuildGroup; +class App; +class LayoutInfo; +class RepaintSignal; + +class VGUIAPI Panel +{ +public: + Panel() {} + Panel(int x,int y,int wide,int tall) {setPos(x, y); setSize(wide, tall);} +private: + void init(int x,int y,int wide,int tall) {} +public: + virtual void setPos(int x,int y) {_pos[0] = x; _pos[1] = y;} + virtual void getPos(int& x,int& y) {x = _pos[0]; y = _pos[1];} + virtual void setSize(int wide,int tall) {_size[0] = wide, _size[1] = tall;} + virtual void getSize(int& wide,int& tall) {wide = _size[0], tall = _size[1];} + virtual void setBounds(int x,int y,int wide,int tall) {} + virtual void getBounds(int& x,int& y,int& wide,int& tall) {} + virtual int getWide() {return _size[0];} + virtual int getTall() {return _size[1];} + virtual Panel* getParent() {return _parent;} + virtual void setVisible(bool state) {_visible = state;} + virtual bool isVisible() {return _visible;} + virtual bool isVisibleUp() {return false;} + virtual void repaint() {} + virtual void repaintAll() {} + virtual void getAbsExtents(int& x0,int& y0,int& x1,int& y1) {} + virtual void getClipRect(int& x0,int& y0,int& x1,int& y1) {} + virtual void setParent(Panel* newParent) {_parent = newParent; newParent->addChild(this);} + virtual void addChild(Panel* child) {} + virtual void insertChildAt(Panel* child,int index) {} + virtual void removeChild(Panel* child) {} + virtual bool wasMousePressed(MouseCode code) {return false;} + virtual bool wasMouseDoublePressed(MouseCode code) {return false;} + virtual bool isMouseDown(MouseCode code) {return false;} + virtual bool wasMouseReleased(MouseCode code) {return false;} + virtual bool wasKeyPressed(KeyCode code) {return false;} + virtual bool isKeyDown(KeyCode code) {return false;} + virtual bool wasKeyTyped(KeyCode code) {return false;} + virtual bool wasKeyReleased(KeyCode code) {return false;} + virtual void addInputSignal(InputSignal* s) {} + virtual void removeInputSignal(InputSignal* s) {} + virtual void addRepaintSignal(RepaintSignal* s) {} + virtual void removeRepaintSignal(RepaintSignal* s) {} + virtual bool isWithin(int x,int y) {return false;} //in screen space + virtual Panel* isWithinTraverse(int x,int y) {return 0;} + virtual void localToScreen(int& x,int& y) {} + virtual void screenToLocal(int& x,int& y) {} + virtual void setCursor(Cursor* cursor) {} + virtual void setCursor(Scheme::SchemeCursor scu) {} + virtual Cursor* getCursor() {return 0;} + virtual void setMinimumSize(int wide,int tall) {} + virtual void getMinimumSize(int& wide,int& tall) {} + virtual void requestFocus() {} + virtual bool hasFocus() {return false;} + virtual int getChildCount() {return 0;} + virtual Panel* getChild(int index) {return 0;} + virtual void setLayout(Layout* layout) {} + virtual void invalidateLayout(bool layoutNow) {} + virtual void setFocusNavGroup(FocusNavGroup* focusNavGroup) {} + virtual void requestFocusPrev() {} + virtual void requestFocusNext() {} + virtual void addFocusChangeSignal(FocusChangeSignal* s) {} + virtual bool isAutoFocusNavEnabled() {return false;} + virtual void setAutoFocusNavEnabled(bool state) {} + virtual void setBorder(Border* border) {} + virtual void setPaintBorderEnabled(bool state) {} + virtual void setPaintBackgroundEnabled(bool state) {} + virtual void setPaintEnabled(bool state) {} + virtual void getInset(int& left,int& top,int& right,int& bottom) {} + virtual void getPaintSize(int& wide,int& tall) {} + virtual void setPreferredSize(int wide,int tall) {} + virtual void getPreferredSize(int& wide,int& tall) {} + virtual SurfaceBase* getSurfaceBase() {return 0;} + virtual bool isEnabled() {return _enabled = false;} + virtual void setEnabled(bool state) {_enabled = true;} + virtual void setBuildGroup(BuildGroup* buildGroup,const char* panelPersistanceName) {} + virtual bool isBuildGroupEnabled() {return false;} + virtual void removeAllChildren() {} + virtual void repaintParent() {} + virtual Panel* createPropertyPanel() {return 0;} + virtual void getPersistanceText(char* buf,int bufLen) {} + virtual void applyPersistanceText(const char* buf) {} + virtual void setFgColor(Scheme::SchemeColor sc) {} + virtual void setBgColor(Scheme::SchemeColor sc) {} + virtual void setFgColor(int r,int g,int b,int a) {} + virtual void setBgColor(int r,int g,int b,int a) {} + virtual void getFgColor(int& r,int& g,int& b,int& a) {} + virtual void getBgColor(int& r,int& g,int& b,int& a) {} + virtual void setBgColor(Color color) {} + virtual void setFgColor(Color color) {} + virtual void getBgColor(Color& color) {} + virtual void getFgColor(Color& color) {} + virtual void setAsMouseCapture(bool state) {} + virtual void setAsMouseArena(bool state) {} + virtual App* getApp() {return 0;} + virtual void getVirtualSize(int& wide,int& tall) {} + virtual void setLayoutInfo(LayoutInfo* layoutInfo) {} + virtual LayoutInfo* getLayoutInfo() {return 0;} + virtual bool isCursorNone() {return false;} +public: //bullshit public + virtual void solveTraverse() {} + virtual void paintTraverse() {} + virtual void setSurfaceBaseTraverse(SurfaceBase* surfaceBase) {} +protected: + virtual void performLayout() {} + virtual void internalPerformLayout() {} + virtual void drawSetColor(Scheme::SchemeColor sc) {} + virtual void drawSetColor(int r,int g,int b,int a) {} + virtual void drawFilledRect(int x0,int y0,int x1,int y1) {} + virtual void drawOutlinedRect(int x0,int y0,int x1,int y1) {} + virtual void drawSetTextFont(Scheme::SchemeFont sf) {} + virtual void drawSetTextFont(Font* font) {} + virtual void drawSetTextColor(Scheme::SchemeColor sc) {} + virtual void drawSetTextColor(int r,int g,int b,int a) {} + virtual void drawSetTextPos(int x,int y) {} + virtual void drawPrintText(const char* str,int strlen) {} + virtual void drawPrintText(int x,int y,const char* str,int strlen) {} + virtual void drawPrintChar(char ch) {} + virtual void drawPrintChar(int x,int y,char ch) {} + virtual void drawSetTextureRGBA(int id,const char* rgba,int wide,int tall) {} + virtual void drawSetTexture(int id) {} + virtual void drawTexturedRect(int x0,int y0,int x1,int y1) {} + virtual void solve() {} + virtual void paintTraverse(bool repaint) {if(repaint) paintBackground();} + virtual void paintBackground() {} + virtual void paint() {} + virtual void paintBuildOverlay() {} + virtual void internalCursorMoved(int x,int y) {} + virtual void internalCursorEntered() {} + virtual void internalCursorExited() {} + virtual void internalMousePressed(MouseCode code) {} + virtual void internalMouseDoublePressed(MouseCode code) {} + virtual void internalMouseReleased(MouseCode code) {} + virtual void internalMouseWheeled(int delta) {} + virtual void internalKeyPressed(KeyCode code) {} + virtual void internalKeyTyped(KeyCode code) {} + virtual void internalKeyReleased(KeyCode code) {} + virtual void internalKeyFocusTicked() {} + virtual void internalFocusChanged(bool lost) {} + virtual void internalSetCursor() {} +protected: + int _pos[2]; + int _size[2]; + int _loc[2]; + int _minimumSize[2]; + int _preferredSize[2]; + Dar _childDar; + Panel* _parent; + SurfaceBase* _surfaceBase; + Dar _inputSignalDar; + Dar _repaintSignalDar; + int _clipRect[4]; + Cursor* _cursor; + Scheme::SchemeCursor _schemeCursor; + bool _visible; + Layout* _layout; + bool _needsLayout; + FocusNavGroup* _focusNavGroup; + Dar _focusChangeSignalDar; + bool _autoFocusNavEnabled; + Border* _border; +private: + bool _needsRepaint; + bool _enabled; + BuildGroup* _buildGroup; + Color _fgColor; + Color _bgColor; + LayoutInfo* _layoutInfo; + bool _paintBorderEnabled; + bool _paintBackgroundEnabled; + bool _paintEnabled; +friend class Panel; +friend class App; +friend class SurfaceBase; +friend class Image; +}; +} + +#endif diff --git a/utils/false_vgui/include/VGUI_Scheme.h b/utils/false_vgui/include/VGUI_Scheme.h new file mode 100644 index 00000000..e32d7976 --- /dev/null +++ b/utils/false_vgui/include/VGUI_Scheme.h @@ -0,0 +1,82 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_SCHEME_H +#define VGUI_SCHEME_H + +#include + + +namespace vgui +{ + +class Font; +class Cursor; + +class VGUIAPI Scheme +{ +public: + enum SchemeColor + { + sc_user=0, + sc_black, + sc_white, + sc_primary1, + sc_primary2, + sc_primary3, + sc_secondary1, + sc_secondary2, + sc_secondary3, + sc_last + }; + enum SchemeFont + { + sf_user=0, + sf_primary1, + sf_primary2, + sf_primary3, + sf_secondary1, + sf_last + }; + enum SchemeCursor + { + scu_user=0, + scu_none, + scu_arrow, + scu_ibeam, + scu_hourglass, + scu_crosshair, + scu_up, + scu_sizenwse, + scu_sizenesw, + scu_sizewe, + scu_sizens, + scu_sizeall, + scu_no, + scu_hand, + scu_last + }; +public: + Scheme() {} +public: + virtual void setColor(SchemeColor sc,int r,int g,int b,int a) {} + virtual void getColor(SchemeColor sc,int& r,int& g,int& b,int& a) {} + virtual void setFont(SchemeFont sf,Font* font) {} + virtual Font* getFont(SchemeFont sf) {return 0;} + virtual void setCursor(SchemeCursor sc,Cursor* cursor) {} + virtual Cursor* getCursor(SchemeCursor sc) {return 0;} +protected: + int _color[sc_last][4]; + Font* _font[sf_last]; + Cursor* _cursor[scu_last]; + friend class Panel; + friend class Canvas; +}; + +} + +#endif From 33de8458d64353b2c4657a6c6648b4e1bc85cf86 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Wed, 6 Dec 2017 22:18:34 +0300 Subject: [PATCH 121/144] Some cleanup. Add false_vgui include path to makefiles --- cl_dll/Android.mk | 5 ++- cl_dll/CMakeLists.txt | 2 +- cl_dll/Makefile | 2 +- cl_dll/cdll_int.cpp | 3 ++ cl_dll/cl_dll.dsp | 4 +- utils/false_vgui/include/VGUI.h | 13 ------ utils/false_vgui/include/VGUI_Bitmap.h | 37 --------------- utils/false_vgui/include/VGUI_Image.h | 62 -------------------------- 8 files changed, 10 insertions(+), 118 deletions(-) delete mode 100644 utils/false_vgui/include/VGUI_Bitmap.h delete mode 100644 utils/false_vgui/include/VGUI_Image.h diff --git a/cl_dll/Android.mk b/cl_dll/Android.mk index 29aee174..452eb48b 100755 --- a/cl_dll/Android.mk +++ b/cl_dll/Android.mk @@ -91,7 +91,7 @@ SRCS+=./view.cpp SRCS+=./input_xash3d.cpp SRCS+=./scoreboard.cpp SRCS+=./MOTD.cpp -INCLUDES = -I../common -I. -I../game_shared -I../pm_shared -I../engine -I../dlls +INCLUDES = -I../common -I. -I../game_shared -I../pm_shared -I../engine -I../dlls -I../utils/false_vgui/include DEFINES = -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w LOCAL_C_INCLUDES := $(LOCAL_PATH)/. \ @@ -99,7 +99,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/. \ $(LOCAL_PATH)/../engine \ $(LOCAL_PATH)/../game_shared \ $(LOCAL_PATH)/../dlls \ - $(LOCAL_PATH)/../pm_shared + $(LOCAL_PATH)/../pm_shared \ + $(LOCAL_PATH)/../utils/false_vgui/include LOCAL_CFLAGS += $(DEFINES) $(INCLUDES) ifeq ($(GOLDSOURCE_SUPPORT),1) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index e52a0d95..e5a3aa0a 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -27,7 +27,7 @@ set (CLDLL_LIBRARY client) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w") if (GOLDSOURCE_SUPPORT) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT -L${CMAKE_CURRENT_SOURCE_DIR}/.. -lSDL2 -Wl,--no-undefined") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT -lSDL2") endif() set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") diff --git a/cl_dll/Makefile b/cl_dll/Makefile index 16427f8f..f624473e 100644 --- a/cl_dll/Makefile +++ b/cl_dll/Makefile @@ -67,7 +67,7 @@ SRCS+=./view.cpp SRCS+=./input_xash3d.cpp SRCS+=./scoreboard.cpp SRCS+=./MOTD.cpp -INCLUDES = -I../common -I. -I../game_shared -I../pm_shared -I../engine -I../dlls +INCLUDES = -I../common -I. -I../game_shared -I../pm_shared -I../engine -I../dlls -I../utils/false_vgui/include DEFINES = -Wno-write-strings -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL CFLAGS = -m32 OBJS = $(SRCS:.cpp=.o) $(SRCS_C:.c=.o) diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index 1901d9d2..7427ef80 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -239,6 +239,7 @@ int DLLEXPORT HUD_VidInit( void ) #ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT vgui::Panel* root=(vgui::Panel*)gEngfuncs.VGui_GetPanel(); if (root) { + gEngfuncs.Con_Printf( "Root VGUI panel exists\n" ); root->setBgColor(128,128,0,0); if (gViewPort != NULL) @@ -250,6 +251,8 @@ int DLLEXPORT HUD_VidInit( void ) gViewPort = new TeamFortressViewport(0,0,root->getWide(),root->getTall()); gViewPort->setParent(root); } + } else { + gEngfuncs.Con_Printf( "Root VGUI panel does not exist\n" ); } #endif return 1; diff --git a/cl_dll/cl_dll.dsp b/cl_dll/cl_dll.dsp index e8ae7d15..17beb9ae 100644 --- a/cl_dll/cl_dll.dsp +++ b/cl_dll/cl_dll.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 1 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\utils\vgui\include" /I "..\engine" /I "..\common" /I "..\pm_shared" /I "..\dlls" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "CLIENT_DLL" /D "CLIENT_WEAPONS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\utils\false_vgui\include" /I "..\engine" /I "..\common" /I "..\pm_shared" /I "..\dlls" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "CLIENT_DLL" /D "CLIENT_WEAPONS" /YX /FD /c # SUBTRACT CPP /Z # ADD BASE MTL /nologo /D "NDEBUG" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -80,7 +80,7 @@ SOURCE="$(InputPath)" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /G5 /MTd /W3 /Gm /GR /GX /ZI /Od /I "..\dlls" /I "..\common" /I "..\pm_shared" /I "..\engine" /I "..\utils\vgui\include" /I "..\game_shared" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "CLIENT_DLL" /D "CLIENT_WEAPONS" /FR /YX /FD /c +# ADD CPP /nologo /G5 /MTd /W3 /Gm /GR /GX /ZI /Od /I "..\dlls" /I "..\common" /I "..\pm_shared" /I "..\engine" /I "..\utils\false_vgui\include" /I "..\game_shared" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "CLIENT_DLL" /D "CLIENT_WEAPONS" /FR /YX /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "_DEBUG" diff --git a/utils/false_vgui/include/VGUI.h b/utils/false_vgui/include/VGUI.h index 0dff607a..c33e0589 100644 --- a/utils/false_vgui/include/VGUI.h +++ b/utils/false_vgui/include/VGUI.h @@ -91,18 +91,5 @@ typedef unsigned short ushort; typedef unsigned int uint; typedef unsigned long ulong; -namespace vgui -{ - -VGUIAPI void vgui_setMalloc(void *(*malloc)(size_t size) ); -VGUIAPI void vgui_setFree(void (*free)(void* memblock)); -VGUIAPI void vgui_strcpy(char* dst,int dstLen,const char* src); -VGUIAPI char* vgui_strdup(const char* src); -VGUIAPI int vgui_printf(const char* format,...); -VGUIAPI int vgui_dprintf(const char* format,...); -VGUIAPI int vgui_dprintf2(const char* format,...); - -} - #endif diff --git a/utils/false_vgui/include/VGUI_Bitmap.h b/utils/false_vgui/include/VGUI_Bitmap.h deleted file mode 100644 index a2cc7a45..00000000 --- a/utils/false_vgui/include/VGUI_Bitmap.h +++ /dev/null @@ -1,37 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#ifndef VGUI_BITMAP_H -#define VGUI_BITMAP_H - -#include -#include - -namespace vgui -{ - -class Panel; - -class VGUIAPI Bitmap : public Image -{ -private: - int _id; - bool _uploaded; -public: - Bitmap() {} -protected: - virtual void setSize(int wide,int tall) {} - virtual void setRGBA(int x,int y,uchar r,uchar g,uchar b,uchar a) {} -public: - virtual void paint(Panel* panel) {} -protected: - uchar* _rgba; -}; - -} - -#endif diff --git a/utils/false_vgui/include/VGUI_Image.h b/utils/false_vgui/include/VGUI_Image.h deleted file mode 100644 index ff83f047..00000000 --- a/utils/false_vgui/include/VGUI_Image.h +++ /dev/null @@ -1,62 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#ifndef VGUI_IMAGE_H -#define VGUI_IMAGE_H - -#include -#include -#include - -//TODO:: needs concept of insets - -namespace vgui -{ - -class Panel; - -class VGUIAPI Image -{ -friend class Panel; -private: - int _pos[2]; - int _size[2]; - Panel* _panel; - Color _color; -public: - Image(); -public: - virtual void setPos(int x,int y) {} - virtual void getPos(int& x,int& y) {} - virtual void getSize(int& wide,int& tall) {} - virtual void setColor(Color color) {} - virtual void getColor(Color& color) {} -protected: - virtual void setSize(int wide,int tall) {} - virtual void drawSetColor(Scheme::SchemeColor sc) {} - virtual void drawSetColor(int r,int g,int b,int a) {} - virtual void drawFilledRect(int x0,int y0,int x1,int y1) {} - virtual void drawOutlinedRect(int x0,int y0,int x1,int y1) {} - virtual void drawSetTextFont(Scheme::SchemeFont sf) {} - virtual void drawSetTextFont(Font* font) {} - virtual void drawSetTextColor(Scheme::SchemeColor sc) {} - virtual void drawSetTextColor(int r,int g,int b,int a) {} - virtual void drawSetTextPos(int x,int y) {} - virtual void drawPrintText(const char* str,int strlen) {} - virtual void drawPrintText(int x,int y,const char* str,int strlen) {} - virtual void drawPrintChar(char ch) {} - virtual void drawPrintChar(int x,int y,char ch) {} - virtual void drawSetTextureRGBA(int id,const char* rgba,int wide,int tall) {} - virtual void drawSetTexture(int id) {} - virtual void drawTexturedRect(int x0,int y0,int x1,int y1) {} - virtual void paint(Panel* panel) {} -public: - virtual void doPaint(Panel* panel) {} -}; -} - -#endif From ca590f24208f7cf37889f833286822e33f4a1b5f Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Thu, 7 Dec 2017 00:31:27 +0300 Subject: [PATCH 122/144] Use old API to draw scoreboard and motd lines in goldsource --- cl_dll/cdll_int.cpp | 5 +++++ cl_dll/cl_util.h | 6 +++++- cl_dll/hud_redraw.cpp | 42 ++++++++++++++++++++++++------------------ cl_dll/input_mouse.cpp | 3 ++- 4 files changed, 36 insertions(+), 20 deletions(-) diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index d71659e9..80b45e31 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -305,3 +305,8 @@ void DLLEXPORT HUD_MobilityInterface( mobile_engfuncs_t *gpMobileEngfuncs ) return; gMobileEngfuncs = gpMobileEngfuncs; } + +bool isXashFWGS() +{ + return gMobileEngfuncs != NULL; +} diff --git a/cl_dll/cl_util.h b/cl_dll/cl_util.h index 1996543d..23f12230 100644 --- a/cl_dll/cl_util.h +++ b/cl_dll/cl_util.h @@ -15,7 +15,8 @@ // // cl_util.h // - +#ifndef CL_UTIL_H +#define CL_UTIL_H #include "exportdef.h" #include "cvardef.h" @@ -179,3 +180,6 @@ inline void UnpackRGB( int &r, int &g, int &b, unsigned long ulRGB )\ } HSPRITE LoadSprite( const char *pszName ); + +bool isXashFWGS(); +#endif diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index 829fd4b2..06b25a33 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -235,29 +235,35 @@ int CHud::DrawHudString( int xpos, int ypos, int iMaxX, const char *szIt, int r, int DrawUtfString( int xpos, int ypos, int iMaxX, const char *szIt, int r, int g, int b ) { - // xash3d: reset unicode state - gEngfuncs.pfnVGUI2DrawCharacterAdditive( 0, 0, 0, 0, 0, 0, 0 ); - - // draw the string until we hit the null character or a newline character - for( ; *szIt != 0 && *szIt != '\n'; szIt++ ) + if (isXashFWGS()) { - int w = gHUD.m_scrinfo.charWidths['M']; - if( xpos + w > iMaxX ) - return xpos; - if( ( *szIt == '^' ) && ( *( szIt + 1 ) >= '0') && ( *( szIt + 1 ) <= '7') ) + // xash3d: reset unicode state + gEngfuncs.pfnVGUI2DrawCharacterAdditive( 0, 0, 0, 0, 0, 0, 0 ); + + // draw the string until we hit the null character or a newline character + for( ; *szIt != 0 && *szIt != '\n'; szIt++ ) { - szIt++; - r = colors[*szIt - '0'][0]; - g = colors[*szIt - '0'][1]; - b = colors[*szIt - '0'][2]; - if( !*(++szIt) ) + int w = gHUD.m_scrinfo.charWidths['M']; + if( xpos + w > iMaxX ) return xpos; + if( ( *szIt == '^' ) && ( *( szIt + 1 ) >= '0') && ( *( szIt + 1 ) <= '7') ) + { + szIt++; + r = colors[*szIt - '0'][0]; + g = colors[*szIt - '0'][1]; + b = colors[*szIt - '0'][2]; + if( !*(++szIt) ) + return xpos; + } + int c = (unsigned int)(unsigned char)*szIt; + xpos += gEngfuncs.pfnVGUI2DrawCharacterAdditive( xpos, ypos, c, r, g, b, 0 ); } - int c = (unsigned int)(unsigned char)*szIt; - xpos += gEngfuncs.pfnVGUI2DrawCharacterAdditive( xpos, ypos, c, r, g, b, 0 ); + return xpos; + } + else + { + return gHUD.DrawHudString(xpos, ypos, iMaxX, szIt, r, g, b); } - - return xpos; } int CHud::DrawHudStringLen( const char *szIt ) diff --git a/cl_dll/input_mouse.cpp b/cl_dll/input_mouse.cpp index 724824cd..8d57091b 100644 --- a/cl_dll/input_mouse.cpp +++ b/cl_dll/input_mouse.cpp @@ -1,6 +1,7 @@ #include "input_mouse.h" #include "exportdef.h" #include "hud.h" +#include "cl_util.h" // shared between backends Vector dead_viewangles(0, 0, 0); @@ -68,7 +69,7 @@ void IN_Shutdown( void ) void IN_Init( void ) { #ifdef SUPPORT_GOLDSOURCE_INPUT - if (gMobileEngfuncs) { + if (isXashFWGS()) { gEngfuncs.Con_Printf( "FWGS Xash3D input is in use\n" ); currentInput = &fwgsInput; } else { From 1759e8c956e1d4cbd42e9a6d17c1d4208b5b8f1a Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Thu, 7 Dec 2017 01:25:59 +0300 Subject: [PATCH 123/144] Dynamic sdl2 loading from client --- cl_dll/CMakeLists.txt | 5 ++- cl_dll/input_goldsource.cpp | 73 ++++++++++++++++++++++++++++--------- cl_dll/input_mouse.h | 1 + 3 files changed, 60 insertions(+), 19 deletions(-) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index e5a3aa0a..e3ac075a 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -27,7 +27,10 @@ set (CLDLL_LIBRARY client) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w") if (GOLDSOURCE_SUPPORT) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT -lSDL2") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT") + if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ldl") + endif() endif() set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp index 5c2b0381..7c0e6183 100644 --- a/cl_dll/input_goldsource.cpp +++ b/cl_dll/input_goldsource.cpp @@ -28,8 +28,18 @@ #endif #ifdef USE_SDL2 +#include #include #include +int (*pfnSDL_SetRelativeMouseMode)(SDL_bool); +Uint32 (*pfnSDL_GetRelativeMouseState)(int* x, int* y); +int (*pfnSDL_NumJoysticks)(void); +SDL_bool (*pfnSDL_IsGameController)(int); +SDL_GameController* (*pfnSDL_GameControllerOpen)(int); +Sint16 (*pfnSDL_GameControllerGetAxis)(SDL_GameController*, SDL_GameControllerAxis); +Uint8 (*pfnSDL_GameControllerGetButton)(SDL_GameController*, SDL_GameControllerButton); +void (*pfnSDL_JoystickUpdate)(void); +const char* (*pfnSDL_GameControllerName)(SDL_GameController*); #endif #ifdef _WIN32 @@ -289,12 +299,12 @@ void IN_SetMouseMode(bool enable) if(m_bRawInput) { #ifdef USE_SDL2 - SDL_SetRelativeMouseMode(SDL_TRUE); + pfnSDL_SetRelativeMouseMode(SDL_TRUE); #endif isMouseRelative = true; } #else - SDL_SetRelativeMouseMode(SDL_TRUE); + pfnSDL_SetRelativeMouseMode(SDL_TRUE); #endif currentMouseMode = true; @@ -305,7 +315,7 @@ void IN_SetMouseMode(bool enable) if(isMouseRelative) { #ifdef USE_SDL2 - SDL_SetRelativeMouseMode(SDL_FALSE); + pfnSDL_SetRelativeMouseMode(SDL_FALSE); #endif isMouseRelative = false; } @@ -313,7 +323,7 @@ void IN_SetMouseMode(bool enable) if (restore_spi) SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0); #else - SDL_SetRelativeMouseMode(SDL_FALSE); + pfnSDL_SetRelativeMouseMode(SDL_FALSE); #endif currentMouseMode = false; @@ -464,6 +474,11 @@ void GoldSourceInput::IN_Shutdown (void) s_hMouseThreadActiveLock = (HANDLE)0; } #endif + +#ifdef USE_SDL2 + dlclose(sdl2Lib); + sdl2Lib = NULL; +#endif } /* @@ -623,7 +638,7 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY) #endif { #ifdef USE_SDL2 - SDL_GetRelativeMouseState( &deltaX, &deltaY ); + pfnSDL_GetRelativeMouseState( &deltaX, &deltaY ); current_pos.x = deltaX; current_pos.y = deltaY; #else @@ -679,14 +694,14 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY) if(m_bRawInput && !isMouseRelative) { #ifdef USE_SDL2 - SDL_SetRelativeMouseMode(SDL_TRUE); + pfnSDL_SetRelativeMouseMode(SDL_TRUE); #endif isMouseRelative = true; } else if(!m_bRawInput && isMouseRelative) { #ifdef USE_SDL2 - SDL_SetRelativeMouseMode(SDL_FALSE); + pfnSDL_SetRelativeMouseMode(SDL_FALSE); #endif isMouseRelative = false; } @@ -815,7 +830,7 @@ void GoldSourceInput::IN_Accumulate (void) { #ifdef USE_SDL2 int deltaX, deltaY; - SDL_GetRelativeMouseState( &deltaX, &deltaY ); + pfnSDL_GetRelativeMouseState( &deltaX, &deltaY ); mx_accum += deltaX; my_accum += deltaY; #else @@ -869,14 +884,14 @@ void IN_StartupJoystick (void) // assume no joystick joy_avail = 0; #ifdef USE_SDL2 - int nJoysticks = SDL_NumJoysticks(); + int nJoysticks = pfnSDL_NumJoysticks(); if ( nJoysticks > 0 ) { for ( int i = 0; i < nJoysticks; i++ ) { - if ( SDL_IsGameController( i ) ) + if ( pfnSDL_IsGameController( i ) ) { - s_pJoystick = SDL_GameControllerOpen( i ); + s_pJoystick = pfnSDL_GameControllerOpen( i ); if ( s_pJoystick ) { //save the joystick's number of buttons and POV status @@ -888,7 +903,7 @@ void IN_StartupJoystick (void) // mark the joystick as available and advanced initialization not completed // this is needed as cvars are not available during initialization - gEngfuncs.Con_Printf ("joystick found\n\n", SDL_GameControllerName(s_pJoystick)); + gEngfuncs.Con_Printf ("joystick found\n\n", pfnSDL_GameControllerName(s_pJoystick)); joy_avail = 1; joy_advancedinit = 0; break; @@ -912,13 +927,13 @@ int RawValuePointer (int axis) { default: case JOY_AXIS_X: - return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTX ); + return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTX ); case JOY_AXIS_Y: - return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTY ); + return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTY ); case JOY_AXIS_Z: - return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTX ); + return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTX ); case JOY_AXIS_R: - return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTY ); + return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTY ); } #else @@ -1011,7 +1026,7 @@ void GoldSourceInput::IN_Commands (void) #ifdef USE_SDL2 for ( i = 0; i < SDL_CONTROLLER_BUTTON_MAX; i++ ) { - if ( SDL_GameControllerGetButton( s_pJoystick, (SDL_GameControllerButton)i ) ) + if ( pfnSDL_GameControllerGetButton( s_pJoystick, (SDL_GameControllerButton)i ) ) { buttonstate |= 1< Date: Thu, 7 Dec 2017 04:43:25 +0300 Subject: [PATCH 124/144] Provide safe wrappers around sdl function pointers. Use dylib extension on macOS --- cl_dll/input_goldsource.cpp | 137 ++++++++++++++++++++++++++++-------- 1 file changed, 108 insertions(+), 29 deletions(-) diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp index 7c0e6183..e367a37e 100644 --- a/cl_dll/input_goldsource.cpp +++ b/cl_dll/input_goldsource.cpp @@ -40,6 +40,63 @@ Sint16 (*pfnSDL_GameControllerGetAxis)(SDL_GameController*, SDL_GameControllerAx Uint8 (*pfnSDL_GameControllerGetButton)(SDL_GameController*, SDL_GameControllerButton); void (*pfnSDL_JoystickUpdate)(void); const char* (*pfnSDL_GameControllerName)(SDL_GameController*); + +int safe_pfnSDL_SetRelativeMouseMode(SDL_bool mode) +{ + if (pfnSDL_SetRelativeMouseMode) + return pfnSDL_SetRelativeMouseMode(mode); + return -1; +} +Uint32 safe_pfnSDL_GetRelativeMouseState(int* x, int* y) +{ + if (pfnSDL_GetRelativeMouseState) + return pfnSDL_GetRelativeMouseState(x, y); + return 0; +} +int safe_pfnSDL_NumJoysticks() +{ + if (pfnSDL_NumJoysticks) + return pfnSDL_NumJoysticks(); + return -1; +} +SDL_bool safe_pfnSDL_IsGameController(int joystick_index) +{ + if (pfnSDL_IsGameController) + return pfnSDL_IsGameController(joystick_index); + return SDL_FALSE; +} +SDL_GameController* safe_pfnSDL_GameControllerOpen(int joystick_index) +{ + if (pfnSDL_GameControllerOpen) + return pfnSDL_GameControllerOpen(joystick_index); + return NULL; +} +Sint16 safe_pfnSDL_GameControllerGetAxis(SDL_GameController* gamecontroller, SDL_GameControllerAxis axis) +{ + if (pfnSDL_GameControllerGetAxis) + return pfnSDL_GameControllerGetAxis(gamecontroller, axis); + return 0; +} +Uint8 safe_pfnSDL_GameControllerGetButton(SDL_GameController* gamecontroller, SDL_GameControllerButton button) +{ + if (pfnSDL_GameControllerGetButton) + return pfnSDL_GameControllerGetButton(gamecontroller, button); + return 0; +} +void safe_pfnSDL_JoystickUpdate() +{ + if (pfnSDL_JoystickUpdate) + pfnSDL_JoystickUpdate(); +} +const char* safe_pfnSDL_GameControllerName(SDL_GameController* gamecontroller) +{ + if (pfnSDL_GameControllerName) + return pfnSDL_GameControllerName(gamecontroller); + return NULL; +} +static void** const sdlFunctionPointers[] = {(void**)&pfnSDL_SetRelativeMouseMode, (void**)&pfnSDL_GetRelativeMouseState, (void**)&pfnSDL_NumJoysticks, + (void**)&pfnSDL_IsGameController, (void**)&pfnSDL_GameControllerOpen, (void**)&pfnSDL_GameControllerGetAxis, + (void**)&pfnSDL_GameControllerGetButton, (void**)&pfnSDL_JoystickUpdate, (void**)&pfnSDL_GameControllerName}; #endif #ifdef _WIN32 @@ -299,12 +356,12 @@ void IN_SetMouseMode(bool enable) if(m_bRawInput) { #ifdef USE_SDL2 - pfnSDL_SetRelativeMouseMode(SDL_TRUE); + safe_pfnSDL_SetRelativeMouseMode(SDL_TRUE); #endif isMouseRelative = true; } #else - pfnSDL_SetRelativeMouseMode(SDL_TRUE); + safe_pfnSDL_SetRelativeMouseMode(SDL_TRUE); #endif currentMouseMode = true; @@ -315,7 +372,7 @@ void IN_SetMouseMode(bool enable) if(isMouseRelative) { #ifdef USE_SDL2 - pfnSDL_SetRelativeMouseMode(SDL_FALSE); + safe_pfnSDL_SetRelativeMouseMode(SDL_FALSE); #endif isMouseRelative = false; } @@ -323,7 +380,7 @@ void IN_SetMouseMode(bool enable) if (restore_spi) SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0); #else - pfnSDL_SetRelativeMouseMode(SDL_FALSE); + safe_pfnSDL_SetRelativeMouseMode(SDL_FALSE); #endif currentMouseMode = false; @@ -476,6 +533,9 @@ void GoldSourceInput::IN_Shutdown (void) #endif #ifdef USE_SDL2 + for (int j=0; j 0 ) { for ( int i = 0; i < nJoysticks; i++ ) { - if ( pfnSDL_IsGameController( i ) ) + if ( safe_pfnSDL_IsGameController( i ) ) { - s_pJoystick = pfnSDL_GameControllerOpen( i ); + s_pJoystick = safe_pfnSDL_GameControllerOpen( i ); if ( s_pJoystick ) { //save the joystick's number of buttons and POV status @@ -903,7 +963,7 @@ void IN_StartupJoystick (void) // mark the joystick as available and advanced initialization not completed // this is needed as cvars are not available during initialization - gEngfuncs.Con_Printf ("joystick found\n\n", pfnSDL_GameControllerName(s_pJoystick)); + gEngfuncs.Con_Printf ("joystick found\n\n", safe_pfnSDL_GameControllerName(s_pJoystick)); joy_avail = 1; joy_advancedinit = 0; break; @@ -927,13 +987,13 @@ int RawValuePointer (int axis) { default: case JOY_AXIS_X: - return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTX ); + return safe_pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTX ); case JOY_AXIS_Y: - return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTY ); + return safe_pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTY ); case JOY_AXIS_Z: - return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTX ); + return safe_pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTX ); case JOY_AXIS_R: - return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTY ); + return safe_pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTY ); } #else @@ -1026,7 +1086,7 @@ void GoldSourceInput::IN_Commands (void) #ifdef USE_SDL2 for ( i = 0; i < SDL_CONTROLLER_BUTTON_MAX; i++ ) { - if ( pfnSDL_GameControllerGetButton( s_pJoystick, (SDL_GameControllerButton)i ) ) + if ( safe_pfnSDL_GameControllerGetButton( s_pJoystick, (SDL_GameControllerButton)i ) ) { buttonstate |= 1< Date: Thu, 7 Dec 2017 21:25:26 +0300 Subject: [PATCH 125/144] sdl loading refactoring --- cl_dll/input_goldsource.cpp | 58 ++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp index e367a37e..38dac71d 100644 --- a/cl_dll/input_goldsource.cpp +++ b/cl_dll/input_goldsource.cpp @@ -28,6 +28,7 @@ #endif #ifdef USE_SDL2 +#define ARRAYSIZE(p) ( sizeof(p) /sizeof(p[0]) ) #include #include #include @@ -94,9 +95,23 @@ const char* safe_pfnSDL_GameControllerName(SDL_GameController* gamecontroller) return pfnSDL_GameControllerName(gamecontroller); return NULL; } -static void** const sdlFunctionPointers[] = {(void**)&pfnSDL_SetRelativeMouseMode, (void**)&pfnSDL_GetRelativeMouseState, (void**)&pfnSDL_NumJoysticks, - (void**)&pfnSDL_IsGameController, (void**)&pfnSDL_GameControllerOpen, (void**)&pfnSDL_GameControllerGetAxis, - (void**)&pfnSDL_GameControllerGetButton, (void**)&pfnSDL_JoystickUpdate, (void**)&pfnSDL_GameControllerName}; + +struct SDLFunction +{ + void** ppfnFunc; + const char* name; +}; +static SDLFunction sdlFunctions[] = { + {(void**)&pfnSDL_SetRelativeMouseMode, "SDL_SetRelativeMouseMode"}, + {(void**)&pfnSDL_GetRelativeMouseState, "SDL_GetRelativeMouseState"}, + {(void**)&pfnSDL_NumJoysticks, "SDL_NumJoysticks"}, + {(void**)&pfnSDL_IsGameController, "SDL_IsGameController"}, + {(void**)&pfnSDL_GameControllerOpen, "SDL_GameControllerOpen"}, + {(void**)&pfnSDL_GameControllerGetAxis, "SDL_GameControllerGetAxis"}, + {(void**)&pfnSDL_GameControllerGetButton, "SDL_GameControllerGetButton"}, + {(void**)&pfnSDL_JoystickUpdate, "SDL_JoystickUpdate"}, + {(void**)&pfnSDL_GameControllerName, "SDL_GameControllerName"} +}; #endif #ifdef _WIN32 @@ -533,8 +548,8 @@ void GoldSourceInput::IN_Shutdown (void) #endif #ifdef USE_SDL2 - for (int j=0; j Date: Sat, 9 Dec 2017 00:16:29 +0300 Subject: [PATCH 126/144] Update README.md, update makefiles, add .bat scripts for msvc --- README.md | 92 +++++++++++++++++++++++++++++----- cl_dll/Android.mk | 4 +- cl_dll/Makefile | 1 - cl_dll/compile.bat | 84 +++++++++++++++++++++++++++++++ dlls/Makefile | 4 +- dlls/compile.bat | 121 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 291 insertions(+), 15 deletions(-) create mode 100644 cl_dll/compile.bat create mode 100644 dlls/compile.bat diff --git a/README.md b/README.md index bb1cc675..21db93fb 100644 --- a/README.md +++ b/README.md @@ -6,22 +6,41 @@ Half-Life SDK for Xash3D & GoldSource with some fixes. ### CMake as most universal way -``` -mkdir build && cd build -cmake ../ -``` + mkdir build && cd build + cmake ../ + make You may enable or disable some build options by -Dkey=value. All available build options are defined in CMakeLists.txt at root directory. +See below if you want to build the GoldSource compatible libraries. See below, if CMake is not suitable for you: ### Windows +#### Using msvc + +We use compilers provided with Microsoft Visual Studio 6. There're `compile.bat` scripts in both `cl_dll` and `dlls` directories. +Before running any of those files you must define `MSVCDir` variable which is the path to your msvc installation. + + set MSVCDir=C:\Program Files\Microsoft Visual Studio + compile.bat + +These scripts also can be ran via wine: + + MSVCDir="z:\home\$USER\.wine\drive_c\Program Files\Microsoft Visual Studio" wine cmd /c compile.bat + +The libraries built this way are always GoldSource compatible. + +There're dsp projects for MVS 6 in `cl_dll` and `dlls` directories, but we don't keep them up-to-date. You're free to adapt them for yourself and try to import into the newer MVS versions. + +#### Using mingw + TODO ### Linux -TODO + (cd dlls && make) + (cd cl_dll && make) ### OS X @@ -29,14 +48,65 @@ TODO ### FreeBSD -``` - cd dlls - gmake CXX=clang++ CC=clang - cd ../cl_dll - gmake CXX=clang++ CC=clang -``` + (cd dlls && gmake CXX=clang++ CC=clang) + (cd cl_dll && gmake CXX=clang++ CC=clang) ### Android Just typical `ndk-build`. +TODO: describe what it is. + +### Building GoldSource-compatible libraries + +To enable building the goldsource compatible client library add GOLDSOURCE_SUPPORT flag when calling cmake: + + cmake .. -DGOLDSOURCE_SUPPORT=ON + +or when using make without cmake: + + make GOLDSOURCE_SUPPORT=1 + +Unlike original client by Valve the resulting client library will not depend on vgui or SDL2 just like the one that's used in FWGS Xash3d. + +Note for **Linux**: GoldSource requires libraries (both client and server) to be compiled with libstdc++ bundled with g++ of major version 4 (versions from 4.6 to 4.9 should work). +If your Linux distribution does not provide compatible g++ version you have several options. + +#### Method 1: Statically build with c++ library + +This one is the most simple but has a drawback. + + cmake ../ -DGOLDSOURCE_SUPPORT=ON -DCMAKE_C_FLAGS="-static-libstdc++ -static-libgcc" + +The drawback is that the compiled libraries will be larger in size. + +#### Method 2: Create and use chroot with older distro that includes g++ 4. + +Use the most suitable way for you to create an old distro 32-bit chroot. E.g. on Debian (and similar) you can use debootstrap. + + sudo debootstrap --arch=i386 jessie /var/chroot/jessie-debian-i386 # On Ubuntu type trusty instead of jessie + sudo chroot /var/chroot/jessie-debian-i386 + +Inside chroot install cmake, make, g++ and libsdl2-dev. Then exit the chroot. + +On the host system install schroot. Then create and adapt the following config in /etc/schroot/chroot.d/jessie.conf (you can choose a different name): + +``` +[jessie] +type=directory +description=Debian jessie i386 +directory=/var/chroot/debian-jessie-i386/ +users=yourusername +groups=yourusername +root-groups=root +preserve-environment=true +personality=linux32 +``` + +Insert your actual user name in place of `yourusername`. Then prepend any make or cmake call with `schroot -c jessie --`: + + schroot -c jessie -- cmake ../ -DGOLDSOURCE_SUPPORT=ON + schroot -c jessie -- make + +#### Method 3: Install the needed g++ version yourself +TODO: describe steps. diff --git a/cl_dll/Android.mk b/cl_dll/Android.mk index 452eb48b..68917633 100755 --- a/cl_dll/Android.mk +++ b/cl_dll/Android.mk @@ -105,7 +105,9 @@ LOCAL_CFLAGS += $(DEFINES) $(INCLUDES) ifeq ($(GOLDSOURCE_SUPPORT),1) DEFINES += -DGOLDSOURCE_SUPPORT - LOCAL_LDLIBS += -lSDL2 + ifeq ($(shell uname -s),Linux) + LOCAL_LDLIBS += -ldl + endif endif LOCAL_SRC_FILES := $(SRCS) $(SRCS_C) diff --git a/cl_dll/Makefile b/cl_dll/Makefile index f624473e..0ff4dadf 100644 --- a/cl_dll/Makefile +++ b/cl_dll/Makefile @@ -75,7 +75,6 @@ OBJS = $(SRCS:.cpp=.o) $(SRCS_C:.c=.o) LIBS=-lm ifeq ($(GOLDSOURCE_SUPPORT),1) DEFINES += -DGOLDSOURCE_SUPPORT - LIBS += -lSDL2 endif ifeq ($(shell uname -s),Linux) diff --git a/cl_dll/compile.bat b/cl_dll/compile.bat new file mode 100644 index 00000000..9270d4bc --- /dev/null +++ b/cl_dll/compile.bat @@ -0,0 +1,84 @@ +@echo off +echo Setting environment for minimal Visual C++ 6 +set INCLUDE=%MSVCDir%\VC98\Include +set LIB=%MSVCDir%\VC98\Lib +set PATH=%MSVCDir%\VC98\Bin;%MSVCDir%\Common\MSDev98\Bin\;%PATH% + +echo -- Compiler is MSVC6 + +set XASH3DSRC=..\..\Xash3D_original +set INCLUDES=-I../common -I../engine -I../pm_shared -I../game_shared -I../public -I../external -I../dlls -I../utils/false_vgui/include +set SOURCES=../dlls/crossbow.cpp^ + ../dlls/crowbar.cpp^ + ../dlls/egon.cpp^ + ../dlls/gauss.cpp^ + ../dlls/handgrenade.cpp^ + ../dlls/hornetgun.cpp^ + ../dlls/mp5.cpp^ + ../dlls/python.cpp^ + ../dlls/rpg.cpp^ + ../dlls/satchel.cpp^ + ../dlls/shotgun.cpp^ + ../dlls/squeakgrenade.cpp^ + ../dlls/tripmine.cpp^ + ../dlls/glock.cpp^ + ev_hldm.cpp^ + hl/hl_baseentity.cpp^ + hl/hl_events.cpp^ + hl/hl_objects.cpp^ + hl/hl_weapons.cpp^ + ammo.cpp^ + ammo_secondary.cpp^ + ammohistory.cpp^ + battery.cpp^ + cdll_int.cpp^ + com_weapons.cpp^ + death.cpp^ + demo.cpp^ + entity.cpp^ + ev_common.cpp^ + events.cpp^ + flashlight.cpp^ + GameStudioModelRenderer.cpp^ + geiger.cpp^ + health.cpp^ + hud.cpp^ + hud_msg.cpp^ + hud_redraw.cpp^ + hud_spectator.cpp^ + hud_update.cpp^ + in_camera.cpp^ + input.cpp^ + input_goldsource.cpp^ + input_mouse.cpp^ + input_xash3d.cpp^ + menu.cpp^ + message.cpp^ + overview.cpp^ + parsemsg.cpp^ + ../pm_shared/pm_debug.c^ + ../pm_shared/pm_math.c^ + ../pm_shared/pm_shared.c^ + saytext.cpp^ + status_icons.cpp^ + statusbar.cpp^ + studio_util.cpp^ + StudioModelRenderer.cpp^ + text_message.cpp^ + train.cpp^ + tri.cpp^ + util.cpp^ + view.cpp^ + scoreboard.cpp^ + MOTD.cpp +set DEFINES=/DCLIENT_DLL /DCLIENT_WEAPONS /Dsnprintf=_snprintf /DNO_VOICEGAMEMGR /DGOLDSOURCE_SUPPORT +set LIBS=user32.lib Winmm.lib +set OUTNAME=client.dll +set DEBUG=/debug + +cl %DEFINES% %LIBS% %SOURCES% %INCLUDES% -o %OUTNAME% /link /dll /out:%OUTNAME% %DEBUG% + +echo -- Compile done. Cleaning... + +del *.obj *.exp *.lib *.ilk +echo -- Done. diff --git a/dlls/Makefile b/dlls/Makefile index 60aad1b3..3599b9c7 100644 --- a/dlls/Makefile +++ b/dlls/Makefile @@ -129,13 +129,13 @@ OBJ = \ $(DLL_OBJDIR)/multiplay_gamerules.o \ $(DLL_OBJDIR)/nihilanth.o \ $(DLL_OBJDIR)/nodes.o \ - $(DLL_OBJDIR)/observer.cpp \^M + $(DLL_OBJDIR)/observer.o \ $(DLL_OBJDIR)/osprey.o \ $(DLL_OBJDIR)/pathcorner.o \ $(DLL_OBJDIR)/plane.o \ $(DLL_OBJDIR)/plats.o \ $(DLL_OBJDIR)/player.o \ - $(DLL_OBJDIR)/playermonster.o \^M + $(DLL_OBJDIR)/playermonster.o \ $(DLL_OBJDIR)/python.o \ $(DLL_OBJDIR)/rat.o \ $(DLL_OBJDIR)/roach.o \ diff --git a/dlls/compile.bat b/dlls/compile.bat new file mode 100644 index 00000000..53c4511b --- /dev/null +++ b/dlls/compile.bat @@ -0,0 +1,121 @@ +@echo off +echo Setting environment for minimal Visual C++ 6 +set INCLUDE=%MSVCDir%\VC98\Include +set LIB=%MSVCDir%\VC98\Lib +set PATH=%MSVCDir%\VC98\Bin;%MSVCDir%\Common\MSDev98\Bin\;%PATH% + +echo -- Compiler is MSVC6 + +set XASH3DSRC=..\..\Xash3D_original +set INCLUDES=-I../common -I../engine -I../pm_shared -I../game_shared -I../public +set SOURCES=agrunt.cpp^ + airtank.cpp^ + aflock.cpp^ + animating.cpp^ + animation.cpp^ + apache.cpp^ + barnacle.cpp^ + barney.cpp^ + bigmomma.cpp^ + bloater.cpp^ + bmodels.cpp^ + bullsquid.cpp^ + buttons.cpp^ + cbase.cpp^ + client.cpp^ + combat.cpp^ + controller.cpp^ + crossbow.cpp^ + crowbar.cpp^ + defaultai.cpp^ + doors.cpp^ + effects.cpp^ + egon.cpp^ + explode.cpp^ + flyingmonster.cpp^ + func_break.cpp^ + func_tank.cpp^ + game.cpp^ + gamerules.cpp^ + gargantua.cpp^ + gauss.cpp^ + genericmonster.cpp^ + ggrenade.cpp^ + globals.cpp^ + glock.cpp^ + gman.cpp^ + h_ai.cpp^ + h_battery.cpp^ + h_cine.cpp^ + h_cycler.cpp^ + h_export.cpp^ + handgrenade.cpp^ + hassassin.cpp^ + headcrab.cpp^ + healthkit.cpp^ + hgrunt.cpp^ + hornet.cpp^ + hornetgun.cpp^ + houndeye.cpp^ + ichthyosaur.cpp^ + islave.cpp^ + items.cpp^ + leech.cpp^ + lights.cpp^ + maprules.cpp^ + monstermaker.cpp^ + monsters.cpp^ + monsterstate.cpp^ + mortar.cpp^ + mp5.cpp^ + multiplay_gamerules.cpp^ + nihilanth.cpp^ + nodes.cpp^ + observer.cpp^ + osprey.cpp^ + pathcorner.cpp^ + plane.cpp^ + plats.cpp^ + player.cpp^ + playermonster.cpp^ + python.cpp^ + rat.cpp^ + roach.cpp^ + rpg.cpp^ + satchel.cpp^ + schedule.cpp^ + scientist.cpp^ + scripted.cpp^ + shotgun.cpp^ + singleplay_gamerules.cpp^ + skill.cpp^ + sound.cpp^ + soundent.cpp^ + spectator.cpp^ + squadmonster.cpp^ + squeakgrenade.cpp^ + subs.cpp^ + talkmonster.cpp^ + teamplay_gamerules.cpp^ + tempmonster.cpp^ + tentacle.cpp^ + triggers.cpp^ + tripmine.cpp^ + turret.cpp^ + util.cpp^ + weapons.cpp^ + world.cpp^ + xen.cpp^ + zombie.cpp^ + ../pm_shared/pm_debug.c ../pm_shared/pm_math.c ../pm_shared/pm_shared.c +set DEFINES=/DCLIENT_WEAPONS /Dsnprintf=_snprintf /DNO_VOICEGAMEMGR +set LIBS=user32.lib +set OUTNAME=hl.dll +set DEBUG=/debug + +cl %DEFINES% %LIBS% %SOURCES% %INCLUDES% -o %OUTNAME% /link /dll /out:%OUTNAME% %DEBUG% /def:".\hl.def" + +echo -- Compile done. Cleaning... + +del *.obj *.exp *.lib *.ilk +echo -- Done. From 0d56674e28cf6d08eda6cca79ce208a16a1af6bd Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sat, 9 Dec 2017 13:49:31 +0300 Subject: [PATCH 127/144] Add steam runtime chroot method --- README.md | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 21db93fb..f0d3b4a1 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,21 @@ This one is the most simple but has a drawback. The drawback is that the compiled libraries will be larger in size. -#### Method 2: Create and use chroot with older distro that includes g++ 4. +#### Method 2: Build in Steam Runtime chroot + +This is the official way to build Steam compatible games for Linux. + +Clone https://github.com/ValveSoftware/steam-runtime and follow instructions https://github.com/ValveSoftware/steam-runtime#building-in-the-runtime + + sudo ./setup_chroot.sh --i386 + +Then use cmake and make as usual, but prepend the commands with `schroot --chroot steamrt_scout_i386 --`: + + mkdir build-in-steamrt && cd build-in-steamrt + schroot --chroot steamrt_scout_i386 -- cmake ../ -DGOLDSOURCE_SUPPORT=ON + schroot --chroot steamrt_scout_i386 -- make + +#### Method 3: Create your own chroot with older distro that includes g++ 4. Use the most suitable way for you to create an old distro 32-bit chroot. E.g. on Debian (and similar) you can use debootstrap. @@ -104,9 +118,10 @@ personality=linux32 Insert your actual user name in place of `yourusername`. Then prepend any make or cmake call with `schroot -c jessie --`: - schroot -c jessie -- cmake ../ -DGOLDSOURCE_SUPPORT=ON - schroot -c jessie -- make + mkdir build-in-chroot && cd build-in-chroot + schroot --chroot jessie -- cmake ../ -DGOLDSOURCE_SUPPORT=ON + schroot --chroot jessie -- make -#### Method 3: Install the needed g++ version yourself +#### Method 4: Install the needed g++ version yourself TODO: describe steps. From 87d6ca3b687eb0f6b3745c1ec79d22aac9071783 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sat, 9 Dec 2017 14:45:54 +0300 Subject: [PATCH 128/144] Add instructions for using chroot toolchain in QtCreator --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index f0d3b4a1..9261b1b3 100644 --- a/README.md +++ b/README.md @@ -125,3 +125,17 @@ Insert your actual user name in place of `yourusername`. Then prepend any make o #### Method 4: Install the needed g++ version yourself TODO: describe steps. + +#### Configuring Qt Creator to use toolchain from chroot + +Create a file with the following contents anywhere: + +```sh +#!/bin/sh +schroot --chroot steamrt_scout_i386 -- cmake "$@" +``` + +Make it executable. +In Qt Creator go to `Tools` -> `Options` -> `Build & Run` -> `CMake`. Add a new cmake tool and specify the path of previously created file. +Go to `Kits` tab, clone your default configuration and choose your CMake tool there. +Choose the new kit when opening CMakeLists.txt. From 5a60f08a59651aaaac73efa4af147f2a2d391a57 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Mon, 4 Dec 2017 01:02:25 +0300 Subject: [PATCH 129/144] Joystick support for non-sdl win32 (untested) --- cl_dll/input_goldsource.cpp | 161 ++++++++++++++++++++++++++++++++++-- 1 file changed, 153 insertions(+), 8 deletions(-) diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp index 38dac71d..f530bdbc 100644 --- a/cl_dll/input_goldsource.cpp +++ b/cl_dll/input_goldsource.cpp @@ -217,10 +217,25 @@ enum _ControlList AxisTurn }; +#if !defined(USE_SDL2) && defined(_WIN32) +DWORD dwAxisFlags[JOY_MAX_AXES] = +{ + JOY_RETURNX, + JOY_RETURNY, + JOY_RETURNZ, + JOY_RETURNR, + JOY_RETURNU, + JOY_RETURNV +}; +#endif DWORD dwAxisMap[ JOY_MAX_AXES ]; DWORD dwControlMap[ JOY_MAX_AXES ]; +#if defined(USE_SDL2) int pdwRawValue[ JOY_MAX_AXES ]; +#elif defined(_WIN32) +PDWORD pdwRawValue[ JOY_MAX_AXES ]; +#endif DWORD joy_oldbuttonstate, joy_oldpovstate; int joy_id; @@ -228,6 +243,9 @@ DWORD joy_numbuttons; #ifdef USE_SDL2 SDL_GameController *s_pJoystick = NULL; +#elif defined(_WIN32) +DWORD joy_flags; +static JOYINFOEX ji; #endif // none of these cvars are saved over a session @@ -990,14 +1008,64 @@ void IN_StartupJoystick (void) { gEngfuncs.Con_DPrintf ("joystick not found -- driver not present\n\n"); } +#elif defined(_WIN32) + int numdevs; + JOYCAPS jc; + MMRESULT mmr; + // verify joystick driver is present + if ((numdevs = joyGetNumDevs ()) == 0) + { + gEngfuncs.Con_DPrintf ("joystick not found -- driver not present\n\n"); + return; + } + + // cycle through the joystick ids for the first valid one + for (joy_id=0 ; joy_idvalue != 0.0) + { + ji.dwUpos += 100; + } + return 1; + } + else + { + // read error occurred + // turning off the joystick seems too harsh for 1 read error,\ + // but what should be done? + // Con_Printf ("IN_ReadJoystick: no response\n"); + // joy_avail = 0; + return 0; + } +#else + return 0; +#endif } @@ -1213,7 +1353,12 @@ void IN_JoyMove ( float frametime, usercmd_t *cmd ) for (i = 0; i < JOY_MAX_AXES; i++) { // get the floating point zero-centered, potentially-inverted data for the current axis +#ifdef USE_SDL2 fAxisValue = (float)pdwRawValue[i]; +#elif defined(_WIN32) + fAxisValue = (float) *pdwRawValue[i]; + fAxisValue -= 32768.0; +#endif if (joy_wwhack2->value != 0.0) { From 18adf0979fe6fe8a9af2e5f46721f198b6274e5e Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 10 Dec 2017 20:56:46 +0500 Subject: [PATCH 130/144] Redefine string_t. Fix wrong variables type. --- cl_dll/util_vector.h | 2 +- common/const.h | 2 +- dlls/bigmomma.cpp | 2 +- dlls/cbase.h | 2 +- dlls/effects.cpp | 6 +++--- dlls/effects.h | 2 +- dlls/extdll.h | 2 +- dlls/func_break.h | 4 ++-- dlls/func_tank.cpp | 6 +++--- dlls/lights.cpp | 2 +- dlls/mortar.cpp | 4 ++-- dlls/plats.cpp | 6 +++--- dlls/scripted.cpp | 6 +++--- dlls/scripted.h | 6 +++--- dlls/talkmonster.h | 4 ++-- dlls/triggers.cpp | 14 +++++++------- dlls/util.cpp | 14 +++++++------- dlls/util.h | 4 ++-- dlls/weapons.h | 2 +- 19 files changed, 45 insertions(+), 45 deletions(-) diff --git a/cl_dll/util_vector.h b/cl_dll/util_vector.h index ff5f9a91..8b596ac1 100644 --- a/cl_dll/util_vector.h +++ b/cl_dll/util_vector.h @@ -23,7 +23,7 @@ // Header file containing definition of globalvars_t and entvars_t typedef unsigned int func_t; // -typedef unsigned int string_t; // from engine's pr_comp.h; +typedef int string_t; // from engine's pr_comp.h; typedef float vec_t; // needed before including progdefs.h //========================================================= diff --git a/common/const.h b/common/const.h index d29816e6..3d738675 100644 --- a/common/const.h +++ b/common/const.h @@ -733,7 +733,7 @@ enum }; typedef unsigned int func_t; -typedef unsigned int string_t; +typedef int string_t; typedef unsigned char byte; typedef unsigned short word; diff --git a/dlls/bigmomma.cpp b/dlls/bigmomma.cpp index 6b594983..434d6134 100644 --- a/dlls/bigmomma.cpp +++ b/dlls/bigmomma.cpp @@ -49,7 +49,7 @@ public: virtual int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; - int m_preSequence; + string_t m_preSequence; }; LINK_ENTITY_TO_CLASS( info_bigmomma, CInfoBM ) diff --git a/dlls/cbase.h b/dlls/cbase.h index b78de883..10f7a85f 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -438,7 +438,7 @@ class CBaseDelay : public CBaseEntity { public: float m_flDelay; - int m_iszKillTarget; + string_t m_iszKillTarget; virtual void KeyValue( KeyValueData *pkvd ); virtual int Save( CSave &save ); diff --git a/dlls/effects.cpp b/dlls/effects.cpp index 15df3bc3..5b8d650c 100644 --- a/dlls/effects.cpp +++ b/dlls/effects.cpp @@ -379,9 +379,10 @@ public: void BeamUpdateVars( void ); + string_t m_iszStartEntity; + string_t m_iszEndEntity; + string_t m_iszSpriteName; int m_active; - int m_iszStartEntity; - int m_iszEndEntity; float m_life; int m_boltWidth; int m_noiseAmplitude; @@ -389,7 +390,6 @@ public: int m_speed; float m_restrike; int m_spriteTexture; - int m_iszSpriteName; int m_frameStart; float m_radius; diff --git a/dlls/effects.h b/dlls/effects.h index 68f0ea29..f4b6b5b2 100644 --- a/dlls/effects.h +++ b/dlls/effects.h @@ -321,7 +321,7 @@ public: static TYPEDESCRIPTION m_SaveData[]; CSprite *m_pSprite; - int m_iszSpriteName; + string_t m_iszSpriteName; Vector m_firePosition; }; #endif //EFFECTS_H diff --git a/dlls/extdll.h b/dlls/extdll.h index 45c42309..812ce40f 100644 --- a/dlls/extdll.h +++ b/dlls/extdll.h @@ -69,7 +69,7 @@ typedef int BOOL; // Header file containing definition of globalvars_t and entvars_t typedef unsigned int func_t; -typedef unsigned int string_t; // from engine's pr_comp.h; +typedef int string_t; // from engine's pr_comp.h; typedef float vec_t; // needed before including progdefs.h // Vector class diff --git a/dlls/func_break.h b/dlls/func_break.h index ab5dda41..b4ff1fc1 100644 --- a/dlls/func_break.h +++ b/dlls/func_break.h @@ -82,9 +82,9 @@ public: Materials m_Material; Explosions m_Explosion; + string_t m_iszGibModel; + string_t m_iszSpawnObject; int m_idShard; float m_angle; - int m_iszGibModel; - int m_iszSpawnObject; }; #endif // FUNC_BREAK_H diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp index 6eebc675..013948eb 100644 --- a/dlls/func_tank.cpp +++ b/dlls/func_tank.cpp @@ -97,6 +97,9 @@ public: protected: CBasePlayer* m_pController; + string_t m_iszSpriteSmoke; + string_t m_iszSpriteFlash; + string_t m_iszMaster; // Master entity (game_team_master or multisource) float m_flNextAttack; Vector m_vecControllerUsePos; @@ -120,14 +123,11 @@ protected: Vector m_barrelPos; // Length of the freakin barrel float m_spriteScale; // Scale of any sprites we shoot - int m_iszSpriteSmoke; - int m_iszSpriteFlash; TANKBULLET m_bulletType; // Bullet type int m_iBulletDamage; // 0 means use Bullet type's default damage Vector m_sightOrigin; // Last sight of target int m_spread; // firing spread - int m_iszMaster; // Master entity (game_team_master or multisource) }; TYPEDESCRIPTION CFuncTank::m_SaveData[] = diff --git a/dlls/lights.cpp b/dlls/lights.cpp index e6b03125..8a4f8de8 100644 --- a/dlls/lights.cpp +++ b/dlls/lights.cpp @@ -37,8 +37,8 @@ public: static TYPEDESCRIPTION m_SaveData[]; private: + string_t m_iszPattern; int m_iStyle; - int m_iszPattern; }; LINK_ENTITY_TO_CLASS( light, CLight ) diff --git a/dlls/mortar.cpp b/dlls/mortar.cpp index 33a7d2da..7faf3e56 100644 --- a/dlls/mortar.cpp +++ b/dlls/mortar.cpp @@ -45,8 +45,8 @@ public: void EXPORT FieldUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - int m_iszXController; - int m_iszYController; + string_t m_iszXController; + string_t m_iszYController; float m_flSpread; float m_flDelay; int m_iCount; diff --git a/dlls/plats.cpp b/dlls/plats.cpp index c1220f3c..b3e1c683 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -1619,9 +1619,9 @@ public: CFuncTrackTrain *m_train; - int m_trackTopName; - int m_trackBottomName; - int m_trainName; + string_t m_trackTopName; + string_t m_trackBottomName; + string_t m_trainName; TRAIN_CODE m_code; int m_targetState; int m_use; diff --git a/dlls/scripted.cpp b/dlls/scripted.cpp index 678502f6..92b9aa6a 100644 --- a/dlls/scripted.cpp +++ b/dlls/scripted.cpp @@ -907,15 +907,15 @@ public: BOOL StartSentence( CBaseMonster *pTarget ); private: - int m_iszSentence; // string index for idle animation - int m_iszEntity; // entity that is wanted for this sentence + string_t m_iszSentence; // string index for idle animation + string_t m_iszEntity; // entity that is wanted for this sentence + string_t m_iszListener; // name of entity to look at while talking float m_flRadius; // range to search float m_flDuration; // How long the sentence lasts float m_flRepeat; // repeat rate float m_flAttenuation; float m_flVolume; BOOL m_active; - int m_iszListener; // name of entity to look at while talking }; #define SF_SENTENCE_ONCE 0x0001 diff --git a/dlls/scripted.h b/dlls/scripted.h index 25348114..6cf8cfa1 100644 --- a/dlls/scripted.h +++ b/dlls/scripted.h @@ -77,9 +77,9 @@ public: void AllowInterrupt( BOOL fAllow ); int IgnoreConditions( void ); - int m_iszIdle; // string index for idle animation - int m_iszPlay; // string index for scripted animation - int m_iszEntity; // entity that is wanted for this script + string_t m_iszIdle; // string index for idle animation + string_t m_iszPlay; // string index for scripted animation + string_t m_iszEntity; // entity that is wanted for this script int m_fMoveTo; int m_iFinishSchedule; float m_flRadius; // range to search diff --git a/dlls/talkmonster.h b/dlls/talkmonster.h index 72222aae..084861bc 100644 --- a/dlls/talkmonster.h +++ b/dlls/talkmonster.h @@ -162,8 +162,8 @@ public: int m_voicePitch; // pitch of voice for this head const char *m_szGrp[TLK_CGROUPS]; // sentence group names float m_useTime; // Don't allow +USE until this time - int m_iszUse; // Custom +USE sentence group (follow) - int m_iszUnUse; // Custom +USE sentence group (stop following) + string_t m_iszUse; // Custom +USE sentence group (follow) + string_t m_iszUnUse; // Custom +USE sentence group (stop following) float m_flLastSaidSmelled;// last time we talked about something that stinks float m_flStopTalkTime;// when in the future that I'll be done saying this sentence. diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index 8171a195..7d7f255c 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -114,7 +114,7 @@ public: static TYPEDESCRIPTION m_SaveData[]; private: - int m_globalstate; + string_t m_globalstate; USE_TYPE triggerType; }; @@ -267,11 +267,11 @@ public: static TYPEDESCRIPTION m_SaveData[]; - int m_cTargets; // the total number of targets in this manager's fire list. + string_t m_iTargetName[MAX_MULTI_TARGETS];// list if indexes into global string array + float m_flTargetDelay[MAX_MULTI_TARGETS];// delay (in seconds) from time of manager fire to target fire + int m_cTargets; // the total number of targets in this manager's fire list. int m_index; // Current target float m_startTime;// Time we started firing - int m_iTargetName[MAX_MULTI_TARGETS];// list if indexes into global string array - float m_flTargetDelay[MAX_MULTI_TARGETS];// delay (in seconds) from time of manager fire to target fire private: inline BOOL IsClone( void ) { return ( pev->spawnflags & SF_MULTIMAN_CLONE ) ? TRUE : FALSE; } inline BOOL ShouldClone( void ) @@ -1321,9 +1321,9 @@ public: static TYPEDESCRIPTION m_SaveData[]; + string_t m_changeTarget; char m_szMapName[cchMapNameMost]; // trigger_changelevel only: next map char m_szLandmarkName[cchMapNameMost]; // trigger_changelevel only: landmark on next map - int m_changeTarget; float m_changeTargetDelay; }; @@ -2054,7 +2054,7 @@ public: static TYPEDESCRIPTION m_SaveData[]; private: - int m_iszNewTarget; + string_t m_iszNewTarget; }; LINK_ENTITY_TO_CLASS( trigger_changetarget, CTriggerChangeTarget ) @@ -2117,7 +2117,7 @@ public: EHANDLE m_hPlayer; EHANDLE m_hTarget; CBaseEntity *m_pentPath; - int m_sPath; + string_t m_sPath; float m_flWait; float m_flReturnTime; float m_flStopTime; diff --git a/dlls/util.cpp b/dlls/util.cpp index f382ac58..94c8c68c 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -1586,7 +1586,7 @@ void UTIL_StripToken( const char *pKey, char *pDest ) static int gSizes[FIELD_TYPECOUNT] = { sizeof(float), // FIELD_FLOAT - sizeof(int), // FIELD_STRING + sizeof(string_t), // FIELD_STRING sizeof(void*), // FIELD_ENTITY sizeof(void*), // FIELD_CLASSPTR sizeof(void*), // FIELD_EHANDLE @@ -1613,7 +1613,7 @@ static int gSizes[FIELD_TYPECOUNT] = static int gInputSizes[FIELD_TYPECOUNT] = { sizeof(float), // FIELD_FLOAT - sizeof(int), // FIELD_STRING + sizeof(string_t), // FIELD_STRING sizeof(int), // FIELD_ENTITY sizeof(int), // FIELD_CLASSPTR sizeof(int), // FIELD_EHANDLE @@ -1940,7 +1940,7 @@ void EntvarsKeyvalue( entvars_t *pev, KeyValueData *pkvd ) case FIELD_MODELNAME: case FIELD_SOUNDNAME: case FIELD_STRING: - ( *(int *)( (char *)pev + pField->fieldOffset ) ) = ALLOC_STRING( pkvd->szValue ); + ( *(string_t *)( (char *)pev + pField->fieldOffset ) ) = ALLOC_STRING( pkvd->szValue ); break; case FIELD_TIME: case FIELD_FLOAT: @@ -2014,7 +2014,7 @@ int CSave::WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFi case FIELD_MODELNAME: case FIELD_SOUNDNAME: case FIELD_STRING: - WriteString( pTest->fieldName, (int *)pOutputData, pTest->fieldSize ); + WriteString( pTest->fieldName, (string_t *)pOutputData, pTest->fieldSize ); break; case FIELD_CLASSPTR: case FIELD_EVARS: @@ -2197,14 +2197,14 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou } pInputData = pString; if( strlen( (char *)pInputData ) == 0 ) - *( (int *)pOutputData ) = 0; + *( (string_t *)pOutputData ) = 0; else { - int string; + string_t string; string = ALLOC_STRING( (char *)pInputData ); - *( (int *)pOutputData ) = string; + *( (string_t *)pOutputData ) = string; if( !FStringNull( string ) && m_precache ) { diff --git a/dlls/util.h b/dlls/util.h index 2ffe536e..ee7d116b 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -37,13 +37,13 @@ extern globalvars_t *gpGlobals; #define STRING(offset) (const char *)(gpGlobals->pStringBase + (int)offset) #if !defined XASH_64BIT || defined(CLIENT_DLL) -#define MAKE_STRING(str) ((size_t)str - (size_t)STRING(0)) +#define MAKE_STRING(str) ((int)str - (int)STRING(0)) #else static inline int MAKE_STRING(const char *szValue) { long long ptrdiff = szValue - STRING(0); if( ptrdiff > INT_MAX || ptrdiff < INT_MIN ) - return ALLOC_STRING(szValue); + return ALLOC_STRING( szValue ); else return (int)ptrdiff; } diff --git a/dlls/weapons.h b/dlls/weapons.h index 6c03105b..0cfa2031 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -446,7 +446,7 @@ public: CBasePlayerItem *m_rgpPlayerItems[MAX_ITEM_TYPES];// one slot for each - int m_rgiszAmmo[MAX_AMMO_SLOTS];// ammo names + string_t m_rgiszAmmo[MAX_AMMO_SLOTS];// ammo names int m_rgAmmo[MAX_AMMO_SLOTS];// ammo quantities int m_cAmmoTypes;// how many ammo types packed into this box (if packed by a level designer) From 28020503292fb16cf30b6ccd639f5e6cb9cd4b46 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 10 Dec 2017 21:05:13 +0500 Subject: [PATCH 131/144] Add missing break. --- dlls/hgrunt.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dlls/hgrunt.cpp b/dlls/hgrunt.cpp index 4cb85c2c..62c947f1 100644 --- a/dlls/hgrunt.cpp +++ b/dlls/hgrunt.cpp @@ -959,6 +959,7 @@ void CHGrunt::HandleAnimEvent( MonsterEvent_t *pEvent ) } } + break; default: CSquadMonster::HandleAnimEvent( pEvent ); break; From 83c0505ffe12da025c207fcca1f9bd67b5291097 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 10 Dec 2017 21:08:10 +0500 Subject: [PATCH 132/144] Add missing precache calls. --- dlls/effects.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dlls/effects.cpp b/dlls/effects.cpp index 5b8d650c..2e127b2d 100644 --- a/dlls/effects.cpp +++ b/dlls/effects.cpp @@ -2181,6 +2181,8 @@ public: void CItemSoda::Precache( void ) { + PRECACHE_MODEL( "models/can.mdl" ); + PRECACHE_SOUND( "weapons/g_bounce.wav" ); } LINK_ENTITY_TO_CLASS( item_sodacan, CItemSoda ) From 41c9b072e5f871f6d4ce778a037cfa6ae38abcdb Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 10 Dec 2017 22:19:34 +0500 Subject: [PATCH 133/144] Add missing #include guards. --- cl_dll/ammohistory.h | 3 +++ cl_dll/health.h | 3 +++ cl_dll/hud_spectator.h | 4 ++-- cl_dll/parsemsg.h | 3 +++ dlls/gamerules.h | 4 +++- dlls/plane.h | 6 +++--- dlls/skill.h | 3 +++ dlls/spectator.h | 3 +++ dlls/squad.h | 4 +++- dlls/squadmonster.h | 3 +++ dlls/util.h | 3 +++ 11 files changed, 32 insertions(+), 7 deletions(-) diff --git a/cl_dll/ammohistory.h b/cl_dll/ammohistory.h index f1063ae1..032d3ee3 100644 --- a/cl_dll/ammohistory.h +++ b/cl_dll/ammohistory.h @@ -15,6 +15,8 @@ // // ammohistory.h // +#ifndef AMMOHISTORY_H +#define AMMOHISTORY_H // this is the max number of items in each bucket #define MAX_WEAPON_POSITIONS MAX_WEAPON_SLOTS @@ -137,3 +139,4 @@ public: }; extern HistoryResource gHR; +#endif // AMMOHISTORY_H diff --git a/cl_dll/health.h b/cl_dll/health.h index 132b9cb4..1007c17c 100644 --- a/cl_dll/health.h +++ b/cl_dll/health.h @@ -12,6 +12,8 @@ * without written permission from Valve LLC. * ****/ +#ifndef HEALTH_H +#define HEALTH_H #define DMG_IMAGE_LIFE 2 // seconds that image is up @@ -122,3 +124,4 @@ private: void CalcDamageDirection( vec3_t vecFrom ); void UpdateTiles( float fTime, long bits ); }; +#endif // HEALTH_H diff --git a/cl_dll/hud_spectator.h b/cl_dll/hud_spectator.h index 58026668..9cfc5519 100644 --- a/cl_dll/hud_spectator.h +++ b/cl_dll/hud_spectator.h @@ -5,8 +5,8 @@ // $NoKeywords: $ //============================================================================= -#ifndef SPECTATOR_H -#define SPECTATOR_H +#ifndef HUD_SPECTATOR_H +#define HUD_SPECTATOR_H #pragma once #include "cl_entity.h" diff --git a/cl_dll/parsemsg.h b/cl_dll/parsemsg.h index 0e6bd2a3..6d552413 100644 --- a/cl_dll/parsemsg.h +++ b/cl_dll/parsemsg.h @@ -15,6 +15,8 @@ // // parsemsg.h // +#ifndef PARSEMSG_H +#define PARSEMSG_H #define ASSERT( x ) @@ -30,6 +32,7 @@ float READ_COORD( void ); float READ_ANGLE( void ); float READ_HIRESANGLE( void ); +#endif // PARSEMSG_H diff --git a/dlls/gamerules.h b/dlls/gamerules.h index 6ad470d0..71036151 100644 --- a/dlls/gamerules.h +++ b/dlls/gamerules.h @@ -15,7 +15,8 @@ //========================================================= // GameRules //========================================================= - +#ifndef GAMERULES_H +#define GAMERULES_H //#include "weapons.h" //#include "items.h" class CBasePlayerItem; @@ -361,3 +362,4 @@ protected: }; extern DLL_GLOBAL CGameRules *g_pGameRules; +#endif // GAMERULES_H diff --git a/dlls/plane.h b/dlls/plane.h index 35a17611..912062f6 100644 --- a/dlls/plane.h +++ b/dlls/plane.h @@ -12,12 +12,12 @@ * without written permission from Valve LLC. * ****/ -#ifndef PLANE_H -#define PLANE_H - //========================================================= // Plane //========================================================= +#ifndef PLANE_H +#define PLANE_H + class CPlane { public: diff --git a/dlls/skill.h b/dlls/skill.h index 12b784e3..aa338362 100644 --- a/dlls/skill.h +++ b/dlls/skill.h @@ -15,6 +15,8 @@ //========================================================= // skill.h - skill level concerns //========================================================= +#ifndef SKILL_H +#define SKILL_H struct skilldata_t { @@ -143,3 +145,4 @@ extern DLL_GLOBAL int g_iSkillLevel; #define SKILL_EASY 1 #define SKILL_MEDIUM 2 #define SKILL_HARD 3 +#endif // SKILL_H diff --git a/dlls/spectator.h b/dlls/spectator.h index 90f8678f..00567fc6 100644 --- a/dlls/spectator.h +++ b/dlls/spectator.h @@ -13,6 +13,8 @@ * ****/ // Spectator.h +#ifndef SPECTATOR_H +#define SPECTATOR_H class CBaseSpectator : public CBaseEntity { @@ -25,3 +27,4 @@ public: private: void SpectatorImpulseCommand( void ); }; +#endif // SPECTATOR_H diff --git a/dlls/squad.h b/dlls/squad.h index bb2784bb..c29a7199 100644 --- a/dlls/squad.h +++ b/dlls/squad.h @@ -4,10 +4,11 @@ // // $NoKeywords: $ //============================================================================= - //========================================================= // squad.h //========================================================= +#ifndef SQUAD_H +#define SQUAD_H // these are special group roles that are assigned to members when the group is formed. // the reason these are explicitly assigned and tasks like throwing grenades to flush out @@ -19,3 +20,4 @@ #define bits_SQUAD_FLANK_RIGHT ( 1 << 1 ) #define bits_SQUAD_ADVANCE ( 1 << 2 ) #define bits_SQUAD_FLUSH_ATTACK ( 1 << 3 ) +#endif // SQUAD_H diff --git a/dlls/squadmonster.h b/dlls/squadmonster.h index 707910c2..132d4177 100644 --- a/dlls/squadmonster.h +++ b/dlls/squadmonster.h @@ -16,6 +16,8 @@ // CSquadMonster - all the extra data for monsters that // form squads. //========================================================= +#ifndef SQUADMONSTER_H +#define SQUADMONSTER_H #define SF_SQUADMONSTER_LEADER 32 @@ -116,3 +118,4 @@ public: MONSTERSTATE GetIdealState( void ); Schedule_t *GetScheduleOfType( int iType ); }; +#endif // SQUADMONSTER_H diff --git a/dlls/util.h b/dlls/util.h index ee7d116b..8f56cd76 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -12,6 +12,8 @@ * without written permission from Valve LLC. * ****/ +#ifndef UTIL_H +#define UTIL_H // // Misc utility code // @@ -575,3 +577,4 @@ int UTIL_SharedRandomLong( unsigned int seed, int low, int high ); float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ); float UTIL_WeaponTimeBase( void ); +#endif // UTIL_H From f27d1028acf7ae1cf7494002e880d235177f2c52 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 11 Dec 2017 01:40:41 +0500 Subject: [PATCH 134/144] Do not reorganize variables in classes. Add missing #pragma once directives and more #include guards. --- cl_dll/GameStudioModelRenderer.h | 6 ++---- cl_dll/GameStudioModelRenderer_Sample.h | 6 ++---- cl_dll/StudioModelRenderer.h | 4 +--- cl_dll/ammo.h | 2 +- cl_dll/ammohistory.h | 1 + cl_dll/camera.h | 2 +- cl_dll/cl_dll.h | 1 + cl_dll/com_weapons.h | 4 +--- cl_dll/demo.h | 2 +- cl_dll/ev_hldm.h | 1 + cl_dll/eventscripts.h | 1 + cl_dll/health.h | 1 + cl_dll/hud.h | 1 + cl_dll/hud_iface.h | 2 +- cl_dll/hud_spectator.h | 2 +- cl_dll/in_defs.h | 2 +- cl_dll/input_mouse.h | 1 + cl_dll/kbutton.h | 3 +-- cl_dll/overview.h | 2 +- cl_dll/parsemsg.h | 1 + cl_dll/studio_util.h | 4 +--- cl_dll/util_vector.h | 4 ++++ common/beamdef.h | 4 ++-- common/bspfile.h | 2 +- common/cl_entity.h | 4 ++-- common/com_model.h | 4 ++-- common/con_nprint.h | 3 ++- common/const.h | 1 + common/cvardef.h | 1 + common/demo_api.h | 4 ++-- common/dlight.h | 4 ++-- common/entity_state.h | 3 ++- common/entity_types.h | 4 ++-- common/event_api.h | 4 ++-- common/event_args.h | 3 ++- common/event_flags.h | 4 ++-- common/gameinfo.h | 4 ++-- common/hltv.h | 4 ++-- common/ivoicetweak.h | 4 ++-- common/lightstyle.h | 4 ++-- common/mathlib.h | 5 ++++- common/net_api.h | 4 ++-- common/netadr.h | 4 ++-- common/particledef.h | 4 ++-- common/pmtrace.h | 4 ++-- common/qfont.h | 4 ++-- common/r_efx.h | 4 ++-- common/r_studioint.h | 5 ++--- common/ref_params.h | 4 ++-- common/render_api.h | 4 ++-- common/screenfade.h | 4 ++-- common/studio_event.h | 4 ++-- common/triangleapi.h | 2 +- common/usercmd.h | 4 ++-- common/wadfile.h | 4 ++-- common/weaponinfo.h | 4 ++-- common/wrect.h | 4 ++-- dlls/activity.h | 2 +- dlls/activitymap.h | 5 ++++- dlls/animation.h | 1 + dlls/basemonster.h | 2 +- dlls/cbase.h | 1 + dlls/cdll_dll.h | 2 +- dlls/client.h | 1 + dlls/decals.h | 1 + dlls/doors.h | 1 + dlls/effects.cpp | 4 ++-- dlls/effects.h | 1 + dlls/explode.h | 3 ++- dlls/exportdef.h | 1 + dlls/extdll.h | 1 + dlls/flyingmonster.h | 2 +- dlls/func_break.h | 5 +++-- dlls/func_tank.cpp | 6 +++--- dlls/game.h | 2 +- dlls/gamerules.h | 1 + dlls/hornet.h | 5 ++++- dlls/items.h | 1 + dlls/lights.cpp | 2 +- dlls/monsters.h | 1 + dlls/nodes.h | 1 + dlls/physcallback.h | 2 +- dlls/player.h | 1 + dlls/saverestore.h | 1 + dlls/schedule.h | 2 +- dlls/scripted.cpp | 2 +- dlls/scripted.h | 1 + dlls/scriptevent.h | 3 ++- dlls/skill.h | 3 ++- dlls/soundent.h | 4 ++++ dlls/spectator.h | 1 + dlls/squad.h | 1 + dlls/squadmonster.h | 1 + dlls/talkmonster.h | 1 + dlls/teamplay_gamerules.h | 4 ++++ dlls/trains.h | 1 + dlls/triggers.cpp | 6 +++--- dlls/util.h | 1 + dlls/vector.h | 1 + dlls/weapons.h | 1 + engine/cdll_exp.h | 3 ++- engine/cdll_int.h | 2 +- engine/custom.h | 3 +-- engine/customentity.h | 2 +- engine/edict.h | 4 +--- engine/eiface.h | 2 +- engine/keydefs.h | 4 ++-- engine/menu_int.h | 2 +- engine/physint.h | 4 ++-- engine/progdefs.h | 3 +-- engine/shake.h | 2 +- engine/sprite.h | 4 ++-- engine/studio.h | 2 +- pm_shared/pm_debug.h | 3 +-- pm_shared/pm_defs.h | 3 +-- pm_shared/pm_info.h | 3 +-- pm_shared/pm_materials.h | 1 + pm_shared/pm_movevars.h | 1 + pm_shared/pm_shared.h | 4 +--- 119 files changed, 183 insertions(+), 140 deletions(-) diff --git a/cl_dll/GameStudioModelRenderer.h b/cl_dll/GameStudioModelRenderer.h index 7d06f70f..881dd144 100644 --- a/cl_dll/GameStudioModelRenderer.h +++ b/cl_dll/GameStudioModelRenderer.h @@ -5,11 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( GAMESTUDIOMODELRENDERER_H ) #define GAMESTUDIOMODELRENDERER_H -#if defined( _WIN32 ) -#pragma once -#endif /* ==================== @@ -23,4 +21,4 @@ public: CGameStudioModelRenderer( void ); }; -#endif // GAMESTUDIOMODELRENDERER_H \ No newline at end of file +#endif // GAMESTUDIOMODELRENDERER_H diff --git a/cl_dll/GameStudioModelRenderer_Sample.h b/cl_dll/GameStudioModelRenderer_Sample.h index c924ba3e..9c09374b 100644 --- a/cl_dll/GameStudioModelRenderer_Sample.h +++ b/cl_dll/GameStudioModelRenderer_Sample.h @@ -5,11 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( GAMESTUDIOMODELRENDERER_H ) #define GAMESTUDIOMODELRENDERER_H -#if defined( _WIN32 ) -#pragma once -#endif /* ==================== @@ -52,4 +50,4 @@ private: bool m_bLocal; }; -#endif // GAMESTUDIOMODELRENDERER_H \ No newline at end of file +#endif // GAMESTUDIOMODELRENDERER_H diff --git a/cl_dll/StudioModelRenderer.h b/cl_dll/StudioModelRenderer.h index 0a56b731..cbfd0d3b 100644 --- a/cl_dll/StudioModelRenderer.h +++ b/cl_dll/StudioModelRenderer.h @@ -5,11 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined ( STUDIOMODELRENDERER_H ) #define STUDIOMODELRENDERER_H -#if defined( _WIN32 ) -#pragma once -#endif /* ==================== diff --git a/cl_dll/ammo.h b/cl_dll/ammo.h index 9134681c..57c08805 100644 --- a/cl_dll/ammo.h +++ b/cl_dll/ammo.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef __AMMO_H__ #define __AMMO_H__ diff --git a/cl_dll/ammohistory.h b/cl_dll/ammohistory.h index 032d3ee3..44edc916 100644 --- a/cl_dll/ammohistory.h +++ b/cl_dll/ammohistory.h @@ -15,6 +15,7 @@ // // ammohistory.h // +#pragma once #ifndef AMMOHISTORY_H #define AMMOHISTORY_H diff --git a/cl_dll/camera.h b/cl_dll/camera.h index 448b22ca..69a00216 100644 --- a/cl_dll/camera.h +++ b/cl_dll/camera.h @@ -7,7 +7,7 @@ // Camera.h -- defines and such for a 3rd person camera // NOTE: must include quakedef.h first - +#pragma once #ifndef _CAMERA_H_ #define _CAMERA_H_ diff --git a/cl_dll/cl_dll.h b/cl_dll/cl_dll.h index 0acd6860..6e1c4e69 100644 --- a/cl_dll/cl_dll.h +++ b/cl_dll/cl_dll.h @@ -25,6 +25,7 @@ // - Drawing the HUD graphics every frame // - Handling the custum HUD-update packets // +#pragma once #ifndef CL_DLL_H #define CL_DLL_H typedef unsigned char byte; diff --git a/cl_dll/com_weapons.h b/cl_dll/com_weapons.h index d252c196..efe06ad6 100644 --- a/cl_dll/com_weapons.h +++ b/cl_dll/com_weapons.h @@ -7,11 +7,9 @@ // com_weapons.h // Shared weapons common function prototypes +#pragma once #if !defined( COM_WEAPONSH ) #define COM_WEAPONSH -#ifdef _WIN32 -#pragma once -#endif #include "hud_iface.h" diff --git a/cl_dll/demo.h b/cl_dll/demo.h index a0a1b30e..b7dbaff0 100644 --- a/cl_dll/demo.h +++ b/cl_dll/demo.h @@ -5,9 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( DEMOH ) #define DEMOH -#pragma once // Types of demo messages we can write/parse enum diff --git a/cl_dll/ev_hldm.h b/cl_dll/ev_hldm.h index bff43b1e..88b221df 100644 --- a/cl_dll/ev_hldm.h +++ b/cl_dll/ev_hldm.h @@ -5,6 +5,7 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined ( EV_HLDMH ) #define EV_HLDMH diff --git a/cl_dll/eventscripts.h b/cl_dll/eventscripts.h index bb835474..c11ee338 100644 --- a/cl_dll/eventscripts.h +++ b/cl_dll/eventscripts.h @@ -6,6 +6,7 @@ //============================================================================= // eventscripts.h +#pragma once #if !defined ( EVENTSCRIPTSH ) #define EVENTSCRIPTSH diff --git a/cl_dll/health.h b/cl_dll/health.h index 1007c17c..62d7e0bc 100644 --- a/cl_dll/health.h +++ b/cl_dll/health.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef HEALTH_H #define HEALTH_H diff --git a/cl_dll/hud.h b/cl_dll/hud.h index 1970753d..decfa917 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -19,6 +19,7 @@ // // CHud handles the message, calculation, and drawing the HUD // +#pragma once #ifndef HUD_H #define HUD_H #define RGB_YELLOWISH 0x00FFA000 //255,160,0 diff --git a/cl_dll/hud_iface.h b/cl_dll/hud_iface.h index a7a05e7e..7993bd9d 100644 --- a/cl_dll/hud_iface.h +++ b/cl_dll/hud_iface.h @@ -5,9 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( HUD_IFACEH ) #define HUD_IFACEH -#pragma once #include "exportdef.h" diff --git a/cl_dll/hud_spectator.h b/cl_dll/hud_spectator.h index 9cfc5519..7a9ec9d3 100644 --- a/cl_dll/hud_spectator.h +++ b/cl_dll/hud_spectator.h @@ -5,9 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #ifndef HUD_SPECTATOR_H #define HUD_SPECTATOR_H -#pragma once #include "cl_entity.h" diff --git a/cl_dll/in_defs.h b/cl_dll/in_defs.h index 037c7cc6..d5c352fa 100644 --- a/cl_dll/in_defs.h +++ b/cl_dll/in_defs.h @@ -5,9 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( IN_DEFSH ) #define IN_DEFSH -#pragma once // up / down #define PITCH 0 diff --git a/cl_dll/input_mouse.h b/cl_dll/input_mouse.h index 6ddf54db..cf0102c8 100644 --- a/cl_dll/input_mouse.h +++ b/cl_dll/input_mouse.h @@ -1,3 +1,4 @@ +#pragma once #ifndef INPUT_MOUSE_H #define INPUT_MOUSE_H #include "cl_dll.h" diff --git a/cl_dll/kbutton.h b/cl_dll/kbutton.h index 29accdf5..54f1ea93 100644 --- a/cl_dll/kbutton.h +++ b/cl_dll/kbutton.h @@ -4,10 +4,9 @@ // // $NoKeywords: $ //============================================================================= - +#pragma once #if !defined( KBUTTONH ) #define KBUTTONH -#pragma once typedef struct kbutton_s { diff --git a/cl_dll/overview.h b/cl_dll/overview.h index 6748760b..59535fb4 100644 --- a/cl_dll/overview.h +++ b/cl_dll/overview.h @@ -5,9 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #ifndef OVERVIEW_H #define OVERVIEW_H -#pragma once //----------------------------------------------------------------------------- // Purpose: Handles the drawing of the top-down map and all the things on it diff --git a/cl_dll/parsemsg.h b/cl_dll/parsemsg.h index 6d552413..05efefc3 100644 --- a/cl_dll/parsemsg.h +++ b/cl_dll/parsemsg.h @@ -15,6 +15,7 @@ // // parsemsg.h // +#pragma once #ifndef PARSEMSG_H #define PARSEMSG_H diff --git a/cl_dll/studio_util.h b/cl_dll/studio_util.h index 963dcda7..7af94672 100644 --- a/cl_dll/studio_util.h +++ b/cl_dll/studio_util.h @@ -5,11 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( STUDIO_UTIL_H ) #define STUDIO_UTIL_H -#if defined( WIN32 ) -#pragma once -#endif #ifndef M_PI #define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h diff --git a/cl_dll/util_vector.h b/cl_dll/util_vector.h index 8b596ac1..477d97be 100644 --- a/cl_dll/util_vector.h +++ b/cl_dll/util_vector.h @@ -15,6 +15,9 @@ // Vector.h // A subset of the extdll.h in the project HL Entity DLL // +#pragma once +#ifndef UTIL_VECTOR_H +#define UTIL_VECTOR_H // Misc C-runtime library headers #include "stdio.h" @@ -124,3 +127,4 @@ inline float DotProduct( const Vector& a, const Vector& b) { return( a.x * b.x + inline Vector CrossProduct(const Vector& a, const Vector& b) { return Vector( a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x ); } #define vec3_t Vector +#endif // UTIL_VECTOR_H diff --git a/common/beamdef.h b/common/beamdef.h index 3b8c553a..f254428c 100644 --- a/common/beamdef.h +++ b/common/beamdef.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef BEAMDEF_H #define BEAMDEF_H @@ -57,4 +57,4 @@ struct beam_s struct particle_s *particles; }; -#endif//BEAMDEF_H \ No newline at end of file +#endif//BEAMDEF_H diff --git a/common/bspfile.h b/common/bspfile.h index 809e2fd0..079e1b21 100644 --- a/common/bspfile.h +++ b/common/bspfile.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef BSPFILE_H #define BSPFILE_H diff --git a/common/cl_entity.h b/common/cl_entity.h index 02f84e35..c003ce30 100644 --- a/common/cl_entity.h +++ b/common/cl_entity.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef CL_ENTITY_H #define CL_ENTITY_H @@ -102,4 +102,4 @@ struct cl_entity_s colorVec cvFloorColor; }; -#endif//CL_ENTITY_H \ No newline at end of file +#endif//CL_ENTITY_H diff --git a/common/com_model.h b/common/com_model.h index 709f23d9..abc8e8e6 100644 --- a/common/com_model.h +++ b/common/com_model.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef COM_MODEL_H #define COM_MODEL_H @@ -410,4 +410,4 @@ typedef struct mspriteframedesc_t frames[1]; } msprite_t; -#endif//COM_MODEL_H \ No newline at end of file +#endif//COM_MODEL_H diff --git a/common/con_nprint.h b/common/con_nprint.h index 5d87c760..615a1850 100644 --- a/common/con_nprint.h +++ b/common/con_nprint.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef CON_NPRINT_H #define CON_NPRINT_H @@ -22,4 +23,4 @@ typedef struct con_nprint_s float color[3]; // RGB colors ( 0.0 -> 1.0 scale ) } con_nprint_t; -#endif//CON_NPRINT_H \ No newline at end of file +#endif//CON_NPRINT_H diff --git a/common/const.h b/common/const.h index 3d738675..fa0f33e6 100644 --- a/common/const.h +++ b/common/const.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef CONST_H #define CONST_H // diff --git a/common/cvardef.h b/common/cvardef.h index e8a24581..f461c329 100644 --- a/common/cvardef.h +++ b/common/cvardef.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef CVARDEF_H #define CVARDEF_H diff --git a/common/demo_api.h b/common/demo_api.h index fa89bbef..1a678b60 100644 --- a/common/demo_api.h +++ b/common/demo_api.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef DEMO_API_H #define DEMO_API_H @@ -24,4 +24,4 @@ typedef struct demo_api_s void (*WriteBuffer)( int size, unsigned char *buffer ); } demo_api_t; -#endif//DEMO_API_H \ No newline at end of file +#endif//DEMO_API_H diff --git a/common/dlight.h b/common/dlight.h index b139d582..ecb01445 100644 --- a/common/dlight.h +++ b/common/dlight.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef DLIGHT_H #define DLIGHT_H @@ -28,4 +28,4 @@ typedef struct dlight_s qboolean dark; // subtracts light instead of adding } dlight_t; -#endif//DLIGHT_H \ No newline at end of file +#endif//DLIGHT_H diff --git a/common/entity_state.h b/common/entity_state.h index ef5448f1..2ffd70dc 100644 --- a/common/entity_state.h +++ b/common/entity_state.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef ENTITY_STATE_H #define ENTITY_STATE_H @@ -183,4 +184,4 @@ typedef struct local_state_s weapon_data_t weapondata[64]; } local_state_t; -#endif//ENTITY_STATE_H \ No newline at end of file +#endif//ENTITY_STATE_H diff --git a/common/entity_types.h b/common/entity_types.h index 25a8fce9..f5754fea 100644 --- a/common/entity_types.h +++ b/common/entity_types.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef ENTITY_TYPES_H #define ENTITY_TYPES_H @@ -22,4 +22,4 @@ #define ET_BEAM 3 #define ET_FRAGMENTED 4 // BMODEL or SPRITE that was split across BSP nodes -#endif//ENTITY_TYPES_H \ No newline at end of file +#endif//ENTITY_TYPES_H diff --git a/common/event_api.h b/common/event_api.h index a7ff71b2..86c5fbe9 100644 --- a/common/event_api.h +++ b/common/event_api.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef EVENT_API_H #define EVENT_API_H @@ -51,4 +51,4 @@ typedef struct event_api_s struct msurface_s *( *EV_TraceSurface )( int ground, float *vstart, float *vend ); } event_api_t; -#endif//EVENT_API_H \ No newline at end of file +#endif//EVENT_API_H diff --git a/common/event_args.h b/common/event_args.h index d85906cc..4cf63741 100644 --- a/common/event_args.h +++ b/common/event_args.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef EVENT_ARGS_H #define EVENT_ARGS_H @@ -44,4 +45,4 @@ typedef struct event_args_s int bparam2; } event_args_t; -#endif//EVENT_ARGS_H \ No newline at end of file +#endif//EVENT_ARGS_H diff --git a/common/event_flags.h b/common/event_flags.h index 3c1d8fb3..a2d5f3b7 100644 --- a/common/event_flags.h +++ b/common/event_flags.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef EVENT_FLAGS_H #define EVENT_FLAGS_H @@ -42,4 +42,4 @@ // Only issue event client side ( from shared code ) #define FEV_CLIENT (1<<6) -#endif//EVENT_FLAGS_H \ No newline at end of file +#endif//EVENT_FLAGS_H diff --git a/common/gameinfo.h b/common/gameinfo.h index 511b3718..ab5f649c 100644 --- a/common/gameinfo.h +++ b/common/gameinfo.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef GAMEINFO_H #define GAMEINFO_H @@ -46,4 +46,4 @@ typedef struct int gamemode; } GAMEINFO; -#endif//GAMEINFO_H \ No newline at end of file +#endif//GAMEINFO_H diff --git a/common/hltv.h b/common/hltv.h index 79251910..e64dd30b 100644 --- a/common/hltv.h +++ b/common/hltv.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef HLTV_H #define HLTV_H @@ -56,4 +56,4 @@ #define MAX_DIRECTOR_CMD_PARAMETERS 4 #define MAX_DIRECTOR_CMD_STRING 128 -#endif//HLTV_H \ No newline at end of file +#endif//HLTV_H diff --git a/common/ivoicetweak.h b/common/ivoicetweak.h index 541a63fa..96879beb 100644 --- a/common/ivoicetweak.h +++ b/common/ivoicetweak.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef IVOICETWEAK_H #define IVOICETWEAK_H @@ -37,4 +37,4 @@ typedef struct IVoiceTweak_s int (*GetSpeakingVolume)( void ); } IVoiceTweak; -#endif//IVOICETWEAK_H \ No newline at end of file +#endif//IVOICETWEAK_H diff --git a/common/lightstyle.h b/common/lightstyle.h index 8b42edac..a12702f4 100644 --- a/common/lightstyle.h +++ b/common/lightstyle.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef LIGHTSTYLE_H #define LIGHTSTYLE_H @@ -26,4 +26,4 @@ typedef struct float time; // local time is gurantee what new style begins from the start, not mid or end of the sequence } lightstyle_t; -#endif//LIGHTSTYLE_H \ No newline at end of file +#endif//LIGHTSTYLE_H diff --git a/common/mathlib.h b/common/mathlib.h index 12fb972f..6bcf76eb 100644 --- a/common/mathlib.h +++ b/common/mathlib.h @@ -13,7 +13,9 @@ * ****/ // mathlib.h - +#pragma once +#ifndef MATHLIB_H +#define MATHLIB_H #include typedef float vec_t; @@ -98,3 +100,4 @@ float anglemod(float a); ) \ : \ BoxOnPlaneSide( (emins), (emaxs), (p))) +#endif // MATHLIB_H diff --git a/common/net_api.h b/common/net_api.h index 00831394..da18fc30 100644 --- a/common/net_api.h +++ b/common/net_api.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef NET_API_H #define NET_API_H @@ -94,4 +94,4 @@ typedef struct net_api_s void (*SetValueForKey)( char *s, const char *key, const char *value, int maxsize ); } net_api_t; -#endif//NET_APIH \ No newline at end of file +#endif // NET_APIH diff --git a/common/netadr.h b/common/netadr.h index dfeea8b0..0d70a22b 100644 --- a/common/netadr.h +++ b/common/netadr.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef NETADR_H #define NETADR_H @@ -34,4 +34,4 @@ typedef struct netadr_s unsigned short port; } netadr_t; -#endif//NETADR_H \ No newline at end of file +#endif//NETADR_H diff --git a/common/particledef.h b/common/particledef.h index 3f2ead66..15c95feb 100644 --- a/common/particledef.h +++ b/common/particledef.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef PARTICLEDEF_H #define PARTICLEDEF_H @@ -51,4 +51,4 @@ typedef struct particle_s unsigned char context; } particle_t; -#endif//PARTICLEDEF_H \ No newline at end of file +#endif//PARTICLEDEF_H diff --git a/common/pmtrace.h b/common/pmtrace.h index 6394de56..d5dd1453 100644 --- a/common/pmtrace.h +++ b/common/pmtrace.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef PM_TRACE_H #define PM_TRACE_H @@ -38,4 +38,4 @@ struct pmtrace_s int hitgroup; }; -#endif//PM_TRACE_H \ No newline at end of file +#endif//PM_TRACE_H diff --git a/common/qfont.h b/common/qfont.h index 06408572..beb36ff9 100644 --- a/common/qfont.h +++ b/common/qfont.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef QFONT_H #define QFONT_H @@ -35,4 +35,4 @@ typedef struct qfont_s byte data[4]; } qfont_t; -#endif//QFONT_H \ No newline at end of file +#endif//QFONT_H diff --git a/common/r_efx.h b/common/r_efx.h index fc27bef7..1a55aa0b 100644 --- a/common/r_efx.h +++ b/common/r_efx.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef R_EFX_H #define R_EFX_H @@ -192,4 +192,4 @@ struct efx_api_s void (*R_FireCustomDecal)( int textureIndex, int entity, int modelIndex, float *position, int flags, float scale ); }; -#endif//R_EFX_H \ No newline at end of file +#endif//R_EFX_H diff --git a/common/r_studioint.h b/common/r_studioint.h index 00384a16..b17e826f 100644 --- a/common/r_studioint.h +++ b/common/r_studioint.h @@ -12,8 +12,7 @@ * without written permission from Valve LLC. * ****/ - - +#pragma once #ifndef R_STUDIOINT_H #define R_STUDIOINT_H @@ -151,4 +150,4 @@ typedef struct sv_blending_interface_s const edict_t *pEdict ); } sv_blending_interface_t; -#endif//R_STUDIOINT_H \ No newline at end of file +#endif//R_STUDIOINT_H diff --git a/common/ref_params.h b/common/ref_params.h index 0458c4f4..61527eca 100644 --- a/common/ref_params.h +++ b/common/ref_params.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef REF_PARAMS_H #define REF_PARAMS_H @@ -87,4 +87,4 @@ typedef struct ref_overview_s float flZoom; } ref_overview_t; -#endif//REF_PARAMS_H \ No newline at end of file +#endif//REF_PARAMS_H diff --git a/common/render_api.h b/common/render_api.h index 7a9fcffe..03973f27 100644 --- a/common/render_api.h +++ b/common/render_api.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef RENDER_API_H #define RENDER_API_H @@ -258,4 +258,4 @@ typedef struct render_interface_s void (*Mod_ProcessUserData)( struct model_s *mod, qboolean create, const byte *buffer ); } render_interface_t; -#endif//RENDER_API_H \ No newline at end of file +#endif//RENDER_API_H diff --git a/common/screenfade.h b/common/screenfade.h index 730f729e..1611f914 100644 --- a/common/screenfade.h +++ b/common/screenfade.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef SCREENFADE_H #define SCREENFADE_H @@ -26,4 +26,4 @@ typedef struct screenfade_s int fadeFlags; // Fading flags } screenfade_t; -#endif//SCREENFADE_H \ No newline at end of file +#endif//SCREENFADE_H diff --git a/common/studio_event.h b/common/studio_event.h index 29ea1f90..cf21e82a 100644 --- a/common/studio_event.h +++ b/common/studio_event.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef STUDIO_EVENT_H #define STUDIO_EVENT_H @@ -24,4 +24,4 @@ typedef struct mstudioevent_s char options[64]; } mstudioevent_t; -#endif//STUDIO_EVENT_H \ No newline at end of file +#endif//STUDIO_EVENT_H diff --git a/common/triangleapi.h b/common/triangleapi.h index f2e9a309..49dc919f 100644 --- a/common/triangleapi.h +++ b/common/triangleapi.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef TRIANGLEAPI_H #define TRIANGLEAPI_H diff --git a/common/usercmd.h b/common/usercmd.h index 96e3c91b..538c60a6 100644 --- a/common/usercmd.h +++ b/common/usercmd.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef USERCMD_H #define USERCMD_H @@ -36,4 +36,4 @@ typedef struct usercmd_s vec3_t impact_position; } usercmd_t; -#endif//USERCMD_H \ No newline at end of file +#endif//USERCMD_H diff --git a/common/wadfile.h b/common/wadfile.h index 38a08032..84ffbb2d 100644 --- a/common/wadfile.h +++ b/common/wadfile.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef WADFILE_H #define WADFILE_H @@ -76,4 +76,4 @@ typedef struct mip_s unsigned int offsets[4]; // four mip maps stored } mip_t; -#endif//WADFILE_H \ No newline at end of file +#endif//WADFILE_H diff --git a/common/weaponinfo.h b/common/weaponinfo.h index ae78c645..b94857b6 100644 --- a/common/weaponinfo.h +++ b/common/weaponinfo.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef WEAPONINFO_H #define WEAPONINFO_H @@ -47,4 +47,4 @@ typedef struct weapon_data_s float fuser4; } weapon_data_t; -#endif//WEAPONINFO_H \ No newline at end of file +#endif//WEAPONINFO_H diff --git a/common/wrect.h b/common/wrect.h index 8dd2ba2f..51e84d88 100644 --- a/common/wrect.h +++ b/common/wrect.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef WRECT_H #define WRECT_H @@ -21,4 +21,4 @@ typedef struct wrect_s int left, right, top, bottom; } wrect_t; -#endif//WRECT_H \ No newline at end of file +#endif//WRECT_H diff --git a/dlls/activity.h b/dlls/activity.h index 5382d70d..90d85a08 100644 --- a/dlls/activity.h +++ b/dlls/activity.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef ACTIVITY_H #define ACTIVITY_H diff --git a/dlls/activitymap.h b/dlls/activitymap.h index 5f77c55a..b5f789f9 100644 --- a/dlls/activitymap.h +++ b/dlls/activitymap.h @@ -12,7 +12,9 @@ * without written permission from Valve LLC. * ****/ - +#pragma once +#ifndef ACTIVITYMAP_H +#define ACTIVITYMAP_H #define _A( a ) { a, #a } activity_map_t activity_map[] = @@ -95,3 +97,4 @@ _A( ACT_FLINCH_LEFTLEG ), _A( ACT_FLINCH_RIGHTLEG ), { 0, NULL } }; +#endif // ACTIVITYMAP_H diff --git a/dlls/animation.h b/dlls/animation.h index 384c1e98..6def910c 100644 --- a/dlls/animation.h +++ b/dlls/animation.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef ANIMATION_H #define ANIMATION_H diff --git a/dlls/basemonster.h b/dlls/basemonster.h index 0d22104f..2234aaf9 100644 --- a/dlls/basemonster.h +++ b/dlls/basemonster.h @@ -12,7 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ - +#pragma once #ifndef BASEMONSTER_H #define BASEMONSTER_H diff --git a/dlls/cbase.h b/dlls/cbase.h index 10f7a85f..4cf40abd 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef CBASE_H #define CBASE_H /* diff --git a/dlls/cdll_dll.h b/dlls/cdll_dll.h index c960a6ac..0aafafbd 100644 --- a/dlls/cdll_dll.h +++ b/dlls/cdll_dll.h @@ -16,7 +16,7 @@ // cdll_dll.h // this file is included by both the game-dll and the client-dll, - +#pragma once #ifndef CDLL_DLL_H #define CDLL_DLL_H diff --git a/dlls/client.h b/dlls/client.h index 6728151b..6feaac1a 100644 --- a/dlls/client.h +++ b/dlls/client.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef CLIENT_H #define CLIENT_H diff --git a/dlls/decals.h b/dlls/decals.h index 97f5f29f..5de54421 100644 --- a/dlls/decals.h +++ b/dlls/decals.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef DECALS_H #define DECALS_H diff --git a/dlls/doors.h b/dlls/doors.h index 7e89b497..fe2b5a85 100644 --- a/dlls/doors.h +++ b/dlls/doors.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef DOORS_H #define DOORS_H diff --git a/dlls/effects.cpp b/dlls/effects.cpp index 2e127b2d..bd9959f9 100644 --- a/dlls/effects.cpp +++ b/dlls/effects.cpp @@ -379,10 +379,9 @@ public: void BeamUpdateVars( void ); + int m_active; string_t m_iszStartEntity; string_t m_iszEndEntity; - string_t m_iszSpriteName; - int m_active; float m_life; int m_boltWidth; int m_noiseAmplitude; @@ -390,6 +389,7 @@ public: int m_speed; float m_restrike; int m_spriteTexture; + string_t m_iszSpriteName; int m_frameStart; float m_radius; diff --git a/dlls/effects.h b/dlls/effects.h index f4b6b5b2..5dd55209 100644 --- a/dlls/effects.h +++ b/dlls/effects.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef EFFECTS_H #define EFFECTS_H diff --git a/dlls/explode.h b/dlls/explode.h index e1c6cce0..001d93ca 100644 --- a/dlls/explode.h +++ b/dlls/explode.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef EXPLODE_H #define EXPLODE_H @@ -26,4 +27,4 @@ extern DLL_GLOBAL short g_sModelIndexFireball; extern DLL_GLOBAL short g_sModelIndexSmoke; extern void ExplosionCreate( const Vector ¢er, const Vector &angles, edict_t *pOwner, int magnitude, BOOL doDamage ); -#endif //EXPLODE_H +#endif // EXPLODE_H diff --git a/dlls/exportdef.h b/dlls/exportdef.h index 995613ff..363d8d12 100644 --- a/dlls/exportdef.h +++ b/dlls/exportdef.h @@ -1,3 +1,4 @@ +#pragma once #ifndef EXPORTDEF_H #define EXPORTDEF_H #if defined _WIN32 || defined __CYGWIN__ diff --git a/dlls/extdll.h b/dlls/extdll.h index 812ce40f..d6ea4888 100644 --- a/dlls/extdll.h +++ b/dlls/extdll.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef EXTDLL_H #define EXTDLL_H diff --git a/dlls/flyingmonster.h b/dlls/flyingmonster.h index 4dd87fb4..31ff4e33 100644 --- a/dlls/flyingmonster.h +++ b/dlls/flyingmonster.h @@ -13,7 +13,7 @@ * ****/ // Base class for flying monsters. This overrides the movement test & execution code from CBaseMonster - +#pragma once #ifndef FLYINGMONSTER_H #define FLYINGMONSTER_H diff --git a/dlls/func_break.h b/dlls/func_break.h index b4ff1fc1..89c9f54e 100644 --- a/dlls/func_break.h +++ b/dlls/func_break.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef FUNC_BREAK_H #define FUNC_BREAK_H @@ -82,9 +83,9 @@ public: Materials m_Material; Explosions m_Explosion; - string_t m_iszGibModel; - string_t m_iszSpawnObject; int m_idShard; float m_angle; + string_t m_iszGibModel; + string_t m_iszSpawnObject; }; #endif // FUNC_BREAK_H diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp index 013948eb..a3dba841 100644 --- a/dlls/func_tank.cpp +++ b/dlls/func_tank.cpp @@ -97,9 +97,6 @@ public: protected: CBasePlayer* m_pController; - string_t m_iszSpriteSmoke; - string_t m_iszSpriteFlash; - string_t m_iszMaster; // Master entity (game_team_master or multisource) float m_flNextAttack; Vector m_vecControllerUsePos; @@ -123,11 +120,14 @@ protected: Vector m_barrelPos; // Length of the freakin barrel float m_spriteScale; // Scale of any sprites we shoot + string_t m_iszSpriteSmoke; + string_t m_iszSpriteFlash; TANKBULLET m_bulletType; // Bullet type int m_iBulletDamage; // 0 means use Bullet type's default damage Vector m_sightOrigin; // Last sight of target int m_spread; // firing spread + string_t m_iszMaster; // Master entity (game_team_master or multisource) }; TYPEDESCRIPTION CFuncTank::m_SaveData[] = diff --git a/dlls/game.h b/dlls/game.h index a6d0cd1c..0dc5ba87 100644 --- a/dlls/game.h +++ b/dlls/game.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef GAME_H #define GAME_H diff --git a/dlls/gamerules.h b/dlls/gamerules.h index 71036151..04c6eea5 100644 --- a/dlls/gamerules.h +++ b/dlls/gamerules.h @@ -15,6 +15,7 @@ //========================================================= // GameRules //========================================================= +#pragma once #ifndef GAMERULES_H #define GAMERULES_H //#include "weapons.h" diff --git a/dlls/hornet.h b/dlls/hornet.h index dc78fc40..f0f0d366 100644 --- a/dlls/hornet.h +++ b/dlls/hornet.h @@ -15,7 +15,9 @@ //========================================================= // Hornets //========================================================= - +#pragma once +#ifndef HORNET_H +#define HORNET_H //========================================================= // Hornet Defines //========================================================= @@ -55,3 +57,4 @@ public: int m_iHornetType; float m_flFlySpeed; }; +#endif // HORNET_H diff --git a/dlls/items.h b/dlls/items.h index 2c31f801..060678c8 100644 --- a/dlls/items.h +++ b/dlls/items.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef ITEMS_H #define ITEMS_H diff --git a/dlls/lights.cpp b/dlls/lights.cpp index 8a4f8de8..1c39266b 100644 --- a/dlls/lights.cpp +++ b/dlls/lights.cpp @@ -37,8 +37,8 @@ public: static TYPEDESCRIPTION m_SaveData[]; private: - string_t m_iszPattern; int m_iStyle; + string_t m_iszPattern; }; LINK_ENTITY_TO_CLASS( light, CLight ) diff --git a/dlls/monsters.h b/dlls/monsters.h index 6f2df294..4aeca3a9 100644 --- a/dlls/monsters.h +++ b/dlls/monsters.h @@ -12,6 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ +#pragma once #ifndef MONSTERS_H #include "skill.h" #define MONSTERS_H diff --git a/dlls/nodes.h b/dlls/nodes.h index 49036a39..52b715e5 100644 --- a/dlls/nodes.h +++ b/dlls/nodes.h @@ -15,6 +15,7 @@ //========================================================= // nodes.h //========================================================= +#pragma once #ifndef NODES_H #define NODES_H //========================================================= diff --git a/dlls/physcallback.h b/dlls/physcallback.h index 1db276e0..fd68936c 100644 --- a/dlls/physcallback.h +++ b/dlls/physcallback.h @@ -12,9 +12,9 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PHYSCALLBACK_H #define PHYSCALLBACK_H -#pragma once #include "physint.h" diff --git a/dlls/player.h b/dlls/player.h index fecaf3c9..6fc06dbb 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PLAYER_H #define PLAYER_H diff --git a/dlls/saverestore.h b/dlls/saverestore.h index 4295871d..81f9f131 100644 --- a/dlls/saverestore.h +++ b/dlls/saverestore.h @@ -13,6 +13,7 @@ * ****/ // Implementation in UTIL.CPP +#pragma once #ifndef SAVERESTORE_H #define SAVERESTORE_H diff --git a/dlls/schedule.h b/dlls/schedule.h index 0c4fb1ce..6414ff15 100644 --- a/dlls/schedule.h +++ b/dlls/schedule.h @@ -15,7 +15,7 @@ //========================================================= // Scheduling //========================================================= - +#pragma once #ifndef SCHEDULE_H #define SCHEDULE_H diff --git a/dlls/scripted.cpp b/dlls/scripted.cpp index 92b9aa6a..41638b39 100644 --- a/dlls/scripted.cpp +++ b/dlls/scripted.cpp @@ -909,13 +909,13 @@ public: private: string_t m_iszSentence; // string index for idle animation string_t m_iszEntity; // entity that is wanted for this sentence - string_t m_iszListener; // name of entity to look at while talking float m_flRadius; // range to search float m_flDuration; // How long the sentence lasts float m_flRepeat; // repeat rate float m_flAttenuation; float m_flVolume; BOOL m_active; + string_t m_iszListener; // name of entity to look at while talking }; #define SF_SENTENCE_ONCE 0x0001 diff --git a/dlls/scripted.h b/dlls/scripted.h index 6cf8cfa1..59b696f7 100644 --- a/dlls/scripted.h +++ b/dlls/scripted.h @@ -12,6 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ +#pragma once #ifndef SCRIPTED_H #define SCRIPTED_H diff --git a/dlls/scriptevent.h b/dlls/scriptevent.h index 714ac99c..18436a26 100644 --- a/dlls/scriptevent.h +++ b/dlls/scriptevent.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef SCRIPTEVENT_H #define SCRIPTEVENT_H @@ -26,4 +27,4 @@ #define SCRIPT_EVENT_SOUND_VOICE 1008 // Play named wave file (on CHAN_VOICE) #define SCRIPT_EVENT_SENTENCE_RND1 1009 // Play sentence group 25% of the time #define SCRIPT_EVENT_NOT_DEAD 1010 // Bring back to life (for life/death sequences) -#endif //SCRIPTEVENT_H +#endif // SCRIPTEVENT_H diff --git a/dlls/skill.h b/dlls/skill.h index aa338362..5244c923 100644 --- a/dlls/skill.h +++ b/dlls/skill.h @@ -15,6 +15,7 @@ //========================================================= // skill.h - skill level concerns //========================================================= +#pragma once #ifndef SKILL_H #define SKILL_H @@ -23,7 +24,7 @@ struct skilldata_t int iSkillLevel; // game skill level // Monster Health & Damage - float agruntHealth; + float agruntHealth; float agruntDmgPunch; float apacheHealth; diff --git a/dlls/soundent.h b/dlls/soundent.h index 6c39a6c0..88def506 100644 --- a/dlls/soundent.h +++ b/dlls/soundent.h @@ -17,6 +17,9 @@ // spawns, and handles the world's active and free sound // lists. //========================================================= +#pragma once +#ifndef SOUNDENT_H +#define SOUNDENT_H #define MAX_WORLD_SOUNDS 64 // maximum number of sounds handled by the world at one time. @@ -91,3 +94,4 @@ public: private: CSound m_SoundPool[ MAX_WORLD_SOUNDS ]; }; +#endif // SOUNDENT_H diff --git a/dlls/spectator.h b/dlls/spectator.h index 00567fc6..c4e895c0 100644 --- a/dlls/spectator.h +++ b/dlls/spectator.h @@ -13,6 +13,7 @@ * ****/ // Spectator.h +#pragma once #ifndef SPECTATOR_H #define SPECTATOR_H diff --git a/dlls/squad.h b/dlls/squad.h index c29a7199..f8f20aa0 100644 --- a/dlls/squad.h +++ b/dlls/squad.h @@ -7,6 +7,7 @@ //========================================================= // squad.h //========================================================= +#pragma once #ifndef SQUAD_H #define SQUAD_H diff --git a/dlls/squadmonster.h b/dlls/squadmonster.h index 132d4177..e2c8a5b9 100644 --- a/dlls/squadmonster.h +++ b/dlls/squadmonster.h @@ -16,6 +16,7 @@ // CSquadMonster - all the extra data for monsters that // form squads. //========================================================= +#pragma once #ifndef SQUADMONSTER_H #define SQUADMONSTER_H diff --git a/dlls/talkmonster.h b/dlls/talkmonster.h index 084861bc..36ac21a6 100644 --- a/dlls/talkmonster.h +++ b/dlls/talkmonster.h @@ -12,6 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ +#pragma once #ifndef TALKMONSTER_H #define TALKMONSTER_H diff --git a/dlls/teamplay_gamerules.h b/dlls/teamplay_gamerules.h index 06823ca6..12ed038f 100644 --- a/dlls/teamplay_gamerules.h +++ b/dlls/teamplay_gamerules.h @@ -15,6 +15,9 @@ // // teamplay_gamerules.h // +#pragma once +#ifndef TEAMPLAY_GAMERULES_H +#define TEAMPLAY_GAMERULES_H #define MAX_TEAMNAME_LENGTH 16 #define MAX_TEAMS 32 @@ -55,3 +58,4 @@ private: BOOL m_teamLimit; // This means the server set only some teams as valid char m_szTeamList[TEAMPLAY_TEAMLISTLENGTH]; }; +#endif // TEAMPLAY_GAMERULES_H diff --git a/dlls/trains.h b/dlls/trains.h index e8003b3e..f740e2ea 100644 --- a/dlls/trains.h +++ b/dlls/trains.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef TRAINS_H #define TRAINS_H diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index 7d7f255c..6d8fef04 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -267,11 +267,11 @@ public: static TYPEDESCRIPTION m_SaveData[]; - string_t m_iTargetName[MAX_MULTI_TARGETS];// list if indexes into global string array - float m_flTargetDelay[MAX_MULTI_TARGETS];// delay (in seconds) from time of manager fire to target fire int m_cTargets; // the total number of targets in this manager's fire list. int m_index; // Current target float m_startTime;// Time we started firing + string_t m_iTargetName[MAX_MULTI_TARGETS];// list if indexes into global string array + float m_flTargetDelay[MAX_MULTI_TARGETS];// delay (in seconds) from time of manager fire to target fire private: inline BOOL IsClone( void ) { return ( pev->spawnflags & SF_MULTIMAN_CLONE ) ? TRUE : FALSE; } inline BOOL ShouldClone( void ) @@ -1321,9 +1321,9 @@ public: static TYPEDESCRIPTION m_SaveData[]; - string_t m_changeTarget; char m_szMapName[cchMapNameMost]; // trigger_changelevel only: next map char m_szLandmarkName[cchMapNameMost]; // trigger_changelevel only: landmark on next map + string_t m_changeTarget; float m_changeTargetDelay; }; diff --git a/dlls/util.h b/dlls/util.h index 8f56cd76..7f9dea70 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef UTIL_H #define UTIL_H // diff --git a/dlls/vector.h b/dlls/vector.h index 265a9b00..48c707b4 100644 --- a/dlls/vector.h +++ b/dlls/vector.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef VECTOR_H #define VECTOR_H diff --git a/dlls/weapons.h b/dlls/weapons.h index 0cfa2031..312f5531 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef WEAPONS_H #define WEAPONS_H diff --git a/engine/cdll_exp.h b/engine/cdll_exp.h index bf43654c..e4c1f5d8 100644 --- a/engine/cdll_exp.h +++ b/engine/cdll_exp.h @@ -12,6 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ +#pragma once #ifndef CDLL_EXP_H #define CDLL_EXP_H @@ -66,4 +67,4 @@ typedef struct cldll_func_s void (*pfnClipMoveToEntity)( struct physent_s *pe, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, struct pmtrace_s *tr ); } cldll_func_t; -#endif//CDLL_EXP_H \ No newline at end of file +#endif//CDLL_EXP_H diff --git a/engine/cdll_int.h b/engine/cdll_int.h index 20af4b55..abfc43bd 100644 --- a/engine/cdll_int.h +++ b/engine/cdll_int.h @@ -18,7 +18,7 @@ // 4-23-98 // JOHN: client dll interface declarations // - +#pragma once #ifndef CDLL_INT_H #define CDLL_INT_H diff --git a/engine/custom.h b/engine/custom.h index 30ee8d53..02aa2089 100644 --- a/engine/custom.h +++ b/engine/custom.h @@ -12,11 +12,10 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef CUSTOM_H #define CUSTOM_H -#pragma once - #include "const.h" ///////////////// diff --git a/engine/customentity.h b/engine/customentity.h index 63e672f8..f524ae79 100644 --- a/engine/customentity.h +++ b/engine/customentity.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef CUSTOMENTITY_H #define CUSTOMENTITY_H diff --git a/engine/edict.h b/engine/edict.h index 3994c705..8584a0d9 100644 --- a/engine/edict.h +++ b/engine/edict.h @@ -12,12 +12,10 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef EDICT_H #define EDICT_H -#pragma once - #define MAX_ENT_LEAFS 48 #include "progdefs.h" diff --git a/engine/eiface.h b/engine/eiface.h index 6fa51c12..f6cf2f51 100644 --- a/engine/eiface.h +++ b/engine/eiface.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef EIFACE_H #define EIFACE_H diff --git a/engine/keydefs.h b/engine/keydefs.h index ea22139f..5593d75a 100644 --- a/engine/keydefs.h +++ b/engine/keydefs.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef KEYDEFS_H #define KEYDEFS_H @@ -130,4 +130,4 @@ #define K_MOUSE4 244 #define K_MOUSE5 245 -#endif//KEYDEFS_H \ No newline at end of file +#endif//KEYDEFS_H diff --git a/engine/menu_int.h b/engine/menu_int.h index 69c10ce4..d907bd87 100644 --- a/engine/menu_int.h +++ b/engine/menu_int.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef MENU_INT_H #define MENU_INT_H diff --git a/engine/physint.h b/engine/physint.h index af923a00..2b4ac8f7 100644 --- a/engine/physint.h +++ b/engine/physint.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef PHYSINT_H #define PHYSINT_H @@ -111,4 +111,4 @@ typedef struct physics_interface_s int (*pfnRestoreDecal)( struct decallist_s *entry, edict_t *pEdict, qboolean adjacent ); } physics_interface_t; -#endif//PHYSINT_H \ No newline at end of file +#endif//PHYSINT_H diff --git a/engine/progdefs.h b/engine/progdefs.h index 56d904b1..31cfb3cb 100644 --- a/engine/progdefs.h +++ b/engine/progdefs.h @@ -12,11 +12,10 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PROGDEFS_H #define PROGDEFS_H -#pragma once - typedef struct { float time; diff --git a/engine/shake.h b/engine/shake.h index b2e88a33..a3e49324 100644 --- a/engine/shake.h +++ b/engine/shake.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef SHAKE_H #define SHAKE_H diff --git a/engine/sprite.h b/engine/sprite.h index afc81a4e..4368c1ac 100644 --- a/engine/sprite.h +++ b/engine/sprite.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef SPRITE_H #define SPRITE_H @@ -99,4 +99,4 @@ typedef struct frametype_t type; } dframetype_t; -#endif//SPRITE_H \ No newline at end of file +#endif//SPRITE_H diff --git a/engine/studio.h b/engine/studio.h index 00e7ad27..88254c96 100644 --- a/engine/studio.h +++ b/engine/studio.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef STUDIO_H #define STUDIO_H diff --git a/pm_shared/pm_debug.h b/pm_shared/pm_debug.h index 417c3478..6c91d62e 100644 --- a/pm_shared/pm_debug.h +++ b/pm_shared/pm_debug.h @@ -12,11 +12,10 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PM_DEBUG_H #define PM_DEBUG_H -#pragma once - void PM_ViewEntity( void ); void PM_DrawBBox( vec3_t mins, vec3_t maxs, vec3_t origin, int pcolor, float life ); void PM_ParticleLine( vec3_t start, vec3_t end, int pcolor, float life, float vert ); diff --git a/pm_shared/pm_defs.h b/pm_shared/pm_defs.h index eddb17b6..82480806 100644 --- a/pm_shared/pm_defs.h +++ b/pm_shared/pm_defs.h @@ -12,11 +12,10 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PM_DEFS_H #define PM_DEFS_H -#pragma once - #define MAX_PHYSENTS 600 // Must have room for all entities in the world. #define MAX_MOVEENTS 64 #define MAX_CLIP_PLANES 5 diff --git a/pm_shared/pm_info.h b/pm_shared/pm_info.h index d75b67fc..9a971d53 100644 --- a/pm_shared/pm_info.h +++ b/pm_shared/pm_info.h @@ -12,10 +12,9 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PM_INFO_H #define PM_INFO_H -#pragma once - #define MAX_PHYSINFO_STRING 256 #endif//PM_INFO_H diff --git a/pm_shared/pm_materials.h b/pm_shared/pm_materials.h index e625b4fc..9bc71b72 100644 --- a/pm_shared/pm_materials.h +++ b/pm_shared/pm_materials.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PM_MATERIALS_H #define PM_MATERIALS_H diff --git a/pm_shared/pm_movevars.h b/pm_shared/pm_movevars.h index 35fa5b4f..61eb06fd 100644 --- a/pm_shared/pm_movevars.h +++ b/pm_shared/pm_movevars.h @@ -6,6 +6,7 @@ //============================================================================= // pm_movevars.h +#pragma once #if !defined( PM_MOVEVARSH ) #define PM_MOVEVARSH diff --git a/pm_shared/pm_shared.h b/pm_shared/pm_shared.h index 2fb947a2..c315353b 100644 --- a/pm_shared/pm_shared.h +++ b/pm_shared/pm_shared.h @@ -12,12 +12,10 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef PM_SHARED_H #define PM_SHARED_H -#pragma once - void PM_Init( struct playermove_s *ppmove ); void PM_Move( struct playermove_s *ppmove, int server ); char PM_FindTextureType( char *name ); From bf429f0709d5045a8cf2880b3b035fb0ab0b41e7 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sat, 16 Dec 2017 04:56:23 +0300 Subject: [PATCH 135/144] Fix item soda precache --- dlls/effects.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/effects.cpp b/dlls/effects.cpp index bd9959f9..bd12f8aa 100644 --- a/dlls/effects.cpp +++ b/dlls/effects.cpp @@ -2182,7 +2182,7 @@ public: void CItemSoda::Precache( void ) { PRECACHE_MODEL( "models/can.mdl" ); - PRECACHE_SOUND( "weapons/g_bounce.wav" ); + PRECACHE_SOUND( "weapons/g_bounce3.wav" ); } LINK_ENTITY_TO_CLASS( item_sodacan, CItemSoda ) From 1285d4834781aead0d99c65784ebb671be5e59e1 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 17 Dec 2017 02:35:36 +0500 Subject: [PATCH 136/144] Update .travis.yml. --- .travis.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9e165b81..00f3f479 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,20 @@ compiler: os: - linux - osx -sudo: true +addons: + apt: + packages: + - gcc-multilib + - g++-multilib before_script: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install gcc-multilib g++-multilib; fi + - curl http://libsdl.org/release/SDL2-devel-2.0.7-mingw.tar.gz | tar xzf - + - mv SDL2-2.0.7/i686-w64-mingw32/include/SDL2 cl_dll/ script: - mkdir -p build && cd build - - cmake ../ -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DUSE_VOICEMGR=0 && make -j3 && rm -rf * - - cmake ../ -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DUSE_VOICEMGR=1 && make -j3 && rm -rf * \ No newline at end of file + - cmake ../ -DCMAKE_C_FLAGS="-O2 -pipe -DNDEBUG -march=nocona -fvisibility=hidden -fomit-frame-pointer" -DCMAKE_CXX_FLAGS="-fno-exceptions -fno-rtti" -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined -Wl,--strip-all" -DGOLDSOURCE_SUPPORT=1 -DUSE_VOICEMGR=0 && make -j3 + - mkdir -p gamelibs/cl_dlls + - mkdir -p gamelibs/dlls + - cp cl_dll/libclient.* gamelibs/cl_dlls + - cp dlls/libserver.* gamelibs/dlls + - tar -J -cf gamelibs.txz gamelibs + - curl --upload-file gamelibs.txz https://transfer.sh/gamelibs.txz From e0f475e80e05b00984fb52088f1230d84c724736 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 17 Dec 2017 22:46:44 +0500 Subject: [PATCH 137/144] Use branch name and OS name as tarball name. --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 00f3f479..da740958 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,9 +16,9 @@ before_script: script: - mkdir -p build && cd build - cmake ../ -DCMAKE_C_FLAGS="-O2 -pipe -DNDEBUG -march=nocona -fvisibility=hidden -fomit-frame-pointer" -DCMAKE_CXX_FLAGS="-fno-exceptions -fno-rtti" -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined -Wl,--strip-all" -DGOLDSOURCE_SUPPORT=1 -DUSE_VOICEMGR=0 && make -j3 - - mkdir -p gamelibs/cl_dlls - - mkdir -p gamelibs/dlls - - cp cl_dll/libclient.* gamelibs/cl_dlls - - cp dlls/libserver.* gamelibs/dlls - - tar -J -cf gamelibs.txz gamelibs - - curl --upload-file gamelibs.txz https://transfer.sh/gamelibs.txz + - mkdir -p $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/cl_dlls + - mkdir -p $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/dlls + - cp cl_dll/libclient.* $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/cl_dlls + - cp dlls/libserver.* $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/dlls + - tar -J -cf $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC.txz $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC + - curl --upload-file $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC.txz https://transfer.sh/$TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC.txz From a2f0ecf7419e58b7bd3a15257ecf954786e18128 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 18 Dec 2017 02:44:42 +0500 Subject: [PATCH 138/144] Fix linking with libdl on some environments. --- cl_dll/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index e3ac075a..aa1e94f8 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -28,9 +28,6 @@ set (CLDLL_LIBRARY client) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w") if (GOLDSOURCE_SUPPORT) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT") - if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ldl") - endif() endif() set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") @@ -109,6 +106,9 @@ if(USE_VOICEMGR) endif() add_library (${CLDLL_LIBRARY} SHARED ${CLDLL_SOURCES}) +if (GOLDSOURCE_SUPPORT) + target_link_libraries( ${CLDLL_LIBRARY} ${CMAKE_DL_LIBS} ) +endif() set_target_properties (${CLDLL_SHARED} PROPERTIES POSITION_INDEPENDENT_CODE 1) From b5650d56108f60d3b7e290edef835610a7d0dc65 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 18 Dec 2017 04:32:25 +0500 Subject: [PATCH 139/144] Do not use cpu-dependent optimization. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index da740958..dff12df2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ before_script: - mv SDL2-2.0.7/i686-w64-mingw32/include/SDL2 cl_dll/ script: - mkdir -p build && cd build - - cmake ../ -DCMAKE_C_FLAGS="-O2 -pipe -DNDEBUG -march=nocona -fvisibility=hidden -fomit-frame-pointer" -DCMAKE_CXX_FLAGS="-fno-exceptions -fno-rtti" -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined -Wl,--strip-all" -DGOLDSOURCE_SUPPORT=1 -DUSE_VOICEMGR=0 && make -j3 + - cmake ../ -DCMAKE_C_FLAGS="-O2 -pipe -DNDEBUG -fvisibility=hidden -fomit-frame-pointer" -DCMAKE_CXX_FLAGS="-fno-exceptions -fno-rtti" -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined -Wl,--strip-all" -DGOLDSOURCE_SUPPORT=1 -DUSE_VOICEMGR=0 && make -j3 - mkdir -p $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/cl_dlls - mkdir -p $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/dlls - cp cl_dll/libclient.* $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/cl_dlls From c128c69ceb2a96730ffe487bef234c4e59f3cac3 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 19 Dec 2017 00:27:56 +0300 Subject: [PATCH 140/144] Add install() for CMake. --- CMakeLists.txt | 4 ++++ cl_dll/CMakeLists.txt | 13 ++++++++++++- dlls/CMakeLists.txt | 13 ++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7719bac6..0d754eb5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,10 @@ option(USE_VOICEMGR "Enable VOICE MANAGER." OFF) option(BUILD_CLIENT "Build client dll" ON) option(BUILD_SERVER "Build server dll" ON) option(GOLDSOURCE_SUPPORT "Build goldsource compatible client library" OFF) +set(GAMEDIR "valve" CACHE STRING "Gamedir path") +set(SERVER_INSTALL_DIR "dlls" CACHE STRING "Where put server dll") +set(CLIENT_INSTALL_DIR "cl_dlls" CACHE STRING "Where put client dll") +set(SERVER_LIBRARY_NAME "hl" CACHE STRING "Library name for Linux/MacOS/Windows") #----------------- # MAIN BUILD CODE \ diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index aa1e94f8..2d247950 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -110,6 +110,17 @@ if (GOLDSOURCE_SUPPORT) target_link_libraries( ${CLDLL_LIBRARY} ${CMAKE_DL_LIBS} ) endif() -set_target_properties (${CLDLL_SHARED} PROPERTIES +set_target_properties (${CLDLL_LIBRARY} PROPERTIES POSITION_INDEPENDENT_CODE 1) +if(APPLE OR WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + set_target_properties(${CLDLL_LIBRARY} PROPERTIES + OUTPUT_NAME "client" + PREFIX "") +endif() + +install( TARGETS ${CLDLL_LIBRARY} + DESTINATION "${GAMEDIR}/${CLIENT_INSTALL_DIR}/" + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE ) diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index 4e56ab44..480b61d1 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -145,6 +145,17 @@ endif() add_library (${SVDLL_LIBRARY} SHARED ${SVDLL_SOURCES}) -set_target_properties (${SVDLL_SHARED} PROPERTIES +set_target_properties (${SVDLL_LIBRARY} PROPERTIES POSITION_INDEPENDENT_CODE 1) +if(APPLE OR WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + set_target_properties(${SVDLL_LIBRARY} PROPERTIES + OUTPUT_NAME ${SERVER_LIBRARY_NAME} + PREFIX "") +endif() + +install( TARGETS ${SVDLL_LIBRARY} + DESTINATION "${GAMEDIR}/${SERVER_INSTALL_DIR}/" + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE) From 7981bad606f0a251b3904405539b667c06c676f5 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 19 Dec 2017 00:28:34 +0300 Subject: [PATCH 141/144] Fix weapon selection being broken at the start of demo(or manual fullupdate call) --- dlls/player.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dlls/player.cpp b/dlls/player.cpp index d0a1f763..52f5f546 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -3327,6 +3327,10 @@ void CBasePlayer::ForceClientDllUpdate( void ) m_fWeapon = FALSE; // Force weapon send m_fKnownItem = FALSE; // Force weaponinit messages. m_fInitHUD = TRUE; // Force HUD gmsgResetHUD message + m_bSentBhopcap = true; // a1ba: Update bhopcap state + memset( m_rgAmmoLast, 0, sizeof( m_rgAmmoLast )); // a1ba: Force update AmmoX + + // Now force all the necessary messages // to be sent. From 113135f7b9dd9d0dcd54f2e6724f016148faa1d8 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Mon, 18 Dec 2017 23:58:30 +0300 Subject: [PATCH 142/144] Ignore dlls, pdb, some cmake generated files and orig files produced by some diff programs --- .gitignore | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 26362f60..a0bc5604 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,14 @@ *.a *.framework *.exe -build/ \ No newline at end of file +*.dll +*.pdb +build/ +CMakeLists.txt.user +cmake_install.cmake +*.orig +*.cbp +*.dsw +*.vsxproj +*.vsproj +*.sln From 6be68c49f334b63055ffe09da94cd5295ae4bc15 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Wed, 20 Dec 2017 04:35:54 +0300 Subject: [PATCH 143/144] Remove redundant files of original xash3d hlsdk --- backup.bat | 31 ------------------------- backup.lst | 36 ----------------------------- debug.bat | 42 --------------------------------- make_sdk.bat | 62 ------------------------------------------------- release.bat | 42 --------------------------------- xash.dsw | 65 ---------------------------------------------------- xash_sdk.dsw | 65 ---------------------------------------------------- xash_sdk.lst | 22 ------------------ 8 files changed, 365 deletions(-) delete mode 100644 backup.bat delete mode 100644 backup.lst delete mode 100644 debug.bat delete mode 100644 make_sdk.bat delete mode 100644 release.bat delete mode 100644 xash.dsw delete mode 100644 xash_sdk.dsw delete mode 100644 xash_sdk.lst diff --git a/backup.bat b/backup.bat deleted file mode 100644 index 7e780aa8..00000000 --- a/backup.bat +++ /dev/null @@ -1,31 +0,0 @@ -@echo off -color 4F -echo XashXT Group 2006 (C) -echo Prepare source for backup -echo. - -if exist backup.log del /f /q backup.log -if not exist D:\!backup/ mkdir D:\!backup\ -echo Prepare OK! -echo Please wait: backup in progress -C:\Progra~1\WinRar\rar a -agMMMYYYY-DD D:\!backup\.rar -dh -m5 @backup.lst >>backup.log -if errorlevel 1 goto error -if errorlevel 0 goto ok -:ok -cls -echo Source was sucessfully backuped -echo and stored in folder "backup" -echo Press any key for exit. :-) -if exist backup.log del /f /q backup.log -exit -:error -echo ****************************** -echo ***********Error!************* -echo ****************************** -echo **See backup.log for details** -echo ****************************** -echo ****************************** -echo. -echo press any key for exit :-( -pause>nul -exit diff --git a/backup.lst b/backup.lst deleted file mode 100644 index 628de079..00000000 --- a/backup.lst +++ /dev/null @@ -1,36 +0,0 @@ -//======================================================================= -// Copyright XashXT Group 2007 © -// list with backup directories -//======================================================================= - -// global stuff -xash.dsw -debug.bat -backup.lst -backup.bat -release.bat -change.log -make_sdk.bat -xash_sdk.lst - -cl_dll\ -cl_dll\hl\ -common\ -dlls\ -game_shared\ -game_launch\ -engine\ -engine\client\ -engine\client\vgui\ -engine\server\ -engine\common\ -engine\common\imagelib\ -engine\common\soundlib\ -pm_shared\ -mainui\ -mainui\legacy -utils\ -utils\makefont\ -utils\vgui\ -utils\vgui\include\ -utils\vgui\lib\win32_vc6\ \ No newline at end of file diff --git a/debug.bat b/debug.bat deleted file mode 100644 index eb702325..00000000 --- a/debug.bat +++ /dev/null @@ -1,42 +0,0 @@ -@echo off - -set MSDEV=BuildConsole -set CONFIG=/ShowTime /ShowAgent /nologo /cfg= -set MSDEV=msdev -set CONFIG=/make -set build_type=debug -set BUILD_ERROR= -call vcvars32 - -%MSDEV% engine/engine.dsp %CONFIG%"engine - Win32 Debug" %build_target% -if errorlevel 1 set BUILD_ERROR=1 - -%MSDEV% mainui/mainui.dsp %CONFIG%"mainui - Win32 Debug" %build_target% -if errorlevel 1 set BUILD_ERROR=1 - -if "%BUILD_ERROR%"=="" goto build_ok - -echo ********************* -echo ********************* -echo *** Build Errors! *** -echo ********************* -echo ********************* -echo press any key to exit -echo ********************* -pause>nul -goto done - - -@rem -@rem Successful build -@rem -:build_ok - -rem //delete log files -if exist engine\engine.plg del /f /q engine\engine.plg -if exist mainui\mainui.plg del /f /q mainui\mainui.plg - -echo -echo Build succeeded! -echo -:done \ No newline at end of file diff --git a/make_sdk.bat b/make_sdk.bat deleted file mode 100644 index 96602839..00000000 --- a/make_sdk.bat +++ /dev/null @@ -1,62 +0,0 @@ -@echo off -color 5A -echo XashXT Group 2010 (C) -echo Create Xash3D SDK -echo. - -if not exist D:\Xash3D\src_main\xash_sdk/ mkdir D:\Xash3D\src_main\xash_sdk\ -if not exist D:\Xash3D\src_main\xash_sdk\engine/ mkdir D:\Xash3D\src_main\xash_sdk\engine\ -if not exist D:\Xash3D\src_main\xash_sdk\common/ mkdir D:\Xash3D\src_main\xash_sdk\common\ -if not exist D:\Xash3D\src_main\xash_sdk\mainui/ mkdir D:\Xash3D\src_main\xash_sdk\mainui\ -if not exist D:\Xash3D\src_main\xash_sdk\mainui\legacy/ mkdir D:\Xash3D\src_main\xash_sdk\mainui\legacy -if not exist D:\Xash3D\src_main\xash_sdk\utils/ mkdir D:\Xash3D\src_main\xash_sdk\utils\ -if not exist D:\Xash3D\src_main\xash_sdk\utils\makefont/ mkdir D:\Xash3D\src_main\xash_sdk\utils\makefont -if not exist D:\Xash3D\src_main\xash_sdk\utils\vgui/ mkdir D:\Xash3D\src_main\xash_sdk\utils\vgui -if not exist D:\Xash3D\src_main\xash_sdk\utils\vgui\include/ mkdir D:\Xash3D\src_main\xash_sdk\utils\vgui\include -if not exist D:\Xash3D\src_main\xash_sdk\utils\vgui\lib/ mkdir D:\Xash3D\src_main\xash_sdk\utils\vgui\lib -if not exist D:\Xash3D\src_main\xash_sdk\utils\vgui\lib\win32_vc6/ mkdir D:\Xash3D\src_main\xash_sdk\utils\vgui\lib\win32_vc6 -if not exist D:\Xash3D\src_main\xash_sdk\game_launch/ mkdir D:\Xash3D\src_main\xash_sdk\game_launch\ -if not exist D:\Xash3D\src_main\xash_sdk\cl_dll/ mkdir D:\Xash3D\src_main\xash_sdk\cl_dll\ -if not exist D:\Xash3D\src_main\xash_sdkcl_dll\hl/ mkdir D:\Xash3D\src_main\xash_sdk\cl_dll\hl\ -if not exist D:\Xash3D\src_main\xash_sdk\dlls/ mkdir D:\Xash3D\src_main\xash_sdk\dlls\ -if not exist D:\Xash3D\src_main\xash_sdk\dlls\wpn_shared/ mkdir D:\Xash3D\src_main\xash_sdk\dlls\wpn_shared\ -if not exist D:\Xash3D\src_main\xash_sdk\game_shared/ mkdir D:\Xash3D\src_main\xash_sdk\game_shared\ -if not exist D:\Xash3D\src_main\xash_sdk\pm_shared/ mkdir D:\Xash3D\src_main\xash_sdk\pm_shared\ -@copy /Y engine\*.h xash_sdk\engine\*.h -@copy /Y game_launch\*.* xash_sdk\game_launch\*.* -@copy /Y mainui\*.* xash_sdk\mainui\*.* -@copy /Y mainui\legacy\*.* xash_sdk\mainui\legacy\*.* -@copy /Y common\*.* xash_sdk\common\*.* -@copy /Y cl_dll\*.* xash_sdk\cl_dll\*.* -@copy /Y cl_dll\hl\*.* xash_sdk\cl_dll\hl\*.* -@copy /Y dlls\*.* xash_sdk\dlls\*.* -@copy /Y dlls\wpn_shared\*.* xash_sdk\dlls\wpn_shared\*.* -@copy /Y utils\makefont\*.* xash_sdk\utils\makefont\*.* -@copy /Y utils\vgui\include\*.* xash_sdk\utils\vgui\include\*.* -@copy /Y utils\vgui\lib\win32_vc6\*.* xash_sdk\utils\vgui\lib\win32_vc6\*.* -@copy /Y game_shared\*.* xash_sdk\game_shared\*.* -@copy /Y pm_shared\*.* xash_sdk\pm_shared\*.* -@copy /Y xash_sdk.dsw xash_sdk\xash_sdk.dsw -echo Prepare OK! -echo Please wait: creating SDK in progress -C:\Progra~1\WinRar\rar a xash_sdk -dh -k -r -s -df -m5 @xash_sdk.lst >>makesdk.log -if errorlevel 1 goto error -if errorlevel 0 goto ok -:ok -cls -echo SDK was sucessfully created -echo and stored in RAR-chive "xash_sdk" -echo Press any key for exit. :-) -if exist makesdk.log del /f /q makesdk.log -exit -:error -echo ****************************** -echo ***********Error!************* -echo ****************************** -echo *See makesdk.log for details** -echo ****************************** -echo ****************************** -echo. -echo press any key for exit :-( -pause>nul -exit \ No newline at end of file diff --git a/release.bat b/release.bat deleted file mode 100644 index dae2d16c..00000000 --- a/release.bat +++ /dev/null @@ -1,42 +0,0 @@ -@echo off - -set MSDEV=BuildConsole -set CONFIG=/ShowTime /ShowAgent /nologo /cfg= -set MSDEV=msdev -set CONFIG=/make -set build_type=release -set BUILD_ERROR= -call vcvars32 - -%MSDEV% engine/engine.dsp %CONFIG%"engine - Win32 Release" %build_target% -if errorlevel 1 set BUILD_ERROR=1 - -%MSDEV% mainui/mainui.dsp %CONFIG%"mainui - Win32 Release" %build_target% -if errorlevel 1 set BUILD_ERROR=1 - -if "%BUILD_ERROR%"=="" goto build_ok - -echo ********************* -echo ********************* -echo *** Build Errors! *** -echo ********************* -echo ********************* -echo press any key to exit -echo ********************* -pause>nul -goto done - - -@rem -@rem Successful build -@rem -:build_ok - -rem //delete log files -if exist engine\engine.plg del /f /q engine\engine.plg -if exist mainui\mainui.plg del /f /q mainui\mainui.plg - -echo -echo Build succeeded! -echo -:done \ No newline at end of file diff --git a/xash.dsw b/xash.dsw deleted file mode 100644 index 3be1a44d..00000000 --- a/xash.dsw +++ /dev/null @@ -1,65 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "hl"=".\dlls\hl.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "client"=".\cl_dll\cl_dll.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "mainui"=".\mainui\mainui.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "engine"=".\engine\engine.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/xash_sdk.dsw b/xash_sdk.dsw deleted file mode 100644 index ad911ba0..00000000 --- a/xash_sdk.dsw +++ /dev/null @@ -1,65 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "hl"=".\dlls\hl.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "client"=".\cl_dll\cl_dll.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "mainui"=".\mainui\mainui.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "game"=".\game_launch\game.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/xash_sdk.lst b/xash_sdk.lst deleted file mode 100644 index a211c3b4..00000000 --- a/xash_sdk.lst +++ /dev/null @@ -1,22 +0,0 @@ -//======================================================================= -// Copyright XashXT Group 2011 © -// list with SDK directories -//======================================================================= - -// global stuff -xash_sdk\xash_sdk.dsw -xash_sdk\cl_dll\ -xash_sdk\cl_dll\hl\ -xash_sdk\common\ -xash_sdk\dlls\ -xash_sdk\game_shared\ -xash_sdk\game_launch\ -xash_sdk\engine\ -xash_sdk\pm_shared\ -xash_sdk\mainui\ -xash_dsk\mainui\legacy -xash_sdk\utils\ -xash_sdk\makefont\ -xash_sdk\utils\vgui\ -xash_sdk\utils\vgui\include\ -xash_sdk\utils\vgui\lib\win32_vc6\ \ No newline at end of file From df737ff88d5552e7d6fc0ac67ea60520d9f8f4e6 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 21 Dec 2017 17:12:05 +0500 Subject: [PATCH 144/144] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index dff12df2..fb18612f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ script: - cmake ../ -DCMAKE_C_FLAGS="-O2 -pipe -DNDEBUG -fvisibility=hidden -fomit-frame-pointer" -DCMAKE_CXX_FLAGS="-fno-exceptions -fno-rtti" -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined -Wl,--strip-all" -DGOLDSOURCE_SUPPORT=1 -DUSE_VOICEMGR=0 && make -j3 - mkdir -p $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/cl_dlls - mkdir -p $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/dlls - - cp cl_dll/libclient.* $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/cl_dlls - - cp dlls/libserver.* $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/dlls + - cp cl_dll/client.* $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/cl_dlls + - cp dlls/hl.* $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/dlls - tar -J -cf $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC.txz $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC - curl --upload-file $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC.txz https://transfer.sh/$TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC.txz