mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Added a command to check user status commands
This commit is contained in:
parent
9fe96f6b04
commit
c7d9b289e7
|
@ -605,6 +605,7 @@ CConsole::CConsole(int FlagMask)
|
||||||
|
|
||||||
Register("mod_command", "s?i", CFGFLAG_SERVER, ConModCommandAccess, this, "Specify command accessibility for moderators");
|
Register("mod_command", "s?i", CFGFLAG_SERVER, ConModCommandAccess, this, "Specify command accessibility for moderators");
|
||||||
Register("mod_status", "", CFGFLAG_SERVER, ConModCommandStatus, this, "List all commands which are accessible for moderators");
|
Register("mod_status", "", CFGFLAG_SERVER, ConModCommandStatus, this, "List all commands which are accessible for moderators");
|
||||||
|
Register("user_status", "", CFGFLAG_SERVER, ConUserCommandStatus, this, "List all commands which are accessible for users");
|
||||||
|
|
||||||
// TODO: this should disappear
|
// TODO: this should disappear
|
||||||
#define MACRO_CONFIG_INT(Name,ScriptName,Def,Min,Max,Flags,Desc) \
|
#define MACRO_CONFIG_INT(Name,ScriptName,Def,Min,Max,Flags,Desc) \
|
||||||
|
@ -839,3 +840,38 @@ const IConsole::CCommandInfo *CConsole::GetCommandInfo(const char *pName, int Fl
|
||||||
|
|
||||||
|
|
||||||
extern IConsole *CreateConsole(int FlagMask) { return new CConsole(FlagMask); }
|
extern IConsole *CreateConsole(int FlagMask) { return new CConsole(FlagMask); }
|
||||||
|
|
||||||
|
void CConsole::ConUserCommandStatus(IResult *pResult, void *pUser)
|
||||||
|
{
|
||||||
|
CConsole* pConsole = static_cast<CConsole *>(pUser);
|
||||||
|
char aBuf[240];
|
||||||
|
mem_zero(aBuf, sizeof(aBuf));
|
||||||
|
int Used = 0;
|
||||||
|
|
||||||
|
for(CCommand *pCommand = pConsole->m_pFirstCommand; pCommand; pCommand = pCommand->m_pNext)
|
||||||
|
{
|
||||||
|
if(pCommand->m_Flags&pConsole->m_FlagMask && pCommand->GetAccessLevel() == ACCESS_LEVEL_USER)
|
||||||
|
{
|
||||||
|
int Length = str_length(pCommand->m_pName);
|
||||||
|
if(Used + Length + 2 < (int)(sizeof(aBuf)))
|
||||||
|
{
|
||||||
|
if(Used > 0)
|
||||||
|
{
|
||||||
|
Used += 2;
|
||||||
|
str_append(aBuf, ", ", sizeof(aBuf));
|
||||||
|
}
|
||||||
|
str_append(aBuf, pCommand->m_pName, sizeof(aBuf));
|
||||||
|
Used += Length;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pConsole->Print(OUTPUT_LEVEL_STANDARD, "Console", aBuf);
|
||||||
|
mem_zero(aBuf, sizeof(aBuf));
|
||||||
|
str_copy(aBuf, pCommand->m_pName, sizeof(aBuf));
|
||||||
|
Used = Length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(Used > 0)
|
||||||
|
pConsole->Print(OUTPUT_LEVEL_STANDARD, "Console", aBuf);
|
||||||
|
}
|
||||||
|
|
|
@ -177,6 +177,10 @@ public:
|
||||||
virtual void Print(int Level, const char *pFrom, const char *pStr);
|
virtual void Print(int Level, const char *pFrom, const char *pStr);
|
||||||
|
|
||||||
void SetAccessLevel(int AccessLevel) { m_AccessLevel = clamp(AccessLevel, (int)(ACCESS_LEVEL_ADMIN), (int)(ACCESS_LEVEL_USER)); }
|
void SetAccessLevel(int AccessLevel) { m_AccessLevel = clamp(AccessLevel, (int)(ACCESS_LEVEL_ADMIN), (int)(ACCESS_LEVEL_USER)); }
|
||||||
|
|
||||||
|
// DDRace
|
||||||
|
|
||||||
|
static void ConUSerCommandStatus(IConsole::IResult *pResult, void *pUser);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue