From c7d9b289e7fcf6988a1d57ddf98da62dccf9e37e Mon Sep 17 00:00:00 2001 From: GreYFoX Date: Fri, 26 Aug 2011 23:37:10 +0200 Subject: [PATCH] Added a command to check user status commands --- src/engine/shared/console.cpp | 36 +++++++++++++++++++++++++++++++++++ src/engine/shared/console.h | 4 ++++ 2 files changed, 40 insertions(+) diff --git a/src/engine/shared/console.cpp b/src/engine/shared/console.cpp index e8bd5893f..cc57f12f8 100644 --- a/src/engine/shared/console.cpp +++ b/src/engine/shared/console.cpp @@ -605,6 +605,7 @@ CConsole::CConsole(int FlagMask) 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("user_status", "", CFGFLAG_SERVER, ConUserCommandStatus, this, "List all commands which are accessible for users"); // TODO: this should disappear #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); } + +void CConsole::ConUserCommandStatus(IResult *pResult, void *pUser) +{ + CConsole* pConsole = static_cast(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); +} diff --git a/src/engine/shared/console.h b/src/engine/shared/console.h index a318a5217..7726201d4 100644 --- a/src/engine/shared/console.h +++ b/src/engine/shared/console.h @@ -177,6 +177,10 @@ public: 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)); } + + // DDRace + + static void ConUSerCommandStatus(IConsole::IResult *pResult, void *pUser); }; #endif