summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2018-03-05 20:41:48 +0300
committerAndrei Karas <akaras@inbox.ru>2018-03-05 20:41:48 +0300
commit8032eb0f2345ed6b9097277034d94066af66f4fd (patch)
tree6e4490564a53cd1ac3e80a8d60e63906ce4e6e67 /src
parent55c9a94d904bb7fb6351f55e652ad241c079cf96 (diff)
downloadmv-8032eb0f2345ed6b9097277034d94066af66f4fd.tar.gz
mv-8032eb0f2345ed6b9097277034d94066af66f4fd.tar.bz2
mv-8032eb0f2345ed6b9097277034d94066af66f4fd.tar.xz
mv-8032eb0f2345ed6b9097277034d94066af66f4fd.zip
Add empty pincode manager.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/gui/windows/charselectdialog.cpp12
-rw-r--r--src/net/charserverhandler.h2
-rw-r--r--src/net/eathena/charserverhandler.cpp8
-rw-r--r--src/net/eathena/charserverhandler.h2
-rw-r--r--src/net/eathena/charserverrecv.cpp17
-rw-r--r--src/net/eathena/charserverrecv.h3
-rw-r--r--src/net/tmwa/charserverhandler.h3
-rw-r--r--src/pincodemanager.cpp61
-rw-r--r--src/pincodemanager.h62
-rw-r--r--src/progs/manaplus/client.cpp2
12 files changed, 138 insertions, 38 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a12eaff47..fdf5e7e4f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1301,6 +1301,8 @@ SET(SRCS
particle/particlevector.h
party.cpp
party.h
+ pincodemanager.cpp
+ pincodemanager.h
being/playerignorestrategy.h
being/playerinfo.cpp
being/playerinfo.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 8e44e386c..23ffab297 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1407,6 +1407,8 @@ SRC = ${BASE_SRC} \
particle/particlevector.h \
party.cpp \
party.h \
+ pincodemanager.cpp \
+ pincodemanager.h \
utils/chatutils.cpp \
utils/chatutils.h \
utils/gmfunctions.cpp \
diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp
index 5038195d2..f526f133c 100644
--- a/src/gui/windows/charselectdialog.cpp
+++ b/src/gui/windows/charselectdialog.cpp
@@ -172,18 +172,6 @@ void CharSelectDialog::postInit()
Window::postInit();
setVisible(Visible_true);
requestFocus();
- if (charServerHandler->isNeedCreatePin())
- {
- EditDialog *const dialog = CREATEWIDGETR(EditDialog,
- // TRANSLATORS: pin code dialog header.
- _("Please set new pincode"),
- "",
- "OK",
- 300,
- nullptr,
- Modal_true);
- dialog->addActionListener(&pincodeListener);
- }
}
void CharSelectDialog::action(const ActionEvent &event)
diff --git a/src/net/charserverhandler.h b/src/net/charserverhandler.h
index f7d1bfd6f..8c41db2ad 100644
--- a/src/net/charserverhandler.h
+++ b/src/net/charserverhandler.h
@@ -87,8 +87,6 @@ class CharServerHandler notfinal
virtual void clear() const = 0;
- virtual bool isNeedCreatePin() const = 0;
-
virtual void setNewPincode(const std::string &pin) const = 0;
virtual void changeSlot(const int oldSlot,
diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp
index 5b042aaa5..e98f963e4 100644
--- a/src/net/eathena/charserverhandler.cpp
+++ b/src/net/eathena/charserverhandler.cpp
@@ -50,10 +50,7 @@ CharServerHandler::CharServerHandler() :
Ea::CharServerHandler()
{
CharServerRecv::mNewName.clear();
- CharServerRecv::mPinSeed = 0;
- CharServerRecv::mPinAccountId = BeingId_zero;
CharServerRecv::mRenameId = BeingId_zero;
- CharServerRecv::mNeedCreatePin = false;
charServerHandler = this;
}
@@ -240,9 +237,4 @@ unsigned int CharServerHandler::hatSprite() const
return 7;
}
-bool CharServerHandler::isNeedCreatePin() const
-{
- return CharServerRecv::mNeedCreatePin;
-}
-
} // namespace EAthena
diff --git a/src/net/eathena/charserverhandler.h b/src/net/eathena/charserverhandler.h
index 662873e00..e86e03721 100644
--- a/src/net/eathena/charserverhandler.h
+++ b/src/net/eathena/charserverhandler.h
@@ -62,8 +62,6 @@ class CharServerHandler final : public Ea::CharServerHandler
void connect() const override final;
- bool isNeedCreatePin() const override final A_WARN_UNUSED;
-
void setNewPincode(const std::string &pin) const override final;
/**
diff --git a/src/net/eathena/charserverrecv.cpp b/src/net/eathena/charserverrecv.cpp
index abae9b0e1..3e69005e3 100644
--- a/src/net/eathena/charserverrecv.cpp
+++ b/src/net/eathena/charserverrecv.cpp
@@ -24,6 +24,7 @@
#include "client.h"
#include "configuration.h"
+#include "pincodemanager.h"
#include "settings.h"
#include "gui/windows/charcreatedialog.h"
@@ -65,10 +66,7 @@ extern ServerInfo mapServer;
namespace CharServerRecv
{
std::string mNewName;
- uint32_t mPinSeed = 0;
- BeingId mPinAccountId = BeingId_zero;
BeingId mRenameId = BeingId_zero;
- bool mNeedCreatePin = false;
} // namespace CharServerRecv
// callers must count each packet size by self
@@ -349,31 +347,34 @@ void CharServerRecv::processChangeMapServer(Net::MessageIn &msg)
void CharServerRecv::processPincodeStatus(Net::MessageIn &msg)
{
- mPinSeed = msg.readInt32("pincode seed");
- mPinAccountId = msg.readBeingId("account id");
+ pincodeManager.setSeed(msg.readInt32("pincode seed"));
+ pincodeManager.setAccountId(msg.readBeingId("account id"));
const uint16_t state = CAST_U16(msg.readInt16("state"));
switch (state)
{
case 0: // pin ok
+ pincodeManager.pinOk();
break;
case 1: // ask for pin
+ pincodeManager.askPin();
break;
case 2: // create new pin
case 4: // create new pin?
{
- mNeedCreatePin = true;
+ pincodeManager.createNewPin();
break;
}
case 3: // pin must be changed
+ pincodeManager.changePin();
break;
+ case 8: // pincode was incorrect
case 5: // client show error?
+ pincodeManager.wrongPin();
break;
case 6: // Unable to use your KSSN number
break;
case 7: // char select window shows a button
break;
- case 8: // pincode was incorrect
- break;
default:
UNIMPLEMENTEDPACKET;
break;
diff --git a/src/net/eathena/charserverrecv.h b/src/net/eathena/charserverrecv.h
index b19273877..3ad63a311 100644
--- a/src/net/eathena/charserverrecv.h
+++ b/src/net/eathena/charserverrecv.h
@@ -39,10 +39,7 @@ namespace EAthena
namespace CharServerRecv
{
extern std::string mNewName;
- extern uint32_t mPinSeed;
- extern BeingId mPinAccountId;
extern BeingId mRenameId;
- extern bool mNeedCreatePin;
void readPlayerData(Net::MessageIn &msg,
Net::Character *const character);
diff --git a/src/net/tmwa/charserverhandler.h b/src/net/tmwa/charserverhandler.h
index 5ea4b6a5c..6d2051a63 100644
--- a/src/net/tmwa/charserverhandler.h
+++ b/src/net/tmwa/charserverhandler.h
@@ -62,9 +62,6 @@ class CharServerHandler final : public Ea::CharServerHandler
void connect() const override final;
- bool isNeedCreatePin() const override final
- { return false; }
-
void setNewPincode(const std::string &pin A_UNUSED) const
override final
{ }
diff --git a/src/pincodemanager.cpp b/src/pincodemanager.cpp
new file mode 100644
index 000000000..e13671293
--- /dev/null
+++ b/src/pincodemanager.cpp
@@ -0,0 +1,61 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2018 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "pincodemanager.h"
+
+#include "debug.h"
+
+PincodeManager pincodeManager;
+
+PincodeManager::PincodeManager() :
+ mSeed(0U),
+ mAccountId(BeingId_zero)
+{
+}
+
+PincodeManager::~PincodeManager()
+{
+}
+
+void PincodeManager::init()
+{
+ mSeed = 0;
+ mAccountId = BeingId_zero;
+}
+
+void PincodeManager::pinOk()
+{
+}
+
+void PincodeManager::askPin()
+{
+}
+
+void PincodeManager::createNewPin()
+{
+}
+
+void PincodeManager::changePin()
+{
+}
+
+void PincodeManager::wrongPin()
+{
+}
diff --git a/src/pincodemanager.h b/src/pincodemanager.h
new file mode 100644
index 000000000..58af704ed
--- /dev/null
+++ b/src/pincodemanager.h
@@ -0,0 +1,62 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2018 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PINCODEMANAGER_H
+#define PINCODEMANAGER_H
+
+#include "enums/simpletypes/beingid.h"
+
+#include "localconsts.h"
+
+class PincodeManager final
+{
+ public:
+ PincodeManager();
+
+ A_DELETE_COPY(PincodeManager)
+
+ ~PincodeManager();
+
+ void init();
+
+ void pinOk();
+
+ void askPin();
+
+ void createNewPin();
+
+ void changePin();
+
+ void wrongPin();
+
+ void setSeed(const uint32_t seed)
+ { mSeed = seed; }
+
+ void setAccountId(const BeingId id)
+ { mAccountId = id; }
+
+ protected:
+ uint32_t mSeed;
+ BeingId mAccountId;
+};
+
+extern PincodeManager pincodeManager;
+
+#endif // PINCODEMANAGER_H
diff --git a/src/progs/manaplus/client.cpp b/src/progs/manaplus/client.cpp
index 04956381f..c035ed018 100644
--- a/src/progs/manaplus/client.cpp
+++ b/src/progs/manaplus/client.cpp
@@ -30,6 +30,7 @@
#include "graphicsmanager.h"
#include "main.h"
#include "party.h"
+#include "pincodemanager.h"
#include "settings.h"
#include "soundmanager.h"
#include "spellmanager.h"
@@ -1118,6 +1119,7 @@ int Client::gameExec()
State::SWITCH_SERVER);
TranslationManager::loadCurrentLang();
TranslationManager::loadDictionaryLang();
+ pincodeManager.init();
BLOCK_END("Client::gameExec State::CONNECT_SERVER")
break;