From 35fc1805590a863d73f532fd397ea863c5112266 Mon Sep 17 00:00:00 2001 From: def Date: Sun, 20 Sep 2020 12:16:25 +0200 Subject: [PATCH 1/3] Finish /showothers 2 implementation on server --- src/engine/shared/config_variables.h | 4 ++-- src/game/server/ddracechat.h | 2 +- src/game/server/entities/character.cpp | 4 ++-- src/game/server/entities/dragger.cpp | 4 ++-- src/game/server/entities/plasma.cpp | 4 ++-- src/game/server/gamecontext.cpp | 4 ++-- src/game/server/gameworld.cpp | 2 +- src/game/server/player.cpp | 2 +- src/game/server/player.h | 2 +- src/game/server/teams.cpp | 18 ++++++++++++++---- 10 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index 4fa3eba2c..b0125a7f3 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -286,7 +286,7 @@ MACRO_CONFIG_INT(ClRaceSaveGhost, cl_race_save_ghost, 1, 0, 1, CFGFLAG_CLIENT | MACRO_CONFIG_INT(ClDDRaceScoreBoard, cl_ddrace_scoreboard, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Enable DDRace Scoreboard") MACRO_CONFIG_INT(ClShowDecisecs, cl_show_decisecs, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Show deciseconds in game time") MACRO_CONFIG_INT(SvResetPickups, sv_reset_pickups, 0, 0, 1, CFGFLAG_SERVER | CFGFLAG_GAME, "Whether the weapons are reset on passing the start tile or not") -MACRO_CONFIG_INT(ClShowOthers, cl_show_others, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show players in other teams") +MACRO_CONFIG_INT(ClShowOthers, cl_show_others, 0, 0, 2, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show players in other teams (2 to show own team only)") MACRO_CONFIG_INT(ClShowOthersAlpha, cl_show_others_alpha, 40, 0, 100, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show players in other teams (alpha value, 0 invisible, 100 fully visible)") MACRO_CONFIG_INT(ClOverlayEntities, cl_overlay_entities, 0, 0, 100, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Overlay game tiles with a percentage of opacity") MACRO_CONFIG_INT(ClShowQuads, cl_show_quads, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show quads") @@ -296,7 +296,7 @@ MACRO_CONFIG_COL(ClBackgroundEntitiesColor, cl_background_entities_color, 128, C MACRO_CONFIG_STR(ClBackgroundEntities, cl_background_entities, 100, "", CFGFLAG_CLIENT | CFGFLAG_SAVE, "Background (entities)") MACRO_CONFIG_INT(ClBackgroundShowTilesLayers, cl_background_show_tiles_layers, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Whether draw tiles layers when using custom background (entities)") MACRO_CONFIG_INT(SvShowOthers, sv_show_others, 1, 0, 1, CFGFLAG_SERVER, "Whether players can use the command showothers or not") -MACRO_CONFIG_INT(SvShowOthersDefault, sv_show_others_default, 0, 0, 1, CFGFLAG_SERVER, "Whether players see others by default") +MACRO_CONFIG_INT(SvShowOthersDefault, sv_show_others_default, 0, 0, 2, CFGFLAG_SERVER, "Whether players see others by default (2 for own team)") MACRO_CONFIG_INT(SvShowAllDefault, sv_show_all_default, 0, 0, 1, CFGFLAG_SERVER, "Whether players see all tees by default") MACRO_CONFIG_INT(SvMaxAfkTime, sv_max_afk_time, 0, 0, 9999, CFGFLAG_SERVER, "The time in seconds a player is allowed to be afk (0 = disabled)") MACRO_CONFIG_INT(SvMaxAfkVoteTime, sv_max_afk_vote_time, 300, 0, 9999, CFGFLAG_SERVER, "The time in seconds a player can be afk and his votes still count (0 = disabled)") diff --git a/src/game/server/ddracechat.h b/src/game/server/ddracechat.h index 09400f499..2baa42f78 100644 --- a/src/game/server/ddracechat.h +++ b/src/game/server/ddracechat.h @@ -45,7 +45,7 @@ CHAT_COMMAND("lock", "?i['0'|'1']", CFGFLAG_CHAT|CFGFLAG_SERVER, ConLockTeam, th CHAT_COMMAND("unlock", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConUnlockTeam, this, "Unlock a team") CHAT_COMMAND("invite", "r[player name]", CFGFLAG_CHAT|CFGFLAG_SERVER, ConInviteTeam, this, "Invite a person to a locked team") -CHAT_COMMAND("showothers", "?i['0'|'1']", CFGFLAG_CHAT|CFGFLAG_SERVER, ConShowOthers, this, "Whether to show players from other teams or not (off by default), optional i = 0 for off else for on") +CHAT_COMMAND("showothers", "?i['0'|'1'|'2']", CFGFLAG_CHAT|CFGFLAG_SERVER, ConShowOthers, this, "Whether to show players from other teams or not (off by default), optional i = 0 for off, i = 1 for on, i = 2 for own team only") CHAT_COMMAND("showall", "?i['0'|'1']", CFGFLAG_CHAT|CFGFLAG_SERVER, ConShowAll, this, "Whether to show players at any distance (off by default), optional i = 0 for off else for on") CHAT_COMMAND("specteam", "?i['0'|'1']", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSpecTeam, this, "Whether to show players from other teams when spectating (on by default), optional i = 0 for off else for on") CHAT_COMMAND("ninjajetpack", "?i['0'|'1']", CFGFLAG_CHAT|CFGFLAG_SERVER, ConNinjaJetpack, this, "Whether to use ninja jetpack or not. Makes jetpack look more awesome") diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index d57a4c537..efd7f5e75 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -1223,12 +1223,12 @@ void CCharacter::Snap(int SnappingClient) if(pSnapPlayer->GetTeam() == TEAM_SPECTATORS || pSnapPlayer->IsPaused()) { - if(pSnapPlayer->m_SpectatorID != -1 && !CanCollide(pSnapPlayer->m_SpectatorID) && !pSnapPlayer->m_ShowOthers) + if(pSnapPlayer->m_SpectatorID != -1 && !CanCollide(pSnapPlayer->m_SpectatorID) && (pSnapPlayer->m_ShowOthers == 0 || (pSnapPlayer->m_ShowOthers == 2 && !SameTeam(pSnapPlayer->m_SpectatorID)))) return; else if(pSnapPlayer->m_SpectatorID == -1 && !CanCollide(SnappingClient) && pSnapPlayer->m_SpecTeam) return; } - else if(pSnapChar && !pSnapChar->m_Super && !CanCollide(SnappingClient) && !pSnapPlayer->m_ShowOthers) + else if(pSnapChar && !pSnapChar->m_Super && !CanCollide(SnappingClient) && (pSnapPlayer->m_ShowOthers == 0 || (pSnapPlayer->m_ShowOthers == 2 && !SameTeam(SnappingClient)))) return; } diff --git a/src/game/server/entities/dragger.cpp b/src/game/server/entities/dragger.cpp index 797cb4dac..927813ebc 100644 --- a/src/game/server/entities/dragger.cpp +++ b/src/game/server/entities/dragger.cpp @@ -225,8 +225,8 @@ void CDragger::Snap(int SnappingClient) continue; } - if (Char && Char->IsAlive() && Target && Target->IsAlive() && Target->GetPlayer()->GetCID() != Char->GetPlayer()->GetCID() && !Char->GetPlayer()->m_ShowOthers && - (Char->Teams()->m_Core.GetSolo(SnappingClient) || Char->Teams()->m_Core.GetSolo(Target->GetPlayer()->GetCID()))) + if (Char && Char->IsAlive() && Target && Target->IsAlive() && Target->GetPlayer()->GetCID() != Char->GetPlayer()->GetCID() && (Char->GetPlayer()->m_ShowOthers == 0 || (Char->GetPlayer()->m_ShowOthers == 2 && + (Char->Teams()->m_Core.GetSolo(SnappingClient) || Char->Teams()->m_Core.GetSolo(Target->GetPlayer()->GetCID()))))) { continue; } diff --git a/src/game/server/entities/plasma.cpp b/src/game/server/entities/plasma.cpp index b71ff5faa..b9b877d2a 100644 --- a/src/game/server/entities/plasma.cpp +++ b/src/game/server/entities/plasma.cpp @@ -99,12 +99,12 @@ void CPlasma::Snap(int SnappingClient) if(SnapPlayer && (SnapPlayer->GetTeam() == TEAM_SPECTATORS || SnapPlayer->IsPaused()) && SnapPlayer->m_SpectatorID != -1 && GameServer()->GetPlayerChar(SnapPlayer->m_SpectatorID) && GameServer()->GetPlayerChar(SnapPlayer->m_SpectatorID)->Team() != m_ResponsibleTeam - && !SnapPlayer->m_ShowOthers) + && SnapPlayer->m_ShowOthers != 1) return; if(SnapPlayer && SnapPlayer->GetTeam() != TEAM_SPECTATORS && !SnapPlayer->IsPaused() && SnapChar && SnapChar && SnapChar->Team() != m_ResponsibleTeam - && !SnapPlayer->m_ShowOthers) + && SnapPlayer->m_ShowOthers != 1) return; if(SnapPlayer && (SnapPlayer->GetTeam() == TEAM_SPECTATORS || SnapPlayer->IsPaused()) && SnapPlayer->m_SpectatorID == -1 diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index dfd42650e..8c2eae876 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -1212,12 +1212,12 @@ void CGameContext::OnClientEnter(int ClientID) Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); - if (g_Config.m_SvShowOthersDefault) + if (g_Config.m_SvShowOthersDefault > 0) { if (g_Config.m_SvShowOthers) SendChatTarget(ClientID, "You can see other players. To disable this use DDNet client and type /showothers ."); - m_apPlayers[ClientID]->m_ShowOthers = true; + m_apPlayers[ClientID]->m_ShowOthers = g_Config.m_SvShowOthersDefault; } } m_VoteUpdate = true; diff --git a/src/game/server/gameworld.cpp b/src/game/server/gameworld.cpp index 7edfb99a1..5a2d22ae7 100644 --- a/src/game/server/gameworld.cpp +++ b/src/game/server/gameworld.cpp @@ -188,7 +188,7 @@ void CGameWorld::UpdatePlayerMaps() (!GameServer()->m_apPlayers[i] || GameServer()->m_apPlayers[i]->GetClientVersion() == VERSION_VANILLA || (GameServer()->m_apPlayers[i]->GetClientVersion() >= VERSION_DDRACE && - !GameServer()->m_apPlayers[i]->m_ShowOthers + GameServer()->m_apPlayers[i]->m_ShowOthers != 1 ) ) ) diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index b3f65de54..0191f7607 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -414,7 +414,7 @@ void CPlayer::Snap(int SnappingClient) CPlayer *pSnapPlayer = GameServer()->m_apPlayers[SnappingClient]; ShowSpec = ShowSpec && ( GameServer()->GetDDRaceTeam(id) == GameServer()->GetDDRaceTeam(SnappingClient) - || pSnapPlayer->m_ShowOthers + || pSnapPlayer->m_ShowOthers == 1 || (pSnapPlayer->GetTeam() == TEAM_SPECTATORS || pSnapPlayer->IsPaused()) ); } diff --git a/src/game/server/player.h b/src/game/server/player.h index 9a0199f14..a42af6d0f 100644 --- a/src/game/server/player.h +++ b/src/game/server/player.h @@ -161,7 +161,7 @@ public: bool IsPlaying(); int64 m_Last_KickVote; int64 m_Last_Team; - bool m_ShowOthers; + int m_ShowOthers; bool m_ShowAll; vec2 m_ShowDistance; bool m_SpecTeam; diff --git a/src/game/server/teams.cpp b/src/game/server/teams.cpp index 5ad3c8d4d..e0e110b8b 100644 --- a/src/game/server/teams.cpp +++ b/src/game/server/teams.cpp @@ -389,7 +389,12 @@ int64 CGameTeams::TeamMask(int Team, int ExceptID, int Asker) { // Actions of other players if (!Character(i)) continue; // Player is currently dead - if (!GetPlayer(i)->m_ShowOthers) + if (GetPlayer(i)->m_ShowOthers == 2) + { + if (m_Core.Team(i) != Team && m_Core.Team(i) != TEAM_SUPER) + continue; // In different teams + } + else if (GetPlayer(i)->m_ShowOthers == 0) { if (m_Core.GetSolo(Asker)) continue; // When in solo part don't show others @@ -397,7 +402,7 @@ int64 CGameTeams::TeamMask(int Team, int ExceptID, int Asker) continue; // When in solo part don't show others if (m_Core.Team(i) != Team && m_Core.Team(i) != TEAM_SUPER) continue; // In different teams - } // ShowOthers + } } // See everything of yourself } else if (GetPlayer(i)->m_SpectatorID != SPEC_FREEVIEW) @@ -406,7 +411,12 @@ int64 CGameTeams::TeamMask(int Team, int ExceptID, int Asker) { // Actions of other players if (!Character(GetPlayer(i)->m_SpectatorID)) continue; // Player is currently dead - if (!GetPlayer(i)->m_ShowOthers) + if (GetPlayer(i)->m_ShowOthers == 2) + { + if (m_Core.Team(GetPlayer(i)->m_SpectatorID) != Team && m_Core.Team(GetPlayer(i)->m_SpectatorID) != TEAM_SUPER) + continue; // In different teams + } + else if (GetPlayer(i)->m_ShowOthers == 0) { if (m_Core.GetSolo(Asker)) continue; // When in solo part don't show others @@ -414,7 +424,7 @@ int64 CGameTeams::TeamMask(int Team, int ExceptID, int Asker) continue; // When in solo part don't show others if (m_Core.Team(GetPlayer(i)->m_SpectatorID) != Team && m_Core.Team(GetPlayer(i)->m_SpectatorID) != TEAM_SUPER) continue; // In different teams - } // ShowOthers + } } // See everything of player you're spectating } else From cfd32c357b5aca410c7befb8ae4953fec1fa54ed Mon Sep 17 00:00:00 2001 From: def Date: Sun, 20 Sep 2020 20:38:08 +0200 Subject: [PATCH 2/3] Fix clang-format --- src/game/server/ddracechat.h | 20 ++++++++++---------- src/game/server/entities/dragger.cpp | 3 +-- src/game/server/entities/plasma.cpp | 9 ++------- src/game/server/gamecontext.cpp | 2 +- src/game/server/gameworld.cpp | 5 +---- src/game/server/player.cpp | 6 +----- src/game/server/teams.cpp | 12 ++++++------ 7 files changed, 22 insertions(+), 35 deletions(-) diff --git a/src/game/server/ddracechat.h b/src/game/server/ddracechat.h index 2baa42f78..77068621e 100644 --- a/src/game/server/ddracechat.h +++ b/src/game/server/ddracechat.h @@ -45,16 +45,16 @@ CHAT_COMMAND("lock", "?i['0'|'1']", CFGFLAG_CHAT|CFGFLAG_SERVER, ConLockTeam, th CHAT_COMMAND("unlock", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConUnlockTeam, this, "Unlock a team") CHAT_COMMAND("invite", "r[player name]", CFGFLAG_CHAT|CFGFLAG_SERVER, ConInviteTeam, this, "Invite a person to a locked team") -CHAT_COMMAND("showothers", "?i['0'|'1'|'2']", CFGFLAG_CHAT|CFGFLAG_SERVER, ConShowOthers, this, "Whether to show players from other teams or not (off by default), optional i = 0 for off, i = 1 for on, i = 2 for own team only") -CHAT_COMMAND("showall", "?i['0'|'1']", CFGFLAG_CHAT|CFGFLAG_SERVER, ConShowAll, this, "Whether to show players at any distance (off by default), optional i = 0 for off else for on") -CHAT_COMMAND("specteam", "?i['0'|'1']", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSpecTeam, this, "Whether to show players from other teams when spectating (on by default), optional i = 0 for off else for on") -CHAT_COMMAND("ninjajetpack", "?i['0'|'1']", CFGFLAG_CHAT|CFGFLAG_SERVER, ConNinjaJetpack, this, "Whether to use ninja jetpack or not. Makes jetpack look more awesome") -CHAT_COMMAND("saytime", "?r[player name]", CFGFLAG_CHAT|CFGFLAG_SERVER|CFGFLAG_NONTEEHISTORIC, ConSayTime, this, "Privately messages someone's current time in this current running race (your time by default)") -CHAT_COMMAND("saytimeall", "", CFGFLAG_CHAT|CFGFLAG_SERVER|CFGFLAG_NONTEEHISTORIC, ConSayTimeAll, this, "Publicly messages everyone your current time in this current running race") -CHAT_COMMAND("time", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConTime, this, "Privately shows you your current time in this current running race in the broadcast message") -CHAT_COMMAND("timer", "?s['gametimer'|'broadcast'|'both'|'none'|'cycle']", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSetTimerType, this, "Personal Setting of showing time in either broadcast or game/round timer, timer s, where s = broadcast for broadcast, gametimer for game/round timer, cycle for cycle, both for both, none for no timer and nothing to show current status") -CHAT_COMMAND("r", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConRescue, this, "Teleport yourself out of freeze (use sv_rescue 1 to enable this feature)") -CHAT_COMMAND("rescue", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConRescue, this, "Teleport yourself out of freeze (use sv_rescue 1 to enable this feature)") +CHAT_COMMAND("showothers", "?i['0'|'1'|'2']", CFGFLAG_CHAT | CFGFLAG_SERVER, ConShowOthers, this, "Whether to show players from other teams or not (off by default), optional i = 0 for off, i = 1 for on, i = 2 for own team only") +CHAT_COMMAND("showall", "?i['0'|'1']", CFGFLAG_CHAT | CFGFLAG_SERVER, ConShowAll, this, "Whether to show players at any distance (off by default), optional i = 0 for off else for on") +CHAT_COMMAND("specteam", "?i['0'|'1']", CFGFLAG_CHAT | CFGFLAG_SERVER, ConSpecTeam, this, "Whether to show players from other teams when spectating (on by default), optional i = 0 for off else for on") +CHAT_COMMAND("ninjajetpack", "?i['0'|'1']", CFGFLAG_CHAT | CFGFLAG_SERVER, ConNinjaJetpack, this, "Whether to use ninja jetpack or not. Makes jetpack look more awesome") +CHAT_COMMAND("saytime", "?r[player name]", CFGFLAG_CHAT | CFGFLAG_SERVER | CFGFLAG_NONTEEHISTORIC, ConSayTime, this, "Privately messages someone's current time in this current running race (your time by default)") +CHAT_COMMAND("saytimeall", "", CFGFLAG_CHAT | CFGFLAG_SERVER | CFGFLAG_NONTEEHISTORIC, ConSayTimeAll, this, "Publicly messages everyone your current time in this current running race") +CHAT_COMMAND("time", "", CFGFLAG_CHAT | CFGFLAG_SERVER, ConTime, this, "Privately shows you your current time in this current running race in the broadcast message") +CHAT_COMMAND("timer", "?s['gametimer'|'broadcast'|'both'|'none'|'cycle']", CFGFLAG_CHAT | CFGFLAG_SERVER, ConSetTimerType, this, "Personal Setting of showing time in either broadcast or game/round timer, timer s, where s = broadcast for broadcast, gametimer for game/round timer, cycle for cycle, both for both, none for no timer and nothing to show current status") +CHAT_COMMAND("r", "", CFGFLAG_CHAT | CFGFLAG_SERVER, ConRescue, this, "Teleport yourself out of freeze (use sv_rescue 1 to enable this feature)") +CHAT_COMMAND("rescue", "", CFGFLAG_CHAT | CFGFLAG_SERVER, ConRescue, this, "Teleport yourself out of freeze (use sv_rescue 1 to enable this feature)") CHAT_COMMAND("kill", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConProtectedKill, this, "Kill yourself when kill-protected during a long game (use f1, kill for regular kill)") diff --git a/src/game/server/entities/dragger.cpp b/src/game/server/entities/dragger.cpp index 927813ebc..8ce5bead1 100644 --- a/src/game/server/entities/dragger.cpp +++ b/src/game/server/entities/dragger.cpp @@ -225,8 +225,7 @@ void CDragger::Snap(int SnappingClient) continue; } - if (Char && Char->IsAlive() && Target && Target->IsAlive() && Target->GetPlayer()->GetCID() != Char->GetPlayer()->GetCID() && (Char->GetPlayer()->m_ShowOthers == 0 || (Char->GetPlayer()->m_ShowOthers == 2 && - (Char->Teams()->m_Core.GetSolo(SnappingClient) || Char->Teams()->m_Core.GetSolo(Target->GetPlayer()->GetCID()))))) + if(Char && Char->IsAlive() && Target && Target->IsAlive() && Target->GetPlayer()->GetCID() != Char->GetPlayer()->GetCID() && (Char->GetPlayer()->m_ShowOthers == 0 || (Char->GetPlayer()->m_ShowOthers == 2 && (Char->Teams()->m_Core.GetSolo(SnappingClient) || Char->Teams()->m_Core.GetSolo(Target->GetPlayer()->GetCID()))))) { continue; } diff --git a/src/game/server/entities/plasma.cpp b/src/game/server/entities/plasma.cpp index b9b877d2a..3673f5726 100644 --- a/src/game/server/entities/plasma.cpp +++ b/src/game/server/entities/plasma.cpp @@ -96,15 +96,10 @@ void CPlasma::Snap(int SnappingClient) && (!Tick)) return; - if(SnapPlayer && (SnapPlayer->GetTeam() == TEAM_SPECTATORS || SnapPlayer->IsPaused()) && SnapPlayer->m_SpectatorID != -1 - && GameServer()->GetPlayerChar(SnapPlayer->m_SpectatorID) - && GameServer()->GetPlayerChar(SnapPlayer->m_SpectatorID)->Team() != m_ResponsibleTeam - && SnapPlayer->m_ShowOthers != 1) + if(SnapPlayer && (SnapPlayer->GetTeam() == TEAM_SPECTATORS || SnapPlayer->IsPaused()) && SnapPlayer->m_SpectatorID != -1 && GameServer()->GetPlayerChar(SnapPlayer->m_SpectatorID) && GameServer()->GetPlayerChar(SnapPlayer->m_SpectatorID)->Team() != m_ResponsibleTeam && SnapPlayer->m_ShowOthers != 1) return; - if(SnapPlayer && SnapPlayer->GetTeam() != TEAM_SPECTATORS && !SnapPlayer->IsPaused() && SnapChar - && SnapChar && SnapChar->Team() != m_ResponsibleTeam - && SnapPlayer->m_ShowOthers != 1) + if(SnapPlayer && SnapPlayer->GetTeam() != TEAM_SPECTATORS && !SnapPlayer->IsPaused() && SnapChar && SnapChar && SnapChar->Team() != m_ResponsibleTeam && SnapPlayer->m_ShowOthers != 1) return; if(SnapPlayer && (SnapPlayer->GetTeam() == TEAM_SPECTATORS || SnapPlayer->IsPaused()) && SnapPlayer->m_SpectatorID == -1 diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 8c2eae876..8ae15c870 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -1212,7 +1212,7 @@ void CGameContext::OnClientEnter(int ClientID) Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); - if (g_Config.m_SvShowOthersDefault > 0) + if(g_Config.m_SvShowOthersDefault > 0) { if (g_Config.m_SvShowOthers) SendChatTarget(ClientID, "You can see other players. To disable this use DDNet client and type /showothers ."); diff --git a/src/game/server/gameworld.cpp b/src/game/server/gameworld.cpp index 5a2d22ae7..51aa77149 100644 --- a/src/game/server/gameworld.cpp +++ b/src/game/server/gameworld.cpp @@ -188,10 +188,7 @@ void CGameWorld::UpdatePlayerMaps() (!GameServer()->m_apPlayers[i] || GameServer()->m_apPlayers[i]->GetClientVersion() == VERSION_VANILLA || (GameServer()->m_apPlayers[i]->GetClientVersion() >= VERSION_DDRACE && - GameServer()->m_apPlayers[i]->m_ShowOthers != 1 - ) - ) - ) + GameServer()->m_apPlayers[i]->m_ShowOthers != 1))) Dist[j].first = 1e8; else Dist[j].first = 0; diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 0191f7607..c6675598b 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -412,11 +412,7 @@ void CPlayer::Snap(int SnappingClient) if(SnappingClient >= 0) { CPlayer *pSnapPlayer = GameServer()->m_apPlayers[SnappingClient]; - ShowSpec = ShowSpec && ( - GameServer()->GetDDRaceTeam(id) == GameServer()->GetDDRaceTeam(SnappingClient) - || pSnapPlayer->m_ShowOthers == 1 - || (pSnapPlayer->GetTeam() == TEAM_SPECTATORS || pSnapPlayer->IsPaused()) - ); + ShowSpec = ShowSpec && (GameServer()->GetDDRaceTeam(id) == GameServer()->GetDDRaceTeam(SnappingClient) || pSnapPlayer->m_ShowOthers == 1 || (pSnapPlayer->GetTeam() == TEAM_SPECTATORS || pSnapPlayer->IsPaused())); } if(ShowSpec) diff --git a/src/game/server/teams.cpp b/src/game/server/teams.cpp index e0e110b8b..a056c9869 100644 --- a/src/game/server/teams.cpp +++ b/src/game/server/teams.cpp @@ -389,12 +389,12 @@ int64 CGameTeams::TeamMask(int Team, int ExceptID, int Asker) { // Actions of other players if (!Character(i)) continue; // Player is currently dead - if (GetPlayer(i)->m_ShowOthers == 2) + if(GetPlayer(i)->m_ShowOthers == 2) { - if (m_Core.Team(i) != Team && m_Core.Team(i) != TEAM_SUPER) + if(m_Core.Team(i) != Team && m_Core.Team(i) != TEAM_SUPER) continue; // In different teams } - else if (GetPlayer(i)->m_ShowOthers == 0) + else if(GetPlayer(i)->m_ShowOthers == 0) { if (m_Core.GetSolo(Asker)) continue; // When in solo part don't show others @@ -411,12 +411,12 @@ int64 CGameTeams::TeamMask(int Team, int ExceptID, int Asker) { // Actions of other players if (!Character(GetPlayer(i)->m_SpectatorID)) continue; // Player is currently dead - if (GetPlayer(i)->m_ShowOthers == 2) + if(GetPlayer(i)->m_ShowOthers == 2) { - if (m_Core.Team(GetPlayer(i)->m_SpectatorID) != Team && m_Core.Team(GetPlayer(i)->m_SpectatorID) != TEAM_SUPER) + if(m_Core.Team(GetPlayer(i)->m_SpectatorID) != Team && m_Core.Team(GetPlayer(i)->m_SpectatorID) != TEAM_SUPER) continue; // In different teams } - else if (GetPlayer(i)->m_ShowOthers == 0) + else if(GetPlayer(i)->m_ShowOthers == 0) { if (m_Core.GetSolo(Asker)) continue; // When in solo part don't show others From 3a3d3bcb99f003b4c8420fabe630883335a4af86 Mon Sep 17 00:00:00 2001 From: def Date: Mon, 21 Sep 2020 15:31:55 +0200 Subject: [PATCH 3/3] Fix UpdatePlayerMaps --- src/game/server/gameworld.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/game/server/gameworld.cpp b/src/game/server/gameworld.cpp index 51aa77149..9413a41b9 100644 --- a/src/game/server/gameworld.cpp +++ b/src/game/server/gameworld.cpp @@ -188,7 +188,8 @@ void CGameWorld::UpdatePlayerMaps() (!GameServer()->m_apPlayers[i] || GameServer()->m_apPlayers[i]->GetClientVersion() == VERSION_VANILLA || (GameServer()->m_apPlayers[i]->GetClientVersion() >= VERSION_DDRACE && - GameServer()->m_apPlayers[i]->m_ShowOthers != 1))) + (GameServer()->m_apPlayers[i]->m_ShowOthers == 0 || + (GameServer()->m_apPlayers[i]->m_ShowOthers == 2 && !GameServer()->m_apPlayers[i]->GetCharacter()->SameTeam(j)))))) Dist[j].first = 1e8; else Dist[j].first = 0;