This commit is contained in:
aozhiwei 2023-02-20 17:22:42 +08:00
parent 581315e18e
commit 54b7efe873
2 changed files with 26 additions and 5 deletions

View File

@ -3,13 +3,25 @@
#include "mt/Grasp.h"
IMPL_TABLE(mt::Grasp)
std::map<long long, std::map<int, std::vector<const mt::GraspBuff*>>> mt::Grasp:: hero_weapon_hash_;
std::map<long long, std::map<int, mt::GraspBuffs>> mt::Grasp:: hero_weapon_hash_;
namespace mt
{
void Grasp::Init1()
{
buff1_meta = mt::GraspBuff::GetById(graspbuff_id1());
if (graspbuff_id1() && !buff1_meta) {
abort();
}
floor2_buff_meta = mt::GraspBuff::GetById(graspbuff_id1_floor2());
if (graspbuff_id1_floor2() && !floor2_buff_meta) {
abort();
}
buff2_meta = mt::GraspBuff::GetById(graspbuff_id2());
if (graspbuff_id2() && !buff2_meta) {
abort();
}
}
void Grasp::Init2()
@ -25,11 +37,19 @@ namespace mt
{
auto itr = hero_weapon_hash_.find(a8::MakeInt64(meta->hero_id(), meta->weapon_id()));
if (itr != hero_weapon_hash_.end()) {
auto itr2 = itr->second.find(meta->hero_lv());
if (itr2 == itr->second.end()) {
itr->second[meta->hero_lv()] = GraspBuffs();
}
itr2 = itr->second.find(meta->hero_lv());
if (itr2 == itr->second.end()) {
abort();
}
}
});
}
std::vector<const mt::GraspBuff*>* Grasp::GetGrasp(int hero_id, int hero_lv, int weapon_id)
GraspBuffs* Grasp::GetGrasp(int hero_id, int hero_lv, int weapon_id)
{
auto itr = hero_weapon_hash_.find(a8::MakeInt64(hero_id, weapon_id));
if (itr != hero_weapon_hash_.end()) {

View File

@ -2,10 +2,11 @@
#include "mt/macro.h"
#include "mtb/Grasp.h"
#include "mtb/GraspBuff.h"
#include "mt/GraspBuff.h"
namespace mt
{
typedef std::vector<std::tuple<const mt::GraspBuff*, const mt::GraspBuff*>> GraspBuffs;
DECLARE_ID_TABLE(Grasp, mtb::Grasp,
"grasp@grasp.json",
@ -20,10 +21,10 @@ namespace mt
const mt::GraspBuff* floor2_buff_meta = nullptr;
const mt::GraspBuff* buff2_meta = nullptr;
static std::vector<const mt::GraspBuff*>* GetGrasp(int hero_id, int hero_lv, int weapon_id);
static GraspBuffs* GetGrasp(int hero_id, int hero_lv, int weapon_id);
private:
static std::map<long long, std::map<int, std::vector<const mt::GraspBuff*>>> hero_weapon_hash_;
static std::map<long long, std::map<int, GraspBuffs>> hero_weapon_hash_;
};
}