#include <ePlayer.h>
Public Types | |
enum | ChatFlags { ChatFlags_Chat = 1, ChatFlags_Away = 2, ChatFlags_Menu = 4, ChatFlags_Console = 4 } |
typedef std::set< eTeam * > | eTeamSet |
Public Member Functions | |
ePlayerNetID (int p=-1) | |
ePlayerNetID (nMessage &m) | |
virtual | ~ePlayerNetID () |
virtual bool | ActionOnQuit () |
virtual void | ActionOnDelete () |
bool | IsChatting () const |
void | SetChatting (ChatFlags flag, bool chatting) |
bool | IsSpectating () const |
bool | StealthMode () const |
bool | TeamChangeAllowed (bool informPlayer=false) const |
is this player allowed to change teams? | |
void | SetTeamChangeAllowed (bool allowed) |
set if this player should always be allowed to change teams | |
eTeam * | NextTeam () const |
eTeam * | CurrentTeam () const |
int | TeamListID () const |
eTeam * | FindDefaultTeam () |
void | SetDefaultTeam () |
void | SetTeamForce (eTeam *team) |
void | SetTeam (eTeam *team) |
void | SetTeamWish (eTeam *team) |
void | SetTeamname (const char *) |
void | UpdateTeamForce () |
void | UpdateTeam () |
eTeamSet const & | GetInvitations () const |
teams this player is invited to | |
void | CreateNewTeam () |
void | CreateNewTeamWish () |
virtual void | ReceiveControlNet (nMessage &m) |
virtual void | PrintName (tString &s) const |
virtual bool | AcceptClientSync () const |
virtual void | WriteSync (nMessage &m) |
virtual void | ReadSync (nMessage &m) |
virtual nDescriptor & | CreatorDescriptor () const |
virtual void | InitAfterCreation () |
virtual bool | ClearToTransmit (int user) const |
virtual void | NewObject () |
virtual void | RightBeforeDeath (int triesLeft) |
void | RemoveFromGame () |
virtual void | ControlObject (eNetGameObject *c) |
virtual void | ClearObject () |
void | Greet () |
void | Suspend (int rounds=5) |
bool | IsActive () const |
bool | IsSilenced (void) const |
void | SetSilenced (bool silenced) |
bool & | AccessSilenced (void) |
eVoter * | GetVoter () const |
void | CreateVoter () |
virtual bool | IsHuman () const |
void | Activity () |
REAL | LastActivity () const |
returns how long the last activity of this player was ago | |
eNetGameObject * | Object () const |
void | AddScore (int points, const tOutput &reasonwin, const tOutput &reasonlose) |
int | Score () const |
int | TotalScore () const |
void | LogScoreDifference () |
void | GreetHighscores (tString &s) |
void | GetScoreFromDisconnectedCopy () |
void | Chat (const tString &s) |
virtual void | Color (REAL &r, REAL &g, REAL &b) const |
virtual void | TrailColor (REAL &r, REAL &g, REAL &b) const |
bool | IsLoggedIn () const |
void | BeLoggedIn () |
void | BeNotLoggedIn () |
tAccessLevel | GetLastAccessLevel () const |
void | UpdateName () |
update the player name from the client's wishes | |
tColoredString const & | GetNameFromClient (void) const |
Gets this player's name as the client wants it to be. Avoid using it when possilbe. | |
ePlayerNetID const & | GetNameFromClient (tColoredString &nameFromClient) const |
Gets this player's name as the client wants it to be. Avoid using it when possilbe. | |
tColoredString const & | GetColoredName (void) const |
Gets this player's name, cleared by the server. Use this for onscreen screen display. | |
ePlayerNetID const & | GetColoredName (tColoredString &coloredName) const |
Gets this player's name, cleared by the server. Use this for onscreen screen display. | |
tString const & | GetName (void) const |
Gets this player's name without colors. | |
ePlayerNetID const & | GetName (tString &name) const |
Gets this player's name without colors. | |
tString const & | GetUserName (void) const |
Gets this player's full name. Use for writing to files or comparing with admin input. | |
ePlayerNetID const & | GetUserName (tString &userName) const |
Gets this player's name, cleared for system logs. Use for writing to files or comparing with admin input. | |
tString const & | GetLogName (void) const |
Gets this player's name, cleared for system logs (with escaped special characters). Use for writing to files. | |
tString | GetFilteredAuthenticatedName (void) const |
Gets the filtered, ecaped authentication name. | |
ePlayerNetID & | SetName (tString const &name) |
Sets this player's name. Sets processed names (colored, username, nameFromCLient) as well. | |
ePlayerNetID & | SetName (char const *name) |
Sets this player's name. Sets processed names (colored, username, nameFromCLient) as well. | |
ePlayerNetID & | SetUserName (tString const &userName) |
Sets this player's name, cleared for system logs. Use for writing to files or comparing with admin input. The other names stay unaffected. | |
Static Public Member Functions | |
static bool | Enemies (ePlayerNetID const *a, ePlayerNetID const *b) |
determines whether two players are opponents and can score points against each other | |
static void | RequestScheduledLogins () |
initiates login processes for all pending wishes | |
static void | SilenceMenu () |
static void | PoliceMenu () |
static void | ResetScoreDifferences () |
static void | LogScoreDifferences () |
static void | SortByScore () |
static tString | Ranking (int MAX=12, bool cut=true) |
static float | RankingGraph (float y, int MAX) |
static void | RankingLadderLog () |
static void | ResetScore () |
static void | DisplayScores () |
static void | Update () |
static bool | WaitToLeaveChat () |
waits for players to leave chat state. Returns true if the caller should wait to proceed with whatever he wants to do. | |
static void | RemoveChatbots () |
removes chatbots and idling players from the game | |
static void | CompleteRebuild () |
static void | ClearAll () |
static void | SpectateAll (bool spectate=true) |
static void | ThrowOutDisconnected () |
static ePlayerNetID * | FindPlayerByName (tString const &name, ePlayerNetID *requester=0) |
finds a player by name using lax name matching. Reports errors to the console or to the requesting player. | |
static void | FilterName (tString const &in, tString &out) |
filters a name (removes unprintables, color codes and spaces) | |
static tString | FilterName (tString const &in) |
filters a name (removes unprintables, color codes and spaces) | |
Public Attributes | |
int | pID |
tString | teamname |
tArray< tString > | lastSaid |
tArray< nTimeRolling > | lastSaidTimes |
unsigned short | r |
unsigned short | g |
unsigned short | b |
unsigned short | pingCharity |
REAL | ping |
double | lastSync |
time of the last sync request | |
double | lastActivity_ |
time of the last activity | |
bool | loginWanted |
flag indicating whether this player currently wants to log on | |
nSpamProtection | chatSpam_ |
Protected Member Functions | |
virtual nMachine & | DoGetMachine () const |
returns the machine this object belongs to | |
Private Member Functions | |
tCONTROLLED_PTR (eTeam) nextTeam | |
tCONTROLLED_PTR (eTeam) currentTeam | |
tCONTROLLED_PTR (eVoter) voter_ | |
tCHECKED_PTR (eNetGameObject) object | |
ePlayerNetID & | operator= (const ePlayerNetID &) |
void | RegisterWithMachine () |
registers with a machine | |
void | UnregisterWithMachine () |
un registers with a machine | |
void | MyInitAfterCreation () |
ePlayerNetID & | SetNameFromClient (tColoredString const &nameFromClient) |
Sets this player's name as the client wants it to be. Avoid using it when possilbe. | |
ePlayerNetID & | SetColoredName (tColoredString const &coloredName) |
Sets this player's name, cleared by the server. Use this for onscreen screen display. | |
int & | AccessSuspended () |
accesses the suspension count | |
int | GetSuspended () const |
returns the suspension count | |
Static Private Member Functions | |
static void | SwapPlayersNo (int a, int b) |
Private Attributes | |
int | listID |
int | teamListID |
bool | silenced_ |
int | suspended_ |
nTimeAbsolute | timeJoinedTeam |
number of rounds the player is currently suspended from playing | |
eTeamSet | invitations_ |
int | score |
int | lastScore_ |
int | favoriteNumberOfPlayersPerTeam |
bool | nameTeamAfterMe |
bool | greeted |
bool | disconnected |
bool | spectating_ |
are we currently spectating? Spectators don't get assigned to teams. | |
bool | stealth_ |
does this player want to hide his/her identity? | |
bool | chatting_ |
are we currently chatting? | |
int | chatFlags_ |
different types of reasons for beeing chatting | |
bool | allowTeamChange_ |
allow team changes even if ALLOW_TEAM_CHANGE is disabled? | |
tAccessLevel | lastAccessLevel |
access level at the time of the last name update | |
nMachine * | registeredMachine_ |
the machine the player is registered with | |
tColoredString | nameFromClient_ |
this player's name as the client wants it to be. Avoid using it when possilbe. | |
tColoredString | nameFromServer_ |
this player's name as the server wants it to be. Avoid using it when possilbe. | |
tColoredString | coloredName_ |
this player's name, cleared by the server. Use this for onscreen screen display. | |
tString | name_ |
this player's name without colors. | |
tString | userName_ |
this player's name, cleared for system logs. Use for writing to files or comparing with admin input. | |
REAL | wait_ |
time in seconds WaitToLeaveChat() will wait for this player | |
Friends | |
class | ePlayer |
class | eTeam |
class | eNetGameObject |
class | tControlledPTR< ePlayerNetID > |
Definition at line 142 of file ePlayer.h.
typedef std::set< eTeam * > ePlayerNetID::eTeamSet |
Definition at line 192 of file ePlayer.h.
00193 { 00194 ChatFlags_Chat = 1, 00195 ChatFlags_Away = 2, 00196 ChatFlags_Menu = 4, 00197 ChatFlags_Console = 4 00198 };
ePlayerNetID::ePlayerNetID | ( | int | p = -1 |
) |
Definition at line 3700 of file ePlayer.cpp.
03702 :nNetObject(),listID(-1), teamListID(-1), allowTeamChange_(false), registeredMachine_(0), pID(p),chatSpam_( se_chatSpamSettings ) 03703 { 03704 // default access level 03705 lastAccessLevel = tAccessLevel_Default; 03706 03707 favoriteNumberOfPlayersPerTeam = 1; 03708 03709 nameTeamAfterMe = false; 03710 03711 r = g = b = 15; 03712 03713 greeted = true; 03714 chatting_ = false; 03715 spectating_ = false; 03716 stealth_ = false; 03717 chatFlags_ = 0; 03718 disconnected = false; 03719 suspended_ = 0; 03720 03721 loginWanted = false; 03722 03723 03724 if (p>=0){ 03725 ePlayer *P = ePlayer::PlayerConfig(p); 03726 if (P){ 03727 SetName( P->Name() ); 03728 teamname = P->Teamname(); 03729 r= P->rgb[0]; 03730 g= P->rgb[1]; 03731 b= P->rgb[2]; 03732 03733 sg_ClampPingCharity(); 03734 pingCharity=::pingCharity; 03735 03736 loginWanted = P->autoLogin; 03737 } 03738 } 03739 /* 03740 else 03741 { 03742 SetName( "AI" ); 03743 teamname = ""; 03744 } 03745 */ 03746 lastSaid.SetLen(12); 03747 lastSaidTimes.SetLen(12); 03748 03749 se_PlayerNetIDs.Add(this,listID); 03750 object=NULL; 03751 03752 /* 03753 if(sn_GetNetState()!=nSERVER) 03754 ping=sn_Connections[0].ping; 03755 else 03756 */ 03757 ping=0; // hehe! server has no ping. 03758 03759 lastSync=tSysTimeFloat(); 03760 03761 RequestSync(); 03762 score=0; 03763 lastScore_=IMPOSSIBLY_LOW_SCORE; 03764 // rubberstatus=0; 03765 03766 MyInitAfterCreation(); 03767 03768 if(sn_GetNetState()==nSERVER)
ePlayerNetID::ePlayerNetID | ( | nMessage & | m | ) |
Definition at line 3773 of file ePlayer.cpp.
References tList< T, MALLOC, REFERENCE >::Add(), b, chatFlags_, chatting_, disconnected, g, greeted, IMPOSSIBLY_LOW_SCORE, lastAccessLevel, lastSaid, lastSaidTimes, lastScore_, lastSync, listID, loginWanted, nameTeamAfterMe, NULL, pID, nConnectionInfo::ping, ping, r, score, nMessage::SenderID(), tArray< T, MALLOC >::SetLen(), sn_Connections, spectating_, stealth_, suspended_, tAccessLevel_Default, teamname, and tSysTimeFloat().
03775 :nNetObject(m),listID(-1), teamListID(-1) 03776 , allowTeamChange_(false), registeredMachine_(0), chatSpam_( se_chatSpamSettings ) 03777 { 03778 // default access level 03779 lastAccessLevel = tAccessLevel_Default; 03780 03781 greeted =false; 03782 chatting_ =false; 03783 spectating_ =false; 03784 stealth_ =false; 03785 disconnected=false; 03786 suspended_ = 0; 03787 chatFlags_ =0; 03788 03789 r = g = b = 15; 03790 03791 nameTeamAfterMe = false; 03792 teamname = ""; 03793 03794 lastSaid.SetLen(12); 03795 lastSaidTimes.SetLen(12); 03796 03797 pID=-1; 03798 se_PlayerNetIDs.Add(this,listID); 03799 object=NULL; 03800 ping=sn_Connections[m.SenderID()].ping; 03801 lastSync=tSysTimeFloat(); 03802 03803 loginWanted = false; 03804 03805 score=0; 03806 lastScore_=IMPOSSIBLY_LOW_SCORE;
ePlayerNetID::~ePlayerNetID | ( | ) | [virtual] |
Definition at line 3904 of file ePlayer.cpp.
03907 { 03908 // se_PlayerNetIDs.Remove(this,listID); 03909 if ( sn_GetNetState() == nSERVER && disconnected ) 03910 { 03911 tOutput mess; 03912 tColoredString name; 03913 name << *this << tColoredString::ColorString(1,.5,.5); 03914 mess.SetTemplateParameter(1, name); 03915 mess.SetTemplateParameter(2, score); 03916 mess << "$player_left_game"; 03917 sn_ConsoleOut(mess); 03918 } 03919 03920 UnregisterWithMachine(); 03921 03922 RemoveFromGame(); 03923 03924 ClearObject(); 03925 //con << "Player info sent.\n"; 03926 03927 for(int i=MAX_PLAYERS-1;i>=0;i--){ 03928 ePlayer *p = ePlayer::PlayerConfig(i); 03929 03930 if (p && static_cast<ePlayerNetID *>(p->netPlayer)==this) 03931 p->netPlayer=NULL; 03932 } 03933 03934 if ( currentTeam ) 03935 { 03936 currentTeam->RemovePlayer( this ); 03937 } 03938 03939 #ifdef DEBUG 03940 con << *this << " destroyed.\n";
ePlayerNetID::tCONTROLLED_PTR | ( | eTeam | ) | [private] |
ePlayerNetID::tCONTROLLED_PTR | ( | eTeam | ) | [private] |
ePlayerNetID::tCONTROLLED_PTR | ( | eVoter | ) | [private] |
ePlayerNetID::tCHECKED_PTR | ( | eNetGameObject | ) | [private] |
void ePlayerNetID::SwapPlayersNo | ( | int | a, | |
int | b | |||
) | [static, private] |
Definition at line 5012 of file ePlayer.cpp.
References GrowingArrayBase::Len(), listID, and se_PlayerNetIDs.
Referenced by SortByScore().
05014 { 05015 if (0>a || se_PlayerNetIDs.Len()<=a) 05016 return; 05017 if (0>b || se_PlayerNetIDs.Len()<=b) 05018 return; 05019 if (a==b) 05020 return; 05021 05022 ePlayerNetID *A=se_PlayerNetIDs(a); 05023 ePlayerNetID *B=se_PlayerNetIDs(b); 05024 05025 se_PlayerNetIDs(b)=A; 05026 se_PlayerNetIDs(a)=B; 05027 A->listID=b;
ePlayerNetID& ePlayerNetID::operator= | ( | const ePlayerNetID & | ) | [private] |
void ePlayerNetID::RegisterWithMachine | ( | void | ) | [private] |
registers with a machine
Definition at line 7283 of file ePlayer.cpp.
References nMachine::AddPlayer(), nNetObject::DoGetMachine(), and registeredMachine_.
Referenced by MyInitAfterCreation().
07286 { 07287 if ( !registeredMachine_ ) 07288 { 07289 // store machine (it won't get deleted while this object exists; the player count prevents that) 07290 registeredMachine_ = &this->nNetObject::DoGetMachine(); 07291 registeredMachine_->AddPlayer();
void ePlayerNetID::UnregisterWithMachine | ( | void | ) | [private] |
un registers with a machine
Definition at line 7302 of file ePlayer.cpp.
References GetVoter(), registeredMachine_, nMachine::RemovePlayer(), and suspended_.
07305 { 07306 if ( registeredMachine_ ) 07307 { 07308 // store suspension count 07309 if ( GetVoter() ) 07310 { 07311 GetVoter()->suspended_ = suspended_; 07312 } 07313 07314 registeredMachine_->RemovePlayer(); 07315 registeredMachine_ = 0;
bool ePlayerNetID::ActionOnQuit | ( | ) | [virtual] |
Reimplemented from nNetObject.
Definition at line 4008 of file ePlayer.cpp.
04011 { 04012 tControlledPTR< ePlayerNetID > holder( this ); 04013 04014 // clear legacy spectator 04015 se_ClearLegacySpectator( Owner() ); 04016 04017 this->RemoveFromGame();
void ePlayerNetID::ActionOnDelete | ( | ) | [virtual] |
Reimplemented from nNetObject.
Definition at line 4019 of file ePlayer.cpp.
04022 { 04023 tControlledPTR< ePlayerNetID > holder( this ); 04024 04025 if ( sn_GetNetState() == nSERVER ) 04026 { 04027 // get the number of players registered from this client 04028 // int playerCount = nMachine::GetMachine(Owner()).GetPlayerCount(); 04029 int playerCount = 0; 04030 for ( int i = se_PlayerNetIDs.Len()-1; i >= 0; --i ) 04031 { 04032 if ( se_PlayerNetIDs[i]->Owner() == Owner() ) 04033 playerCount++; 04034 } 04035 04036 // if this is the last player, store it 04037 if ( playerCount == 1 ) 04038 { 04039 // log scores 04040 LogScoreDifference(); 04041 04042 // clear legacy spectator 04043 se_ClearLegacySpectator( Owner() ); 04044 04045 // store new legacy spectator 04046 se_legacySpectators[ Owner() ] = this; 04047 spectating_ = true; 04048 04049 // quit team already 04050 SetTeamWish( NULL ); 04051 SetTeam( NULL ); 04052 UpdateTeam(); 04053 04054 // and kill controlled object 04055 ControlObject( NULL ); 04056 04057 // inform other clients that the player left 04058 TakeOwnership(); 04059 RequestSync(); 04060 04061 return; 04062 } 04063 } 04064 04065 // standard behavior: just get us out of here
bool ePlayerNetID::IsChatting | ( | ) | const [inline] |
Definition at line 227 of file ePlayer.h.
References chatting_.
Referenced by gDestination::CopyFrom(), RemoveChatbots(), and sg_FullscreenMessage().
00227 { return chatting_; }
void ePlayerNetID::SetChatting | ( | ChatFlags | flag, | |
bool | chatting | |||
) |
Definition at line 5983 of file ePlayer.cpp.
References chatFlags_, ChatFlags_Menu, chatting_, nSTANDALONE, nNetObject::RequestSync(), and sn_GetNetState().
Referenced by se_ChatState().
05986 { 05987 if ( sn_GetNetState() == nSTANDALONE && flag == ChatFlags_Menu ) 05988 { 05989 chatting = false; 05990 } 05991 05992 if ( chatting ) 05993 { 05994 chatFlags_ |= flag; 05995 if ( !chatting_ ) 05996 this->RequestSync(); 05997 05998 chatting_ = true; 05999 } 06000 else 06001 { 06002 chatFlags_ &= ~flag; 06003 if ( 0 == chatFlags_ ) 06004 { 06005 if ( chatting_ ) 06006 this->RequestSync(); 06007 06008 chatting_ = false; 06009 }
bool ePlayerNetID::IsSpectating | ( | ) | const [inline] |
Definition at line 231 of file ePlayer.h.
References spectating_.
Referenced by CreateNewTeam(), eVoter::GetVoter(), RemoveChatbots(), gAIPlayer::SetNumberOfAIs(), and SetTeam().
00231 { return spectating_; }
bool ePlayerNetID::StealthMode | ( | ) | const [inline] |
bool ePlayerNetID::TeamChangeAllowed | ( | bool | informPlayer = false |
) | const |
is this player allowed to change teams?
Definition at line 6015 of file ePlayer.cpp.
References allowTeamChange_, CurrentTeam(), eAccessLevelHolder::GetAccessLevel(), tCurrentAccessLevel::GetName(), GetSuspended(), nNetObject::Owner(), se_allowTeamChanges, and sn_ConsoleOut().
Referenced by CreateNewTeam(), ReceiveControlNet(), se_ChatTeamLeave(), SetDefaultTeam(), and Update().
06017 { 06018 if (!( allowTeamChange_ || se_allowTeamChanges )) 06019 { 06020 if ( informPlayer ) 06021 { 06022 sn_ConsoleOut(tOutput("$player_teamchanges_disallowed"), Owner()); 06023 } 06024 return false; 06025 } 06026 06027 int suspended = GetSuspended(); 06028 if ( suspended > 0 ) 06029 { 06030 if ( informPlayer ) 06031 { 06032 sn_ConsoleOut(tOutput("$player_teamchanges_suspended", suspended ), Owner()); 06033 } 06034 return false; 06035 } 06036 06037 #ifdef KRAWALL_SERVER 06038 // only allow players with enough access level to enter the game, everyone is free to leave, though 06039 if (!( GetAccessLevel() <= AccessLevelRequiredToPlay() || CurrentTeam() )) 06040 { 06041 if ( informPlayer ) 06042 { 06043 sn_ConsoleOut(tOutput("$player_teamchanges_accesslevel", 06044 tCurrentAccessLevel::GetName( GetAccessLevel() ), 06045 tCurrentAccessLevel::GetName( AccessLevelRequiredToPlay() ) ), 06046 Owner()); 06047 } 06048 return false; 06049 } 06050 #endif 06051
void ePlayerNetID::SetTeamChangeAllowed | ( | bool | allowed | ) | [inline] |
set if this player should always be allowed to change teams
Definition at line 237 of file ePlayer.h.
References allowTeamChange_.
eTeam* ePlayerNetID::NextTeam | ( | ) | const [inline] |
Definition at line 239 of file ePlayer.h.
Referenced by gMenuItemPlayer::Enter(), LogScoreDifferences(), eTeam::PlayerMayJoin(), ReceiveControlNet(), gMenuItemStatus::Render(), se_ChatTeamLeave(), gAIPlayer::SetNumberOfAIs(), SetTeamWish(), sg_NumHumans(), eTeam::SwapPlayers(), and Update().
eTeam* ePlayerNetID::CurrentTeam | ( | ) | const [inline] |
Definition at line 240 of file ePlayer.h.
Referenced by gEnemyInfluence::AddWall(), cCockpit::cb_CurrentScoreTeam(), eTeam::Enemies(), gMenuItemPlayer::Enter(), init_game_objects(), zValidatorAllButTeamOwner::isValid(), zValidatorOwnerTeam::isValid(), gCycle::KillAt(), LogScoreDifferences(), gBaseZoneHack::OnEnter(), gWinZoneHack::OnEnter(), gCycle::PassEdge(), eTeam::PlayerMayJoin(), PrepareTeamText(), RemoveChatbots(), gMenuItemStatus::Render(), se_ChatMsg(), se_ChatShuffle(), se_ChatTeamLeave(), se_GetManagedTeam(), zSelectorAnotherNotTeammateDead::select(), zSelectorAnotherTeammateDead::select(), zSelectorTeam::select(), zSelectorTeammate::select(), SetTeamWish(), sg_NumHumans(), eTeam::SwapPlayers(), TeamChangeAllowed(), gBaseZoneHack::Timestep(), eTeam::UnInvite(), Update(), and WaitToLeaveChat().
int ePlayerNetID::TeamListID | ( | ) | const [inline] |
Definition at line 241 of file ePlayer.h.
References teamListID.
Referenced by se_ChatShuffle().
00241 { return teamListID; } // return my position in the team
eTeam * ePlayerNetID::FindDefaultTeam | ( | ) |
Definition at line 6076 of file ePlayer.cpp.
References favoriteNumberOfPlayersPerTeam, eTeam::IsHuman(), eTeam::minTeams, eTeam::NewTeamAllowed(), NULL, eTeam::NumHumanPlayers(), eTeam::PlayerMayJoin(), and eTeam::teams.
Referenced by SetDefaultTeam(), Suspend(), and Update().
06079 { 06080 // find the team with the least number of players on it 06081 eTeam *min = NULL; 06082 for ( int i=eTeam::teams.Len()-1; i>=0; --i ) 06083 { 06084 eTeam *t = eTeam::teams( i ); 06085 if ( t->IsHuman() && ( !min || min->NumHumanPlayers() > t->NumHumanPlayers() ) ) 06086 min = t; 06087 } 06088 06089 if ( min && 06090 // create new teams until minTeams is matched 06091 eTeam::teams.Len() >= eTeam::minTeams && 06092 min->PlayerMayJoin( this ) && 06093 // no new team allowed or not more than favoriteNumberOfPlayers on team 06094 ( !eTeam::NewTeamAllowed() || ( min->NumHumanPlayers() > 0 && min->NumHumanPlayers() < favoriteNumberOfPlayersPerTeam ) ) 06095 ) 06096 { 06097 // return the team 06098 return min; 06099 } 06100 // return NULL to indicate no team was found => "create a new team" (?)
void ePlayerNetID::SetDefaultTeam | ( | ) |
Definition at line 6054 of file ePlayer.cpp.
References CreateNewTeamWish(), FindDefaultTeam(), nCLIENT, eTeam::NewTeamAllowed(), se_assignTeamAutomatically, SetTeamWish(), sn_GetNetState(), spectating_, and TeamChangeAllowed().
Referenced by gMenuItemAutoSelect::Enter(), ReceiveControlNet(), RemoveChatbots(), and Update().
06057 { 06058 // only the server should do this, the client does not have the full information on how to do do it right. 06059 if ( sn_GetNetState() == nCLIENT || !se_assignTeamAutomatically || spectating_ || !TeamChangeAllowed() ) 06060 return; 06061 06062 // if ( !IsHuman() ) 06063 // { 06064 // SetTeam( NULL ); 06065 // return; 06066 // } 06067 06068 eTeam* defaultTeam = FindDefaultTeam(); 06069 if (defaultTeam) 06070 SetTeamWish(defaultTeam); 06071 else if ( eTeam::NewTeamAllowed() ) 06072 CreateNewTeamWish(); 06073 // yes, if all teams are full and no team creation is allowed, the player stays without team and will not be spawned.
void ePlayerNetID::SetTeamForce | ( | eTeam * | team | ) |
Definition at line 6137 of file ePlayer.cpp.
References GetName(), and eTeam::Name().
Referenced by eTeam::Enforce(), SetTeam(), SetTeamWish(), and Update().
06140 { 06141 // check if the team change is legal 06142 //tASSERT ( !newTeam || nCLIENT != sn_GetNetState() ); 06143 #ifdef DEBUG 06144 std::cout << "DEBUG: Player:" << this->GetName() << " SetTeamForce:" << ((newTeam)?(const char*)newTeam->Name():"NULL") << "\n"; 06145 #endif
void ePlayerNetID::SetTeam | ( | eTeam * | team | ) |
Definition at line 6103 of file ePlayer.cpp.
References GetName(), IsSpectating(), eTeam::Name(), nCLIENT, nNetObject::Owner(), eTeam::PlayerMayJoin(), SetTeamForce(), tOutput::SetTemplateParameter(), sn_ConsoleOut(), sn_GetNetState(), and tASSERT.
Referenced by gAITeam::BalanceWithAIs(), ReceiveControlNet(), RemoveChatbots(), gAIPlayer::SetNumberOfAIs(), SetTeamWish(), Suspend(), eTeam::UnInvite(), and Update().
06106 { 06107 // check if the team change is legal 06108 tASSERT ( !newTeam || nCLIENT != sn_GetNetState() ); 06109 06110 SetTeamForce( newTeam ); 06111 06112 if (newTeam && ( !newTeam->PlayerMayJoin( this ) || IsSpectating() ) ) 06113 { 06114 tOutput message; 06115 message.SetTemplateParameter( 1, GetName() ); 06116 if ( newTeam ) 06117 message.SetTemplateParameter(2, newTeam->Name() ); 06118 else 06119 message.SetTemplateParameter(2, "NULL"); 06120 message << "$player_nojoin_team"; 06121 06122 sn_ConsoleOut( message, Owner() ); 06123 // return;
void ePlayerNetID::SetTeamWish | ( | eTeam * | team | ) |
Definition at line 6253 of file ePlayer.cpp.
References nMessage::BroadCast(), CurrentTeam(), GetName(), eTeam::Name(), nCLIENT, nNetObject::NewControlMessage(), NextTeam(), nSERVER, NULL, eTeam::NumPlayers(), nNetObject::Owner(), se_assignTeamAutomatically, SetTeam(), SetTeamForce(), sn_ConsoleOut(), sn_GetNetState(), sn_myNetID, TEAMCHANGE, and UpdateTeam().
Referenced by gMenuItemSpectate::Enter(), se_ChatTeamLeave(), SetDefaultTeam(), and Update().
06256 { 06257 if (NextTeam()==newTeam) 06258 return; 06259 06260 if ( nSERVER == sn_GetNetState() && newTeam==NULL && CurrentTeam()!=NULL && NextTeam()!=NULL) 06261 { 06262 if ( se_assignTeamAutomatically ) 06263 { 06264 sn_ConsoleOut("$no_spectators_allowed", Owner() ); 06265 return; 06266 } 06267 06268 eTeam * leftTeam = NextTeam(); 06269 if ( leftTeam ) 06270 { 06271 if ( !leftTeam ) 06272 leftTeam = CurrentTeam(); 06273 06274 if ( leftTeam->NumPlayers() > 1 ) 06275 { 06276 sn_ConsoleOut( tOutput( "$player_leave_team_wish", 06277 tColoredString::RemoveColors(GetName()), 06278 tColoredString::RemoveColors(leftTeam->Name()) ) ); 06279 } 06280 else 06281 { 06282 sn_ConsoleOut( tOutput( "$player_leave_game_wish", 06283 tColoredString::RemoveColors(GetName()) ) ); 06284 } 06285 } 06286 } 06287 if ( nCLIENT == sn_GetNetState() && Owner() == sn_myNetID ) 06288 { 06289 nMessage* m = NewControlMessage(); 06290 06291 (*m) << TEAMCHANGE; 06292 (*m) << newTeam; 06293 06294 m->BroadCast(); 06295 // update local client data, should be ok (dangerous?, why?) 06296 SetTeamForce( newTeam ); 06297 } 06298 else 06299 { 06300 SetTeam( newTeam ); 06301 06302 // directly join if possible to keep counts up to date 06303 if (!currentTeam) 06304 UpdateTeam();
void ePlayerNetID::SetTeamname | ( | const char * | newTeamname | ) |
Definition at line 6126 of file ePlayer.cpp.
References nNetObject::ID(), and teamname.
Referenced by Update().
06129 { 06130 teamname = newTeamname; 06131 if (bool(currentTeam) && currentTeam->OldestHumanPlayer() && 06132 currentTeam->OldestHumanPlayer()->ID()==ID()) 06133 { 06134 currentTeam->UpdateAppearance();
void ePlayerNetID::UpdateTeamForce | ( | ) |
Definition at line 6179 of file ePlayer.cpp.
Referenced by eTeam::Enforce(), and UpdateTeam().
06182 { 06183 // check if work is needed 06184 if ( nextTeam == currentTeam ) 06185 { 06186 return; 06187 } 06188 06189 eTeam *oldTeam = currentTeam; 06190 06191 if ( nextTeam ) 06192 nextTeam->AddPlayer ( this ); 06193 else if ( oldTeam ) 06194 oldTeam->RemovePlayer( this ); 06195 06196 if( nCLIENT != sn_GetNetState() && GetRefcount() > 0 ) 06197 { 06198 RequestSync();
void ePlayerNetID::UpdateTeam | ( | ) |
Definition at line 6148 of file ePlayer.cpp.
References GetName(), nCLIENT, nNetObject::Owner(), tOutput::SetTemplateParameter(), sn_ConsoleOut(), sn_GetNetState(), and UpdateTeamForce().
Referenced by gAITeam::BalanceWithAIs(), CreateNewTeam(), LogScoreDifferences(), RemoveChatbots(), gAIPlayer::SetNumberOfAIs(), SetTeamWish(), and Update().
06151 { 06152 // check if work is needed 06153 if ( nextTeam == currentTeam ) 06154 { 06155 return; 06156 } 06157 06158 // check if the team change is legal 06159 if ( nCLIENT == sn_GetNetState() ) 06160 { 06161 return; 06162 } 06163 06164 if ( bool( nextTeam ) && !nextTeam->PlayerMayJoin( this ) ) 06165 { 06166 tOutput message; 06167 message.SetTemplateParameter(1, GetName() ); 06168 if ( nextTeam ) 06169 message.SetTemplateParameter(2, nextTeam->Name() ); 06170 else 06171 message.SetTemplateParameter(2, "NULL"); 06172 message << "$player_nojoin_team"; 06173 06174 sn_ConsoleOut( message, Owner() ); 06175 return; 06176 } 06177
ePlayerNetID::eTeamSet const & ePlayerNetID::GetInvitations | ( | ) | const |
teams this player is invited to
Definition at line 6201 of file ePlayer.cpp.
References invitations_.
void ePlayerNetID::CreateNewTeam | ( | ) |
Definition at line 6207 of file ePlayer.cpp.
References GetName(), IsSpectating(), nCLIENT, eTeam::NewTeamAllowed(), nNetObject::Owner(), score, tOutput::SetTemplateParameter(), sn_ConsoleOut(), sn_GetNetState(), tASSERT, TeamChangeAllowed(), tNEW, and UpdateTeam().
Referenced by CreateNewTeamWish(), and ReceiveControlNet().
06210 { 06211 // check if the team change is legal 06212 tASSERT ( nCLIENT != sn_GetNetState() ); 06213 06214 if(!TeamChangeAllowed( true )) { 06215 return; 06216 } 06217 06218 if ( !eTeam::NewTeamAllowed() || 06219 ( bool( currentTeam ) && ( currentTeam->NumHumanPlayers() == 1 ) ) || 06220 IsSpectating() ) 06221 { 06222 tOutput message; 06223 message.SetTemplateParameter(1, GetName() ); 06224 message << "$player_nocreate_team"; 06225 06226 sn_ConsoleOut( message, Owner() ); 06227 06228 // yarrt: Should CreateNewTeam only try to create a team ? 06229 // yarrt: yes, let's try 06230 // if it can't create a team => just idle? 06231 //Old code 06232 //if ( !currentTeam ) 06233 // SetDefaultTeam(); 06234 06235 return; 06236 } 06237 06238 // create the new team and join it 06239 tJUST_CONTROLLED_PTR< eTeam > newTeam = tNEW( eTeam ); 06240 nextTeam = newTeam; 06241 nextTeam->AddScore( score ); 06242 06243 // directly if possible 06244 if ( !currentTeam ) 06245 { 06246 UpdateTeam();
void ePlayerNetID::CreateNewTeamWish | ( | ) |
Definition at line 6307 of file ePlayer.cpp.
References nMessage::BroadCast(), CreateNewTeam(), nCLIENT, NEW_TEAM, nNetObject::NewControlMessage(), and sn_GetNetState().
Referenced by gMenuItemNewTeam::Enter(), and SetDefaultTeam().
06310 { 06311 if ( nCLIENT == sn_GetNetState() ) 06312 { 06313 nMessage* m = NewControlMessage(); 06314 06315 (*m) << NEW_TEAM; 06316 06317 m->BroadCast(); 06318 } 06319 else 06320 // create a new team if possible otherwise spectate
void ePlayerNetID::ReceiveControlNet | ( | nMessage & | m | ) | [virtual] |
Reimplemented from nNetObject.
Definition at line 6323 of file ePlayer.cpp.
References chatSpam_, nSpamProtection::CheckSpam(), CreateNewTeam(), GetName(), NEW_TEAM, NextTeam(), NULL, nNetObject::Owner(), se_assignTeamAutomatically, SetDefaultTeam(), SetTeam(), tOutput::SetTemplateParameter(), sn_ConsoleOut(), tASSERT, TEAMCHANGE, and TeamChangeAllowed().
06326 { 06327 short messageType; 06328 m >> messageType; 06329 06330 switch (messageType) 06331 { 06332 case NEW_TEAM: 06333 { 06334 // create a new team if possible otherwise spectate or... 06335 CreateNewTeam(); 06336 // if auto_team is enabled join the default team 06337 if (se_assignTeamAutomatically && NextTeam()==NULL) 06338 SetDefaultTeam(); 06339 06340 break; 06341 } 06342 case TEAMCHANGE: 06343 { 06344 eTeam *newTeam; 06345 06346 m >> newTeam; 06347 06348 if(!TeamChangeAllowed( true )) { 06349 break; 06350 } 06351 06352 // annihilate team if it no longer is in the game 06353 if ( bool(newTeam) && newTeam->TeamID() < 0 ) 06354 newTeam = 0; 06355 06356 // NULL team probably means that the change target does not 06357 // exist any more. Create a new team instead. 06358 if ( !newTeam ) 06359 { 06360 if ( currentTeam ) 06361 sn_ConsoleOut( tOutput( "$player_joins_team_noex" ), Owner() ); 06362 break; 06363 } 06364 06365 // check if the resulting message is obnoxious 06366 bool redundant = ( nextTeam == newTeam ); 06367 bool obnoxious = ( nextTeam != currentTeam || redundant ); 06368 06369 SetTeam( newTeam ); 06370 06371 // announce the change 06372 if ( bool(nextTeam) && !redundant ) 06373 { 06374 tOutput message; 06375 message.SetTemplateParameter(1, tColoredString::RemoveColors(GetName())); 06376 message.SetTemplateParameter(2, tColoredString::RemoveColors(nextTeam->Name()) ); 06377 message << "$player_joins_team"; 06378 06379 sn_ConsoleOut( message ); 06380 06381 // count it as spam if it is obnoxious 06382 if ( obnoxious ) 06383 chatSpam_.CheckSpam( 4.0, Owner(), tOutput("$spam_teamchage") ); 06384 } 06385 06386 break; 06387 } 06388 default: 06389 { 06390 tASSERT(0); 06391 }
bool ePlayerNetID::Enemies | ( | ePlayerNetID const * | a, | |
ePlayerNetID const * | b | |||
) | [static] |
determines whether two players are opponents and can score points against each other
a | first player to compare | |
b | second player to compare |
Definition at line 7252 of file ePlayer.cpp.
References nNetObject::GetMachine(), nCLIENT, nNetObject::Owner(), se_allowEnemiesSameClient, se_allowEnemiesSameIP, and sn_GetNetState().
Referenced by gEnemyInfluence::AddWall(), and eTeam::Enemies().
07255 { 07256 // the client does not need a true answer 07257 if ( sn_GetNetState() == nCLIENT ) 07258 return true; 07259 07260 // no scoring if one of them does not exist 07261 if ( !a || !b ) 07262 return false; 07263 07264 // no scoring for two players from the same IP 07265 if ( !se_allowEnemiesSameIP && a->Owner() != 0 && a->GetMachine() == b->GetMachine() ) 07266 return false; 07267 07268 // no scoring for two players from the same client 07269 if ( !se_allowEnemiesSameClient && a->Owner() != 0 && a->Owner() == b->Owner() ) 07270 return false; 07271 07272 // no objections
void ePlayerNetID::PrintName | ( | tString & | s | ) | const [virtual] |
bool ePlayerNetID::AcceptClientSync | ( | ) | const [virtual] |
void ePlayerNetID::WriteSync | ( | nMessage & | m | ) | [virtual] |
Reimplemented from nNetObject.
Definition at line 4474 of file ePlayer.cpp.
04476 { 04477 lastSync=tSysTimeFloat(); 04478 nNetObject::WriteSync(m); 04479 m.Write(r); 04480 m.Write(g); 04481 m.Write(b); 04482 04483 // write ping charity; spectators get a fake (high) value 04484 if ( currentTeam || nextTeam ) 04485 m.Write(pingCharity); 04486 else 04487 m.Write(1000); 04488 04489 if ( sn_GetNetState() == nCLIENT ) 04490 { 04491 m << nameFromClient_; 04492 } 04493 else 04494 { 04495 m << nameFromServer_; 04496 } 04497 04498 //if(sn_GetNetState()==nSERVER) 04499 m << ping; 04500 04501 // pack chat, spectator and stealth status together 04502 unsigned short flags = ( chatting_ ? 1 : 0 ) | ( spectating_ ? 2 : 0 ) | ( stealth_ ? 4 : 0 ); 04503 m << flags; 04504 04505 m << score; 04506 m << static_cast<unsigned short>(disconnected); 04507 04508 m << nextTeam; 04509 m << currentTeam; 04510 04511 m << favoriteNumberOfPlayersPerTeam; 04512 m << nameTeamAfterMe; 04513 //TODO: Only update between rounds
void ePlayerNetID::ReadSync | ( | nMessage & | m | ) | [virtual] |
Reimplemented from nNetObject.
Definition at line 4703 of file ePlayer.cpp.
04705 { 04706 // check whether this is the first sync 04707 bool firstSync = ( this->ID() == 0 ); 04708 04709 nNetObject::ReadSync(m); 04710 04711 m.Read(r); 04712 m.Read(g); 04713 m.Read(b); 04714 04715 if ( !se_bugColorOverflow ) 04716 { 04717 // clamp color values 04718 Clamp(r); 04719 Clamp(g); 04720 Clamp(b); 04721 } 04722 04723 m.Read(pingCharity); 04724 sg_ClampPingCharity(pingCharity); 04725 04726 // name as sent from the other end 04727 tString & remoteName = ( sn_GetNetState() == nCLIENT ) ? nameFromServer_ : nameFromClient_; 04728 04729 // name handling 04730 { 04731 // read and shorten name, but don't update it yet 04732 m >> remoteName; 04733 04734 // filter 04735 se_OptionalNameFilters( remoteName ); 04736 04737 se_CutString( remoteName, 16 ); 04738 } 04739 04740 // directly apply name changes sent from the server, they are safe. 04741 if ( sn_GetNetState() != nSERVER ) 04742 { 04743 UpdateName(); 04744 } 04745 04746 REAL p; 04747 m >> p; 04748 if (sn_GetNetState()!=nSERVER) 04749 ping=p; 04750 04751 // if (!m.End()) 04752 { 04753 // read chat and spectator status 04754 unsigned short flags; 04755 m >> flags; 04756 04757 if (Owner() != ::sn_myNetID) 04758 { 04759 bool newChat = ( ( flags & 1 ) != 0 ); 04760 bool newSpectate = ( ( flags & 2 ) != 0 ); 04761 bool newStealth = ( ( flags & 4 ) != 0 ); 04762 04763 if ( chatting_ != newChat || spectating_ != newSpectate || newStealth != stealth_ ) 04764 lastActivity_ = tSysTimeFloat(); 04765 chatting_ = newChat; 04766 spectating_ = newSpectate; 04767 stealth_ = newStealth; 04768 } 04769 } 04770 04771 // if (!m.End()) 04772 { 04773 if(sn_GetNetState()!=nSERVER) 04774 m >> score; 04775 else{ 04776 int s; 04777 m >> s; 04778 } 04779 } 04780 04781 if (!m.End()){ 04782 unsigned short newdisc; 04783 m >> newdisc; 04784 04785 if (Owner() != ::sn_myNetID && sn_GetNetState()!=nSERVER) 04786 disconnected = newdisc; 04787 } 04788 04789 if (!m.End()) 04790 { 04791 if ( nSERVER != sn_GetNetState() ) 04792 { 04793 eTeam *newCurrentTeam, *newNextTeam; 04794 04795 m >> newNextTeam; 04796 m >> newCurrentTeam; 04797 04798 // update team 04799 if ( newCurrentTeam != currentTeam ) 04800 { 04801 if ( newCurrentTeam ) 04802 // automatically removed player from currentTeam 04803 newCurrentTeam->AddPlayerDirty( this ); 04804 else 04805 currentTeam->RemovePlayer( this ); 04806 } 04807 // update nextTeam 04808 nextTeam = newNextTeam; 04809 } 04810 else 04811 { 04812 eTeam* t; 04813 m >> t; 04814 m >> t; 04815 } 04816 04817 m >> favoriteNumberOfPlayersPerTeam; 04818 m >> nameTeamAfterMe; 04819 } 04820 if (!m.End()) 04821 { 04822 m >> teamname; 04823 } 04824 // con << "Player info updated.\n"; 04825 04826 // make sure we did not accidentally overwrite values 04827 // ePlayer::Update(); 04828 04829 // update the team 04830 if ( nSERVER == sn_GetNetState() ) 04831 { 04832 if ( nextTeam ) 04833 nextTeam->UpdateProperties(); 04834 04835 if ( currentTeam ) 04836 currentTeam->UpdateProperties(); 04837 } 04838 04839 // first sync message 04840 if ( firstSync && sn_GetNetState() == nSERVER ) 04841 { 04842 UpdateName(); 04843 04844 #ifndef KRAWALL_SERVER 04845 GetScoreFromDisconnectedCopy(); 04846 #endif 04847 SetDefaultTeam(); 04848 04849 RequestSync(); 04850 }
nDescriptor & ePlayerNetID::CreatorDescriptor | ( | void | ) | const [virtual] |
void ePlayerNetID::InitAfterCreation | ( | void | ) | [virtual] |
bool ePlayerNetID::ClearToTransmit | ( | int | user | ) | const [virtual] |
virtual void ePlayerNetID::NewObject | ( | ) | [inline, virtual] |
Reimplemented in gAIPlayer.
Definition at line 269 of file ePlayer.h.
Referenced by ControlObject().
virtual void ePlayerNetID::RightBeforeDeath | ( | int | triesLeft | ) | [inline, virtual] |
void ePlayerNetID::RemoveFromGame | ( | void | ) |
Definition at line 3956 of file ePlayer.cpp.
Referenced by gAITeam::BalanceWithAIs(), se_ClearLegacySpectator(), gAIPlayer::SetNumberOfAIs(), and Update().
03959 { 03960 // unregister with the machine 03961 this->UnregisterWithMachine(); 03962 03963 // release voter 03964 if ( this->voter_ ) 03965 this->voter_->RemoveFromGame(); 03966 this->voter_ = 0; 03967 03968 // log scores 03969 LogScoreDifference(); 03970 03971 if ( sn_GetNetState() != nCLIENT ) 03972 { 03973 nameFromClient_ = nameFromServer_; 03974 03975 nMessage *m=new nMessage(player_removed_from_game); 03976 m->Write(this->ID()); 03977 m->BroadCast(); 03978 03979 if ( listID >= 0 ){ 03980 if ( ( IsSpectating() || !se_assignTeamAutomatically ) && CurrentTeam() == NULL ) 03981 { 03982 // get colored player name 03983 tColoredString playerName; 03984 playerName << *this << tColoredString::ColorString(1,.5,.5); 03985 03986 // announce a generic leave 03987 sn_ConsoleOut( tOutput( "$player_left_spectator", playerName ) ); 03988 } 03989 03990 if ( IsHuman() && sn_GetNetState() == nSERVER && NULL != sn_Connections[Owner()].socket ) 03991 { 03992 tString ladder; 03993 ladder << "PLAYER_LEFT " << userName_ << " " << nMachine::GetMachine(Owner()).GetIP() << "\n"; 03994 se_SaveToLadderLog(ladder); 03995 tString notificationMessage(userName_); 03996 notificationMessage << " left the grid"; 03997 se_sendEventNotification(tString("Player left"), notificationMessage); 03998 } 03999 } 04000 } 04001 04002 se_PlayerNetIDs.Remove(this, listID); 04003 SetTeamWish( NULL ); 04004 SetTeam( NULL ); 04005 UpdateTeam(); 04006 ControlObject( NULL );
void ePlayerNetID::ControlObject | ( | eNetGameObject * | c | ) | [virtual] |
Reimplemented in gAIPlayer.
Definition at line 4861 of file ePlayer.cpp.
References ClearObject(), NewObject(), and eGameObject::team.
Referenced by gAIPlayer::ControlObject(), init_game_objects(), and sg_RespawnPlayer().
04863 { 04864 if (bool(object) && c!=object) 04865 ClearObject(); 04866 04867 if (!c) 04868 { 04869 return; 04870 } 04871 04872 04873 object=c; 04874 c->team = currentTeam; 04875 04876 if (bool(object)) 04877 object->SetPlayer(this); 04878 #ifdef DEBUG 04879 //con << "Player " << name << " controlles new object.\n"; 04880 #endif 04881
void ePlayerNetID::ClearObject | ( | ) | [virtual] |
Reimplemented in gAIPlayer.
Definition at line 4883 of file ePlayer.cpp.
Referenced by gAIPlayer::ClearObject(), and ControlObject().
04885 { 04886 if (object) 04887 { 04888 tJUST_CONTROLLED_PTR< eNetGameObject > x=object; 04889 object=NULL; 04890 x->RemoveFromGame(); 04891 x->SetPlayer( NULL ); 04892 } 04893 #ifdef DEBUG 04894 //con << "Player " << name << " controlles nothing.\n";
void ePlayerNetID::Greet | ( | ) |
Definition at line 4896 of file ePlayer.cpp.
Referenced by init_game_objects().
04898 { 04899 if (!greeted){ 04900 tOutput o; 04901 o.SetTemplateParameter(1, GetName() ); 04902 o.SetTemplateParameter(2, sn_programVersion); 04903 o << "$player_welcome"; 04904 tString s; 04905 s << o; 04906 s << "\n"; 04907 GreetHighscores(s); 04908 s << "\n"; 04909 //std::cout << s; 04910 sn_ConsoleOut(s,Owner()); 04911 greeted=true;
void ePlayerNetID::Suspend | ( | int | rounds = 5 |
) |
rounds | number of rounds to suspend |
Definition at line 7380 of file ePlayer.cpp.
References AccessSuspended(), FindDefaultTeam(), GetColoredName(), NULL, SetTeam(), and sn_ConsoleOut().
Referenced by eVoteItemSuspend::DoExecute(), and LogScoreDifferences().
07383 { 07384 if ( rounds < 0 ) 07385 { 07386 rounds = 0; 07387 } 07388 07389 int & suspended = AccessSuspended(); 07390 07391 if ( suspended == rounds ) 07392 { 07393 return; 07394 } 07395 07396 suspended = rounds; 07397 07398 if ( suspended == 0 ) 07399 { 07400 sn_ConsoleOut( tOutput( "$player_no_longer_suspended", GetColoredName() ) ); 07401 FindDefaultTeam(); 07402 } 07403 else 07404 { 07405 sn_ConsoleOut( tOutput( "$player_suspended", GetColoredName(), suspended ) ); 07406 SetTeam( NULL );
void ePlayerNetID::RequestScheduledLogins | ( | ) | [static] |
initiates login processes for all pending wishes
Definition at line 1390 of file ePlayer.cpp.
References GrowingArrayBase::Len(), se_PlayerNetIDs, and se_RequestLogin().
01391 { 01392 for( int i = se_PlayerNetIDs.Len()-1; i>=0; --i ) 01393 { 01394 se_RequestLogin( se_PlayerNetIDs(i) ); 01395 } 01396 }
bool ePlayerNetID::IsActive | ( | ) | const [inline] |
Definition at line 291 of file ePlayer.h.
References disconnected.
Referenced by gGame::Analysis(), init_game_objects(), and sg_NumHumans().
00291 { return !disconnected; }
bool ePlayerNetID::IsSilenced | ( | void | ) | const [inline] |
Definition at line 293 of file ePlayer.h.
References silenced_.
Referenced by IsSilencedWithWarning(), se_DisplayChatLocally(), and se_DisplayChatLocallyClient().
00293 { return silenced_; }
void ePlayerNetID::SetSilenced | ( | bool | silenced | ) | [inline] |
bool& ePlayerNetID::AccessSilenced | ( | void | ) | [inline] |
eVoter* ePlayerNetID::GetVoter | ( | ) | const [inline] |
Definition at line 297 of file ePlayer.h.
Referenced by eVoteItemKickServerControlled::DoCheckValid(), eVoter::HandleChat(), MyInitAfterCreation(), and UnregisterWithMachine().
void ePlayerNetID::CreateVoter | ( | ) |
Definition at line 4463 of file ePlayer.cpp.
References eVoter::GetVoter(), nVersion::Max(), nCLIENT, nNetObject::Owner(), eVoter::PlayerChanged(), sn_Connections, sn_GetNetState(), and nConnectionInfo::version.
Referenced by MyInitAfterCreation().
04466 { 04467 // only count nonlocal players with voting support as voters 04468 if ( sn_GetNetState() != nCLIENT && this->Owner() != 0 && sn_Connections[ this->Owner() ].version.Max() >= 3 ) 04469 { 04470 this->voter_ = eVoter::GetVoter( this->Owner() ); 04471 if ( this->voter_ ) 04472 this->voter_->PlayerChanged();
void ePlayerNetID::SilenceMenu | ( | ) | [static] |
Definition at line 892 of file ePlayer.cpp.
References uMenu::Enter(), IsHuman(), GrowingArrayBase::Len(), and tNEW.
Referenced by PoliceMenu().
00893 { 00894 uMenu menu( "$player_police_silence_text" ); 00895 00896 int size = se_PlayerNetIDs.Len(); 00897 eMenuItemSilence** items = tNEW( eMenuItemSilence* )[ size ]; 00898 00899 int i; 00900 for ( i = size-1; i>=0; --i ) 00901 { 00902 ePlayerNetID* player = se_PlayerNetIDs[ i ]; 00903 if ( player->IsHuman() ) 00904 { 00905 items[i] = tNEW( eMenuItemSilence )( &menu, player ); 00906 } 00907 else 00908 { 00909 items[i] = 0; 00910 } 00911 00912 } 00913 00914 menu.Enter(); 00915 00916 for ( i = size - 1; i>=0; --i ) 00917 { 00918 if( items[i] ) delete items[i]; 00919 } 00920 delete[] items; 00921 }
void ePlayerNetID::PoliceMenu | ( | ) | [static] |
Definition at line 923 of file ePlayer.cpp.
References uMenu::Enter(), eVoter::KickMenu(), and SilenceMenu().
Referenced by MainMenu().
00924 { 00925 uMenu menu( "$player_police_text" ); 00926 00927 uMenuItemFunction kick( &menu, "$player_police_kick_text", "$player_police_kick_help", eVoter::KickMenu ); 00928 uMenuItemFunction silence( &menu, "$player_police_silence_text", "$player_police_silence_help", ePlayerNetID::SilenceMenu ); 00929 00930 menu.Enter(); 00931 }
virtual bool ePlayerNetID::IsHuman | ( | ) | const [inline, virtual] |
Reimplemented in gAIPlayer.
Definition at line 302 of file ePlayer.h.
Referenced by gGame::Analysis(), gServerInfoAdmin::GetUsers(), eVoter::KickMenu(), gCycle::KillAt(), LogScoreDifference(), eTeam::OldestAIPlayer(), eTeam::OldestHumanPlayer(), gAITeam::PlayerMayJoin(), eTeam::PlayerMayJoin(), RemoveChatbots(), ResetScoreDifferences(), sg_NumHumans(), SilenceMenu(), Update(), eTeam::UpdateAppearance(), eTeam::YoungestAIPlayer(), and eTeam::YoungestHumanPlayer().
void ePlayerNetID::Activity | ( | ) |
Definition at line 3808 of file ePlayer.cpp.
Referenced by new_destination_handler().
03811 { 03812 // the player was active; therefore, he cannot possibly be chatting_ or disconnected. 03813 03814 // but do nothing if we are in client mode and the player is not local to this computer 03815 if (sn_GetNetState() != nSERVER && Owner() != ::sn_myNetID) 03816 return; 03817 03818 if (chatting_ || disconnected) 03819 { 03820 #ifdef DEBUG 03821 con << *this << " showed activity and lost chat status.\n"; 03822 #endif 03823 RequestSync(); 03824 } 03825 03826 chatting_ = disconnected = false; 03827 03828 // store time
REAL ePlayerNetID::LastActivity | ( | void | ) | const |
returns how long the last activity of this player was ago
Definition at line 7346 of file ePlayer.cpp.
References lastActivity_, and tSysTimeFloat().
Referenced by RemoveChatbots().
eNetGameObject * ePlayerNetID::Object | ( | ) | const |
Definition at line 4913 of file ePlayer.cpp.
Referenced by gEnemyInfluence::AddWall(), eTeam::Alive(), eTeam::AlivePlayers(), gGame::Analysis(), gGame::GameLoop(), zSelector::getAllValid(), gCycle::KillAt(), gAIPlayer::Object(), gBaseZoneHack::OnVanish(), ResetScoreDifferences(), se_DisplayChatLocallyClient(), se_GetAlivePlayerFromUserID(), se_GetWatchedObject(), se_SetWatchedObject(), cCockpit::SetCycle(), cCockpit::SetPlayer(), sg_RespawnPlayer(), and stc_updateFastest().
Definition at line 4956 of file ePlayer.cpp.
References tOutput::Append(), tColoredString::ColorString(), tOutput::IsEmpty(), nNetObject::RequestSync(), score, se_SaveToScoreFile(), tOutput::SetTemplateParameter(), and sn_ConsoleOut().
Referenced by gCycle::KillAt(), gDeathZoneHack::OnEnter(), gCycle::OnRoundEnd(), and sg_HoleScore().
04956 {rubberstatus = rubber2;} 04957 04958 void ePlayerNetID::AddScore(int points, 04959 const tOutput& reasonwin, 04960 const tOutput& reasonlose) 04961 { 04962 if (points==0) 04963 return; 04964 04965 score += points; 04966 if (currentTeam) 04967 currentTeam->AddScore( points ); 04968 04969 tColoredString name; 04970 name << *this << tColoredString::ColorString(1,1,1); 04971 04972 tOutput message; 04973 message.SetTemplateParameter(1, name); 04974 message.SetTemplateParameter(2, points > 0 ? points : -points); 04975 04976 04977 if (points>0) 04978 { 04979 if (reasonwin.IsEmpty()) 04980 message << "$player_win_default"; 04981 else 04982 message.Append(reasonwin); 04983 } 04984 else 04985 { 04986 if (reasonlose.IsEmpty()) 04987 message << "$player_lose_default"; 04988 else 04989 message.Append(reasonlose); 04990 } 04991 04992 sn_ConsoleOut(message); 04993 RequestSync(true); 04994
int ePlayerNetID::Score | ( | ) | const [inline] |
int ePlayerNetID::TotalScore | ( | ) | const |
Definition at line 4999 of file ePlayer.cpp.
References score.
Referenced by cCockpit::cb_CurrentScore().
05002 { 05003 if ( currentTeam ) 05004 { 05005 return score;// + currentTeam->Score() * 5; 05006 } 05007 else 05008 { 05009 return score;
void ePlayerNetID::ResetScoreDifferences | ( | void | ) | [static] |
Definition at line 7360 of file ePlayer.cpp.
References IsHuman(), lastScore_, GrowingArrayBase::Len(), Object(), score, and se_PlayerNetIDs.
Referenced by init_game_objects().
07363 { 07364 for ( int i = se_PlayerNetIDs.Len()-1; i>=0; --i ) 07365 { 07366 ePlayerNetID* p = se_PlayerNetIDs(i); 07367 if ( bool(p->Object()) && p->IsHuman() ) 07368 p->lastScore_ = p->score;
void ePlayerNetID::LogScoreDifferences | ( | void | ) | [static] |
Definition at line 7417 of file ePlayer.cpp.
References CurrentTeam(), GetSuspended(), GrowingArrayBase::Len(), LogScoreDifference(), NextTeam(), se_PlayerNetIDs, Suspend(), and UpdateTeam().
Referenced by own_game(), and gGame::StateUpdate().
07420 { 07421 for ( int i = se_PlayerNetIDs.Len()-1; i>=0; --i ) 07422 { 07423 ePlayerNetID* p = se_PlayerNetIDs(i); 07424 p->LogScoreDifference(); 07425 07426 int suspended = p->GetSuspended(); 07427 07428 // update suspension count 07429 if ( suspended > 0 ) 07430 { 07431 if ( p->CurrentTeam() && !p->NextTeam() ) 07432 { 07433 p->UpdateTeam(); 07434 } 07435 else 07436 { 07437 p->Suspend( suspended - 1 ); 07438 } 07439 }
void ePlayerNetID::LogScoreDifference | ( | void | ) |
Definition at line 7450 of file ePlayer.cpp.
References FilterName(), GetUserName(), IMPOSSIBLY_LOW_SCORE, IsHuman(), lastScore_, score, and se_SaveToLadderLog().
Referenced by LogScoreDifferences().
07453 { 07454 if ( lastScore_ > IMPOSSIBLY_LOW_SCORE && IsHuman() ) 07455 { 07456 tString ret; 07457 int scoreDifference = score - lastScore_; 07458 lastScore_ = IMPOSSIBLY_LOW_SCORE; 07459 ret << "ROUND_SCORE " << scoreDifference << " " << GetUserName(); 07460 if ( currentTeam ) 07461 ret << " " << FilterName( currentTeam->Name() ) << " " << currentTeam->Score(); 07462 ret << "\n"; 07463 se_SaveToLadderLog( ret );
void ePlayerNetID::SortByScore | ( | ) | [static] |
Definition at line 5030 of file ePlayer.cpp.
References GrowingArrayBase::Len(), se_PlayerNetIDs, and SwapPlayersNo().
Referenced by gGame::Analysis(), and Ranking().
05032 { 05033 // bubble sort (AAARRGGH! but good for lists that change not much) 05034 05035 bool inorder=false; 05036 while (!inorder){ 05037 inorder=true; 05038 int i; 05039 for(i=se_PlayerNetIDs.Len()-2;i>=0;i--) 05040 if (se_PlayerNetIDs(i)->TotalScore() < se_PlayerNetIDs(i+1)->TotalScore() ){ 05041 SwapPlayersNo(i,i+1); 05042 inorder=false; 05043 }
tString ePlayerNetID::Ranking | ( | int | MAX = 12 , |
|
bool | cut = true | |||
) | [static] |
Definition at line 5105 of file ePlayer.cpp.
References GrowingArrayBase::Len(), max(), se_PlayerNetIDs, tColoredString::SetPos(), tString::SetPos(), and SortByScore().
Referenced by gGame::Analysis().
05107 { 05108 SortByScore(); 05109 05110 tString ret; 05111 05112 if (se_PlayerNetIDs.Len()>0){ 05113 ret << tOutput("$player_scoretable_name"); 05114 ret.SetPos(17, cut ); 05115 ret << tOutput("$player_scoretable_alive"); 05116 ret.SetPos(24, cut ); 05117 ret << tOutput("$player_scoretable_score"); 05118 ret.SetPos(31, cut ); 05119 ret << tOutput("$player_scoretable_ping"); 05120 ret.SetPos(37, cut ); 05121 ret << tOutput("$player_scoretable_team"); 05122 ret.SetPos(53, cut ); 05123 ret << "\n"; 05124 05125 int max = se_PlayerNetIDs.Len(); 05126 05127 // wasting the last line with ... is as stupid if it stands for only 05128 // one player 05129 if ( MAX == max + 1 ) 05130 MAX = max; 05131 05132 if ( max > MAX && MAX > 0 ) 05133 { 05134 max = MAX ; 05135 } 05136 05137 for(int i=0;i<max;i++){ 05138 tColoredString line; 05139 ePlayerNetID *p=se_PlayerNetIDs(i); 05140 // tColoredString name( p->GetColoredName() ); 05141 // name.SetPos(16, cut ); 05142 05143 // This line is example of how we manually get the player color... could come in useful. 05144 // line << tColoredString::ColorString( p->r/15.0, p->g/15.0, p->b/15.0 ) << name << tColoredString::ColorString(1,1,1); 05145 05146 // however, using the streaming operator is a lot cleaner. The example is left, as it really can be usefull in some situations. 05147 line << *p; 05148 line.SetPos(17, false ); 05149 if ( p->Object() && p->Object()->Alive() ) 05150 { 05151 line << tOutput("$player_scoretable_alive_yes"); 05152 } 05153 else 05154 { 05155 line << tOutput("$player_scoretable_alive_no"); 05156 } 05157 line.SetPos(24, cut ); 05158 line << p->score; 05159 05160 if (p->IsActive()) 05161 { 05162 line.SetPos(31, cut ); 05163 //line << "ping goes here"; 05164 line << int(p->ping*1000); 05165 line.SetPos(37, cut ); 05166 if ( p->currentTeam ) 05167 { 05168 //tString teamtemp = p->currentTeam->Name(); 05169 //teamtemp.RemoveHex(); 05170 line << tColoredString::RemoveColors(p->currentTeam->Name()); 05171 line.SetPos(53, cut ); 05172 } 05173 } 05174 else 05175 line << tOutput("$player_scoretable_inactive"); 05176 ret << line << "\n"; 05177 } 05178 if ( max < se_PlayerNetIDs.Len() ) 05179 { 05180 ret << "...\n"; 05181 } 05182 05183 } 05184 else 05185 ret << tOutput("$player_scoretable_nobody");
float ePlayerNetID::RankingGraph | ( | float | y, | |
int | MAX | |||
) | [static] |
Definition at line 5186 of file ePlayer.cpp.
05188 { 05189 SortByScore(); 05190 05191 if (se_PlayerNetIDs.Len()>0){ 05192 tColoredString name; 05193 name << tColoredString::ColorString(1.,.5,.5) 05194 << tOutput("$player_scoretable_name"); 05195 DisplayText(-.7, y, .06, name.c_str(), sr_fontScoretable, -1); 05196 tColoredString alive; 05197 alive << tOutput("$player_scoretable_alive"); 05198 DisplayText(-.3, y, .06, alive.c_str(), sr_fontScoretable, -1); 05199 tColoredString score; 05200 score << tOutput("$player_scoretable_score"); 05201 DisplayText(.05, y, .06, score.c_str(), sr_fontScoretable, 1); 05202 tColoredString ping; 05203 ping << tOutput("$player_scoretable_ping"); 05204 DisplayText(.25, y, .06, ping.c_str(), sr_fontScoretable, 1); 05205 tColoredString team; 05206 team << tOutput("$player_scoretable_team"); 05207 DisplayText(.3, y, .06, team.c_str(), sr_fontScoretable, -1); 05208 y-=.06; 05209 05210 int max = se_PlayerNetIDs.Len(); 05211 05212 // wasting the last line with ... is as stupid if it stands for only 05213 // one player 05214 if ( MAX == max + 1 ) 05215 MAX = max; 05216 05217 if ( max > MAX && MAX > 0 ) 05218 { 05219 max = MAX ; 05220 } 05221 05222 for(int i=0;i<max;i++){ 05223 ePlayerNetID *p=se_PlayerNetIDs(i); 05224 if(p->chatting_) 05225 DisplayText(-.705, y, .06, "*", sr_fontScoretable, 1); 05226 tColoredString name; 05227 name << *p; 05228 DisplayText(-.7, y, .06, name.c_str(), sr_fontScoretable, -1); 05229 tColoredString alive; 05230 if ( p->Object() && p->Object()->Alive() ) 05231 { 05232 alive << tColoredString::ColorString(0,1,0) 05233 << tOutput("$player_scoretable_alive_yes"); 05234 } 05235 else 05236 { 05237 alive << tColoredString::ColorString(1,0,0) 05238 << tOutput("$player_scoretable_alive_no"); 05239 } 05240 DisplayText(-.3, y, .06, alive.c_str(), sr_fontScoretable, -1); 05241 tColoredString score; 05242 score << p->score; 05243 DisplayText(.05, y, .06, score.c_str(), sr_fontScoretable, 1); 05244 if (p->IsActive()) 05245 { 05246 tColoredString ping; 05247 ping << int(p->ping*1000); 05248 DisplayText(.25, y, .06, ping.c_str(), sr_fontScoretable, 1); 05249 if ( p->currentTeam ) 05250 { 05251 tColoredString team; 05252 eTeam *t = p->currentTeam; 05253 team << tColoredStringProxy(t->R()/15.f, t->G()/15.f, t->B()/15.f) << t->Name(); 05254 DisplayText(.3, y, .06, team.c_str(), sr_fontScoretable, -1); 05255 } 05256 } 05257 else { 05258 tColoredString noone; 05259 noone << tOutput("$player_scoretable_inactive"); 05260 DisplayText(.1, y, .06, noone.c_str(), sr_fontScoretable, -1); 05261 } 05262 y-=.06; 05263 } 05264 if ( max < se_PlayerNetIDs.Len() ) 05265 { 05266 DisplayText(-.7, y, .06, "...", sr_fontScoretable, -1); 05267 y-=.06; 05268 } 05269 05270 } 05271 else { 05272 tColoredString noone; 05273 noone << tOutput("$player_scoretable_nobody"); 05274 DisplayText(-.7, y, .06, noone.c_str(), sr_fontScoretable, -1); 05275 }
void ePlayerNetID::RankingLadderLog | ( | ) | [static] |
Definition at line 5277 of file ePlayer.cpp.
Referenced by gGame::StateUpdate().
05279 { 05280 SortByScore(); 05281 05282 int num_humans = 0; 05283 int max = se_PlayerNetIDs.Len(); 05284 for(int i = 0; i < max; ++i) { 05285 ePlayerNetID *p = se_PlayerNetIDs(i); 05286 if(p->Owner() == 0) continue; // ignore AIs 05287 05288 tString line("ONLINE_PLAYER "); 05289 05290 line << p->GetLogName(); 05291 05292 if(p->IsActive()) { 05293 line << " " << p->ping; 05294 if(p->currentTeam) { 05295 line << " " << FilterName(p->currentTeam->Name()); 05296 ++num_humans; 05297 } 05298 } 05299 05300 line << '\n'; 05301 se_SaveToLadderLog(line); 05302 } 05303 tString line("NUM_HUMANS "); 05304 line << num_humans << '\n';
void ePlayerNetID::ResetScore | ( | ) | [static] |
Definition at line 5045 of file ePlayer.cpp.
05047 { 05048 int i; 05049 for(i=se_PlayerNetIDs.Len()-1;i>=0;i--){ 05050 se_PlayerNetIDs(i)->score=0; 05051 if (sn_GetNetState()==nSERVER) 05052 se_PlayerNetIDs(i)->RequestSync(); 05053 } 05054 05055 for(i=eTeam::teams.Len()-1;i>=0;i--){ 05056 eTeam::teams(i)->ResetScore(); 05057 if (sn_GetNetState()==nSERVER) 05058 eTeam::teams(i)->RequestSync(); 05059 } 05060
void ePlayerNetID::DisplayScores | ( | ) | [static] |
Definition at line 5062 of file ePlayer.cpp.
Referenced by scores().
05064 { 05065 sr_ResetRenderState(true); 05066 05067 REAL W=sr_screenWidth; 05068 REAL H=sr_screenHeight; 05069 05070 REAL MW=400; 05071 REAL MH=(MW*3)/4; 05072 05073 if(W>MW) 05074 W=MW; 05075 05076 if(H>MH) 05077 H=MH; 05078 05079 #ifndef DEDICATED 05080 if (sr_glOut){ 05081 ::Color(1,1,1); 05082 float y=.6; 05083 05084 // print team ranking if there actually is a team with more than one player 05085 int maxPlayers = 20; 05086 bool showTeam = false; 05087 for ( int i = eTeam::teams.Len() - 1; i >= 0; --i ) 05088 { 05089 if ( eTeam::teams[i]->NumPlayers() > 1 || 05090 ( eTeam::teams[i]->NumPlayers() == 1 && eTeam::teams[i]->Player(0)->Score() != eTeam::teams[i]->Score() ) ) 05091 { 05092 y = eTeam::RankingGraph(y); 05093 y-=.06; 05094 maxPlayers -= ( eTeam::teams.Len() > 6 ? 6 : eTeam::teams.Len() ) + 2; 05095 showTeam = true; 05096 break; 05097 } 05098 } 05099 05100 // print player ranking 05101 RankingGraph( y , maxPlayers ); 05102 }
void ePlayerNetID::GreetHighscores | ( | tString & | s | ) |
Definition at line 5972 of file ePlayer.cpp.
05974 { 05975 s << eCallbackGreeting::Greet(this); 05976 // tOutput o; 05977 // gHighscoresBase::Greet(this,o);
void ePlayerNetID::Update | ( | ) | [static] |
Definition at line 5418 of file ePlayer.cpp.
References b, nNetObject::ClearAllDeleted(), con, CurrentTeam(), ePlayer::favoriteNumberOfPlayersPerTeam, favoriteNumberOfPlayersPerTeam, FindDefaultTeam(), g, eAccessLevelHolder::GetAccessLevel(), GetName(), IsHuman(), GrowingArrayBase::Len(), MAX_PLAYERS, eTeam::maxPlayers, eTeam::Name(), nameFromClient_, ePlayer::nameTeamAfterMe, nameTeamAfterMe, nCLIENT, NextTeam(), nSERVER, NULL, nNetObject::Owner(), ping, pingCharity, ePlayer::PlayerConfig(), ePlayer::PlayerIsInGame(), eTeam::PlayerMayJoin(), players, r, RemoveFromGame(), nNetObject::RequestSync(), ePlayer::rgb, se_assignTeamAutomatically, se_pingCharityMax, se_pingCharityMin, se_pingCharityServerConf, se_pingCharityServerControlled, se_PlayerNetIDs, se_RandomizeColor(), se_randomizeColor, se_VisibleSpectatorsSupported(), SetDefaultTeam(), SetName(), SetTeam(), SetTeamForce(), SetTeamname(), SetTeamWish(), tOutput::SetTemplateParameter(), sg_ClampPingCharity(), sn_ConsoleOut(), sn_GetNetState(), sn_myNetID, sn_pingCharityServer, ePlayer::spectate, spectating_, sr_glOut, ePlayer::stealth, stealth_, nVersionFeature::Supported(), tASSERT, tCONTROLLED_PTR(), TeamChangeAllowed(), ePlayer::Teamname(), eTeam::teams, tNEW, UpdateName(), and UpdateTeam().
Referenced by gMenuItemPlayer::Enter(), gGame::GameLoop(), ingame_menu_cleanup(), sg_PlayerMenu(), and gGame::StateUpdate().
05420 { 05421 #ifdef KRAWALL_SERVER 05422 // update access level 05423 UpdateAccessLevelRequiredToPlay(); 05424 05425 // remove players with insufficient access rights 05426 tAccessLevel required = AccessLevelRequiredToPlay(); 05427 for( int i=se_PlayerNetIDs.Len()-1; i >= 0; --i ) 05428 { 05429 ePlayerNetID* player = se_PlayerNetIDs(i); 05430 if ( player->GetAccessLevel() > required && player->IsHuman() ) 05431 { 05432 player->SetTeamWish(0); 05433 } 05434 } 05435 #endif 05436 05437 #ifdef DEDICATED 05438 if (sr_glOut) 05439 #endif 05440 { 05441 for(int i=0; i<MAX_PLAYERS; ++i ){ 05442 bool in_game=ePlayer::PlayerIsInGame(i); 05443 ePlayer *local_p=ePlayer::PlayerConfig(i); 05444 tASSERT(local_p); 05445 tCONTROLLED_PTR(ePlayerNetID) &p=local_p->netPlayer; 05446 05447 if (!p && in_game && ( !local_p->spectate || se_VisibleSpectatorsSupported() ) ) // insert new player 05448 { 05449 p=tNEW(ePlayerNetID) (i); 05450 p->SetDefaultTeam(); 05451 p->RequestSync(); 05452 } 05453 05454 if (bool(p) && (!in_game || ( local_p->spectate && !se_VisibleSpectatorsSupported() ) ) && // remove player 05455 p->Owner() == ::sn_myNetID ) 05456 { 05457 p->RemoveFromGame(); 05458 05459 if (p->object) 05460 p->object->player = NULL; 05461 05462 p->object = NULL; 05463 p = NULL; 05464 } 05465 05466 if (bool(p) && in_game){ // update 05467 p->favoriteNumberOfPlayersPerTeam=ePlayer::PlayerConfig(i)->favoriteNumberOfPlayersPerTeam; 05468 p->nameTeamAfterMe=ePlayer::PlayerConfig(i)->nameTeamAfterMe; 05469 05470 if ( se_randomizeColor ) 05471 { 05472 se_RandomizeColor(local_p,p); 05473 } 05474 05475 p->r=ePlayer::PlayerConfig(i)->rgb[0]; 05476 p->g=ePlayer::PlayerConfig(i)->rgb[1]; 05477 p->b=ePlayer::PlayerConfig(i)->rgb[2]; 05478 05479 sg_ClampPingCharity(); 05480 p->pingCharity=::pingCharity; 05481 p->SetTeamname(local_p->Teamname()); 05482 05483 // update spectator status 05484 if ( p->spectating_ != local_p->spectate ) 05485 p->RequestSync(); 05486 p->spectating_ = local_p->spectate; 05487 05488 // update stealth status 05489 if ( p->stealth_ != local_p->stealth ) 05490 p->RequestSync(); 05491 p->stealth_ = local_p->stealth; 05492 05493 // update name 05494 tString newName( ePlayer::PlayerConfig(i)->Name() ); 05495 05496 if ( ::sn_GetNetState() != nCLIENT || newName != p->nameFromClient_ ) 05497 { 05498 p->RequestSync(); 05499 } 05500 05501 p->SetName( ePlayer::PlayerConfig(i)->Name() ); 05502 } 05503 } 05504 05505 } 05506 05507 int i; 05508 05509 05510 // update the ping charity, but 05511 // don't do so on the client if the server controls the ping charity completely 05512 if ( sn_GetNetState() == nSERVER || !se_pingCharityServerControlled.Supported(0) ) 05513 { 05514 int old_c=sn_pingCharityServer; 05515 sg_ClampPingCharity(); 05516 sn_pingCharityServer=::pingCharity; 05517 05518 #ifndef DEDICATED 05519 if (sn_GetNetState()==nCLIENT) 05520 #endif 05521 sn_pingCharityServer+=100000; 05522 05523 // set configurable maximum 05524 if ( se_pingCharityServerControlled.Supported() ) 05525 { 05526 sn_pingCharityServer = se_pingCharityMax; 05527 } 05528 05529 for(i=se_PlayerNetIDs.Len()-1;i>=0;i--){ 05530 ePlayerNetID *pni=se_PlayerNetIDs(i); 05531 pni->UpdateName(); 05532 int new_ps=pni->pingCharity; 05533 new_ps+=int(pni->ping*500); 05534 05535 // only take ping charity into account for non-spectators 05536 if ( sn_GetNetState() != nSERVER || pni->currentTeam || pni->nextTeam ) 05537 if (new_ps < sn_pingCharityServer) 05538 sn_pingCharityServer=new_ps; 05539 } 05540 if (sn_pingCharityServer<0) 05541 sn_pingCharityServer=0; 05542 05543 // set configurable minimum 05544 if ( se_pingCharityServerControlled.Supported() ) 05545 { 05546 if ( sn_pingCharityServer < se_pingCharityMin ) 05547 sn_pingCharityServer = se_pingCharityMin; 05548 } 05549 05550 if (old_c!=sn_pingCharityServer) 05551 { 05552 tOutput o; 05553 o.SetTemplateParameter(1, old_c); 05554 o.SetTemplateParameter(2, sn_pingCharityServer); 05555 o << "$player_pingcharity_changed"; 05556 con << o; 05557 05558 // trigger transmission to the clients 05559 if (sn_GetNetState()==nSERVER) 05560 se_pingCharityServerConf.nConfItemBase::WasChanged(true); 05561 } 05562 } 05563 05564 // update team assignment 05565 bool assigned = true; 05566 while ( assigned && sn_GetNetState() != nCLIENT ) 05567 { 05568 assigned = false; 05569 05570 int players = se_PlayerNetIDs.Len(); 05571 05572 // start with the players that came in earlier 05573 for( i=0; i<players; ++i ) 05574 { 05575 ePlayerNetID* player = se_PlayerNetIDs(i); 05576 05577 // only assign new team if it is possible 05578 if ( player->NextTeam() != player->CurrentTeam() && player->TeamChangeAllowed() && 05579 ( !player->NextTeam() || player->NextTeam()->PlayerMayJoin( player ) ) 05580 ) 05581 { 05582 player->UpdateTeam(); 05583 if ( player->NextTeam() == player->CurrentTeam() ) 05584 assigned = true; 05585 } 05586 } 05587 05588 // assign players that are not currently on a team, but want to, to any team. Start with the late comers here. 05589 if ( !assigned ) 05590 { 05591 for( i=players-1; i>=0; --i ) 05592 { 05593 ePlayerNetID* player = se_PlayerNetIDs(i); 05594 05595 // if the player is not currently on a team, but wants to join a specific team, let it join any, but keep the wish stored 05596 if ( player->NextTeam() && !player->CurrentTeam() && player->TeamChangeAllowed() ) 05597 { 05598 eTeam * wish = player->NextTeam(); 05599 bool assignBack = se_assignTeamAutomatically; 05600 se_assignTeamAutomatically = true; 05601 player->FindDefaultTeam(); 05602 se_assignTeamAutomatically = assignBack; 05603 player->SetTeamForce( wish ); 05604 05605 if ( player->CurrentTeam() ) 05606 { 05607 assigned = true; 05608 break; 05609 } 05610 } 05611 } 05612 } 05613 } 05614 05615 if ( sn_GetNetState() != nCLIENT ) 05616 { 05617 for(i=se_PlayerNetIDs.Len()-1;i>=0;i--) 05618 { 05619 ePlayerNetID* player = se_PlayerNetIDs(i); 05620 05621 // announce unfullfilled wishes 05622 if ( player->NextTeam() != player->CurrentTeam() && player->NextTeam() ) 05623 { 05624 //if the player can't change teams delete the team wish 05625 if(!player->TeamChangeAllowed()) { 05626 player->SetTeam( player->CurrentTeam() ); 05627 continue; 05628 } 05629 05630 tOutput message( "$player_joins_team_wish", 05631 player->GetName(), 05632 player->NextTeam()->Name() ); 05633 05634 sn_ConsoleOut( message ); 05635 05636 // if team change is futile because team play is disabled, 05637 // delete the team change wish 05638 if ( eTeam::maxPlayers <= 1 ) 05639 player->SetTeam( player->CurrentTeam() ); 05640 } 05641 } 05642 } 05643 05644 // update the teams as well 05645 for (i=eTeam::teams.Len()-1; i>=0; --i) 05646 { 05647 eTeam::teams(i)->UpdateProperties(); 05648 } 05649 05650 // get rid of deleted netobjects
bool ePlayerNetID::WaitToLeaveChat | ( | ) | [static] |
waits for players to leave chat state. Returns true if the caller should wait to proceed with whatever he wants to do.
Definition at line 5669 of file ePlayer.cpp.
References chatting_, CurrentTeam(), dt, GetName(), lastTime, GrowingArrayBase::Len(), NULL, eTeam::OldestHumanPlayer(), REAL, se_PlayerNetIDs, se_playerWaitFraction, se_playerWaitMax, se_playerWaitSingle, se_playerWaitTeamleader, sn_ConsoleOut(), tSysTimeFloat(), and wait_.
Referenced by gGame::GameLoop(), and gGame::StateUpdate().
05672 { 05673 static bool lastReturn = false; 05674 static double lastTime = 0; 05675 static ePlayerNetID * lastPlayer = 0; // the last player that caused a pause. Use only for comparison, the pointer may be bad. Don't dereference! 05676 double time = tSysTimeFloat(); 05677 REAL dt = time - lastTime; 05678 bool ret = false; 05679 05680 if ( !lastReturn ) 05681 { 05682 // account for non-break pause: give players additional pause time 05683 for ( int i = se_PlayerNetIDs.Len()-1; i>=0; --i ) 05684 { 05685 ePlayerNetID* player = se_PlayerNetIDs(i); 05686 if ( dt > 1.0 || !player->chatting_ ) 05687 { 05688 player->wait_ += se_playerWaitFraction * dt; 05689 if ( player->wait_ > se_playerWaitMax ) 05690 { 05691 player->wait_ = se_playerWaitMax; 05692 } 05693 } 05694 } 05695 05696 if ( dt > 1.0 ) 05697 lastPlayer = 0; 05698 05699 dt = 0; 05700 } 05701 05702 // the chatting player with the most wait seconds left 05703 ePlayerNetID * maxPlayer = 0; 05704 REAL maxWait = .2; 05705 05706 // iterate over chatting players 05707 for ( int i = se_PlayerNetIDs.Len()-1; i>=0; --i ) 05708 { 05709 ePlayerNetID* player = se_PlayerNetIDs(i); 05710 if ( player->CurrentTeam() && player->chatting_ && ( !se_playerWaitTeamleader || player->CurrentTeam()->OldestHumanPlayer() == player ) ) 05711 { 05712 // account for waiting time if everyone is to get his time reduced 05713 if ( !se_playerWaitSingle ) 05714 { 05715 player->wait_ -= dt; 05716 05717 // hold back 05718 if ( player->wait_ > 0 ) 05719 { 05720 ret = true; 05721 } 05722 else 05723 { 05724 player->wait_ = 0; 05725 } 05726 } 05727 05728 // determine player we'll wait for longest 05729 if ( ( maxPlayer != lastPlayer || NULL == maxPlayer ) && ( player->wait_ > maxWait || player == lastPlayer ) && player->wait_ > 0 ) 05730 { 05731 maxWait = player->wait_; 05732 maxPlayer = player; 05733 } 05734 } 05735 } 05736 05737 // account for waiting time if only one player should get his waiting time reduced 05738 if ( se_playerWaitSingle && maxPlayer ) 05739 { 05740 maxPlayer->wait_ -= dt; 05741 05742 // hold back 05743 if ( maxPlayer->wait_ < 0 ) 05744 { 05745 maxPlayer->wait_ = 0; 05746 } 05747 } 05748 05749 static double lastPrint = -2; 05750 05751 // print information: who are we waiting for? 05752 if ( maxPlayer && maxPlayer != lastPlayer && tSysTimeFloat() - lastPrint > 1 ) 05753 { 05754 sn_ConsoleOut( tOutput( "$gamestate_chat_wait", maxPlayer->GetName(), int(10*maxPlayer->wait_)*.1f ) ); 05755 lastPlayer = maxPlayer; 05756 } 05757 05758 if ( lastPlayer == maxPlayer ) 05759 { 05760 lastPrint = tSysTimeFloat(); 05761 } 05762 05763 // store values for future reference 05764 lastReturn = ret; 05765 lastTime = time; 05766
void ePlayerNetID::RemoveChatbots | ( | ) | [static] |
removes chatbots and idling players from the game
Definition at line 5781 of file ePlayer.cpp.
References tColoredString::ColorString(), CurrentTeam(), IsChatting(), IsHuman(), IsSpectating(), LastActivity(), lastTime, GrowingArrayBase::Len(), nCLIENT, NULL, nNetObject::Owner(), REAL, se_chatterRemoveTime, se_idleKickTime, se_idleRemoveTime, se_PlayerNetIDs, SetDefaultTeam(), SetTeam(), sn_GetNetState(), sn_KickUser(), tSysTimeFloat(), and UpdateTeam().
Referenced by gGame::StateUpdate(), and update_settings().
05784 { 05785 // nothing to be done on the clients 05786 if ( nCLIENT == sn_GetNetState() ) 05787 return; 05788 05789 #ifdef KRAWALL_SERVER 05790 // update access level 05791 UpdateAccessLevelRequiredToPlay(); 05792 #endif 05793 05794 // determine the length of the last round 05795 static double lastTime = 0; 05796 double currentTime = tSysTimeFloat(); 05797 REAL roundTime = currentTime - lastTime; 05798 lastTime = currentTime; 05799 05800 // go through all players that don't have a team assigned currently, and assign one 05801 for ( int i = se_PlayerNetIDs.Len()-1; i>=0; --i ) 05802 { 05803 ePlayerNetID *p = se_PlayerNetIDs(i); 05804 if ( p && p->IsHuman() ) 05805 { 05806 // time allowed to be idle 05807 REAL idleTime = p->IsChatting() ? se_chatterRemoveTime : se_idleRemoveTime; 05808 05809 // determine whether the player should have a team 05810 bool shouldHaveTeam = idleTime <= 0 || p->LastActivity() - roundTime < idleTime; 05811 shouldHaveTeam &= !p->IsSpectating(); 05812 05813 tColoredString name; 05814 name << *p << tColoredString::ColorString(1,.5,.5); 05815 05816 // see to it that the player has or has not a team. 05817 if ( shouldHaveTeam ) 05818 { 05819 if ( !p->CurrentTeam() ) 05820 { 05821 p->SetDefaultTeam(); 05822 } 05823 } 05824 else 05825 { 05826 if ( p->CurrentTeam() ) 05827 { 05828 p->SetTeam( NULL ); 05829 p->UpdateTeam(); 05830 } 05831 } 05832 05833 // kick idle players (Removes player from list, this must be the last operation of the loop) 05834 if ( se_idleKickTime > 0 && se_idleKickTime < p->LastActivity() - roundTime ) 05835 { 05836 sn_KickUser( p->Owner(), tOutput( "$network_kill_idle" ) ); 05837 05838 // if many players get kicked with one client, the array may have changed 05839 if ( i >= se_PlayerNetIDs.Len() ) 05840 i = se_PlayerNetIDs.Len()-1; 05841 } 05842 }
void ePlayerNetID::CompleteRebuild | ( | ) | [static] |
Definition at line 5338 of file ePlayer.cpp.
Referenced by sg_HostGame(), and singlePlayer_game().
05340 { 05341 ClearAll();
void ePlayerNetID::ClearAll | ( | ) | [static] |
Reimplemented from nNetObject.
Reimplemented in gAIPlayer.
Definition at line 5306 of file ePlayer.cpp.
Referenced by ConnectToServerCore().
05308 { 05309 for(int i=MAX_PLAYERS-1;i>=0;i--){ 05310 ePlayer *local_p=ePlayer::PlayerConfig(i); 05311 if (local_p) 05312 local_p->netPlayer = NULL;
void ePlayerNetID::SpectateAll | ( | bool | spectate = true |
) | [static] |
Definition at line 5321 of file ePlayer.cpp.
References MAX_PLAYERS, NULL, ePlayer::PlayerConfig(), se_VisibleSpectatorsSupported(), and ePlayer::spectate.
05323 { 05324 for(int i=MAX_PLAYERS-1;i>=0;i--){ 05325 ePlayer *local_p=ePlayer::PlayerConfig(i); 05326 if (local_p) 05327 { 05328 if ( se_VisibleSpectatorsSupported() && bool(local_p->netPlayer) ) 05329 { 05330 local_p->netPlayer->spectating_ = spectate || local_p->spectate; 05331 05332 local_p->netPlayer->RequestSync(); 05333 } 05334 else 05335 local_p->netPlayer = NULL; 05336 }
void ePlayerNetID::ThrowOutDisconnected | ( | ) | [static] |
Definition at line 5844 of file ePlayer.cpp.
Referenced by gGame::~gGame().
05847 { 05848 int i; 05849 // find all disconnected players 05850 05851 for(i=se_PlayerNetIDs.Len()-1;i>=0;i--){ 05852 ePlayerNetID *pni=se_PlayerNetIDs(i); 05853 if (pni->disconnected) 05854 { 05855 // remove it from the list of players (so it won't be deleted twice...) 05856 se_PlayerNetIDs.Remove(pni, pni->listID); 05857 } 05858 } 05859
void ePlayerNetID::GetScoreFromDisconnectedCopy | ( | ) |
Definition at line 5861 of file ePlayer.cpp.
05864 { 05865 int i; 05866 // find a copy 05867 for(i=se_PlayerNetIDs.Len()-1;i>=0;i--){ 05868 ePlayerNetID *pni=se_PlayerNetIDs(i); 05869 if (pni->disconnected && pni->GetUserName() == GetUserName() && pni->Owner() == 0) 05870 { 05871 #ifdef DEBUG 05872 con << GetName() << " reconnected.\n"; 05873 #endif 05874 05875 pni->RequestSync(); 05876 RequestSync(); 05877 05878 score = pni->score; 05879 05880 ControlObject(pni->Object()); 05881 // object->ePlayer = this; 05882 pni->object = NULL; 05883 05884 if (bool(object)) 05885 chatting_ = true; 05886 05887 pni->disconnected = false; 05888 se_PlayerNetIDs.Remove(pni, pni->listID); 05889 se_PlayerReferences.Remove( pni ); // really delete it without a message 05890 }
void ePlayerNetID::Chat | ( | const tString & | s | ) |
Definition at line 3228 of file ePlayer.cpp.
Referenced by gAIPlayer::EmergencySurvive(), and se_rubyEval().
03231 { 03232 tColoredString s( s_orig ); 03233 s.NetFilter(); 03234 03235 switch (sn_GetNetState()) 03236 { 03237 case nCLIENT: 03238 { 03239 if(s_orig.StartsWith("/console") ) { 03240 tString params(""); 03241 if (s_orig.StrPos(" ") == -1) 03242 return; 03243 else 03244 params = s_orig.SubStr(s_orig.StrPos(" ") + 1); 03245 03246 if ( tRecorder::IsPlayingBack() ) 03247 { 03248 tConfItemBase::LoadPlayback(); 03249 } 03250 else 03251 { 03252 std::stringstream s(static_cast< char const * >( params ) ); 03253 tConfItemBase::LoadAll(s); 03254 } 03255 std::cout << "console selected\n"; 03256 } else 03257 se_NewChatMessage( this, s )->BroadCast(); 03258 break; 03259 } 03260 case nSERVER: 03261 { 03262 se_BroadcastChat( this, s ); 03263 } 03264 default: 03265 { 03266 if(s_orig.StartsWith("/console") ) { 03267 tString params(""); 03268 if (s_orig.StrPos(" ") == -1) 03269 return; 03270 else 03271 params = s_orig.SubStr(s_orig.StrPos(" ") + 1); 03272 03273 if ( tRecorder::IsPlayingBack() ) 03274 { 03275 tConfItemBase::LoadPlayback(); 03276 } 03277 else 03278 { 03279 std::stringstream s(static_cast< char const * >( params ) ); 03280 tConfItemBase::LoadAll(s); 03281 } 03282 std::cout << "console selected\n"; 03283 } else 03284 se_DisplayChatLocally( this, s ); 03285 03286 break; 03287 }
Reimplemented in gAIPlayer.
Definition at line 6393 of file ePlayer.cpp.
Referenced by gAIPlayer::Color(), and UpdateName().
06396 { 06397 if ( ( static_cast<bool>(currentTeam) ) && ( currentTeam->IsHuman() ) ) 06398 { 06399 REAL w = 5; 06400 REAL r_w = 2; 06401 REAL g_w = 1; 06402 REAL b_w = 2; 06403 06404 int r = this->r; 06405 int g = this->g; 06406 int b = this->b; 06407 06408 // don't tolerate color overflow in a real team 06409 if ( currentTeam->NumPlayers() > 1 ) 06410 { 06411 if ( r > 15 ) 06412 r = 15; 06413 if ( g > 15 ) 06414 g = 15; 06415 if ( b > 15 ) 06416 b = 15; 06417 } 06418 06419 a_r=(r_w*r + w*currentTeam->R())/( 15.0 * ( w + r_w ) ); 06420 a_g=(g_w*g + w*currentTeam->G())/( 15.0 * ( w + g_w ) ); 06421 a_b=(b_w*b + w*currentTeam->B())/( 15.0 * ( w + b_w ) ); 06422 } 06423 else 06424 { 06425 a_r = r/15.0; 06426 a_g = g/15.0; 06427 a_b = b/15.0;
Definition at line 6429 of file ePlayer.cpp.
06432 { 06433 Color( a_r, a_g, a_b ); 06434 06435 /* 06436 if ( ( static_cast<bool>(currentTeam) ) && ( currentTeam->IsHuman() ) ) 06437 { 06438 int w = 6; 06439 a_r=(2*r + w*currentTeam->R())/( 15.0 * ( w + 2 ) ); 06440 a_g=(2*g + w*currentTeam->G())/( 15.0 * ( w + 2 ) ); 06441 a_b=(2*b + w*currentTeam->B())/( 15.0 * ( w + 2 ) ); 06442 } 06443 else 06444 { 06445 a_r = r/15.0; 06446 a_g = g/15.0; 06447 a_b = b/15.0; 06448 }
bool ePlayerNetID::IsLoggedIn | ( | ) | const [inline] |
Definition at line 356 of file ePlayer.h.
References eAccessLevelHolder::GetAccessLevel(), and tAccessLevel_Moderator.
Referenced by IsSilencedWithWarning().
00356 { return GetAccessLevel() < tAccessLevel_Moderator; }
void ePlayerNetID::BeLoggedIn | ( | ) | [inline] |
Definition at line 357 of file ePlayer.h.
References eAccessLevelHolder::SetAccessLevel(), and tAccessLevel_Admin.
00357 { SetAccessLevel( tAccessLevel_Admin ); }
void ePlayerNetID::BeNotLoggedIn | ( | ) | [inline] |
Definition at line 358 of file ePlayer.h.
References eAccessLevelHolder::SetAccessLevel(), and tAccessLevel_Program.
00358 { SetAccessLevel( tAccessLevel_Program ); }
tAccessLevel ePlayerNetID::GetLastAccessLevel | ( | ) | const [inline] |
Definition at line 359 of file ePlayer.h.
References lastAccessLevel.
00359 { return lastAccessLevel; }
ePlayerNetID * ePlayerNetID::FindPlayerByName | ( | tString const & | name, | |
ePlayerNetID * | requester = 0 | |||
) | [static] |
finds a player by name using lax name matching. Reports errors to the console or to the requesting player.
Definition at line 1599 of file ePlayer.cpp.
References CompareBufferToPlayerNames(), con, FilterName(), GetName(), GetUserName(), NULL, nNetObject::Owner(), se_Hide(), se_NameFilterID(), se_NonHide(), and sn_ConsoleOut().
Referenced by eVoter::HandleChat(), se_FindPlayerInChatCommand(), and se_ReadUser().
01600 { 01601 int num_matches = 0; 01602 01603 // look for matches in the exact player names first 01604 ePlayerNetID * ret = CompareBufferToPlayerNames( name, num_matches, requester, &ePlayerNetID::GetName, &se_NameFilterID, &se_NonHide ); 01605 if ( ret && num_matches == 1 ) 01606 { 01607 return ret; 01608 } 01609 01610 // ok, next round: try filtering the names before comparing them, this makes the matching case-insensitive 01611 SE_NameFilter Filter = &ePlayerNetID::FilterName; 01612 01613 // look for matches in the screen names again 01614 if ( !ret ) 01615 { 01616 ret = CompareBufferToPlayerNames( name, num_matches, requester, &ePlayerNetID::GetName, Filter, &se_NonHide ); 01617 } 01618 if ( ret && num_matches == 1 ) 01619 { 01620 return ret; 01621 } 01622 01623 #ifdef KRAWALL_SERVER 01624 // nothing found? try the user names. 01625 if ( !ret ) 01626 { 01627 ret = CompareBufferToPlayerNames( name, num_matches, requester, &ePlayerNetID::GetUserName, &se_NameFilterID, &se_Hide ); 01628 } 01629 if ( ret && num_matches == 1 ) 01630 { 01631 return ret; 01632 } 01633 01634 // still nothing found? user names again 01635 if ( !ret ) 01636 { 01637 ret = CompareBufferToPlayerNames( name, num_matches, requester, &ePlayerNetID::GetUserName, Filter, &se_Hide ); 01638 } 01639 if ( ret && num_matches == 1 ) 01640 { 01641 return ret; 01642 } 01643 #endif 01644 01645 // More than than one match for the current buffer. Complain about that. 01646 else if (num_matches > 1) { 01647 tOutput toSender( "$msg_toomanymatches", name ); 01648 if ( requester ) 01649 { 01650 sn_ConsoleOut(toSender,requester->Owner() ); 01651 } 01652 else 01653 { 01654 con << toSender; 01655 } 01656 return NULL; 01657 } 01658 // 0 matches. The user can't spell. Complain about that, too. 01659 else { 01660 tOutput toSender( "$msg_nomatch", name ); 01661 if ( requester ) 01662 { 01663 sn_ConsoleOut(toSender,requester->Owner() ); 01664 } 01665 else 01666 { 01667 con << toSender; 01668 } 01669 return NULL; 01670 } 01671 01672 return 0; 01673 }
void ePlayerNetID::UpdateName | ( | void | ) |
update the player name from the client's wishes
Definition at line 6905 of file ePlayer.cpp.
References b, tString::Clear(), Color(), coloredName_, tColoredString::ColorString(), con, g, eAccessLevelHolder::GetAccessLevel(), GetFilteredAuthenticatedName(), lastAccessLevel, tString::Len(), name_, nameFromClient_, nameFromServer_, nCLIENT, nSERVER, nNetObject::Owner(), r, REAL, nNetObject::RequestSync(), se_allowImposters, se_IsNameTaken(), se_legacyLogNames, se_OptionalNameFilters(), se_UnauthenticatedUserName(), sn_ConsoleOut(), sn_GetNetState(), tString::SubStr(), and userName_.
Referenced by eTeam::AddPlayer(), eTeam::AddPlayerDirty(), eTeam::RemovePlayer(), SetName(), and Update().
06908 { 06909 // don't do a thing if we're not fully synced 06910 if ( this->ID() == 0 && nameFromClient_.Len() <= 1 && sn_GetNetState() == nSERVER ) 06911 return; 06912 06913 // monitor name changes 06914 eNameMessenger messenger( *this ); 06915 06916 // apply client change, stripping excess spaces 06917 if ( sn_GetNetState() != nCLIENT ) 06918 { 06919 // apply name filters only on remote players 06920 if ( Owner() != 0 ) 06921 se_OptionalNameFilters( nameFromClient_ ); 06922 06923 // disallow name changes if there was a kick vote recently 06924 if ( !bool(this->voter_) || voter_->AllowNameChange() || nameFromServer_.Len() <= 1 ) 06925 { 06926 nameFromServer_ = nameFromClient_; 06927 } 06928 else if ( nameFromServer_ != nameFromClient_ ) 06929 { 06930 // inform victim to avoid complaints 06931 tOutput message( "$player_rename_rejected", nameFromServer_, nameFromClient_ ); 06932 sn_ConsoleOut( message, Owner() ); 06933 con << message; 06934 06935 // revert name 06936 nameFromClient_ = nameFromServer_; 06937 } 06938 } 06939 06940 // remove colors from name 06941 tString newName = tColoredString::RemoveColors( nameFromServer_ ); 06942 tString newUserName = se_UnauthenticatedUserName( newName ); 06943 06944 // test if it is already taken, find an alternative name if so. 06945 if ( sn_GetNetState() != nCLIENT && !se_allowImposters && se_IsNameTaken( newUserName, this ) ) 06946 { 06947 // Remove possilble trailing digit. 06948 if ( newName.Len() > 2 && isdigit(newName(newName.Len()-2)) ) 06949 { 06950 newName = newName.SubStr( 0, newName.Len()-2 ); 06951 } 06952 06953 // append numbers until the name is free 06954 for ( int i=2; i<1000; ++i ) 06955 { 06956 tString testName(newName); 06957 testName << i; 06958 06959 // false the beginning if the name is too long 06960 if ( testName.Len() > 17 ) 06961 testName = testName.SubStr( testName.Len() - 17 ); 06962 06963 newUserName = se_UnauthenticatedUserName( testName ); 06964 06965 if ( !se_IsNameTaken( newUserName, this ) ) 06966 { 06967 newName = testName; 06968 break; 06969 } 06970 } 06971 06972 // rudely overwrite name from client 06973 nameFromServer_ = newName; 06974 } 06975 06976 // set the colored name to the name from the client, set trailing color to white 06977 coloredName_.Clear(); 06978 REAL r,g,b; 06979 Color(r,g,b); 06980 coloredName_ << tColoredString::ColorString(r,g,b) << nameFromServer_; 06981 06982 if ( name_ != newName || lastAccessLevel != GetAccessLevel() ) 06983 { 06984 // copy it to the name, removing colors of course 06985 name_ = newName; 06986 06987 // remove spaces and possibly other nasties for the user name 06988 userName_ = se_UnauthenticatedUserName( name_ ); 06989 06990 if (sn_GetNetState()!=nCLIENT) 06991 { 06992 // sync the new name 06993 RequestSync(); 06994 } 06995 } 06996 06997 // store access level for next update 06998 lastAccessLevel = GetAccessLevel(); 06999 07000 #ifdef KRAWALL_SERVER 07001 // take the user name to be the authenticated name 07002 if ( IsAuthenticated() ) 07003 { 07004 userName_ = GetFilteredAuthenticatedName(); 07005 if ( se_legacyLogNames ) 07006 { 07007 userName_ = tString( "0:" ) + userName_; 07008 } 07009 } 07010 else 07011 { 07012 rawAuthenticatedName_ = ""; 07013 }
filters a name (removes unprintables, color codes and spaces)
in | input name | |
out | output name cleared to be usable as a username |
Definition at line 7133 of file ePlayer.cpp.
References ePlayerCharacterFilter::Filter(), se_IsUnderscore(), se_StripMatchingEnds(), and tString::Size().
Referenced by gGame::Analysis(), FilterName(), FindPlayerByName(), LogScoreDifference(), se_IsNameTaken(), and se_UnauthenticatedUserName().
07136 { 07137 int i; 07138 static ePlayerCharacterFilter filter; 07139 out = tColoredString::RemoveColors( in ); 07140 07141 // filter out illegal characters 07142 for ( i = out.Size()-1; i>=0; --i ) 07143 { 07144 char & c = out[i]; 07145 07146 c = filter.Filter( c ); 07147 } 07148 07149 // strip leading and trailing unknown characters
filters a name (removes unprintables, color codes and spaces)
in | input name |
Definition at line 7162 of file ePlayer.cpp.
References FilterName().
07165 { 07166 tString out; 07167 FilterName( in, out );
void ePlayerNetID::MyInitAfterCreation | ( | void | ) | [private] |
Definition at line 3859 of file ePlayer.cpp.
References CreateVoter(), nMachine::GetMachine(), GetVoter(), lastActivity_, nSERVER, nNetObject::Owner(), RegisterWithMachine(), se_ClearLegacySpectator(), se_maxPlayersPerIP, se_silenceAll, silenced_, sn_DisconnectUser(), sn_GetNetState(), suspended_, tSysTimeFloat(), and wait_.
03862 { 03863 this->CreateVoter(); 03864 03865 this->silenced_ = se_silenceAll; 03866 03867 // register with machine and kick user if too many players are present 03868 if ( Owner() != 0 && sn_GetNetState() == nSERVER ) 03869 { 03870 this->RegisterWithMachine(); 03871 if ( se_maxPlayersPerIP < nMachine::GetMachine(Owner()).GetPlayerCount() ) 03872 { 03873 // kill them 03874 sn_DisconnectUser( Owner(), "$network_kill_too_many_players" ); 03875 03876 // technically has the same effect as the above function, but we also want 03877 // to abort registering this player object and this exception will do that as well. 03878 throw nKillHim(); 03879 } 03880 03881 // clear old legacy spectator that may be lurking around 03882 se_ClearLegacySpectator( Owner() ); 03883 03884 // get suspension count 03885 if ( GetVoter() ) 03886 { 03887 suspended_ = GetVoter()->suspended_; 03888 } 03889 } 03890 03891 this->wait_ = 0; 03892
nMachine & ePlayerNetID::DoGetMachine | ( | void | ) | const [protected, virtual] |
returns the machine this object belongs to
Reimplemented from nNetObject.
Definition at line 7327 of file ePlayer.cpp.
References nNetObject::DoGetMachine(), and registeredMachine_.
07330 { 07331 // return machine I'm registered at, otherwise whatever the base class thinks 07332 if ( registeredMachine_ ) 07333 return *registeredMachine_; 07334 else
tColoredString const & ePlayerNetID::GetNameFromClient | ( | void | ) | const [inline] |
Gets this player's name as the client wants it to be. Avoid using it when possilbe.
Definition at line 471 of file ePlayer.h.
References nameFromClient_.
00472 { 00473 return this->nameFromClient_; 00474 }
ePlayerNetID const & ePlayerNetID::GetNameFromClient | ( | tColoredString & | nameFromClient | ) | const [inline] |
Gets this player's name as the client wants it to be. Avoid using it when possilbe.
nameFromClient | this player's name as the client wants it to be. Avoid using it when possilbe. to fill |
Definition at line 487 of file ePlayer.h.
References nameFromClient_.
00488 { 00489 nameFromClient = this->nameFromClient_; 00490 return *this; 00491 }
tColoredString const & ePlayerNetID::GetColoredName | ( | void | ) | const [inline] |
Gets this player's name, cleared by the server. Use this for onscreen screen display.
Definition at line 520 of file ePlayer.h.
References coloredName_.
Referenced by eMenuItemSilence::eMenuItemSilence(), eTeam::Invite(), operator<<(), Suspend(), and eTeam::UnInvite().
00521 { 00522 return this->coloredName_; 00523 }
ePlayerNetID const & ePlayerNetID::GetColoredName | ( | tColoredString & | coloredName | ) | const [inline] |
Gets this player's name, cleared by the server. Use this for onscreen screen display.
coloredName | this player's name, cleared by the server. Use this for onscreen screen display. to fill |
Definition at line 536 of file ePlayer.h.
References coloredName_.
00537 { 00538 coloredName = this->coloredName_; 00539 return *this; 00540 }
tString const & ePlayerNetID::GetName | ( | void | ) | const [inline] |
Gets this player's name without colors.
Definition at line 569 of file ePlayer.h.
References name_.
Referenced by gGame::Analysis(), cCockpit::cb_CurrentName(), CreateNewTeam(), do_chat(), gCycleMovement::DoTurn(), eMenuItemKick::eMenuItemKick(), eNameMessenger::eNameMessenger(), gMenuItemPlayer::Enter(), FindPlayerByName(), gServerInfoAdmin::GetUsers(), gCycle::KillAt(), gCycleMovement::MyInitAfterCreation(), eVoter::Name(), gBaseZoneHack::OnVanish(), ReceiveControlNet(), gMenuItemPlayer::Render(), se_ChatTeamLeave(), se_DisplayChatLocallyClient(), se_IsNameTaken(), se_ListPlayers(), SetTeam(), SetTeamForce(), SetTeamWish(), sg_TopologyPoliceKill(), stc_updateFastest(), gCamera::Timestep(), gCycleMovement::TimestepCore(), Update(), eTeam::UpdateAppearance(), UpdateTeam(), and WaitToLeaveChat().
00570 { 00571 return this->name_; 00572 }
ePlayerNetID const & ePlayerNetID::GetName | ( | tString & | name | ) | const [inline] |
tString const & ePlayerNetID::GetUserName | ( | void | ) | const [inline] |
Gets this player's full name. Use for writing to files or comparing with admin input.
Definition at line 601 of file ePlayer.h.
References userName_.
Referenced by FindPlayerByName(), GetLogName(), gCycle::KillAt(), LogScoreDifference(), gCycle::PassEdge(), se_IsNameTaken(), se_RequestLogin(), sg_TopologyPoliceCheck(), gCycleMovement::Timestep(), and eTeam::UpdateAppearance().
00602 { 00603 return this->userName_; 00604 }
ePlayerNetID const & ePlayerNetID::GetUserName | ( | tString & | userName | ) | const [inline] |
Gets this player's name, cleared for system logs. Use for writing to files or comparing with admin input.
userName | this player's name, cleared for system logs. Use for writing to files or comparing with admin input. to fill |
Definition at line 617 of file ePlayer.h.
References userName_.
00618 { 00619 userName = this->userName_; 00620 return *this; 00621 }
tString const& ePlayerNetID::GetLogName | ( | void | ) | const [inline] |
Gets this player's name, cleared for system logs (with escaped special characters). Use for writing to files.
Definition at line 400 of file ePlayer.h.
References GetUserName().
Referenced by eNameMessenger::eNameMessenger().
tString ePlayerNetID::GetFilteredAuthenticatedName | ( | void | ) | const |
Gets the filtered, ecaped authentication name.
Definition at line 7224 of file ePlayer.cpp.
References se_EscapeName().
Referenced by se_ListPlayers(), and UpdateName().
07227 { 07228 #ifdef KRAWALL_SERVER 07229 return tString( se_EscapeName( GetRawAuthenticatedName() ).c_str() ); 07230 #else 07231 return tString("");
ePlayerNetID & ePlayerNetID::SetName | ( | tString const & | name | ) |
Sets this player's name. Sets processed names (colored, username, nameFromCLient) as well.
name | this player's name without colors. to set |
Definition at line 7180 of file ePlayer.cpp.
References IsLegalPlayerName(), nameFromClient_, nameFromServer_, nCLIENT, tString::NetFilter(), sn_GetNetState(), and UpdateName().
Referenced by gAITeam::BalanceWithAIs(), SetName(), gAIPlayer::SetNumberOfAIs(), and Update().
07183 { 07184 this->nameFromClient_ = name; 07185 this->nameFromClient_.NetFilter(); 07186 07187 // replace empty name 07188 if ( !IsLegalPlayerName( nameFromClient_ ) ) 07189 nameFromClient_ = "Player 1"; 07190 07191 if ( sn_GetNetState() != nCLIENT ) 07192 nameFromServer_ = nameFromClient_; 07193 07194 UpdateName(); 07195
ePlayerNetID & ePlayerNetID::SetName | ( | char const * | name | ) |
Sets this player's name. Sets processed names (colored, username, nameFromCLient) as well.
name | this player's name without colors. to set |
Definition at line 7208 of file ePlayer.cpp.
References SetName().
ePlayerNetID & ePlayerNetID::SetUserName | ( | tString const & | userName | ) | [inline] |
Sets this player's name, cleared for system logs. Use for writing to files or comparing with admin input. The other names stay unaffected.
userName | this player's name, cleared for system logs. Use for writing to files or comparing with admin input. to set |
Definition at line 634 of file ePlayer.h.
References userName_.
00635 { 00636 this->userName_ = userName; 00637 return *this; 00638 }
ePlayerNetID & ePlayerNetID::SetNameFromClient | ( | tColoredString const & | nameFromClient | ) | [inline, private] |
Sets this player's name as the client wants it to be. Avoid using it when possilbe.
nameFromClient | this player's name as the client wants it to be. Avoid using it when possilbe. to set |
Definition at line 504 of file ePlayer.h.
References nameFromClient_.
00505 { 00506 this->nameFromClient_ = nameFromClient; 00507 return *this; 00508 }
ePlayerNetID & ePlayerNetID::SetColoredName | ( | tColoredString const & | coloredName | ) | [inline, private] |
Sets this player's name, cleared by the server. Use this for onscreen screen display.
coloredName | this player's name, cleared by the server. Use this for onscreen screen display. to set |
Definition at line 553 of file ePlayer.h.
References coloredName_.
00554 { 00555 this->coloredName_ = coloredName; 00556 return *this; 00557 }
int & ePlayerNetID::AccessSuspended | ( | ) | [private] |
accesses the suspension count
Definition at line 7490 of file ePlayer.cpp.
References suspended_.
Referenced by Suspend().
int ePlayerNetID::GetSuspended | ( | ) | const [private] |
returns the suspension count
Definition at line 7496 of file ePlayer.cpp.
References suspended_.
Referenced by LogScoreDifferences(), eTeam::PlayerMayJoin(), and TeamChangeAllowed().
friend class eNetGameObject [friend] |
friend class tControlledPTR< ePlayerNetID > [friend] |
int ePlayerNetID::listID [private] |
int ePlayerNetID::teamListID [private] |
Definition at line 153 of file ePlayer.h.
Referenced by eTeam::AddPlayer(), eTeam::AddPlayerDirty(), eTeam::RemovePlayerDirty(), eTeam::SwapPlayers(), and TeamListID().
bool ePlayerNetID::silenced_ [private] |
Definition at line 155 of file ePlayer.h.
Referenced by AccessSilenced(), IsSilenced(), MyInitAfterCreation(), and SetSilenced().
int ePlayerNetID::suspended_ [private] |
Definition at line 156 of file ePlayer.h.
Referenced by AccessSuspended(), ePlayerNetID(), GetSuspended(), MyInitAfterCreation(), and UnregisterWithMachine().
nTimeAbsolute ePlayerNetID::timeJoinedTeam [private] |
number of rounds the player is currently suspended from playing
Definition at line 158 of file ePlayer.h.
Referenced by eTeam::AddPlayer(), eTeam::AddPlayerDirty(), eTeam::OldestAIPlayer(), eTeam::OldestHumanPlayer(), eTeam::OldestPlayer(), eTeam::YoungestAIPlayer(), eTeam::YoungestHumanPlayer(), and eTeam::YoungestPlayer().
eTeamSet ePlayerNetID::invitations_ [private] |
Definition at line 161 of file ePlayer.h.
Referenced by GetInvitations(), eTeam::Invite(), eTeam::IsInvited(), and eTeam::UnInvite().
int ePlayerNetID::score [private] |
Definition at line 167 of file ePlayer.h.
Referenced by AddScore(), CreateNewTeam(), ePlayerNetID(), gAIPlayer::gAIPlayer(), LogScoreDifference(), ResetScoreDifferences(), Score(), and TotalScore().
int ePlayerNetID::lastScore_ [private] |
Definition at line 168 of file ePlayer.h.
Referenced by ePlayerNetID(), LogScoreDifference(), and ResetScoreDifferences().
int ePlayerNetID::favoriteNumberOfPlayersPerTeam [private] |
bool ePlayerNetID::nameTeamAfterMe [private] |
Definition at line 171 of file ePlayer.h.
Referenced by ePlayerNetID(), Update(), and eTeam::UpdateAppearance().
bool ePlayerNetID::greeted [private] |
bool ePlayerNetID::disconnected [private] |
bool ePlayerNetID::spectating_ [private] |
are we currently spectating? Spectators don't get assigned to teams.
Definition at line 179 of file ePlayer.h.
Referenced by ePlayerNetID(), IsSpectating(), SetDefaultTeam(), and Update().
bool ePlayerNetID::stealth_ [private] |
does this player want to hide his/her identity?
Definition at line 180 of file ePlayer.h.
Referenced by ePlayerNetID(), StealthMode(), and Update().
bool ePlayerNetID::chatting_ [private] |
are we currently chatting?
Definition at line 181 of file ePlayer.h.
Referenced by ePlayerNetID(), IsChatting(), SetChatting(), and WaitToLeaveChat().
int ePlayerNetID::chatFlags_ [private] |
different types of reasons for beeing chatting
Definition at line 182 of file ePlayer.h.
Referenced by ePlayerNetID(), and SetChatting().
bool ePlayerNetID::allowTeamChange_ [private] |
allow team changes even if ALLOW_TEAM_CHANGE is disabled?
Definition at line 183 of file ePlayer.h.
Referenced by SetTeamChangeAllowed(), and TeamChangeAllowed().
tAccessLevel ePlayerNetID::lastAccessLevel [private] |
access level at the time of the last name update
Definition at line 186 of file ePlayer.h.
Referenced by ePlayerNetID(), GetLastAccessLevel(), and UpdateName().
nMachine* ePlayerNetID::registeredMachine_ [private] |
the machine the player is registered with
Definition at line 188 of file ePlayer.h.
Referenced by DoGetMachine(), RegisterWithMachine(), and UnregisterWithMachine().
Definition at line 201 of file ePlayer.h.
Referenced by ePlayerNetID(), SetTeamname(), and eTeam::UpdateAppearance().
unsigned short ePlayerNetID::r |
Definition at line 206 of file ePlayer.h.
Referenced by ePlayerNetID(), gAIPlayer::gAIPlayer(), Update(), eTeam::UpdateAppearance(), and UpdateName().
unsigned short ePlayerNetID::g |
Definition at line 206 of file ePlayer.h.
Referenced by ePlayerNetID(), gAIPlayer::gAIPlayer(), Update(), eTeam::UpdateAppearance(), and UpdateName().
unsigned short ePlayerNetID::b |
Definition at line 206 of file ePlayer.h.
Referenced by gAIPlayer::CycleBlocksWay(), ePlayerNetID(), gAIPlayer::gAIPlayer(), gAIPlayer::ThinkTrace(), Update(), eTeam::UpdateAppearance(), and UpdateName().
unsigned short ePlayerNetID::pingCharity |
Definition at line 210 of file ePlayer.h.
Referenced by ePlayerNetID(), gAIPlayer::gAIPlayer(), GameLoop(), se_GetPing(), sg_RubberValues(), and Update().
double ePlayerNetID::lastSync |
time of the last sync request
Definition at line 212 of file ePlayer.h.
Referenced by ePlayerNetID(), and GameLoop().
double ePlayerNetID::lastActivity_ |
time of the last activity
Definition at line 213 of file ePlayer.h.
Referenced by LastActivity(), and MyInitAfterCreation().
flag indicating whether this player currently wants to log on
Definition at line 215 of file ePlayer.h.
Referenced by ePlayerNetID(), and se_RequestLogin().
Definition at line 217 of file ePlayer.h.
Referenced by eChatSpamTester::Check(), and ReceiveControlNet().
tColoredString ePlayerNetID::nameFromClient_ [private] |
this player's name as the client wants it to be. Avoid using it when possilbe.
Definition at line 367 of file ePlayer.h.
Referenced by GetNameFromClient(), SetName(), SetNameFromClient(), Update(), and UpdateName().
tColoredString ePlayerNetID::nameFromServer_ [private] |
this player's name as the server wants it to be. Avoid using it when possilbe.
Definition at line 368 of file ePlayer.h.
Referenced by SetName(), and UpdateName().
tColoredString ePlayerNetID::coloredName_ [private] |
this player's name, cleared by the server. Use this for onscreen screen display.
Definition at line 369 of file ePlayer.h.
Referenced by GetColoredName(), SetColoredName(), and UpdateName().
tString ePlayerNetID::name_ [private] |
this player's name without colors.
Definition at line 370 of file ePlayer.h.
Referenced by GetName(), and UpdateName().
tString ePlayerNetID::userName_ [private] |
this player's name, cleared for system logs. Use for writing to files or comparing with admin input.
Definition at line 371 of file ePlayer.h.
Referenced by GetUserName(), SetUserName(), and UpdateName().
REAL ePlayerNetID::wait_ [private] |
time in seconds WaitToLeaveChat() will wait for this player
Definition at line 377 of file ePlayer.h.
Referenced by MyInitAfterCreation(), and WaitToLeaveChat().