Files
mir_server/server/LogicServer/base/OfflineCenterUserMgr.h

114 lines
3.4 KiB
C
Raw Permalink Normal View History

2025-01-09 17:45:40 +08:00
#pragma once
/*
*线线
*
OnLoadActorOther
*/
#include <map>
#include <vector>
#include <functional>
class CActor;
//离线玩家的信息管理器
struct COfflineCenterUser:
public ActorOfflineMsg
{
CUserItem* m_Equips[itMaxEquipPos]; //装备信息
std::vector<CSkillSubSystem::SKILLDATA> m_Skilldata;// 技能信息
std::map<int, std::vector<StrengthInfo> > m_nStrengths;// 强化信息
std::vector<CNewTitleSystem::NEWTITLEDATA> m_NewTitleDataList;// 称号信息
std::vector<CAlmirahItem> m_Almirah; //时装信息
std::vector<GhostData> m_ghost; //神魔信息
std::vector<SoulWeaponNetData> vSoulWeapon; //兵魂信息
};
class COfflineCenterUserMgr:
public CComponent
{
public:
COfflineCenterUserMgr():m_FixedSizeAllocator(_T("OfflineCenterUserAllocator"))
{
}
typedef std::map<unsigned int,COfflineCenterUser* > OfflineUserMap; //玩家数据查找的迭代器
/*
* Comments:线
* Param unsigned int nActorId:actorid
*Parambool &isExist
* @Return COfflineCenterUser *:
*/
COfflineCenterUser * AddCenterOffLineUser(unsigned int nActorId,bool &isExist);
//处理跨服玩家 数据返回
void OnCenterReturnData(CDataPacketReader& reader);
//topackt
void ViewOffLineActorToPacket(unsigned int nActorId, CDataPacket& data);
/*
* Comments:actorid返回玩家的指针
* Param unsigned int nActorId:actorid
* Param bool loadWhenNotExist:DB装载
* @Return COfflineCenterUser *:
*/
inline COfflineCenterUser * GetUserByActorId(unsigned int nActorId)
{
if(nActorId ==0) return NULL;
OfflineUserMap::iterator iter = m_actoridMap.find(nActorId);
if (iter == m_actoridMap.end())
{
return NULL;
}
return iter->second;
}
/*
* Comments:
* Param unsigned int nActorID: actorid
* @Return void:
*/
void RemoveUser(unsigned int nActorID);
//删除了所有的玩家的信息
void RemoveAllUser();
//销毁组件
virtual VOID Destroy()
{
RemoveAllUser();
}
//初始化
bool Initialize()
{
return true;
}
using CallBack = std::function<void(CActor*)>;
//装载玩家的离线消息
void LoadCenterUser(unsigned nActorId, unsigned nViewerId=0, int nsys = enEuipSystemID,int ncmd = sGetOtherEqip);
void viewCenterByOfflineUser(COfflineCenterUser *pUser,unsigned int nActorId,int nsys = enEuipSystemID,int ncmd = sGetOtherEqip);
//Comments:查看离线玩家的信息 优先使用actorid 如果actorid==0 则使用name
void ViewCenterOffLineActor(CActor *pActor, unsigned int nActorId, int nsys = enEuipSystemID,int ncmd = sGetOtherEqip);
void viewCenterOfflineUserData(COfflineCenterUser *pUser, CDataPacket& data);
public:
//装载玩家的装备信息
void OnLoadCenterActorData(unsigned int nActorId, CDataPacketReader &reader);
void SetCenterOfflineUserData(CDataPacketReader& data);
private:
OfflineUserMap m_actoridMap; //玩家的actorid到数据的索引每天23点55分左右会重置
std::map<unsigned int, std::vector<std::function<void(COfflineCenterUser*)>>> m_noticeMap; //通知的列表
CSingleObjectAllocator<COfflineCenterUser> m_FixedSizeAllocator;
};