summaryrefslogtreecommitdiff
path: root/src/net/eathena
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-10-05 22:28:03 +0300
committerAndrei Karas <akaras@inbox.ru>2014-10-05 22:28:03 +0300
commit7901ff853659fb9dda0218eac22c740dd44b1bd3 (patch)
tree6c69a874bdb2885662f6aa98113c9a0a62ac4039 /src/net/eathena
parent641be9d16d2c1ce41da1bb0f700725ca04311d30 (diff)
downloadplus-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')
-rw-r--r--src/net/eathena/charserverhandler.cpp61
-rw-r--r--src/net/eathena/charserverhandler.h3
-rw-r--r--src/net/eathena/packets.h2
-rw-r--r--src/net/eathena/protocol.h6
4 files changed, 66 insertions, 6 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
diff --git a/src/net/eathena/charserverhandler.h b/src/net/eathena/charserverhandler.h
index c59ab8c64..0fa9a7722 100644
--- a/src/net/eathena/charserverhandler.h
+++ b/src/net/eathena/charserverhandler.h
@@ -90,11 +90,14 @@ class CharServerHandler final : public MessageHandler,
void processCharCreate(Net::MessageIn &msg);
+ void processCharCheckRename(Net::MessageIn &msg);
+
void processCharRename(Net::MessageIn &msg);
private:
uint32_t mPinSeed;
uint32_t mPinAccountId;
+ uint32_t mRenameId;
bool mNeedCreatePin;
};
diff --git a/src/net/eathena/packets.h b/src/net/eathena/packets.h
index a70e95c2b..bd30b0dc9 100644
--- a/src/net/eathena/packets.h
+++ b/src/net/eathena/packets.h
@@ -94,7 +94,7 @@ int16_t packet_lengths[] =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
// #0x0280
0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 4, 0,
- 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, -1, 0, 0,
+ 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, -1, 0, 0,
0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, -1, -1, 107, 6, -1, 0, 0, 0, 191, 0, 0, 0, 0, 0, 0,
// #0x02C0
diff --git a/src/net/eathena/protocol.h b/src/net/eathena/protocol.h
index 0d2d39547..71baa43be 100644
--- a/src/net/eathena/protocol.h
+++ b/src/net/eathena/protocol.h
@@ -39,7 +39,8 @@
#define SMSG_CHAR_LOGIN_ERROR 0x006c
#define SMSG_CHAR_CREATE_SUCCEEDED 0x006d
#define SMSG_CHAR_PINCODE_STATUS 0x08b9
-#define SMSG_CHAR_RENAME 0x028e
+#define SMSG_CHAR_CHECK_RENAME 0x028e
+#define SMSG_CHAR_RENAME 0x0290
#define SMSG_CHAR_CREATE_FAILED 0x006e
#define SMSG_CHAR_DELETE_SUCCEEDED 0x006f
@@ -292,7 +293,8 @@
#define CMSG_CHAR_CREATE 0x0970
#define CMSG_CHAR_DELETE 0x0068
#define CMSG_CHAR_CREATE_PIN 0x08ba
-#define CMSG_CHAR_RENAME 0x08fc
+#define CMSG_CHAR_CHECK_RENAME 0x08fc
+#define CMSG_CHAR_RENAME 0x028f
#define CMSG_MAP_SERVER_CONNECT 0x089c
#define CMSG_MAP_PING 0x035f /**< Send to server with tick */