添加子弹数量流量优化

This commit is contained in:
aozhiwei 2019-10-09 16:48:44 +08:00
parent 9accc9a0ee
commit 79a54df690
8 changed files with 36 additions and 5 deletions

View File

@ -169,7 +169,8 @@ enum PropertyType_e
kPropHp = 1,
kPropMaxHp = 2,
kPropTankBulletNum = 6,
kPropTankOil = 7
kPropTankOil = 7,
kPropBulletNum = 8
};
enum MapObjectType_e

View File

@ -138,6 +138,13 @@ void FrameEvent::AddExplosionEx(Human* sender, int item_id, a8::Vec2 bomb_pos, i
}
}
void FrameEvent::AddBulletNumChg(Human* hum)
{
chged_bullet_nums_.push_back(hum);
int idx = chged_bullet_nums_.size() - 1;
hum->chged_bullet_nums_.push_back(idx);
}
void FrameEvent::AddTankBulletNumChg(Human* hum)
{
chged_tank_bullet_nums_.push_back(hum);
@ -211,6 +218,9 @@ void FrameEvent::Clear()
if (airdrops_.size() > 0) {
airdrops_.Clear();
}
if (!chged_bullet_nums_.empty()) {
chged_bullet_nums_.clear();
}
if (!chged_tank_bullet_nums_.empty()) {
chged_tank_bullet_nums_.clear();
}

View File

@ -14,6 +14,7 @@ public:
void AddExplosion(Bullet* bullet, int item_id, a8::Vec2 bomb_pos);
void AddSmoke(Bullet* bullet, int item_id, a8::Vec2 pos);
void AddExplosionEx(Human* sender, int item_id, a8::Vec2 bomb_pos, int effect);
void AddBulletNumChg(Human* hum);
void AddTankBulletNumChg(Human* hum);
void AddTankOilValueChg(Human* hum);
void AddTankOilMaxChg(Human* hum);
@ -27,6 +28,7 @@ private:
std::vector<std::tuple<Human*, ::cs::MFExplosion>> explosions_;
std::vector<std::tuple<Human*, ::cs::MFSmoke>> smokes_;
std::vector<std::tuple<Human*, ::cs::MFEmote>> emotes_;
std::vector<Human*> chged_bullet_nums_;
std::vector<Human*> chged_tank_bullet_nums_;
std::vector<Human*> chged_tank_oil_value_;
std::vector<Human*> chged_tank_oil_max_;

View File

@ -83,6 +83,17 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(const Human* hum)
}
}
}
for (size_t idx : hum->chged_bullet_nums_) {
if (idx < room->frame_event.chged_bullet_nums_.size()) {
Human* target = room->frame_event.chged_bullet_nums_[idx];
if (target->curr_weapon) {
auto p = msg->add_chged_property_list();
p->set_obj_id(target->entity_uniid);
p->set_property_type(kPropBulletNum);
p->set_value(target->curr_weapon->ammo);
}
}
}
for (size_t idx : hum->chged_tank_bullet_nums_) {
if (idx < room->frame_event.chged_tank_bullet_nums_.size()) {
Human* target = room->frame_event.chged_tank_bullet_nums_[idx];

View File

@ -320,7 +320,9 @@ void Human::Shot(a8::Vec2& target_dir)
break;
}
last_shot_frameno_ = room->frame_no;
need_sync_active_player = true;
if (!need_sync_active_player) {
room->frame_event.AddBulletNumChg(this);
}
}
void Human::TankShot(a8::Vec2& target_dir)
@ -2000,6 +2002,9 @@ void Human::ClearFrameData()
if (!emotes_.empty()) {
emotes_.clear();
}
if (!chged_bullet_nums_.empty()) {
chged_bullet_nums_.clear();
}
if (!chged_tank_bullet_nums_.empty()) {
chged_tank_bullet_nums_.clear();
}

View File

@ -256,6 +256,7 @@ protected:
std::vector<int> smokes_;
std::vector<int> explosions_;
std::set<Human*> observers_;
std::vector<int> chged_bullet_nums_;
std::vector<int> chged_tank_bullet_nums_;
std::vector<int> chged_tank_oil_value_;
std::vector<int> chged_tank_oil_max_;

View File

@ -54,9 +54,6 @@ void Player::Update(int delta_time)
UpdateMove();
}
if (room->frame_no % 2 == 0) {
if (shot_start || shot_hold) {
UpdateShot();
}
if (drop_weapon) {
UpdateDropWeapon();
}
@ -99,6 +96,9 @@ void Player::Update(int delta_time)
if (get_down) {
UpdateGetDown();
}
if (shot_start || shot_hold) {
UpdateShot();
}
}
}

View File

@ -105,6 +105,7 @@ message MFVector2D
property_type: 6
property_type: 7
property_subtype: 01()) !
property_type: 8
*/
message MFPropertyChg
{