From 22976b8a7cf9ba374eaa9967287b17d059b9b389 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 11 Feb 2014 17:31:46 -0500 Subject: Fix flags +* or -* sometimes incorrectly reporting opers as overriding when they are not --- modules/commands/cs_flags.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'modules/commands/cs_flags.cpp') diff --git a/modules/commands/cs_flags.cpp b/modules/commands/cs_flags.cpp index 3e4f75de9..01314e2d3 100644 --- a/modules/commands/cs_flags.cpp +++ b/modules/commands/cs_flags.cpp @@ -175,21 +175,26 @@ class CommandCSFlags : public Command } Privilege *p = NULL; - int add = 1; + bool add = true; for (size_t i = 0; i < flags.length(); ++i) { char f = flags[i]; switch (f) { case '+': - add = 1; + add = true; break; case '-': - add = 0; + add = false; break; case '*': for (std::map::iterator it = defaultFlags.begin(), it_end = defaultFlags.end(); it != it_end; ++it) { + bool has = current_flags.count(it->second); + // If we are adding a flag they already have or removing one they don't have, don't bother + if (add == has) + continue; + if (!u_access.HasPriv(it->first) && !u_access.founder) { if (source.HasPriv("chanserv/access/modify")) @@ -197,9 +202,10 @@ class CommandCSFlags : public Command else continue; } - if (add == 1) + + if (add) current_flags.insert(it->second); - else if (add == 0) + else current_flags.erase(it->second); } break; @@ -225,9 +231,9 @@ class CommandCSFlags : public Command break; } } - if (add == 1) + if (add) current_flags.insert(f); - else if (add == 0) + else current_flags.erase(f); break; } -- cgit