mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
[Tasks] Add method to filter shared task offers (#2497)
This commit is contained in:
parent
7abb02655d
commit
5708164511
@ -100,7 +100,7 @@ bool TaskManager::LoadTasks(int single_task)
|
||||
LogTasksDetail(
|
||||
"[LoadTasks] (Task) task_id [{}] type [{}] () duration [{}] duration_code [{}] title [{}] description [{}] "
|
||||
" reward_text [{}] reward_id_list [{}] cash_reward [{}] exp_reward [{}] reward_method [{}] faction_reward [{}] min_level [{}] "
|
||||
" max_level [{}] level_spread [{}] min_players [{}] max_players [{}] repeatable [{}] completion_emote [{}]",
|
||||
" max_level [{}] level_spread [{}] min_players [{}] max_players [{}] repeatable [{}] completion_emote [{}]"
|
||||
" replay_group [{}] replay_timer_seconds [{}] request_group [{}] request_timer_seconds [{}]",
|
||||
task.id,
|
||||
task.type,
|
||||
@ -722,15 +722,9 @@ void TaskManager::SharedTaskSelector(Client* client, Mob* mob, const std::vector
|
||||
std::vector<int> task_list;
|
||||
|
||||
for (int i = 0; i < tasks.size() && task_list.size() < MAXCHOOSERENTRIES; ++i) {
|
||||
// todo: are there non repeatable shared tasks? (would need to check all group/raid members)
|
||||
auto task = tasks[i];
|
||||
const auto task_data = GetTaskData(task);
|
||||
if (task_data &&
|
||||
task_data->type == TaskType::Shared &&
|
||||
request.lowest_level >= task_data->min_level &&
|
||||
(task_data->max_level == 0 || request.highest_level <= task_data->max_level))
|
||||
if (CanOfferSharedTask(tasks[i], request))
|
||||
{
|
||||
task_list.push_back(task);
|
||||
task_list.push_back(tasks[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -744,6 +738,39 @@ void TaskManager::SharedTaskSelector(Client* client, Mob* mob, const std::vector
|
||||
}
|
||||
}
|
||||
|
||||
bool TaskManager::CanOfferSharedTask(int task_id, const SharedTaskRequest& request)
|
||||
{
|
||||
// todo: are there non repeatable shared tasks? (would need to check all group/raid members)
|
||||
const auto task = GetTaskData(task_id);
|
||||
if (!task)
|
||||
{
|
||||
LogTasksDetail("[CanOfferSharedTask] task data for task id [{}] not found", task_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (task->type != TaskType::Shared)
|
||||
{
|
||||
LogTasksDetail("[CanOfferSharedTask] task [{}] is not a shared task type", task_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (task->min_level > 0 && request.lowest_level < task->min_level)
|
||||
{
|
||||
LogTasksDetail("[CanOfferSharedTask] lowest level [{}] is below task [{}] min level [{}]",
|
||||
request.lowest_level, task_id, task->min_level);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (task->max_level > 0 && request.highest_level > task->max_level)
|
||||
{
|
||||
LogTasksDetail("[CanOfferSharedTask] highest level [{}] exceeds task [{}] max level [{}]",
|
||||
request.highest_level, task_id, task->max_level);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// sends task selector to client
|
||||
void TaskManager::SendTaskSelector(Client* client, Mob* mob, const std::vector<int>& task_list)
|
||||
{
|
||||
|
||||
@ -11,8 +11,8 @@
|
||||
#include <algorithm>
|
||||
|
||||
class Client;
|
||||
|
||||
class Mob;
|
||||
class SharedTaskRequest;
|
||||
|
||||
class TaskManager {
|
||||
|
||||
@ -81,6 +81,7 @@ private:
|
||||
void SendActiveTaskToClient(ClientTaskInformation *task, Client *client, int task_index, bool task_complete);
|
||||
|
||||
// shared tasks
|
||||
bool CanOfferSharedTask(int task_id, const SharedTaskRequest& request);
|
||||
void SyncClientSharedTaskWithPersistedState(Client *c, ClientTaskState *cts);
|
||||
void SyncClientSharedTaskRemoveLocalIfNotExists(Client *c, ClientTaskState *cts);
|
||||
void SendSharedTaskSelector(Client* client, Mob* mob, const std::vector<int>& tasks);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user