diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/net/ea/traderecv.cpp | 2 | ||||
-rw-r--r-- | src/net/eathena/familyhandler.cpp | 12 | ||||
-rw-r--r-- | src/net/eathena/familyrecv.cpp | 48 | ||||
-rw-r--r-- | src/net/eathena/familyrecv.h | 6 |
6 files changed, 56 insertions, 14 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 379d39ce7..a4fb9bed4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1126,6 +1126,7 @@ SET(SRCS listeners/playerrelationslistener.h listeners/renamelistener.cpp listeners/renamelistener.h + listeners/requestadoptchildlistener.h listeners/requesttradelistener.h position.cpp position.h diff --git a/src/Makefile.am b/src/Makefile.am index 84d3c0bb0..1884936ea 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1526,6 +1526,7 @@ manaplus_SOURCES += gui/windows/bankwindow.cpp \ listeners/buyingstoreslotslistener.h \ listeners/pincodelistener.cpp \ listeners/pincodelistener.h \ + listeners/requestadoptchildlistener.h \ listeners/shoprenamelistener.cpp \ listeners/shoprenamelistener.h \ listeners/skillwarplistener.cpp \ diff --git a/src/net/ea/traderecv.cpp b/src/net/ea/traderecv.cpp index 4c0e4796f..0cafdb3a9 100644 --- a/src/net/ea/traderecv.cpp +++ b/src/net/ea/traderecv.cpp @@ -165,7 +165,7 @@ void TradeRecv::processTradeRequestContinue(const std::string &partner) strprintf(_("%s wants to trade with you, do" " you accept?"), tradePartnerName.c_str()), SOUND_REQUEST, - true); + true); confirmDlg->addActionListener(&listener); } else diff --git a/src/net/eathena/familyhandler.cpp b/src/net/eathena/familyhandler.cpp index 961d8877d..36297bb61 100644 --- a/src/net/eathena/familyhandler.cpp +++ b/src/net/eathena/familyhandler.cpp @@ -35,8 +35,8 @@ namespace EAthena FamilyHandler::FamilyHandler() { - FamilyRecv::mParent1 = 0; - FamilyRecv::mParent2 = 0; + FamilyRecv::mParent1 = BeingId_zero; + FamilyRecv::mParent2 = BeingId_zero; familyHandler = this; } @@ -53,9 +53,11 @@ void FamilyHandler::askForChild(const Being *const being) const void FamilyHandler::askForChildReply(const bool accept) const { createOutPacket(CMSG_FAMILY_ASK_FOR_CHILD_REPLY); - outMsg.writeInt32(FamilyRecv::mParent1, "parent1"); - outMsg.writeInt32(FamilyRecv::mParent2, "parent2"); - outMsg.writeInt32(accept ? 0: 1, "result"); + outMsg.writeBeingId(FamilyRecv::mParent1, "parent1"); + outMsg.writeBeingId(FamilyRecv::mParent2, "parent2"); + outMsg.writeInt32(accept ? 1 : 0, "result"); + FamilyRecv::mParent1 = BeingId_zero; + FamilyRecv::mParent2 = BeingId_zero; } } // namespace EAthena diff --git a/src/net/eathena/familyrecv.cpp b/src/net/eathena/familyrecv.cpp index 995c00a8b..7b0e9fa01 100644 --- a/src/net/eathena/familyrecv.cpp +++ b/src/net/eathena/familyrecv.cpp @@ -22,11 +22,21 @@ #include "logger.h" #include "notifymanager.h" +#include "party.h" #include "being/localplayer.h" #include "enums/resources/notifytypes.h" +#include "gui/widgets/createwidget.h" + +#include "gui/windows/confirmdialog.h" + +#include "utils/gettext.h" +#include "utils/stringutils.h" + +#include "listeners/requestadoptchildlistener.h" + #include "net/messagein.h" #include "debug.h" @@ -36,16 +46,42 @@ namespace EAthena namespace FamilyRecv { - int mParent1 = 0; - int mParent2 = 0; + ConfirmDialog *confirmDlg = nullptr; + RequestAdoptChildListener listener; + BeingId mParent1 = BeingId_zero; + BeingId mParent2 = BeingId_zero; } // namespace FamilyRecv void FamilyRecv::processAskForChild(Net::MessageIn &msg) { - UNIMPLIMENTEDPACKET; - msg.readInt32("account id who ask"); - msg.readInt32("acoount id for other parent"); - msg.readString(24, "name who ask"); + if (!localPlayer) + { + mParent1 = msg.readBeingId("account id who ask"); + mParent2 = msg.readBeingId("acoount id for other parent"); + msg.readString(24, "name who ask"); + return; + } + mParent1 = msg.readBeingId("account id who ask"); + mParent2 = msg.readBeingId("acoount id for other parent"); + const std::string name1 = msg.readString(24, "name who ask"); + const Party *const party = localPlayer->getParty(); + if (party) + { + const PartyMember *const member = party->getMember(mParent2); + if (member) + { + const std::string name2 = member->getName(); + CREATEWIDGETV(confirmDlg, ConfirmDialog, + // TRANSLATORS: adopt child message + _("Request parents"), + // TRANSLATORS: adopt child message + strprintf(_("Do you accept %s and %s as parents?"), + name1.c_str(), name2.c_str()), + SOUND_REQUEST, + false); + confirmDlg->addActionListener(&listener); + } + } } void FamilyRecv::processCallPartner(Net::MessageIn &msg) diff --git a/src/net/eathena/familyrecv.h b/src/net/eathena/familyrecv.h index 09953be6f..0ce18bf7f 100644 --- a/src/net/eathena/familyrecv.h +++ b/src/net/eathena/familyrecv.h @@ -23,6 +23,8 @@ #ifdef EATHENA_SUPPORT +#include "enums/simpletypes/beingid.h" + namespace Net { class MessageIn; @@ -32,8 +34,8 @@ namespace EAthena { namespace FamilyRecv { - extern int mParent1; - extern int mParent2; + extern BeingId mParent1; + extern BeingId mParent2; void processAskForChild(Net::MessageIn &msg); void processCallPartner(Net::MessageIn &msg); |