mirror of
https://github.com/inspircd/inspircd.git
synced 2025-04-20 23:11:28 -04:00
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:
parent
4d9af8667f
commit
98df7c960c
@ -53,7 +53,7 @@ class BlockCaps : public ModeHandler
|
|||||||
class ModuleBlockCAPS : public Module
|
class ModuleBlockCAPS : public Module
|
||||||
{
|
{
|
||||||
BlockCaps* bc;
|
BlockCaps* bc;
|
||||||
unsigned int percent;
|
float percent;
|
||||||
unsigned int minlen;
|
unsigned int minlen;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -77,22 +77,22 @@ public:
|
|||||||
|
|
||||||
virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
|
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 (target_type == TYPE_CHANNEL)
|
||||||
{
|
{
|
||||||
|
if ((!IS_LOCAL(user)) || (text.length() < minlen))
|
||||||
|
return 0;
|
||||||
|
|
||||||
chanrec* c = (chanrec*)dest;
|
chanrec* c = (chanrec*)dest;
|
||||||
|
|
||||||
if (c->IsModeSet('P'))
|
if (c->IsModeSet('P'))
|
||||||
{
|
{
|
||||||
int caps = 0;
|
float caps = 0;
|
||||||
for (std::string::iterator i = text.begin(); i != text.end(); i++)
|
for (std::string::iterator i = text.begin(); i != text.end(); i++)
|
||||||
{
|
{
|
||||||
if ( (*i >= 'A') && (*i <= 'Z'))
|
if ( (*i >= 'A') && (*i <= 'Z'))
|
||||||
caps++;
|
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);
|
user->WriteServ( "404 %s %s :Can't send all-CAPS to channel (+P set)", user->nick, c->name);
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user