Planeshift
Public Member Functions | Protected Attributes

psGuildInfo Class Reference

Holds data for a guild. More...

#include <psguildinfo.h>

List of all members.

Public Member Functions

void AddGuildWar (psGuildInfo *other)
 Adds a guild war with another guild.
bool AddNewMember (psCharacter *player, int level=1)
 Adds a character to this guild.
void AdjustMoney (const psMoney &money, bool unused)
 Override for BankManager.
void AdjustMoney (const psMoney &money)
 Adjusts the money in this guild's bank.
void Connect (psCharacter *player)
 Marks a player as being connected.
void Disconnect (psCharacter *player)
 Marks a player as being disconnted.
psGuildMemberFindLeader () const
 Finds the leader.
psGuildLevelFindLevel (int level) const
 Finds a level.
psGuildMemberFindMember (PID char_id) const
 Finds a member.
psGuildMemberFindMember (const char *name) const
 Finds a member.
int GetAllianceID () const
 Gets the ID of the alliance this guild belongs to.
psMoneyGetBankMoney ()
 Returns the amount of money this guild has in it's bank.
int GetID () const
 Gets the ID of this guild.
int GetKarmaPoints () const
 Gets the karma points.
csArray< psGuildLevel * >
::ConstIterator 
GetLevelIterator () const
 Gets a const iterator for levels.
csArray< psGuildLevel * >::Iterator GetLevelIterator ()
 Gets an iterator for level.
int GetMaxMemberPoints () const
 Simply returns the max member points allowed for this guild.
size_t GetMemberCount () const
 Gets the number of members.
csArray< psGuildMember * >
::Iterator 
GetMemberIterator ()
 Gets an iterator for level.
csArray< psGuildMember * >
::ConstIterator 
GetMemberIterator () const
 Gets a const iterator for levels.
const csString & GetMOTD () const
 Gets the MOTD string.
const csString & GetName () const
 Simply returns this guild's name.
const csString & GetWebPage () const
 Gets the web page.
bool InsertNew ()
 Inserts a new guild into the DB.
bool IsGuildWarActive (psGuildInfo *other)
 Checks if a guild war is active.
bool IsSecret () const
 Returns whether this guild is secret.
bool Load (const csString &name)
 Loads the guild based on the name of the guild.
bool Load (unsigned int id)
 Loads the guild based on the ID of the guild.
bool Load (iResultRow &row)
 Loads guild information out of a DB result.
bool MeetsMinimumRequirements () const
 Tests if the guild meets minimum requirements.
unsigned int MinutesUntilUserChangeName () const
 Gets how long before a user change their name.
 psGuildInfo (csString name, PID founder)
 Basic constructor.
 psGuildInfo ()
 Basic constructor.
bool RemoveGuild ()
 Removes the guild from the DB.
void RemoveGuildWar (psGuildInfo *other)
 Removes a guild war.
bool RemoveMember (psGuildMember *target)
 Removes a member from this guild.
bool RenameLevel (int level, const char *levelname)
 Renames a level within this guild.
void SaveBankMoney ()
 Performs the DB save for this bank's money.
bool SetKarmaPoints (int n_karma_points)
 Sets the karma points.
bool SetMaxMemberPoints (int points)
 Changes the max amount of points a member may have for this guild.
bool SetMemberNotes (psGuildMember *member, const csString &notes, bool isPublic)
 Sets a member's notes for the guild.
bool SetMemberPoints (psGuildMember *member, int points)
 Sets a member's points in the guild.
bool SetMemberPrivilege (psGuildMember *member, GUILD_PRIVILEGE privilege, bool on)
 Sets a privilege flag on a specific member.
bool SetMOTD (const csString &str)
 Sets the MOTD string.
bool SetName (csString guildName)
 Sets the name for the guild.
bool SetPrivilege (int level, GUILD_PRIVILEGE privilege, bool on)
 Sets a privilege flag on a level.
bool SetSecret (bool secretGuild)
 Sets whether the guild is secret or not.
bool SetWebPage (const csString &web_page)
 Sets the web page.
void UpdateLastLogin (psCharacter *player)
 Updates the last login time for the player.
bool UpdateMemberLevel (psGuildMember *target, int level)
 Changes a member's level.
 ~psGuildInfo ()
 Basic deconstructor.

Protected Attributes

int alliance
 Alliance ID that this guild belongs to Default: 0(no alliance)
psMoney bankMoney
 Money stored in the guild bank account.
PID founder
 Character id for the founder of the guild.
csArray< intguild_war_with_id
 IDs of guild that this guild is at war with.
int id
 UID of the guild.
int karma_points
 Guild's current karma points.
csTicks lastNameChange
 Last time the name of this guild was changed Default: 0
csArray< psGuildLevel * > levels
 All of the levels of the guild.
int max_guild_points
 Maximum guild points obtainable in the guild.
csArray< psGuildMember * > members
 All of the members of the guild.
csString motd
 The guild's Message of the day.
csString name
 Name of the guild.
bool secret
 Flag if the guild is secret or not.
csString web_page
 URL for the guild.

Detailed Description

Holds data for a guild.

Primary database table : guilds <br> Secondary database tables: characters, guild_wars, guildlevels

Definition at line 159 of file psguildinfo.h.


Constructor & Destructor Documentation

psGuildInfo::psGuildInfo ( )

Basic constructor.

Initializes an empty guild that is invalid. Load or InsertNew() must be called before this guild is populated with anything useful.

psGuildInfo::psGuildInfo ( csString  name,
PID  founder 
)

Basic constructor.

Initializes an empty guild that is invalid. Load or InsertNew() must be called before this guild is populated with anything useful.

Parameters:
nameThe name of the guild
founderThe PID of the founder of the guild
psGuildInfo::~psGuildInfo ( )

Basic deconstructor.


Member Function Documentation

void psGuildInfo::AddGuildWar ( psGuildInfo other)

Adds a guild war with another guild.

Adds the other guild to guild_war_with_id. DB is updated through the command pump.

Parameters:
otherThe guild this guild is going to war with
bool psGuildInfo::AddNewMember ( psCharacter player,
int  level = 1 
)

Adds a character to this guild.

Checks if member is already part of a guild and fails if they are. If they are not the database is updated and this object is updated accordingly to reflect a new member by adding the new member to members.

Parameters:
playerThe character that is joining
levelThe level the character is joining at
Note:
No checks are done to ensure the joining level is valid
Returns:
True if everything went okay, false if the member was already part of a guild or the DB update failed.
void psGuildInfo::AdjustMoney ( const psMoney money,
bool  unused 
) [inline]

Override for BankManager.

Parameters:
moneyPassed to other func
unusedUnused

Definition at line 430 of file psguildinfo.h.

void psGuildInfo::AdjustMoney ( const psMoney money)

Adjusts the money in this guild's bank.

Simply updates bankMoney and then calls SaveBankMoney.

Parameters:
moneyThe money values to adjust by
void psGuildInfo::Connect ( psCharacter player)

Marks a player as being connected.

If player matches one of members then that object has its actor updated.

Parameters:
playerThe player that connected
void psGuildInfo::Disconnect ( psCharacter player)

Marks a player as being disconnted.

If player matches one of members then that member has its actor reset back to null and player has its guild set to null

Parameters:
playerThe player that disconnected
psGuildMember* psGuildInfo::FindLeader ( ) const

Finds the leader.

Searches through members for the member with level equal to MAX_GUILD_LEVEL.

Note:
This function should never return null
Returns:
null if the leader could not be found, the member otherwise
psGuildLevel* psGuildInfo::FindLevel ( int  level) const

Finds a level.

Searches through level for the level equal to level.

Parameters:
levelThe level to look for
Returns:
null if the level could not be found, the level otherwise
psGuildMember* psGuildInfo::FindMember ( const char *  name) const

Finds a member.

Searches through members for a member with a name that matches name (case-insensitive).

Returns:
null if member was not found, the member otherwise
psGuildMember* psGuildInfo::FindMember ( PID  char_id) const

Finds a member.

Searches through members for a member with a PID that matches char_id.

Returns:
null if member was not found, the member otherwise
int psGuildInfo::GetAllianceID ( ) const [inline]

Gets the ID of the alliance this guild belongs to.

Returns:
alliance, 0 denotes no alliance

Definition at line 657 of file psguildinfo.h.

psMoney& psGuildInfo::GetBankMoney ( ) [inline]

Returns the amount of money this guild has in it's bank.

Returns:
bankMoney

Definition at line 449 of file psguildinfo.h.

int psGuildInfo::GetID ( ) const [inline]

Gets the ID of this guild.

Returns:
id

Definition at line 667 of file psguildinfo.h.

int psGuildInfo::GetKarmaPoints ( ) const [inline]

Gets the karma points.

Returns:
karma_points

Definition at line 608 of file psguildinfo.h.

csArray<psGuildLevel*>::ConstIterator psGuildInfo::GetLevelIterator ( ) const [inline]

Gets a const iterator for levels.

Returns:
A const iterator from levels

Definition at line 677 of file psguildinfo.h.

csArray<psGuildLevel*>::Iterator psGuildInfo::GetLevelIterator ( ) [inline]

Gets an iterator for level.

Returns:
An iterator from levels

Definition at line 687 of file psguildinfo.h.

int psGuildInfo::GetMaxMemberPoints ( ) const [inline]

Simply returns the max member points allowed for this guild.

Returns:
max_guild_points

Definition at line 497 of file psguildinfo.h.

size_t psGuildInfo::GetMemberCount ( ) const [inline]

Gets the number of members.

Returns:
Size of members

Definition at line 717 of file psguildinfo.h.

csArray<psGuildMember*>::ConstIterator psGuildInfo::GetMemberIterator ( ) const [inline]

Gets a const iterator for levels.

Returns:
A const iterator from levels

Definition at line 697 of file psguildinfo.h.

csArray<psGuildMember*>::Iterator psGuildInfo::GetMemberIterator ( ) [inline]

Gets an iterator for level.

Returns:
An iterator from levels

Definition at line 707 of file psguildinfo.h.

const csString& psGuildInfo::GetMOTD ( ) const [inline]

Gets the MOTD string.

Returns:
motd

Definition at line 588 of file psguildinfo.h.

const csString& psGuildInfo::GetName ( ) const [inline]

Simply returns this guild's name.

Returns:
name

Definition at line 478 of file psguildinfo.h.

const csString& psGuildInfo::GetWebPage ( ) const [inline]

Gets the web page.

Returns:
web_page

Definition at line 546 of file psguildinfo.h.

bool psGuildInfo::InsertNew ( )

Inserts a new guild into the DB.

Uses the name and founder currently stored to insert. Updates id with the ID received from the DB.

Returns:
True on success, false otherwise
bool psGuildInfo::IsGuildWarActive ( psGuildInfo other)

Checks if a guild war is active.

Loops through guild_war_with_id to see if the other guild's ID is present.

Parameters:
otherThe other guild to check if there is a guild war
Returns:
True if ther other guild is at war with this one
bool psGuildInfo::IsSecret ( ) const [inline]

Returns whether this guild is secret.

Returns:
secret

Definition at line 578 of file psguildinfo.h.

bool psGuildInfo::Load ( unsigned int  id)

Loads the guild based on the ID of the guild.

Loads the guild information from the database. If any of the information fails to load, false is immediately returned

Parameters:
idThe ID of the guild to load
Returns:
True if successful, false otherwise
bool psGuildInfo::Load ( const csString &  name)

Loads the guild based on the name of the guild.

Loads the guild information from the database. If any of the information fails to load, false is immediately returned

Parameters:
nameThe name of the guild to load
Returns:
True if successful, false otherwise
bool psGuildInfo::Load ( iResultRow &  row)

Loads guild information out of a DB result.

Extracts all of the guild information out of the result row. Also performs queries to get members, levels and wars.

Parameters:
rowThe result to extract information out of
Returns:
True if successful, false otherwise
bool psGuildInfo::MeetsMinimumRequirements ( ) const

Tests if the guild meets minimum requirements.

Currently only checks to see if members has at least GUILD_MIN_MEMBERS members.

Returns:
True if requirements are met, false otherwise
unsigned int psGuildInfo::MinutesUntilUserChangeName ( ) const

Gets how long before a user change their name.

Used to ensure a user can actually change their guild name. If a user has changed their name too recently this will return the number of minutes until the user can change their name, otherwise this will return 0. Uses lastNameChange and GUILD_NAME_CHANGE_LIMIT.

Returns:
0 if the user can change their name, minutes until they can otherwise
bool psGuildInfo::RemoveGuild ( )

Removes the guild from the DB.

Deletes everything associated with this guild from the DB. This includes guild wars, guild levels, updating characters and the guild itself. If the guild was in an alliance, the alliance object is also notified.

Returns:
True if all the deletions/updates succeeded, false otherwise
void psGuildInfo::RemoveGuildWar ( psGuildInfo other)

Removes a guild war.

Removes the other guild's ID from guild_war_with_id. DB is then updated through the command pump.

bool psGuildInfo::RemoveMember ( psGuildMember target)

Removes a member from this guild.

First validates that the member is actually a member of this guild. If it is then the DB is updated and this object removes the member from members.

Parameters:
targetThe member that is being remvoed
Returns:
True if everything went okay, false if the member wasn't part of this guild or if the DB update failed.
bool psGuildInfo::RenameLevel ( int  level,
const char *  levelname 
)

Renames a level within this guild.

First validates that the level exists in this guild. If it does then the DB is updated with the new guild level name and the corresponding psGuildLevel in levels is updated.

Parameters:
levelThe level to rename
levelnameThe name for the level
Returns:
False if the level did not exist or the DB update failed, true otherwise
void psGuildInfo::SaveBankMoney ( )

Performs the DB save for this bank's money.

If an error occurs it is simply written out of Error3

bool psGuildInfo::SetKarmaPoints ( int  n_karma_points)

Sets the karma points.

Updates DB and sets karma_points

Parameters:
n_karma_pointsNew value for karma points
Returns:
True if successful, false if DB update failed.
bool psGuildInfo::SetMaxMemberPoints ( int  points)

Changes the max amount of points a member may have for this guild.

Note:
points has an upper bound of MAX_GUILD_POINTS_LIMIT
Parameters:
pointsThe amount of points to set
Returns:
True if the DB update was successful, false otherwise
bool psGuildInfo::SetMemberNotes ( psGuildMember member,
const csString &  notes,
bool  isPublic 
)

Sets a member's notes for the guild.

Depending on if isPublic is true determines where psGuildMember::public_notes or psGuildMember::private_notes is updated for the member. DB is also updated.

Parameters:
memberThe member to adjust notes
notesThe new value for the notes
isPublicTrue for public notes, false for private
Returns:
True if successful, false if DB update failed.
bool psGuildInfo::SetMemberPoints ( psGuildMember member,
int  points 
)

Sets a member's points in the guild.

Checks if desired points is greater than max_guild_points. If it is false is returned. Otherwise the database and the member have their points updated.

Parameters:
memberThe member to adjust guild points
pointsThe amount of points to adjust to
Returns:
True if successful, false if points > max_guild_points or if the DB update failed.
bool psGuildInfo::SetMemberPrivilege ( psGuildMember member,
GUILD_PRIVILEGE  privilege,
bool  on 
)

Sets a privilege flag on a specific member.

First validates that the member does not already have the flag and that the level is valid. After that depending on whether the flag is being allowed or disallowed and if psGuildLevel::HasRights returns true determines whether the psGuildMember::removedPrivileges is updated or psGuildMember::privileges. Finally the DB is updated accordingly.

Parameters:
memberThe member that is changing privileges
privilegePrivilige to add or remove
onIf true the privilege is added, otherwise it is removed from the member
Returns:
True if successful, false if the level did not exist, the member already had the correct privileges or the DB update failed.
bool psGuildInfo::SetMOTD ( const csString &  str)

Sets the MOTD string.

Updates DB and sets motd.

Parameters:
strThe new value for the MOTD
Returns:
True if successful, false if DB update failed.
bool psGuildInfo::SetName ( csString  guildName)

Sets the name for the guild.

Updates the cached copy as well as the DB. Udates lastNameChange to the current time (in minutes)

Parameters:
guildNameThe desired new name
Returns:
True if successful, false if DB update failed.
bool psGuildInfo::SetPrivilege ( int  level,
GUILD_PRIVILEGE  privilege,
bool  on 
)

Sets a privilege flag on a level.

First validates that the level exists in this guild. If it does then the DB is updated with the new guild level privilege and the corresponding psGuildLevel in levels is updated.

Parameters:
levelThe level to update privileges
privilegeThe privilege to add or remove
onIf true the privilege is added, otherwise it is removed from the level
Returns:
False if the level did not exist or the DB update failed, true otherwise
bool psGuildInfo::SetSecret ( bool  secretGuild)

Sets whether the guild is secret or not.

If secret is already the requested value, true is returned. Otherwise secret and the DB are updated.

Parameters:
secretGuildThe new value to set secret to
Returns:
True if successful, false if DB update failed.
bool psGuildInfo::SetWebPage ( const csString &  web_page)

Sets the web page.

If current web_page is equal to parameter, true is returned. Otherwise web_page is updated and the DB is updated.

Parameters:
web_pageThe value to overwrite into web_page
Returns:
True if successful, false if DB update failed.
void psGuildInfo::UpdateLastLogin ( psCharacter player)

Updates the last login time for the player.

Updates the local information for the last login time of the player.

Note:
The DB is not updated because it is managed separately
Parameters:
playerThe player that has changed its last login time
bool psGuildInfo::UpdateMemberLevel ( psGuildMember target,
int  level 
)

Changes a member's level.

First validates that the level exists in this guild. If it does then the DB is updated with the new member level and the target's level is also updated.

Parameters:
targetThe member to update
levelThe level to update to
Returns:
False if the level did not exist or the DB update failed, true otherwise

Member Data Documentation

Alliance ID that this guild belongs to Default: 0(no alliance)

Definition at line 172 of file psguildinfo.h.

Money stored in the guild bank account.

Definition at line 169 of file psguildinfo.h.

PID psGuildInfo::founder [protected]

Character id for the founder of the guild.

Definition at line 164 of file psguildinfo.h.

IDs of guild that this guild is at war with.

Definition at line 175 of file psguildinfo.h.

int psGuildInfo::id [protected]

UID of the guild.

Definition at line 162 of file psguildinfo.h.

Guild's current karma points.

Definition at line 165 of file psguildinfo.h.

csTicks psGuildInfo::lastNameChange [protected]

Last time the name of this guild was changed Default: 0

Definition at line 171 of file psguildinfo.h.

All of the levels of the guild.

Definition at line 174 of file psguildinfo.h.

Maximum guild points obtainable in the guild.

Definition at line 170 of file psguildinfo.h.

All of the members of the guild.

Definition at line 173 of file psguildinfo.h.

csString psGuildInfo::motd [protected]

The guild's Message of the day.

Definition at line 167 of file psguildinfo.h.

csString psGuildInfo::name [protected]

Name of the guild.

Definition at line 163 of file psguildinfo.h.

bool psGuildInfo::secret [protected]

Flag if the guild is secret or not.

Definition at line 168 of file psguildinfo.h.

csString psGuildInfo::web_page [protected]

URL for the guild.

Definition at line 166 of file psguildinfo.h.


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