This commit is contained in:
aozhiwei 2019-07-12 15:20:47 +08:00
parent cc72a3feca
commit 0efdb6e23c
6 changed files with 29 additions and 39 deletions

View File

@ -170,16 +170,17 @@ void FrameEvent::AddRevive(Human* hum)
void FrameEvent::AddBuff(Human* hum, Buff* buff) void FrameEvent::AddBuff(Human* hum, Buff* buff)
{ {
{ {
cs::MFAddBuff add_buff_pb; cs::MFBuffChg chged_buff_pb;
add_buff_pb.set_obj_id(hum->entity_uniid); chged_buff_pb.set_obj_id(hum->entity_uniid);
buff->FillMFBuff(add_buff_pb.mutable_buff()); chged_buff_pb.set_chg(0);
add_buffs_.push_back(std::make_tuple(hum, add_buff_pb)); buff->FillMFBuff(chged_buff_pb.mutable_buff());
chged_buffs_.push_back(std::make_tuple(hum, chged_buff_pb));
} }
{ {
int idx = add_buffs_.size() - 1; int idx = chged_buffs_.size() - 1;
for (auto& cell : hum->grid_list) { for (auto& cell : hum->grid_list) {
for (auto& hum : cell->human_list) { for (auto& hum : cell->human_list) {
hum->add_buffs_.push_back(idx); hum->chged_buffs_.push_back(idx);
} }
} }
} }
@ -188,13 +189,17 @@ void FrameEvent::AddBuff(Human* hum, Buff* buff)
void FrameEvent::RemoveBuff(Human* hum, int buff_id) void FrameEvent::RemoveBuff(Human* hum, int buff_id)
{ {
{ {
remove_buffs_.push_back(std::make_tuple(hum->entity_uniid, buff_id)); cs::MFBuffChg chged_buff_pb;
chged_buff_pb.set_obj_id(hum->entity_uniid);
chged_buff_pb.set_chg(1);
chged_buff_pb.mutable_buff()->set_buff_id(buff_id);
chged_buffs_.push_back(std::make_tuple(hum, chged_buff_pb));
} }
{ {
int idx = remove_buffs_.size() - 1; int idx = chged_buffs_.size() - 1;
for (auto& cell : hum->grid_list) { for (auto& cell : hum->grid_list) {
for (auto& hum : cell->human_list) { for (auto& hum : cell->human_list) {
hum->remove_buffs_.push_back(idx); hum->chged_buffs_.push_back(idx);
} }
} }
} }
@ -226,10 +231,7 @@ void FrameEvent::Clear()
if (!dead_objs_.empty()) { if (!dead_objs_.empty()) {
dead_objs_.clear(); dead_objs_.clear();
} }
if (!add_buffs_.empty()) { if (!chged_buffs_.empty()) {
add_buffs_.clear(); chged_buffs_.clear();
}
if (!remove_buffs_.empty()) {
remove_buffs_.clear();
} }
} }

View File

@ -31,8 +31,7 @@ private:
std::vector<::cs::MFExplosion> explosions_; std::vector<::cs::MFExplosion> explosions_;
std::vector<std::tuple<Human*, ::cs::MFSmoke>> smokes_; std::vector<std::tuple<Human*, ::cs::MFSmoke>> smokes_;
std::vector<std::tuple<Human*, ::cs::MFEmote>> emotes_; std::vector<std::tuple<Human*, ::cs::MFEmote>> emotes_;
std::vector<std::tuple<Human*, ::cs::MFAddBuff>> add_buffs_; std::vector<std::tuple<Human*, ::cs::MFBuffChg>> chged_buffs_;
std::vector<std::tuple<int, int>> remove_buffs_;
std::vector<int> revive_objs_; std::vector<int> revive_objs_;
std::vector<std::tuple<int, int>> dead_objs_; std::vector<std::tuple<int, int>> dead_objs_;

View File

@ -73,17 +73,10 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(const Human* hum)
p->add_values(std::get<1>(room->frame_event.dead_objs_[idx])); p->add_values(std::get<1>(room->frame_event.dead_objs_[idx]));
} }
} }
for (size_t idx : hum->add_buffs_) { for (size_t idx : hum->chged_buffs_) {
if (idx < room->frame_event.add_buffs_.size()) { if (idx < room->frame_event.chged_buffs_.size()) {
auto p = msg->add_add_buff_list(); auto p = msg->add_chged_buff_list();
*p = std::get<1>(room->frame_event.add_buffs_[idx]); *p = std::get<1>(room->frame_event.chged_buffs_[idx]);
}
}
for (size_t idx : hum->remove_buffs_) {
if (idx < room->frame_event.remove_buffs_.size()) {
auto p = msg->add_remove_buff_list();
p->set_key(std::get<0>(room->frame_event.remove_buffs_[idx]));
p->set_value(std::get<1>(room->frame_event.remove_buffs_[idx]));
} }
} }
if (room->frame_event.airdrops_.size() > 0) { if (room->frame_event.airdrops_.size() > 0) {

View File

@ -1660,11 +1660,8 @@ void Human::ClearFrameData()
if (!emotes_.empty()) { if (!emotes_.empty()) {
emotes_.clear(); emotes_.clear();
} }
if (!add_buffs_.empty()) { if (!chged_buffs_.empty()) {
add_buffs_.clear(); chged_buffs_.clear();
}
if (!remove_buffs_.empty()) {
remove_buffs_.clear();
} }
if (!revive_objs_.empty()) { if (!revive_objs_.empty()) {
revive_objs_.clear(); revive_objs_.clear();

View File

@ -246,8 +246,7 @@ protected:
std::vector<int> bullets_; std::vector<int> bullets_;
std::vector<int> smokes_; std::vector<int> smokes_;
std::vector<int> explosions_; std::vector<int> explosions_;
std::vector<int> add_buffs_; std::vector<int> chged_buffs_;
std::vector<int> remove_buffs_;
std::vector<int> revive_objs_; std::vector<int> revive_objs_;
std::vector<int> dead_objs_; std::vector<int> dead_objs_;
std::set<Human*> observers_; std::set<Human*> observers_;

View File

@ -531,11 +531,12 @@ message MFBuff
optional float lasting_time = 3; //() optional float lasting_time = 3; //()
} }
//add buff //buff变更
message MFAddBuff message MFBuffChg
{ {
optional int32 obj_id = 1; //id optional int32 obj_id = 1; //id
optional MFBuff buff = 2; //buff optional int32 chg = 2; //0:/ 1:
optional MFBuff buff = 3; //buff
} }
//end mfmsg //end mfmsg
@ -695,8 +696,7 @@ message SMUpdate
optional MFAirDrop airdrop = 17; // optional MFAirDrop airdrop = 17; //
repeated int32 revive_objids = 18; // repeated int32 revive_objids = 18; //
repeated MFTuple dead_objs = 19; //values[0]:objid values[1]: repeated MFTuple dead_objs = 19; //values[0]:objid values[1]:
repeated MFAddBuff add_buff_list = 20; //buff列表 repeated MFBuffChg chged_buff_list = 20; //buff变更列表
repeated MFPair remove_buff_list = 21; //buff列表 key:objid value:buff_id
} }
// //