优化roommgr

This commit is contained in:
aozhiwei 2020-05-26 16:42:00 +08:00
parent 51f901dfa1
commit ac3b59e2ce

View File

@ -18,8 +18,7 @@
#include "framework/cpp/httpclientpool.h"
#include "framework/cpp/utils.h"
const int ROOM_NUM_DOWN_LIMIT = 15;
const int ROOM_NUM_UP_LIMIT = 40;
const int ROOM_NUM_UP_LIMIT = 900;
const int HUM_NUM_DOWN_LIMIT = 1000;
static RoomType_e GetHumanRoomType(const cs::CMJoin& msg)
@ -143,26 +142,14 @@ Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg, const RoomType_e self_room
return group_rooms[self_room_type][rand() % group_rooms[self_room_type].size()];
}
if (self_room_type == RT_NewBrid) {
if (RoomNum() < ROOM_NUM_DOWN_LIMIT - 5) {
return CreateRoom(self_room_type);
}
return CreateRoom(self_room_type);
}
if (self_room_type == RT_MidBrid) {
if (RoomNum() < ROOM_NUM_DOWN_LIMIT - 5) {
return CreateRoom(self_room_type);
}
return CreateRoom(self_room_type);
}
for (int i = 0; i < RT_Max; ++i) {
if (RoomNum() > ROOM_NUM_DOWN_LIMIT - 5) {
for (Room* room : group_rooms[i]) {
return room;
}
} else {
if (i != self_room_type) {
for (Room* room : group_rooms[i]) {
return room;
}
}
for (Room* room : group_rooms[i]) {
return room;
}
}
return CreateRoom(self_room_type);
@ -322,8 +309,7 @@ bool RoomMgr::IsLimitJoin()
{
return RoomNum() >= ROOM_NUM_UP_LIMIT ||
(
RoomNum() >= ROOM_NUM_DOWN_LIMIT &&
App::Instance()->perf.alive_count >= HUM_NUM_DOWN_LIMIT
App::Instance()->perf.real_alive_count >= HUM_NUM_DOWN_LIMIT
);
}