diff --git a/server/gameserver/framemaker.cc b/server/gameserver/framemaker.cc index 6c4abe5..cbd4025 100644 --- a/server/gameserver/framemaker.cc +++ b/server/gameserver/framemaker.cc @@ -186,7 +186,10 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(const Human* hum) msg->set_gas_progress(room->GetGasData().gas_progress); TypeConvert::ToPb(room->GetGasData().pos_old, msg->mutable_gas_pos_old()); } - msg->set_alive_count(room->AliveCount()); + if (room->GetFrameNo() - room->AliveCountChgFrameNo() <= 4 || + room->GetFrameNo() - hum->join_frameno <= 2) { + msg->set_alive_count(room->AliveCount()); + } } return msg; } diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index cae64bb..0a04b19 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -190,6 +190,7 @@ void Room::AddPlayer(Player* hum) MatchTeam(hum); hum->PushJoinRoomMsg(); ++alive_count_; + alive_count_chged_frameno_ = GetFrameNo(); ++PerfMonitor::Instance()->alive_count; grid_service->AddHuman(hum); @@ -287,6 +288,7 @@ void Room::CreateAndroid(int robot_num) AddToHumanHash(hum); MatchTeam(hum); ++alive_count_; + alive_count_chged_frameno_ = GetFrameNo(); ++PerfMonitor::Instance()->alive_count; refreshed_robot_set_.insert(robot_meta->i->id()); @@ -539,6 +541,7 @@ void Room::RemoveObjectLater(RoomEntity* entity) void Room::OnHumanDie(Human* hum) { --alive_count_; + alive_count_chged_frameno_ = GetFrameNo(); --PerfMonitor::Instance()->alive_count; RemoveFromAliveHumanHash(hum); NotifyUiUpdate(); @@ -1390,6 +1393,7 @@ void Room::RandRemoveAndroid() RemoveFromAliveHumanHash(hum); AddToRemovedRobotHash(hum); --alive_count_; + alive_count_chged_frameno_ = GetFrameNo(); --PerfMonitor::Instance()->alive_count; for (auto& pair : human_hash_) { pair.second->RemovePartObjects(hum); diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 1c2faae..5702969 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -62,6 +62,7 @@ public: int GetPlayerNum(); int AliveCount(); + long long AliveCountChgFrameNo() { return alive_count_chged_frameno_; }; inline int RealAliveCount() { return alive_human_hash_.size(); } Player* GetPlayerByAccountId(const std::string& accountid); Player* GetPlayerByUniId(int uniid); @@ -223,6 +224,7 @@ private: long long game_over_frameno_ = 0; int elapsed_time_ = 0; int alive_count_ = 0; + long long alive_count_chged_frameno_ = 0; MetaData::AirLine* airline_ = nullptr; a8::XTimerAttacher xtimer_attacher_; size_t airdrop_times_ = 0;