#include <dalstorage.hpp>
Public Member Functions | |
| DALStorage () | |
| Constructor. | |
| ~DALStorage () | |
| Destructor. | |
| void | open () |
| Connect to the database and initialize it if necessary. | |
| void | close () |
| Disconnect from the database. | |
| Account * | getAccount (const std::string &userName) |
| Get an account by user name. | |
| Account * | getAccount (int accountID) |
| Get an account by ID. | |
| Character * | getCharacter (int id, Account *owner) |
| Gets a character by database ID. | |
| Character * | getCharacter (const std::string &name) |
| Gets a character by character name. | |
| void | addAccount (Account *account) |
| Add a new account. | |
| void | delAccount (Account *account) |
| Delete an account. | |
| void | updateLastLogin (const Account *account) |
| Update the date and time of the last login. | |
| void | updateCharacterPoints (const int CharId, const int CharPoints, const int CorrPoints, const int AttribId, const int AttribValue) |
| Write a modification message about Character points to the database. | |
| void | updateExperience (const int CharId, const int SkillId, const int SkillValue) |
| Write a modification message about character skills to the database. | |
| void | banCharacter (int id, int duration) |
| Sets a ban on an account (hence on all its characters). | |
| void | delCharacter (int charId, bool startTransaction) const |
| Delete a character in the database. | |
| void | delCharacter (Character *character, bool startTransaction) const |
| Delete a character in the database. | |
| void | checkBannedAccounts () |
| Removes expired bans from accounts. | |
| bool | doesUserNameExist (const std::string &name) |
| Tells if the user name already exists. | |
| bool | doesEmailAddressExist (const std::string &email) |
| Tells if the email address already exists. | |
| bool | doesCharacterNameExist (const std::string &name) |
| Tells if the character name already exists. | |
| bool | updateCharacter (Character *ptr, bool startTransaction=true) |
| Updates the data for a single character, does not update the owning account or the characters name. | |
| void | flushSkill (const Character *const character, const int skill_id) |
| Save changes of a skill to the database permanently. | |
| void | addGuild (Guild *guild) |
| Add a new guild. | |
| void | removeGuild (Guild *guild) |
| Delete a guild. | |
| void | addGuildMember (int guild_id, int memberId) |
| Add member to guild. | |
| void | removeGuildMember (int guildId, int memberId) |
| Remove member from guild. | |
| void | setMemberRights (int guildId, int memberId, int rights) |
| Save guild member rights. | |
| std::list< Guild * > | getGuildList () |
| Get guild list. | |
| void | flushAll () |
| Save changes to the database permanently. | |
| void | flush (Account *) |
| Update an account from the database. | |
| std::string | getQuestVar (int id, const std::string &) |
| Gets the value of a quest variable. | |
| void | setQuestVar (int id, const std::string &, const std::string &) |
| Sets the value of a quest variable. | |
| std::string | getWorldStateVar (const std::string &name, int map_id=-1) |
| Gets the string value of a map specific world state variable. | |
| void | setWorldStateVar (const std::string &name, const std::string &value) |
| Sets the value of a world state variable. | |
| void | setWorldStateVar (const std::string &name, int map_id, const std::string &value) |
| Sets the value of a world state variable of a specific map. | |
| void | setAccountLevel (int id, int level) |
| Set the level on an account. | |
| void | setPlayerLevel (int id, int level) |
| Set the level on a character. | |
| void | storeLetter (Letter *letter) |
| Store letter. | |
| Post * | getStoredPost (int playerId) |
| Retrieve post. | |
| void | deletePost (Letter *letter) |
| Delete a letter from the database. | |
| void | addAuctionItem (unsigned int itemId, int playerId, unsigned int gold) |
| Add item to auction. | |
| unsigned int | getItemDatabaseVersion (void) const |
| Gets the version of the local item database. | |
| void | setOnlineStatus (int charId, bool online) |
| Sets the status of a character to online (true) or offline (false). | |
| void | addTransaction (const Transaction &trans) |
| Store a transaction. | |
| std::vector< Transaction > | getTransactions (unsigned int num) |
| Retrieve a series of transactions Either based on number of transactions last saved or by all transactions since a date. | |
| std::vector< Transaction > | getTransactions (time_t date) |
Definition at line 42 of file dalstorage.hpp.
| Account * DALStorage::getAccount | ( | const std::string & | userName | ) |
Get an account by user name.
| userName | the owner of the account. |
Definition at line 204 of file dalstorage.cpp.
| Account * DALStorage::getAccount | ( | int | accountID | ) |
Get an account by ID.
| accountID | the ID of the account. |
Definition at line 214 of file dalstorage.cpp.
Gets a character by database ID.
| id | the ID of the character. | |
| owner | the account the character is in. |
Definition at line 366 of file dalstorage.cpp.
Referenced by getGuildList(), getStoredPost(), ServerHandler::processMessage(), ChatHandler::sendGuildListUpdate(), and ChatHandler::tokenMatched().
| Character * DALStorage::getCharacter | ( | const std::string & | name | ) |
Gets a character by character name.
| name | of the character |
Definition at line 373 of file dalstorage.cpp.
| void DALStorage::addAccount | ( | Account * | account | ) |
Add a new account.
Add an account to the database.
| account | the new account. |
Definition at line 651 of file dalstorage.cpp.
References dal::DataProvider::beginTransaction(), dal::DataProvider::commitTransaction(), dal::DataProvider::execSql(), Account::getCharacters(), Account::getEmail(), dal::DataProvider::getLastId(), Account::getLastLogin(), Account::getLevel(), Account::getName(), Account::getPassword(), Account::getRegistrationDate(), dal::DataProvider::rollbackTransaction(), Account::setID(), and dal::DbException::what().
| void DALStorage::delAccount | ( | Account * | account | ) |
Delete an account.
Delete an account and its associated data from the database.
| account | the account to delete. |
Definition at line 825 of file dalstorage.cpp.
References dal::DataProvider::execSql(), flush(), Account::getID(), and Account::setCharacters().
| void DALStorage::updateLastLogin | ( | const Account * | account | ) |
Update the date and time of the last login.
| account | the account that recently logged in. |
Definition at line 840 of file dalstorage.cpp.
References dal::DataProvider::execSql(), Account::getID(), and Account::getLastLogin().
| void DALStorage::updateCharacterPoints | ( | const int | CharId, | |
| const int | CharPoints, | |||
| const int | CorrPoints, | |||
| const int | AttribId, | |||
| const int | AttribValue | |||
| ) |
Write a modification message about Character points to the database.
| CharId | ID of the character | |
| CharPoints | Number of character points left for the character | |
| CorrPoints | Number of correction points left for the character | |
| AttribId | ID of the modified attribute | |
| AttribValue | New value of the modified attribute |
Definition at line 849 of file dalstorage.cpp.
References dal::DataProvider::execSql().
| void DALStorage::updateExperience | ( | const int | CharId, | |
| const int | SkillId, | |||
| const int | SkillValue | |||
| ) |
Write a modification message about character skills to the database.
| CharId | ID of the character | |
| SkillId | ID of the skill | |
| SkillValue | new skill points |
Definition at line 872 of file dalstorage.cpp.
References dal::DataProvider::execSql(), dal::DataProvider::getModifiedRows(), and dal::DbException::what().
Referenced by flush(), flushSkill(), and updateCharacter().
| void DALStorage::banCharacter | ( | int | id, | |
| int | duration | |||
| ) |
Sets a ban on an account (hence on all its characters).
| id | character identifier. | |
| duration | duration in minutes. |
Definition at line 1232 of file dalstorage.cpp.
References dal::DataProvider::execSql(), dal::RecordSet::isEmpty(), and dal::DbException::what().
Referenced by ServerHandler::processMessage().
| void DALStorage::delCharacter | ( | int | charId, | |
| bool | startTransaction = true | |||
| ) | const |
Delete a character in the database.
| charId | character identifier. | |
| startTransaction | indicates wheter the function should run in its own transaction or is called inline of another transaction |
Definition at line 1259 of file dalstorage.cpp.
References dal::DataProvider::beginTransaction(), dal::DataProvider::commitTransaction(), dal::DataProvider::execSql(), dal::DataProvider::rollbackTransaction(), and dal::DbException::what().
Referenced by delCharacter(), and flush().
| void DALStorage::delCharacter | ( | Character * | character, | |
| bool | startTransaction = true | |||
| ) | const |
Delete a character in the database.
The object itself i not touched by this function!
| character | character object. | |
| startTransaction | indicates wheter the function should run in its own transaction or is called inline of another transaction |
Definition at line 1325 of file dalstorage.cpp.
References delCharacter(), and Character::getDatabaseID().
| bool DALStorage::doesUserNameExist | ( | const std::string & | name | ) |
Tells if the user name already exists.
Definition at line 415 of file dalstorage.cpp.
References dal::DataProvider::execSql().
| bool DALStorage::doesEmailAddressExist | ( | const std::string & | ) |
Tells if the email address already exists.
true if the email address exists.
Definition at line 439 of file dalstorage.cpp.
References dal::DataProvider::execSql().
| bool DALStorage::doesCharacterNameExist | ( | const std::string & | name | ) |
Tells if the character name already exists.
Tells if the character's name already exists.
true if character's name exists.
Definition at line 463 of file dalstorage.cpp.
References dal::DataProvider::execSql().
| bool DALStorage::updateCharacter | ( | Character * | ptr, | |
| bool | startTransaction = true | |||
| ) |
Updates the data for a single character, does not update the owning account or the characters name.
Primary usage should be storing characterdata received from a game server. returns true if succefull, false otherwise.
| ptr | Character to store values in the database. | |
| startTransaction | set to false if this method is called as nested transaction. |
Character's skills
Character's inventory
Definition at line 484 of file dalstorage.cpp.
References dal::DataProvider::beginTransaction(), dal::DataProvider::commitTransaction(), Possessions::equipment, dal::DataProvider::execSql(), Character::getAttribute(), Character::getCharacterPoints(), Character::getCorrectionPoints(), Character::getDatabaseID(), Character::getExperience(), Character::getGender(), Character::getHairColor(), Character::getHairStyle(), Character::getLevel(), Character::getMapId(), Character::getPosition(), Character::getPossessions(), Possessions::inventory, Possessions::money, dal::DataProvider::rollbackTransaction(), updateExperience(), dal::DbException::what(), Point::x, and Point::y.
Referenced by flush(), and ServerHandler::processMessage().
| void DALStorage::flushSkill | ( | const Character *const | character, | |
| const int | skill_id | |||
| ) |
Save changes of a skill to the database permanently.
| character | Character thats skill has changed. | |
| skill_id | Identifier of the changed skill. |
| dbl::DbSqlQueryExecFailure. |
Definition at line 641 of file dalstorage.cpp.
References Character::getDatabaseID(), Character::getExperience(), and updateExperience().
| void DALStorage::addGuild | ( | Guild * | guild | ) |
Add a new guild.
Add a guild.
Definition at line 924 of file dalstorage.cpp.
References dal::DataProvider::execSql(), Guild::getName(), and Guild::setId().
Referenced by GuildManager::createGuild().
| void DALStorage::removeGuild | ( | Guild * | guild | ) |
Delete a guild.
Remove guild.
Definition at line 945 of file dalstorage.cpp.
References dal::DataProvider::execSql(), and Guild::getId().
Referenced by GuildManager::removeGuild().
| void DALStorage::addGuildMember | ( | int | guild_id, | |
| int | memberId | |||
| ) |
Add member to guild.
add a member to a guild
Definition at line 957 of file dalstorage.cpp.
References dal::DataProvider::execSql(), and dal::DbException::what().
Referenced by GuildManager::addGuildMember().
| void DALStorage::removeGuildMember | ( | int | guildId, | |
| int | memberId | |||
| ) |
Remove member from guild.
remove a member from a guild
Definition at line 980 of file dalstorage.cpp.
References dal::DataProvider::execSql(), and dal::DbException::what().
Referenced by GuildManager::removeGuildMember().
| std::list< Guild * > DALStorage::getGuildList | ( | ) |
Get guild list.
get a list of guilds
Get the guilds stored in the db.
Add the members to the guilds.
Definition at line 1021 of file dalstorage.cpp.
References Character::addGuild(), dal::DataProvider::execSql(), getCharacter(), Character::getDatabaseID(), dal::RecordSet::isEmpty(), dal::RecordSet::rows(), Guild::setId(), and dal::DbException::what().
Referenced by GuildManager::GuildManager().
| void DALStorage::flushAll | ( | ) |
Save changes to the database permanently.
| dal::DbSqlQueryExecFailure. |
| std::string DALStorage::getWorldStateVar | ( | const std::string & | name, | |
| int | map_id = -1 | |||
| ) |
Gets the string value of a map specific world state variable.
| name | Name of the requested world-state variable. | |
| map_id | Id of the specific map. |
Definition at line 1110 of file dalstorage.cpp.
References dal::DataProvider::execSql(), dal::RecordSet::isEmpty(), and dal::DbException::what().
Referenced by open().
| void DALStorage::setWorldStateVar | ( | const std::string & | name, | |
| const std::string & | value | |||
| ) |
Sets the value of a world state variable.
| name | Name of the world-state vairable. | |
| value | New value of the world-state variable. |
Definition at line 1138 of file dalstorage.cpp.
| void DALStorage::setWorldStateVar | ( | const std::string & | name, | |
| int | map_id, | |||
| const std::string & | value | |||
| ) |
Sets the value of a world state variable of a specific map.
| name | Name of the world-state vairable. | |
| map_id | ID of the specific map | |
| value | New value of the world-state variable. |
Definition at line 1143 of file dalstorage.cpp.
References dal::DataProvider::execSql(), dal::DataProvider::getModifiedRows(), and dal::DbException::what().
| void DALStorage::setAccountLevel | ( | int | id, | |
| int | level | |||
| ) |
Set the level on an account.
| id | The id of the account | |
| level | The level to set for the account |
Definition at line 1349 of file dalstorage.cpp.
References dal::DataProvider::execSql(), and dal::DbException::what().
Referenced by ServerHandler::processMessage().
| void DALStorage::setPlayerLevel | ( | int | id, | |
| int | level | |||
| ) |
Set the level on a character.
| id | The id of the character | |
| level | The level to set for the character |
Definition at line 1365 of file dalstorage.cpp.
References dal::DataProvider::execSql(), and dal::DbException::what().
Referenced by ServerHandler::processMessage().
| void DALStorage::storeLetter | ( | Letter * | letter | ) |
Store letter.
| letter | The letter to store |
Definition at line 1381 of file dalstorage.cpp.
References dal::DataProvider::execSql(), dal::DataProvider::getLastId(), and dal::DataProvider::getModifiedRows().
| Post * DALStorage::getStoredPost | ( | int | playerId | ) |
Retrieve post.
| playerId | The id of the character requesting his post |
Definition at line 1427 of file dalstorage.cpp.
References dal::DataProvider::execSql(), getCharacter(), dal::RecordSet::isEmpty(), and dal::RecordSet::rows().
| void DALStorage::deletePost | ( | Letter * | letter | ) |
Delete a letter from the database.
| letter | The letter to delete. |
Definition at line 1467 of file dalstorage.cpp.
References dal::DataProvider::beginTransaction(), dal::DataProvider::commitTransaction(), dal::DataProvider::execSql(), dal::DataProvider::rollbackTransaction(), and dal::DbException::what().
| void DALStorage::addAuctionItem | ( | unsigned int | itemId, | |
| int | playerId, | |||
| unsigned int | gold | |||
| ) |
Add item to auction.
| itemId | The id of the item for auction | |
| player | The player who put the item up for auction | |
| gold | The amount of money to buy it |
| unsigned int DALStorage::getItemDatabaseVersion | ( | void | ) | const [inline] |
Gets the version of the local item database.
Definition at line 360 of file dalstorage.hpp.
Referenced by ServerHandler::processMessage().
| void DALStorage::setOnlineStatus | ( | int | charId, | |
| bool | online | |||
| ) |
Sets the status of a character to online (true) or offline (false).
| charId | Id of the character. | |
| online | True to mark the character as being online. |
Definition at line 1595 of file dalstorage.cpp.
References dal::DataProvider::execSql(), and dal::DbException::what().
1.5.5