Public Member Functions | |
eVoteItemHarm (ePlayerNetID *player=0) | |
~eVoteItemHarm () | |
ePlayerNetID * | GetPlayer () const |
Protected Member Functions | |
virtual nDescriptor * | DoGetDescriptorLegacy () const |
virtual void | DoFillToMessageLegacy (nMessage &m) const |
virtual bool | DoFillFromMessage (nMessage &m) |
virtual bool | DoCheckValid (int senderID) |
virtual void | DoFillToMessage (nMessage &m) const |
virtual nDescriptor & | DoGetDescriptor () const |
virtual char const * | DoGetPrefix () const =0 |
virtual tString | DoGetDescription () const |
virtual tString | DoGetDetails () const |
nMachine * | GetMachine () const |
Private Attributes | |
nObserverPtr< ePlayerNetID > | player_ |
nMachineObserver * | machine_ |
tString | name_ |
Definition at line 992 of file eVoter.cpp.
eVoteItemHarm::eVoteItemHarm | ( | ePlayerNetID * | player = 0 |
) | [inline] |
eVoteItemHarm::~eVoteItemHarm | ( | ) | [inline] |
ePlayerNetID* eVoteItemHarm::GetPlayer | ( | ) | const [inline] |
Definition at line 1009 of file eVoter.cpp.
01010 { 01011 ePlayerNetID const * player = player_; 01012 return const_cast< ePlayerNetID * >( player ); 01013 }
virtual nDescriptor* eVoteItemHarm::DoGetDescriptorLegacy | ( | ) | const [inline, protected, virtual] |
Reimplemented from eVoteItem.
Definition at line 1016 of file eVoter.cpp.
References DoGetDescriptor().
01017 { 01018 return &eVoteItemHarm::DoGetDescriptor(); 01019 }
virtual void eVoteItemHarm::DoFillToMessageLegacy | ( | nMessage & | m | ) | const [inline, protected, virtual] |
Reimplemented from eVoteItem.
Definition at line 1021 of file eVoter.cpp.
References DoFillToMessage().
01022 { 01023 return eVoteItemHarm::DoFillToMessage( m ); 01024 };
virtual bool eVoteItemHarm::DoFillFromMessage | ( | nMessage & | m | ) | [inline, protected, virtual] |
Reimplemented from eVoteItem.
Reimplemented in eVoteItemHarmServerControlled.
Definition at line 1026 of file eVoter.cpp.
References eVoteItem::DoFillFromMessage(), nNetObject::ObjectDangerous(), and nMessage::Read().
Referenced by eVoteItemHarmServerControlled::DoFillFromMessage().
01027 { 01028 // read player ID 01029 unsigned short id; 01030 m.Read(id); 01031 tJUST_CONTROLLED_PTR< ePlayerNetID > p=dynamic_cast<ePlayerNetID *>(nNetObject::ObjectDangerous(id)); 01032 player_ = p; 01033 01034 return eVoteItem::DoFillFromMessage( m ); 01035 }
virtual bool eVoteItemHarm::DoCheckValid | ( | int | senderID | ) | [inline, protected, virtual] |
Reimplemented from eVoteItem.
Reimplemented in eVoteItemKick, and eVoteItemKickServerControlled.
Definition at line 1037 of file eVoter.cpp.
References eVoteItem::DoCheckValid(), eVoter::GetVoter(), eVoter::harmCount_, eVoter::lastChange_, eVoter::lastHarmVote_, eVoter::lastNameChangePreventor_, eVoter::machine_, nCLIENT, REAL, se_minTimeBetweenHarms, se_votingMaturity, sn_ConsoleOut(), sn_GetNetState(), tNEW, and tSysTimeFloat().
Referenced by eVoteItemKickServerControlled::DoCheckValid(), and eVoteItemKick::DoCheckValid().
01038 { 01039 // always accept votes from server 01040 if ( sn_GetNetState() == nCLIENT && senderID == 0 ) 01041 { 01042 return true; 01043 } 01044 01045 eVoter * sender = eVoter::GetVoter( senderID ); 01046 01047 double time = tSysTimeFloat(); 01048 01049 // check whether the issuer is allowed to start a vote 01050 if ( sender && sender->lastChange_ + se_votingMaturity > tSysTimeFloat() && sender->lastChange_ * 2 > tSysTimeFloat() ) 01051 { 01052 REAL time = sender->lastChange_ + se_votingMaturity - tSysTimeFloat(); 01053 tOutput message( "$vote_maturity", time ); 01054 sn_ConsoleOut( message, senderID ); 01055 return false; 01056 } 01057 01058 // prevent the sender from changing his name for confusion 01059 if ( sender ) 01060 sender->lastNameChangePreventor_ = time; 01061 01062 // check if player is protected from kicking 01063 if ( player_ && sn_GetNetState() != nCLIENT ) 01064 { 01065 // check whether the player is on the server 01066 if ( player_->Owner() == 0 ) 01067 { 01068 sn_ConsoleOut( tOutput( "$vote_kick_local", player_->GetName() ), senderID ); 01069 return false; 01070 } 01071 01072 name_ = player_->GetName(); 01073 eVoter * voter = eVoter::GetVoter( player_->Owner() ); 01074 if ( voter ) 01075 { 01076 machine_ = tNEW( nMachineObserver )( voter->machine_ ); 01077 01078 if ( time < voter->lastHarmVote_ + se_minTimeBetweenHarms ) 01079 { 01080 tOutput message("$vote_redundant"); 01081 sn_ConsoleOut( message, senderID ); 01082 return false; 01083 } 01084 else 01085 { 01086 voter->lastHarmVote_ = time; 01087 voter->lastNameChangePreventor_ = time; 01088 } 01089 01090 // count harmful votes 01091 voter->harmCount_++; 01092 } 01093 } 01094 01095 return eVoteItem::DoCheckValid( senderID ); 01096 };
virtual void eVoteItemHarm::DoFillToMessage | ( | nMessage & | m | ) | const [inline, protected, virtual] |
Reimplemented from eVoteItem.
Reimplemented in eVoteItemHarmServerControlled.
Definition at line 1098 of file eVoter.cpp.
References eVoteItem::DoFillToMessage(), and nMessage::Write().
Referenced by DoFillToMessageLegacy().
01099 { 01100 if ( player_ ) 01101 m.Write( player_->ID() ); 01102 else 01103 m.Write( 0 ); 01104 01105 eVoteItem::DoFillToMessage( m ); 01106 };
nDescriptor & eVoteItemHarm::DoGetDescriptor | ( | ) | const [protected, virtual] |
Implements eVoteItem.
Reimplemented in eVoteItemHarmServerControlled.
Definition at line 1403 of file eVoter.cpp.
References kill_vote_handler.
Referenced by DoGetDescriptorLegacy().
01404 { 01405 return kill_vote_handler; 01406 }
virtual char const* eVoteItemHarm::DoGetPrefix | ( | ) | const [protected, pure virtual] |
Implemented in eVoteItemKick, and eVoteItemSuspend.
virtual tString eVoteItemHarm::DoGetDescription | ( | ) | const [inline, protected, virtual] |
Implements eVoteItem.
Reimplemented in eVoteItemHarmServerControlled.
Definition at line 1114 of file eVoter.cpp.
Referenced by eVoteItemHarmServerControlled::Update().
01115 { 01116 // get name from player 01117 if ( player_ ) 01118 name_ = player_->GetName(); 01119 01120 return tString( tOutput( tString("$") + DoGetPrefix() + "_player_text", name_ ) ); 01121 }
virtual tString eVoteItemHarm::DoGetDetails | ( | ) | const [inline, protected, virtual] |
Reimplemented from eVoteItem.
Reimplemented in eVoteItemHarmServerControlled.
Definition at line 1123 of file eVoter.cpp.
References eVoteItem::DoGetDetails().
Referenced by eVoteItemHarmServerControlled::Update().
01124 { 01125 // get name from player 01126 if ( player_ ) 01127 name_ = player_->GetName(); 01128 01129 return eVoteItem::DoGetDetails() + tString( tOutput( tString("$") + DoGetPrefix() + "_player_details_text", name_ ) ); 01130 }
nMachine* eVoteItemHarm::GetMachine | ( | ) | const [inline, protected] |
Definition at line 1132 of file eVoter.cpp.
01133 { 01134 if ( !machine_ ) 01135 { 01136 return 0; 01137 } 01138 else 01139 { 01140 return machine_->GetMachine(); 01141 } 01142 }
nObserverPtr< ePlayerNetID > eVoteItemHarm::player_ [private] |
Definition at line 1144 of file eVoter.cpp.
Referenced by eMenuItemKick::eMenuItemKick(), and eMenuItemKick::Enter().
nMachineObserver* eVoteItemHarm::machine_ [private] |
Definition at line 1145 of file eVoter.cpp.
tString eVoteItemHarm::name_ [mutable, private] |