Vote enforcer as command executer

Force pause doesn't need the client id to be positive
Fixed force pause parameter reading

partially helps #124
This commit is contained in:
GreYFoX 2011-11-08 13:06:09 +02:00
parent 137a447065
commit d6845f0502
4 changed files with 10 additions and 6 deletions

View file

@ -29,7 +29,7 @@ CONSOLE_COMMAND("down", "", CFGFLAG_SERVER|CMDFLAG_TEST, ConGoDown, this, "Makes
CONSOLE_COMMAND("move", "ii", CFGFLAG_SERVER|CMDFLAG_TEST, ConMove, this, "Moves to the tile with x/y-number ii")
CONSOLE_COMMAND("move_raw", "ii", CFGFLAG_SERVER|CMDFLAG_TEST, ConMoveRaw, this, "Moves to the point with x/y-coordinates ii")
CONSOLE_COMMAND("force_pause", "ii", CFGFLAG_SERVER, ConForcePause, this, "Force i to pause for i seconds")
CONSOLE_COMMAND("force_unpause", "v", CFGFLAG_SERVER, ConForcePause, this, "Set force-pause timer of v to 0.")
CONSOLE_COMMAND("force_unpause", "i", CFGFLAG_SERVER, ConForcePause, this, "Set force-pause timer of i to 0.")
CONSOLE_COMMAND("mute", "", CFGFLAG_SERVER, ConMute, this, "");
CONSOLE_COMMAND("muteid", "vi", CFGFLAG_SERVER, ConMuteID, this, "");

View file

@ -261,7 +261,7 @@ void CGameContext::ConKill(IConsole::IResult *pResult, void *pUserData)
void CGameContext::ConForcePause(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;
if(!CheckClientID(pResult->m_ClientID)) return;
// if(!CheckClientID(pResult->m_ClientID)) return;
CServer* pServ = (CServer*)pSelf->Server();
int Victim = pResult->GetInteger(0);
int Seconds = 0;
@ -269,6 +269,8 @@ void CGameContext::ConForcePause(IConsole::IResult *pResult, void *pUserData)
if(pResult->NumArguments() > 0 && pResult->m_ClientID < 0)
Seconds = clamp(pResult->GetInteger(0), 0, 15);
//else if(pResult->NumArguments() > 0 && CheckClientID(pResult->m_ClientID))
//Seconds = clamp(pResult->GetInteger(1), 0, 360);
CPlayer *pPlayer = pSelf->m_apPlayers[Victim];
if(!pPlayer || (!Seconds && pResult->m_ClientID >= 0))
@ -390,4 +392,4 @@ void CGameContext::ConMutes(IConsole::IResult *pResult, void *pUserData)
str_format(aBuf, sizeof aBuf, "%d: \"%s\", %d seconds left", i, aIpBuf, (pSelf->m_aMutes[i].m_Expire - pSelf->Server()->Tick()) / pSelf->Server()->TickSpeed());
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mutes", aBuf);
}
}
}

View file

@ -537,7 +537,7 @@ void CGameContext::OnTick()
{
char aBuf[64];
str_format(aBuf, sizeof(aBuf),"Vote passed enforced by server administrator");
Console()->ExecuteLine(m_aVoteCommand);
Console()->ExecuteLine(m_aVoteCommand, m_VoteEnforcer);
SendChat(-1, CGameContext::CHAT_ALL, aBuf);
EndVote();
}
@ -1610,9 +1610,10 @@ void CGameContext::ConVote(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;
if(str_comp_nocase(pResult->GetString(0), "yes") == 0)
pSelf->m_VoteEnforce = CGameContext::VOTE_ENFORCE_YES;
pSelf->m_VoteEnforce = CGameContext::VOTE_ENFORCE_YES_ADMIN;
else if(str_comp_nocase(pResult->GetString(0), "no") == 0)
pSelf->m_VoteEnforce = CGameContext::VOTE_ENFORCE_NO;
pSelf->m_VoteEnforce = CGameContext::VOTE_ENFORCE_NO_ADMIN;
pSelf->m_VoteEnforcer = pResult->m_ClientID;
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "admin forced vote %s", pResult->GetString(0));
pSelf->SendChatTarget(-1, aBuf);

View file

@ -260,6 +260,7 @@ public:
VOTE_ENFORCE_NO_ADMIN = VOTE_ENFORCE_YES + 1,
VOTE_ENFORCE_YES_ADMIN
};
int m_VoteEnforcer;
void SendRecord(int ClientID);
static void SendChatResponse(const char *pLine, void *pUser);
static void SendChatResponseAll(const char *pLine, void *pUser);