ManaPlus
Public Member Functions
EAthena::PartyHandler Class Reference

#include <partyhandler.h>

Inheritance diagram for EAthena::PartyHandler:
Ea::PartyHandler Net::PartyHandler

Public Member Functions

 PartyHandler ()
 
 ~PartyHandler ()
 
void create (const std::string &name) const
 
void invite (const std::string &name) const
 
void inviteResponse (const int partyId, const bool accept) const
 
void leave () const
 
void kick (const Being *const being) const
 
void kick (const std::string &name) const
 
void chat (const std::string &text) const
 
void setShareExperience (const PartyShareT share) const
 
void setShareItems (const PartyShareT share) const
 
void changeLeader (const std::string &name) const
 
void allowInvite (const bool allow) const
 
void setShareAutoItems (const PartyShareT share) const
 
PartyShareT getShareAutoItems () const
 
- Public Member Functions inherited from Ea::PartyHandler
 PartyHandler ()
 
void join (const int partyId) const
 
PartyShareT getShareExperience () const
 
PartyShareT getShareItems () const
 
void clear () const
 
ChatTabgetTab () const
 
- Public Member Functions inherited from Net::PartyHandler
 PartyHandler ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Ea::PartyHandler
static void reload ()
 

Detailed Description

Definition at line 31 of file partyhandler.h.

Constructor & Destructor Documentation

◆ PartyHandler()

EAthena::PartyHandler::PartyHandler ( )

Definition at line 46 of file partyhandler.cpp.

46  :
48 {
49  partyHandler = this;
50 }
Net::PartyHandler * partyHandler
Definition: net.cpp:94

References partyHandler.

◆ ~PartyHandler()

EAthena::PartyHandler::~PartyHandler ( )
virtual

Reimplemented from Ea::PartyHandler.

Definition at line 52 of file partyhandler.cpp.

53 {
54  partyHandler = nullptr;
55 }

References partyHandler.

Member Function Documentation

◆ allowInvite()

void EAthena::PartyHandler::allowInvite ( const bool  allow) const
virtual

Implements Net::PartyHandler.

Definition at line 190 of file partyhandler.cpp.

191 {
192  createOutPacket(CMSG_PARTY_ALLOW_INVITES);
193  outMsg.writeInt8(CAST_S8(allow ? 1 : 0), "allow");
194 }
#define CAST_S8
Definition: cast.h:26
#define createOutPacket(name)
Definition: messageout.h:37

References CAST_S8, and createOutPacket.

◆ changeLeader()

void EAthena::PartyHandler::changeLeader ( const std::string &  name) const
virtual

Implements Net::PartyHandler.

Definition at line 178 of file partyhandler.cpp.

179 {
180  if (actorManager == nullptr)
181  return;
182  const Being *const being = actorManager->findBeingByName(
183  name, ActorType::Player);
184  if (being == nullptr)
185  return;
186  createOutPacket(CMSG_PARTY_CHANGE_LEADER);
187  outMsg.writeBeingId(being->getId(), "account id");
188 }
ActorManager * actorManager
Being * findBeingByName(const std::string &name, const ActorTypeT type) const
BeingId getId() const
Definition: actorsprite.h:64
Definition: being.h:96

References actorManager, createOutPacket, ActorManager::findBeingByName(), ActorSprite::getId(), and ActorType::Player.

◆ chat()

void EAthena::PartyHandler::chat ( const std::string &  text) const
virtual

Implements Net::PartyHandler.

Definition at line 126 of file partyhandler.cpp.

127 {
128  createOutPacket(CMSG_PARTY_MESSAGE);
129  const std::string mes = std::string(localPlayer->getName()).append(
130  " : ").append(text);
131  if (packetVersion >= 20151001)
132  {
133  outMsg.writeInt16(CAST_S16(mes.length() + 4), "len");
134  outMsg.writeString(mes, CAST_S32(mes.length()), "nick : message");
135  }
136  else
137  {
138  outMsg.writeInt16(CAST_S16(mes.length() + 4 + 1), "len");
139  outMsg.writeString(mes, CAST_S32(mes.length()), "nick : message");
140  outMsg.writeInt8(0, "null char");
141  }
142 }
#define CAST_S16
Definition: cast.h:28
#define CAST_S32
Definition: cast.h:30
const std::string & getName() const
Definition: being.h:232
int packetVersion
Definition: client.cpp:125
LocalPlayer * localPlayer

References CAST_S16, CAST_S32, createOutPacket, Being::getName(), localPlayer, and packetVersion.

◆ create()

void EAthena::PartyHandler::create ( const std::string &  name) const
virtual

Implements Net::PartyHandler.

Definition at line 57 of file partyhandler.cpp.

58 {
59  createOutPacket(CMSG_PARTY_CREATE);
60  outMsg.writeString(name.substr(0, 23), 24, "party name");
61 }

References createOutPacket.

◆ getShareAutoItems()

PartyShareT EAthena::PartyHandler::getShareAutoItems ( ) const
virtual

Implements Net::PartyHandler.

Definition at line 196 of file partyhandler.cpp.

197 {
199 }
PartyShareT mShareAutoItems
Definition: partyrecv.cpp:53

References EAthena::PartyRecv::mShareAutoItems.

◆ invite()

void EAthena::PartyHandler::invite ( const std::string &  name) const
virtual

Implements Net::PartyHandler.

Definition at line 63 of file partyhandler.cpp.

64 {
65  if (actorManager == nullptr)
66  return;
67  const Being *const being = actorManager->findBeingByName(
68  name, ActorType::Player);
69  if (being != nullptr)
70  {
71  createOutPacket(CMSG_PARTY_INVITE);
72  outMsg.writeBeingId(being->getId(), "account id");
73  }
74  else
75  {
76  if (packetVersion < 20070227)
77  return;
78  createOutPacket(CMSG_PARTY_INVITE2);
79  outMsg.writeString(name, 24, "nick");
80  }
81 }

References actorManager, createOutPacket, ActorManager::findBeingByName(), ActorSprite::getId(), packetVersion, and ActorType::Player.

◆ inviteResponse()

void EAthena::PartyHandler::inviteResponse ( const int  partyId,
const bool  accept 
) const
virtual

Implements Net::PartyHandler.

Definition at line 83 of file partyhandler.cpp.

85 {
86  if (localPlayer != nullptr)
87  {
88  createOutPacket(CMSG_PARTY_INVITED2);
89  outMsg.writeInt32(partyId, "party id");
90  outMsg.writeInt8(CAST_S8(accept ? 1 : 0), "accept");
91  }
92 }
TcpNet::Socket accept(const TcpNet::Socket sock)
Definition: sdltcpnet.cpp:198

References TcpNet::accept(), CAST_S8, createOutPacket, and localPlayer.

◆ kick() [1/2]

void EAthena::PartyHandler::kick ( const Being *const  being) const
virtual

Implements Net::PartyHandler.

Definition at line 99 of file partyhandler.cpp.

100 {
101  if (being != nullptr)
102  {
103  createOutPacket(CMSG_PARTY_KICK);
104  outMsg.writeBeingId(being->getId(), "account id");
105  outMsg.writeString(being->getName(), 24, "player name");
106  }
107 }

References createOutPacket, ActorSprite::getId(), and Being::getName().

◆ kick() [2/2]

void EAthena::PartyHandler::kick ( const std::string &  name) const
virtual

Implements Net::PartyHandler.

Definition at line 109 of file partyhandler.cpp.

110 {
111  if (Ea::taParty == nullptr)
112  return;
113 
114  const PartyMember *const m = Ea::taParty->getMember(name);
115  if (m == nullptr)
116  {
118  return;
119  }
120 
121  createOutPacket(CMSG_PARTY_KICK);
122  outMsg.writeBeingId(m->getID(), "account id");
123  outMsg.writeString(name, 24, "player name");
124 }
BeingId getID() const
Definition: avatar.h:150
PartyMember * getMember(const BeingId id) const
Definition: party.cpp:99
Party * taParty
Definition: partyrecv.cpp:48
void notify(const unsigned int message)
@ PARTY_USER_NOT_IN_PARTY
Definition: notifytypes.h:83

References createOutPacket, Avatar::getID(), Party::getMember(), NotifyManager::notify(), NotifyTypes::PARTY_USER_NOT_IN_PARTY, and Ea::taParty.

◆ leave()

void EAthena::PartyHandler::leave ( ) const
virtual

Implements Net::PartyHandler.

Definition at line 94 of file partyhandler.cpp.

95 {
96  createOutPacket(CMSG_PARTY_LEAVE);
97 }

References createOutPacket.

◆ setShareAutoItems()

void EAthena::PartyHandler::setShareAutoItems ( const PartyShareT  share) const
virtual

Implements Net::PartyHandler.

Definition at line 201 of file partyhandler.cpp.

202 {
204 }

References EAthena::PartyRecv::mShareAutoItems.

◆ setShareExperience()

void EAthena::PartyHandler::setShareExperience ( const PartyShareT  share) const
virtual

Implements Net::PartyHandler.

Definition at line 145 of file partyhandler.cpp.

146 {
147  if (share == PartyShare::NOT_POSSIBLE)
148  return;
149 
150  createOutPacket(CMSG_PARTY_SETTINGS);
151  if (packetVersion >= 20090603)
152  {
153  outMsg.writeInt32(CAST_S32(share), "share exp");
154  outMsg.writeInt16(CAST_S16(Ea::PartyRecv::mShareItems),
155  "share items");
156  }
157  else
158  {
159  outMsg.writeInt32(CAST_S32(share), "share exp");
160  }
161 }
PartyShareT mShareItems
Definition: partyrecv.cpp:53
@ NOT_POSSIBLE
Definition: partyshare.h:34

References CAST_S16, CAST_S32, createOutPacket, Ea::PartyRecv::mShareItems, PartyShare::NOT_POSSIBLE, and packetVersion.

◆ setShareItems()

void EAthena::PartyHandler::setShareItems ( const PartyShareT  share) const
virtual

Implements Net::PartyHandler.

Definition at line 164 of file partyhandler.cpp.

165 {
166  if (share == PartyShare::NOT_POSSIBLE)
167  return;
168 
169  createOutPacket(CMSG_PARTY_SETTINGS);
170  if (packetVersion >= 20090603)
171  {
172  outMsg.writeInt32(CAST_S32(Ea::PartyRecv::mShareExp),
173  "share exp");
174  outMsg.writeInt16(CAST_S16(share), "share items");
175  }
176 }
PartyShareT mShareExp
Definition: partyrecv.cpp:52

References CAST_S16, CAST_S32, createOutPacket, Ea::PartyRecv::mShareExp, PartyShare::NOT_POSSIBLE, and packetVersion.


The documentation for this class was generated from the following files: