1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-31 13:37:45 +00:00
sapphire/src/servers/sapphire_zone/Social/Group.h

115 lines
3.2 KiB
C
Raw Normal View History

2017-11-21 13:20:43 +00:00
#ifndef _GROUP_H
#define _GROUP_H
2018-03-09 09:50:35 -03:00
#include <Common.h>
#include <Network/PacketDef/Zone/ServerZoneDef.h>
#include <Forwards.h>
2018-01-25 15:32:33 -02:00
#include <sapphire_zone/Forwards.h>
2017-11-21 13:20:43 +00:00
#include <boost/enable_shared_from_this.hpp>
#include <set>
#include <cstdint>
#include <map>
2018-03-09 09:50:35 -03:00
#include <chrono>
2017-11-21 13:20:43 +00:00
namespace Core {
namespace Social {
2017-11-21 13:20:43 +00:00
struct GroupMember
{
2018-03-15 13:21:17 -03:00
//uint64_t inviterId;
uint64_t characterId; // todo: maybe just use id..
//std::string name;
2017-11-21 13:20:43 +00:00
uint32_t role;
};
enum class GroupType : uint8_t
{
None,
Party,
2017-11-21 17:01:05 +00:00
FriendList,
2017-11-21 13:20:43 +00:00
FreeCompany,
Linkshell,
FreeCompanyPetition,
Blacklist,
ContentGroup
};
2018-03-09 12:09:05 -03:00
class Group
2017-11-21 13:20:43 +00:00
{
2017-12-07 04:15:20 -02:00
public:
Group( uint64_t id, uint64_t ownerId ) :
m_id( id ), m_ownerId( m_ownerId ) {};
2017-12-07 04:15:20 -02:00
bool isParty() const;
bool isFriendList() const;
bool isFreeCompany() const;
bool isLinkshell() const;
bool isFreeCompanyPetition() const;
bool isBlacklist() const;
bool isContentGroup() const;
2018-03-15 13:21:17 -03:00
// New group system: return error code for logmessage
//TODO: change the member models!!!!!!!
virtual uint32_t addMember( uint64_t characterId );
virtual uint32_t addInvite( uint64_t characterId );
virtual Core::Network::Packets::GamePacketPtr processInvite( uint64_t recipientId, uint64_t senderId );
virtual Core::Network::Packets::GamePacketPtr addMember2( Entity::PlayerPtr pSender, Entity::PlayerPtr pRecipient, uint64_t senderId = 0, uint64_t recipientId = 0 );
2018-03-15 13:21:17 -03:00
virtual Core::Network::Packets::GamePacketPtr inviteMember2( Entity::PlayerPtr pSender, Entity::PlayerPtr pRecipient, uint64_t senderId = 0, uint64_t recipientId = 0 );
virtual Core::Network::Packets::GamePacketPtr removeMember2( Entity::PlayerPtr pSender, Entity::PlayerPtr pRecipient, uint64_t senderId = 0, uint64_t recipientId = 0 );
//virtual Core::Network::Packets::GamePacketPtr kickMember( PlayerPtr pSender, PlayerPtr pRecipient, uint64_t senderId = 0, uint64_t recipientId = 0 );
2017-12-07 04:15:20 -02:00
virtual void sendPacketToMembers( Core::Network::Packets::GamePacketPtr pPacket, bool invitesToo = false );
2018-03-15 13:21:17 -03:00
//virtual void populateGroupMembers();
2017-12-07 04:15:20 -02:00
/*! generates a player entry used for lists (social, etc) */
2018-03-15 13:21:17 -03:00
//
2017-12-07 13:17:15 -02:00
2018-03-15 13:21:17 -03:00
/*! access member vector */
std::set< uint64_t >& getMembers();
2017-12-07 13:17:15 -02:00
2018-03-15 13:21:17 -03:00
/*! access invite vector */
std::set< uint64_t >& getInvites();
2017-12-07 04:15:20 -02:00
/*! get container limit */
uint32_t getCapacity() const;
2018-03-15 13:21:17 -03:00
/*! get total size of group (members + invites) */
uint32_t Group::getTotalSize() const;
bool hasMember( uint64_t memberId ) const;
bool hasInvite( uint64_t inviteId ) const;
protected:
2017-11-21 13:20:43 +00:00
GroupType m_type{ GroupType::None };
uint64_t m_id{ 0 };
uint64_t m_ownerId{ 0 };
uint32_t m_maxCapacity{ 250 };
uint32_t m_maxRoles{ 50 };
2018-03-09 09:50:35 -03:00
std::chrono::steady_clock::time_point m_createTime{ std::chrono::steady_clock::now() };
2018-03-15 13:21:17 -03:00
std::set< uint64_t > m_groupMembers;
std::set< uint64_t > m_groupInvites;
2017-11-21 13:20:43 +00:00
std::map< uint64_t, GroupMember > m_members;
std::map< uint64_t, GroupMember > m_invites; // <recipient, groupmember (which contains senderId)>
2017-12-07 04:15:20 -02:00
private:
2017-11-21 13:20:43 +00:00
2017-12-07 17:50:54 -02:00
/*virtual void load();
2017-11-21 17:01:05 +00:00
virtual void update();
2017-12-07 17:50:54 -02:00
virtual void disband();*/
2017-11-21 13:20:43 +00:00
};
}
2018-03-09 12:09:05 -03:00
using GroupPtr = boost::shared_ptr< Social::Group >;
2017-11-21 13:20:43 +00:00
};
#endif // ! _GROUP_H