src/engine/eVoter.h

Go to the documentation of this file.
00001 /*
00002 
00003 *************************************************************************
00004 
00005 ArmageTron -- Just another Tron Lightcycle Game in 3D.
00006 Copyright (C) 2000  Manuel Moos (manuel@moosnet.de)
00007 
00008 **************************************************************************
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00023 
00024 ***************************************************************************
00025 
00026 */
00027 
00028 #ifndef ArmageTron_VOTER_H
00029 #define ArmageTron_VOTER_H
00030 
00031 class ePlayerNetID;
00032 class eMenuItemVote;
00033 //class eVoteItem;
00034 
00035 #include "tSafePTR.h"
00036 #include "tList.h"
00037 #include "tString.h"
00038 
00039 #include "nNetObject.h"
00040 
00041 #include "nSpamProtection.h"
00042 
00043 // information in eVoter accessible for ePlayer only
00044 class eVoterPlayerInfo
00045 {
00046 public:
00047     friend class ePlayerNetID;
00048 
00049     eVoterPlayerInfo();
00050 private:
00051     int             suspended_;  
00052 };
00053 
00054 // class identifying a voter; all players coming from the same IP share the same voter.
00055 class eVoter: public tReferencable< eVoter >, public tListMember, public nMachineDecorator, public eVoterPlayerInfo
00056 {
00057     friend class eVoteItem;
00058     friend class eVoteItemHarm;
00059     friend class eVoteItemKick;
00060 public:
00061     eVoter( nMachine & machine );
00062     ~eVoter();
00063 
00064     void PlayerChanged();                                       
00065 
00066     void Spam( int user, REAL spamLevel, tOutput const & message );     // trigger spam guard
00067     bool IsSpamming( int user );                                                                // check if user has been found spamming
00068     void RemoveFromGame();                                                                              // remove from game
00069 
00070     static void KickMenu();                                                                             // activate player kick menu
00071     static void VotingMenu();                                                                   // activate voting menu ( you can vote about suggestions there )
00072     static eVoter* GetVoter ( int ID, bool complain = false );  // find or create the voter for the specified user ID
00073     static eVoter* GetVoter ( nMachine & machine );                 // find or create the voter for the specified machine
00074     static bool VotingPossible();                                                               // returns whether voting is currently possible
00075 
00076     static void HandleChat( ePlayerNetID * p, std::istream & message ); 
00077 
00078     tString Name(int senderID = -1) const;                                              // returns the name of the voter
00079 
00080     REAL Age() const;                                           
00081 
00082     bool AllowNameChange() const;  
00083 
00085     int HarmCount() const
00086     {
00087         return harmCount_;
00088     }
00089 protected:
00090     virtual void OnDestroy();      
00091 
00092 private:
00093     //    static eVoter* GetVoterFromIP( tString IP );  // find or create the voter for the specified IP
00094     //    const tString IP_;                                                            // IP address of voter
00095     nMachine & machine_;                            // the machine this voter comes from
00096     static tList< eVoter > voters_;                                     // list of all voters
00097     nSpamProtection votingSpam_;                                        // spam control
00098     tJUST_CONTROLLED_PTR< eVoter > selfReference_;  
00099     int harmCount_;                                 
00100     double lastHarmVote_;                           
00101     double lastKickVote_;                           
00102     double lastNameChangePreventor_;                
00103     double lastChange_;                             
00104 };
00105 
00106 
00107 #endif  // ArmageTron_VOTER_H
00108 

Generated on Sat Mar 15 22:55:48 2008 for Armagetron Advanced by  doxygen 1.5.4