feat: 新增回调 AllTaskCompleted 回调消息 runned_tasks 字段,并修复公招计算、自动战斗完成后也会触发完成后动作的问题

https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/955
This commit is contained in:
MistEO
2022-06-23 02:25:31 +08:00
parent 8276c12b7d
commit 72ea71f705
4 changed files with 75 additions and 22 deletions

View File

@@ -201,6 +201,7 @@ void Assistant::working_proc()
{
LogTraceFunction;
std::vector<TaskId> runned_tasks;
while (!m_thread_exit) {
//LogTraceScope("Assistant::working_proc Loop");
@@ -211,7 +212,7 @@ void Assistant::working_proc()
json::value callback_json = json::object{
{ "taskchain", task_ptr->get_task_chain() },
{ "taskid", task_ptr->get_task_id() }
{ "taskid", id }
};
task_callback(AsstMsg::TaskChainStart, callback_json, this);
@@ -220,6 +221,7 @@ void Assistant::working_proc()
.set_status(m_status);
bool ret = task_ptr->run();
runned_tasks.emplace_back(id);
lock.lock();
if (!m_tasks_list.empty()) {
@@ -235,6 +237,7 @@ void Assistant::working_proc()
if (!m_thread_idle && m_tasks_list.empty()) {
task_callback(AsstMsg::AllTasksCompleted, callback_json, this);
runned_tasks.clear();
}
auto delay = Resrc.cfg().get_options().task_delay;
@@ -244,6 +247,7 @@ void Assistant::working_proc()
}
else {
m_thread_idle = true;
runned_tasks.clear();
Log.flush();
m_condvar.wait(lock);
}