From 0764bba1b2f0222a3f91df626f656f98a2c015df Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 21 Oct 2023 14:27:27 +0800 Subject: [PATCH] 1 --- server/gameserver/android_agent.cc | 8 +++++++- server/gameserver/hero_agent.cc | 8 ++++---- server/gameserver/hero_agent.h | 8 ++++---- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/server/gameserver/android_agent.cc b/server/gameserver/android_agent.cc index 6e9a4476..ef2867d1 100644 --- a/server/gameserver/android_agent.cc +++ b/server/gameserver/android_agent.cc @@ -2,6 +2,8 @@ #include "android_agent.h" +#include "human.h" + AndroidAgent::AndroidAgent():HeroAgent() { @@ -13,5 +15,9 @@ AndroidAgent::~AndroidAgent() const std::string AndroidAgent::GetAccountId() { - + if (owner_->IsHuman()) { + return owner_->AsHuman()->account_id; + } else { + return ""; + } } diff --git a/server/gameserver/hero_agent.cc b/server/gameserver/hero_agent.cc index 32aadb6e..c8db3692 100644 --- a/server/gameserver/hero_agent.cc +++ b/server/gameserver/hero_agent.cc @@ -648,11 +648,11 @@ void HeroAgent::UnSetFlag(int tag) a8::UnSetBitFlag(flags_, tag); } -behaviac::EBTStatus HeroAgent::StartCoroutine(std::shared_ptr coroutine) +behaviac::EBTStatus HeroAgent::StartCoroutine(std::shared_ptr co) { - coroutine_ = coroutine; - status_ = behaviac::BT_RUNNING; - return status_; + coroutines_hash_[co->GetId()] = co; + list_add_tail(&coroutines_list_, &co->entry); + return behaviac::BT_RUNNING; } behaviac::EBTStatus HeroAgent::RegisterEvents(behaviac::vector events) diff --git a/server/gameserver/hero_agent.h b/server/gameserver/hero_agent.h index 5c6c0de5..4f524397 100644 --- a/server/gameserver/hero_agent.h +++ b/server/gameserver/hero_agent.h @@ -141,18 +141,18 @@ public: protected: bool PreEnterCoroutine(int co_id, behaviac::EBTStatus& status); - behaviac::EBTStatus StartCoroutine(std::shared_ptr coroutine); + behaviac::EBTStatus StartCoroutine(std::shared_ptr co); bool InternalUseSkill(int skill_id, int& wait_time); void CheckCoroutineEvent(); -private: + Creature* owner_ = nullptr; + +private: bool bullet_trace_mode_ = false; long long flags_ = 0; std::map dyn_hash_; - behaviac::EBTStatus status_= behaviac::BT_SUCCESS; - std::shared_ptr coroutine_; std::map> coroutines_hash_; list_head coroutines_list_; };