merge master

This commit is contained in:
aozhiwei 2020-07-09 21:47:21 +08:00
commit 726ee63335
6 changed files with 59 additions and 11 deletions

View File

@ -48,6 +48,7 @@ void Room::InitData(RoomInitInfo& init_info)
room_uuid_ = init_info.room_uuid; room_uuid_ = init_info.room_uuid;
room_type_ = init_info.room_type; room_type_ = init_info.room_type;
creator_game_times_ = init_info.creator_game_times; creator_game_times_ = init_info.creator_game_times;
creator_register_time_ = init_info.creator_register_time;
map_tpl_name_ = init_info.map_tpl_name; map_tpl_name_ = init_info.map_tpl_name;
grid_service = init_info.grid_service; grid_service = init_info.grid_service;
@ -908,8 +909,8 @@ void Room::UpdateGasInactive()
battle_start_frameno_ = GetFrameNo(); battle_start_frameno_ = GetFrameNo();
if (human_hash_.size() < GetRoomMaxPlayerNum()) { if (human_hash_.size() < GetRoomMaxPlayerNum()) {
CreateAndroid(GetRoomMaxPlayerNum() - human_hash_.size()); CreateAndroid(GetRoomMaxPlayerNum() - human_hash_.size());
NotifyUiUpdate();
} }
NotifyUiUpdate();
CombineTeam(); CombineTeam();
NotifyGameStart(); NotifyGameStart();
NotifyWxVoip(); NotifyWxVoip();
@ -2390,7 +2391,7 @@ a8::Vec2 Room::GetDefaultBornPoint()
void Room::AddPlayerPostProc(Player* hum) void Room::AddPlayerPostProc(Player* hum)
{ {
if (room_type_ == RT_NewBrid) { if (room_type_ == RT_NewBrid) {
CreateAndroid(20 + rand() % 10); CreateAndroid(10 + rand() % 5);
xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * (1 + rand() % 3), xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * (1 + rand() % 3),
a8::XParams() a8::XParams()
.SetSender(hum), .SetSender(hum),
@ -2566,8 +2567,12 @@ void Room::NewBieRoomStart()
first_newbie_ = pair.second; first_newbie_ = pair.second;
break; break;
} }
int protect_time = MetaMgr::Instance()->level0room_robot_protect_time;
if (creator_game_times_ > 0) {
protect_time = 6;
}
xtimer.AddDeadLineTimerAndAttach xtimer.AddDeadLineTimerAndAttach
(SERVER_FRAME_RATE * MetaMgr::Instance()->level0room_robot_protect_time, (SERVER_FRAME_RATE * protect_time,
a8::XParams() a8::XParams()
.SetSender(this), .SetSender(this),
[] (const a8::XParams& param) [] (const a8::XParams& param)
@ -2848,6 +2853,13 @@ void Room::ShuaLastGas()
bool Room::IsMiniRoom() bool Room::IsMiniRoom()
{ {
if (GetRoomType() == RT_NewBrid ||
GetRoomType() == RT_MidBrid) {
if (a8::BetweenDays(Global::g_nowtime, creator_register_time_) > 0) {
return false;
}
}
return return
GetRoomType() == RT_NewBrid || GetRoomType() == RT_NewBrid ||
GetRoomType() == RT_MidBrid || GetRoomType() == RT_MidBrid ||

View File

@ -235,6 +235,7 @@ private:
int level1room_born_point_uniid_ = 0; int level1room_born_point_uniid_ = 0;
bool show_handed_ = false; bool show_handed_ = false;
int creator_game_times_ = 0; int creator_game_times_ = 0;
int creator_register_time_ = 0;
int current_teamid_ = 0; int current_teamid_ = 0;
int current_uniid_ = FIXED_OBJECT_MAXID; int current_uniid_ = FIXED_OBJECT_MAXID;

View File

@ -87,6 +87,30 @@ static RoomType_e GetHumanRoomType(const cs::CMJoin& msg, int& game_times)
} }
} }
time_t register_time = f8::ExtractRegisterTimeFromSessionId(msg.session_id());
#if 1
if (!msg.team_uuid().empty()) {
bool has_new_brid = false;
for (auto& team_member : msg.team_members()) {
if (team_member.create_time() != 0 &&
a8::BetweenDays(Global::g_nowtime, team_member.create_time()) <= 0) {
has_new_brid = true;
break;
}
}
if (has_new_brid) {
return RT_OldBrid1;
} else {
return RT_OldBrid2;
}
} else {
if (a8::BetweenDays(Global::g_nowtime, register_time) <= 0) {
return RT_OldBrid1;
} else {
return RT_OldBrid2;
}
}
#else
if (rank >= 0 && rank <= 10) { if (rank >= 0 && rank <= 10) {
return RT_OldBrid1; return RT_OldBrid1;
} else if (rank >= 11 && rank <= 17) { } else if (rank >= 11 && rank <= 17) {
@ -96,6 +120,7 @@ static RoomType_e GetHumanRoomType(const cs::CMJoin& msg, int& game_times)
} else { } else {
return RT_OldBrid1; return RT_OldBrid1;
} }
#endif
} }
void RoomMgr::Init() void RoomMgr::Init()
@ -135,7 +160,8 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
} }
int game_times = 0; int game_times = 0;
RoomType_e self_room_type = GetHumanRoomType(msg, game_times); RoomType_e self_room_type = GetHumanRoomType(msg, game_times);
Room* room = GetJoinableRoom(msg, self_room_type, game_times); time_t register_time = f8::ExtractRegisterTimeFromSessionId(msg.session_id());
Room* room = GetJoinableRoom(msg, self_room_type, game_times, register_time);
if (!room) { if (!room) {
JoinErrorHandle(msg, 3, hdr.socket_handle); JoinErrorHandle(msg, 3, hdr.socket_handle);
return; return;
@ -165,7 +191,10 @@ int RoomMgr::OverRoomNum()
return over_room_hash_.size(); return over_room_hash_.size();
} }
Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg, const RoomType_e self_room_type, int game_times) Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg,
const RoomType_e self_room_type,
int game_times,
int creator_register_time)
{ {
std::vector<std::vector<Room*>> group_rooms; std::vector<std::vector<Room*>> group_rooms;
for (int i = 0; i < RT_Max; ++i) { for (int i = 0; i < RT_Max; ++i) {
@ -185,10 +214,10 @@ 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()]; return group_rooms[self_room_type][rand() % group_rooms[self_room_type].size()];
} }
if (self_room_type == RT_NewBrid) { if (self_room_type == RT_NewBrid) {
return CreateRoom(self_room_type, game_times); return CreateRoom(self_room_type, game_times, creator_register_time);
} }
if (self_room_type == RT_MidBrid) { if (self_room_type == RT_MidBrid) {
return CreateRoom(self_room_type, game_times); return CreateRoom(self_room_type, game_times, creator_register_time);
} }
for (int i = 0; i < RT_Max; ++i) { for (int i = 0; i < RT_Max; ++i) {
for (Room* room : group_rooms[i]) { for (Room* room : group_rooms[i]) {
@ -197,7 +226,7 @@ Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg, const RoomType_e self_room
} }
} }
} }
return CreateRoom(self_room_type, game_times); return CreateRoom(self_room_type, game_times, creator_register_time);
} }
Room* RoomMgr::GetRoomByUuid(long long room_uuid) Room* RoomMgr::GetRoomByUuid(long long room_uuid)
@ -370,7 +399,7 @@ int RoomMgr::AllocRoomIdx()
return current_room_idx_; return current_room_idx_;
} }
Room* RoomMgr::CreateRoom(RoomType_e room_type, int game_times) Room* RoomMgr::CreateRoom(RoomType_e room_type, int game_times, int creator_register_time)
{ {
int room_idx = AllocRoomIdx(); int room_idx = AllocRoomIdx();
if (room_idx < 1) { if (room_idx < 1) {
@ -382,6 +411,7 @@ Room* RoomMgr::CreateRoom(RoomType_e room_type, int game_times)
init_info.room_uuid = App::Instance()->NewUuid(); init_info.room_uuid = App::Instance()->NewUuid();
init_info.room_type = room_type; init_info.room_type = room_type;
init_info.creator_game_times = game_times; init_info.creator_game_times = game_times;
init_info.creator_register_time = creator_register_time;
if (GetRoomByUuid(init_info.room_uuid)) { if (GetRoomByUuid(init_info.room_uuid)) {
abort(); abort();
} }

View File

@ -33,13 +33,16 @@ class RoomMgr : public a8::Singleton<RoomMgr>
private: private:
void InstallReportStateTimer(); void InstallReportStateTimer();
Room* GetRoomByIdx(int room_idx); Room* GetRoomByIdx(int room_idx);
Room* GetJoinableRoom(const cs::CMJoin& msg, const RoomType_e self_room_type, int game_times); Room* GetJoinableRoom(const cs::CMJoin& msg,
const RoomType_e self_room_type,
int game_times,
int creator_register_time);
void ReportServerState(int instance_id, const std::string& host, int port); void ReportServerState(int instance_id, const std::string& host, int port);
void FreeOverRoom(long long room_uuid); void FreeOverRoom(long long room_uuid);
bool IsLimitJoin(); bool IsLimitJoin();
int AllocRoomIdx(); int AllocRoomIdx();
Room* CreateRoom(RoomType_e room_type, int game_times); Room* CreateRoom(RoomType_e room_type, int game_times, int creator_register_time);
void JoinErrorHandle(const cs::CMJoin& msg, int error_code, int socket_handle); void JoinErrorHandle(const cs::CMJoin& msg, int error_code, int socket_handle);
private: private:

View File

@ -154,6 +154,7 @@ struct RoomInitInfo
long long room_uuid = 0; long long room_uuid = 0;
RoomType_e room_type = RT_NewBrid; RoomType_e room_type = RT_NewBrid;
int creator_game_times = 0; int creator_game_times = 0;
int creator_register_time = 0;
const MetaData::Map* map_meta = nullptr; const MetaData::Map* map_meta = nullptr;
std::string map_tpl_name; std::string map_tpl_name;

View File

@ -671,6 +671,7 @@ message MFTeamMember
optional int32 game_times = 4; // optional int32 game_times = 4; //
optional int32 win_times = 5; // optional int32 win_times = 5; //
optional int32 kill_times = 6; // optional int32 kill_times = 6; //
optional int32 create_time = 7; //
} }
//end mfmsg //end mfmsg