From afa1e8adc5764bb617e6cb4e02abfaa2e75666db Mon Sep 17 00:00:00 2001 From: def Date: Fri, 1 Mar 2019 22:11:00 +0100 Subject: [PATCH] Uninvite kicked/spectated players from team (fixed #1464) --- src/game/ddracecommands.h | 1 + src/game/server/ddracecommands.cpp | 10 +++++++++- src/game/server/gamecontext.cpp | 14 +++++++++----- src/game/server/gamecontext.h | 1 + 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/game/ddracecommands.h b/src/game/ddracecommands.h index 3d18f5f56..3db5cf773 100644 --- a/src/game/ddracecommands.h +++ b/src/game/ddracecommands.h @@ -39,6 +39,7 @@ CONSOLE_COMMAND("force_unpause", "v[id]", CFGFLAG_SERVER, ConForcePause, this, " CONSOLE_COMMAND("list", "?s[filter]", CFGFLAG_CHAT, ConList, this, "List connected players with optional case-insensitive substring matching filter") CONSOLE_COMMAND("set_team_ddr", "v[id] ?i[team]", CFGFLAG_SERVER, ConSetDDRTeam, this, "Set ddrace team of a player") +CONSOLE_COMMAND("uninvite", "v[id] ?i[team]", CFGFLAG_SERVER, ConUninvite, this, "Uninvite player from team") CONSOLE_COMMAND("vote_mute", "v[id] i[seconds]", CFGFLAG_SERVER, ConVoteMute, this, "Remove v's right to vote for i seconds") CONSOLE_COMMAND("mute", "", CFGFLAG_SERVER, ConMute, this, "") diff --git a/src/game/server/ddracecommands.cpp b/src/game/server/ddracecommands.cpp index a9099036d..8e018aada 100644 --- a/src/game/server/ddracecommands.cpp +++ b/src/game/server/ddracecommands.cpp @@ -587,7 +587,15 @@ void CGameContext::ConSetDDRTeam(IConsole::IResult *pResult, void *pUserData) if(pController->m_Teams.m_Core.Team(Target) && pController->m_Teams.GetDDRaceState(pSelf->m_apPlayers[Target]) == DDRACE_STARTED) pSelf->m_apPlayers[Target]->KillCharacter(WEAPON_SELF); - pController->m_Teams.SetForceCharacterTeam(pResult->GetVictim(), Team); + pController->m_Teams.SetForceCharacterTeam(Target, Team); +} + +void CGameContext::ConUninvite(IConsole::IResult *pResult, void *pUserData) +{ + CGameContext *pSelf = (CGameContext *)pUserData; + CGameControllerDDRace *pController = (CGameControllerDDRace *)pSelf->m_pController; + + pController->m_Teams.SetClientInvited(pResult->GetInteger(1), pResult->GetVictim(), false); } void CGameContext::ConFreezeHammer(IConsole::IResult *pResult, void *pUserData) diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index c8b65de91..0e5ae7c60 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -1594,21 +1594,25 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) } str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to kick '%s' (%s)", Server()->ClientName(ClientID), Server()->ClientName(KickID), aReason); - str_format(aDesc, sizeof(aDesc), "Kick '%s'", Server()->ClientName(KickID)); if(!GetDDRaceTeam(ClientID)) { if (!g_Config.m_SvVoteKickBantime) + { str_format(aCmd, sizeof(aCmd), "kick %d Kicked by vote", KickID); + str_format(aDesc, sizeof(aDesc), "Kick '%s'", Server()->ClientName(KickID)); + } else { char aAddrStr[NETADDR_MAXSTRSIZE] = {0}; Server()->GetClientAddr(KickID, aAddrStr, sizeof(aAddrStr)); str_format(aCmd, sizeof(aCmd), "ban %s %d Banned by vote", aAddrStr, g_Config.m_SvVoteKickBantime); + str_format(aDesc, sizeof(aDesc), "Ban '%s'", Server()->ClientName(KickID)); } } else { - str_format(aCmd, sizeof(aCmd), "set_team_ddr %d 0", KickID); + str_format(aCmd, sizeof(aCmd), "uninvite %d %d; set_team_ddr %d 0", KickID, GetDDRaceTeam(KickID), KickID); + str_format(aDesc, sizeof(aDesc), "Move '%s' to team 0", Server()->ClientName(KickID)); } m_apPlayers[ClientID]->m_Last_KickVote = time_get(); m_VoteKick = true; @@ -1650,13 +1654,13 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) { str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to pause '%s' for %d seconds (%s)", Server()->ClientName(ClientID), Server()->ClientName(SpectateID), g_Config.m_SvVotePauseTime, aReason); str_format(aDesc, sizeof(aDesc), "Pause '%s' (%ds)", Server()->ClientName(SpectateID), g_Config.m_SvVotePauseTime); - str_format(aCmd, sizeof(aCmd), "force_pause %d %d", SpectateID, g_Config.m_SvVotePauseTime); + str_format(aCmd, sizeof(aCmd), "uninvite %d %d; force_pause %d %d", SpectateID, GetDDRaceTeam(SpectateID), SpectateID, g_Config.m_SvVotePauseTime); } else { str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to move '%s' to spectators (%s)", Server()->ClientName(ClientID), Server()->ClientName(SpectateID), aReason); - str_format(aDesc, sizeof(aDesc), "move '%s' to spectators", Server()->ClientName(SpectateID)); - str_format(aCmd, sizeof(aCmd), "set_team %d -1 %d", SpectateID, g_Config.m_SvVoteSpectateRejoindelay); + str_format(aDesc, sizeof(aDesc), "Move '%s' to spectators", Server()->ClientName(SpectateID)); + str_format(aCmd, sizeof(aCmd), "uninvite %d %d; set_team %d -1 %d", SpectateID, GetDDRaceTeam(SpectateID), SpectateID, g_Config.m_SvVoteSpectateRejoindelay); } m_VoteKick = false; m_VoteSpec = true; diff --git a/src/game/server/gamecontext.h b/src/game/server/gamecontext.h index 17a305650..99e3526ac 100644 --- a/src/game/server/gamecontext.h +++ b/src/game/server/gamecontext.h @@ -362,6 +362,7 @@ private: static void ConList(IConsole::IResult *pResult, void *pUserData); static void ConSetDDRTeam(IConsole::IResult *pResult, void *pUserData); + static void ConUninvite(IConsole::IResult *pResult, void *pUserData); static void ConFreezeHammer(IConsole::IResult *pResult, void *pUserData); static void ConUnFreezeHammer(IConsole::IResult *pResult, void *pUserData);