mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 09:34:19 +00:00
Added possibility to deny changing of team after a set_team for a certain amount of time. Added server setting to do this automatically for spec votes. fixes #640.
This commit is contained in:
parent
bf6ca3e33d
commit
14f98a9ded
|
@ -196,7 +196,7 @@ void CGameClient::OnConsoleInit()
|
|||
Console()->Register("restart", "?i", CFGFLAG_SERVER, 0, 0, "Restart in x seconds");
|
||||
Console()->Register("broadcast", "r", CFGFLAG_SERVER, 0, 0, "Broadcast message");
|
||||
Console()->Register("say", "r", CFGFLAG_SERVER, 0, 0, "Say in chat");
|
||||
Console()->Register("set_team", "ii", CFGFLAG_SERVER, 0, 0, "Set team of player to team");
|
||||
Console()->Register("set_team", "ii?i", CFGFLAG_SERVER, 0, 0, "Set team of player to team");
|
||||
Console()->Register("set_team_all", "i", CFGFLAG_SERVER, 0, 0, "Set team of all players to team");
|
||||
Console()->Register("add_vote", "sr", CFGFLAG_SERVER, 0, 0, "Add a voting option");
|
||||
Console()->Register("remove_vote", "s", CFGFLAG_SERVER, 0, 0, "remove a voting option");
|
||||
|
|
|
@ -738,7 +738,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
|
||||
str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to move '%s' to spectators (%s)", Server()->ClientName(ClientID), Server()->ClientName(SpectateID), pReason);
|
||||
str_format(aDesc, sizeof(aDesc), "move '%s' to spectators", Server()->ClientName(SpectateID));
|
||||
str_format(aCmd, sizeof(aCmd), "set_team %d -1", SpectateID);
|
||||
str_format(aCmd, sizeof(aCmd), "set_team %d -1 %d", SpectateID, g_Config.m_SvVoteSpectateRejoindelay*60);
|
||||
}
|
||||
|
||||
if(aCmd[0])
|
||||
|
@ -774,6 +774,15 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
if(pPlayer->GetTeam() == pMsg->m_Team || (g_Config.m_SvSpamprotection && pPlayer->m_LastSetTeam && pPlayer->m_LastSetTeam+Server()->TickSpeed()*3 > Server()->Tick()))
|
||||
return;
|
||||
|
||||
if(pPlayer->m_TeamChangeTick > Server()->Tick())
|
||||
{
|
||||
int TimeLeft = (pPlayer->m_TeamChangeTick - Server()->Tick())/Server()->TickSpeed();
|
||||
char aBuf[128];
|
||||
str_format(aBuf, sizeof(aBuf), "Time to wait before changing team: %02d:%02d", TimeLeft/60, TimeLeft%60);
|
||||
SendBroadcast(aBuf, ClientID);
|
||||
return;
|
||||
}
|
||||
|
||||
// Switch team on given client and kill/respawn him
|
||||
if(m_pController->CanJoinTeam(pMsg->m_Team, ClientID))
|
||||
{
|
||||
|
@ -784,6 +793,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
m_VoteUpdate = true;
|
||||
pPlayer->SetTeam(pMsg->m_Team);
|
||||
(void)m_pController->CheckTeamBalance();
|
||||
pPlayer->m_TeamChangeTick = Server()->Tick();
|
||||
}
|
||||
else
|
||||
SendBroadcast("Teams must be balanced, please join other team", ClientID);
|
||||
|
@ -1025,6 +1035,9 @@ void CGameContext::ConSetTeam(IConsole::IResult *pResult, void *pUserData)
|
|||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
int ClientID = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
|
||||
int Team = clamp(pResult->GetInteger(1), -1, 1);
|
||||
int Delay = 0;
|
||||
if(pResult->NumArguments() > 2)
|
||||
Delay = clamp(pResult->GetInteger(2), 0, 1000);
|
||||
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "moved client %d to team %d", ClientID, Team);
|
||||
|
@ -1033,6 +1046,7 @@ void CGameContext::ConSetTeam(IConsole::IResult *pResult, void *pUserData)
|
|||
if(!pSelf->m_apPlayers[ClientID])
|
||||
return;
|
||||
|
||||
pSelf->m_apPlayers[ClientID]->m_TeamChangeTick = pSelf->Server()->Tick()+pSelf->Server()->TickSpeed()*Delay;
|
||||
pSelf->m_apPlayers[ClientID]->SetTeam(Team);
|
||||
(void)pSelf->m_pController->CheckTeamBalance();
|
||||
}
|
||||
|
@ -1249,7 +1263,7 @@ void CGameContext::ConForceVote(IConsole::IResult *pResult, void *pUserData)
|
|||
return;
|
||||
}
|
||||
|
||||
str_format(aBuf, sizeof(aBuf), "set_team %d -1", SpectateID);
|
||||
str_format(aBuf, sizeof(aBuf), "set_team %d -1 %d", SpectateID, g_Config.m_SvVoteSpectateRejoindelay*60);
|
||||
pSelf->Console()->ExecuteLine(aBuf);
|
||||
}
|
||||
}
|
||||
|
@ -1306,7 +1320,7 @@ void CGameContext::OnConsoleInit()
|
|||
Console()->Register("restart", "?i", CFGFLAG_SERVER|CFGFLAG_STORE, ConRestart, this, "");
|
||||
Console()->Register("broadcast", "r", CFGFLAG_SERVER, ConBroadcast, this, "");
|
||||
Console()->Register("say", "r", CFGFLAG_SERVER, ConSay, this, "");
|
||||
Console()->Register("set_team", "ii", CFGFLAG_SERVER, ConSetTeam, this, "");
|
||||
Console()->Register("set_team", "ii?i", CFGFLAG_SERVER, ConSetTeam, this, "");
|
||||
Console()->Register("set_team_all", "i", CFGFLAG_SERVER, ConSetTeamAll, this, "");
|
||||
|
||||
Console()->Register("add_vote", "sr", CFGFLAG_SERVER, ConAddVote, this, "");
|
||||
|
|
|
@ -20,6 +20,7 @@ CPlayer::CPlayer(CGameContext *pGameServer, int ClientID, int Team)
|
|||
m_Team = GameServer()->m_pController->ClampTeam(Team);
|
||||
m_SpectatorID = SPEC_FREEVIEW;
|
||||
m_LastActionTick = Server()->Tick();
|
||||
m_TeamChangeTick = Server()->Tick();
|
||||
}
|
||||
|
||||
CPlayer::~CPlayer()
|
||||
|
|
|
@ -78,6 +78,7 @@ public:
|
|||
int m_ScoreStartTick;
|
||||
bool m_ForceBalanced;
|
||||
int m_LastActionTick;
|
||||
int m_TeamChangeTick;
|
||||
struct
|
||||
{
|
||||
int m_TargetX;
|
||||
|
|
|
@ -75,6 +75,7 @@ MACRO_CONFIG_INT(SvInactiveKick, sv_inactivekick, 1, 0, 2, CFGFLAG_SERVER, "How
|
|||
|
||||
MACRO_CONFIG_INT(SvStrictSpectateMode, sv_strict_spectate_mode, 0, 0, 1, CFGFLAG_SERVER, "Restricts information in spectator mode")
|
||||
MACRO_CONFIG_INT(SvVoteSpectate, sv_vote_spectate, 1, 0, 1, CFGFLAG_SERVER, "Allow voting to move players to spectators")
|
||||
MACRO_CONFIG_INT(SvVoteSpectateRejoindelay, sv_vote_spectate_rejoindelay, 3, 0, 1000, CFGFLAG_SERVER, "How many minutes to wait before a player can rejoin after being moved to spectators by vote")
|
||||
MACRO_CONFIG_INT(SvVoteKick, sv_vote_kick, 1, 0, 1, CFGFLAG_SERVER, "Allow voting to kick players")
|
||||
MACRO_CONFIG_INT(SvVoteKickMin, sv_vote_kick_min, 0, 0, MAX_CLIENTS, CFGFLAG_SERVER, "Minimum number of players required to start a kick vote")
|
||||
MACRO_CONFIG_INT(SvVoteKickBantime, sv_vote_kick_bantime, 5, 0, 1440, CFGFLAG_SERVER, "The time to ban a player if kicked by vote. 0 makes it just use kick")
|
||||
|
|
Loading…
Reference in a new issue