2020-12-08 11:15:16 +08:00

72 lines
2.2 KiB
C++

#pragma once
#include <a8/timer_attacher.h>
namespace cs
{
class CMJoin;
class CMReconnect;
}
class Room;
class RoomMgr : public a8::Singleton<RoomMgr>
{
public:
enum { HID = HID_RoomMgr };
private:
RoomMgr() {};
friend class a8::Singleton<RoomMgr>;
public:
void Init();
void UnInit();
void Update(int delta_time);
void _CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg);
void _CMReconnect(f8::MsgHdr& hdr, const cs::CMReconnect& msg);
void ActiveRoom(long long room_uuid);
int RoomNum();
int OverRoomNum();
Room* GetRoomByUuid(long long uuid);
void AddOverRoom(long long room_uuid);
bool IsGM(const std::string& account_id);
private:
void InstallReportStateTimer();
Room* GetRoomByIdx(int room_idx);
Room* GetJoinableRoom(const cs::CMJoin& msg,
const RoomType_e self_room_type,
int game_times,
int creator_register_time,
int proto_version,
int channel);
void ReportServerState(int instance_id, const std::string& host, int port);
void FreeOverRoom(long long room_uuid);
bool IsLimitJoin();
int AllocRoomIdx();
Room* CreateRoom(const cs::CMJoin& msg,
RoomType_e room_type,
int game_times,
int creator_register_time,
int creator_proto_version,
int creator_channel,
int map_id);
void JoinErrorHandle(const cs::CMJoin& msg, int error_code, int socket_handle);
std::string GenTeamHashData(const std::string& team_uuid, std::map<std::string, long long>* team_hash);
void OnJoinRoomOk(const cs::CMJoin& msg, Player* hum);
void TeamRoomTimeOut(const std::string& team_uuid);
private:
int current_room_idx_ = 0;
std::map<long long, Room*> inactive_room_hash_;
std::map<long long, Room*> room_hash_;
std::map<int, Room*> room_idx_hash_;
std::map<long long, Room*> over_room_hash_;
a8::TimerAttacher reportstate_timer_attacher_;
std::map<std::string, int> gm_hash_;
std::map<std::string, std::map<std::string, long long>> team_room_hash_;
};