diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 2d84cda..812488d 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -287,7 +287,7 @@ void Room::CreateAndroid(int robot_num) ++App::Instance()->perf.alive_count; refreshed_robot_set_.insert(robot_meta->i->id()); - if (room_type_ == RT_NewBrid) { + if (!CanAddToScene(hum)) { a8::SetBitFlag(hum->status, HS_Disable); } else { AddToAliveHumanHash(hum); @@ -1258,10 +1258,20 @@ void Room::OnGameOver() void Room::RandRemoveAndroid() { Human* hum = nullptr; - for (auto& pair : human_hash_) { - if (pair.second->IsAndroid()) { - hum = pair.second; - break; + if (room_type_ == RT_MidBrid) { + for (auto& pair : alive_human_hash_) { + if (pair.second->IsAndroid()) { + hum = pair.second; + break; + } + } + } + if (!hum) { + for (auto& pair : human_hash_) { + if (pair.second->IsAndroid()) { + hum = pair.second; + break; + } } } if (hum) { @@ -2212,6 +2222,16 @@ void Room::AddPlayerPostProc(Player* hum) hum->AddBuff(buff_meta, 1); } } + if (room_type_ == RT_MidBrid) { + Player* first_player = GetOneAlivePlayer(); + if (first_player && first_player->born_point) { + if (hum->born_point) { + DecBornPointHumanNum(hum->born_point, hum); + } + hum->born_point = first_player->born_point; + IncBornPointHumanNum(hum->born_point, hum); + } + } } while (human_hash_.size() > ROOM_MAX_PLAYER_NUM) { RandRemoveAndroid(); @@ -2489,3 +2509,20 @@ void Room::CreateLevel0RoomSpecThings() } } } + +bool Room::CanAddToScene(Human* hum) +{ + if (room_type_ == RT_NewBrid) { + return false; + } else if (room_type_ == RT_MidBrid) { + Player* player = GetOneAlivePlayer(); + if (player) { + if (std::fabs(hum->GetPos().x - player->GetPos().x) <= 1024 && + std::fabs(hum->GetPos().y - player->GetPos().y) <= 1024) { + return true; + } + } + return false; + } + return true; +} diff --git a/server/gameserver/room.h b/server/gameserver/room.h index f4b6f5f..5d51af0 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -188,6 +188,7 @@ private: void ForceSetBornPoint(Human* hum, BornPoint* born_point); void NewBieRoomStart(); void CreateLevel0RoomSpecThings(); + bool CanAddToScene(Human* hum); #ifdef DEBUG void InitDebugInfo();