From 859751f74d671ecaa36d777450803ece85a72bf4 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Fri, 1 Oct 2021 18:42:36 -0500 Subject: [PATCH] Revert "Shared task kill update fix" This reverts commit 91c451b6c588338357e86b85f003401b336dcca6. --- zone/task_client_state.cpp | 182 +++++++++++++++++-------------------- 1 file changed, 82 insertions(+), 100 deletions(-) diff --git a/zone/task_client_state.cpp b/zone/task_client_state.cpp index e3ed80637..e00960238 100644 --- a/zone/task_client_state.cpp +++ b/zone/task_client_state.cpp @@ -2739,128 +2739,110 @@ void ClientTaskState::SyncSharedTaskZoneClientDoneCountState( void ClientTaskState::HandleUpdateTasksOnKill(Client *client, uint32 npc_type_id) { - - // get clients to update - std::vector clients_to_update = {}; - - // raid - Raid *raid = entity_list.GetRaidByClient(client); - if (raid) { - for (auto &e : raid->members) { - if (e.member && e.member->IsClient()) { - clients_to_update.push_back(e.member->CastToClient()); - } - } + if (!HasActiveTasks()) { + return; } - // group - if (!clients_to_update.empty()) { - Group *group = entity_list.GetGroupByClient(client); - if (group) { - for (auto &m : group->members) { - if (m && m->IsClient()) { - clients_to_update.push_back(m->CastToClient()); - } - } - } - } - - // solo - if (!clients_to_update.empty()) { - clients_to_update.push_back(client); - } - - for (auto &c: clients_to_update) { - if (c->ClientDataLoaded()) { + // loop over the union of tasks and quests + for (auto &active_task : m_active_tasks) { + auto current_task = &active_task; + if (current_task->task_id == TASKSLOTEMPTY) { continue; } - LogTasksDetail("[HandleUpdateTasksOnKill] Looping through client [{}]", c->GetCleanName()); + // Check if there are any active kill activities for this p_task_data + auto p_task_data = task_manager->m_task_data[current_task->task_id]; + if (p_task_data == nullptr) { + return; + } - // loop over the union of tasks and quests - for (auto &active_task : c->GetTaskState()->m_active_tasks) { - auto current_task = &active_task; - if (current_task->task_id == TASKSLOTEMPTY) { + for (int activity_id = 0; activity_id < p_task_data->activity_count; activity_id++) { + ClientActivityInformation *client_activity = ¤t_task->activity[activity_id]; + ActivityInformation *activity_info = &p_task_data->activity_information[activity_id]; + + // We are not interested in completed or hidden activities + if (client_activity->activity_state != ActivityActive) { continue; } - // Check if there are any active kill activities for this p_task_data - auto p_task_data = task_manager->m_task_data[current_task->task_id]; - if (p_task_data == nullptr) { - return; + // We are only interested in Kill activities + if (activity_info->activity_type != TaskActivityType::Kill) { + continue; } - for (int activity_id = 0; activity_id < p_task_data->activity_count; activity_id++) { - ClientActivityInformation *client_activity = ¤t_task->activity[activity_id]; - ActivityInformation *activity_info = &p_task_data->activity_information[activity_id]; - - // We are not interested in completed or hidden activities - if (client_activity->activity_state != ActivityActive) { - continue; - } - - // We are only interested in Kill activities - if (activity_info->activity_type != TaskActivityType::Kill) { - continue; - } - - // Is there a zone restriction on the activity_information ? - if (!activity_info->CheckZone(zone->GetZoneID())) { - LogTasks( - "[HandleUpdateTasksOnKill] character [{}] task_id [{}] activity_id [{}] activity_type [{}] for NPC [{}] failed zone check", - client->GetName(), - current_task->task_id, - activity_id, - static_cast(TaskActivityType::Kill), - npc_type_id - ); - continue; - } - // Is the activity_information to kill this type of NPC ? - switch (activity_info->goal_method) { - case METHODSINGLEID: - if (activity_info->goal_id != npc_type_id) { - LogTasksDetail("[HandleUpdateTasksOnKill] Matched single goal"); - continue; - } - break; - - case METHODLIST: - if (!task_manager->m_goal_list_manager.IsInList( - activity_info->goal_id, - (int) npc_type_id - )) { - LogTasksDetail("[HandleUpdateTasksOnKill] Matched list goal"); - continue; - } - break; - - default: - // If METHODQUEST, don't updated the activity_information here + // Is there a zone restriction on the activity_information ? + if (!activity_info->CheckZone(zone->GetZoneID())) { + LogTasks( + "[HandleUpdateTasksOnKill] character [{}] task_id [{}] activity_id [{}] activity_type [{}] for NPC [{}] failed zone check", + client->GetName(), + current_task->task_id, + activity_id, + static_cast(TaskActivityType::Kill), + npc_type_id + ); + continue; + } + // Is the activity_information to kill this type of NPC ? + switch (activity_info->goal_method) { + case METHODSINGLEID: + if (activity_info->goal_id != npc_type_id) { + LogTasksDetail("[HandleUpdateTasksOnKill] Matched single goal"); continue; - } + } + break; - LogTasksDetail("[HandleUpdateTasksOnKill] passed checks"); + case METHODLIST: + if (!task_manager->m_goal_list_manager.IsInList( + activity_info->goal_id, + (int) npc_type_id + )) { + LogTasksDetail("[HandleUpdateTasksOnKill] Matched list goal"); + continue; + } + break; - // handle actual update - // legacy eqemu task update logic loops through group on kill of npc to update a single task - if (p_task_data->type != TaskType::Shared) { - LogTasksDetail("[HandleUpdateTasksOnKill] Non-Shared Update"); - IncrementDoneCount(c, p_task_data, current_task->slot, activity_id); + default: + // If METHODQUEST, don't updated the activity_information here + continue; + } + + LogTasksDetail("[HandleUpdateTasksOnKill] passed checks"); + + // handle actual update + // legacy eqemu task update logic loops through group on kill of npc to update a single task + if (p_task_data->type != TaskType::Shared) { + LogTasksDetail("[HandleUpdateTasksOnKill] Non-Shared Update"); + + Raid *raid = entity_list.GetRaidByClient(client); + if (raid) { + for (auto &e : raid->members) { + if (e.member && e.member->IsClient()) { + Client *c = e.member->CastToClient(); + c->UpdateTasksOnKill(npc_type_id); + } + } return; } - LogTasksDetail("[HandleUpdateTasksOnKill] Shared update"); - - // shared tasks only require one client to receive an update to propagate - if (c == client) { - IncrementDoneCount(c, p_task_data, current_task->slot, activity_id); + Group *group = entity_list.GetGroupByClient(client); + if (group) { + for (auto &m : group->members) { + if (m && m->IsClient()) { + Client *c = m->CastToClient(); + c->UpdateTasksOnKill(npc_type_id); + } + } + return; } } + + LogTasksDetail("[HandleUpdateTasksOnKill] Shared update"); + + // shared tasks only require one client to receive an update to propagate + client->UpdateTasksOnKill(npc_type_id); } } } - bool ClientTaskState::HasActiveTasks() { if (!task_manager) {