From cf5b2f9e14fdc87f3c58b8780834fffd9cec8fd7 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 23:50:55 +0500 Subject: [PATCH] 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 ) {