Planeshift
|
Holds data for a guild. More...
#include <psguildinfo.h>
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. | |
psGuildMember * | FindLeader () const |
Finds the leader. | |
psGuildLevel * | FindLevel (int level) const |
Finds a level. | |
psGuildMember * | FindMember (PID char_id) const |
Finds a member. | |
psGuildMember * | FindMember (const char *name) const |
Finds a member. | |
int | GetAllianceID () const |
Gets the ID of the alliance this guild belongs to. | |
psMoney & | GetBankMoney () |
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 ¬es, 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< int > | guild_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. |
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.
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.
name | The name of the guild |
founder | The PID of the founder of the guild |
psGuildInfo::~psGuildInfo | ( | ) |
Basic deconstructor.
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.
other | The 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.
player | The character that is joining |
level | The level the character is joining at |
void psGuildInfo::AdjustMoney | ( | const psMoney & | money, |
bool | unused | ||
) | [inline] |
Override for BankManager.
money | Passed to other func |
unused | Unused |
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.
money | The 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.
player | The 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
player | The player that disconnected |
psGuildMember* psGuildInfo::FindLeader | ( | ) | const |
Finds the leader.
Searches through members for the member with level equal to MAX_GUILD_LEVEL.
psGuildLevel* psGuildInfo::FindLevel | ( | int | level | ) | const |
Finds a level.
Searches through level for the level equal to level.
level | The level to look for |
psGuildMember* psGuildInfo::FindMember | ( | const char * | name | ) | const |
psGuildMember* psGuildInfo::FindMember | ( | PID | char_id | ) | const |
Finds a member.
Searches through members for a member with a PID that matches char_id.
int psGuildInfo::GetAllianceID | ( | ) | const [inline] |
Gets the ID of the alliance this guild belongs to.
Definition at line 657 of file psguildinfo.h.
psMoney& psGuildInfo::GetBankMoney | ( | ) | [inline] |
Returns the amount of money this guild has in it's bank.
Definition at line 449 of file psguildinfo.h.
int psGuildInfo::GetID | ( | ) | const [inline] |
int psGuildInfo::GetKarmaPoints | ( | ) | const [inline] |
csArray<psGuildLevel*>::ConstIterator psGuildInfo::GetLevelIterator | ( | ) | const [inline] |
Gets a const iterator for levels.
Definition at line 677 of file psguildinfo.h.
csArray<psGuildLevel*>::Iterator psGuildInfo::GetLevelIterator | ( | ) | [inline] |
Gets an iterator for level.
Definition at line 687 of file psguildinfo.h.
int psGuildInfo::GetMaxMemberPoints | ( | ) | const [inline] |
Simply returns the max member points allowed for this guild.
Definition at line 497 of file psguildinfo.h.
size_t psGuildInfo::GetMemberCount | ( | ) | const [inline] |
csArray<psGuildMember*>::ConstIterator psGuildInfo::GetMemberIterator | ( | ) | const [inline] |
Gets a const iterator for levels.
Definition at line 697 of file psguildinfo.h.
csArray<psGuildMember*>::Iterator psGuildInfo::GetMemberIterator | ( | ) | [inline] |
Gets an iterator for level.
Definition at line 707 of file psguildinfo.h.
const csString& psGuildInfo::GetMOTD | ( | ) | const [inline] |
const csString& psGuildInfo::GetName | ( | ) | const [inline] |
const csString& psGuildInfo::GetWebPage | ( | ) | const [inline] |
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.
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.
other | The other guild to check if there is a guild war |
bool psGuildInfo::IsSecret | ( | ) | const [inline] |
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
id | The ID of the guild to load |
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
name | The name of the guild to load |
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.
row | The result to extract information out of |
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.
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.
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.
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.
target | The member that is being remvoed |
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.
level | The level to rename |
levelname | The name for the level |
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
n_karma_points | New value for karma points |
bool psGuildInfo::SetMaxMemberPoints | ( | int | points | ) |
Changes the max amount of points a member may have for this guild.
points | The amount of points to set |
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.
member | The member to adjust notes |
notes | The new value for the notes |
isPublic | True for public notes, false for private |
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.
member | The member to adjust guild points |
points | The amount of points to adjust to |
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.
member | The member that is changing privileges |
privilege | Privilige to add or remove |
on | If true the privilege is added, otherwise it is removed from the member |
bool psGuildInfo::SetMOTD | ( | const csString & | str | ) |
Sets the MOTD string.
Updates DB and sets motd.
str | The new value for the MOTD |
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)
guildName | The desired new name |
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.
level | The level to update privileges |
privilege | The privilege to add or remove |
on | If true the privilege is added, otherwise it is removed from the level |
bool psGuildInfo::SetSecret | ( | bool | secretGuild | ) |
bool psGuildInfo::SetWebPage | ( | const csString & | web_page | ) |
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.
player | The 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.
target | The member to update |
level | The level to update to |
int psGuildInfo::alliance [protected] |
Alliance ID that this guild belongs to Default: 0(no alliance)
Definition at line 172 of file psguildinfo.h.
psMoney psGuildInfo::bankMoney [protected] |
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.
csArray<int> psGuildInfo::guild_war_with_id [protected] |
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.
int psGuildInfo::karma_points [protected] |
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.
csArray<psGuildLevel*> psGuildInfo::levels [protected] |
All of the levels of the guild.
Definition at line 174 of file psguildinfo.h.
int psGuildInfo::max_guild_points [protected] |
Maximum guild points obtainable in the guild.
Definition at line 170 of file psguildinfo.h.
csArray<psGuildMember*> psGuildInfo::members [protected] |
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.