2021-11-27 00:53:57 +01:00
|
|
|
#pragma once
|
2017-08-28 18:36:51 +02:00
|
|
|
|
2018-10-25 12:44:51 +11:00
|
|
|
#include <memory>
|
2017-08-28 18:36:51 +02:00
|
|
|
#include <map>
|
2021-11-27 00:53:57 +01:00
|
|
|
#include <vector>
|
2018-12-02 02:01:41 +01:00
|
|
|
#include "ForwardsZone.h"
|
2017-08-28 18:36:51 +02:00
|
|
|
|
2018-12-02 02:01:41 +01:00
|
|
|
namespace Sapphire::World::Manager
|
2018-10-28 21:53:21 +01:00
|
|
|
{
|
2017-08-28 18:36:51 +02:00
|
|
|
|
2021-12-07 00:13:18 +01:00
|
|
|
enum Hierarchy : uint32_t
|
2021-12-04 01:02:25 +01:00
|
|
|
{
|
|
|
|
NONE_1 = 0x0,
|
|
|
|
MASTER = 0x1,
|
|
|
|
LEADER = 0x2,
|
|
|
|
MEMBER = 0x3,
|
|
|
|
INVITE = 0x4,
|
|
|
|
MAX_0 = 0x7,
|
|
|
|
};
|
|
|
|
|
2020-03-01 01:00:57 +11:00
|
|
|
class LinkshellMgr
|
2018-10-28 21:53:21 +01:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::map< uint64_t, LinkshellPtr > m_linkshellIdMap;
|
|
|
|
std::map< std::string, LinkshellPtr > m_linkshellNameMap;
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
LinkshellPtr getLinkshellByName( const std::string& name );
|
2017-08-28 18:36:51 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
public:
|
2020-03-01 01:00:57 +11:00
|
|
|
LinkshellMgr() = default;
|
2017-08-28 18:36:51 +02:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
// initialize all linkshells from db to memory
|
2018-10-28 21:53:21 +01:00
|
|
|
bool loadLinkshells();
|
2021-12-04 12:29:54 +01:00
|
|
|
void writeLinkshell( uint64_t lsId );
|
2021-11-27 00:53:57 +01:00
|
|
|
|
|
|
|
// create new linkshell entry and insert into db
|
|
|
|
LinkshellPtr createLinkshell( const std::string& name, Entity::Player& player );
|
|
|
|
|
2021-12-03 22:21:18 +01:00
|
|
|
void finishLinkshellCreation( const std::string& name, uint32_t result, Entity::Player& player );
|
|
|
|
|
2021-12-07 00:02:41 +01:00
|
|
|
void invitePlayer( Entity::Player& sourcePlayer, Entity::Player& invitedPlayer, uint64_t linkshellId );
|
2021-12-09 23:38:23 +01:00
|
|
|
void kickPlayer( Entity::Player& sourcePlayer, Entity::Player& kickedPlayer, uint64_t linkshellId );
|
2021-12-04 21:53:04 +01:00
|
|
|
|
2021-12-12 13:06:15 +01:00
|
|
|
void addLeader( Entity::Player& sourcePlayer, Entity::Player& newLeaderPlayer, uint64_t linkshellId );
|
|
|
|
void removeLeader( Entity::Player& sourcePlayer, Entity::Player& leaderPlayer, uint64_t linkshellId );
|
|
|
|
void declineLeader( Entity::Player& sourcePlayer, uint64_t linkshellId );
|
2021-12-12 15:56:45 +01:00
|
|
|
void changeMaster( Entity::Player& sourcePlayer, Entity::Player& nextMasterPlayer, uint64_t linkshellId );
|
2021-12-12 13:06:15 +01:00
|
|
|
|
2021-12-04 21:53:04 +01:00
|
|
|
void sendLinkshellList( Entity::Player& player );
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
// get all linkshells associated with player
|
|
|
|
const std::vector< LinkshellPtr > getPlayerLinkshells( Entity::Player& player ) const;
|
|
|
|
|
|
|
|
LinkshellPtr getLinkshellById( uint64_t lsId );
|
2021-12-04 12:29:54 +01:00
|
|
|
|
2021-12-05 00:37:52 +01:00
|
|
|
void leaveLinkshell( uint64_t lsId, uint64_t characterId );
|
|
|
|
void joinLinkshell( uint64_t lsId, uint64_t characterId );
|
|
|
|
|
2021-12-04 12:29:54 +01:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
};
|
2017-08-28 18:36:51 +02:00
|
|
|
|
|
|
|
}
|