From 0d9b301a150cacc3f7e36c0ffdf3e1bda6c2fafb Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 6 Sep 2022 15:29:19 +0800 Subject: [PATCH] 1 --- server/gameserver/battledatacontext.cc | 8 ++++++-- server/gameserver/battledatacontext.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/server/gameserver/battledatacontext.cc b/server/gameserver/battledatacontext.cc index b63dd532..a1e82a4c 100644 --- a/server/gameserver/battledatacontext.cc +++ b/server/gameserver/battledatacontext.cc @@ -50,6 +50,12 @@ float* GetAttrRatePtr(std::array& attr, int attr_id) return &attr[attr_id]; } +BattleDataContext::BattleDataContext() +{ + hero_ability_ = std::make_shared(); + hero_ability_->hero_meta = MetaMgr::Instance()->human_meta; +} + void BattleDataContext::Clear() { if (hero_ability_) { @@ -74,7 +80,6 @@ void BattleDataContext::ParseResult(a8::XObject& obj) errmsg = obj.Get("errmsg").GetString(); if (obj.HasKey("hero_dto") && obj.At("hero_dto")->IsObject()) { hero_dto = obj.At("hero_dto"); - hero_ability_ = std::make_shared(); hero_ability_->hero_uniid_ = hero_dto->Get("hero_uniid", ""); if (hero_dto->HasKey("attr") && hero_dto->IsArray()) { ApplyAttr(hero_ability_->attr_abs_, @@ -378,7 +383,6 @@ void BattleDataContext::ForceInit(long long hero_uniid, long long weapon2_uniid, MetaData::Equip* weapon2_meta) { - hero_ability_ = std::make_shared(); hero_ability_->hero_uniid_ = hero_uniid; hero_ability_->hero_meta = hum_meta; if (weapon1_uniid && weapon1_meta) { diff --git a/server/gameserver/battledatacontext.h b/server/gameserver/battledatacontext.h index 8b622a5a..971d6a03 100644 --- a/server/gameserver/battledatacontext.h +++ b/server/gameserver/battledatacontext.h @@ -37,6 +37,7 @@ struct BattleDataContext std::shared_ptr weapon_dto1; std::shared_ptr weapon_dto2; + BattleDataContext(); float GetHeroAttrAbs(long long hero_uniid, int attr_id); float GetHeroAttrRate(long long hero_uniid, int attr_id);