流量优化 alive_count

This commit is contained in:
aozhiwei 2020-07-06 13:43:57 +08:00
parent 7afa5385ce
commit b45c3ed44f
3 changed files with 10 additions and 1 deletions

View File

@ -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());
}
if (room->GetFrameNo() - room->AliveCountChgFrameNo() <= 4 ||
room->GetFrameNo() - hum->join_frameno <= 2) {
msg->set_alive_count(room->AliveCount());
}
}
return msg;
}

View File

@ -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);

View File

@ -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;