Planeshift
Client Class Reference

This class collects data of a netclient. More...

#include <client.h>

Public Member Functions

void AddDuelClient (uint32_t clientnum)
 
void AddPet (gemActor *pet)
 
bool AllowDisconnect ()
 Permit the player to disconnect? Players cannot quit while in combat (includes spell casting). More...
 
void AnnounceToDuelClients (gemActor *attacker, const char *event)
 
void ClearAllDuelClients ()
 
 Client ()
 Please call constructor with the connection object produced by handleUnknownClient. More...
 
void CountDetectedCheat ()
 Give a warning to the client silently. Capped at 10000. More...
 
void DecrementSpamPoints ()
 
bool Disconnect ()
 
void FloodControl (uint8_t chatType, const csString &newMessage, const csString &recipient)
 Warn or mute for chat spamming. More...
 
AccountID GetAccountID ()
 The account number for this client. More...
 
unsigned int GetAccountTotalOnlineTime ()
 
gemActorGetActor () const
 
const SOCKADDR_INGetAddress () const
 
bool GetAdvisor ()
 
int GetAdvisorPoints ()
 
int GetAllianceID ()
 the alliance id value if the player is member of a guild in an alliance More...
 
bool GetBuddyListHide ()
 
MuteBuffableGetBuffableMute ()
 
psCharacterGetCharacterData ()
 
bool GetCheatMask (CheatFlags mask)
 
uint32_t GetClientNum () const
 
NetBase::ConnectionGetConnection () const
 
unsigned int GetDetectedCheatCount ()
 
int GetDuelClient (int id)
 
int GetDuelClientCount ()
 
int GetExchangeID ()
 
gemActorGetFamiliar ()
 
int GetGuildID ()
 The guild id value if player is member of guild. More...
 
void GetIPAddress (char *addrStr, socklen_t size)
 Return a string representing the ip address of this client. More...
 
csString GetIPAddress ()
 
csString GetIPRange (int octets=3)
 
bool GetLastInviteResult ()
 
csTicks GetLastInviteTime ()
 
csList< iSector * >::Iterator GetLocationDisplaying ()
 
csString GetMesh () const
 
const char * GetName ()
 Get Client Name. More...
 
size_t GetNumPets ()
 
OrderedMessageChannelGetOrderedMessageChannel (msgtype mtype)
 Get the channel to use for an ordered message. More...
 
csList< iSector * >::Iterator GetPathDisplaying ()
 
gemActorGetPet (size_t index)
 
PID GetPID ()
 The player number for this client. More...
 
int GetSecurityLevel () const
 The security level of this player. More...
 
int GetSelectedLocationID ()
 
int GetSpamPoints ()
 
int GetTargetClientID ()
 Get the current selected target player. More...
 
gemObjectGetTargetObject () const
 
csList< iSector * >::Iterator GetWaypointDisplaying ()
 
bool HasBeenPenalized ()
 
bool HasBeenWarned ()
 
void IncrementAdvisorPoints (int n=1)
 
void IncrementSpamPoints ()
 
bool Initialize (LPSOCKADDR_IN addr, uint32_t clientnum)
 
bool IsAdvisorBanned ()
 
bool IsAlive () const
 Returns whether the client's character is alive. More...
 
bool IsDuelClient (uint32_t clientnum)
 
bool IsGM () const
 
bool IsMute ()
 
bool IsMyPet (gemActor *other) const
 Return if other is one of my pets. More...
 
bool IsPlayerClient ()
 
bool IsReady ()
 
bool IsSuperClient ()
 
bool IsZombie ()
 A zombie client is a client that is prevented from disconnecting because of combat, spellcasting, or defeted. More...
 
void LocationClearDisplaying ()
 
bool LocationIsDisplaying ()
 
void LocationSetIsDisplaying (iSector *sector)
 Online edit of location. More...
 
void PathClearDisplaying ()
 
psPathPathGetPath ()
 
bool PathIsDisplaying ()
 
void PathSetIsDisplaying (iSector *sector)
 
void PathSetPath (psPath *path)
 
void RemoveDuelClient (Client *client)
 
void RemovePet (size_t index)
 
void SetAccountID (AccountID id)
 
void SetActor (gemActor *myactor)
 
void SetAdvisor (bool advisor)
 Set this client's advisor status. More...
 
void SetAdvisorBan (bool ban)
 
void SetAdvisorPoints (int p)
 
void SetAllowedToDisconnect (bool allowed)
 Called from server side to set the allowedToDisconnect flag. More...
 
void SetBuddyListHide (bool hide)
 Change whether hiding from buddylists. More...
 
void SetCheatMask (CheatFlags mask, bool flag)
 Set the next move as not a cheat, or clear it. More...
 
void SetExchangeID (int ID)
 
void SetFamiliar (gemActor *familiar)
 
void SetLastInviteResult (bool result)
 
void SetLastInviteTime (csTicks time)
 
void SetMesh (csString nextMesh)
 
void SetMute (bool flag)
 SetMute is the function that toggles the muted flag. More...
 
void SetName (const char *n)
 Set the clients name. More...
 
void SetPenalized (bool value)
 
void SetPID (PID id)
 
void SetReady (bool rdy)
 Sets the player state to ready. For example ready to receive chat messages. More...
 
void SetSecurityLevel (int level)
 
void SetSelectedLocationID (int id)
 
void SetSpamPoints (int points)
 
void SetSuperClient (bool flag)
 Allow distinguishing superclients from regular player clients. More...
 
void SetTargetObject (gemObject *object, bool updateClientGUI=false)
 
void SetWarned ()
 
bool ValidateDistanceToTarget (float range)
 Check if distance between client and target is within range. More...
 
void WaypointClearDisplaying ()
 
int WaypointGetNewPathIndex ()
 
int WaypointGetPathIndex ()
 
csString & WaypointGetPathName ()
 
bool WaypointIsDisplaying ()
 
void WaypointSetIsDisplaying (iSector *sector)
 
void WaypointSetPath (csString &path, int index)
 Online edit of paths. More...
 
bool ZombieAllowDisconnect ()
 Check if a zombie is allowed to disconnect. Called from the network thread so no access to server internal data should be made. More...
 
 ~Client ()
 

Static Public Member Functions

static csString GetIPRange (const char *ipaddr, int octets=3)
 
static void GetTargetTypeName (int32_t targetType, csString &targetDesc)
 Builds a list of target type names associated with a target type bitmap (formed by OR-ing TARGET_TYPES). More...
 

Public Attributes

csTicks accumulatedLag
 For cheat detection. More...
 
csTicks lastGlyphSend
 
csTicks lastInventorySend
 
csRef< NetPacketQueueRefCountoutqueue
 

Protected Member Functions

void SaveAccountData ()
 
- Protected Member Functions inherited from NetBase::Connection
void AddToWindow (uint32_t bytes)
 Add to window when reliable data is in transit. More...
 
 Connection (uint32_t num=0)
 
uint32_t GetNextPacketID ()
 
bool isValid () const
 
bool IsWindowFull ()
 Check if the reliable transmission window is full. More...
 
void RemoveFromWindow (uint32_t bytes)
 Remove from transmission window when an ack is received. More...
 
 ~Connection ()
 

Protected Attributes

AccountID accountID
 
gemActoractor
 Pointer to the gemActor object played by this client once a character is logged in and in-game. More...
 
int advisorPoints
 
bool allowedToDisconnect
 Server set this flag when the player isn't casting spells, fighting or doing anythinge else that should prevent the player from disconnecting. More...
 
csArray< uint32_t > duel_clients
 
int exchangeID
 Currently active id of Exchange object managed by Exchange Manager, or 0 if no exchange is active. More...
 
FloodBuffRow floodHistory [floodMax]
 
bool hasBeenPenalized
 
bool hasBeenWarned
 
bool isAdvisor
 Store if this client is acting as an advisor. More...
 
bool lastInviteResult
 
csTicks lastInviteTime
 
csArray< gemNPC * > listeningNpc
 
csList< iSector * > locationDisplaySectors
 
csString mesh
 
MuteBuffable mute
 mute flag More...
 
csString name
 
int nextFloodHistoryIndex
 
csHash< OrderedMessageChannel * > orderedMessages
 This collection stores queues of ordered messages while we're waiting for an out of order one to arrive. More...
 
csList< iSector * > pathDisplaySectors
 
psPathpathPath
 
csArray< PID > pets
 
PID playerID
 
bool ready
 
int securityLevel
 
int selectedLocationID
 
int spamPoints
 
bool superclient
 
csList< iSector * > waypointDisplaySectors
 Sectors where client is doing online editing. More...
 
int waypointPathIndex
 
csString waypointPathName
 
bool zombie
 A zombie client is a client where the player has disconnected, but still active due to not finished combat, spellcasting, or defeted. More...
 
csTicks zombietimeout
 
- Protected Attributes inherited from NetBase::Connection
SOCKADDR_IN addr
 The INet Adress of the client. More...
 
void * buf
 buffer for split up packets, allocated when needed More...
 
uint32_t clientnum
 the client num More...
 
float devRTT
 RTT deviance. More...
 
float estRTT
 Estimated RTT. More...
 
int heartbeat
 number of attempts to keep alive connection without ack response More...
 
int historypos
 
csTicks lastRecvPacketTime
 last time packet was received from this connection More...
 
csString nameAddr
 The adress if provided, usually in clients, else an empty csstring. More...
 
csHash< uint32_t > packethistoryhash
 
uint32_t packethistoryid [MAXPACKETHISTORY]
 keeps track of received packets to drop doubled packets More...
 
uint32_t packethistoryoffset [MAXPACKETHISTORY]
 
int pcknumin
 The Number of the last incoming packet. More...
 
int pcknumout
 The Number of the last outgoing packet. More...
 
uint32_t resends
 Number of resends. More...
 
csTicks RTO
 timeout More...
 
uint32_t sends
 Number of reliable sends. More...
 
bool valid
 Is this already a valid connection? More...
 
uint32_t window
 

Static Protected Attributes

static const unsigned int floodForgiveTime = 10000
 How long to wait before forgiving a repeated message. More...
 
static const int floodMax = 5
 Mute client after 5 repeated messages. More...
 
static const int floodWarn = 3
 Warn client after 3 repeated messages. More...
 

Detailed Description

This class collects data of a netclient.

While the socket data like ip adress and port is managed inside NetManager and not stored here this is the object that will be saved in the ObjectManager and will get an Object ID

Definition at line 95 of file client.h.

Constructor & Destructor Documentation

Client::Client ( )

Please call constructor with the connection object produced by handleUnknownClient.

Client::~Client ( )

Member Function Documentation

void Client::AddDuelClient ( uint32_t  clientnum)
void Client::AddPet ( gemActor pet)
bool Client::AllowDisconnect ( )

Permit the player to disconnect? Players cannot quit while in combat (includes spell casting).

Also causes the client to be set as a zombie indicating that the server knows the connection has been broken.

void Client::AnnounceToDuelClients ( gemActor attacker,
const char *  event 
)
void Client::ClearAllDuelClients ( )
void Client::CountDetectedCheat ( )
inline

Give a warning to the client silently. Capped at 10000.

Definition at line 470 of file client.h.

void Client::DecrementSpamPoints ( )
inline

Definition at line 408 of file client.h.

bool Client::Disconnect ( )
void Client::FloodControl ( uint8_t  chatType,
const csString &  newMessage,
const csString &  recipient 
)

Warn or mute for chat spamming.

AccountID Client::GetAccountID ( )
inline

The account number for this client.

Definition at line 212 of file client.h.

unsigned int Client::GetAccountTotalOnlineTime ( )
gemActor* Client::GetActor ( ) const
inline

Definition at line 161 of file client.h.

const SOCKADDR_IN& Client::GetAddress ( ) const
inline

Definition at line 315 of file client.h.

bool Client::GetAdvisor ( )
inline

Definition at line 353 of file client.h.

int Client::GetAdvisorPoints ( )
inline

Definition at line 343 of file client.h.

int Client::GetAllianceID ( )

the alliance id value if the player is member of a guild in an alliance

bool Client::GetBuddyListHide ( )
inline

Definition at line 499 of file client.h.

MuteBuffable& Client::GetBuffableMute ( )
inline

Definition at line 137 of file client.h.

psCharacter* Client::GetCharacterData ( )
bool Client::GetCheatMask ( CheatFlags  mask)
inline

Definition at line 480 of file client.h.

uint32_t Client::GetClientNum ( ) const
inline

Definition at line 206 of file client.h.

NetBase::Connection* Client::GetConnection ( ) const
inline

Definition at line 310 of file client.h.

unsigned int Client::GetDetectedCheatCount ( )
inline

Definition at line 474 of file client.h.

int Client::GetDuelClient ( int  id)
int Client::GetDuelClientCount ( )
int Client::GetExchangeID ( )
inline

Definition at line 231 of file client.h.

gemActor* Client::GetFamiliar ( )
int Client::GetGuildID ( )

The guild id value if player is member of guild.

void Client::GetIPAddress ( char *  addrStr,
socklen_t  size 
)

Return a string representing the ip address of this client.

csString Client::GetIPAddress ( )
csString Client::GetIPRange ( int  octets = 3)
static csString Client::GetIPRange ( const char *  ipaddr,
int  octets = 3 
)
static
bool Client::GetLastInviteResult ( )
inline

Definition at line 372 of file client.h.

csTicks Client::GetLastInviteTime ( )
inline

Definition at line 364 of file client.h.

csList<iSector*>::Iterator Client::GetLocationDisplaying ( )
csString Client::GetMesh ( ) const
inline

Definition at line 195 of file client.h.

const char* Client::GetName ( )

Get Client Name.

Returning the account name until a Character is connected to the client. When a Character is connected it will returnt the Character first name.

size_t Client::GetNumPets ( )
OrderedMessageChannel* Client::GetOrderedMessageChannel ( msgtype  mtype)

Get the channel to use for an ordered message.

csList<iSector*>::Iterator Client::GetPathDisplaying ( )
gemActor* Client::GetPet ( size_t  index)
PID Client::GetPID ( )
inline

The player number for this client.

Definition at line 222 of file client.h.

int Client::GetSecurityLevel ( ) const
inline

The security level of this player.

Definition at line 241 of file client.h.

int Client::GetSelectedLocationID ( )
inline

Definition at line 463 of file client.h.

int Client::GetSpamPoints ( )
inline

Definition at line 396 of file client.h.

int Client::GetTargetClientID ( )

Get the current selected target player.

Returns
-1 if no target selected or target not a player
gemObject* Client::GetTargetObject ( ) const
static void Client::GetTargetTypeName ( int32_t  targetType,
csString &  targetDesc 
)
static

Builds a list of target type names associated with a target type bitmap (formed by OR-ing TARGET_TYPES).

Parameters
targetTypeA target type bitmap.
targetDesc[CHANGES] Gets filled in with a comma-separated list of target names.
csList<iSector*>::Iterator Client::GetWaypointDisplaying ( )
bool Client::HasBeenPenalized ( )
inline

Definition at line 388 of file client.h.

bool Client::HasBeenWarned ( )
inline

Definition at line 380 of file client.h.

void Client::IncrementAdvisorPoints ( int  n = 1)
inline

Definition at line 339 of file client.h.

void Client::IncrementSpamPoints ( )
inline

Definition at line 404 of file client.h.

bool Client::Initialize ( LPSOCKADDR_IN  addr,
uint32_t  clientnum 
)
bool Client::IsAdvisorBanned ( )
bool Client::IsAlive ( ) const

Returns whether the client's character is alive.

bool Client::IsDuelClient ( uint32_t  clientnum)
bool Client::IsGM ( ) const
bool Client::IsMute ( )
inline

Definition at line 133 of file client.h.

bool Client::IsMyPet ( gemActor other) const

Return if other is one of my pets.

bool Client::IsPlayerClient ( )
inline

Definition at line 295 of file client.h.

bool Client::IsReady ( )
inline

Definition at line 262 of file client.h.

bool Client::IsSuperClient ( )
inline

Definition at line 291 of file client.h.

bool Client::IsZombie ( )
inline

A zombie client is a client that is prevented from disconnecting because of combat, spellcasting, or defeted.

Definition at line 281 of file client.h.

void Client::LocationClearDisplaying ( )
bool Client::LocationIsDisplaying ( )
void Client::LocationSetIsDisplaying ( iSector *  sector)

Online edit of location.

void Client::PathClearDisplaying ( )
psPath* Client::PathGetPath ( )
inline

Definition at line 432 of file client.h.

bool Client::PathIsDisplaying ( )
void Client::PathSetIsDisplaying ( iSector *  sector)
void Client::PathSetPath ( psPath path)
inline

Definition at line 436 of file client.h.

void Client::RemoveDuelClient ( Client client)
void Client::RemovePet ( size_t  index)
void Client::SaveAccountData ( )
protected
void Client::SetAccountID ( AccountID  id)
inline

Definition at line 216 of file client.h.

void Client::SetActor ( gemActor myactor)
void Client::SetAdvisor ( bool  advisor)
inline

Set this client's advisor status.

Definition at line 349 of file client.h.

void Client::SetAdvisorBan ( bool  ban)
void Client::SetAdvisorPoints ( int  p)
inline

Definition at line 335 of file client.h.

void Client::SetAllowedToDisconnect ( bool  allowed)

Called from server side to set the allowedToDisconnect flag.

This flagg will be read by the network thread to see if the client could be disconnected.

void Client::SetBuddyListHide ( bool  hide)
inline

Change whether hiding from buddylists.

Definition at line 495 of file client.h.

void Client::SetCheatMask ( CheatFlags  mask,
bool  flag 
)

Set the next move as not a cheat, or clear it.

void Client::SetExchangeID ( int  ID)
inline

Definition at line 235 of file client.h.

void Client::SetFamiliar ( gemActor familiar)
void Client::SetLastInviteResult ( bool  result)
inline

Definition at line 376 of file client.h.

void Client::SetLastInviteTime ( csTicks  time)
inline

Definition at line 368 of file client.h.

void Client::SetMesh ( csString  nextMesh)
inline

Definition at line 191 of file client.h.

void Client::SetMute ( bool  flag)
inline

SetMute is the function that toggles the muted flag.

Definition at line 129 of file client.h.

void Client::SetName ( const char *  n)

Set the clients name.

Use this to set the account name during loading. When a Character is loaded this call will have no effect anymore, since GetName than will use the character to get the name.

void Client::SetPenalized ( bool  value)
inline

Definition at line 392 of file client.h.

void Client::SetPID ( PID  id)
inline

Definition at line 226 of file client.h.

void Client::SetReady ( bool  rdy)
inline

Sets the player state to ready. For example ready to receive chat messages.

Definition at line 258 of file client.h.

void Client::SetSecurityLevel ( int  level)
inline

Definition at line 245 of file client.h.

void Client::SetSelectedLocationID ( int  id)
inline

Definition at line 459 of file client.h.

void Client::SetSpamPoints ( int  points)
inline

Definition at line 400 of file client.h.

void Client::SetSuperClient ( bool  flag)
inline

Allow distinguishing superclients from regular player clients.

Definition at line 287 of file client.h.

void Client::SetTargetObject ( gemObject object,
bool  updateClientGUI = false 
)
void Client::SetWarned ( )
inline

Definition at line 384 of file client.h.

bool Client::ValidateDistanceToTarget ( float  range)

Check if distance between client and target is within range.

void Client::WaypointClearDisplaying ( )
int Client::WaypointGetNewPathIndex ( )
inline

Definition at line 427 of file client.h.

int Client::WaypointGetPathIndex ( )
inline

Definition at line 423 of file client.h.

csString& Client::WaypointGetPathName ( )
inline

Definition at line 419 of file client.h.

bool Client::WaypointIsDisplaying ( )
void Client::WaypointSetIsDisplaying ( iSector *  sector)
void Client::WaypointSetPath ( csString &  path,
int  index 
)
inline

Online edit of paths.

Definition at line 414 of file client.h.

bool Client::ZombieAllowDisconnect ( )

Check if a zombie is allowed to disconnect. Called from the network thread so no access to server internal data should be made.

Member Data Documentation

AccountID Client::accountID
protected

Definition at line 538 of file client.h.

csTicks Client::accumulatedLag

For cheat detection.

Definition at line 361 of file client.h.

gemActor* Client::actor
protected

Pointer to the gemActor object played by this client once a character is logged in and in-game.

Definition at line 524 of file client.h.

int Client::advisorPoints
protected

Definition at line 555 of file client.h.

bool Client::allowedToDisconnect
protected

Server set this flag when the player isn't casting spells, fighting or doing anythinge else that should prevent the player from disconnecting.

Definition at line 518 of file client.h.

csArray<uint32_t> Client::duel_clients
protected

Definition at line 545 of file client.h.

int Client::exchangeID
protected

Currently active id of Exchange object managed by Exchange Manager, or 0 if no exchange is active.

Definition at line 521 of file client.h.

const unsigned int Client::floodForgiveTime = 10000
staticprotected

How long to wait before forgiving a repeated message.

Definition at line 550 of file client.h.

FloodBuffRow Client::floodHistory[floodMax]
protected

Definition at line 551 of file client.h.

const int Client::floodMax = 5
staticprotected

Mute client after 5 repeated messages.

Definition at line 549 of file client.h.

const int Client::floodWarn = 3
staticprotected

Warn client after 3 repeated messages.

Definition at line 548 of file client.h.

bool Client::hasBeenPenalized
protected

Definition at line 563 of file client.h.

bool Client::hasBeenWarned
protected

Definition at line 562 of file client.h.

bool Client::isAdvisor
protected

Store if this client is acting as an advisor.

Definition at line 533 of file client.h.

csTicks Client::lastGlyphSend

Definition at line 492 of file client.h.

csTicks Client::lastInventorySend

Definition at line 491 of file client.h.

bool Client::lastInviteResult
protected

Definition at line 561 of file client.h.

csTicks Client::lastInviteTime
protected

Definition at line 560 of file client.h.

csArray<gemNPC*> Client::listeningNpc
protected

Definition at line 542 of file client.h.

csList<iSector*> Client::locationDisplaySectors
protected

Definition at line 576 of file client.h.

csString Client::mesh
protected

Definition at line 527 of file client.h.

MuteBuffable Client::mute
protected

mute flag

Definition at line 536 of file client.h.

csString Client::name
protected

Definition at line 543 of file client.h.

int Client::nextFloodHistoryIndex
protected

Definition at line 552 of file client.h.

csHash<OrderedMessageChannel*> Client::orderedMessages
protected

This collection stores queues of ordered messages while we're waiting for an out of order one to arrive.

Definition at line 531 of file client.h.

csRef<NetPacketQueueRefCount> Client::outqueue

Definition at line 320 of file client.h.

csList<iSector*> Client::pathDisplaySectors
protected

Definition at line 575 of file client.h.

psPath* Client::pathPath
protected

Definition at line 569 of file client.h.

csArray<PID> Client::pets
protected

Definition at line 526 of file client.h.

PID Client::playerID
protected

Definition at line 539 of file client.h.

bool Client::ready
protected

Definition at line 528 of file client.h.

int Client::securityLevel
protected

Definition at line 540 of file client.h.

int Client::selectedLocationID
protected

Definition at line 571 of file client.h.

int Client::spamPoints
protected

Definition at line 554 of file client.h.

bool Client::superclient
protected

Definition at line 541 of file client.h.

csList<iSector*> Client::waypointDisplaySectors
protected

Sectors where client is doing online editing.

Definition at line 574 of file client.h.

int Client::waypointPathIndex
protected

Definition at line 567 of file client.h.

csString Client::waypointPathName
protected

Definition at line 566 of file client.h.

bool Client::zombie
protected

A zombie client is a client where the player has disconnected, but still active due to not finished combat, spellcasting, or defeted.

Definition at line 510 of file client.h.

csTicks Client::zombietimeout
protected

Definition at line 511 of file client.h.


The documentation for this class was generated from the following file: