mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge pull request #751 from Learath2/dd_pr_ratelimitinvite
Add ratelimiting for /invite
This commit is contained in:
commit
a0a1276b6a
|
@ -197,6 +197,8 @@ MACRO_CONFIG_INT(SvPauseable, sv_pauseable, 1, 0, 1, CFGFLAG_SERVER|CFGFLAG_GAME
|
|||
MACRO_CONFIG_INT(SvPauseMessages, sv_pause_messages, 0, 0, 1, CFGFLAG_SERVER, "Whether to show messages when a player pauses and resumes")
|
||||
MACRO_CONFIG_INT(SvPauseTime, sv_pause_time, 0, 0, 1, CFGFLAG_SERVER, "Whether '/pause' and 'sv_max_dc_restore' pauses the time of player or not")
|
||||
MACRO_CONFIG_INT(SvPauseFrequency, sv_pause_frequency, 1, 0, 9999, CFGFLAG_SERVER, "The minimum allowed delay between pauses")
|
||||
MACRO_CONFIG_INT(SvInvite, sv_invite, 1, 0, 1, CFGFLAG_SERVER, "Whether players can invite other players to teams")
|
||||
MACRO_CONFIG_INT(SvInviteFrequency, sv_invite_frequency, 1, 0, 9999, CFGFLAG_SERVER, "The minimum allowed delay between invites")
|
||||
|
||||
MACRO_CONFIG_INT(SvEmotionalTees, sv_emotional_tees, 1, -1, 1, CFGFLAG_SERVER, "Whether eye change of tees is enabled with emoticons = 1, not = 0, -1 not at all")
|
||||
MACRO_CONFIG_INT(SvEmoticonDelay, sv_emoticon_delay, 3, 0, 9999, CFGFLAG_SERVER, "The time in seconds between over-head emoticons")
|
||||
|
|
|
@ -772,6 +772,12 @@ void CGameContext::ConInviteTeam(IConsole::IResult *pResult, void *pUserData)
|
|||
CGameControllerDDRace *pController = (CGameControllerDDRace *)pSelf->m_pController;
|
||||
const char *pName = pResult->GetString(0);
|
||||
|
||||
if(!g_Config.m_SvInvite)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "invite", "Admin has diabled invites");
|
||||
return;
|
||||
}
|
||||
|
||||
int Team = pController->m_Teams.m_Core.Team(pResult->m_ClientID);
|
||||
if(Team > TEAM_FLOCK && Team < TEAM_SUPER)
|
||||
{
|
||||
|
@ -797,7 +803,14 @@ void CGameContext::ConInviteTeam(IConsole::IResult *pResult, void *pUserData)
|
|||
return;
|
||||
}
|
||||
|
||||
if(pSelf->m_apPlayers[pResult->m_ClientID] && pSelf->m_apPlayers[pResult->m_ClientID]->m_LastInvited + g_Config.m_SvInviteFrequency * pSelf->Server()->TickSpeed() > pSelf->Server()->Tick())
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "invite", "Can't invite this quickly");
|
||||
return;
|
||||
}
|
||||
|
||||
pController->m_Teams.SetClientInvited(Team, Target, true);
|
||||
pSelf->m_apPlayers[pResult->m_ClientID]->m_LastInvited = pSelf->Server()->Tick();
|
||||
|
||||
char aBuf[512];
|
||||
str_format(aBuf, sizeof aBuf, "'%s' invited you to team %d.", pSelf->Server()->ClientName(pResult->m_ClientID), Team);
|
||||
|
@ -863,6 +876,8 @@ void CGameContext::ConJoinTeam(IConsole::IResult *pResult, void *pUserData)
|
|||
else if(pResult->GetInteger(0) > 0 && pResult->GetInteger(0) < MAX_CLIENTS && pController->m_Teams.TeamLocked(pResult->GetInteger(0)) && !pController->m_Teams.IsInvited(pResult->GetInteger(0), pResult->m_ClientID))
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join",
|
||||
g_Config.m_SvInvite ?
|
||||
"This team is locked using /lock. Only members of the team can unlock it using /lock." :
|
||||
"This team is locked using /lock. Only members of the team can invite you or unlock it using /lock.");
|
||||
}
|
||||
else if(pResult->GetInteger(0) > 0 && pResult->GetInteger(0) < MAX_CLIENTS && pController->m_Teams.Count(pResult->GetInteger(0)) >= g_Config.m_SvTeamMaxSize)
|
||||
|
@ -1222,11 +1237,11 @@ void CGameContext::ConSetTimerType(IConsole::IResult *pResult, void *pUserData)
|
|||
return;
|
||||
|
||||
char aBuf[128];
|
||||
|
||||
|
||||
if(pResult->NumArguments() > 0)
|
||||
{
|
||||
int OldType = pPlayer->m_TimerType;
|
||||
|
||||
|
||||
if(str_comp_nocase(pResult->GetString(0), "gametimer") == 0)
|
||||
{
|
||||
if(pPlayer->m_ClientVersion >= VERSION_DDNET_GAMETICK)
|
||||
|
@ -1271,16 +1286,16 @@ void CGameContext::ConSetTimerType(IConsole::IResult *pResult, void *pUserData)
|
|||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "timer", aBuf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if((OldType == CPlayer::TIMERTYPE_BROADCAST || OldType == CPlayer::TIMERTYPE_GAMETIMER_AND_BROADCAST) && (pPlayer->m_TimerType == CPlayer::TIMERTYPE_GAMETIMER || pPlayer->m_TimerType == CPlayer::TIMERTYPE_NONE))
|
||||
pSelf->SendBroadcast("", pResult->m_ClientID);
|
||||
}
|
||||
|
||||
|
||||
if(pPlayer->m_TimerType <= CPlayer::TIMERTYPE_GAMETIMER_AND_BROADCAST && pPlayer->m_TimerType >= CPlayer::TIMERTYPE_GAMETIMER)
|
||||
str_format(aBuf, sizeof(aBuf), "Timer is displayed in %s", s_aaMsg[pPlayer->m_TimerType]);
|
||||
else if(pPlayer->m_TimerType == CPlayer::TIMERTYPE_NONE)
|
||||
str_format(aBuf, sizeof(aBuf), "Timer isn't displayed.");
|
||||
|
||||
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "timer", aBuf);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ void CPlayer::Reset()
|
|||
m_SpectatorID = SPEC_FREEVIEW;
|
||||
m_LastActionTick = Server()->Tick();
|
||||
m_TeamChangeTick = Server()->Tick();
|
||||
m_LastInvited = 0;
|
||||
m_WeakHookSpawn = false;
|
||||
|
||||
int* idMap = Server()->GetIdMap(m_ClientID);
|
||||
|
|
|
@ -77,6 +77,7 @@ public:
|
|||
int m_LastCommands[4];
|
||||
int m_LastCommandPos;
|
||||
int m_LastWhisperTo;
|
||||
int m_LastInvited;
|
||||
|
||||
int m_SendVoteIndex;
|
||||
|
||||
|
|
Loading…
Reference in a new issue