diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-10-05 22:28:03 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-10-05 22:28:03 +0300 |
commit | 7901ff853659fb9dda0218eac22c740dd44b1bd3 (patch) | |
tree | 6c69a874bdb2885662f6aa98113c9a0a62ac4039 /src/net/eathena/charserverhandler.cpp | |
parent | 641be9d16d2c1ce41da1bb0f700725ca04311d30 (diff) | |
download | plus-7901ff853659fb9dda0218eac22c740dd44b1bd3.tar.gz plus-7901ff853659fb9dda0218eac22c740dd44b1bd3.tar.bz2 plus-7901ff853659fb9dda0218eac22c740dd44b1bd3.tar.xz plus-7901ff853659fb9dda0218eac22c740dd44b1bd3.zip |
eathena: complete char rename support.
Diffstat (limited to 'src/net/eathena/charserverhandler.cpp')
-rw-r--r-- | src/net/eathena/charserverhandler.cpp | 61 |
1 files changed, 58 insertions, 3 deletions
diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp index ee40d5e65..b0a7249f5 100644 --- a/src/net/eathena/charserverhandler.cpp +++ b/src/net/eathena/charserverhandler.cpp @@ -65,6 +65,7 @@ CharServerHandler::CharServerHandler() : Ea::CharServerHandler(), mPinSeed(0), mPinAccountId(0), + mRenameId(0), mNeedCreatePin(false) { static const uint16_t _messages[] = @@ -79,6 +80,7 @@ CharServerHandler::CharServerHandler() : SMSG_CHAR_MAP_INFO, SMSG_CHANGE_MAP_SERVER, SMSG_CHAR_PINCODE_STATUS, + SMSG_CHAR_CHECK_RENAME, SMSG_CHAR_RENAME, 0 }; @@ -130,6 +132,10 @@ void CharServerHandler::handleMessage(Net::MessageIn &msg) processPincodeStatus(msg); break; + case SMSG_CHAR_CHECK_RENAME: + processCharCheckRename(msg); + break; + case SMSG_CHAR_RENAME: processCharRename(msg); break; @@ -483,26 +489,31 @@ void CharServerHandler::processCharCreate(Net::MessageIn &msg) void CharServerHandler::renameCharacter(const int id, const std::string &newName) { - createOutPacket(CMSG_CHAR_RENAME); + createOutPacket(CMSG_CHAR_CHECK_RENAME); + mRenameId = id; outMsg.writeInt32(id, "char id"); outMsg.writeString(newName, 24, "name"); } -void CharServerHandler::processCharRename(Net::MessageIn &msg) +void CharServerHandler::processCharCheckRename(Net::MessageIn &msg) { if (msg.readInt16("flag")) { + createOutPacket(CMSG_CHAR_RENAME); + outMsg.writeInt32(mRenameId, "char id"); +/* // TRANSLATORS: info message new OkDialog(_("Info"), _("Character renamed."), // TRANSLATORS: ok dialog button _("OK"), DialogType::OK, true, true, nullptr, 260); +*/ } else { // TRANSLATORS: info message - new OkDialog(_("Info"), _("Character rename error."), + new OkDialog(_("Error"), _("Character rename error."), // TRANSLATORS: ok dialog button _("Error"), DialogType::ERROR, @@ -510,4 +521,48 @@ void CharServerHandler::processCharRename(Net::MessageIn &msg) } } +void CharServerHandler::processCharRename(Net::MessageIn &msg) +{ + const int flag = msg.readInt16("flag"); + if (!flag) + { + // TRANSLATORS: info message + new OkDialog(_("Info"), _("Character renamed."), + // TRANSLATORS: ok dialog button + _("OK"), + DialogType::OK, + true, true, nullptr, 260); + } + else + { + std::string message; + switch (flag) + { + case 1: + // TRANSLATORS: char rename error + message = _("Rename not allowed."); + break; + case 2: + // TRANSLATORS: char rename error + message = _("New name is not set."); + break; + case 3: + default: + // TRANSLATORS: char rename error + message = _("Character rename error."); + break; + case 4: + // TRANSLATORS: char rename error + message = _("Character not found."); + break; + } + // TRANSLATORS: info message + new OkDialog(_("Info"), message, + // TRANSLATORS: ok dialog button + _("OK"), + DialogType::OK, + true, true, nullptr, 260); + } +} + } // namespace EAthena |