src/engine/eVoter.cpp File Reference

#include "rSDL.h"
#include "eVoter.h"
#include "tMemManager.h"
#include "tSysTime.h"
#include "tDirectories.h"
#include "uMenu.h"
#include "nConfig.h"
#include "nServerInfo.h"
#include "rConsole.h"
#include "ePlayer.h"
#include "eGrid.h"

Include dependency graph for eVoter.cpp:

Go to the source code of this file.

Classes

class  eVoteItem
class  eMenuItemVote
class  eVoteItemServerControlled
class  nMachineObserver
class  eVoteItemHarm
class  eVoteItemKick
class  eVoteItemHarmServerControlled
class  eVoteItemSuspend
class  eVoteItemKickServerControlled
class  eMenuItemKick

Enumerations

enum  Vote { Vote_Approve, Vote_Reject, Vote_DontMind }

Functions

static eVoterse_GetVoter (const nMessage &m)
static tAccessLevel se_GetAccessLevel (int userID)
void se_CancelAllVotes (std::istream &)
static void se_HandleServerVoteChanged (nMessage &m)
static void se_HandleNewServerVote (nMessage &m)
void se_VoteKickUser (int user)
void se_VoteKickPlayer (ePlayerNetID *p)
static void se_HandleKickVote (nMessage &m)
static void se_SendKick (ePlayerNetID *p)
static bool se_KeepConsoleSmall ()
static void se_Cleanup ()

Variables

static bool se_useServerControlledKick = false
static nSettingItem< bool > se_usc ("VOTE_USE_SERVER_CONTROLLED_KICK", se_useServerControlledKick)
static unsigned short se_votingItemID = 0
static float se_votingTimeout = 300.0f
static nSettingItem< float > se_vt ("VOTING_TIMEOUT", se_votingTimeout)
static float se_votingTimeoutPerVoter = 0.0f
static nSettingItem< float > se_vtp ("VOTING_TIMEOUT_PER_VOTER", se_votingTimeoutPerVoter)
static float se_votingStartDecay = 60.0f
static nSettingItem< float > se_vsd ("VOTING_START_DECAY", se_votingStartDecay)
static float se_votingDecay = 60.0f
static nSettingItem< float > se_vd ("VOTING_DECAY", se_votingDecay)
static float se_votingSpamIssue = 1.0f
static nSettingItem< float > se_vsi ("VOTING_SPAM_ISSUE", se_votingSpamIssue)
static float se_votingSpamReject = 5.0f
static nSettingItem< float > se_vsr ("VOTING_SPAM_REJECT", se_votingSpamReject)
static bool se_allowVoting = false
static tSettingItem< bool > se_av ("ALLOW_VOTING", se_allowVoting)
static bool se_allowVotingSpectator = false
static tSettingItem< bool > se_avo ("ALLOW_VOTING_SPECTATOR", se_allowVotingSpectator)
static int se_suspendRounds = 5
static tSettingItem< int > se_sr ("VOTING_SUSPEND_ROUNDS", se_suspendRounds)
static int se_minVoters = 3
static tSettingItem< int > se_mv ("MIN_VOTERS", se_minVoters)
static int se_votingBias = 0
static tSettingItem< int > se_vb ("VOTING_BIAS", se_votingBias)
static int se_votingBiasKick = 0
static tSettingItem< int > se_vbKick ("VOTING_BIAS_KICK", se_votingBiasKick)
static int se_votingBiasSuspend = 0
static tSettingItem< int > se_vbSuspend ("VOTING_BIAS_SUSPEND", se_votingBiasSuspend)
static int se_votingBiasInclude = 0
static tSettingItem< int > se_vbInclude ("VOTING_BIAS_INCLUDE", se_votingBiasInclude)
static int se_votingBiasCommand = 0
static tSettingItem< int > se_vbCommand ("VOTING_BIAS_COMMAND", se_votingBiasCommand)
static int se_votingPrivacy = 1
static tSettingItem< int > se_vp ("VOTING_PRIVACY", se_votingPrivacy)
static int se_maxVotes = 5
static tSettingItem< int > se_maxVotesSI ("MAX_VOTES", se_maxVotes)
static int se_maxVotesPerVoter = 2
static tSettingItem< int > se_maxVotesPerVoterSI ("MAX_VOTES_PER_VOTER", se_maxVotesPerVoter)
static int se_minTimeBetweenKicks = 300
static tSettingItem< int > se_minTimeBetweenKicksSI ("VOTING_KICK_TIME", se_minTimeBetweenKicks)
static int se_minTimeBetweenHarms = 180
static tSettingItem< int > se_minTimeBetweenHarmsSI ("VOTING_HARM_TIME", se_minTimeBetweenHarms)
static int se_votingMaturity = 300
static tSettingItem< int > se_votingMaturitySI ("VOTING_MATURITY", se_votingMaturity)
static tConfItemFunc se_cancelAllVotes_conf ("VOTES_CANCEL",&se_CancelAllVotes)
static nDescriptor vote_handler (230, eVoteItem::GetControlMessage,"vote cast")
static nDescriptor server_vote_expired_handler (233, se_HandleServerVoteChanged,"Server controlled vote expired")
static nDescriptor new_server_vote_handler (232, se_HandleNewServerVote,"Server controlled vote")
static tString se_voteKickToServer ("")
static int se_voteKickToPort = 4534
static tSettingItem< tStringse_voteKickToServerConf ("VOTE_KICK_TO_SERVER", se_voteKickToServer)
static tSettingItem< int > se_voteKickToPortConf ("VOTE_KICK_TO_PORT", se_voteKickToPort)
static int se_kickMinHarm = 0
static tSettingItem< int > se_kickMinHarmSI ("VOTING_KICK_MINHARM", se_kickMinHarm)
static tString se_voteKickReason ("")
static tConfItemLine se_voteKickReasonConf ("VOTE_KICK_REASON", se_voteKickReason)
static nDescriptor kill_vote_handler (231, se_HandleKickVote,"Kick vote")
static nSpamProtectionSettings se_voteSpamProtection (50.0f,"SPAM_PROTECTION_VOTE", tOutput("$vote_spam_protection"))
static uMenuvotingMenu = 0
static nCallbackLoginLogout se_cleanup (se_Cleanup)


Enumeration Type Documentation

enum Vote

Enumerator:
Vote_Approve 
Vote_Reject 
Vote_DontMind 

Definition at line 709 of file eVoter.cpp.

00710 {
00711     Vote_Approve,
00712     Vote_Reject,
00713     Vote_DontMind
00714 };


Function Documentation

void se_CancelAllVotes ( std::istream &   ) 

Definition at line 669 of file eVoter.cpp.

References eVoteItem::GetItems(), GrowingArrayBase::Len(), nCLIENT, sn_ConsoleOut(), and sn_GetNetState().

00670 {
00671     if ( sn_GetNetState() == nCLIENT )
00672     {
00673         return;
00674     }
00675 
00676     sn_ConsoleOut( tOutput( "$vote_cancel_all" ) );
00677 
00678     tList< eVoteItem > const & items = eVoteItem::GetItems();
00679     
00680     while ( items.Len() )
00681     {
00682         delete items(0);
00683     }
00684 }

Here is the call graph for this function:

static void se_Cleanup (  )  [static]

Definition at line 1915 of file eVoter.cpp.

References eVoteItem::CreateMessage(), eGrid::CurrentGrid(), uMenu::Exit(), eVoteItem::GetItems(), GrowingArrayBase::Len(), nCallbackLoginLogout::Login(), nMessage::Send(), nCallbackLoginLogout::User(), and votingMenu.

01916 {
01917     if ( nCallbackLoginLogout::User() == 0 )
01918     {
01919         if ( votingMenu )
01920         {
01921             votingMenu->Exit();
01922         }
01923 
01924         if ( !nCallbackLoginLogout::Login() && eGrid::CurrentGrid() )
01925         {
01926             //                  uMenu::exitToMain = true;
01927         }
01928 
01929         // client login/logout: delete voting items
01930         const tList< eVoteItem >& list = eVoteItem::GetItems();
01931         while ( list.Len() > 0 )
01932         {
01933             delete list(0);
01934         }
01935     }
01936     else if ( nCallbackLoginLogout::Login() )
01937     {
01938         // new user: send pending voting items
01939         const tList< eVoteItem >& list = eVoteItem::GetItems();
01940         for ( int i = list.Len()-1; i >= 0; -- i)
01941         {
01942             eVoteItem* vote = list( i );
01943             nMessage* m = vote->CreateMessage();
01944             m->Send( nCallbackLoginLogout::User() );
01945         }
01946     }
01947 }

Here is the call graph for this function:

static tAccessLevel se_GetAccessLevel ( int  userID  )  [static]

Definition at line 166 of file eVoter.cpp.

References eAccessLevelHolder::GetAccessLevel(), GrowingArrayBase::Len(), nNetObject::Owner(), se_PlayerNetIDs, and tAccessLevel_Default.

Referenced by eVoteItem::CheckValid().

00167 {
00168     tAccessLevel ret = tAccessLevel_Default;
00169 
00170     // scan players of given user ID
00171     for ( int i = se_PlayerNetIDs.Len()-1; i>=0; --i )
00172     {
00173         ePlayerNetID* p = se_PlayerNetIDs(i);
00174         
00175         if ( p->Owner() == userID )
00176         {
00177             if( p->GetAccessLevel() < ret )
00178             {
00179                 ret = p->GetAccessLevel();
00180             }
00181         }
00182     }
00183     
00184     return ret;
00185 }

Here is the call graph for this function:

Here is the caller graph for this function:

static eVoter* se_GetVoter ( const nMessage m  )  [static]

Definition at line 159 of file eVoter.cpp.

References eVoter::GetVoter(), and nMessage::SenderID().

Referenced by eVoteItem::AcceptNewVote(), and eVoteItem::GetControlMessage().

00160 {
00161     return eVoter::GetVoter( m.SenderID(), true );
00162 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void se_HandleKickVote ( nMessage m  )  [static]

Definition at line 1386 of file eVoter.cpp.

References eVoteItem::AcceptNewVote(), eVoteItem::FillFromMessage(), and tNEW.

01387 {
01388     // accept message
01389     if ( eVoteItem::AcceptNewVote( m ) )
01390     {
01391         eVoteItemHarm* item = tNEW( eVoteItemKickServerControlled )( true, 0 );
01392         if ( !item->FillFromMessage( m ) )
01393         {
01394             delete item;
01395             return;
01396         }
01397     }
01398 }

Here is the call graph for this function:

static void se_HandleNewServerVote ( nMessage m  )  [static]

Definition at line 896 of file eVoter.cpp.

References eVoteItem::AcceptNewVote(), eVoteItem::FillFromMessage(), nCLIENT, sn_GetNetState(), and tNEW.

00897 {
00898     if ( sn_GetNetState() != nCLIENT ||  eVoteItem::AcceptNewVote( m ) )
00899     {
00900         // accept message
00901         eVoteItem* item = tNEW( eVoteItemServerControlled )();
00902         if ( !item->FillFromMessage( m ) )
00903             delete item;
00904     }
00905 }

Here is the call graph for this function:

static void se_HandleServerVoteChanged ( nMessage m  )  [static]

Definition at line 891 of file eVoter.cpp.

References eVoteItemServerControlled::s_HandleChanged().

00892 {
00893     eVoteItemServerControlled::s_HandleChanged( m );
00894 }

Here is the call graph for this function:

static bool se_KeepConsoleSmall (  )  [static]

Definition at line 1778 of file eVoter.cpp.

Referenced by eVoter::VotingMenu().

01779 {
01780     return true;
01781 }

Here is the caller graph for this function:

static void se_SendKick ( ePlayerNetID p  )  [static]

Definition at line 1408 of file eVoter.cpp.

References eVoteItem::SendMessage().

Referenced by eMenuItemKick::Enter().

01409 {
01410     eVoteItemKick kick( p );
01411     kick.SendMessage();
01412 }

Here is the call graph for this function:

Here is the caller graph for this function:

void se_VoteKickPlayer ( ePlayerNetID p  ) 

Definition at line 981 of file eVoter.cpp.

References nNetObject::Owner(), and se_VoteKickUser().

Referenced by eVoteItemKick::DoExecute(), and eMenuItemKick::Enter().

00982 {
00983     if ( !p )
00984     {
00985         return;
00986     }
00987 
00988     se_VoteKickUser( p->Owner() );
00989 }

Here is the call graph for this function:

Here is the caller graph for this function:

void se_VoteKickUser ( int  user  ) 

Definition at line 952 of file eVoter.cpp.

References tString::Len(), se_voteKickReason, se_voteKickToPort, se_voteKickToServer, and sn_KickUser().

Referenced by eVoteItemKick::DoExecute(), and se_VoteKickPlayer().

00953 {
00954     if ( user == 0 )
00955     {
00956         return;
00957     }
00958 
00959     tString reason;
00960     if ( se_voteKickReason.Len() >= 2 )
00961     {
00962         reason = se_voteKickReason;
00963     }
00964     else
00965     {
00966         reason = tOutput("$voted_kill_kick");
00967     }
00968 
00969     if ( se_voteKickToServer.Len() < 2 )
00970     {
00971         sn_KickUser( user, reason );
00972     }
00973     else
00974     {
00975         // kick player to default destination
00976         nServerInfoRedirect redirect( se_voteKickToServer, se_voteKickToPort );
00977         sn_KickUser( user, reason, 1, &redirect );
00978     }
00979 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

nDescriptor kill_vote_handler(231, se_HandleKickVote,"Kick vote") [static]

Referenced by eVoteItemHarm::DoGetDescriptor().

nDescriptor new_server_vote_handler(232, se_HandleNewServerVote,"Server controlled vote") [static]

Referenced by eVoteItemServerControlled::DoGetDescriptor().

bool se_allowVoting = false [static]

Definition at line 75 of file eVoter.cpp.

Referenced by eVoteItem::AcceptNewVote().

bool se_allowVotingSpectator = false [static]

Definition at line 78 of file eVoter.cpp.

Referenced by eVoter::GetVoter().

tSettingItem< bool > se_av("ALLOW_VOTING", se_allowVoting) [static]

tSettingItem< bool > se_avo("ALLOW_VOTING_SPECTATOR", se_allowVotingSpectator) [static]

tConfItemFunc se_cancelAllVotes_conf("VOTES_CANCEL",&se_CancelAllVotes) [static]

nCallbackLoginLogout se_cleanup(se_Cleanup) [static]

int se_kickMinHarm = 0 [static]

Definition at line 945 of file eVoter.cpp.

Referenced by eVoteItemKickServerControlled::DoCheckValid().

tSettingItem< int > se_kickMinHarmSI("VOTING_KICK_MINHARM", se_kickMinHarm) [static]

int se_maxVotes = 5 [static]

Definition at line 113 of file eVoter.cpp.

Referenced by eVoteItem::AcceptNewVote().

int se_maxVotesPerVoter = 2 [static]

Definition at line 117 of file eVoter.cpp.

Referenced by eVoteItem::AcceptNewVote().

tSettingItem< int > se_maxVotesPerVoterSI("MAX_VOTES_PER_VOTER", se_maxVotesPerVoter) [static]

tSettingItem< int > se_maxVotesSI("MAX_VOTES", se_maxVotes) [static]

int se_minTimeBetweenHarms = 180 [static]

Definition at line 125 of file eVoter.cpp.

Referenced by eVoteItemHarm::DoCheckValid().

tSettingItem< int > se_minTimeBetweenHarmsSI("VOTING_HARM_TIME", se_minTimeBetweenHarms) [static]

int se_minTimeBetweenKicks = 300 [static]

Definition at line 121 of file eVoter.cpp.

Referenced by eVoter::AllowNameChange(), and eVoteItemKick::DoCheckValid().

tSettingItem< int > se_minTimeBetweenKicksSI("VOTING_KICK_TIME", se_minTimeBetweenKicks) [static]

int se_minVoters = 3 [static]

Definition at line 85 of file eVoter.cpp.

Referenced by eVoteItem::AcceptNewVote().

tSettingItem< int > se_mv("MIN_VOTERS", se_minVoters) [static]

tSettingItem< int > se_sr("VOTING_SUSPEND_ROUNDS", se_suspendRounds) [static]

int se_suspendRounds = 5 [static]

Definition at line 82 of file eVoter.cpp.

Referenced by eVoteItemSuspend::DoExecute().

nSettingItem< bool > se_usc("VOTE_USE_SERVER_CONTROLLED_KICK", se_useServerControlledKick) [static]

bool se_useServerControlledKick = false [static]

Definition at line 48 of file eVoter.cpp.

tSettingItem< int > se_vb("VOTING_BIAS", se_votingBias) [static]

tSettingItem< int > se_vbCommand("VOTING_BIAS_COMMAND", se_votingBiasCommand) [static]

tSettingItem< int > se_vbInclude("VOTING_BIAS_INCLUDE", se_votingBiasInclude) [static]

tSettingItem< int > se_vbKick("VOTING_BIAS_KICK", se_votingBiasKick) [static]

tSettingItem< int > se_vbSuspend("VOTING_BIAS_SUSPEND", se_votingBiasSuspend) [static]

nSettingItem< float > se_vd("VOTING_DECAY", se_votingDecay) [static]

tString se_voteKickReason("") [static]

Referenced by se_VoteKickUser().

tConfItemLine se_voteKickReasonConf("VOTE_KICK_REASON", se_voteKickReason) [static]

int se_voteKickToPort = 4534 [static]

Definition at line 938 of file eVoter.cpp.

Referenced by se_VoteKickUser().

tSettingItem< int > se_voteKickToPortConf("VOTE_KICK_TO_PORT", se_voteKickToPort) [static]

tString se_voteKickToServer("") [static]

Referenced by se_VoteKickUser().

tSettingItem< tString > se_voteKickToServerConf("VOTE_KICK_TO_SERVER", se_voteKickToServer) [static]

nSpamProtectionSettings se_voteSpamProtection(50.0f,"SPAM_PROTECTION_VOTE", tOutput("$vote_spam_protection")) [static]

int se_votingBias = 0 [static]

Definition at line 89 of file eVoter.cpp.

Referenced by eVoteItem::Evaluate().

int se_votingBiasCommand = 0 [static]

Definition at line 105 of file eVoter.cpp.

int se_votingBiasInclude = 0 [static]

Definition at line 101 of file eVoter.cpp.

int se_votingBiasKick = 0 [static]

Definition at line 93 of file eVoter.cpp.

Referenced by eVoteItemKick::DoGetExtraBias().

int se_votingBiasSuspend = 0 [static]

Definition at line 97 of file eVoter.cpp.

Referenced by eVoteItemSuspend::DoGetExtraBias().

float se_votingDecay = 60.0f [static]

Definition at line 64 of file eVoter.cpp.

Referenced by eVoteItem::Evaluate().

unsigned short se_votingItemID = 0 [static]

Definition at line 53 of file eVoter.cpp.

int se_votingMaturity = 300 [static]

Definition at line 129 of file eVoter.cpp.

Referenced by eVoteItemHarm::DoCheckValid().

tSettingItem< int > se_votingMaturitySI("VOTING_MATURITY", se_votingMaturity) [static]

int se_votingPrivacy = 1 [static]

Definition at line 109 of file eVoter.cpp.

Referenced by eVoteItem::AcceptNewVote(), eVoteItem::DoGetDetails(), eVoteItem::FillFromMessage(), eVoteItem::GetControlMessage(), eVoter::HandleChat(), and eVoteItem::ReBroadcast().

float se_votingSpamIssue = 1.0f [static]

Definition at line 68 of file eVoter.cpp.

Referenced by eVoteItem::AcceptNewVote().

float se_votingSpamReject = 5.0f [static]

Definition at line 72 of file eVoter.cpp.

Referenced by eVoteItem::Evaluate().

float se_votingStartDecay = 60.0f [static]

Definition at line 61 of file eVoter.cpp.

Referenced by eVoteItem::Evaluate().

float se_votingTimeout = 300.0f [static]

Definition at line 54 of file eVoter.cpp.

Referenced by eVoteItem::Evaluate().

float se_votingTimeoutPerVoter = 0.0f [static]

Definition at line 58 of file eVoter.cpp.

Referenced by eVoteItem::Evaluate().

tSettingItem< int > se_vp("VOTING_PRIVACY", se_votingPrivacy) [static]

nSettingItem< float > se_vsd("VOTING_START_DECAY", se_votingStartDecay) [static]

nSettingItem< float > se_vsi("VOTING_SPAM_ISSUE", se_votingSpamIssue) [static]

nSettingItem< float > se_vsr("VOTING_SPAM_REJECT", se_votingSpamReject) [static]

nSettingItem< float > se_vt("VOTING_TIMEOUT", se_votingTimeout) [static]

nSettingItem< float > se_vtp("VOTING_TIMEOUT_PER_VOTER", se_votingTimeoutPerVoter) [static]

nDescriptor server_vote_expired_handler(233, se_HandleServerVoteChanged,"Server controlled vote expired") [static]

Referenced by eVoteItemServerControlled::SendChanged().

nDescriptor vote_handler(230, eVoteItem::GetControlMessage,"vote cast") [static]

Referenced by eVoteItem::Vote().

uMenu* votingMenu = 0 [static]

Definition at line 1784 of file eVoter.cpp.

Referenced by se_Cleanup(), and eVoter::VotingMenu().


Generated on Sat Mar 15 22:59:41 2008 for Armagetron Advanced by  doxygen 1.5.4