From 7762d7974c9ed5241bace069a26a20aa5347acd2 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 31 Oct 2023 14:22:44 +0800 Subject: [PATCH] 1 --- server/gameserver/base_agent.h | 11 ++++++++++- server/gameserver/btcoroutine.cc | 6 ++++++ server/gameserver/btcoroutine.h | 4 ++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/server/gameserver/base_agent.h b/server/gameserver/base_agent.h index beedb4e8..20fb1e4b 100644 --- a/server/gameserver/base_agent.h +++ b/server/gameserver/base_agent.h @@ -9,7 +9,16 @@ #include "btcontext.h" #define PRE_ENTER_COROUTINE() \ - const int co_id = __LINE__; \ + const int co_id = 1000 + __LINE__; \ + { \ + behaviac::EBTStatus status; \ + if (PreEnterCoroutine(co_id, status)) { \ + return status; \ + } \ + } + +#define PRE_ENTER_COROUTINE_EX(ID) \ + const int co_id = ID; \ { \ behaviac::EBTStatus status; \ if (PreEnterCoroutine(co_id, status)) { \ diff --git a/server/gameserver/btcoroutine.cc b/server/gameserver/btcoroutine.cc index a74f8622..174a4297 100644 --- a/server/gameserver/btcoroutine.cc +++ b/server/gameserver/btcoroutine.cc @@ -6,3 +6,9 @@ #include "base_agent.h" #include "btcontext.h" #include "btevent.h" + +void BtCoroutine::Abort(long long frameno) +{ + is_abort_ = true; + abort_frameno = frameno; +} diff --git a/server/gameserver/btcoroutine.h b/server/gameserver/btcoroutine.h index 7b207b0e..37fcc336 100644 --- a/server/gameserver/btcoroutine.h +++ b/server/gameserver/btcoroutine.h @@ -13,6 +13,7 @@ class BtCoroutine long long sleep_end_frameno = 0; int sleep_time = 0; list_head entry; + long long abort_frameno = 0; behaviac::EBTStatus status = behaviac::BT_RUNNING; BtCoroutine(std::shared_ptr context, int id, const char* name) @@ -26,10 +27,13 @@ class BtCoroutine const char* GetName() const { return name_; } auto GetContext() { return context_; } int GetId() { return id_; } + bool IsAbort() { return is_abort_; } + void Abort(long long frameno); private: std::shared_ptr context_; const char* name_ = nullptr; int id_ = 0; + bool is_abort_ = false; };