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-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/ea/partyrecv.h"
23 
24 #include "actormanager.h"
25 #include "configuration.h"
26 #include "notifymanager.h"
27 #include "party.h"
28 
29 #include "being/localplayer.h"
30 
32 
33 #include "gui/windows/chatwindow.h"
35 
36 #include "net/messagein.h"
37 
39 
40 #include "utils/delete2.h"
41 
42 #include "debug.h"
43 
44 namespace Ea
45 {
46 
47 Party *taParty = nullptr;
48 
49 namespace PartyRecv
50 {
53 } // namespace PartyRecv
54 
56 {
57  if (msg.readUInt8("flag") != 0U)
59  else
61 }
62 
64  const PartyShareT exp)
65 {
66  switch (exp)
67  {
68  case PartyShare::YES:
70  break;
73  break;
74  case PartyShare::NO:
76  break;
79  break;
82  break;
85  break;
86  default:
89  break;
90  }
91 }
92 
94  const PartyShareT item)
95 {
96  switch (item)
97  {
98  case PartyShare::YES:
100  break;
103  break;
104  case PartyShare::NO:
106  break;
109  break;
112  break;
115  break;
116  default:
117  case PartyShare::UNKNOWN:
119  break;
120  }
121 }
122 
124 {
125  const BeingId id = msg.readBeingId("account id");
126  const std::string nick = msg.readString(24, "nick");
127  const int reason = msg.readUInt8("flag");
128  if (localPlayer == nullptr)
129  return;
130 
131  if (id == localPlayer->getId())
132  {
133  switch (reason)
134  {
135  case 0:
136  default:
138  break;
139 
140  case 1:
142  break;
143 
144  case 2:
146  break;
147 
148  case 3:
150  break;
151  }
152 
153  if (reason >= 2)
154  return;
155 
156  if (Ea::taParty != nullptr)
157  {
160  }
161 
163 
164  if ((socialWindow != nullptr) && (Ea::taParty != nullptr))
167  }
168  else
169  {
170  switch (reason)
171  {
172  case 0:
173  default:
175  break;
176 
177  case 1:
179  break;
180 
181  case 2:
183  break;
184 
185  case 3:
187  break;
188  }
189 
190  if (reason >= 2)
191  return;
192 
193  if (actorManager != nullptr)
194  {
195  Being *const b = actorManager->findBeing(id);
196  if ((b != nullptr) && b->getType() == ActorType::Player)
197  {
198  b->setParty(nullptr);
199  b->setPartyName("");
200  }
201  }
202  if (Ea::taParty != nullptr)
204  }
205 }
206 
208 {
209  const BeingId id = msg.readBeingId("account id");
210  PartyMember *m = nullptr;
211  if (Ea::taParty != nullptr)
212  m = Ea::taParty->getMember(id);
213  if (m != nullptr)
214  {
215  m->setX(msg.readInt16("x"));
216  m->setY(msg.readInt16("y"));
217  }
218  else
219  {
220  msg.readInt16("x");
221  msg.readInt16("y");
222  }
223 }
224 
226 {
228  if (config.getBoolValue("showChatHistory"))
229  partyTab->loadFromLogFile("#Party");
230 }
231 
232 } // namespace Ea
void removeMember(const PartyMember *const member)
Definition: party.cpp:127
ChatWindow * chatWindow
Definition: chatwindow.cpp:89
unsigned char readUInt8(const char *const str)
Definition: messagein.cpp:103
Definition: party.h:61
BeingId readBeingId(const char *const str)
Definition: messagein.cpp:223
void processPartyItemSettingsContinue(Net::MessageIn &msg, const PartyShareT item)
Definition: partyrecv.cpp:93
PartyShareT mShareExp
Definition: partyrecv.cpp:51
bool removeTab(Guild *const guild)
Party * taParty
Definition: partyrecv.cpp:47
BeingId getId() const
Definition: actorsprite.h:63
PartyTab * partyTab
Definition: partytab.cpp:44
PartyShare ::T PartyShareT
Definition: partyshare.h:35
Configuration config
int BeingId
Definition: beingid.h:29
bool msg(InputEvent &event)
Definition: chat.cpp:38
void clearMembers()
Definition: party.h:121
void notify(const unsigned int message)
#define delete2(var)
Definition: delete2.h:24
void setY(const int y)
Definition: avatar.h:134
void processPartyCreate(Net::MessageIn &msg)
Definition: partyrecv.cpp:55
void setPartyName(const std::string &name)
Definition: being.cpp:5246
PartyShareT mShareItems
Definition: partyrecv.cpp:52
void loadFromLogFile(const std::string &name)
Definition: chattab.cpp:509
int16_t readInt16(const char *const str)
Definition: messagein.cpp:130
bool getBoolValue(const std::string &key) const
void createTab()
Definition: partyrecv.cpp:225
#define CAST_S32
Definition: cast.h:29
void processPartyUpdateCoords(Net::MessageIn &msg)
Definition: partyrecv.cpp:207
LocalPlayer * localPlayer
void processPartyLeave(Net::MessageIn &msg)
Definition: partyrecv.cpp:123
Being * findBeing(const BeingId id) const
PartyMember * getMember(const BeingId id) const
Definition: party.cpp:98
ActorTypeT getType() const
Definition: being.h:115
SocialWindow * socialWindow
void processPartyExpSettingsContinue(Net::MessageIn &msg, const PartyShareT exp)
Definition: partyrecv.cpp:63
void setParty(Party *const party)
Definition: being.cpp:1306
std::string readString(int length, const char *const dstr)
Definition: messagein.cpp:367
Definition: being.h:93
void setX(const int x)
Definition: avatar.h:128
ActorManager * actorManager
#define UNIMPLEMENTEDPACKETFIELD(field)
Definition: logger.h:58
void removeFromMembers()
Definition: party.cpp:200