diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2012-07-30 21:31:32 +0200 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2012-07-30 21:33:14 +0200 |
commit | d9d5ebbcd623e97f9b13a9c1046b08be34e1302e (patch) | |
tree | 2e82346ea818ab0ae4ab0109a5eb62d783831fb5 /src | |
parent | 86e4671b292a30413f99c1bb00046d743b258706 (diff) | |
download | manaserv-d9d5ebbcd623e97f9b13a9c1046b08be34e1302e.tar.gz manaserv-d9d5ebbcd623e97f9b13a9c1046b08be34e1302e.tar.bz2 manaserv-d9d5ebbcd623e97f9b13a9c1046b08be34e1302e.tar.xz manaserv-d9d5ebbcd623e97f9b13a9c1046b08be34e1302e.zip |
Hacked away the selection of attributes at char creation
All attributes are set to 5 for now
Diffstat (limited to 'src')
-rw-r--r-- | src/account-server/accounthandler.cpp | 101 |
1 files changed, 36 insertions, 65 deletions
diff --git a/src/account-server/accounthandler.cpp b/src/account-server/accounthandler.cpp index 3590dbeb..a7b43e2a 100644 --- a/src/account-server/accounthandler.cpp +++ b/src/account-server/accounthandler.cpp @@ -692,8 +692,7 @@ void AccountHandler::handleCharacterCreateMessage(AccountClient &client, // Avoid creation of character from old clients. int slot = -1; - if (msg.getUnreadLength() > 7) - slot = msg.readInt8(); + slot = msg.readInt8(); MessageOut reply(APMSG_CHAR_CREATE_RESPONSE); @@ -759,76 +758,48 @@ 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) - attributes[i] = msg.readInt16(); + attributes[i] = 5; - int totalAttributes = 0; + Character *newCharacter = new Character(name); + + // Set the initial attributes provided by the client for (unsigned int i = 0; i < mModifiableAttributes.size(); ++i) { - // For good total attributes check. - totalAttributes += attributes.at(i); - - // For checking if all stats are >= min and <= max. - if (attributes.at(i) < mAttributeMinimum - || attributes.at(i) > mAttributeMaximum) - { - reply.writeInt8(CREATE_ATTRIBUTES_OUT_OF_RANGE); - client.send(reply); - return; - } + newCharacter->mAttributes.insert( + std::make_pair(mModifiableAttributes.at(i), attributes[i])); } - if (totalAttributes > mStartingPoints) - { - reply.writeInt8(CREATE_ATTRIBUTES_TOO_HIGH); - } - else if (totalAttributes < mStartingPoints) - { - reply.writeInt8(CREATE_ATTRIBUTES_TOO_LOW); - } - else - { - Character *newCharacter = new Character(name); + newCharacter->mAttributes.insert(mDefaultAttributes.begin(), + mDefaultAttributes.end()); + newCharacter->setAccount(acc); + newCharacter->setCharacterSlot(slot); + newCharacter->setGender(gender); + newCharacter->setHairStyle(hairStyle); + newCharacter->setHairColor(hairColor); + newCharacter->setMapId(Configuration::getValue("char_startMap", 1)); + Point startingPos(Configuration::getValue("char_startX", 1024), + Configuration::getValue("char_startY", 1024)); + newCharacter->setPosition(startingPos); + acc->addCharacter(newCharacter); + + LOG_INFO("Character " << name << " was created for " + << acc->getName() << "'s account."); + + storage->flush(acc); // flush changes + + // log transaction + Transaction trans; + trans.mCharacterId = newCharacter->getDatabaseID(); + trans.mAction = TRANS_CHAR_CREATE; + trans.mMessage = acc->getName() + " created character "; + trans.mMessage.append("called " + name); + storage->addTransaction(trans); - // Set the initial attributes provided by the client - for (unsigned int i = 0; i < mModifiableAttributes.size(); ++i) - { - newCharacter->mAttributes.insert( - std::make_pair(mModifiableAttributes.at(i), attributes[i])); - } - - newCharacter->mAttributes.insert(mDefaultAttributes.begin(), - mDefaultAttributes.end()); - newCharacter->setAccount(acc); - newCharacter->setCharacterSlot(slot); - newCharacter->setGender(gender); - newCharacter->setHairStyle(hairStyle); - newCharacter->setHairColor(hairColor); - newCharacter->setMapId(Configuration::getValue("char_startMap", 1)); - Point startingPos(Configuration::getValue("char_startX", 1024), - Configuration::getValue("char_startY", 1024)); - newCharacter->setPosition(startingPos); - acc->addCharacter(newCharacter); - - LOG_INFO("Character " << name << " was created for " - << acc->getName() << "'s account."); - - storage->flush(acc); // flush changes - - // log transaction - Transaction trans; - trans.mCharacterId = newCharacter->getDatabaseID(); - trans.mAction = TRANS_CHAR_CREATE; - trans.mMessage = acc->getName() + " created character "; - trans.mMessage.append("called " + name); - storage->addTransaction(trans); - - reply.writeInt8(ERRMSG_OK); - client.send(reply); + reply.writeInt8(ERRMSG_OK); + client.send(reply); - // Send new characters infos back to client - sendCharacterData(client, *chars[slot]); - return; - } + // Send new characters infos back to client + sendCharacterData(client, *chars[slot]); } client.send(reply); |