Repository navigation
Add place names to player pings #2189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
dc4cfc3
97b4bce
55cf9b5
e008807
c998296
3ef94fd
805967a
9befeee
6e8e404
9da8ca6
c397b5a
0fd0ca8
348b14c
7743cf5
f06488b
428f07a
558e7fe
2eae6fa
9640cda
db7fa1c
6eed711
167366c
43c593c
e465578
c386bf3
32a4ca7
a64ece5
f246574
62dd24e
1dc2eb0
1d32565
d598dbc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,9 @@ | |
| # Qt Creator | ||
| /build-src-* | ||
|
|
||
| # Rider | ||
| **/.idea | ||
|
|
||
| # CMake build dir | ||
| /src/build | ||
| out | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -32,6 +32,16 @@ ConVar cl_neo_player_pings("cl_neo_player_pings", "1", FCVAR_ARCHIVE | FCVAR_USE | |||||||||||||||||||
| } | ||||||||||||||||||||
| }); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| enum NeoPlayerPingsInSpectate | ||||||||||||||||||||
| { | ||||||||||||||||||||
| NEO_SPECTATE_PINGS_DISABLED = 0, | ||||||||||||||||||||
| NEO_SPECTATE_PINGS_TARGET, | ||||||||||||||||||||
| NEO_SPECTATE_PINGS_ALL, | ||||||||||||||||||||
|
|
||||||||||||||||||||
| NEO_SPECTATE_PINGS_LAST_VALUE = NEO_SPECTATE_PINGS_ALL | ||||||||||||||||||||
| }; | ||||||||||||||||||||
| ConVar cl_neo_player_pings_in_spectate("cl_neo_player_pings_in_spectate", "1", FCVAR_ARCHIVE, "See pings of players playing the game. 0 = disabled, 1 = spectate target team, 2 = all", true, NEO_SPECTATE_PINGS_DISABLED, true, NEO_SPECTATE_PINGS_LAST_VALUE); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| CNEOHud_PlayerPing::CNEOHud_PlayerPing(const char* pElementName, vgui::Panel* parent) | ||||||||||||||||||||
| : CHudElement(pElementName), Panel(parent, pElementName) | ||||||||||||||||||||
| { | ||||||||||||||||||||
|
|
@@ -109,45 +119,105 @@ void CNEOHud_PlayerPing::Init(void) | |||||||||||||||||||
| //----------------------------------------------------------------------------- | ||||||||||||||||||||
| void CNEOHud_PlayerPing::FireGameEvent(IGameEvent* event) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| auto eventName = event->GetName(); | ||||||||||||||||||||
| const auto eventName = event->GetName(); | ||||||||||||||||||||
| if (!Q_stricmp(eventName, "player_ping")) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| if (!cl_neo_player_pings.GetBool()) | ||||||||||||||||||||
| OnPlayerPing(event); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else if (!Q_stricmp(eventName, "round_start")) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| HideAllPings(); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else if (!Q_stricmp(eventName, "player_team")) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| auto player = UTIL_PlayerByUserId(event->GetInt("userid")); | ||||||||||||||||||||
| if (player && player->IsLocalPlayer()) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| HideAllPings(); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const int userID = event->GetInt("userid"); | ||||||||||||||||||||
| const int playerIndex = engine->GetPlayerForUserID(userID); | ||||||||||||||||||||
| if (GetClientVoiceMgr()->IsPlayerBlocked(playerIndex) || (!NEORules()->IsTeamplay() && playerIndex != GetLocalPlayerIndex())) | ||||||||||||||||||||
| void CNEOHud_PlayerPing::OnPlayerPing(const IGameEvent* event) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| // This is already checked by the emitter side, but we check again because it could arrive late (dynamic custom rule change etc.) | ||||||||||||||||||||
| if (!NEORules() || !NEORules()->ArePingsAllowed()) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
+143
to
+147
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the send-side check gone, only the null guard is needed here. Moving ArePingsAllowed to another area...
Suggested change
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| if (!cl_neo_player_pings.GetBool()) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const auto localPlayer = C_NEO_Player::GetLocalNEOPlayer(); | ||||||||||||||||||||
| Assert(localPlayer); | ||||||||||||||||||||
| const auto localTeamNumber = localPlayer->GetTeamNumber(); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const int pingerIndex = engine->GetPlayerForUserID(event->GetInt("userid")); | ||||||||||||||||||||
| Assert(pingerIndex >= 0); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const bool isOwnPing = (pingerIndex == localPlayer->entindex()); | ||||||||||||||||||||
| if (!isOwnPing) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| if (pingerIndex == 0 || GetClientVoiceMgr()->IsPlayerBlocked(pingerIndex)) | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Outside teamplay, only other players' pings get dropped, so your own still shows.
Suggested change
|
||||||||||||||||||||
| { | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const int localTeam = GetLocalPlayerTeam(); | ||||||||||||||||||||
| const int playerTeam = event->GetInt("playerteam"); | ||||||||||||||||||||
| if (localTeam != TEAM_SPECTATOR && playerTeam != localTeam) | ||||||||||||||||||||
| const int pingRecipientTeam = event->GetInt("playerteam"); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (localTeamNumber == TEAM_SPECTATOR) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| const C_BaseEntity* obsTarget; | ||||||||||||||||||||
| switch (cl_neo_player_pings_in_spectate.GetInt()) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| case NEO_SPECTATE_PINGS_DISABLED: | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| case NEO_SPECTATE_PINGS_TARGET: | ||||||||||||||||||||
| obsTarget = localPlayer->GetObserverTarget(); | ||||||||||||||||||||
| if (!obsTarget || obsTarget->GetTeamNumber() != pingRecipientTeam) | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| case NEO_SPECTATE_PINGS_ALL: | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| default: | ||||||||||||||||||||
| Warning("%s: unhandled enum case %d\n", __FUNCTION__, cl_neo_player_pings_in_spectate.GetInt()); | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const Vector worldpos = Vector(event->GetInt("pingx"), event->GetInt("pingy"), event->GetInt("pingz")); | ||||||||||||||||||||
| bool ghosterPing = event->GetBool("ghosterping"); | ||||||||||||||||||||
| SetPos(playerIndex - 1, playerTeam, worldpos, ghosterPing); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else if (!Q_stricmp(eventName, "round_start")) | ||||||||||||||||||||
| else if (localTeamNumber != pingRecipientTeam) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| HideAllPings(); | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else if (!Q_stricmp(eventName, "player_team")) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const int pingerSlot = pingerIndex - 1; | ||||||||||||||||||||
| Assert(pingerSlot >= 0); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const Vector worldpos(event->GetInt("pingx"), event->GetInt("pingy"), event->GetInt("pingz")); | ||||||||||||||||||||
| const bool ghosterPing = event->GetBool("ghosterping"); | ||||||||||||||||||||
| SetPos(pingerSlot, pingRecipientTeam, worldpos, ghosterPing); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const bool thisIsPredictedPing = !event->GetBool("server", false); | ||||||||||||||||||||
| if (thisIsPredictedPing) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| auto player = UTIL_PlayerByUserId(event->GetInt("userid")); | ||||||||||||||||||||
| if (player && player->IsLocalPlayer()) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| HideAllPings(); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| // don't print predicted (bogus) placenames; we only wanna predict the in-world visuals but not the place text | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (isOwnPing) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| static ConVarRef cl_neo_player_pings_print_own("cl_neo_player_pings_print_own"); | ||||||||||||||||||||
| Assert(cl_neo_player_pings_print_own.IsValid()); | ||||||||||||||||||||
| if (!cl_neo_player_pings_print_own.GetBool()) | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const bool placeIsExact = event->GetBool("place_exact"); | ||||||||||||||||||||
| const char* placeName = event->GetString("place_name"); | ||||||||||||||||||||
| NotifyPing(pingerSlot, placeName, placeIsExact); | ||||||||||||||||||||
|
sunmachine marked this conversation as resolved.
Resolved
|
||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| void CNEOHud_PlayerPing::LevelShutdown(void) | ||||||||||||||||||||
|
|
@@ -156,15 +226,6 @@ void CNEOHud_PlayerPing::LevelShutdown(void) | |||||||||||||||||||
| m_flNextPingSoundTime = 0.f; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| enum NeoPlayerPingsInSpectate | ||||||||||||||||||||
| { | ||||||||||||||||||||
| NEO_SPECTATE_PINGS_DISABLED = 0, | ||||||||||||||||||||
| NEO_SPECTATE_PINGS_TARGET, | ||||||||||||||||||||
| NEO_SPECTATE_PINGS_ALL, | ||||||||||||||||||||
|
|
||||||||||||||||||||
| NEO_SPECTATE_PINGS_LAST_VALUE = NEO_SPECTATE_PINGS_ALL | ||||||||||||||||||||
| }; | ||||||||||||||||||||
| ConVar cl_neo_player_pings_in_spectate("cl_neo_player_pings_in_spectate", "1", FCVAR_ARCHIVE, "See pings of players playing the game. 0 = disabled, 1 = spectate target team, 2 = all", true, NEO_SPECTATE_PINGS_DISABLED, true, NEO_SPECTATE_PINGS_LAST_VALUE); | ||||||||||||||||||||
| void CNEOHud_PlayerPing::DrawNeoHudElement() | ||||||||||||||||||||
| { | ||||||||||||||||||||
| if (!ShouldDraw()) | ||||||||||||||||||||
|
|
@@ -315,7 +376,8 @@ void CNEOHud_PlayerPing::UpdateDistanceToPlayer(C_BasePlayer* player, const int | |||||||||||||||||||
| m_iPlayerPings[playerSlot].noLineOfSight = tr.fraction < 0.999; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| void CNEOHud_PlayerPing::SetPos(const int playerSlot, const int playerTeam, const Vector& pos, bool ghosterPing) { | ||||||||||||||||||||
| void CNEOHud_PlayerPing::SetPos(const int playerSlot, const int playerTeam, const Vector& pos, bool ghosterPing) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| constexpr float PLAYER_PING_LIFETIME = 8; | ||||||||||||||||||||
| auto localPlayer = C_NEO_Player::GetLocalNEOPlayer(); | ||||||||||||||||||||
| if (!localPlayer) { return; } | ||||||||||||||||||||
|
|
@@ -326,51 +388,38 @@ void CNEOHud_PlayerPing::SetPos(const int playerSlot, const int playerTeam, cons | |||||||||||||||||||
| m_iPlayerPings[playerSlot].ghosterPing = ghosterPing; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| UpdateDistanceToPlayer(localPlayer, playerSlot); | ||||||||||||||||||||
| const int playerPingsInSpectate = cl_neo_player_pings_in_spectate.GetInt(); | ||||||||||||||||||||
| if (GetLocalPlayerTeam() == TEAM_SPECTATOR && playerPingsInSpectate != NEO_SPECTATE_PINGS_ALL) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| if (playerPingsInSpectate == NEO_SPECTATE_PINGS_DISABLED) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| int spectateTargetTeam = TEAM_UNASSIGNED; | ||||||||||||||||||||
| if (auto observerTarget = localPlayer->GetObserverTarget()) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| spectateTargetTeam = observerTarget->GetTeamNumber(); | ||||||||||||||||||||
| if (playerTeam != spectateTargetTeam) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else | ||||||||||||||||||||
| { | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| NotifyPing(playerSlot); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ConVar snd_ping_volume("snd_ping_volume", "0.33", FCVAR_ARCHIVE, "Player ping volume", true, 0.f, true, 1.f); | ||||||||||||||||||||
| ConVar cl_neo_player_pings_chat_message("cl_neo_player_pings_chat_message", "1", FCVAR_ARCHIVE, "Show message in chat for player pings.", true, 0, true, 1); // NEO TODO (Adam) custom chat filter instead? | ||||||||||||||||||||
| ConVar cl_neo_player_pings_time_between_sounds("cl_neo_player_pings_time_between_sounds", "0", FCVAR_ARCHIVE, "Minimum time between two ping sounds", true, 0, false, 0); | ||||||||||||||||||||
| void CNEOHud_PlayerPing::NotifyPing(const int playerSlot) | ||||||||||||||||||||
| #ifdef _DEBUG | ||||||||||||||||||||
| ConVar cl_neo_player_pings_skip_text_for_bots("cl_neo_player_pings_skip_text_for_bots", "1", FCVAR_DONTRECORD); | ||||||||||||||||||||
| #endif | ||||||||||||||||||||
| void CNEOHud_PlayerPing::NotifyPing(const int playerSlot, const char* placeName, bool placeIsExact) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| C_NEO_Player* pPlayer = static_cast<C_NEO_Player*>(UTIL_PlayerByIndex(playerSlot + 1)); | ||||||||||||||||||||
| if (!pPlayer || pPlayer->IsLocalPlayer()) | ||||||||||||||||||||
| if (!pPlayer) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (cl_neo_player_pings_chat_message.GetBool()) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| // Skip text notification for bots | ||||||||||||||||||||
| if (g_PR && !g_PR->IsFakePlayer(playerSlot + 1)) | ||||||||||||||||||||
| if ( | ||||||||||||||||||||
| ( g_PR && !g_PR->IsFakePlayer(playerSlot + 1) ) | ||||||||||||||||||||
| #ifdef _DEBUG | ||||||||||||||||||||
| || !cl_neo_player_pings_skip_text_for_bots.GetBool() | ||||||||||||||||||||
| #endif | ||||||||||||||||||||
| ) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| CBaseHudChat* hudChat = (CBaseHudChat*)GET_HUDELEMENT(CHudChat); | ||||||||||||||||||||
| if (hudChat) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| hudChat->ChatPrintf(0, CHAT_FILTER_NONE, "%s pinged a location\n", pPlayer->GetNeoPlayerName()); | ||||||||||||||||||||
| hudChat->ChatPrintf(0, CHAT_FILTER_NONE, "%s pinged %s%s\n", | ||||||||||||||||||||
| pPlayer->GetNeoPlayerName(), | ||||||||||||||||||||
| (placeIsExact || !placeName || !*placeName) ? "" : "near ", // only specify "near" for concrete callouts | ||||||||||||||||||||
| (placeName && *placeName) ? placeName : "a location"); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -450,6 +450,17 @@ class CNEORules : public CHL2MPRules, public CGameEventListener | |
| bool IsClassFull(int team, int classId) const; | ||
| int GetFallbackClass(int team, int preferredClass) const; | ||
|
|
||
| inline bool ArePingsAllowed() | ||
| { | ||
| constexpr auto modesWhereWeUseSaneLogic = NEO_GAME_TYPE_CTG; | ||
| if (GetGameType() != modesWhereWeUseSaneLogic) | ||
| { | ||
| return true; | ||
| } | ||
| // Only allow pings for game modes with friendlies, because it makes no sense to send pings to your enemies. | ||
| return IsTeamplay(); | ||
| } | ||
|
Comment on lines
+453
to
+462
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, so a second design question, maybe for you and @DESTROYGIRL to chat about from their contribution in #2032.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in 1d32565 - I think the behaviour introduced by #2032 is correct, so I've simply updated the condition to call the new The commit 1d32565 is essentially a no-op at this moment (since it just inlines to what we already had), but it makes the intent more explicit in the spirit of a single source of truth.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Rainyan there might be a contradiction if I'm reading
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Oh, I see what you mean now. But still, I assume we would still not want to print pings for non-collaborative modes, since if everyone is your enemy it just doesn't make very much sense as a mechanic to be sending pings in the first place(?)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do I undestand it correctly you're requesting I preserve the ability for free-for-all DM players to be able to ping stuff just for themselves? Not saying that as a rhetorical question, but just to make it clear what exactly is the behaviour you would hope I preserve here; this might be a stupid question. (Systematically I guess it would be cool if we had some kind of gamerules sanity checker for these kinds of situations, but anyways.)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bingo! And that's per #2032 specifically, which is why I framed it up top as a contradiction I was observing. Edit: Not a stupid question. 👍
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You know what, at this point I just don't care anymore. Realistically, we're never going to release this game, nor am I never going to get hired anywhere, so none of this has any practical meaning besides some kind of ridiculous intellectual exercise that I'm too poor to play along with. Whatever edge case you wanted to change here, I'm sure you can throw at Claude and it'll come up with a solution faster and more correct than I ever could. I don't think there's anything for me to do here anymore, in this PR, or in this repo, or in this ridiculous line of career where apparently human engineering is just not worthwhile anymore, and I'm tired to pretend otherwise. Godspeed to you guys, it was a good run.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In case you're still willing to humour this PR after my meltdown, I have addressed the aforementioned in d598dbc. If that's still insufficient then I frankly don't know what we are even building here but hopefully you will have a better idea.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just glad to see and read an update dude, hope you're well man. I'll give this proper thought again soon, this week is a life-heavy week!! |
||
|
|
||
| public: | ||
| #ifdef GAME_DLL | ||
| // Workaround for bot spawning. See Bot_f() for details. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.