添加房间模式判断

This commit is contained in:
aozhiwei 2020-07-22 17:22:42 +08:00
parent db9a820e6b
commit dd18e41cb6
5 changed files with 24 additions and 4 deletions

View File

@ -281,7 +281,8 @@ enum ObjectSyncFlags_e
enum RoomMode_e
{
kChiJiMode = 0,
kZombieMode = 1
kZombieMode = 1,
kRoomModeEnd
};
enum RaceType_e

View File

@ -25,6 +25,7 @@ void GameLog::GameStart(Player* hum)
prop->SetVal("account_register_date", a8::TimestampToDateTime(hum->account_registertime));
prop->SetVal("game_uniid", a8::XValue(hum->room->GetRoomUuid()).GetString());
prop->SetVal("room_type", a8::XValue(hum->room->GetRoomType()).GetString());
prop->SetVal("room_mode", a8::XValue((int)hum->room->GetRoomMode()));
//prop->SetVal("game_param", "");
prop->SetVal("nickname", hum->name);
//prop->SetVal("localuuid", "");
@ -60,6 +61,7 @@ void GameLog::GameEnd(Player* hum)
prop->SetVal("account_register_date", a8::TimestampToDateTime(hum->account_registertime));
prop->SetVal("game_uniid", a8::XValue(hum->room->GetRoomUuid()).GetString());
prop->SetVal("room_type", a8::XValue(hum->room->GetRoomType()).GetString());
prop->SetVal("room_mode", a8::XValue((int)hum->room->GetRoomMode()));
//prop->SetVal("game_param", "");
prop->SetVal("game_gold", hum->stats.gold);
prop->SetVal("game_score", hum->stats.score);

View File

@ -665,8 +665,19 @@ int Room::GetAliveTeamNum()
return num;
}
bool Room::CanJoin(const std::string& accountid, RoomType_e self_room_type)
bool Room::CanJoin(const std::string& accountid,
RoomType_e self_room_type,
RoomMode_e self_room_mode)
{
if (self_room_mode < kChiJiMode) {
self_room_mode = kChiJiMode;
}
if (self_room_mode > kRoomModeEnd) {
self_room_mode = kZombieMode;
}
if (room_mode_ != self_room_mode) {
return false;
}
if (gas_data_.gas_mode != GasInactive) {
return false;
}

View File

@ -54,6 +54,7 @@ public:
bool IsGameOver() { return game_over_; }
const GasData& GetGasData() { return gas_data_; }
RoomType_e GetRoomType() { return room_type_; }
RoomMode_e GetRoomMode() { return room_mode_; }
long long GetRoomUuid() { return room_uuid_; }
int GetRoomIdx() { return room_idx_; }
std::string GetMapTplName() { return map_tpl_name_; }
@ -97,7 +98,9 @@ public:
bool BattleStarted();
int GetAliveTeamNum();
std::set<Human*>* GetAliveTeam();
bool CanJoin(const std::string& accountid, RoomType_e self_roomm_type);
bool CanJoin(const std::string& accountid,
RoomType_e self_roomm_type,
RoomMode_e self_room_mode);
void OnPlayerOffline(Player* hum);
Entity* FindFirstCollisonEntity(const a8::Vec2& aabb_pos, AabbCollider& aabb_box);
void FindLocationWithAabb(Entity* target, const a8::Vec2& aabb_pos, AabbCollider* aabb_box,

View File

@ -43,6 +43,9 @@ static RoomType_e GetHumanRoomType(const cs::CMJoin& msg, int& game_times)
}
}
#endif
if (msg.room_mode() == kZombieMode) {
return RT_OldBrid3;
}
if (!msg.team_uuid().empty() && msg.team_members().size() > 1) {
for (auto& team_member : msg.team_members()) {
@ -174,7 +177,7 @@ Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg,
}
for (auto& pair : inactive_room_hash_) {
Room* room = pair.second;
if (room->CanJoin(msg.account_id(), self_room_type)) {
if (room->CanJoin(msg.account_id(), self_room_type, (RoomMode_e)msg.room_mode())) {
if (!msg.team_uuid().empty() && room->HaveMyTeam(msg.team_uuid())) {
return room;
}