add ClearFrameData

This commit is contained in:
aozhiwei 2019-04-29 10:25:02 +08:00
parent c25560e035
commit 7721416323
3 changed files with 31 additions and 28 deletions

View File

@ -95,27 +95,6 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
} }
msg->set_alive_count(room->AliveCount()); msg->set_alive_count(room->AliveCount());
} }
if (!hum->new_objects.empty()) {
hum->new_objects.clear();
}
if (!hum->del_objects.empty()) {
hum->del_objects.clear();
}
if (!hum->shots_.empty()) {
hum->shots_.clear();
}
if (!hum->bullets_.empty()) {
hum->bullets_.clear();
}
if (!hum->explosions_.empty()) {
hum->explosions_.clear();
}
if (!hum->smokes_.empty()) {
hum->smokes_.clear();
}
if (!hum->emotes_.empty()) {
hum->emotes_.clear();
}
++hum->send_msg_times; ++hum->send_msg_times;
return msg; return msg;
} }

View File

@ -1167,7 +1167,7 @@ void Human::RemoveObserver(Human* observer)
void Human::SendUpdateMsg() void Human::SendUpdateMsg()
{ {
if (!follow_) { if (!follow_target_) {
cs::SMUpdate* msg = room->frame_maker.MakeUpdateMsg(this); cs::SMUpdate* msg = room->frame_maker.MakeUpdateMsg(this);
if (msg) { if (msg) {
SendNotifyMsg(*msg); SendNotifyMsg(*msg);
@ -1175,14 +1175,10 @@ void Human::SendUpdateMsg()
msg = nullptr; msg = nullptr;
} }
} }
ClearFrameData();
if (send_gameover) { if (send_gameover) {
UpdateGameOver(); UpdateGameOver();
} }
{
if (!new_objects.empty()) {
new_objects.clear();
}
}
} }
void Human::UpdateGameOver() void Human::UpdateGameOver()
@ -1192,3 +1188,28 @@ void Human::UpdateGameOver()
SendNotifyMsg(msg); SendNotifyMsg(msg);
send_gameover = false; send_gameover = false;
} }
void Human::ClearFrameData()
{
if (!new_objects.empty()) {
new_objects.clear();
}
if (!del_objects.empty()) {
del_objects.clear();
}
if (!shots_.empty()) {
shots_.clear();
}
if (!bullets_.empty()) {
bullets_.clear();
}
if (!explosions_.empty()) {
explosions_.clear();
}
if (!smokes_.empty()) {
smokes_.clear();
}
if (!emotes_.empty()) {
emotes_.clear();
}
}

View File

@ -164,6 +164,9 @@ class Human : public Entity
} }
void UpdateGameOver(); void UpdateGameOver();
private:
void ClearFrameData();
protected: protected:
long long last_shot_frameno_ = 0; long long last_shot_frameno_ = 0;
long long last_use_skill_frameno_ = 0; long long last_use_skill_frameno_ = 0;
@ -187,7 +190,7 @@ protected:
std::vector<int> smokes_; std::vector<int> smokes_;
std::vector<int> explosions_; std::vector<int> explosions_;
std::set<Human*> observers_; std::set<Human*> observers_;
Human* follow_ = nullptr; Human* follow_target_ = nullptr;
private: private:
CircleCollider* self_collider_ = nullptr; CircleCollider* self_collider_ = nullptr;