From d1a289b78d2e92f23174ae96d3d28822b7a2d8e2 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 5 Sep 2024 16:46:35 +0800 Subject: [PATCH] 1 --- server/gameserver/ability.cc | 50 +++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/server/gameserver/ability.cc b/server/gameserver/ability.cc index be55ce24..23e8c2a8 100644 --- a/server/gameserver/ability.cc +++ b/server/gameserver/ability.cc @@ -18,6 +18,7 @@ struct AttrAddition : public std::enable_shared_from_this list_head list_entry; int attr_id; float value; + float finaly_value; int source_type = kAstNone; std::shared_ptr holder; std::shared_ptr> get_source; @@ -45,29 +46,42 @@ static std::array>, kAstEnd> s_speed_r static float CalcSpeedRateIn(list_head* head) { - list_head* pos = nullptr; - list_head* next = nullptr; - list_for_each_safe(pos, next, head) { - AttrAddition* e = list_entry(pos, - AttrAddition, - entry); - switch (e->source_type) { - case kAstChip: - { - s_speed_ratein_list.at(e->source_type).push_back(e->holder); - } - break; - default: - { - if (e->source_type >= 0 && e->source_type <= s_speed_ratein_list.size()) { + { + list_head* pos = nullptr; + list_head* next = nullptr; + list_for_each_safe(pos, next, head) { + AttrAddition* e = list_entry(pos, + AttrAddition, + entry); + switch (e->source_type) { + case kAstChip: + { s_speed_ratein_list.at(e->source_type).push_back(e->holder); } + break; + default: + { + if (e->source_type >= 0 && e->source_type <= s_speed_ratein_list.size()) { + s_speed_ratein_list.at(e->source_type).push_back(e->holder); + } + } + break; } - break; } } - for (auto& itr : s_speed_ratein_list) { - itr.clear(); + { + for (auto& itr : s_speed_ratein_list) { + std::sort(itr.begin(), itr.end(), + [] (std::shared_ptr a, std::shared_ptr b) -> bool + { + return std::fabs(a->value) > std::fabs(b->value); + }); + } + } + { + for (auto& itr : s_speed_ratein_list) { + itr.clear(); + } } return 0.0f; }