summaryrefslogtreecommitdiff
path: root/src/commands.cpp
diff options
context:
space:
mode:
authorom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2006-04-04 07:44:05 +0000
committerom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2006-04-04 07:44:05 +0000
commit024c564e53b847e88b40258b2337bf7c3bf9a56c (patch)
tree3d60097c2a8ba3bf6ba749ac377ed6db1a370167 /src/commands.cpp
parentb450c430626cd3034844a749874cce3d2259704a (diff)
Optimisations
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3826 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/commands.cpp')
-rw-r--r--src/commands.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/commands.cpp b/src/commands.cpp
index 46e3ae982..e5d58bfba 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -212,16 +212,16 @@ long duration(const char* str)
bool host_matches_everyone(const std::string &mask, userrec* user)
{
- char insanemasks[MAXBUF];
char buffer[MAXBUF];
char itrigger[MAXBUF];
- Config->ConfValue(Config->config_data, "insane","hostmasks", 0, insanemasks, MAXBUF);
- Config->ConfValue(Config->config_data, "insane","trigger", 0, itrigger, MAXBUF);
- if (*itrigger == 0)
+ long matches = 0;
+
+ if (!Config->ConfValue(Config->config_data, "insane","trigger", 0, itrigger, MAXBUF))
strlcpy(itrigger,"95.5",MAXBUF);
- if ((*insanemasks == 'y') || (*insanemasks == 't') || (*insanemasks == '1'))
+
+ if (Config->ConfValueBool(Config->config_data, "insane","hostmasks", 0))
return false;
- long matches = 0;
+
for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++)
{
strlcpy(buffer,u->second->ident,MAXBUF);
@@ -241,20 +241,21 @@ bool host_matches_everyone(const std::string &mask, userrec* user)
bool ip_matches_everyone(const std::string &ip, userrec* user)
{
- char insanemasks[MAXBUF];
char itrigger[MAXBUF];
- Config->ConfValue(Config->config_data, "insane","ipmasks",0,insanemasks,MAXBUF);
- Config->ConfValue(Config->config_data, "insane","trigger",0,itrigger,MAXBUF);
- if (*itrigger == 0)
+ long matches = 0;
+
+ if (!Config->ConfValue(Config->config_data, "insane","trigger",0,itrigger,MAXBUF))
strlcpy(itrigger,"95.5",MAXBUF);
- if ((*insanemasks == 'y') || (*insanemasks == 't') || (*insanemasks == '1'))
+
+ if (Config->ConfValueBool(Config->config_data, "insane","ipmasks",0))
return false;
- long matches = 0;
+
for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++)
{
if (match((char*)inet_ntoa(u->second->ip4),ip.c_str()))
matches++;
}
+
float percent = ((float)matches / (float)clientlist.size()) * 100;
if (percent > (float)atof(itrigger))
{
@@ -266,20 +267,21 @@ bool ip_matches_everyone(const std::string &ip, userrec* user)
bool nick_matches_everyone(const std::string &nick, userrec* user)
{
- char insanemasks[MAXBUF];
char itrigger[MAXBUF];
- Config->ConfValue(Config->config_data, "insane","nickmasks",0,insanemasks,MAXBUF);
- Config->ConfValue(Config->config_data, "insane","trigger",0,itrigger,MAXBUF);
- if (*itrigger == 0)
+ long matches = 0;
+
+ if (!Config->ConfValue(Config->config_data, "insane","trigger",0,itrigger,MAXBUF))
strlcpy(itrigger,"95.5",MAXBUF);
- if ((*insanemasks == 'y') || (*insanemasks == 't') || (*insanemasks == '1'))
+
+ if (Config->ConfValueBool(Config->config_data, "insane","nickmasks",0))
return false;
- long matches = 0;
+
for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++)
{
if (match(u->second->nick,nick.c_str()))
matches++;
}
+
float percent = ((float)matches / (float)clientlist.size()) * 100;
if (percent > (float)atof(itrigger))
{