Skip to content

Commit 0a7b05f

Browse files
AdamTadeuszRainyanDESTROYGIRL
authored
* Fix demoui smoother buttons being unreactive (#1842) * Fix demoui smoother buttons being unreactive * Fix wrong budget group * Refactor Improve code readability * Server side second auto record command (#1855) * working * fix * delay game_end to end of round * not every comp game should necessarily be recorded * rainfix * Fix spec_next/prev not skipping dead players (#1856) Fix a case where in server demos, spec_next/spec_prev does not correctly skip dead players. * DebugDrawLine grenade trails for spectators and practicing (#1852) * working using debugdralines * clamp and float and stuff * Fix env_sun being hidden when under the centre of view (#1839) * Changing cl_neo_squad_hud_avatar_size updates star texture sizes immediately, also cl_neo_hud_centre convars (#1829) * init * also solve the woldpos marker centre sizes not updating automatically * le epic linux fail * maybe inline breaking it * center -> centre, GetFloat, f * HLTV Changes for a smoother demo watching experience (#1845) * init * cl_observercrosshair is only for roaming observer crosshair * makes most of the new spectate commands work in hltv * fix beacons too * view offsets, userid to entindex properly * neobotmanager ignore sourcetv, fix rest spectate commands * crosshair assert when spectating dead players * float, call spectateChecks function * gpGlobals->maxClients * nits plus quick fixes plus viewmodel is really dark in stvdemos which i only now noticed * don't move lighting origin of weapons attached to players * should probably define this string somewhere else at this point * revert changes to hud_crosshair trying to be smart about cl_observercrosshair * Update src/game/shared/neo/neo_gamerules.cpp Co-authored-by: DESTROYGIRL <toddlodyte44@outlook.com> --------- Co-authored-by: DESTROYGIRL <toddlodyte44@outlook.com> --------- Co-authored-by: Rainyan <Rainyan@users.noreply.github.com> Co-authored-by: DESTROYGIRL <toddlodyte44@outlook.com>
1 parent dc5aba2 commit 0a7b05f

31 files changed

Lines changed: 756 additions & 181 deletions

src/game/client/c_baseanimating.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3619,16 +3619,19 @@ int C_BaseAnimating::InternalDrawModel( int flags )
36193619
#ifdef NEO
36203620
if (IsViewModel())
36213621
{ // view models become dark when standing close to and facing a wall, change lighting origin
3622-
auto pOwner = UTIL_PlayerByIndex(GetLocalPlayerIndex());
3623-
if (pOwner)
3622+
if (!engine->IsHLTV())
36243623
{
3625-
static Vector ownerOrigin;
3626-
ownerOrigin = pOwner->EyePosition();
3627-
pInfo->pLightingOrigin = &ownerOrigin;
3624+
auto pOwner = UTIL_PlayerByIndex(GetLocalPlayerIndex());
3625+
if (pOwner)
3626+
{
3627+
static Vector ownerOrigin;
3628+
ownerOrigin = pOwner->EyePosition();
3629+
pInfo->pLightingOrigin = &ownerOrigin;
3630+
}
36283631
}
36293632
}
3630-
else if (IsBaseCombatWeapon())
3631-
{
3633+
else if (IsBaseCombatWeapon() && !GetMoveParent())
3634+
{ // dropped weapons can become dark when they rotate such that their origin falls through the floor
36323635
static Vector worldSpaceCenter;
36333636
worldSpaceCenter = WorldSpaceCenter();
36343637
pInfo->pLightingOrigin = &worldSpaceCenter;

src/game/client/cdll_client_int.cpp

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@
150150

151151
#endif
152152

153+
#ifdef NEO
154+
#include <vgui_controls/Button.h>
155+
#include <vgui_controls/MenuButton.h>
156+
#endif
153157

154158
extern vgui::IInputInternal *g_InputInternal;
155159

@@ -1943,6 +1947,79 @@ void CHLClient::DecodeUserCmdFromBuffer( bf_read& buf, int slot )
19431947
input->DecodeUserCmdFromBuffer( buf, slot );
19441948
}
19451949

1950+
#ifdef NEO
1951+
inline static vgui::VPANEL ChildOf(const vgui::VPANEL parent, const char* childName)
1952+
{
1953+
Assert(parent);
1954+
const auto& children = vgui::ipanel()->GetChildren(parent);
1955+
for (const auto& child : children)
1956+
{
1957+
const char* name = vgui::ipanel()->GetName(child);
1958+
Assert(childName && *childName);
1959+
if (name && V_strcmp(name, childName) == 0)
1960+
return child;
1961+
}
1962+
return {};
1963+
}
1964+
1965+
static void FixupDemoSmoother()
1966+
{
1967+
VPROF_BUDGET(__FUNCTION__, VPROF_BUDGETGROUP_REPLAY);
1968+
1969+
static bool alreadyDone = false;
1970+
if (alreadyDone)
1971+
return;
1972+
1973+
// Don't spam the vgui iteration attempts too often...
1974+
static float lastAttemptTime{};
1975+
if (gpGlobals->curtime - lastAttemptTime < 1)
1976+
{
1977+
// ...except if we're not ticking, since who knows how long it's been.
1978+
// Luckily perf doesn't really matter if the entire game is currently frozen.
1979+
if (!engine->IsPaused())
1980+
{
1981+
return;
1982+
}
1983+
}
1984+
1985+
lastAttemptTime = gpGlobals->curtime;
1986+
1987+
Assert(enginevgui);
1988+
const auto toolsPanel = enginevgui->GetPanel(PANEL_TOOLS);
1989+
const auto demoUiPanel = ChildOf(toolsPanel, "DemoUIPanel");
1990+
const auto demoSmootherPanel = ChildOf(demoUiPanel, "DemoSmootherPanel");
1991+
if (!demoSmootherPanel)
1992+
return;
1993+
1994+
constexpr const char* demoSmootherPanelButtonsToFix[]{
1995+
"DemoSmoothFixFrameButton",
1996+
"DemoSmootherType" };
1997+
1998+
int numFixed = 0;
1999+
for (const auto& buttonName : demoSmootherPanelButtonsToFix)
2000+
{
2001+
auto button = vgui::ipanel()->GetPanel(ChildOf(demoSmootherPanel, buttonName), "BaseUI");
2002+
if (!button)
2003+
continue;
2004+
2005+
// The buttons live in engine dll, so this could theoretically change in SDK update.
2006+
using ExpectedButtonType = vgui::MenuButton;
2007+
// And so we check
2008+
if (!dynamic_cast<ExpectedButtonType*>(button))
2009+
{
2010+
Assert(false);
2011+
alreadyDone = true; // nothing we can do until code fix... just mark as done
2012+
return;
2013+
}
2014+
2015+
((ExpectedButtonType*)button)->SetButtonActivationType(vgui::Button::ACTIVATE_ONPRESSED);
2016+
++numFixed;
2017+
}
2018+
2019+
alreadyDone = (numFixed == ARRAYSIZE(demoSmootherPanelButtonsToFix));
2020+
}
2021+
#endif
2022+
19462023
//-----------------------------------------------------------------------------
19472024
// Purpose:
19482025
//-----------------------------------------------------------------------------
@@ -1956,6 +2033,12 @@ void CHLClient::View_Render( vrect_t *rect )
19562033

19572034
view->Render( rect );
19582035
UpdatePerfStats();
2036+
#ifdef NEO
2037+
if (engine->IsPlayingDemo())
2038+
{
2039+
FixupDemoSmoother();
2040+
}
2041+
#endif
19592042
}
19602043

19612044

src/game/client/game_controls/SpectatorGUI.cpp

Lines changed: 57 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ void AddSubKeyNamed( KeyValues *pKeys, const char *pszName );
5050
#include "c_team.h"
5151
#include "neo_gamerules.h"
5252
#include "c_neo_player.h"
53+
#include "view.h"
54+
#include "hltvcamera.h"
5355
#endif
5456

5557
// memdbgon must be the last include file in a .cpp file!!!
@@ -986,48 +988,77 @@ CON_COMMAND_F( spec_player, "Spectate player by partial name, steamid, or userid
986988
}
987989
}
988990

989-
#ifdef NEO
991+
#ifdef NEO
990992
CON_COMMAND_F( spec_player_under_mouse, "Spectate player by partial name, steamid, or userid", FCVAR_CLIENTCMD_CAN_EXECUTE )
991993
{
994+
if (engine->IsHLTV() && HLTVCamera()->IsPVSLocked())
995+
{
996+
ConMsg( "%s: HLTV Camera is PVS locked\n", __FUNCTION__ );
997+
return;
998+
}
999+
9921000
C_NEO_Player *pNeoPlayer = C_NEO_Player::GetLocalNEOPlayer();
9931001
if ( !pNeoPlayer || !pNeoPlayer->IsObserver() )
9941002
return;
9951003

996-
if (!engine->IsHLTV() || !HLTVCamera()->IsPVSLocked())
1004+
C_BaseEntity* currentTarget = pNeoPlayer->GetObserverTarget();
1005+
C_NEO_Player *target = nullptr;
1006+
float targetDotProduct = -1;
1007+
for (int i = 1; i <= gpGlobals->maxClients; i++)
9971008
{
998-
C_BaseEntity* currentTarget = pNeoPlayer->GetObserverTarget();
999-
C_NEO_Player *target = nullptr;
1000-
float targetDotProduct = -1;
1001-
for (int i = 1; i < gpGlobals->maxClients; i++)
1009+
C_NEO_Player* pPlayer = ToNEOPlayer(UTIL_PlayerByIndex(i));
1010+
if (currentTarget != pPlayer && pNeoPlayer->IsValidObserverTarget(pPlayer) && pPlayer->IsAlive())
10021011
{
1003-
C_NEO_Player* pPlayer = ToNEOPlayer(UTIL_PlayerByIndex(i));
1004-
if (currentTarget != pPlayer && pNeoPlayer->IsValidObserverTarget(pPlayer) && pPlayer->IsAlive())
1012+
Vector vecToTarget = pPlayer->WorldSpaceCenter() - MainViewOrigin();
1013+
vecToTarget.NormalizeInPlace();
1014+
float dotProduct = DotProduct(MainViewForward(), vecToTarget);
1015+
if (dotProduct > targetDotProduct && dotProduct > 0.5)
10051016
{
1006-
Vector vecForward;
1007-
AngleVectors( pNeoPlayer->EyeAngles(), &vecForward );
1008-
1009-
Vector vecToTarget = pPlayer->WorldSpaceCenter() - pNeoPlayer->EyePosition();
1010-
vecToTarget.NormalizeInPlace();
1011-
float dotProduct = DotProduct(vecForward, vecToTarget);
1012-
if (dotProduct > targetDotProduct && dotProduct > 0.5)
1013-
{
1014-
targetDotProduct = dotProduct;
1015-
target = pPlayer;
1016-
}
1017+
targetDotProduct = dotProduct;
1018+
target = pPlayer;
10171019
}
10181020
}
1021+
}
1022+
1023+
if (target)
1024+
{
1025+
engine->IsHLTV() ? HLTVCamera()->SetPrimaryTarget(target->entindex()) : engine->ClientCmd(VarArgs("spec_player_entity_number %d", target->entindex()));
1026+
}
1027+
}
10191028

1020-
if (target)
1029+
CON_COMMAND_F( spec_fastest_player, "Spectate the fastest player", FCVAR_CLIENTCMD_CAN_EXECUTE )
1030+
{
1031+
C_NEO_Player *pNeoPlayer = C_NEO_Player::GetLocalNEOPlayer();
1032+
if ( !pNeoPlayer || !pNeoPlayer->IsObserver() )
1033+
return;
1034+
1035+
if (engine->IsHLTV())
1036+
{
1037+
if (HLTVCamera()->IsPVSLocked())
10211038
{
1022-
if (engine->IsHLTV())
1023-
{
1024-
HLTVCamera()->SetPrimaryTarget(target->entindex());
1025-
}
1026-
else
1039+
ConMsg( "%s: HLTV Camera is PVS locked\n", __FUNCTION__ );
1040+
return;
1041+
}
1042+
1043+
// We have up to date information on all the players, just do it here
1044+
float fastestSpeedSquared = 0;
1045+
CBasePlayer* pFastestEntity = nullptr;
1046+
for (int i = 1; i <= gpGlobals->maxClients; i++)
1047+
{
1048+
CBasePlayer* pPlayer = UTIL_PlayerByIndex(i);
1049+
if (pPlayer && !pPlayer->IsObserver() && pPlayer->GetAbsVelocity().LengthSqr() > fastestSpeedSquared)
10271050
{
1028-
engine->ClientCmd( VarArgs("spec_player_entity_number %d", target->entindex()) );
1051+
fastestSpeedSquared = pPlayer->GetAbsVelocity().LengthSqr();
1052+
pFastestEntity = pPlayer;
10291053
}
10301054
}
1055+
1056+
if (pFastestEntity)
1057+
HLTVCamera()->SetPrimaryTarget(pFastestEntity->entindex());
1058+
}
1059+
else
1060+
{
1061+
engine->ClientCmd(VarArgs("spectate_fastest_player"));
10311062
}
10321063
}
10331064
#endif // NEO

src/game/client/glow_overlay.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ void CGlowOverlay::UpdateSkyGlowObstruction( float zFar, bool bCacheFullSceneSta
159159
if ( PixelVisibility_IsAvailable() )
160160
{
161161
// Trace a ray at the object.
162+
#ifdef NEO
163+
Vector pos = CurrentViewOrigin() + m_vDirection * zFar * 0.99f;
164+
#else
162165
Vector pos = CurrentViewOrigin() + m_vDirection * zFar * 0.999f;
166+
#endif
163167

164168
// UNDONE: Can probably do only the pixelvis query in this case if you can figure out where
165169
// to put it - or save the position of this trace

0 commit comments

Comments
 (0)