summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-10-06 00:46:45 +0300
committerAndrei Karas <akaras@inbox.ru>2014-10-06 00:46:45 +0300
commit16da077d4094fd6941ae4de60f1b6f3e133f1b5a (patch)
tree8a3b46ef60ad049a21fc21dedbd20db5597dc614 /src
parent87faf131575091160e9776c511e24b65e8b6b2e9 (diff)
downloadmv-16da077d4094fd6941ae4de60f1b6f3e133f1b5a.tar.gz
mv-16da077d4094fd6941ae4de60f1b6f3e133f1b5a.tar.bz2
mv-16da077d4094fd6941ae4de60f1b6f3e133f1b5a.tar.xz
mv-16da077d4094fd6941ae4de60f1b6f3e133f1b5a.zip
Update visible character name and character rename.
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/characterdisplay.h2
-rw-r--r--src/gui/windows/charselectdialog.cpp20
-rw-r--r--src/gui/windows/charselectdialog.h2
-rw-r--r--src/net/eathena/charserverhandler.cpp12
-rw-r--r--src/net/eathena/charserverhandler.h1
5 files changed, 28 insertions, 9 deletions
diff --git a/src/gui/widgets/characterdisplay.h b/src/gui/widgets/characterdisplay.h
index 866e3e580..12fad1201 100644
--- a/src/gui/widgets/characterdisplay.h
+++ b/src/gui/widgets/characterdisplay.h
@@ -82,9 +82,9 @@ class CharacterDisplay final : public Container,
void mousePressed(MouseEvent &event) override final;
- private:
void update();
+ private:
Net::Character *mCharacter;
PlayerBox *mPlayerBox;
Label *mName;
diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp
index 8d80fe1f7..768de6c03 100644
--- a/src/gui/windows/charselectdialog.cpp
+++ b/src/gui/windows/charselectdialog.cpp
@@ -605,3 +605,23 @@ void CharSelectDialog::updateState()
mPlayButton->setCaption(_("Create"));
}
}
+
+void CharSelectDialog::setName(const int id, const std::string &newName)
+{
+ for (unsigned int i = 0, sz = static_cast<unsigned int>(
+ mCharacterEntries.size()); i < sz; ++i)
+ {
+ if (!mCharacterEntries[i])
+ continue;
+ CharacterDisplay *const character = mCharacterEntries[i];
+ if (!character)
+ continue;
+ LocalPlayer *const player = character->getCharacter()->dummy;
+ if (player && player->getId() == id)
+ {
+ player->setName(newName);
+ character->update();
+ return;
+ }
+ }
+}
diff --git a/src/gui/windows/charselectdialog.h b/src/gui/windows/charselectdialog.h
index 97981df5b..36e6330d2 100644
--- a/src/gui/windows/charselectdialog.h
+++ b/src/gui/windows/charselectdialog.h
@@ -91,6 +91,8 @@ class CharSelectDialog final : public Window,
void postInit() override final;
+ void setName(const int id, const std::string &newName);
+
private:
void attemptCharacterDelete(const int index);
diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp
index e595c9ed4..021d12811 100644
--- a/src/net/eathena/charserverhandler.cpp
+++ b/src/net/eathena/charserverhandler.cpp
@@ -31,6 +31,7 @@
#include "gui/dialogtype.h"
#include "gui/windows/charcreatedialog.h"
+#include "gui/windows/charselectdialog.h"
#include "gui/windows/okdialog.h"
#include "net/character.h"
@@ -63,6 +64,7 @@ extern ServerInfo mapServer;
CharServerHandler::CharServerHandler() :
MessageHandler(),
Ea::CharServerHandler(),
+ mNewName(),
mPinSeed(0),
mPinAccountId(0),
mRenameId(0),
@@ -491,6 +493,7 @@ void CharServerHandler::renameCharacter(const int id,
{
createOutPacket(CMSG_CHAR_CHECK_RENAME);
mRenameId = id;
+ mNewName = newName;
outMsg.writeInt32(id, "char id");
outMsg.writeString(newName, 24, "name");
}
@@ -501,14 +504,6 @@ void CharServerHandler::processCharCheckRename(Net::MessageIn &msg)
{
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
{
@@ -526,6 +521,7 @@ void CharServerHandler::processCharRename(Net::MessageIn &msg)
const int flag = msg.readInt16("flag");
if (!flag)
{
+ mCharSelectDialog->setName(mRenameId, mNewName);
// TRANSLATORS: info message
new OkDialog(_("Info"), _("Character renamed."),
// TRANSLATORS: ok dialog button
diff --git a/src/net/eathena/charserverhandler.h b/src/net/eathena/charserverhandler.h
index 0fa9a7722..7f03e3093 100644
--- a/src/net/eathena/charserverhandler.h
+++ b/src/net/eathena/charserverhandler.h
@@ -95,6 +95,7 @@ class CharServerHandler final : public MessageHandler,
void processCharRename(Net::MessageIn &msg);
private:
+ std::string mNewName;
uint32_t mPinSeed;
uint32_t mPinAccountId;
uint32_t mRenameId;