ManaPlus
partyhandler.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2008 Lloyd Bryant <[email protected]>
4  * Copyright (C) 2011-2018 The ManaPlus Developers
5  *
6  * This file is part of The ManaPlus Client.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #include "net/tmwa/partyhandler.h"
23 
24 #include "actormanager.h"
25 #include "notifymanager.h"
26 #include "party.h"
27 
28 #include "being/localplayer.h"
29 
31 
32 #include "net/ea/partyrecv.h"
33 
34 #include "net/tmwa/messageout.h"
35 #include "net/tmwa/protocolout.h"
36 
37 #include "debug.h"
38 
39 namespace TmwAthena
40 {
41 
43  Ea::PartyHandler()
44 {
45  partyHandler = this;
46 }
47 
49 {
50  partyHandler = nullptr;
51 }
52 
53 void PartyHandler::create(const std::string &name) const
54 {
56  outMsg.writeString(name.substr(0, 23), 24, "party name");
57 }
58 
59 void PartyHandler::invite(const std::string &name) const
60 {
61  if (actorManager == nullptr)
62  return;
63 
64  const Being *const being = actorManager->findBeingByName(
65  name, ActorType::Player);
66  if (being != nullptr)
67  {
69  outMsg.writeBeingId(being->getId(), "account id");
70  }
71 }
72 
73 void PartyHandler::inviteResponse(const int partyId A_UNUSED,
74  const bool accept) const
75 {
76  if (localPlayer != nullptr)
77  {
79  outMsg.writeBeingId(localPlayer->getId(), "account id");
80  outMsg.writeInt32(accept ? 1 : 0, "accept");
81  }
82 }
83 
84 void PartyHandler::leave() const
85 {
87 }
88 
89 void PartyHandler::kick(const Being *const being) const
90 {
91  if (being != nullptr)
92  {
94  outMsg.writeBeingId(being->getId(), "account id");
95  outMsg.writeString("", 24, "unused");
96  }
97 }
98 
99 void PartyHandler::kick(const std::string &name) const
100 {
101  if (Ea::taParty == nullptr)
102  return;
103 
104  const PartyMember *const m = Ea::taParty->getMember(name);
105  if (m == nullptr)
106  {
108  return;
109  }
110 
112  outMsg.writeBeingId(m->getID(), "member id");
113  outMsg.writeString(name, 24, "unused");
114 }
115 
116 void PartyHandler::chat(const std::string &text) const
117 {
119  outMsg.writeInt16(CAST_S16(text.length() + 4), "len");
120  outMsg.writeString(text, CAST_S32(text.length()), "text");
121 }
122 
124 {
125  if (share == PartyShare::NOT_POSSIBLE)
126  return;
127 
129  outMsg.writeInt16(CAST_S16(share), "share exp");
130  outMsg.writeInt16(CAST_S16(Ea::PartyRecv::mShareItems),
131  "share items");
132 }
133 
135 {
136  if (share == PartyShare::NOT_POSSIBLE)
137  return;
138 
140  outMsg.writeInt16(CAST_S16(Ea::PartyRecv::mShareExp),
141  "share exp");
142  outMsg.writeInt16(CAST_S16(share), "share items");
143 }
144 
145 void PartyHandler::changeLeader(const std::string &name A_UNUSED) const
146 {
147 }
148 
149 void PartyHandler::allowInvite(const bool allow A_UNUSED) const
150 {
151 }
152 
154 {
156 }
157 
159 {
160 }
161 
162 } // namespace TmwAthena
void invite(const std::string &name) const
void kick(const Being *const being) const
void create(const std::string &name) const
PartyShareT getShareAutoItems() const
PartyShareT mShareExp
Definition: partyrecv.cpp:51
int CMSG_PARTY_MESSAGE
Definition: protocolout.cpp:91
Party * taParty
Definition: partyrecv.cpp:47
BeingId getID() const
Definition: avatar.h:149
BeingId getId() const
Definition: actorsprite.h:63
PartyShare ::T PartyShareT
Definition: partyshare.h:35
void setShareItems(const PartyShareT share) const
void notify(const unsigned int message)
void chat(const std::string &text) const
int CMSG_PARTY_SETTINGS
Definition: protocolout.cpp:89
PartyShareT mShareItems
Definition: partyrecv.cpp:52
void setShareExperience(const PartyShareT share) const
#define CAST_S32
Definition: cast.h:29
LocalPlayer * localPlayer
int CMSG_PARTY_INVITED
Definition: protocolout.cpp:87
void allowInvite(const bool allow) const
PartyMember * getMember(const BeingId id) const
Definition: party.cpp:98
void setShareAutoItems(const PartyShareT share) const
#define createOutPacket(name)
Definition: messageout.h:36
int CMSG_PARTY_CREATE
Definition: protocolout.cpp:85
int CMSG_PARTY_INVITE
Definition: protocolout.cpp:86
#define A_UNUSED
Definition: localconsts.h:151
Net::PartyHandler * partyHandler
Definition: net.cpp:90
void changeLeader(const std::string &name) const
Being * findBeingByName(const std::string &name, const ActorTypeT type) const
#define CAST_S16
Definition: cast.h:27
void inviteResponse(const int partyId, const bool accept) const
int CMSG_PARTY_LEAVE
Definition: protocolout.cpp:88
Definition: being.h:93
int CMSG_PARTY_KICK
Definition: protocolout.cpp:90
ActorManager * actorManager