From acd87806b767d70c0676c0f800e23a7ce4f623e0 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 14 Jul 2018 00:49:40 +0300 Subject: Add packet SMSG_CHAR_PINCODE_STATUS2 0x0ae9. --- src/net/eathena/charserverrecv.cpp | 44 +++++++++++--------------------- src/net/eathena/charserverrecv.h | 1 + src/net/eathena/packetsin.inc | 20 ++++++++++++++- src/pincodemanager.cpp | 51 +++++++++++++++++++++++++++++++++++++- src/pincodemanager.h | 8 ++++++ 5 files changed, 93 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/net/eathena/charserverrecv.cpp b/src/net/eathena/charserverrecv.cpp index 85662e92b..3100aaebb 100644 --- a/src/net/eathena/charserverrecv.cpp +++ b/src/net/eathena/charserverrecv.cpp @@ -346,41 +346,27 @@ void CharServerRecv::processChangeMapServer(Net::MessageIn &msg) } void CharServerRecv::processPincodeStatus(Net::MessageIn &msg) +{ + pincodeManager.setSeed(msg.readUInt32("pincode seed")); + pincodeManager.setAccountId(msg.readBeingId("account id")); + pincodeManager.setPincodeLockFlag(false); + if (pincodeManager.processPincodeStatus(CAST_U16( + msg.readInt16("state"))) == false) + { + UNIMPLEMENTEDPACKET; + } +} + +void CharServerRecv::processPincodeStatus2(Net::MessageIn &msg) { pincodeManager.setSeed(msg.readUInt32("pincode seed")); pincodeManager.setAccountId(msg.readBeingId("account id")); const uint16_t state = CAST_U16(msg.readInt16("state")); - switch (state) + pincodeManager.setPincodeLockFlag(msg.readInt16("flag") == 0); + if (pincodeManager.processPincodeStatus(state) == false) { - case 0: // pin ok - pincodeManager.pinOk(); - break; - case 1: // ask for pin - pincodeManager.setState(PincodeState::Ask); - break; - case 2: // create new pin - case 4: // create new pin? - { - pincodeManager.setState(PincodeState::Create); - break; - } - case 3: // pin must be changed - pincodeManager.setState(PincodeState::Change); - break; - case 8: // pincode was incorrect - case 5: // client show error? - pincodeManager.wrongPin(); - return; - case 6: // Unable to use your KSSN number - break; - case 7: // char select window shows a button - break; - default: - UNIMPLEMENTEDPACKET; - break; + UNIMPLEMENTEDPACKET; } - if (client) - client->updatePinState(); } void CharServerRecv::processPincodeMakeStatus(Net::MessageIn &msg) diff --git a/src/net/eathena/charserverrecv.h b/src/net/eathena/charserverrecv.h index 5b776f82d..78092d3dd 100644 --- a/src/net/eathena/charserverrecv.h +++ b/src/net/eathena/charserverrecv.h @@ -44,6 +44,7 @@ namespace EAthena void readPlayerData(Net::MessageIn &msg, Net::Character *const character); void processPincodeStatus(Net::MessageIn &msg); + void processPincodeStatus2(Net::MessageIn &msg); void processPincodeMakeStatus(Net::MessageIn &msg); void processPincodeEditStatus(Net::MessageIn &msg); void processCharLogin2(Net::MessageIn &msg); diff --git a/src/net/eathena/packetsin.inc b/src/net/eathena/packetsin.inc index 83d30570a..8fa74e371 100644 --- a/src/net/eathena/packetsin.inc +++ b/src/net/eathena/packetsin.inc @@ -1037,6 +1037,24 @@ if (packetVersion >= 20171207) packet(SMSG_PARTY_INFO, 0x0ae5, -1, &PartyRecv::processPartyInfo, 20171207); } +// main 20180124 +if (packetVersionMain >= 20180124) +{ + packet(SMSG_CHAR_PINCODE_STATUS2, 0x0ae9, 13, &CharServerRecv::processPincodeStatus2, 20180124); +} + +// re 20180124 +if (packetVersionRe >= 20180124) +{ + packet(SMSG_CHAR_PINCODE_STATUS2, 0x0ae9, 13, &CharServerRecv::processPincodeStatus2, 20180124); +} + +// zero 20180131 +if (packetVersionZero >= 20180131) +{ + packet(SMSG_CHAR_PINCODE_STATUS2, 0x0ae9, 13, &CharServerRecv::processPincodeStatus2, 20180124); +} + // re 20180221 if (packetVersionRe >= 20180221) { @@ -1081,7 +1099,7 @@ if (packetVersionZero >= 20180411) } // 20180418 -if (packetVersion == 20180418) +if (packetVersion >= 20180418) { packet(SMSG_ITEM_DROPPED, 0x0add, 22, &ItemRecv::processItemDropped, 20180418); } diff --git a/src/pincodemanager.cpp b/src/pincodemanager.cpp index 67b14f2bf..a97c813ef 100644 --- a/src/pincodemanager.cpp +++ b/src/pincodemanager.cpp @@ -46,7 +46,8 @@ PincodeManager::PincodeManager() : mSeed(0U), mAccountId(BeingId_zero), mDialog(nullptr), - mState(PincodeState::None) + mState(PincodeState::None), + mLockFlag(false) { } @@ -235,6 +236,14 @@ void PincodeManager::pinOk() client->focusWindow(); } +void PincodeManager::lockedPin() +{ + // +++ here can be handled locked account by pin code. + // but hercules for now not have this feature + mState = PincodeState::Ask; + updateState(); +} + void PincodeManager::wrongPin() { mState = PincodeState::Ask; @@ -254,3 +263,43 @@ bool PincodeManager::isBlocked() { return mState != PincodeState::None; } + +bool PincodeManager::processPincodeStatus(const uint16_t state) +{ + switch (state) + { + case 0: // pin ok + pincodeManager.pinOk(); + break; + case 1: // ask for pin + pincodeManager.setState(PincodeState::Ask); + break; + case 2: // create new pin + case 4: // create new pin? + { + pincodeManager.setState(PincodeState::Create); + break; + } + case 3: // pin must be changed + pincodeManager.setState(PincodeState::Change); + break; + case 8: // pincode was incorrect + case 5: // client show error? + if (mLockFlag) + pincodeManager.lockedPin(); + else + pincodeManager.wrongPin(); + return true; + case 6: // Unable to use your KSSN number + break; + case 7: // char select window shows a button + break; + default: + if (client) + client->updatePinState(); + return false; + } + if (client) + client->updatePinState(); + return true; +} diff --git a/src/pincodemanager.h b/src/pincodemanager.h index c1613fa7e..49d081157 100644 --- a/src/pincodemanager.h +++ b/src/pincodemanager.h @@ -49,6 +49,8 @@ class PincodeManager final void wrongPin(); + void lockedPin(); + void setSeed(const uint32_t seed) { mSeed = seed; } @@ -58,6 +60,9 @@ class PincodeManager final void setState(const PincodeStateT state) { mState = state; } + void setPincodeLockFlag(const bool flag) + { mLockFlag = flag; } + void changePincode(const std::string &pincode); void clearDialog(const PincodeDialog *const PincodeDialog); @@ -70,6 +75,8 @@ class PincodeManager final bool isBlocked(); + bool processPincodeStatus(const uint16_t state); + protected: std::string mOldPincode; std::string mNewPincode; @@ -77,6 +84,7 @@ class PincodeManager final BeingId mAccountId; Window *mDialog; PincodeStateT mState; + bool mLockFlag; }; extern PincodeManager pincodeManager; -- cgit v1.2.3-70-g09d2