add enum for ShowOthers value

This commit is contained in:
c0d3d3v 2022-03-03 22:56:32 +01:00
parent 300cdf864d
commit 8ddd53ab62
No known key found for this signature in database
GPG key ID: 068AF680530DFF31
10 changed files with 34 additions and 26 deletions

View file

@ -2495,18 +2495,17 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
UI()->DoLabelScaled(&Label, Localize("Alpha"), 14.0f, TEXTALIGN_LEFT);
g_Config.m_ClShowOthersAlpha = (int)(UIEx()->DoScrollbarH(&g_Config.m_ClShowOthersAlpha, &Button, g_Config.m_ClShowOthersAlpha / 100.0f) * 100.0f);
if(DoButton_CheckBox(&g_Config.m_ClShowOthers, Localize("Show others"), g_Config.m_ClShowOthers == 1, &LeftLeft))
if(DoButton_CheckBox(&g_Config.m_ClShowOthers, Localize("Show others"), g_Config.m_ClShowOthers == SHOW_OTHERS_ON, &LeftLeft))
{
g_Config.m_ClShowOthers = g_Config.m_ClShowOthers != 1 ? 1 : 0;
g_Config.m_ClShowOthers = g_Config.m_ClShowOthers != SHOW_OTHERS_ON ? SHOW_OTHERS_ON : SHOW_OTHERS_OFF;
}
}
Left.HSplitTop(20.0f, &Button, &Left);
bool ShowOwnTeam = g_Config.m_ClShowOthers == 2;
static int s_ShowOwnTeamID = 0;
if(DoButton_CheckBox(&s_ShowOwnTeamID, Localize("Show others (own team only)"), ShowOwnTeam, &Button))
if(DoButton_CheckBox(&s_ShowOwnTeamID, Localize("Show others (own team only)"), g_Config.m_ClShowOthers == SHOW_OTHERS_ONLY_TEAM, &Button))
{
g_Config.m_ClShowOthers = g_Config.m_ClShowOthers != 2 ? 2 : 0;
g_Config.m_ClShowOthers = g_Config.m_ClShowOthers != SHOW_OTHERS_ONLY_TEAM ? SHOW_OTHERS_ONLY_TEAM : SHOW_OTHERS_OFF;
}
Left.HSplitTop(20.0f, &Button, &Left);

View file

@ -276,8 +276,8 @@ void CGameClient::OnInit()
m_DDRaceMsgSent[0] = false;
m_DDRaceMsgSent[1] = false;
m_ShowOthers[0] = -1;
m_ShowOthers[1] = -1;
m_ShowOthers[0] = SHOW_OTHERS_NOT_SET;
m_ShowOthers[1] = SHOW_OTHERS_NOT_SET;
m_SwitchStateTeam[0] = -1;
m_SwitchStateTeam[1] = -1;
@ -511,8 +511,8 @@ void CGameClient::OnReset()
m_Teams.Reset();
m_DDRaceMsgSent[0] = false;
m_DDRaceMsgSent[1] = false;
m_ShowOthers[0] = -1;
m_ShowOthers[1] = -1;
m_ShowOthers[0] = SHOW_OTHERS_NOT_SET;
m_ShowOthers[1] = SHOW_OTHERS_NOT_SET;
m_LastZoom = .0;
m_LastScreenAspect = .0;
@ -654,7 +654,7 @@ void CGameClient::OnRender()
void CGameClient::OnDummyDisconnect()
{
m_DDRaceMsgSent[1] = false;
m_ShowOthers[1] = -1;
m_ShowOthers[1] = SHOW_OTHERS_NOT_SET;
m_LastNewPredictedTick[1] = -1;
m_PredictedDummyID = -1;
}
@ -1605,7 +1605,7 @@ void CGameClient::OnNewSnapshot()
m_DDRaceMsgSent[i] = true;
}
if(m_ShowOthers[g_Config.m_ClDummy] == -1 || (m_ShowOthers[g_Config.m_ClDummy] != -1 && m_ShowOthers[g_Config.m_ClDummy] != g_Config.m_ClShowOthers))
if(m_ShowOthers[g_Config.m_ClDummy] == SHOW_OTHERS_NOT_SET || (m_ShowOthers[g_Config.m_ClDummy] != SHOW_OTHERS_NOT_SET && m_ShowOthers[g_Config.m_ClDummy] != g_Config.m_ClShowOthers))
{
{
CNetMsg_Cl_ShowOthers Msg;

View file

@ -167,6 +167,15 @@ enum
//COREEVENT_HOOK_TELE=0x80,
};
// show others values - do not change them
enum
{
SHOW_OTHERS_NOT_SET = -1, // show others value before it is set
SHOW_OTHERS_OFF = 0, // show no other players in solo or other teams
SHOW_OTHERS_ON = 1, // show all other players in solo and other teams
SHOW_OTHERS_ONLY_TEAM = 2 // show players that are in solo and are in the same team
};
class CWorldCore
{
public:

View file

@ -1161,12 +1161,12 @@ bool CCharacter::CanSnapCharacter(int SnappingClient)
if(pSnapPlayer->GetTeam() == TEAM_SPECTATORS || pSnapPlayer->IsPaused())
{
if(pSnapPlayer->m_SpectatorID != -1 && !CanCollide(pSnapPlayer->m_SpectatorID) && (pSnapPlayer->m_ShowOthers == 0 || (pSnapPlayer->m_ShowOthers == 2 && !SameTeam(pSnapPlayer->m_SpectatorID))))
if(pSnapPlayer->m_SpectatorID != -1 && !CanCollide(pSnapPlayer->m_SpectatorID) && (pSnapPlayer->m_ShowOthers == SHOW_OTHERS_OFF || (pSnapPlayer->m_ShowOthers == SHOW_OTHERS_ONLY_TEAM && !SameTeam(pSnapPlayer->m_SpectatorID))))
return false;
else if(pSnapPlayer->m_SpectatorID == -1 && !CanCollide(SnappingClient) && pSnapPlayer->m_SpecTeam && !SameTeam(SnappingClient))
return false;
}
else if(pSnapChar && !pSnapChar->m_Super && !CanCollide(SnappingClient) && (pSnapPlayer->m_ShowOthers == 0 || (pSnapPlayer->m_ShowOthers == 2 && !SameTeam(SnappingClient))))
else if(pSnapChar && !pSnapChar->m_Super && !CanCollide(SnappingClient) && (pSnapPlayer->m_ShowOthers == SHOW_OTHERS_OFF || (pSnapPlayer->m_ShowOthers == SHOW_OTHERS_ONLY_TEAM && !SameTeam(SnappingClient))))
return false;
return true;

View file

@ -243,7 +243,7 @@ void CDragger::Snap(int SnappingClient)
if(!pChar && !pTarget && m_CaughtTeam != 0)
continue;
if(pChar && pTarget && pTarget->GetPlayer()->GetCID() != pChar->GetPlayer()->GetCID() && ((pChar->GetPlayer()->m_ShowOthers == 0 && (pChar->Teams()->m_Core.GetSolo(SnappingClient) || pChar->Teams()->m_Core.GetSolo(pTarget->GetPlayer()->GetCID()))) || (pChar->GetPlayer()->m_ShowOthers == 2 && !pTarget->SameTeam(SnappingClient))))
if(pChar && pTarget && pTarget->GetPlayer()->GetCID() != pChar->GetPlayer()->GetCID() && ((pChar->GetPlayer()->m_ShowOthers == SHOW_OTHERS_OFF && (pChar->Teams()->m_Core.GetSolo(SnappingClient) || pChar->Teams()->m_Core.GetSolo(pTarget->GetPlayer()->GetCID()))) || (pChar->GetPlayer()->m_ShowOthers == SHOW_OTHERS_ONLY_TEAM && !pTarget->SameTeam(SnappingClient))))
{
continue;
}

View file

@ -94,10 +94,10 @@ void CPlasma::Snap(int SnappingClient)
if(SnapChar && SnapChar->IsAlive() && (m_Layer == LAYER_SWITCH && m_Number > 0 && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[SnapChar->Team()]) && (!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 != SHOW_OTHERS_ON)
return;
if(SnapPlayer && SnapPlayer->GetTeam() != TEAM_SPECTATORS && !SnapPlayer->IsPaused() && SnapChar && SnapChar->Team() != m_ResponsibleTeam && SnapPlayer->m_ShowOthers != 1)
if(SnapPlayer && SnapPlayer->GetTeam() != TEAM_SPECTATORS && !SnapPlayer->IsPaused() && SnapChar && SnapChar->Team() != m_ResponsibleTeam && SnapPlayer->m_ShowOthers != SHOW_OTHERS_ON)
return;
if(SnapPlayer && (SnapPlayer->GetTeam() == TEAM_SPECTATORS || SnapPlayer->IsPaused()) && SnapPlayer->m_SpectatorID == -1 && SnapChar && SnapChar->Team() != m_ResponsibleTeam && SnapPlayer->m_SpecTeam)

View file

@ -1302,7 +1302,7 @@ void CGameContext::OnClientEnter(int ClientID)
if(g_Config.m_SvWelcome[0] != 0)
SendChatTarget(ClientID, g_Config.m_SvWelcome);
if(g_Config.m_SvShowOthersDefault > 0)
if(g_Config.m_SvShowOthersDefault > SHOW_OTHERS_OFF)
{
if(g_Config.m_SvShowOthers)
SendChatTarget(ClientID, "You can see other players. To disable this use DDNet client and type /showothers .");
@ -3194,7 +3194,7 @@ void CGameContext::OnInit(/*class IKernel *pKernel*/)
g_Config.m_SvOldTeleportWeapons = 0;
g_Config.m_SvTeleportHoldHook = 0;
g_Config.m_SvTeam = SV_TEAM_ALLOWED;
g_Config.m_SvShowOthersDefault = 0;
g_Config.m_SvShowOthersDefault = SHOW_OTHERS_OFF;
if(Collision()->m_NumSwitchers > 0)
for(int i = 0; i < Collision()->m_NumSwitchers + 1; ++i)
@ -3210,7 +3210,7 @@ void CGameContext::OnInit(/*class IKernel *pKernel*/)
if(g_Config.m_SvSoloServer)
{
g_Config.m_SvTeam = SV_TEAM_FORCED_SOLO;
g_Config.m_SvShowOthersDefault = 1;
g_Config.m_SvShowOthersDefault = SHOW_OTHERS_ON;
Tuning()->Set("player_collision", 0);
Tuning()->Set("player_hooking", 0);

View file

@ -201,8 +201,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 == 0 ||
(GameServer()->m_apPlayers[i]->m_ShowOthers == 2 && !GameServer()->m_apPlayers[i]->GetCharacter()->SameTeam(j))))))
(GameServer()->m_apPlayers[i]->m_ShowOthers == SHOW_OTHERS_OFF ||
(GameServer()->m_apPlayers[i]->m_ShowOthers == SHOW_OTHERS_ONLY_TEAM && !GameServer()->m_apPlayers[i]->GetCharacter()->SameTeam(j))))))
Dist[j].first = 1e8;
else
Dist[j].first = 0;

View file

@ -433,7 +433,7 @@ void CPlayer::Snap(int SnappingClient)
if(SnappingClient >= 0)
{
CPlayer *pSnapPlayer = GameServer()->m_apPlayers[SnappingClient];
ShowSpec = ShowSpec && (GameServer()->GetDDRaceTeam(m_ClientID) == GameServer()->GetDDRaceTeam(SnappingClient) || pSnapPlayer->m_ShowOthers == 1 || (pSnapPlayer->GetTeam() == TEAM_SPECTATORS || pSnapPlayer->IsPaused()));
ShowSpec = ShowSpec && (GameServer()->GetDDRaceTeam(m_ClientID) == GameServer()->GetDDRaceTeam(SnappingClient) || pSnapPlayer->m_ShowOthers == SHOW_OTHERS_ON || (pSnapPlayer->GetTeam() == TEAM_SPECTATORS || pSnapPlayer->IsPaused()));
}
if(ShowSpec)

View file

@ -499,12 +499,12 @@ int64_t 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 == SHOW_OTHERS_ONLY_TEAM)
{
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 == SHOW_OTHERS_OFF)
{
if(m_Core.GetSolo(Asker))
continue; // When in solo part don't show others
@ -521,12 +521,12 @@ int64_t 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 == SHOW_OTHERS_ONLY_TEAM)
{
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 == SHOW_OTHERS_OFF)
{
if(m_Core.GetSolo(Asker))
continue; // When in solo part don't show others