Additional spectator fixes

- fixed issues with piemenu cursor code being enabled when spectating
- the cursor is now enabled when in an observer mode that locks the view.
- fixed bugs/exploits where dead players could first person spectate the enemy team or travel around in freelook if all spectatable players on the team are dead.
This commit is contained in:
pierow 2024-05-04 04:51:27 -04:00
parent e24041c64a
commit b5177e8e47
5 changed files with 24 additions and 8 deletions

View file

@ -12,6 +12,7 @@
#include "vgui_TeamFortressViewport.h" #include "vgui_TeamFortressViewport.h"
#include "vgui_SpectatorPanel.h" #include "vgui_SpectatorPanel.h"
#include "common/hltv.h" #include "common/hltv.h"
#include "AvHServerVariables.h"
#include "ammohistory.h" #include "ammohistory.h"
#include "pm_shared/pm_shared.h" #include "pm_shared/pm_shared.h"
@ -493,7 +494,7 @@ int CHudSpectator::Draw(float flTime)
bool CHudSpectator::IsInOverviewMode() const bool CHudSpectator::IsInOverviewMode() const
{ {
return g_iUser1 && m_overviewMode && gHUD.GetIsNSMode(); return g_iUser1 && m_overviewMode && gHUD.GetIsNSMode() /*&& g_iUser1 != OBS_ROAMING*/;
} }
void CHudSpectator::SetOverviewMode(bool overviewMode) void CHudSpectator::SetOverviewMode(bool overviewMode)
@ -868,7 +869,7 @@ void CHudSpectator::HandleButtonsDown( int ButtonPressed )
AvHPlayMode CurrPlayMode = gHUD.GetPlayMode(); AvHPlayMode CurrPlayMode = gHUD.GetPlayMode();
float FreeSpecMode = gHUD.GetServerVariableFloat("mp_freespectatormode"); float FreeSpecMode = gHUD.GetServerVariableFloat(kvFreeSpectatorMode);
if (FreeSpecMode == 0 || (FreeSpecMode == 1 && gHUD.GetPlayMode() != PLAYMODE_OBSERVER)) if (FreeSpecMode == 0 || (FreeSpecMode == 1 && gHUD.GetPlayMode() != PLAYMODE_OBSERVER))
{ {
while (theNewMainMode == OBS_CHASE_FREE || theNewMainMode == OBS_ROAMING) while (theNewMainMode == OBS_CHASE_FREE || theNewMainMode == OBS_ROAMING)
@ -1025,8 +1026,8 @@ void CHudSpectator::SetMode(int iNewMainMode)
if (NewMode == OBS_CHASE_FREE || NewMode == OBS_ROAMING) if (NewMode == OBS_CHASE_FREE || NewMode == OBS_ROAMING)
{ {
float FreeSpecMode = gHUD.GetServerVariableFloat("mp_freespectatormode"); float FreeSpecMode = gHUD.GetServerVariableFloat(kvFreeSpectatorMode);
if (FreeSpecMode == 0 || (FreeSpecMode == 1 && gHUD.GetPlayMode() != PLAYMODE_OBSERVER)) if ((FreeSpecMode == 0 || (FreeSpecMode == 1.0f && gHUD.GetPlayMode() != PLAYMODE_OBSERVER)) && !gEngfuncs.IsSpectateOnly())
{ {
if (g_iUser1 != OBS_CHASE_FREE && g_iUser1 != OBS_ROAMING) if (g_iUser1 != OBS_CHASE_FREE && g_iUser1 != OBS_ROAMING)
{ {
@ -1899,7 +1900,7 @@ void CHudSpectator::CheckSettings()
gHUD.SetCurrentCrosshair( 0, m_crosshairRect, 0, 0, 0 ); gHUD.SetCurrentCrosshair( 0, m_crosshairRect, 0, 0, 0 );
gWR.SetWeaponConfig(nullptr, -1); gWR.SetWeaponConfig(nullptr, -1);
} }
// Removed by mmcguire. // Removed by mmcguire.
/* /*

View file

@ -129,6 +129,8 @@ void IN_ResetMouse( void );
extern CMenuPanel *CMessageWindowPanel_Create( const char *szMOTD, const char *szTitle, int iShadeFullscreen, int iRemoveMe, int x, int y, int wide, int tall ); extern CMenuPanel *CMessageWindowPanel_Create( const char *szMOTD, const char *szTitle, int iShadeFullscreen, int iRemoveMe, int x, int y, int wide, int tall );
extern float * GetClientColor( int clientIndex ); extern float * GetClientColor( int clientIndex );
extern AvHPieMenuHandler gPieMenuHandler;
using namespace vgui; using namespace vgui;
@ -1604,6 +1606,8 @@ void TeamFortressViewport::UpdateSpectatorPanel()
gHUD.m_TextMessage.MsgFunc_TextMsg( NULL, strlen( tempString ) + 1, tempString ); gHUD.m_TextMessage.MsgFunc_TextMsg( NULL, strlen( tempString ) + 1, tempString );
*/ */
} }
gViewPort->UpdateCursorState();
sprintf(bottomText,"#Spec_Mode%d", g_iUser1 ); sprintf(bottomText,"#Spec_Mode%d", g_iUser1 );
sprintf(helpString2,"#Spec_Mode%d", g_iUser1 ); sprintf(helpString2,"#Spec_Mode%d", g_iUser1 );
@ -2216,7 +2220,8 @@ void TeamFortressViewport::UpdateOnPlayerInfo()
void TeamFortressViewport::UpdateCursorState() void TeamFortressViewport::UpdateCursorState()
{ {
if (gHUD.GetInTopDownMode() || m_pSpectatorPanel->isVisible() || GetClientVoiceMgr()->IsInSquelchMode()) if (gHUD.GetInTopDownMode() || GetClientVoiceMgr()->IsInSquelchMode() || /*gPieMenuHandler.GetIsPieMenuOpen() ||*/
(m_pSpectatorPanel->isVisible() && (g_iUser1 == OBS_CHASE_LOCKED || g_iUser1 == OBS_IN_EYE)))
{ {
gHUD.GetManager().SetMouseVisibility(true); gHUD.GetManager().SetMouseVisibility(true);
} }

View file

@ -295,7 +295,7 @@ void CBasePlayer::Observer_SetMode( int iMode )
NewMode = OBS_IN_EYE; // now it is NewMode = OBS_IN_EYE; // now it is
// if we are not roaming, we need a valid target to track // if we are not roaming, we need a valid target to track
if ( (NewMode != OBS_ROAMING) && (m_hObserverTarget == NULL) ) if (NewMode != OBS_ROAMING)
{ {
Observer_FindNextPlayer(); Observer_FindNextPlayer();
@ -313,6 +313,11 @@ void CBasePlayer::Observer_SetMode( int iMode )
if (NewMode == OBS_ROAMING) if (NewMode == OBS_ROAMING)
{ {
pev->iuser2 = 0; pev->iuser2 = 0;
if (!theIsObserving)
{
pev->health = 0; // Set dead status and block free look movement in pmove.
}
} }
else else
{ {

View file

@ -1693,6 +1693,11 @@ void CBasePlayer::StartObserver( Vector vecPosition, Vector vecViewAngle )
// pev->flags = FL_CLIENT | FL_SPECTATOR; // Should we set Spectator flag? Or is it reserver for people connecting with spectator 1? // pev->flags = FL_CLIENT | FL_SPECTATOR; // Should we set Spectator flag? Or is it reserver for people connecting with spectator 1?
pev->deadflag = DEAD_RESPAWNABLE; pev->deadflag = DEAD_RESPAWNABLE;
if (this->pev->playerclass != PLAYMODE_OBSERVER)
{
pev->health = 0; // Set dead status and block free look movement in pmove.
}
// Tell the physics code that this player's now in observer mode // Tell the physics code that this player's now in observer mode
Observer_SetMode(OBS_IN_EYE); Observer_SetMode(OBS_IN_EYE);
Observer_SpectatePlayer(this->GetDefaultSpectatingTarget()); Observer_SpectatePlayer(this->GetDefaultSpectatingTarget());

View file

@ -5561,7 +5561,7 @@ void AvHHud::UpdatePieMenuControl()
} }
// If we're dead, make sure the popup menu is closed // If we're dead, make sure the popup menu is closed
if(!this->GetIsAlive(false)) if(!this->GetIsAlive(false) && gPieMenuHandler.GetIsPieMenuOpen())
{ {
gPieMenuHandler.ClosePieMenu(); gPieMenuHandler.ClosePieMenu();
} }