mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 18:18:18 +00:00
Fixing Force-pause:
* sv_vote_pause_time : maximum 15s, default 10s * Removing sv_vote_pause_auto (so afk stay in pause) * force_pause require config level * force_unpause set force-pause timer to 0
This commit is contained in:
parent
bb971bdcf0
commit
3f2dc36151
|
@ -40,8 +40,8 @@ CONSOLE_COMMAND("help", "?r", CFGFLAG_SERVER, ConHelp, this, "Shows help to comm
|
|||
CONSOLE_COMMAND("info", "", CFGFLAG_SERVER, ConInfo, this, "Shows info about this server", IConsole::CONSOLELEVEL_USER)
|
||||
CONSOLE_COMMAND("me", "r", CFGFLAG_SERVER, ConMe, this, "Like the famous irc command '/me says hi' will display '<yourname> says hi'", IConsole::CONSOLELEVEL_USER)
|
||||
CONSOLE_COMMAND("pause", "", CFGFLAG_SERVER, ConTogglePause, this, "Toggles pause on/off (if activated on server)", IConsole::CONSOLELEVEL_USER)
|
||||
CONSOLE_COMMAND("force_pause", "v?i", CFGFLAG_SERVER, ConForcePause, this, "Force v to pause for i seconds", IConsole::CONSOLELEVEL_ADMIN)
|
||||
CONSOLE_COMMAND("force_unpause", "v", CFGFLAG_SERVER, ConForceUnpause, this, "Force v to unpause", IConsole::CONSOLELEVEL_ADMIN)
|
||||
CONSOLE_COMMAND("force_pause", "vi", CFGFLAG_SERVER, ConForcePause, this, "Force v to pause for i seconds", IConsole::CONSOLELEVEL_CONFIG)
|
||||
CONSOLE_COMMAND("force_unpause", "v", CFGFLAG_SERVER, ConForcePause, this, "Set force-pause timer of v to 0.", IConsole::CONSOLELEVEL_ADMIN)
|
||||
CONSOLE_COMMAND("rank", "?r", CFGFLAG_SERVER, ConRank, this, "Shows the rank of player with name r (your rank by default)", IConsole::CONSOLELEVEL_USER)
|
||||
CONSOLE_COMMAND("rules", "", CFGFLAG_SERVER, ConRules, this, "Shows the server rules", IConsole::CONSOLELEVEL_USER)
|
||||
CONSOLE_COMMAND("team", "?i", CFGFLAG_SERVER, ConJoinTeam, this, "Lets you join team i (shows your team if left blank)", IConsole::CONSOLELEVEL_USER)
|
||||
|
|
|
@ -478,7 +478,7 @@ void CGameContext::ConTogglePause(IConsole::IResult *pResult, void *pUserData, i
|
|||
else
|
||||
pResult->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", "You can\'t pause that often.");
|
||||
}
|
||||
else if(pPlayer->GetTeam()==TEAM_SPECTATORS && pPlayer->m_InfoSaved && pPlayer->m_ForcePauseTime==0)
|
||||
else if(pPlayer->GetTeam()==TEAM_SPECTATORS && pPlayer->m_InfoSaved && pPlayer->m_ForcePauseTime == 0)
|
||||
{
|
||||
pPlayer->m_PauseInfo.m_Respawn = true;
|
||||
pPlayer->SetTeam(TEAM_RED);
|
||||
|
@ -508,20 +508,18 @@ void CGameContext::ConForcePause(IConsole::IResult *pResult, void *pUserData, in
|
|||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CServer* pServ = (CServer*)pSelf->Server();
|
||||
int Victim = pResult->GetVictim();
|
||||
int Seconds;
|
||||
int Seconds = 0;
|
||||
char aBuf[128];
|
||||
|
||||
if(pResult->NumArguments() > 0)
|
||||
Seconds = pResult->GetInteger(0);
|
||||
else
|
||||
Seconds = g_Config.m_SvVotePauseTime;
|
||||
if(pResult->NumArguments() > 0 && ClientID < 0)
|
||||
Seconds = clamp(pResult->GetInteger(0), 0, 15);
|
||||
|
||||
CPlayer *pPlayer = pSelf->m_apPlayers[Victim];
|
||||
if(!pPlayer)
|
||||
if(!pPlayer || (!Seconds && ClientID >= 0))
|
||||
return;
|
||||
|
||||
CCharacter* pChr = pPlayer->GetCharacter();
|
||||
if(!pPlayer->GetTeam() && pChr && !pPlayer->m_InfoSaved)
|
||||
if(!pPlayer->GetTeam() && pChr && !pPlayer->m_InfoSaved && ClientID < 0)
|
||||
{
|
||||
pPlayer->SaveCharacter();
|
||||
pPlayer->m_InfoSaved = true;
|
||||
|
@ -535,37 +533,7 @@ void CGameContext::ConForcePause(IConsole::IResult *pResult, void *pUserData, in
|
|||
if(ClientID < 0)
|
||||
str_format(aBuf, sizeof(aBuf), "'%s' has been force-paused for %d seconds", pServ->ClientName(Victim), Seconds);
|
||||
else
|
||||
str_format(aBuf, sizeof(aBuf), "'%s' has been force-paused for %d seconds by '%s'", pServ->ClientName(Victim), Seconds, pServ->ClientName(ClientID));
|
||||
pSelf->SendChat(-1, CHAT_ALL, aBuf);
|
||||
}
|
||||
|
||||
void CGameContext::ConForceUnpause(IConsole::IResult *pResult, void *pUserData, int ClientID)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CServer* pServ = (CServer*)pSelf->Server();
|
||||
int Victim = pResult->GetVictim();
|
||||
char aBuf[128];
|
||||
|
||||
CPlayer *pPlayer = pSelf->m_apPlayers[Victim];
|
||||
if(!pPlayer)
|
||||
return;
|
||||
|
||||
if(pPlayer->GetTeam()==TEAM_SPECTATORS && pPlayer->m_InfoSaved)
|
||||
{
|
||||
pPlayer->m_PauseInfo.m_Respawn = true;
|
||||
pPlayer->SetTeam(TEAM_RED);
|
||||
pPlayer->m_InfoSaved = false;
|
||||
//pPlayer->LoadCharacter();//TODO:Check if this system Works
|
||||
pPlayer->m_ForcePauseTime = 0;
|
||||
}
|
||||
else // Shouldn't be reached
|
||||
{
|
||||
pPlayer->m_ForcePauseTime = 0;
|
||||
}
|
||||
if(ClientID < 0)
|
||||
str_format(aBuf, sizeof(aBuf), "'%s' has been force-unpaused", pServ->ClientName(Victim));
|
||||
else
|
||||
str_format(aBuf, sizeof(aBuf), "'%s' has been force-unpaused by '%s'", pServ->ClientName(Victim), pServ->ClientName(ClientID));
|
||||
str_format(aBuf, sizeof(aBuf), "Force-pause of '%s' have been removed by '%s'", pServ->ClientName(Victim), pServ->ClientName(ClientID));
|
||||
pSelf->SendChat(-1, CHAT_ALL, aBuf);
|
||||
}
|
||||
|
||||
|
|
|
@ -945,8 +945,8 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
if(g_Config.m_SvPauseable && g_Config.m_SvVotePause)
|
||||
{
|
||||
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, pReason);
|
||||
str_format(aDesc, sizeof(aDesc), "Pause '%s' (%ds)", Server()->ClientName(SpectateID), g_Config.m_SvVotePauseTime);
|
||||
str_format(aCmd, sizeof(aCmd), "force_pause %d", SpectateID);
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -219,7 +219,6 @@ private:
|
|||
static void ConKill(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
static void ConTogglePause(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
static void ConForcePause(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
static void ConForceUnpause(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
static void ConTop5(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
#if defined(CONF_SQL)
|
||||
static void ConTimes(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
|
|
|
@ -64,13 +64,6 @@ void CPlayer::Tick()
|
|||
if (m_ChatScore > 0)
|
||||
m_ChatScore--;
|
||||
|
||||
if (g_Config.m_SvVotePauseAuto && m_ForcePauseTime==1 && GetTeam()==TEAM_SPECTATORS && m_InfoSaved)
|
||||
{
|
||||
m_InfoSaved = false;
|
||||
m_PauseInfo.m_Respawn = true;
|
||||
SetTeam(TEAM_RED);
|
||||
}
|
||||
|
||||
if (m_ForcePauseTime > 0)
|
||||
m_ForcePauseTime--;
|
||||
|
||||
|
|
|
@ -79,8 +79,7 @@ MACRO_CONFIG_INT(SvVoteKickMin, sv_vote_kick_min, 0, 0, MAX_CLIENTS, CFGFLAG_SER
|
|||
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", IConsole::CONSOLELEVEL_ADMIN)
|
||||
|
||||
MACRO_CONFIG_INT(SvVotePause, sv_vote_pause, 1, 0, 1, CFGFLAG_SERVER, "Allow voting to pause players (instead of moving to spectators)", IConsole::CONSOLELEVEL_ADMIN)
|
||||
MACRO_CONFIG_INT(SvVotePauseTime, sv_vote_pause_time, 60, 0, 3600, CFGFLAG_SERVER, "The time (in seconds) players have to wait in pause when paused by vote", IConsole::CONSOLELEVEL_ADMIN)
|
||||
MACRO_CONFIG_INT(SvVotePauseAuto, sv_vote_pause_auto, 0, 0, 1, CFGFLAG_SERVER, "Automatically unpaused players after the force-pause delay or not", IConsole::CONSOLELEVEL_ADMIN)
|
||||
MACRO_CONFIG_INT(SvVotePauseTime, sv_vote_pause_time, 10, 0, 15, CFGFLAG_SERVER, "The time (in seconds) players have to wait in pause when paused by vote", IConsole::CONSOLELEVEL_ADMIN)
|
||||
// debug
|
||||
#ifdef CONF_DEBUG // this one can crash the server if not used correctly
|
||||
MACRO_CONFIG_INT(DbgDummies, dbg_dummies, 0, 0, 15, CFGFLAG_SERVER, "", IConsole::CONSOLELEVEL_ADMIN)
|
||||
|
|
Loading…
Reference in a new issue