1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-10 04:37:45 +00:00
sapphire/src/world/Manager/FreeCompanyMgr.h

64 lines
1.8 KiB
C
Raw Normal View History

#pragma once
#include <memory>
#include <map>
#include <vector>
#include "ForwardsZone.h"
#include "FreeCompany/FreeCompany.h"
namespace Sapphire::World::Manager
{
2023-02-06 15:49:47 +01:00
class FreeCompanyMgr
{
private:
2023-02-08 15:22:26 +01:00
std::unordered_map< uint64_t, FreeCompanyPtr > m_fcIdMap;
std::unordered_map< std::string, FreeCompanyPtr > m_fcNameMap;
2023-02-08 15:22:26 +01:00
/*! map used for easy lookup of char id to fc id */
std::unordered_map< uint64_t, uint64_t > m_charaIdToFcIdMap;
uint64_t m_maxFcId{ 0 };
uint32_t m_onlinePlayers{ 0 };
public:
FreeCompanyMgr() = default;
// initialize all fcs from db to memory
bool loadFreeCompanies();
void writeFreeCompany( uint64_t fcId );
// create new fc entry and insert into db
FreeCompanyPtr createFreeCompany( const std::string& name, const std::string& tag, Entity::Player& player );
bool renameFreeCompany( uint64_t fcId, const std::string& name, const std::string& tag, Entity::Player& player );
void addMember( uint64_t fcId, uint64_t memberId );
2023-02-06 15:49:47 +01:00
void sendFcInviteList( Entity::Player& player );
void sendFcStatus( Entity::Player& player );
void sendFreeCompanyStatus( Entity::Player& player );
void dbInsertMember( uint64_t fcId, uint64_t characterId, uint8_t hierarchyId );
void dbInsertFc( const FreeCompany& fc );
void dbUpdateFc( const FreeCompany& fc );
std::vector< FreeCompanyPtr > dbSelectFcsAll();
std::vector< FreeCompany::FcMember > dbSelectMembersByFc( uint64_t fcId );
// get fc associated with player
FreeCompanyPtr getPlayerFreeCompany( uint64_t characterId );
FreeCompanyPtr getFreeCompanyById( uint64_t fcId );
2023-02-08 15:22:26 +01:00
FreeCompanyPtr getFreeCompanyByName( const std::string& name );
void onFcLogin( uint64_t characterId );
void onFcLogout( uint64_t characterId );
2023-02-08 15:22:26 +01:00
void onSignPetition( Entity::Player& source, Entity::Player& target );
};
}