ManaPlus
partyrecv.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-2019 The ManaPlus Developers
5  * Copyright (C) 2019-2021 Andrei Karas
6  *
7  * This file is part of The ManaPlus Client.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #include "net/ea/partyrecv.h"
24 
25 #include "actormanager.h"
26 #include "configuration.h"
27 #include "notifymanager.h"
28 #include "party.h"
29 
30 #include "being/localplayer.h"
31 
33 
34 #include "gui/windows/chatwindow.h"
36 
37 #include "net/messagein.h"
38 
40 
41 #include "utils/delete2.h"
42 
43 #include "debug.h"
44 
45 namespace Ea
46 {
47 
48 Party *taParty = nullptr;
49 
50 namespace PartyRecv
51 {
54 } // namespace PartyRecv
55 
57 {
58  if (msg.readUInt8("flag") != 0U)
60  else
62 }
63 
65  const PartyShareT exp)
66 {
67  switch (exp)
68  {
69  case PartyShare::YES:
71  break;
74  break;
75  case PartyShare::NO:
77  break;
80  break;
83  break;
86  break;
87  default:
90  break;
91  }
92 }
93 
95  const PartyShareT item)
96 {
97  switch (item)
98  {
99  case PartyShare::YES:
101  break;
104  break;
105  case PartyShare::NO:
107  break;
110  break;
113  break;
116  break;
117  default:
118  case PartyShare::UNKNOWN:
120  break;
121  }
122 }
123 
125 {
126  const BeingId id = msg.readBeingId("account id");
127  const std::string nick = msg.readString(24, "nick");
128  const int reason = msg.readUInt8("flag");
129  if (localPlayer == nullptr)
130  return;
131 
132  if (id == localPlayer->getId())
133  {
134  switch (reason)
135  {
136  case 0:
137  default:
139  break;
140 
141  case 1:
143  break;
144 
145  case 2:
147  break;
148 
149  case 3:
151  break;
152  }
153 
154  if (reason >= 2)
155  return;
156 
157  if (Ea::taParty != nullptr)
158  {
161  }
162 
164 
165  if ((socialWindow != nullptr) && (Ea::taParty != nullptr))
168  }
169  else
170  {
171  switch (reason)
172  {
173  case 0:
174  default:
176  break;
177 
178  case 1:
180  break;
181 
182  case 2:
184  break;
185 
186  case 3:
188  break;
189  }
190 
191  if (reason >= 2)
192  return;
193 
194  if (actorManager != nullptr)
195  {
196  Being *const b = actorManager->findBeing(id);
197  if ((b != nullptr) && b->getType() == ActorType::Player)
198  {
199  b->setParty(nullptr);
200  b->setPartyName("");
201  }
202  }
203  if (Ea::taParty != nullptr)
205  }
206 }
207 
209 {
210  const BeingId id = msg.readBeingId("account id");
211  PartyMember *m = nullptr;
212  if (Ea::taParty != nullptr)
213  m = Ea::taParty->getMember(id);
214  if (m != nullptr)
215  {
216  m->setX(msg.readInt16("x"));
217  m->setY(msg.readInt16("y"));
218  }
219  else
220  {
221  msg.readInt16("x");
222  msg.readInt16("y");
223  }
224 }
225 
227 {
229  if (config.getBoolValue("showChatHistory"))
230  partyTab->loadFromLogFile("#Party");
231 }
232 
233 } // namespace Ea
ActorManager * actorManager
int BeingId
Definition: beingid.h:30
#define CAST_S32
Definition: cast.h:30
ChatWindow * chatWindow
Definition: chatwindow.cpp:94
Being * findBeing(const BeingId id) const
BeingId getId() const
Definition: actorsprite.h:64
void setY(const int y)
Definition: avatar.h:135
void setX(const int x)
Definition: avatar.h:129
Definition: being.h:96
void setParty(Party *const party)
Definition: being.cpp:1307
void setPartyName(const std::string &name)
Definition: being.cpp:5246
ActorTypeT getType() const
Definition: being.h:116
void loadFromLogFile(const std::string &name)
Definition: chattab.cpp:510
bool getBoolValue(const std::string &key) const
Definition: party.h:63
void removeFromMembers()
Definition: party.cpp:201
void removeMember(const PartyMember *const member)
Definition: party.cpp:128
PartyMember * getMember(const BeingId id) const
Definition: party.cpp:99
void clearMembers()
Definition: party.h:122
bool removeTab(Guild *const guild)
Configuration config
#define delete2(var)
Definition: delete2.h:25
LocalPlayer * localPlayer
#define UNIMPLEMENTEDPACKETFIELD(field)
Definition: logger.h:59
bool msg(InputEvent &event)
Definition: chat.cpp:39
void processPartyLeave(Net::MessageIn &msg)
Definition: partyrecv.cpp:124
void createTab()
Definition: partyrecv.cpp:226
void processPartyItemSettingsContinue(Net::MessageIn &msg, const PartyShareT item)
Definition: partyrecv.cpp:94
void processPartyCreate(Net::MessageIn &msg)
Definition: partyrecv.cpp:56
PartyShareT mShareExp
Definition: partyrecv.cpp:52
void processPartyExpSettingsContinue(Net::MessageIn &msg, const PartyShareT exp)
Definition: partyrecv.cpp:64
void processPartyUpdateCoords(Net::MessageIn &msg)
Definition: partyrecv.cpp:208
PartyShareT mShareItems
Definition: partyrecv.cpp:53
Party * taParty
Definition: partyrecv.cpp:48
void notify(const unsigned int message)
@ PARTY_CREATE_FAILED
Definition: notifytypes.h:60
@ PARTY_EXP_SHARE_ON
Definition: notifytypes.h:72
@ PARTY_USER_KICKED
Definition: notifytypes.h:80
@ PARTY_EXP_SHARE_OFF
Definition: notifytypes.h:73
@ PARTY_EXP_SHARE_ERROR
Definition: notifytypes.h:74
@ PARTY_ITEM_SHARE_ON
Definition: notifytypes.h:75
@ PARTY_ITEM_SHARE_ERROR
Definition: notifytypes.h:77
@ PARTY_ITEM_SHARE_OFF
Definition: notifytypes.h:76
@ PARTY_USER_LEFT_DENY
Definition: notifytypes.h:79
@ PARTY_USER_KICK_DENY
Definition: notifytypes.h:81
@ NOT_POSSIBLE
Definition: partyshare.h:34
PartyShare ::T PartyShareT
Definition: partyshare.h:36
PartyTab * partyTab
Definition: partytab.cpp:45
SocialWindow * socialWindow