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
This commit is contained in:
brain 2007-03-14 17:55:26 +00:00
parent 4d9af8667f
commit 98df7c960c

View File

@ -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;