decphp流量优化
This commit is contained in:
parent
7e7f740eb4
commit
296835d7d6
@ -166,6 +166,8 @@ enum EntitySubType_e
|
||||
|
||||
enum PropertyType_e
|
||||
{
|
||||
kPropHp = 1,
|
||||
kPropMaxHp = 2,
|
||||
kPropTankBulletNum = 6,
|
||||
kPropTankOil = 7
|
||||
};
|
||||
|
@ -180,6 +180,17 @@ void FrameEvent::AddSmoke(Bullet* bullet, int item_id, a8::Vec2 pos)
|
||||
}
|
||||
}
|
||||
|
||||
void FrameEvent::AddHpChg(Human* hum)
|
||||
{
|
||||
chged_hps_.push_back(hum);
|
||||
int idx = chged_hps_.size() - 1;
|
||||
for (auto& cell : hum->grid_list) {
|
||||
for (auto& hum : cell->human_list) {
|
||||
hum->chged_hps_.push_back(idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FrameEvent::Clear()
|
||||
{
|
||||
if (!explosions_.empty()) {
|
||||
@ -209,4 +220,7 @@ void FrameEvent::Clear()
|
||||
if (!chged_tank_oil_max_.empty()) {
|
||||
chged_tank_oil_max_.clear();
|
||||
}
|
||||
if (!chged_hps_.empty()) {
|
||||
chged_hps_.clear();
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ public:
|
||||
void AddTankBulletNumChg(Human* hum);
|
||||
void AddTankOilValueChg(Human* hum);
|
||||
void AddTankOilMaxChg(Human* hum);
|
||||
void AddHpChg(Human* hum);
|
||||
|
||||
void Clear();
|
||||
private:
|
||||
@ -29,6 +30,7 @@ private:
|
||||
std::vector<Human*> chged_tank_bullet_nums_;
|
||||
std::vector<Human*> chged_tank_oil_value_;
|
||||
std::vector<Human*> chged_tank_oil_max_;
|
||||
std::vector<Human*> chged_hps_;
|
||||
|
||||
friend class FrameMaker;
|
||||
};
|
||||
|
@ -114,6 +114,25 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(const Human* hum)
|
||||
p->set_value(target->tank_oil_value);
|
||||
}
|
||||
}
|
||||
for (size_t idx : hum->chged_hps_) {
|
||||
if (idx < room->frame_event.chged_hps_.size()) {
|
||||
Human* target = room->frame_event.chged_hps_[idx];
|
||||
if (hum->CanSee(target)) {
|
||||
{
|
||||
auto p = msg->add_chged_property_list();
|
||||
p->set_obj_id(target->entity_uniid);
|
||||
p->set_property_type(kPropHp);
|
||||
p->set_value(target->GetHP());
|
||||
}
|
||||
{
|
||||
auto p = msg->add_chged_property_list();
|
||||
p->set_obj_id(target->entity_uniid);
|
||||
p->set_property_type(kPropMaxHp);
|
||||
p->set_value(target->GetMaxHP());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (room->frame_event.airdrops_.size() > 0) {
|
||||
*msg->mutable_airdrop() = room->frame_event.airdrops_.Get(0);
|
||||
}
|
||||
|
@ -485,6 +485,11 @@ float Human::GetRadius()
|
||||
return meta->i->radius();
|
||||
}
|
||||
|
||||
float Human::GetHP()
|
||||
{
|
||||
return health;
|
||||
}
|
||||
|
||||
float Human::GetMaxHP()
|
||||
{
|
||||
return meta->i->health();
|
||||
@ -839,7 +844,11 @@ void Human::DecHP(float dec_hp, int killer_id, const std::string& killer_name, i
|
||||
}
|
||||
}
|
||||
}
|
||||
#if 1
|
||||
room->frame_event.AddHpChg(this);
|
||||
#else
|
||||
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Human::AddToNewObjects(Entity* entity)
|
||||
@ -2033,6 +2042,9 @@ void Human::ClearFrameData()
|
||||
if (!chged_tank_oil_max_.empty()){
|
||||
chged_tank_oil_max_.clear();
|
||||
}
|
||||
if (!chged_hps_.empty()) {
|
||||
chged_hps_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void Human::GenBattleReportData(a8::MutableXObject* params)
|
||||
|
@ -145,6 +145,7 @@ class Human : public Entity
|
||||
bool IsCollisionInMapService();
|
||||
void FindPathInMapService();
|
||||
float GetRadius();
|
||||
float GetHP();
|
||||
float GetMaxHP();
|
||||
void UpdatePoisoning();
|
||||
void SyncAroundPlayers(const char* file, int line, const char* func);
|
||||
@ -252,6 +253,7 @@ protected:
|
||||
std::vector<int> chged_tank_bullet_nums_;
|
||||
std::vector<int> chged_tank_oil_value_;
|
||||
std::vector<int> chged_tank_oil_max_;
|
||||
std::vector<int> chged_hps_;
|
||||
Human* follow_target_ = nullptr;
|
||||
bool follow_synced_active_player = false;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user