nSpamProtection Class Reference

#include <nSpamProtection.h>

Collaboration diagram for nSpamProtection:

Collaboration graph
[legend]

List of all members.

Public Types

enum  Level { Level_Ok, Level_Mild, Level_Hard }

Public Member Functions

Level CheckSpam (REAL spamlevel, int UserToKick, tOutput const &message)
REAL BlockTime ()
 nSpamProtection (const nSpamProtectionSettings &settings)
 ~nSpamProtection ()

Private Attributes

const nSpamProtectionSettingssettings_
REAL spamProtect_
nTimeRolling spamProtectTime_


Detailed Description

Definition at line 48 of file nSpamProtection.h.


Member Enumeration Documentation

enum nSpamProtection::Level

Enumerator:
Level_Ok 
Level_Mild 
Level_Hard 

Definition at line 51 of file nSpamProtection.h.

00052     {
00053         Level_Ok,                               // no spam
00054         Level_Mild,                             // some level of spam
00055         Level_Hard                              // extremly annoying
00056     };


Constructor & Destructor Documentation

nSpamProtection::nSpamProtection ( const nSpamProtectionSettings settings  ) 

Definition at line 54 of file nSpamProtection.cpp.

00055         : settings_( settings ), spamProtect_( 0.0f ), spamProtectTime_( tSysTimeFloat( ))
00056 {
00057 }

nSpamProtection::~nSpamProtection ( void   ) 

Definition at line 59 of file nSpamProtection.cpp.

00060 {
00061 }


Member Function Documentation

nSpamProtection::Level nSpamProtection::CheckSpam ( REAL  spamlevel,
int  UserToKick,
tOutput const &  message 
)

Definition at line 69 of file nSpamProtection.cpp.

References tOutput::Append(), Level_Hard, Level_Mild, Level_Ok, REAL, se_SpamAutoKick, se_SpamPenalty, se_SpamProtection, tOutput::SetTemplateParameter(), settings_, nSpamProtectionSettings::silence_, sn_ConsoleOut(), sn_KickUser(), spamProtect_, spamProtectTime_, nSpamProtectionSettings::timeScale_, and tSysTimeFloat().

Referenced by eChatSpamTester::Check(), eVoter::IsSpamming(), ePlayerNetID::ReceiveControlNet(), and eVoter::Spam().

00070 {
00071     if ( se_SpamProtection < 0.01f )
00072     {
00073         se_SpamProtection = 0.01f;
00074     }
00075 
00076     REAL timeScale = this->settings_.timeScale_ * se_SpamProtection;
00077 
00078     spamProtect_ += spamlevel;
00079     spamProtect_ -=( tSysTimeFloat() - spamProtectTime_ ) / timeScale;
00080 
00081     spamProtectTime_ = tSysTimeFloat();
00082     if ( spamProtect_ < 0 )
00083         spamProtect_ = 0;
00084 
00085     if ( spamProtect_ > 6 ){
00086         tOutput message;
00087         spamProtect_ += se_SpamPenalty;
00088 
00089         message.SetTemplateParameter(1, ( spamProtect_ - 6 ) * timeScale );
00090         message.Append( settings_.silence_ );
00091 
00092         //              message << ColorString (1,1,0);
00093         //              message << "$spam_protection";
00094 
00095         sn_ConsoleOut(message,userToKick);
00096 
00097         if ( spamProtect_ > se_SpamAutoKick )
00098         {
00099             tOutput message( "$network_kill_spamkick" );
00100             message.Append( " " );
00101             message.Append( reason );
00102             sn_KickUser( userToKick, message );
00103 
00104             return Level_Hard;
00105         }
00106 
00107         return Level_Mild;
00108     }
00109 
00110     return Level_Ok;
00111 }

Here is the call graph for this function:

Here is the caller graph for this function:

REAL nSpamProtection::BlockTime (  ) 

Definition at line 63 of file nSpamProtection.cpp.

References REAL, se_SpamProtection, settings_, spamProtect_, spamProtectTime_, nSpamProtectionSettings::timeScale_, and tSysTimeFloat().

00064 {
00065     REAL timeScale = this->settings_.timeScale_ * se_SpamProtection;
00066     return ( spamProtect_ - 6 ) * timeScale + ( tSysTimeFloat() - spamProtectTime_ );
00067 }

Here is the call graph for this function:


Member Data Documentation

const nSpamProtectionSettings& nSpamProtection::settings_ [private]

Definition at line 65 of file nSpamProtection.h.

Referenced by BlockTime(), and CheckSpam().

REAL nSpamProtection::spamProtect_ [private]

Definition at line 66 of file nSpamProtection.h.

Referenced by BlockTime(), and CheckSpam().

nTimeRolling nSpamProtection::spamProtectTime_ [private]

Definition at line 67 of file nSpamProtection.h.

Referenced by BlockTime(), and CheckSpam().


The documentation for this class was generated from the following files:
Generated on Sat Mar 15 23:50:57 2008 for Armagetron Advanced by  doxygen 1.5.4