mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
add rcon moderate mode
This commit is contained in:
parent
ae0525a027
commit
d6eb604718
|
@ -181,6 +181,7 @@ access_level bans 1
|
|||
access_level bans_save 1
|
||||
access_level kick 1
|
||||
access_level force_vote 1
|
||||
access_level moderate 1
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ CONSOLE_COMMAND("muteid", "v[id] i[seconds]", CFGFLAG_SERVER, ConMuteID, this, "
|
|||
CONSOLE_COMMAND("muteip", "s[ip] i[seconds]", CFGFLAG_SERVER, ConMuteIP, this, "");
|
||||
CONSOLE_COMMAND("unmute", "v[id]", CFGFLAG_SERVER, ConUnmute, this, "");
|
||||
CONSOLE_COMMAND("mutes", "", CFGFLAG_SERVER, ConMutes, this, "");
|
||||
CONSOLE_COMMAND("moderate", "", CFGFLAG_SERVER, ConModerate, this, "Enables/disables active moderator mode for the player")
|
||||
|
||||
CONSOLE_COMMAND("freezehammer", "v[id]", CFGFLAG_SERVER|CMDFLAG_TEST, ConFreezeHammer, this, "Gives a player Freeze Hammer")
|
||||
CONSOLE_COMMAND("unfreezehammer", "v[id]", CFGFLAG_SERVER|CMDFLAG_TEST, ConUnFreezeHammer, this, "Removes Freeze Hammer from a player")
|
||||
|
|
|
@ -461,6 +461,34 @@ void CGameContext::ConMutes(IConsole::IResult *pResult, void *pUserData)
|
|||
}
|
||||
}
|
||||
|
||||
void CGameContext::ConModerate(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if (!CheckClientID(pResult->m_ClientID))
|
||||
return;
|
||||
|
||||
bool HadModerator = pSelf->PlayerModerating();
|
||||
|
||||
CPlayer* player = pSelf->m_apPlayers[pResult->m_ClientID];
|
||||
player->m_Moderating = !player->m_Moderating;
|
||||
|
||||
char aBuf[256];
|
||||
|
||||
if(!HadModerator && player->m_Moderating)
|
||||
str_format(aBuf, sizeof(aBuf), "Server kick/spec votes will now be actively moderated.");
|
||||
|
||||
if (!pSelf->PlayerModerating())
|
||||
str_format(aBuf, sizeof(aBuf), "Server kick/spec votes are no longer actively moderated.");
|
||||
|
||||
pSelf->SendChat(-1, CHAT_ALL, aBuf, 0);
|
||||
|
||||
if(player->m_Moderating)
|
||||
pSelf->SendChatTarget(pResult->m_ClientID,
|
||||
"Active moderator mode enabled for you.");
|
||||
else
|
||||
pSelf->SendChatTarget(pResult->m_ClientID, "Active moderator mode disabled for you.");
|
||||
}
|
||||
|
||||
void CGameContext::ConList(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
|
|
|
@ -740,6 +740,26 @@ void CGameContext::OnTick()
|
|||
else if(ActVote < 0)
|
||||
VetoStop = true;
|
||||
}
|
||||
|
||||
// Check if a active moderator has voted.
|
||||
if (m_apPlayers[i] && m_apPlayers[i]->m_Vote != 0 && m_apPlayers[i]->m_Moderating)
|
||||
{
|
||||
if (m_apPlayers[i]->m_Vote == 1)
|
||||
{
|
||||
Server()->SetRconCID(IServer::RCON_CID_VOTE);
|
||||
Console()->ExecuteLine(m_aVoteCommand);
|
||||
Server()->SetRconCID(IServer::RCON_CID_SERV);
|
||||
EndVote();
|
||||
SendChat(-1, CGameContext::CHAT_ALL, "Vote passed enforced by server moderator");
|
||||
return;
|
||||
}
|
||||
else if (m_apPlayers[i]->m_Vote == -1)
|
||||
{
|
||||
EndVote();
|
||||
SendChat(-1, CGameContext::CHAT_ALL, "Vote failed enforced by server moderator");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(g_Config.m_SvVoteMaxTotal && Total > g_Config.m_SvVoteMaxTotal &&
|
||||
|
@ -762,14 +782,32 @@ void CGameContext::OnTick()
|
|||
|
||||
if(m_VoteEnforce == VOTE_ENFORCE_YES)
|
||||
{
|
||||
Server()->SetRconCID(IServer::RCON_CID_VOTE);
|
||||
Console()->ExecuteLine(m_aVoteCommand);
|
||||
Server()->SetRconCID(IServer::RCON_CID_SERV);
|
||||
EndVote();
|
||||
SendChat(-1, CGameContext::CHAT_ALL, "Vote passed");
|
||||
if (PlayerModerating() && (m_VoteKick || m_VoteSpec))
|
||||
{
|
||||
// Ensure minimum time for vote to end when moderating.
|
||||
if (time_get() > m_VoteCloseTime)
|
||||
{
|
||||
Server()->SetRconCID(IServer::RCON_CID_VOTE);
|
||||
Console()->ExecuteLine(m_aVoteCommand);
|
||||
Server()->SetRconCID(IServer::RCON_CID_SERV);
|
||||
EndVote();
|
||||
SendChat(-1, CGameContext::CHAT_ALL, "Vote passed");
|
||||
|
||||
if(m_apPlayers[m_VoteCreator] && !m_VoteKick && !m_VoteSpec)
|
||||
m_apPlayers[m_VoteCreator]->m_LastVoteCall = 0;
|
||||
if (m_apPlayers[m_VoteCreator] && !m_VoteKick && !m_VoteSpec)
|
||||
m_apPlayers[m_VoteCreator]->m_LastVoteCall = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Server()->SetRconCID(IServer::RCON_CID_VOTE);
|
||||
Console()->ExecuteLine(m_aVoteCommand);
|
||||
Server()->SetRconCID(IServer::RCON_CID_SERV);
|
||||
EndVote();
|
||||
SendChat(-1, CGameContext::CHAT_ALL, "Vote passed");
|
||||
|
||||
if (m_apPlayers[m_VoteCreator] && !m_VoteKick && !m_VoteSpec)
|
||||
m_apPlayers[m_VoteCreator]->m_LastVoteCall = 0;
|
||||
}
|
||||
}
|
||||
else if(m_VoteEnforce == VOTE_ENFORCE_YES_ADMIN)
|
||||
{
|
||||
|
@ -3345,3 +3383,13 @@ void CGameContext::SetClientVersion(int ClientID, int Version) {
|
|||
}
|
||||
m_apPlayers[ClientID]->m_ClientVersion = Version;
|
||||
}
|
||||
|
||||
bool CGameContext::PlayerModerating()
|
||||
{
|
||||
for (int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if (m_apPlayers[i] && m_apPlayers[i]->m_Moderating)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -245,6 +245,8 @@ public:
|
|||
int GetClientVersion(int ClientID);
|
||||
void SetClientVersion(int ClientID, int Version);
|
||||
bool PlayerExists(int ClientID) { return m_apPlayers[ClientID]; };
|
||||
// Returns true if someone is actively moderating.
|
||||
bool PlayerModerating();
|
||||
|
||||
private:
|
||||
|
||||
|
@ -335,13 +337,12 @@ private:
|
|||
static void ConRescue(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConProtectedKill(IConsole::IResult *pResult, void *pUserData);
|
||||
|
||||
|
||||
|
||||
static void ConMute(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConMuteID(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConMuteIP(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConUnmute(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConMutes(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConModerate(IConsole::IResult *pResult, void *pUserData);
|
||||
|
||||
static void ConList(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConSetDDRTeam(IConsole::IResult *pResult, void *pUserData);
|
||||
|
|
|
@ -62,6 +62,7 @@ void CPlayer::Reset()
|
|||
m_Sent1stAfkWarning = 0;
|
||||
m_Sent2ndAfkWarning = 0;
|
||||
m_ChatScore = 0;
|
||||
m_Moderating = false;
|
||||
m_EyeEmote = true;
|
||||
m_TimerType = (g_Config.m_SvDefaultTimerType == CPlayer::TIMERTYPE_GAMETIMER || g_Config.m_SvDefaultTimerType == CPlayer::TIMERTYPE_GAMETIMER_AND_BROADCAST) ? CPlayer::TIMERTYPE_BROADCAST : g_Config.m_SvDefaultTimerType;
|
||||
m_DefEmote = EMOTE_NORMAL;
|
||||
|
@ -153,6 +154,15 @@ void CPlayer::Tick()
|
|||
|
||||
Server()->SetClientScore(m_ClientID, m_Score);
|
||||
|
||||
if (m_Moderating && m_Afk)
|
||||
{
|
||||
m_Moderating = false;
|
||||
GameServer()->SendChatTarget(m_ClientID, "Active moderator mode disabled because you are afk.");
|
||||
|
||||
if (!GameServer()->PlayerModerating())
|
||||
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, "Server kick/spec votes are no longer actively moderated.");
|
||||
}
|
||||
|
||||
// do latency stuff
|
||||
{
|
||||
IServer::CClientInfo Info;
|
||||
|
@ -374,6 +384,14 @@ void CPlayer::OnDisconnect(const char *pReason)
|
|||
|
||||
str_format(aBuf, sizeof(aBuf), "leave player='%d:%s'", m_ClientID, Server()->ClientName(m_ClientID));
|
||||
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "game", aBuf);
|
||||
|
||||
bool WasModerator = m_Moderating;
|
||||
|
||||
// Set this to false, otherwise PlayerModerating() will return true.
|
||||
m_Moderating = false;
|
||||
|
||||
if (!GameServer()->PlayerModerating() && WasModerator)
|
||||
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, "Server kick/spec votes are no longer actively moderated.");
|
||||
}
|
||||
|
||||
CGameControllerDDRace* Controller = (CGameControllerDDRace*)GameServer()->m_pController;
|
||||
|
|
|
@ -176,6 +176,8 @@ public:
|
|||
|
||||
int m_ChatScore;
|
||||
|
||||
bool m_Moderating;
|
||||
|
||||
bool AfkTimer(int new_target_x, int new_target_y); //returns true if kicked
|
||||
void AfkVoteTimer(CNetObj_PlayerInput *NewTarget);
|
||||
int64 m_LastPlaytime;
|
||||
|
|
Loading…
Reference in a new issue