Skip to content

Commit

Permalink
Fix team chooser menu popup when other player in PVS (#511)
Browse files Browse the repository at this point in the history
* `C_NEO_Player::Spawn` is called not only for the local client's
  player, but also for other player (bot or actual) when they're in the
  local client's PVS
* If it's called, then only update the VGUIs if it's either local player
  wasn't set (so it's initially just spawned in) or matches the set local
  player's pointer.
* fixes #510
  • Loading branch information
nullsystem authored Jul 26, 2024
1 parent b8338be commit 902842b
Showing 1 changed file with 28 additions and 21 deletions.
49 changes: 28 additions & 21 deletions mp/src/game/client/neo/c_neo_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ USER_MESSAGE_REGISTER(DamageInfo);

static void __MsgFunc_IdleRespawnShowMenu(bf_read &)
{
if (auto *localPlayer = C_NEO_Player::GetLocalNEOPlayer())
if (C_NEO_Player::GetLocalNEOPlayer())
{
engine->ClientCmd("classmenu");
}
Expand Down Expand Up @@ -973,7 +973,7 @@ void C_NEO_Player::PostThink(void)

SetNextClientThink(CLIENT_THINK_ALWAYS);

if (GetLocalNEOPlayer() == this)
if (IsLocalPlayer())
{
neo_this_client_speed.SetValue(MIN(GetAbsVelocity().Length2D() / GetNormSpeed(), 1.0f));
}
Expand Down Expand Up @@ -1127,7 +1127,10 @@ void C_NEO_Player::CalcDeathCamView(Vector &eyeOrigin, QAngle &eyeAngles, float

void C_NEO_Player::TeamChange(int iNewTeam)
{
engine->ClientCmd(classmenu.GetName());
if (IsLocalPlayer())
{
engine->ClientCmd(classmenu.GetName());
}
BaseClass::TeamChange(iNewTeam);
}

Expand Down Expand Up @@ -1225,31 +1228,35 @@ void C_NEO_Player::Spawn( void )

SetViewOffset(VEC_VIEW_NEOSCALE(this));

// NEO NOTE (nullsystem): Reset Vis/Enabled/MouseInput/Cursor state here, otherwise it can get stuck at situations
for (const auto pname : {PANEL_CLASS, PANEL_TEAM, PANEL_NEO_LOADOUT})
auto *localPlayer = C_NEO_Player::GetLocalNEOPlayer();
if (localPlayer == nullptr || localPlayer == this)
{
if (auto *panel = static_cast<vgui::EditablePanel*>
(GetClientModeNormal()->GetViewport()->FindChildByName(pname)))
// NEO NOTE (nullsystem): Reset Vis/Enabled/MouseInput/Cursor state here, otherwise it can get stuck at situations
for (const auto pname : {PANEL_CLASS, PANEL_TEAM, PANEL_NEO_LOADOUT})
{
panel->SetVisible(false);
panel->SetEnabled(false);
panel->SetMouseInputEnabled(false);
panel->SetCursorAlwaysVisible(false);
//panel->SetKeyBoardInputEnabled(false);
if (auto *panel = static_cast<vgui::EditablePanel*>
(GetClientModeNormal()->GetViewport()->FindChildByName(pname)))
{
panel->SetVisible(false);
panel->SetEnabled(false);
panel->SetMouseInputEnabled(false);
panel->SetCursorAlwaysVisible(false);
//panel->SetKeyBoardInputEnabled(false);
}
}
}

for (auto *hud : gHUD.m_HudList)
{
if (auto *neoHud = dynamic_cast<CNEOHud_ChildElement *>(hud))
for (auto *hud : gHUD.m_HudList)
{
neoHud->resetLastUpdateTime();
if (auto *neoHud = dynamic_cast<CNEOHud_ChildElement *>(hud))
{
neoHud->resetLastUpdateTime();
}
}
}

if (GetTeamNumber() == TEAM_UNASSIGNED)
{
engine->ClientCmd(teammenu.GetName());
if (GetTeamNumber() == TEAM_UNASSIGNED)
{
engine->ClientCmd(teammenu.GetName());
}
}

#if(0)
Expand Down

0 comments on commit 902842b

Please sign in to comment.