添加active_player_data优化

This commit is contained in:
aozhiwei 2020-07-07 13:13:52 +08:00
parent e898fdf1e0
commit acc2812c24
7 changed files with 41 additions and 2 deletions

View File

@ -249,7 +249,8 @@ enum PropertyType_e
kPropTankBulletNum = 6,
kPropTankOil = 7,
kPropBulletNum = 8,
kPropItem = 9
kPropItem = 9,
kPropWeaponAmmo = 10
};
enum MapObjectType_e

View File

@ -212,6 +212,21 @@ void FrameEvent::AddHpChg(Human* sender)
});
}
void FrameEvent::AddWeaponAmmoChg(Human* hum)
{
if (hum->curr_weapon) {
chged_weapon_ammo_.push_back
(
std::make_tuple(hum,
hum->curr_weapon->weapon_idx,
hum->curr_weapon->ammo
)
);
int idx = chged_weapon_ammo_.size() - 1;
hum->chged_weapon_ammo_.push_back(idx);
}
}
void FrameEvent::AddBuff(Human* sender, Buff* buff)
{
{
@ -310,4 +325,7 @@ void FrameEvent::Clear()
if (!chged_items_.empty()) {
chged_items_.clear();
}
if (!chged_weapon_ammo_.empty()) {
chged_weapon_ammo_.clear();
}
}

View File

@ -21,6 +21,7 @@ public:
void AddTankOilValueChg(Human* hum);
void AddTankOilMaxChg(Human* hum);
void AddHpChg(Human* hum);
void AddWeaponAmmoChg(Human* hum);
void AddBuff(Human* hum, Buff* buff);
void RemoveBuff(Human* hum, int buff_id);
void AddSkillCdChg(Human* hum);
@ -40,6 +41,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<std::tuple<Human*, int, int>> chged_weapon_ammo_;
std::vector<Human*> chged_hps_;
std::vector<Human*> chged_skillcds_;

View File

@ -182,6 +182,18 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(const Human* hum)
}
}
}
for (size_t idx : hum->chged_weapon_ammo_) {
if (idx < room->frame_event.chged_weapon_ammo_.size()) {
auto& tuple = room->frame_event.chged_weapon_ammo_[idx];
{
auto p = msg->add_chged_property_list();
p->set_obj_id((std::get<0>(tuple))->GetEntityUniId());
p->set_property_type(kPropWeaponAmmo);
p->set_property_subtype(std::get<1>(tuple));
p->set_value(std::get<2>(tuple));
}
}
}
if (room->frame_event.airdrops_.size() > 0) {
*msg->mutable_airdrop() = room->frame_event.airdrops_.Get(0);
}

View File

@ -1908,6 +1908,9 @@ void Human::ClearFrameData()
if (!chged_items_.empty()) {
chged_items_.clear();
}
if (!chged_weapon_ammo_.empty()) {
chged_weapon_ammo_.clear();
}
}
void Human::GenBattleReportData(a8::MutableXObject* params)

View File

@ -339,6 +339,7 @@ protected:
std::vector<int> chged_hps_;
std::vector<int> chged_skillcds_;
std::vector<int> chged_items_;
std::vector<int> chged_weapon_ammo_;
Human* follow_target_ = nullptr;
bool follow_synced_active_player = false;
HumanCar car_;

View File

@ -447,7 +447,9 @@ void Player::Shot()
AutoLoadingBullet();
}
last_shot_frameno_ = room->GetFrameNo();
#if 0
#if 1
room->frame_event.AddWeaponAmmoChg(this);
#else
need_sync_active_player = true;
#endif
}