From dfb1e0da7823641ad648f9fbd19b43d2e6b0d7ad Mon Sep 17 00:00:00 2001 From: linuxdaemon Date: Tue, 12 Mar 2019 09:48:28 -0500 Subject: Add Who::Request::GetFlagIndex to get field index Replaces the dirty logic in m_hideoper and m_namesx --- src/modules/m_hideoper.cpp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'src/modules/m_hideoper.cpp') diff --git a/src/modules/m_hideoper.cpp b/src/modules/m_hideoper.cpp index f04d88809..8feb1a852 100644 --- a/src/modules/m_hideoper.cpp +++ b/src/modules/m_hideoper.cpp @@ -123,22 +123,9 @@ class ModuleHideOper if (request.flags['o']) return MOD_RES_DENY; - size_t flag_index = 5; - if (request.whox) - { - // We only need to fiddle with the flags if they are present. - if (!request.whox_fields['f']) - return MOD_RES_PASSTHRU; - - // WHOX makes this a bit tricky as we need to work out the parameter which the flags are in. - flag_index = 0; - static const char* flags = "tcuihsn"; - for (size_t i = 0; i < strlen(flags); ++i) - { - if (request.whox_fields[flags[i]]) - flag_index += 1; - } - } + size_t flag_index; + if (!request.GetFlagIndex('f', flag_index)) + return MOD_RES_PASSTHRU; // hide the "*" that marks the user as an oper from the /WHO line // #chan ident localhost insp22.test nick H@ :0 Attila -- cgit v1.3.1-10-gc9f91 From 1003c593bfd455734a8f39f137d4ce68e7e87ca8 Mon Sep 17 00:00:00 2001 From: linuxdaemon Date: Tue, 12 Mar 2019 12:04:01 -0500 Subject: Rename GetFlagIndex -> GetFieldIndex --- include/modules/who.h | 2 +- src/coremods/core_who.cpp | 2 +- src/modules/m_hideoper.cpp | 2 +- src/modules/m_namesx.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/modules/m_hideoper.cpp') diff --git a/include/modules/who.h b/include/modules/who.h index 8fd2dab08..983cece46 100644 --- a/include/modules/who.h +++ b/include/modules/who.h @@ -80,7 +80,7 @@ class Who::Request * @param out The index will be stored in this value * @return True if the field is available, false otherwise */ - virtual bool GetFlagIndex(char flag, size_t& out) const = 0; + virtual bool GetFieldIndex(char flag, size_t& out) const = 0; protected: Request() diff --git a/src/coremods/core_who.cpp b/src/coremods/core_who.cpp index 52af2d2ce..d6df6de20 100644 --- a/src/coremods/core_who.cpp +++ b/src/coremods/core_who.cpp @@ -39,7 +39,7 @@ static const char who_field_order[] = "cuhsnf"; struct WhoData : public Who::Request { - bool GetFlagIndex(char flag, size_t& out) const CXX11_OVERRIDE + bool GetFieldIndex(char flag, size_t& out) const CXX11_OVERRIDE { if (!whox) { diff --git a/src/modules/m_hideoper.cpp b/src/modules/m_hideoper.cpp index 8feb1a852..d78ed538b 100644 --- a/src/modules/m_hideoper.cpp +++ b/src/modules/m_hideoper.cpp @@ -124,7 +124,7 @@ class ModuleHideOper return MOD_RES_DENY; size_t flag_index; - if (!request.GetFlagIndex('f', flag_index)) + if (!request.GetFieldIndex('f', flag_index)) return MOD_RES_PASSTHRU; // hide the "*" that marks the user as an oper from the /WHO line diff --git a/src/modules/m_namesx.cpp b/src/modules/m_namesx.cpp index 1e051e75c..ac15c9723 100644 --- a/src/modules/m_namesx.cpp +++ b/src/modules/m_namesx.cpp @@ -85,7 +85,7 @@ class ModuleNamesX return MOD_RES_PASSTHRU; size_t flag_index; - if (!request.GetFlagIndex('f', flag_index)) + if (!request.GetFieldIndex('f', flag_index)) return MOD_RES_PASSTHRU; // #chan ident localhost insp22.test nick H@ :0 Attila -- cgit v1.3.1-10-gc9f91