ValveSoftware / halflife

Half-Life 1 engine based games
Other
3.72k stars 624 forks source link

Enter key hardcoded to Join Team VGUI Menu when spectating #2316

Open ghost opened 5 years ago

ghost commented 5 years ago

This happens in Half-Life and some mods like Vampire Slayer so I assume it's an engine problem, please correct me if I'm wrong.

Pressing the Enter key will display the jointeam VGUI dialog even if there's something else bound to it.

This can be very bothersome if you bind a command like messagemode to this key.

Steps to reproduce

Additional notes

Since Enter is +use by default, this dialog should display when sending this command when spectating, rather than being hardcoded. Seems like this menu is barely implemented at all, at least in HLDM, since attempting to join any team to exit the spectator mode the game will not recognize the jointeam command

ghost commented 5 years ago

Hello @kisak-valve, with "Half-Life Deathmatch" I meant regular Half-Life, sorry about the confusion, editing the OP now.

While it may affect other games like DMC I haven't tested it.

SamVanheer commented 5 years ago

Can you show a screenshot of this? I'm unable to reproduce this and the jointeam command is not recognized.

I have enter tied to reload and it has never done this before.

JoelTroch commented 5 years ago

@SamVanheer I can reproduce this under the beta branch.

  1. Spectate a game through HLTV.
  2. Press ENTER.
  3. The team menu appears with the "Auto-assign" button and map's description (but the localization isn't made).

I tried with Counter-Strike Condition Zero (beta branch), both in-game spectating and HLTV, can't reproduce there.

ghost commented 5 years ago

image

Tested on both Linux and Windows (using Proton 4.3-2) versions of Half-Life. No beta branch needed.

As @JoelTroch stated, the entire menu lacks localization strings. As an additional note, if you attempt to exit spectator mode this game the console will say the jointeam command doesn't exists.

Seems like this can't be reproduced on games like Counter-Strike because the team systsm along with the VGUIs are completely implemented.

SamVanheer commented 5 years ago

Looks like it's this code: https://github.com/ValveSoftware/halflife/blob/5d761709a31ce1e71488f2668321de05f791b405/cl_dll/vgui_TeamFortressViewport.cpp#L2207-L2212

This is VGUI1 code, the VGUI2 version used by Counter-Strike doesn't have this:

int __cdecl CounterStrikeViewport::KeyInput(CounterStrikeViewport *const this, int down, int keynum, const char *pszCurrentBinding)
{
  return 1;
}

I suspect this was intended to be used for in-game spectators only, meaning if you're in the server and able to join teams to begin with.

Adding this conditional check around it should fix the problem:

if( !gEngfuncs.IsSpectateOnly() )
{
    //Original code here
}

This will enable the feature if you're not connected through HLTV. That still doesn't solve the problem with the enter key being hardcoded to open this menu, but at least HLTV will work properly in this case.

rtxa commented 5 years ago

Please, do not remove this, MiniAG and plugins that make this VGUI menu works depends on this for change team. Example of how to make it work in AMXX https://github.com/rtxa/agmodx/blob/master/valve/addons/amxmodx/scripting/agmodx.sma#L1502-L1524

SamVanheer commented 5 years ago

Is it used in HLTV or only when spectating in-game?

rtxa commented 5 years ago

Is it used in HLTV or only when spectating in-game?

In both, but in HLTV doesn't make sense to change team because you are not playing. Is true that this menu isn't working out of the box, but you can make it work through AMXX or some mods like MiniAG implement them, so don't remove it for normal gameplay, just for HLTV.

0Ky commented 8 months ago
Protocol version 48
Exe version 1.1.2.2/Stdio (valve)
Exe build: 12:23:38 Dec 22 2023 (9920)

I'm also facing the same issue with the latest version of Half-Life 1. When in a local listen server or a multiplayer server and the server has enabled spectators allow_spectators 1.0, after you spectate with the spectate command you are unable to exit spectator mode.

The command jointeam does not exist, when you press the Enter key to bring the team selection VGUI menu I only see #Team_AutoAssign and pressing that will attempt to jointeam, since the command doesn't exist, the console outputs Unknown command: jointeam.