diff options
Diffstat (limited to 'src/account-server')
-rw-r--r-- | src/account-server/account.cpp | 4 | ||||
-rw-r--r-- | src/account-server/account.h | 2 | ||||
-rw-r--r-- | src/account-server/accounthandler.cpp | 8 | ||||
-rw-r--r-- | src/account-server/character.h | 20 | ||||
-rw-r--r-- | src/account-server/serverhandler.cpp | 8 | ||||
-rw-r--r-- | src/account-server/storage.cpp | 72 | ||||
-rw-r--r-- | src/account-server/storage.h | 10 |
7 files changed, 56 insertions, 68 deletions
diff --git a/src/account-server/account.cpp b/src/account-server/account.cpp index 0878c76..ed7c5df 100644 --- a/src/account-server/account.cpp +++ b/src/account-server/account.cpp @@ -43,13 +43,13 @@ void Account::setCharacters(const Characters &characters) void Account::addCharacter(Character *character) { - unsigned int slot = (unsigned int) character->getCharacterSlot(); + unsigned slot = (unsigned) character->getCharacterSlot(); assert(isSlotEmpty(slot)); mCharacters[slot] = character; } -void Account::delCharacter(unsigned int slot) +void Account::delCharacter(unsigned slot) { for (Characters::iterator iter = mCharacters.begin(), iter_end = mCharacters.end(); iter != iter_end; ++iter) diff --git a/src/account-server/account.h b/src/account-server/account.h index 98794fb..46693e8 100644 --- a/src/account-server/account.h +++ b/src/account-server/account.h @@ -158,7 +158,7 @@ class Account * * @param slot slot index of the character. */ - void delCharacter(unsigned int slot); + void delCharacter(unsigned slot); /** * Get all the characters. diff --git a/src/account-server/accounthandler.cpp b/src/account-server/accounthandler.cpp index 3590dbe..9901300 100644 --- a/src/account-server/accounthandler.cpp +++ b/src/account-server/accounthandler.cpp @@ -740,7 +740,7 @@ void AccountHandler::handleCharacterCreateMessage(AccountClient &client, // than <account_maxCharacters> characters. Characters &chars = acc->getCharacters(); if (slot < 1 || slot > mMaxCharacters - || !acc->isSlotEmpty((unsigned int) slot)) + || !acc->isSlotEmpty((unsigned) slot)) { reply.writeInt8(CREATE_INVALID_SLOT); client.send(reply); @@ -758,11 +758,11 @@ void AccountHandler::handleCharacterCreateMessage(AccountClient &client, // Customization of character's attributes... std::vector<int> attributes = std::vector<int>(mModifiableAttributes.size(), 0); - for (unsigned int i = 0; i < mModifiableAttributes.size(); ++i) + for (unsigned i = 0; i < mModifiableAttributes.size(); ++i) attributes[i] = msg.readInt16(); int totalAttributes = 0; - for (unsigned int i = 0; i < mModifiableAttributes.size(); ++i) + for (unsigned i = 0; i < mModifiableAttributes.size(); ++i) { // For good total attributes check. totalAttributes += attributes.at(i); @@ -790,7 +790,7 @@ void AccountHandler::handleCharacterCreateMessage(AccountClient &client, Character *newCharacter = new Character(name); // Set the initial attributes provided by the client - for (unsigned int i = 0; i < mModifiableAttributes.size(); ++i) + for (unsigned i = 0; i < mModifiableAttributes.size(); ++i) { newCharacter->mAttributes.insert( std::make_pair(mModifiableAttributes.at(i), attributes[i])); diff --git a/src/account-server/character.h b/src/account-server/character.h index 5e6bd3b..0b69739 100644 --- a/src/account-server/character.h +++ b/src/account-server/character.h @@ -55,22 +55,22 @@ struct SpecialValue : currentMana(0) {} - SpecialValue(unsigned int currentMana) + SpecialValue(unsigned currentMana) : currentMana(currentMana) {} - unsigned int currentMana; + unsigned currentMana; }; /** * Stores attributes by their id. */ -typedef std::map<unsigned int, AttributeValue> AttributeMap; +typedef std::map<unsigned, AttributeValue> AttributeMap; /** * Stores specials by their id. */ -typedef std::map<unsigned int, SpecialValue> SpecialMap; +typedef std::map<unsigned, SpecialValue> SpecialMap; class Character { @@ -87,10 +87,10 @@ class Character /** * Gets the slot of the character. */ - unsigned int getCharacterSlot() const + unsigned getCharacterSlot() const { return mCharacterSlot; } - void setCharacterSlot(unsigned int slot) + void setCharacterSlot(unsigned slot) { mCharacterSlot = slot; } /** Gets the account the character belongs to. */ @@ -148,10 +148,10 @@ class Character void setLevel(int level) { mLevel = level; } /** Sets the value of a base attribute of the character. */ - void setAttribute(unsigned int id, double value) + void setAttribute(unsigned id, double value) { mAttributes[id].base = value; } - void setModAttribute(unsigned int id, double value) + void setModAttribute(unsigned id, double value) { mAttributes[id].modified = value; } int getSkillSize() const @@ -277,7 +277,7 @@ class Character Possessions mPossessions; //!< All the possesions of the character. std::string mName; //!< Name of the character. int mDatabaseID; //!< Character database ID. - unsigned int mCharacterSlot; //!< Character slot. + unsigned mCharacterSlot; //!< Character slot. int mAccountID; //!< Account ID of the owner. Account *mAccount; //!< Account owning the character. Point mPos; //!< Position the being is at. @@ -307,6 +307,6 @@ class Character /** * Type definition for a list of Characters. */ -typedef std::map<unsigned int, Character* > Characters; +typedef std::map<unsigned, Character* > Characters; #endif diff --git a/src/account-server/serverhandler.cpp b/src/account-server/serverhandler.cpp index c938324..abdb575 100644 --- a/src/account-server/serverhandler.cpp +++ b/src/account-server/serverhandler.cpp @@ -185,7 +185,7 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg) const std::string password = msg.readString(); // checks the version of the remote item database with our local copy - unsigned int dbversion = msg.readInt32(); + unsigned dbversion = msg.readInt32(); LOG_INFO("Game server uses itemsdatabase with version " << dbversion); LOG_DEBUG("AGMSG_REGISTER_RESPONSE"); @@ -487,7 +487,7 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg) // send the post if valid if (post) { - for (unsigned int i = 0; i < post->getNumberOfLetters(); ++i) + for (unsigned i = 0; i < post->getNumberOfLetters(); ++i) { // get each letter, send the sender's name, // the contents and any attachments @@ -495,7 +495,7 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg) result.writeString(letter->getSender()->getName()); result.writeString(letter->getContents()); std::vector<InventoryItem> items = letter->getAttachments(); - for (unsigned int j = 0; j < items.size(); ++j) + for (unsigned j = 0; j < items.size(); ++j) { result.writeInt16(items[j].itemId); result.writeInt16(items[j].amount); @@ -546,7 +546,7 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg) LOG_DEBUG("Creating letter"); Letter *letter = new Letter(0, sender, receiver); letter->addText(contents); - for (unsigned int i = 0; i < items.size(); ++i) + for (unsigned i = 0; i < items.size(); ++i) { InventoryItem item; item.itemId = items[i].first; diff --git a/src/account-server/storage.cpp b/src/account-server/storage.cpp index 9426c88..f75e3ed 100644 --- a/src/account-server/storage.cpp +++ b/src/account-server/storage.cpp @@ -174,8 +174,6 @@ Account *Storage::getAccountBySQL() if (accountInfo.isEmpty()) return 0; - // Specialize the string_to functor to convert - // a string to an unsigned int. string_to< unsigned > toUint; unsigned id = toUint(accountInfo(0, 0)); @@ -265,8 +263,6 @@ void Storage::fixCharactersSlot(int accountId) if (charInfo.isEmpty()) return; - // Specialize the string_to functor to convert - // a string to an unsigned int. string_to< unsigned > toUint; std::map<unsigned, unsigned> slotsToUpdate; @@ -347,8 +343,6 @@ Character *Storage::getCharacterBySQL(Account *owner) { Character *character = 0; - // Specialize the string_to functor to convert - // a string to an unsigned int. string_to< unsigned > toUint; string_to< int > toInt; @@ -361,8 +355,6 @@ Character *Storage::getCharacterBySQL(Account *owner) if (charInfo.isEmpty()) return 0; - // Specialize the string_to functor to convert - // a string to an unsigned short. string_to< unsigned short > toUshort; string_to< double > toDouble; @@ -417,10 +409,10 @@ Character *Storage::getCharacterBySQL(Account *owner) const dal::RecordSet &attrInfo = mDb->execSql(s.str()); if (!attrInfo.isEmpty()) { - const unsigned int nRows = attrInfo.rows(); - for (unsigned int row = 0; row < nRows; ++row) + const unsigned nRows = attrInfo.rows(); + for (unsigned row = 0; row < nRows; ++row) { - unsigned int id = toUint(attrInfo(row, 0)); + unsigned id = toUint(attrInfo(row, 0)); character->setAttribute(id, toDouble(attrInfo(row, 1))); character->setModAttribute(id, toDouble(attrInfo(row, 2))); } @@ -437,10 +429,10 @@ Character *Storage::getCharacterBySQL(Account *owner) const dal::RecordSet &skillInfo = mDb->execSql(s.str()); if (!skillInfo.isEmpty()) { - const unsigned int nRows = skillInfo.rows(); - for (unsigned int row = 0; row < nRows; ++row) + const unsigned nRows = skillInfo.rows(); + for (unsigned row = 0; row < nRows; ++row) { - unsigned int id = toUint(skillInfo(row, 0)); + unsigned id = toUint(skillInfo(row, 0)); character->setExperience(id, toInt(skillInfo(row, 1))); } } @@ -455,8 +447,8 @@ Character *Storage::getCharacterBySQL(Account *owner) const dal::RecordSet &statusInfo = mDb->execSql(s.str()); if (!statusInfo.isEmpty()) { - const unsigned int nRows = statusInfo.rows(); - for (unsigned int row = 0; row < nRows; row++) + const unsigned nRows = statusInfo.rows(); + for (unsigned row = 0; row < nRows; row++) { character->applyStatusEffect( toUint(statusInfo(row, 0)), // Status Id @@ -472,8 +464,8 @@ Character *Storage::getCharacterBySQL(Account *owner) const dal::RecordSet &killsInfo = mDb->execSql(s.str()); if (!killsInfo.isEmpty()) { - const unsigned int nRows = killsInfo.rows(); - for (unsigned int row = 0; row < nRows; row++) + const unsigned nRows = killsInfo.rows(); + for (unsigned row = 0; row < nRows; row++) { character->setKillCount( toUint(killsInfo(row, 0)), // MonsterID @@ -490,8 +482,8 @@ Character *Storage::getCharacterBySQL(Account *owner) const dal::RecordSet &specialsInfo = mDb->execSql(s.str()); if (!specialsInfo.isEmpty()) { - const unsigned int nRows = specialsInfo.rows(); - for (unsigned int row = 0; row < nRows; row++) + const unsigned nRows = specialsInfo.rows(); + for (unsigned row = 0; row < nRows; row++) { character->giveSpecial(toUint(specialsInfo(row, 0)), toUint(specialsInfo(row, 1))); @@ -523,7 +515,7 @@ Character *Storage::getCharacterBySQL(Account *owner) { equipItem.itemId = toUint(equipInfo(k, 1)); equipItem.itemInstance = toUint(equipInfo(k, 2)); - equipData.insert(std::pair<unsigned int, EquipmentItem>( + equipData.insert(std::pair<unsigned, EquipmentItem>( toUint(equipInfo(k, 0)), equipItem)); } @@ -591,7 +583,7 @@ Character *Storage::getCharacter(const std::string &name) return 0; } -unsigned int Storage::getCharacterId(const std::string &name) +unsigned Storage::getCharacterId(const std::string &name) { std::ostringstream sql; sql << "SELECT id FROM " << CHARACTERS_TBL_NAME << " WHERE name = ?"; @@ -629,7 +621,7 @@ bool Storage::doesUserNameExist(const std::string &name) const dal::RecordSet &accountInfo = mDb->processSql(); std::istringstream ssStream(accountInfo(0, 0)); - unsigned int iReturn = 1; + unsigned iReturn = 1; ssStream >> iReturn; return iReturn != 0; } @@ -662,7 +654,7 @@ bool Storage::doesEmailAddressExist(const std::string &email) const dal::RecordSet &accountInfo = mDb->processSql(); std::istringstream ssStream(accountInfo(0, 0)); - unsigned int iReturn = 1; + unsigned iReturn = 1; ssStream >> iReturn; return iReturn != 0; } @@ -884,8 +876,8 @@ bool Storage::updateCharacter(Character *character) { sql.str(""); unsigned short slot = j->first; - unsigned int itemId = j->second.itemId; - unsigned int amount = j->second.amount; + unsigned itemId = j->second.itemId; + unsigned amount = j->second.amount; assert(itemId); sql << base << slot << ", " << itemId << ", " << amount << ");"; mDb->execSql(sql.str()); @@ -1084,8 +1076,6 @@ void Storage::flush(Account *account) // or updated in database. // Now, let's remove those who are no more in memory from database. - // Specialize the string_to functor to convert - // a string to an unsigned int. string_to<unsigned short> toUint; std::ostringstream sqlSelectNameIdCharactersTable; @@ -1099,7 +1089,7 @@ void Storage::flush(Account *account) // We compare chars from memory and those existing in db, // and delete those not in mem but existing in db. bool charFound; - for (unsigned int i = 0; i < charInMemInfo.rows(); ++i) // In database + for (unsigned i = 0; i < charInMemInfo.rows(); ++i) // In database { charFound = false; for (Characters::const_iterator it = characters.begin(), @@ -1118,7 +1108,7 @@ void Storage::flush(Account *account) // We store the id of the char to delete, // because as deleted, the RecordSet is also emptied, // and that creates an error. - unsigned int charId = toUint(charInMemInfo(i, 1)); + unsigned charId = toUint(charInMemInfo(i, 1)); delCharacter(charId); } } @@ -1235,7 +1225,7 @@ void Storage::updateExperience(int charId, int skillId, int skillValue) } } -void Storage::updateAttribute(int charId, unsigned int attrId, +void Storage::updateAttribute(int charId, unsigned attrId, double base, double mod) { try @@ -1349,7 +1339,7 @@ void Storage::addGuild(Guild *guild) mDb->bindValue(1, guild->getName()); const dal::RecordSet& guildInfo = mDb->processSql(); - string_to<unsigned int> toUint; + string_to<unsigned> toUint; unsigned id = toUint(guildInfo(0, 0)); guild->setId(id); } @@ -1531,7 +1521,7 @@ std::map<int, Guild*> Storage::getGuildList() return guilds; // Loop through every row in the table and assign it to a guild - for (unsigned int i = 0; i < guildInfo.rows(); ++i) + for (unsigned i = 0; i < guildInfo.rows(); ++i) { Guild* guild = new Guild(guildInfo(i,1)); guild->setId(toShort(guildInfo(i,0))); @@ -1550,7 +1540,7 @@ std::map<int, Guild*> Storage::getGuildList() const dal::RecordSet& memberInfo = mDb->execSql(memberSql.str()); std::list<std::pair<int, int> > members; - for (unsigned int j = 0; j < memberInfo.rows(); ++j) + for (unsigned j = 0; j < memberInfo.rows(); ++j) { members.push_back(std::pair<int, int>(toUint(memberInfo(j, 0)), toUint(memberInfo(j, 1)))); @@ -1677,7 +1667,7 @@ std::map<std::string, std::string> Storage::getAllWorldStateVars(int mapId) mDb->bindValue(1, mapId); const dal::RecordSet &results = mDb->processSql(); - for (unsigned int i = 0; i < results.rows(); ++i) + for (unsigned i = 0; i < results.rows(); ++i) { variables[results(i, 0)] = results(i, 1); } @@ -1998,8 +1988,6 @@ Post *Storage::getStoredPost(int playerId) { Post *p = new Post(); - // Specialize the string_to functor to convert - // a string to an unsigned int. string_to< unsigned > toUint; try @@ -2016,7 +2004,7 @@ Post *Storage::getStoredPost(int playerId) return p; } - for (unsigned int i = 0; i < post.rows(); i++ ) + for (unsigned i = 0; i < post.rows(); i++ ) { // Load sender and receiver Character *sender = getCharacter(toUint(post(i, 1)), 0); @@ -2248,10 +2236,10 @@ void Storage::addTransaction(const Transaction &trans) } } -std::vector<Transaction> Storage::getTransactions(unsigned int num) +std::vector<Transaction> Storage::getTransactions(unsigned num) { std::vector<Transaction> transactions; - string_to<unsigned int> toUint; + string_to<unsigned> toUint; try { @@ -2283,7 +2271,7 @@ std::vector<Transaction> Storage::getTransactions(unsigned int num) std::vector<Transaction> Storage::getTransactions(time_t date) { std::vector<Transaction> transactions; - string_to<unsigned int> toUint; + string_to<unsigned> toUint; try { @@ -2292,7 +2280,7 @@ std::vector<Transaction> Storage::getTransactions(time_t date) << date; const dal::RecordSet &rec = mDb->execSql(sql.str()); - for (unsigned int i = 0; i < rec.rows(); ++i) + for (unsigned i = 0; i < rec.rows(); ++i) { Transaction trans; trans.mCharacterId = toUint(rec(i, 1)); diff --git a/src/account-server/storage.h b/src/account-server/storage.h index b71be22..f58738f 100644 --- a/src/account-server/storage.h +++ b/src/account-server/storage.h @@ -101,7 +101,7 @@ class Storage * * @return the id of the character */ - unsigned int getCharacterId(const std::string &name); + unsigned getCharacterId(const std::string &name); /** * Add an account to the database. @@ -152,7 +152,7 @@ class Storage * @param base The base value of the attribute for this character * @param mod The cached modified value for this character. */ - void updateAttribute(int charId, unsigned int attrId, + void updateAttribute(int charId, unsigned attrId, double base, double mod); /** @@ -427,7 +427,7 @@ class Storage * * @return the database version number. */ - unsigned int getItemDatabaseVersion() const + unsigned getItemDatabaseVersion() const { return mItemDbVersion; } /** @@ -450,7 +450,7 @@ class Storage * * @return a vector of transactions. */ - std::vector<Transaction> getTransactions(unsigned int num); + std::vector<Transaction> getTransactions(unsigned num); /** * Retrieve all transactions since the given \a date. @@ -508,7 +508,7 @@ class Storage void syncDatabase(); dal::DataProvider *mDb; /**< the data provider */ - unsigned int mItemDbVersion; /**< Version of the item database. */ + unsigned mItemDbVersion; /**< Version of the item database. */ }; extern Storage *storage; |