summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-01-04 18:54:18 +0300
committerAndrei Karas <akaras@inbox.ru>2015-01-04 18:54:18 +0300
commit829709f07a16e945af416cb1df23d0fcefdba8e0 (patch)
tree1a40a1dd51724970b71c8833f27d18a39b38a62f
parenta3310b047fb85052429a979eb0ebd02d47c43964 (diff)
downloadmv-829709f07a16e945af416cb1df23d0fcefdba8e0.tar.gz
mv-829709f07a16e945af416cb1df23d0fcefdba8e0.tar.bz2
mv-829709f07a16e945af416cb1df23d0fcefdba8e0.tar.xz
mv-829709f07a16e945af416cb1df23d0fcefdba8e0.zip
eathena: allow delete characters if account have non default email.
-rw-r--r--src/gui/windows/charselectdialog.cpp57
-rw-r--r--src/gui/windows/charselectdialog.h3
-rw-r--r--src/net/charserverhandler.h3
-rw-r--r--src/net/eathena/charserverhandler.cpp8
-rw-r--r--src/net/eathena/charserverhandler.h3
-rw-r--r--src/net/tmwa/charserverhandler.cpp3
-rw-r--r--src/net/tmwa/charserverhandler.h3
7 files changed, 54 insertions, 26 deletions
diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp
index 77cbe28cb..b6bc5c83e 100644
--- a/src/gui/windows/charselectdialog.cpp
+++ b/src/gui/windows/charselectdialog.cpp
@@ -297,20 +297,27 @@ void CharSelectDialog::action(const ActionEvent &event)
}
else if (eventId == "try delete character")
{
- if (mDeleteDialog && mDeleteIndex != -1 && mDeleteDialog->getText()
- == LoginDialog::savedPassword)
+ if (mDeleteDialog && mDeleteIndex != -1)
{
- attemptCharacterDelete(mDeleteIndex);
- mDeleteDialog = nullptr;
- }
- else
- {
- // TRANSLATORS: error message
- new OkDialog(_("Error"), _("Incorrect password"),
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::ERROR,
- true, true, nullptr, 260);
+ if (serverFeatures->haveEmailOnDelete())
+ {
+ attemptCharacterDelete(mDeleteIndex, mDeleteDialog->getText());
+ mDeleteDialog = nullptr;
+ }
+ else if (mDeleteDialog->getText() == LoginDialog::savedPassword)
+ {
+ attemptCharacterDelete(mDeleteIndex, "");
+ mDeleteDialog = nullptr;
+ }
+ else
+ {
+ // TRANSLATORS: error message
+ new OkDialog(_("Error"), _("Incorrect password"),
+ // TRANSLATORS: ok dialog button
+ _("OK"),
+ DialogType::ERROR,
+ true, true, nullptr, 260);
+ }
}
mDeleteIndex = -1;
}
@@ -428,7 +435,8 @@ void CharSelectDialog::keyPressed(KeyEvent &event)
/**
* Communicate character deletion to the server.
*/
-void CharSelectDialog::attemptCharacterDelete(const int index)
+void CharSelectDialog::attemptCharacterDelete(const int index,
+ const std::string &email)
{
if (mLocked)
return;
@@ -436,7 +444,8 @@ void CharSelectDialog::attemptCharacterDelete(const int index)
if (mCharacterEntries[index])
{
mCharServerHandler->deleteCharacter(
- mCharacterEntries[index]->getCharacter());
+ mCharacterEntries[index]->getCharacter(),
+ email);
}
lock();
}
@@ -444,10 +453,20 @@ void CharSelectDialog::attemptCharacterDelete(const int index)
void CharSelectDialog::askPasswordForDeletion(const int index)
{
mDeleteIndex = index;
- mDeleteDialog = new TextDialog(
- // TRANSLATORS: char deletion question.
- _("Enter password for deleting character"), _("Enter password:"),
- this, true);
+ if (serverFeatures->haveEmailOnDelete())
+ {
+ mDeleteDialog = new TextDialog(
+ // TRANSLATORS: char deletion question.
+ _("Enter your email for deleting character"), _("Enter email:"),
+ this, false);
+ }
+ else
+ {
+ mDeleteDialog = new TextDialog(
+ // TRANSLATORS: char deletion question.
+ _("Enter password for deleting character"), _("Enter password:"),
+ this, true);
+ }
mDeleteDialog->postInit();
mDeleteDialog->setActionEventId("try delete character");
mDeleteDialog->addActionListener(this);
diff --git a/src/gui/windows/charselectdialog.h b/src/gui/windows/charselectdialog.h
index 0f3529fc0..ca7d6111c 100644
--- a/src/gui/windows/charselectdialog.h
+++ b/src/gui/windows/charselectdialog.h
@@ -94,7 +94,8 @@ class CharSelectDialog final : public Window,
void setName(const int id, const std::string &newName);
private:
- void attemptCharacterDelete(const int index);
+ void attemptCharacterDelete(const int index,
+ const std::string &email);
void attemptCharacterSelect(const int index);
diff --git a/src/net/charserverhandler.h b/src/net/charserverhandler.h
index 846ff0910..2013485a4 100644
--- a/src/net/charserverhandler.h
+++ b/src/net/charserverhandler.h
@@ -63,7 +63,8 @@ class CharServerHandler notfinal
const unsigned char look,
const std::vector<int> &stats) const = 0;
- virtual void deleteCharacter(Net::Character *const character) = 0;
+ virtual void deleteCharacter(Net::Character *const character,
+ const std::string &email) = 0;
virtual void renameCharacter(const int id,
const std::string &newName) = 0;
diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp
index 5ced3761f..c2292abde 100644
--- a/src/net/eathena/charserverhandler.cpp
+++ b/src/net/eathena/charserverhandler.cpp
@@ -285,7 +285,8 @@ void CharServerHandler::newCharacter(const std::string &name, const int slot,
outMsg.writeInt16(static_cast<int16_t>(race), "race");
}
-void CharServerHandler::deleteCharacter(Net::Character *const character)
+void CharServerHandler::deleteCharacter(Net::Character *const character,
+ const std::string &email)
{
if (!character)
return;
@@ -294,7 +295,10 @@ void CharServerHandler::deleteCharacter(Net::Character *const character)
createOutPacket(CMSG_CHAR_DELETE);
outMsg.writeInt32(mSelectedCharacter->dummy->getId(), "id?");
- outMsg.writeString("a@a.com", 40, "email");
+ if (email.empty())
+ outMsg.writeString("a@a.com", 40, "email");
+ else
+ outMsg.writeString(email, 40, "email");
}
void CharServerHandler::switchCharacter() const
diff --git a/src/net/eathena/charserverhandler.h b/src/net/eathena/charserverhandler.h
index 0af45d9bd..d62d0a3df 100644
--- a/src/net/eathena/charserverhandler.h
+++ b/src/net/eathena/charserverhandler.h
@@ -54,7 +54,8 @@ class CharServerHandler final : public MessageHandler,
void renameCharacter(const int id,
const std::string &newName) override final;
- void deleteCharacter(Net::Character *const character) override final;
+ void deleteCharacter(Net::Character *const character,
+ const std::string &email) override final;
void switchCharacter() const override final;
diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp
index 2412a094d..af373ca77 100644
--- a/src/net/tmwa/charserverhandler.cpp
+++ b/src/net/tmwa/charserverhandler.cpp
@@ -292,7 +292,8 @@ void CharServerHandler::newCharacter(const std::string &name, const int slot,
outMsg.writeInt8(race, "class");
}
-void CharServerHandler::deleteCharacter(Net::Character *const character)
+void CharServerHandler::deleteCharacter(Net::Character *const character,
+ const std::string &email A_UNUSED)
{
if (!character)
return;
diff --git a/src/net/tmwa/charserverhandler.h b/src/net/tmwa/charserverhandler.h
index ab513d0d2..ef6afab36 100644
--- a/src/net/tmwa/charserverhandler.h
+++ b/src/net/tmwa/charserverhandler.h
@@ -51,7 +51,8 @@ class CharServerHandler final : public MessageHandler,
const unsigned char look,
const std::vector<int> &stats) const override final;
- void deleteCharacter(Net::Character *const character) override final;
+ void deleteCharacter(Net::Character *const character,
+ const std::string &email) override final;
void renameCharacter(const int id,
const std::string &newName) override final;