diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-08-27 15:53:10 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-08-27 15:53:10 +0000 |
commit | 2922e40cae58bbddf629733a9a7865f2a00ed9e1 (patch) | |
tree | 0ab7a3b6b7c09a180ece61daed219e914f1534f5 /src/account-server | |
parent | 518168ad7859ba214a79c48459e8053391339d68 (diff) | |
download | manaserv-2922e40cae58bbddf629733a9a7865f2a00ed9e1.tar.gz manaserv-2922e40cae58bbddf629733a9a7865f2a00ed9e1.tar.bz2 manaserv-2922e40cae58bbddf629733a9a7865f2a00ed9e1.tar.xz manaserv-2922e40cae58bbddf629733a9a7865f2a00ed9e1.zip |
Added support for user commands. Implemented "warp" and "item".
Diffstat (limited to 'src/account-server')
-rw-r--r-- | src/account-server/account.cpp | 94 | ||||
-rw-r--r-- | src/account-server/account.hpp | 49 | ||||
-rw-r--r-- | src/account-server/characterdata.cpp | 11 | ||||
-rw-r--r-- | src/account-server/characterdata.hpp | 22 |
4 files changed, 54 insertions, 122 deletions
diff --git a/src/account-server/account.cpp b/src/account-server/account.cpp index 6ca75535..fb4e0572 100644 --- a/src/account-server/account.cpp +++ b/src/account-server/account.cpp @@ -34,11 +34,11 @@ Account::Account(const std::string& name, const std::string& password, const std::string& email, int id) - : mID(id), - mName(name), + : mName(name), mPassword(password), mEmail(email), mCharacters(), + mID(id), mLevel(AL_NORMAL) { // NOOP @@ -73,87 +73,6 @@ Account::~Account() /** - * Set the user name. - */ -void -Account::setName(const std::string& name) -{ - mName = name; -} - - -/** - * Get the user name. - */ -const std::string& -Account::getName(void) const -{ - return mName; -} - - -/** - * Set the user password. - */ -void -Account::setPassword(const std::string& password) -{ - mPassword = password; -} - - -/** - * Get the user password. - */ -const std::string -Account::getPassword(void) const -{ - return mPassword; -} - - -/** - * Set the user email address. - */ -void -Account::setEmail(const std::string& email) -{ - // Email validity is checked by Accounthandler - mEmail = email; -} - - -/** - * Get the user email address. - */ -const std::string& -Account::getEmail(void) const -{ - return mEmail; -} - - -/** - * Set the account level. - */ -void -Account::setLevel(AccountLevel level) -{ - mLevel = level; -} - - -/** - * Get the account level. - */ -AccountLevel -Account::getLevel(void) const -{ - return mLevel; -} - - -/** * Set the characters. */ void @@ -191,15 +110,6 @@ bool Account::delCharacter(std::string const &name) /** - * Get all the characters. - */ -Characters &Account::getCharacters() -{ - return mCharacters; -} - - -/** * Get a character by name. */ CharacterPtr Account::getCharacter(const std::string& name) diff --git a/src/account-server/account.hpp b/src/account-server/account.hpp index 50129579..6b1cf8a2 100644 --- a/src/account-server/account.hpp +++ b/src/account-server/account.hpp @@ -25,7 +25,6 @@ #include <string> -#include "defines.h" #include "account-server/characterdata.hpp" #include "utils/countedptr.h" @@ -85,8 +84,8 @@ class Account * * @param name the user name. */ - void - setName(const std::string& name); + void setName(std::string const &name) + { mName = name; } /** @@ -94,8 +93,8 @@ class Account * * @return the user name. */ - const std::string& - getName() const; + std::string const &getName() const + { return mName; } /** @@ -103,8 +102,8 @@ class Account * * @param password the user password. */ - void - setPassword(const std::string& password); + void setPassword(std::string const &password) + { mPassword = password; } /** @@ -112,8 +111,8 @@ class Account * * @return the user password. */ - const std::string - getPassword(void) const; + std::string const &getPassword() const + { return mPassword; } /** @@ -121,8 +120,8 @@ class Account * * @param email the user email address. */ - void - setEmail(const std::string& email); + void setEmail(std::string const &email) + { mEmail = email; } /** @@ -130,8 +129,8 @@ class Account * * @return the user email address. */ - const std::string& - getEmail(void) const; + std::string const &getEmail() const + { return mEmail; } /** @@ -139,8 +138,8 @@ class Account * * @param level the new level. */ - void - setLevel(AccountLevel level); + void setLevel(int level) + { mLevel = level; } /** @@ -148,8 +147,8 @@ class Account * * @return the account level. */ - AccountLevel - getLevel() const; + int getLevel() const + { return mLevel; } /** @@ -183,8 +182,16 @@ class Account * * @return all the characters. */ - Characters& - getCharacters(); + Characters &getCharacters() + { return mCharacters; } + + /** + * Get all the characters. + * + * @return all the characters. + */ + Characters const &getCharacters() const + { return mCharacters; } /** * Get a character by name. @@ -215,12 +222,12 @@ class Account private: - int mID; /**< unique id */ std::string mName; /**< user name */ std::string mPassword; /**< user password (encrypted) */ std::string mEmail; /**< user email address */ Characters mCharacters; /**< Character data */ - AccountLevel mLevel; /**< account level */ + int mID; /**< unique id */ + unsigned char mLevel; /**< account level */ }; diff --git a/src/account-server/characterdata.cpp b/src/account-server/characterdata.cpp index d82100d5..0e140e3c 100644 --- a/src/account-server/characterdata.cpp +++ b/src/account-server/characterdata.cpp @@ -22,9 +22,11 @@ #include "account-server/characterdata.hpp" +#include "account-server/dalstorage.hpp" + CharacterData::CharacterData(std::string const &name, int id): - mDatabaseID(id), mAccountID(-1), mName(name), mGender(0), mHairStyle(0), - mHairColor(0), mLevel(0), mMapId(0), mPos(0,0) + mName(name), mDatabaseID(id), mAccountID(-1), mPos(0,0), mMapId(0), + mGender(0), mHairStyle(0), mHairColor(0), mLevel(0) { for (int i = 0; i < CHAR_ATTR_NB; ++i) { @@ -32,3 +34,8 @@ CharacterData::CharacterData(std::string const &name, int id): } } +int CharacterData::getAccountLevel() const +{ + AccountPtr acc = Storage::instance("tmw").getAccountByID(mAccountID); + return acc->getLevel(); +} diff --git a/src/account-server/characterdata.hpp b/src/account-server/characterdata.hpp index 499b5bef..b1b19d3a 100644 --- a/src/account-server/characterdata.hpp +++ b/src/account-server/characterdata.hpp @@ -91,6 +91,13 @@ class CharacterData void setHairColor(int color) { mHairColor = color; } + /** Gets the account level of the user. */ + int getAccountLevel() const; + + /** Sets the account level of the user. */ + void setAccountLevel(int) + { /* Ignored as we do not trust game servers that much. */ } + /** Gets the level of the character. */ int getLevel() const { return mLevel; } @@ -146,19 +153,20 @@ class CharacterData CharacterData(CharacterData const &); CharacterData &operator=(CharacterData const &); + Possessions mPossessions; //!< All the possesions of the character. + std::string mName; //!< Name of the character. int mDatabaseID; //!< Character database ID. //!< (-1) if not set yet. int mAccountID; //!< Account ID of the account the character //!< belongs to. (-1) if not set yet. - std::string mName; //!< Name of the character. - unsigned char mGender; //!< Gender of the being. - unsigned char mHairStyle; //!< Hair Style of the being. - unsigned char mHairColor; //!< Hair Color of the being. - unsigned char mLevel; //!< Level of the being. + Point mPos; //!< Position the being is at. unsigned short mAttributes[CHAR_ATTR_NB]; //!< Attributes. unsigned short mMapId; //!< Map the being is on. - Point mPos; //!< Position the being is at. - Possessions mPossessions; //!< All the possesions of the character. + unsigned char mGender; //!< Gender of the being. + unsigned char mHairStyle; //!< Hair style of the being. + unsigned char mHairColor; //!< Hair color of the being. + unsigned char mLevel; //!< Level of the being. + std::vector<std::string> mGuilds; //!< All the guilds the player //!< belongs to. }; |