00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "account.h"
00023
00024 #include "internal.h"
00025
00026 #include "net/tmwserv/connection.h"
00027 #include "net/tmwserv/protocol.h"
00028
00029 #include "net/messageout.h"
00030
00031 #include "utils/sha256.h"
00032
00033 #include <string>
00034
00035 void Net::AccountServer::Account::createCharacter(
00036 const std::string &name, char hairStyle, char hairColor, char gender,
00037 short strength, short agility, short vitality,
00038 short intelligence, short dexterity, short willpower)
00039 {
00040 MessageOut msg(PAMSG_CHAR_CREATE);
00041
00042 msg.writeString(name);
00043 msg.writeInt8(hairStyle);
00044 msg.writeInt8(hairColor);
00045 msg.writeInt8(gender);
00046 msg.writeInt16(strength);
00047 msg.writeInt16(agility);
00048 msg.writeInt16(vitality);
00049 msg.writeInt16(intelligence);
00050 msg.writeInt16(dexterity);
00051 msg.writeInt16(willpower);
00052
00053 Net::AccountServer::connection->send(msg);
00054 }
00055
00056 void Net::AccountServer::Account::deleteCharacter(char slot)
00057 {
00058 MessageOut msg(PAMSG_CHAR_DELETE);
00059
00060 msg.writeInt8(slot);
00061
00062 Net::AccountServer::connection->send(msg);
00063 }
00064
00065 void Net::AccountServer::Account::selectCharacter(char slot)
00066 {
00067 MessageOut msg(PAMSG_CHAR_SELECT);
00068
00069 msg.writeInt8(slot);
00070
00071 Net::AccountServer::connection->send(msg);
00072 }
00073
00074 void Net::AccountServer::Account::unregister(const std::string &username,
00075 const std::string &password)
00076 {
00077 MessageOut msg(PAMSG_UNREGISTER);
00078
00079 msg.writeString(username);
00080 msg.writeString(sha256(username + password));
00081
00082 Net::AccountServer::connection->send(msg);
00083 }
00084
00085 void Net::AccountServer::Account::changeEmail(const std::string &email)
00086 {
00087 MessageOut msg(PAMSG_EMAIL_CHANGE);
00088
00089
00090
00091 msg.writeString(email);
00092
00093 Net::AccountServer::connection->send(msg);
00094 }
00095
00096 void Net::AccountServer::Account::changePassword(
00097 const std::string &username,
00098 const std::string &oldPassword,
00099 const std::string &newPassword)
00100 {
00101 MessageOut msg(PAMSG_PASSWORD_CHANGE);
00102
00103
00104 msg.writeString(sha256(username + oldPassword));
00105 msg.writeString(sha256(username + newPassword));
00106
00107 Net::AccountServer::connection->send(msg);
00108 }