This commit is contained in:
aozhiwei 2019-03-13 18:37:43 +08:00
parent 1ad123d4c1
commit 6197a080af
3 changed files with 28 additions and 8 deletions

View File

@ -18,5 +18,21 @@ void RoomMgr::UnInit()
void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
{
cs::SMJoinedNotify notifymsg;
Room* room = GetJoinableRoom(msg.account_id());
if (room) {
} else {
}
GGListener::Instance()->SendToClient(hdr.socket_handle, hdr.seqid, notifymsg);
}
Room* RoomMgr::GetJoinableRoom(const std::string& account_id)
{
for (auto& pair : inactive_room_hash_) {
if (!pair.second->IsFull() && !pair.second->GetPlayerByAccountId(account_id)) {
return pair.second;
}
}
return nullptr;
}

View File

@ -22,6 +22,9 @@ class RoomMgr : public a8::Singleton<RoomMgr>
void _CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg);
private:
std::map<long, long, Room*> inactive_room_hash_;
Room* GetJoinableRoom(const std::string& account_id);
private:
std::map<long long, Room*> inactive_room_hash_;
std::map<long long, Room*> room_hash_;
};

View File

@ -70,9 +70,10 @@ message MFVector2D
message MFPlace
{
optional string name = 1; //
optional MFVector2D pos = 2; //
}
message MFObject
message MFMapObject
{
//type
optional MFVector2D pos = 1; //
@ -536,7 +537,6 @@ message CMVoice
optional string msg = 2; //
}
//endcmmsg
//
@ -553,11 +553,12 @@ message SMJoinedNotify
//
message SMMapInfo
{
optional int32 width = 1; //
optional int32 height = 2; //
optional int32 speed = 3; //
repeated MFPlace places = 4; //
repeated MFObject objects = 5; //
optional int32 map_id = 1; //id
optional int32 width = 2; //
optional int32 height = 3; //
optional int32 seed = 4; //zzz
repeated MFPlace places = 5; //zzz
repeated MFMapObject objects = 6; //
}
//