summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-03-14 17:55:26 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-03-14 17:55:26 +0000
commit98df7c960ca6a450f31de31b83d8877063ac2058 (patch)
tree04668e469805f2ed76ab4d82eca4a7a18a69c2fe
parent4d9af8667fab0cb8bfa45e0844b4a7bd3220b151 (diff)
Fix blockcaps. Who on earth thought that percentage was x*100 / y ???
Its (x/y)*100, muppets :p (also, you cant do floating point maths on integers) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6672 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/modules/m_blockcaps.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/modules/m_blockcaps.cpp b/src/modules/m_blockcaps.cpp
index 856f0c969..c1edcfd04 100644
--- a/src/modules/m_blockcaps.cpp
+++ b/src/modules/m_blockcaps.cpp
@@ -53,7 +53,7 @@ class BlockCaps : public ModeHandler
class ModuleBlockCAPS : public Module
{
BlockCaps* bc;
- unsigned int percent;
+ float percent;
unsigned int minlen;
public:
@@ -77,22 +77,22 @@ public:
virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
- if ((text.size() < minlen) || (!IS_LOCAL(user)))
- return 0;
-
if (target_type == TYPE_CHANNEL)
{
+ if ((!IS_LOCAL(user)) || (text.length() < minlen))
+ return 0;
+
chanrec* c = (chanrec*)dest;
if (c->IsModeSet('P'))
{
- int caps = 0;
+ float caps = 0;
for (std::string::iterator i = text.begin(); i != text.end(); i++)
{
if ( (*i >= 'A') && (*i <= 'Z'))
caps++;
}
- if ( (caps * 100 / text.size()) >= percent )
+ if ( ((caps / text.length()) * 100) >= percent )
{
user->WriteServ( "404 %s %s :Can't send all-CAPS to channel (+P set)", user->nick, c->name);
return 1;