添加性能优化
This commit is contained in:
parent
9974333789
commit
e584fcb352
@ -209,6 +209,15 @@ enum ColliderTag_e
|
|||||||
kColliderTag_Loot = 2, //掉落物
|
kColliderTag_Loot = 2, //掉落物
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum PropertyType_e
|
||||||
|
{
|
||||||
|
kPropHp = 1,
|
||||||
|
kPropMaxHp = 2,
|
||||||
|
kPropInventory = 3,
|
||||||
|
kPropSkillLeftTime = 4,
|
||||||
|
kPropSkillCd = 5
|
||||||
|
};
|
||||||
|
|
||||||
const char* const kPROJ_NAME_FMT = "game%d_gameserver";
|
const char* const kPROJ_NAME_FMT = "game%d_gameserver";
|
||||||
const char* const kPROJ_ROOT_FMT = "/data/logs/%s";
|
const char* const kPROJ_ROOT_FMT = "/data/logs/%s";
|
||||||
|
|
||||||
|
@ -214,15 +214,31 @@ void FrameEvent::RemoveBuff(Human* hum, int buff_id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameEvent::AddPropertyChg(Human* hum)
|
void FrameEvent::AddHpChg(Human* hum)
|
||||||
{
|
{
|
||||||
|
chged_hps_.push_back(hum);
|
||||||
|
int idx = chged_hps_.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->property_chged_humans_.insert(hum);
|
hum->chged_hps_.push_back(idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FrameEvent::AddInventoryChg(Human* hum)
|
||||||
|
{
|
||||||
|
chged_inventorys_.push_back(hum);
|
||||||
|
int idx = chged_inventorys_.size();
|
||||||
|
hum->chged_inventorys_.push_back(idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameEvent::AddSkillCdChg(Human* hum)
|
||||||
|
{
|
||||||
|
chged_skillcds_.push_back(hum);
|
||||||
|
int idx = chged_skillcds_.size();
|
||||||
|
hum->chged_skillcds_.push_back(idx);
|
||||||
|
}
|
||||||
|
|
||||||
void FrameEvent::Clear()
|
void FrameEvent::Clear()
|
||||||
{
|
{
|
||||||
if (!explosions_.empty()) {
|
if (!explosions_.empty()) {
|
||||||
@ -252,4 +268,13 @@ void FrameEvent::Clear()
|
|||||||
if (!chged_buffs_.empty()) {
|
if (!chged_buffs_.empty()) {
|
||||||
chged_buffs_.clear();
|
chged_buffs_.clear();
|
||||||
}
|
}
|
||||||
|
if (!chged_hps_.empty()) {
|
||||||
|
chged_hps_.clear();
|
||||||
|
}
|
||||||
|
if (!chged_inventorys_.empty()) {
|
||||||
|
chged_inventorys_.clear();
|
||||||
|
}
|
||||||
|
if (!chged_skillcds_.empty()) {
|
||||||
|
chged_skillcds_.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,9 @@ public:
|
|||||||
void AddRevive(Human* hum);
|
void AddRevive(Human* hum);
|
||||||
void AddBuff(Human* hum, Buff* buff);
|
void AddBuff(Human* hum, Buff* buff);
|
||||||
void RemoveBuff(Human* hum, int buff_id);
|
void RemoveBuff(Human* hum, int buff_id);
|
||||||
void AddPropertyChg(Human* hum);
|
void AddHpChg(Human* hum);
|
||||||
|
void AddInventoryChg(Human* hum);
|
||||||
|
void AddSkillCdChg(Human* hum);
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
private:
|
private:
|
||||||
@ -36,6 +38,9 @@ private:
|
|||||||
std::vector<std::tuple<Human*, ::cs::MFBuffChg>> chged_buffs_;
|
std::vector<std::tuple<Human*, ::cs::MFBuffChg>> chged_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_;
|
||||||
|
std::vector<Human*> chged_hps_;
|
||||||
|
std::vector<Human*> chged_inventorys_;
|
||||||
|
std::vector<Human*> chged_skillcds_;
|
||||||
|
|
||||||
friend class FrameMaker;
|
friend class FrameMaker;
|
||||||
};
|
};
|
||||||
|
@ -73,10 +73,42 @@ 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->chged_buffs_) {
|
for (size_t idx : hum->chged_hps_) {
|
||||||
if (idx < room->frame_event.chged_buffs_.size()) {
|
if (idx < room->frame_event.chged_hps_.size()) {
|
||||||
auto p = msg->add_chged_buff_list();
|
{
|
||||||
*p = std::get<1>(room->frame_event.chged_buffs_[idx]);
|
auto p = msg->add_chged_property_list();
|
||||||
|
p->set_property_type(kPropHp);
|
||||||
|
p->set_value(room->frame_event.chged_hps_[idx]->GetHP());
|
||||||
|
}
|
||||||
|
{
|
||||||
|
auto p = msg->add_chged_property_list();
|
||||||
|
p->set_property_type(kPropMaxHp);
|
||||||
|
p->set_value(room->frame_event.chged_hps_[idx]->GetMaxHP());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (size_t idx : hum->chged_inventorys_) {
|
||||||
|
if (idx < room->frame_event.chged_inventorys_.size()) {
|
||||||
|
{
|
||||||
|
auto p = msg->add_chged_property_list();
|
||||||
|
p->set_property_type(kPropInventory);
|
||||||
|
p->set_property_subtype(kWEAPON_SLOT);
|
||||||
|
p->set_value(room->frame_event.chged_inventorys_[idx]->GetInventory(kWEAPON_SLOT));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (size_t idx : hum->chged_skillcds_) {
|
||||||
|
if (idx < room->frame_event.chged_skillcds_.size()) {
|
||||||
|
{
|
||||||
|
auto p = msg->add_chged_property_list();
|
||||||
|
p->set_property_type(kPropSkillLeftTime);
|
||||||
|
p->set_value(room->frame_event.chged_skillcds_[idx]->GetSkillLeftTime());
|
||||||
|
}
|
||||||
|
{
|
||||||
|
auto p = msg->add_chged_property_list();
|
||||||
|
p->set_property_type(kPropSkillCd);
|
||||||
|
p->set_value(room->frame_event.chged_skillcds_[idx]->GetSkillCd());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (room->frame_event.airdrops_.size() > 0) {
|
if (room->frame_event.airdrops_.size() > 0) {
|
||||||
|
@ -1852,8 +1852,14 @@ void Human::ClearFrameData()
|
|||||||
if (!dead_objs_.empty()) {
|
if (!dead_objs_.empty()) {
|
||||||
dead_objs_.clear();
|
dead_objs_.clear();
|
||||||
}
|
}
|
||||||
if (!property_chged_humans_.empty()) {
|
if (!chged_hps_.empty()) {
|
||||||
property_chged_humans_.clear();
|
chged_hps_.clear();
|
||||||
|
}
|
||||||
|
if (!chged_inventorys_.empty()) {
|
||||||
|
chged_inventorys_.clear();
|
||||||
|
}
|
||||||
|
if (!chged_skillcds_.empty()) {
|
||||||
|
chged_skillcds_.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,7 +245,9 @@ protected:
|
|||||||
std::vector<int> chged_buffs_;
|
std::vector<int> chged_buffs_;
|
||||||
std::vector<int> revive_objs_;
|
std::vector<int> revive_objs_;
|
||||||
std::vector<int> dead_objs_;
|
std::vector<int> dead_objs_;
|
||||||
std::set<Human*> property_chged_humans_;
|
std::vector<int> chged_hps_;
|
||||||
|
std::vector<int> chged_inventorys_;
|
||||||
|
std::vector<int> chged_skillcds_;
|
||||||
std::set<Human*> observers_;
|
std::set<Human*> observers_;
|
||||||
Human* follow_target_ = nullptr;
|
Human* follow_target_ = nullptr;
|
||||||
bool follow_synced_active_player_ = false;
|
bool follow_synced_active_player_ = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user