finished system to generalize rcon commands, sorry for last commit's description

This commit is contained in:
heinrich5991 2010-11-07 17:35:11 +01:00
parent 470e2773ba
commit 50b8d93d6d
5 changed files with 13 additions and 21 deletions

View file

@ -23,7 +23,10 @@ enum
CFGFLAG_SAVE=1,
CFGFLAG_CLIENT=2,
CFGFLAG_SERVER=4,
CFGFLAG_STORE=8
CFGFLAG_STORE=8,
CMDFLAG_CHEAT=16,
CMDFLAG_TIMER=32,
CMDFLAG_HELPERCMD=64,
};
#endif

View file

@ -405,7 +405,7 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr, const int Client
if(pResult->GetVictim() == -2)
pResult->SetVictim(ClientId);
if((ClientLevel < pCommand->m_Level && !(pCommand->m_Flags & CCommand::CMDFLAG_HELPERCMD)) || (ClientLevel < 1 && (pCommand->m_Flags & CCommand::CMDFLAG_HELPERCMD)))
if((ClientLevel < pCommand->m_Level && !(pCommand->m_Flags & CMDFLAG_HELPERCMD)) || (ClientLevel < 1 && (pCommand->m_Flags & CMDFLAG_HELPERCMD)))
{
RegisterAlternativePrintResponseCallback(pfnAlternativePrintResponseCallback, pResponseUserData);
@ -423,21 +423,21 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr, const int Client
ReleaseAlternativePrintResponseCallback();
}
else if(ClientLevel == 1 && (pCommand->m_Flags & CCommand::CMDFLAG_HELPERCMD) && pResult->GetVictim() != ClientId)
else if(ClientLevel == 1 && (pCommand->m_Flags & CMDFLAG_HELPERCMD) && pResult->GetVictim() != ClientId)
{
RegisterAlternativePrintResponseCallback(pfnAlternativePrintResponseCallback, pResponseUserData);
PrintResponse(OUTPUT_LEVEL_STANDARD, "Console", "As a helper you can't use commands on others.");
dbg_msg("server", "helper tried rcon command ('%s') on others without permission. ClientId=%d", pCommand->m_pName, ClientId);
ReleaseAlternativePrintResponseCallback();
}
else if(!g_Config.m_SvCheats && (pCommand->m_Flags & CCommand::CMDFLAG_CHEAT))
else if(!g_Config.m_SvCheats && (pCommand->m_Flags & CMDFLAG_CHEAT))
{
RegisterAlternativePrintResponseCallback(pfnAlternativePrintResponseCallback, pResponseUserData);
PrintResponse(OUTPUT_LEVEL_STANDARD, "Console", "Cheats are not available on this server");
dbg_msg("server", "client tried rcon cheat ('%s') with cheats off. ClientId=%d", pCommand->m_pName, ClientId);
ReleaseAlternativePrintResponseCallback();
}
else if(!g_Config.m_SvTimer && (pCommand->m_Flags & CCommand::CMDFLAG_TIMER))
else if(!g_Config.m_SvTimer && (pCommand->m_Flags & CMDFLAG_TIMER))
{
RegisterAlternativePrintResponseCallback(pfnAlternativePrintResponseCallback, pResponseUserData);
PrintResponse(OUTPUT_LEVEL_STANDARD, "Console", "Timer commands are not available on this server");
@ -473,7 +473,7 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr, const int Client
PrintResponse(OUTPUT_LEVEL_STANDARD, "Console", "client is offline");
ReleaseAlternativePrintResponseCallback();
}
else if (!CompareClients(ClientLevel, pResult->GetVictim()))
else if (!CompareClients(ClientLevel, pResult->GetVictim()) && ClientId != pResult->GetVictim())
{
RegisterAlternativePrintResponseCallback(pfnAlternativePrintResponseCallback, pResponseUserData);
PrintResponse(OUTPUT_LEVEL_STANDARD, "Console", "you can not use commands on players with the same or higher level than you");

View file

@ -13,13 +13,6 @@ class CConsole : public IConsole
int m_Flags;
FCommandCallback m_pfnCallback;
void *m_pUserData;
enum
{
CMDFLAG_CHEAT = 16,
CMDFLAG_TIMER = 32,
CMDFLAG_HELPERCMD = 64,
};
};

View file

@ -618,7 +618,7 @@ void CGameContext::OnClientEnter(int ClientId)
m_VoteUpdate = true;
}
bool compare_players(CPlayer *pl1, CPlayer *pl2)
bool ComparePlayers(CPlayer *pl1, CPlayer *pl2)
{
if(((pl1->m_Authed >= 0) ? pl1->m_Authed : 0) > ((pl2->m_Authed >= 0) ? pl2->m_Authed : 0))
return true;
@ -862,7 +862,7 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
SendChatTarget(ClientId, "You can't kick yourself");
return;
}
if(compare_players(m_apPlayers[KickId], pPlayer))
if(ComparePlayers(m_apPlayers[KickId], pPlayer))
{
SendChatTarget(ClientId, "You can't kick admins");
m_apPlayers[ClientId]->m_Last_KickVote = time_get();
@ -1326,7 +1326,7 @@ void CGameContext::MoveCharacter(int ClientId, int Victim, int X, int Y, bool Ra
void CGameContext::ConMute(IConsole::IResult *pResult, void *pUserData, int ClientId)
{
CGameContext *pSelf = (CGameContext *)pUserData;
int Victim = pResult->GetVictim());
int Victim = pResult->GetVictim();
int Seconds = pResult->GetInteger(0);
char buf[512];
if(Seconds < 10)
@ -1342,7 +1342,6 @@ void CGameContext::ConMute(IConsole::IResult *pResult, void *pUserData, int Clie
str_format(buf, sizeof(buf), "%s muted by %s for %d seconds", pSelf->Server()->ClientName(Victim), pSelf->Server()->ClientName(ClientId), Seconds);
pSelf->SendChat(-1, CGameContext::CHAT_ALL, buf);
}
}
void CGameContext::ConSetlvl3(IConsole::IResult *pResult, void *pUserData, int ClientId)
{
@ -1585,7 +1584,6 @@ void CGameContext::ModifyWeapons(int ClientId, int Victim, int Weapon, bool Remo
void CGameContext::ConTeleport(IConsole::IResult *pResult, void *pUserData, int ClientId)
{
CGameContext *pSelf = (CGameContext *)pUserData;
if(!pSelf->CheatsAvailable()) return;
int Victim = pResult->GetVictim();
int TeleTo = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
if(pSelf->m_apPlayers[TeleTo])
@ -1669,7 +1667,7 @@ void CGameContext::ConTimerReStart(IConsole::IResult *pResult, void *pUserData,
CCharacter* chr = pSelf->GetPlayerChar(Victim);
if(!chr)
return;
if(pSelf->m_apPlayers[Victim] && compare_players(pSelf->m_apPlayers[ClientId],pSelf->m_apPlayers[Victim]))
if(pSelf->m_apPlayers[Victim])
{
chr->m_StartTime = pSelf->Server()->Tick();
chr->m_RefreshTime = pSelf->Server()->Tick();

View file

@ -186,8 +186,6 @@ public:
void SendVoteStatus(int ClientId, int Total, int Yes, int No);
void AbortVoteKickOnDisconnect(int ClientId);
bool CheatsAvailable();
bool m_VoteKick;
int m_VoteCreator;
int64 m_VoteCloseTime;