diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 9b15c81..cff4901 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -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; +} diff --git a/server/gameserver/roommgr.h b/server/gameserver/roommgr.h index 010447a..a9f9781 100644 --- a/server/gameserver/roommgr.h +++ b/server/gameserver/roommgr.h @@ -22,6 +22,9 @@ class RoomMgr : public a8::Singleton void _CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg); private: - std::map inactive_room_hash_; + Room* GetJoinableRoom(const std::string& account_id); + + private: + std::map inactive_room_hash_; std::map room_hash_; }; diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index c37ec14..691f8f9 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -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; //地图对象 } //玩家信息