summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/extensible.h16
-rw-r--r--modules/core/cs_access.cpp8
-rw-r--r--modules/core/cs_info.cpp2
-rw-r--r--modules/core/cs_set_mlock.cpp2
-rw-r--r--modules/core/db_plain.cpp6
-rw-r--r--modules/protocol/unreal32.cpp52
-rw-r--r--src/modes.cpp2
7 files changed, 44 insertions, 44 deletions
diff --git a/include/extensible.h b/include/extensible.h
index 884ca8ecb..29ac0504c 100644
--- a/include/extensible.h
+++ b/include/extensible.h
@@ -89,12 +89,10 @@ class CoreExport Extensible : public virtual Base
*
* @return Returns true on success, false if otherwise
*/
- bool Extend(const Anope::string &key, ExtensibleItemBase *p)
+ void Extend(const Anope::string &key, ExtensibleItemBase *p)
{
- bool Ret = this->Extension_Items.insert(std::make_pair(key, p)).second;
- if (!Ret)
- delete p;
- return Ret;
+ this->Shrink(key);
+ this->Extension_Items.insert(std::make_pair(key, p));
}
/** Extend an Extensible class.
@@ -108,13 +106,9 @@ class CoreExport Extensible : public virtual Base
*
* @return Returns true on success, false if otherwise
*/
- bool Extend(const Anope::string &key)
+ void Extend(const Anope::string &key)
{
- /* This will only add an item if it doesnt already exist,
- * the return value is a std::pair of an iterator to the
- * element, and a bool saying if it was actually inserted.
- */
- return this->Extend(key, new ExtensibleItemRegular<char *>(NULL));
+ this->Extend(key, new ExtensibleItemRegular<char *>(NULL));
}
/** Shrink an Extensible class.
diff --git a/modules/core/cs_access.cpp b/modules/core/cs_access.cpp
index c6714cf05..a2db35046 100644
--- a/modules/core/cs_access.cpp
+++ b/modules/core/cs_access.cpp
@@ -462,7 +462,9 @@ class CommandCSLevels : public Command
Anope::string lev = params[3];
Anope::string error;
- int level = convertTo<int>(lev, error, false);
+ int level = (lev.is_number_only() ? convertTo<int>(lev, error, false) : 0);
+ if (!lev.is_number_only())
+ error = "1";
if (lev.equals_ci("FOUNDER"))
{
@@ -475,6 +477,7 @@ class CommandCSLevels : public Command
else if (level <= ACCESS_INVALID || level > ACCESS_FOUNDER)
notice_lang(Config->s_ChanServ, u, CHAN_LEVELS_RANGE, ACCESS_INVALID + 1, ACCESS_FOUNDER - 1);
else
+ {
for (int i = 0; levelinfo[i].what >= 0; ++i)
{
if (what.equals_ci(levelinfo[i].name))
@@ -493,7 +496,8 @@ class CommandCSLevels : public Command
}
}
- notice_lang(Config->s_ChanServ, u, CHAN_LEVELS_UNKNOWN, what.c_str(), Config->s_ChanServ.c_str());
+ notice_lang(Config->s_ChanServ, u, CHAN_LEVELS_UNKNOWN, what.c_str(), Config->s_ChanServ.c_str());
+ }
return MOD_CONT;
}
diff --git a/modules/core/cs_info.cpp b/modules/core/cs_info.cpp
index add7f39ff..b25eeb0ea 100644
--- a/modules/core/cs_info.cpp
+++ b/modules/core/cs_info.cpp
@@ -57,7 +57,7 @@ class CommandCSInfo : public Command
}
/* Should we show all fields? Only for sadmins and identified users */
- if (has_auspex && check_access(u, ci, CA_INFO))
+ if (has_auspex || check_access(u, ci, CA_INFO))
show_all = true;
notice_lang(Config->s_ChanServ, u, CHAN_INFO_HEADER, chan.c_str());
diff --git a/modules/core/cs_set_mlock.cpp b/modules/core/cs_set_mlock.cpp
index cfae860a7..b4c117d05 100644
--- a/modules/core/cs_set_mlock.cpp
+++ b/modules/core/cs_set_mlock.cpp
@@ -65,7 +65,7 @@ class CommandCSSetMLock : public Command
if (paramcount >= params.size())
continue;
- Anope::string param = params[paramcount];
+ Anope::string param = params[paramcount++];
ChannelModeParam *cmp = debug_cast<ChannelModeParam *>(cm);
diff --git a/modules/core/db_plain.cpp b/modules/core/db_plain.cpp
index 643146f5d..ea366d299 100644
--- a/modules/core/db_plain.cpp
+++ b/modules/core/db_plain.cpp
@@ -770,9 +770,9 @@ class DBPlain : public Module
else if (key.equals_ci("MLP"))
{
std::vector<std::pair<Anope::string, Anope::string> > mlp;
-
- for (unsigned j = 0, end = params.size(); j < end; j += 2)
- mlp.push_back(std::make_pair(params[j], params[j + 1]));
+ ci->GetExtRegular("db_mlp", mlp);
+
+ mlp.push_back(std::make_pair(params[0], params[1]));
/* For now store mlocked modes in extensible, Anope hasn't yet connected to the IRCd and doesn't know what modes exist */
ci->Extend("db_mlp", new ExtensibleItemRegular<std::vector<std::pair<Anope::string, Anope::string> > >(mlp));
diff --git a/modules/protocol/unreal32.cpp b/modules/protocol/unreal32.cpp
index 892c4fc57..81bd74aaa 100644
--- a/modules/protocol/unreal32.cpp
+++ b/modules/protocol/unreal32.cpp
@@ -1191,34 +1191,36 @@ bool ChannelModeFlood::IsValid(const Anope::string &value) const
{
if (value.empty())
return false;
- Anope::string rest;
- if (value[0] != ':' && convertTo<unsigned>(value[0] == '*' ? value.substr(1) : value, rest, false) > 0 && rest[0] == ':' && rest.length() > 1 && convertTo<unsigned>(rest.substr(1), rest, false) > 0 && rest.empty())
- return true;
- else
+ try
{
- /* '['<number><1 letter>[optional: '#'+1 letter],[next..]']'':'<number> */
- size_t end_bracket = value.find(']', 1);
- if (end_bracket == Anope::string::npos)
- return false;
- Anope::string xbuf = value.substr(0, end_bracket);
- if (value[end_bracket + 1] != ':')
+ Anope::string rest;
+ if (value[0] != ':' && convertTo<unsigned>(value[0] == '*' ? value.substr(1) : value, rest, false) > 0 && rest[0] == ':' && rest.length() > 1 && convertTo<unsigned>(rest.substr(1), rest, false) > 0 && rest.empty())
+ return true;
+ }
+ catch (const CoreException &) { } // convertTo fail
+
+ /* '['<number><1 letter>[optional: '#'+1 letter],[next..]']'':'<number> */
+ size_t end_bracket = value.find(']', 1);
+ if (end_bracket == Anope::string::npos)
+ return false;
+ Anope::string xbuf = value.substr(0, end_bracket);
+ if (value[end_bracket + 1] != ':')
+ return false;
+ commasepstream args(xbuf.substr(1));
+ Anope::string arg;
+ while (args.GetToken(arg))
+ {
+ /* <number><1 letter>[optional: '#'+1 letter] */
+ size_t p = 0;
+ while (p < arg.length() && isdigit(arg[p]))
+ ++p;
+ if (p == arg.length() || !(arg[p] == 'c' || arg[p] == 'j' || arg[p] == 'k' || arg[p] == 'm' || arg[p] == 'n' || arg[p] == 't'))
+ continue; /* continue instead of break for forward compatability. */
+ int v = arg.substr(0, p).is_number_only() ? convertTo<int>(arg.substr(0, p)) : 0;
+ if (v < 1 || v > 999)
return false;
- commasepstream args(xbuf.substr(1));
- Anope::string arg;
- while (args.GetToken(arg))
- {
- /* <number><1 letter>[optional: '#'+1 letter] */
- size_t p = 0;
- while (p < arg.length() && isdigit(arg[p]))
- ++p;
- if (p == arg.length() || !(arg[p] == 'c' || arg[p] == 'j' || arg[p] == 'k' || arg[p] == 'm' || arg[p] == 'n' || arg[p] == 't'))
- continue; /* continue instead of break for forward compatability. */
- int v = arg.substr(0, p).is_number_only() ? convertTo<int>(arg.substr(0, p)) : 0;
- if (v < 1 || v > 999)
- return false;
- }
- return true;
}
+ return true;
}
static void AddModes()
diff --git a/src/modes.cpp b/src/modes.cpp
index d3f8ddb9f..0405cf998 100644
--- a/src/modes.cpp
+++ b/src/modes.cpp
@@ -232,7 +232,7 @@ ChannelModeStatus::~ChannelModeStatus()
*/
bool ChannelModeKey::IsValid(const Anope::string &value) const
{
- if (!value.empty() && value.find(':') != Anope::string::npos && value.find(',') != Anope::string::npos)
+ if (!value.empty() && value.find(':') == Anope::string::npos && value.find(',') == Anope::string::npos)
return true;
return false;