mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 14:41:28 +00:00
Split task classes into their own cpp/h files to speed up incremental compilation and make things easier to maintain
This commit is contained in:
parent
55d4865d36
commit
ff5ea82e38
@ -133,6 +133,11 @@ SET(zone_sources
|
|||||||
special_attacks.cpp
|
special_attacks.cpp
|
||||||
spell_effects.cpp
|
spell_effects.cpp
|
||||||
spells.cpp
|
spells.cpp
|
||||||
|
task_client_state.cpp
|
||||||
|
task_client_state.cpp
|
||||||
|
task_goal_list_manager.cpp
|
||||||
|
task_manager.cpp
|
||||||
|
task_proximity_manager.cpp
|
||||||
tasks.cpp
|
tasks.cpp
|
||||||
titles.cpp
|
titles.cpp
|
||||||
tradeskills.cpp
|
tradeskills.cpp
|
||||||
@ -151,8 +156,7 @@ SET(zone_sources
|
|||||||
zonedb.cpp
|
zonedb.cpp
|
||||||
zone_reload.cpp
|
zone_reload.cpp
|
||||||
zone_store.cpp
|
zone_store.cpp
|
||||||
zoning.cpp
|
zoning.cpp)
|
||||||
)
|
|
||||||
|
|
||||||
SET(zone_headers
|
SET(zone_headers
|
||||||
aa.h
|
aa.h
|
||||||
@ -252,6 +256,10 @@ SET(zone_headers
|
|||||||
spawn2.h
|
spawn2.h
|
||||||
spawngroup.h
|
spawngroup.h
|
||||||
string_ids.h
|
string_ids.h
|
||||||
|
task_client_state.h
|
||||||
|
task_goal_list_manager.h
|
||||||
|
task_manager.h
|
||||||
|
task_proximity_manager.h
|
||||||
tasks.h
|
tasks.h
|
||||||
titles.h
|
titles.h
|
||||||
trap.h
|
trap.h
|
||||||
@ -265,8 +273,7 @@ SET(zone_headers
|
|||||||
zonedb.h
|
zonedb.h
|
||||||
zonedump.h
|
zonedump.h
|
||||||
zone_reload.h
|
zone_reload.h
|
||||||
zone_store.h
|
zone_store.h)
|
||||||
)
|
|
||||||
|
|
||||||
ADD_EXECUTABLE(zone ${zone_sources} ${zone_headers})
|
ADD_EXECUTABLE(zone ${zone_sources} ${zone_headers})
|
||||||
|
|
||||||
|
|||||||
@ -65,6 +65,8 @@ namespace EQ
|
|||||||
#include "zone.h"
|
#include "zone.h"
|
||||||
#include "zonedb.h"
|
#include "zonedb.h"
|
||||||
#include "zone_store.h"
|
#include "zone_store.h"
|
||||||
|
#include "task_manager.h"
|
||||||
|
#include "task_client_state.h"
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
// since windows defines these within windef.h (which windows.h include)
|
// since windows defines these within windef.h (which windows.h include)
|
||||||
|
|||||||
2135
zone/task_client_state.cpp
Normal file
2135
zone/task_client_state.cpp
Normal file
File diff suppressed because it is too large
Load Diff
110
zone/task_client_state.h
Normal file
110
zone/task_client_state.h
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
#ifndef EQEMU_TASK_CLIENT_STATE_H
|
||||||
|
#define EQEMU_TASK_CLIENT_STATE_H
|
||||||
|
|
||||||
|
#include "tasks.h"
|
||||||
|
#include "../common/types.h"
|
||||||
|
#include <list>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
class ClientTaskState {
|
||||||
|
|
||||||
|
public:
|
||||||
|
ClientTaskState();
|
||||||
|
~ClientTaskState();
|
||||||
|
void ShowClientTasks(Client *client);
|
||||||
|
inline int GetActiveTaskCount() { return active_task_count; }
|
||||||
|
int GetActiveTaskID(int index);
|
||||||
|
bool IsTaskActivityCompleted(TaskType task_type, int index, int activity_id);
|
||||||
|
int GetTaskActivityDoneCount(TaskType task_type, int index, int activity_id);
|
||||||
|
int GetTaskActivityDoneCountFromTaskID(int task_id, int activity_id);
|
||||||
|
int GetTaskStartTime(TaskType task_type, int index);
|
||||||
|
void AcceptNewTask(Client *client, int task_id, int npc_type_id, bool enforce_level_requirement = false);
|
||||||
|
void FailTask(Client *client, int task_id);
|
||||||
|
int TaskTimeLeft(int task_id);
|
||||||
|
int IsTaskCompleted(int task_id);
|
||||||
|
bool IsTaskActive(int task_id);
|
||||||
|
bool IsTaskActivityActive(int task_id, int activity_id);
|
||||||
|
ActivityState GetTaskActivityState(TaskType task_type, int index, int activity_id);
|
||||||
|
void UpdateTaskActivity(Client *client, int task_id, int activity_id, int count, bool ignore_quest_update = false);
|
||||||
|
void ResetTaskActivity(Client *client, int task_id, int activity_id);
|
||||||
|
void CancelTask(Client *client, int sequence_number, TaskType task_type, bool remove_from_db = true);
|
||||||
|
void CancelAllTasks(Client *client);
|
||||||
|
void RemoveTask(Client *client, int sequence_number, TaskType task_type);
|
||||||
|
void RemoveTaskByTaskID(Client *client, uint32 task_id);
|
||||||
|
bool UpdateTasksByNPC(Client *client, int activity_type, int npc_type_id);
|
||||||
|
void UpdateTasksOnKill(Client *client, int npc_type_id);
|
||||||
|
void UpdateTasksForItem(Client *client, ActivityType activity_type, int item_id, int count = 1);
|
||||||
|
void UpdateTasksOnExplore(Client *client, int explore_id);
|
||||||
|
bool UpdateTasksOnSpeakWith(Client *client, int npc_type_id);
|
||||||
|
bool UpdateTasksOnDeliver(Client *client, std::list<EQ::ItemInstance *> &items, int cash, int npc_type_id);
|
||||||
|
void UpdateTasksOnTouch(Client *client, int zone_id);
|
||||||
|
void ProcessTaskProximities(Client *client, float x, float y, float z);
|
||||||
|
bool TaskOutOfTime(TaskType task_type, int index);
|
||||||
|
void TaskPeriodicChecks(Client *client);
|
||||||
|
void SendTaskHistory(Client *client, int task_index);
|
||||||
|
void RewardTask(Client *client, TaskInformation *task_information);
|
||||||
|
void EnableTask(int character_id, int task_count, int *task_list);
|
||||||
|
void DisableTask(int character_id, int task_count, int *task_list);
|
||||||
|
bool IsTaskEnabled(int task_id);
|
||||||
|
int EnabledTaskCount(int task_set_id);
|
||||||
|
int ActiveSpeakTask(int npc_type_id);
|
||||||
|
int ActiveSpeakActivity(int npc_type_id, int task_id);
|
||||||
|
int ActiveTasksInSet(int task_set_id);
|
||||||
|
int CompletedTasksInSet(int task_set_id);
|
||||||
|
bool HasSlotForTask(TaskInformation *task);
|
||||||
|
|
||||||
|
inline bool HasFreeTaskSlot() { return active_task.task_id == TASKSLOTEMPTY; }
|
||||||
|
|
||||||
|
friend class TaskManager;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool UnlockActivities(int character_id, ClientTaskInformation &task_info);
|
||||||
|
void IncrementDoneCount(
|
||||||
|
Client *client,
|
||||||
|
TaskInformation *task_information,
|
||||||
|
int task_index,
|
||||||
|
int activity_id,
|
||||||
|
int count = 1,
|
||||||
|
bool ignore_quest_update = false
|
||||||
|
);
|
||||||
|
inline ClientTaskInformation *GetClientTaskInfo(TaskType task_type, int index)
|
||||||
|
{
|
||||||
|
ClientTaskInformation *info = nullptr;
|
||||||
|
switch (task_type) {
|
||||||
|
case TaskType::Task:
|
||||||
|
if (index == 0) {
|
||||||
|
info = &active_task;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TaskType::Shared:
|
||||||
|
break;
|
||||||
|
case TaskType::Quest:
|
||||||
|
if (index < MAXACTIVEQUESTS) {
|
||||||
|
info = &active_quests[index];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
int active_task_count;
|
||||||
|
|
||||||
|
union { // easier to loop over
|
||||||
|
struct {
|
||||||
|
ClientTaskInformation active_task; // only one
|
||||||
|
ClientTaskInformation active_quests[MAXACTIVEQUESTS];
|
||||||
|
};
|
||||||
|
ClientTaskInformation active_tasks[MAXACTIVEQUESTS + 1];
|
||||||
|
};
|
||||||
|
// Shared tasks should be limited to 1 as well
|
||||||
|
std::vector<int> enabled_tasks;
|
||||||
|
std::vector<CompletedTaskInformation> completed_tasks;
|
||||||
|
int last_completed_task_loaded;
|
||||||
|
bool checked_touch_activities;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //EQEMU_TASK_CLIENT_STATE_H
|
||||||
149
zone/task_goal_list_manager.cpp
Normal file
149
zone/task_goal_list_manager.cpp
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
#include "../common/global_define.h"
|
||||||
|
#include "../common/misc_functions.h"
|
||||||
|
#include "../common/repositories/goallists_repository.h"
|
||||||
|
#include "../common/rulesys.h"
|
||||||
|
#include "client.h"
|
||||||
|
#include "mob.h"
|
||||||
|
#include "quest_parser_collection.h"
|
||||||
|
#include "task_goal_list_manager.h"
|
||||||
|
#include "tasks.h"
|
||||||
|
#include "zonedb.h"
|
||||||
|
|
||||||
|
TaskGoalListManager::TaskGoalListManager()
|
||||||
|
{
|
||||||
|
goal_lists_count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
TaskGoalListManager::~TaskGoalListManager() {}
|
||||||
|
|
||||||
|
bool TaskGoalListManager::LoadLists()
|
||||||
|
{
|
||||||
|
task_goal_lists.clear();
|
||||||
|
goal_lists_count = 0;
|
||||||
|
|
||||||
|
std::string query = "SELECT `listid`, COUNT(`entry`) FROM `goallists` GROUP by `listid` ORDER BY `listid`";
|
||||||
|
auto results = content_db.QueryDatabase(query);
|
||||||
|
if (!results.Success()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
goal_lists_count = results.RowCount();
|
||||||
|
LogTasks("Loaded [{}] GoalLists", goal_lists_count);
|
||||||
|
|
||||||
|
task_goal_lists.reserve(goal_lists_count);
|
||||||
|
|
||||||
|
int list_index = 0;
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
int list_id = atoi(row[0]);
|
||||||
|
int list_size = atoi(row[1]);
|
||||||
|
|
||||||
|
task_goal_lists.push_back({list_id, 0, 0});
|
||||||
|
|
||||||
|
task_goal_lists[list_index].GoalItemEntries.reserve(list_size);
|
||||||
|
|
||||||
|
list_index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto goal_lists = GoallistsRepository::GetWhere(content_db, "TRUE ORDER BY listid, entry ASC");
|
||||||
|
for (list_index = 0; list_index < goal_lists_count; list_index++) {
|
||||||
|
|
||||||
|
int list_id = task_goal_lists[list_index].ListID;
|
||||||
|
|
||||||
|
for (auto &entry: goal_lists) {
|
||||||
|
if (entry.listid == list_id) {
|
||||||
|
if (entry.entry < task_goal_lists[list_index].Min) {
|
||||||
|
task_goal_lists[list_index].Min = entry.entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.entry > task_goal_lists[list_index].Max) {
|
||||||
|
task_goal_lists[list_index].Max = entry.entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
task_goal_lists[list_index].GoalItemEntries.push_back(entry.entry);
|
||||||
|
|
||||||
|
LogTasksDetail(
|
||||||
|
"Goal list index [{}] loading list [{}] entry [{}]",
|
||||||
|
list_index,
|
||||||
|
list_id,
|
||||||
|
entry.entry
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int TaskGoalListManager::GetListByID(int list_id)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Find the list with the specified ListID and return the index
|
||||||
|
auto it = std::find_if(
|
||||||
|
task_goal_lists.begin(),
|
||||||
|
task_goal_lists.end(),
|
||||||
|
[list_id](const TaskGoalList_Struct &t) { return t.ListID == list_id; }
|
||||||
|
);
|
||||||
|
|
||||||
|
if (it == task_goal_lists.end()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::distance(task_goal_lists.begin(), it);
|
||||||
|
}
|
||||||
|
|
||||||
|
int TaskGoalListManager::GetFirstEntry(int list_id)
|
||||||
|
{
|
||||||
|
int list_by_id = GetListByID(list_id);
|
||||||
|
|
||||||
|
if ((list_by_id < 0) || (list_by_id >= goal_lists_count)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (task_goal_lists[list_by_id].GoalItemEntries.empty()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return task_goal_lists[list_by_id].GoalItemEntries[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<int> TaskGoalListManager::GetListContents(int list_index)
|
||||||
|
{
|
||||||
|
std::vector<int> list_contents;
|
||||||
|
int list_by_id = GetListByID(list_index);
|
||||||
|
|
||||||
|
if ((list_by_id < 0) || (list_by_id >= goal_lists_count)) {
|
||||||
|
return list_contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
list_contents = task_goal_lists[list_by_id].GoalItemEntries;
|
||||||
|
|
||||||
|
return list_contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TaskGoalListManager::IsInList(int list_id, int entry)
|
||||||
|
{
|
||||||
|
Log(Logs::General, Logs::Tasks, "[UPDATE] TaskGoalListManager::IsInList(%i, %i)", list_id, entry);
|
||||||
|
|
||||||
|
int list_index = GetListByID(list_id);
|
||||||
|
|
||||||
|
if ((list_index < 0) || (list_index >= goal_lists_count)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((entry < task_goal_lists[list_index].Min) || (entry > task_goal_lists[list_index].Max)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int first_entry = 0;
|
||||||
|
auto &task = task_goal_lists[list_index];
|
||||||
|
auto it = std::find(task.GoalItemEntries.begin(), task.GoalItemEntries.end(), entry);
|
||||||
|
|
||||||
|
if (it == task.GoalItemEntries.end()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log(Logs::General, Logs::Tasks, "[UPDATE] TaskGoalListManager::IsInList(%i, %i) returning true", list_index, entry);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
37
zone/task_goal_list_manager.h
Normal file
37
zone/task_goal_list_manager.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#ifndef EQEMU_TASK_GOAL_LIST_MANAGER_H
|
||||||
|
#define EQEMU_TASK_GOAL_LIST_MANAGER_H
|
||||||
|
|
||||||
|
#include "tasks.h"
|
||||||
|
#include "../common/types.h"
|
||||||
|
#include <list>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
struct TaskGoalList_Struct {
|
||||||
|
int ListID;
|
||||||
|
int Min, Max;
|
||||||
|
std::vector<int> GoalItemEntries;
|
||||||
|
};
|
||||||
|
|
||||||
|
// This is used for handling lists, loading them from the database, searching them.
|
||||||
|
// Used for lists of NPCs to kill, items to loot, etc, as well as lists of items to
|
||||||
|
// reward the player with on completion of the task.
|
||||||
|
class TaskGoalListManager {
|
||||||
|
|
||||||
|
public:
|
||||||
|
TaskGoalListManager();
|
||||||
|
~TaskGoalListManager();
|
||||||
|
bool LoadLists();
|
||||||
|
int GetListByID(int list_id);
|
||||||
|
bool IsInList(int list_id, int entry);
|
||||||
|
int GetFirstEntry(int list_id);
|
||||||
|
std::vector<int> GetListContents(int list_index);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<TaskGoalList_Struct> task_goal_lists;
|
||||||
|
int goal_lists_count;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //EQEMU_TASK_GOAL_LIST_MANAGER_H
|
||||||
1652
zone/task_manager.cpp
Normal file
1652
zone/task_manager.cpp
Normal file
File diff suppressed because it is too large
Load Diff
97
zone/task_manager.h
Normal file
97
zone/task_manager.h
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
#ifndef EQEMU_TASK_MANAGER_H
|
||||||
|
#define EQEMU_TASK_MANAGER_H
|
||||||
|
|
||||||
|
#include "tasks.h"
|
||||||
|
#include "task_client_state.h"
|
||||||
|
#include "task_proximity_manager.h"
|
||||||
|
#include "task_goal_list_manager.h"
|
||||||
|
#include "../common/types.h"
|
||||||
|
#include <list>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
class Client;
|
||||||
|
class Mob;
|
||||||
|
|
||||||
|
class TaskManager {
|
||||||
|
|
||||||
|
public:
|
||||||
|
TaskManager();
|
||||||
|
~TaskManager();
|
||||||
|
int GetActivityCount(int task_id);
|
||||||
|
bool LoadTasks(int single_task = 0);
|
||||||
|
void ReloadGoalLists();
|
||||||
|
inline void LoadProximities(int zone_id)
|
||||||
|
{
|
||||||
|
proximity_manager.LoadProximities(zone_id);
|
||||||
|
}
|
||||||
|
bool LoadTaskSets();
|
||||||
|
bool LoadClientState(Client *client, ClientTaskState *client_task_state);
|
||||||
|
bool SaveClientState(Client *client, ClientTaskState *client_task_state);
|
||||||
|
void SendTaskSelector(Client *client, Mob *mob, int task_count, int *task_list);
|
||||||
|
void SendTaskSelectorNew(Client *client, Mob *mob, int task_count, int *task_list);
|
||||||
|
bool ValidateLevel(int task_id, int player_level);
|
||||||
|
std::string GetTaskName(uint32 task_id);
|
||||||
|
TaskType GetTaskType(uint32 task_id);
|
||||||
|
void TaskSetSelector(Client *client, ClientTaskState *client_task_state, Mob *mob, int task_set_id);
|
||||||
|
// task list provided by QuestManager (perl/lua)
|
||||||
|
void TaskQuestSetSelector(
|
||||||
|
Client *client,
|
||||||
|
ClientTaskState *client_task_state,
|
||||||
|
Mob *mob,
|
||||||
|
int count,
|
||||||
|
int *tasks
|
||||||
|
);
|
||||||
|
void SendActiveTasksToClient(Client *client, bool task_complete = false);
|
||||||
|
void SendSingleActiveTaskToClient(
|
||||||
|
Client *client,
|
||||||
|
ClientTaskInformation &task_info,
|
||||||
|
bool task_complete,
|
||||||
|
bool bring_up_task_journal = false
|
||||||
|
);
|
||||||
|
void SendTaskActivityShort(Client *client, int task_id, int activity_id, int client_task_index);
|
||||||
|
void SendTaskActivityLong(
|
||||||
|
Client *client,
|
||||||
|
int task_id,
|
||||||
|
int activity_id,
|
||||||
|
int client_task_index,
|
||||||
|
bool optional,
|
||||||
|
bool task_complete = false
|
||||||
|
);
|
||||||
|
void SendTaskActivityNew(
|
||||||
|
Client *client,
|
||||||
|
int task_id,
|
||||||
|
int activity_id,
|
||||||
|
int client_task_index,
|
||||||
|
bool optional,
|
||||||
|
bool task_complete = false
|
||||||
|
);
|
||||||
|
void SendCompletedTasksToClient(Client *c, ClientTaskState *client_task_state);
|
||||||
|
void ExplainTask(Client *client, int task_id);
|
||||||
|
int FirstTaskInSet(int task_set);
|
||||||
|
int LastTaskInSet(int task_set);
|
||||||
|
int NextTaskInSet(int task_set, int task_id);
|
||||||
|
bool IsTaskRepeatable(int task_id);
|
||||||
|
|
||||||
|
friend class ClientTaskState;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
TaskGoalListManager goal_list_manager;
|
||||||
|
TaskProximityManager proximity_manager;
|
||||||
|
TaskInformation *p_task_data[MAXTASKS]{};
|
||||||
|
std::vector<int> task_sets[MAXTASKSETS];
|
||||||
|
void SendActiveTaskDescription(
|
||||||
|
Client *client,
|
||||||
|
int task_id,
|
||||||
|
ClientTaskInformation &task_info,
|
||||||
|
int start_time,
|
||||||
|
int duration,
|
||||||
|
bool bring_up_task_journal = false
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //EQEMU_TASK_MANAGER_H
|
||||||
80
zone/task_proximity_manager.cpp
Normal file
80
zone/task_proximity_manager.cpp
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
#include "../common/global_define.h"
|
||||||
|
#include "../common/repositories/proximities_repository.h"
|
||||||
|
#include "../common/rulesys.h"
|
||||||
|
#include "client.h"
|
||||||
|
#include "mob.h"
|
||||||
|
#include "quest_parser_collection.h"
|
||||||
|
#include "task_proximity_manager.h"
|
||||||
|
#include "tasks.h"
|
||||||
|
#include "zonedb.h"
|
||||||
|
|
||||||
|
TaskProximityManager::TaskProximityManager()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TaskProximityManager::~TaskProximityManager()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TaskProximityManager::LoadProximities(int zone_id)
|
||||||
|
{
|
||||||
|
TaskProximity proximity{};
|
||||||
|
task_proximities.clear();
|
||||||
|
|
||||||
|
auto proximities = ProximitiesRepository::GetWhere(
|
||||||
|
content_db,
|
||||||
|
fmt::format("zoneid = {} ORDER BY `zoneid` ASC", zone_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
for (auto &row: proximities) {
|
||||||
|
proximity.explore_id = row.exploreid;
|
||||||
|
proximity.min_x = row.minx;
|
||||||
|
proximity.max_x = row.maxx;
|
||||||
|
proximity.min_y = row.miny;
|
||||||
|
proximity.max_y = row.maxy;
|
||||||
|
proximity.min_z = row.minz;
|
||||||
|
proximity.max_z = row.maxz;
|
||||||
|
|
||||||
|
task_proximities.push_back(proximity);
|
||||||
|
}
|
||||||
|
|
||||||
|
LogTasks("Loaded [{}] Task Proximities", proximities.size());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TaskProximityManager::CheckProximities(float x, float y, float z)
|
||||||
|
{
|
||||||
|
for (auto &task_proximity : task_proximities) {
|
||||||
|
|
||||||
|
TaskProximity *p_proximity = &task_proximity;
|
||||||
|
|
||||||
|
Log(
|
||||||
|
Logs::General,
|
||||||
|
Logs::Tasks,
|
||||||
|
"[Proximity] Checking %8.3f, %8.3f, %8.3f against %8.3f, %8.3f, %8.3f, %8.3f, %8.3f, %8.3f",
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
z,
|
||||||
|
p_proximity->min_x,
|
||||||
|
p_proximity->max_x,
|
||||||
|
p_proximity->min_y,
|
||||||
|
p_proximity->max_y,
|
||||||
|
p_proximity->min_z,
|
||||||
|
p_proximity->max_z
|
||||||
|
);
|
||||||
|
|
||||||
|
if (x < p_proximity->min_x || x > p_proximity->max_x || y < p_proximity->min_y || y > p_proximity->max_y ||
|
||||||
|
z < p_proximity->min_z || z > p_proximity->max_z) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return p_proximity->explore_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
27
zone/task_proximity_manager.h
Normal file
27
zone/task_proximity_manager.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef EQEMU_TASK_PROXIMITY_MANAGER_H
|
||||||
|
#define EQEMU_TASK_PROXIMITY_MANAGER_H
|
||||||
|
|
||||||
|
struct TaskProximity {
|
||||||
|
int explore_id;
|
||||||
|
float min_x;
|
||||||
|
float max_x;
|
||||||
|
float min_y;
|
||||||
|
float max_y;
|
||||||
|
float min_z;
|
||||||
|
float max_z;
|
||||||
|
};
|
||||||
|
|
||||||
|
// This class is used for managing proximities so that Quest NPC proximities don't need to be used.
|
||||||
|
class TaskProximityManager {
|
||||||
|
|
||||||
|
public:
|
||||||
|
TaskProximityManager();
|
||||||
|
~TaskProximityManager();
|
||||||
|
bool LoadProximities(int zone_id);
|
||||||
|
int CheckProximities(float x, float y, float z);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<TaskProximity> task_proximities;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_TASK_PROXIMITY_MANAGER_H
|
||||||
4002
zone/tasks.cpp
4002
zone/tasks.cpp
File diff suppressed because it is too large
Load Diff
225
zone/tasks.h
225
zone/tasks.h
@ -26,60 +26,13 @@
|
|||||||
#define RELOADTASKSETS 3
|
#define RELOADTASKSETS 3
|
||||||
|
|
||||||
class Client;
|
class Client;
|
||||||
|
|
||||||
class Mob;
|
class Mob;
|
||||||
|
|
||||||
namespace EQ {
|
namespace EQ {
|
||||||
class ItemInstance;
|
class ItemInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TaskGoalList_Struct {
|
|
||||||
int ListID;
|
|
||||||
int Min, Max;
|
|
||||||
std::vector<int> GoalItemEntries;
|
|
||||||
};
|
|
||||||
|
|
||||||
// This is used for handling lists, loading them from the database, searching them.
|
|
||||||
// Used for lists of NPCs to kill, items to loot, etc, as well as lists of items to
|
|
||||||
// reward the player with on completion of the task.
|
|
||||||
class TaskGoalListManager {
|
|
||||||
|
|
||||||
public:
|
|
||||||
TaskGoalListManager();
|
|
||||||
~TaskGoalListManager();
|
|
||||||
bool LoadLists();
|
|
||||||
int GetListByID(int list_id);
|
|
||||||
bool IsInList(int list_id, int entry);
|
|
||||||
int GetFirstEntry(int list_id);
|
|
||||||
std::vector<int> GetListContents(int list_index);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<TaskGoalList_Struct> task_goal_lists;
|
|
||||||
int goal_lists_count;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct TaskProximity {
|
|
||||||
int explore_id;
|
|
||||||
float min_x;
|
|
||||||
float max_x;
|
|
||||||
float min_y;
|
|
||||||
float max_y;
|
|
||||||
float min_z;
|
|
||||||
float max_z;
|
|
||||||
};
|
|
||||||
|
|
||||||
// This class is used for managing proximities so that Quest NPC proximities don't need to be used.
|
|
||||||
class TaskProximityManager {
|
|
||||||
|
|
||||||
public:
|
|
||||||
TaskProximityManager();
|
|
||||||
~TaskProximityManager();
|
|
||||||
bool LoadProximities(int zone_id);
|
|
||||||
int CheckProximities(float x, float y, float z);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<TaskProximity> task_proximities;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
METHODSINGLEID = 0,
|
METHODSINGLEID = 0,
|
||||||
@ -200,182 +153,4 @@ struct CompletedTaskInformation {
|
|||||||
bool activity_done[MAXACTIVITIESPERTASK];
|
bool activity_done[MAXACTIVITIESPERTASK];
|
||||||
};
|
};
|
||||||
|
|
||||||
class ClientTaskState {
|
|
||||||
|
|
||||||
public:
|
|
||||||
ClientTaskState();
|
|
||||||
~ClientTaskState();
|
|
||||||
void ShowClientTasks(Client *client);
|
|
||||||
inline int GetActiveTaskCount() { return active_task_count; }
|
|
||||||
int GetActiveTaskID(int index);
|
|
||||||
bool IsTaskActivityCompleted(TaskType task_type, int index, int activity_id);
|
|
||||||
int GetTaskActivityDoneCount(TaskType task_type, int index, int activity_id);
|
|
||||||
int GetTaskActivityDoneCountFromTaskID(int task_id, int activity_id);
|
|
||||||
int GetTaskStartTime(TaskType task_type, int index);
|
|
||||||
void AcceptNewTask(Client *client, int task_id, int npc_type_id, bool enforce_level_requirement = false);
|
|
||||||
void FailTask(Client *client, int task_id);
|
|
||||||
int TaskTimeLeft(int task_id);
|
|
||||||
int IsTaskCompleted(int task_id);
|
|
||||||
bool IsTaskActive(int task_id);
|
|
||||||
bool IsTaskActivityActive(int task_id, int activity_id);
|
|
||||||
ActivityState GetTaskActivityState(TaskType task_type, int index, int activity_id);
|
|
||||||
void UpdateTaskActivity(Client *client, int task_id, int activity_id, int count, bool ignore_quest_update = false);
|
|
||||||
void ResetTaskActivity(Client *client, int task_id, int activity_id);
|
|
||||||
void CancelTask(Client *client, int sequence_number, TaskType task_type, bool remove_from_db = true);
|
|
||||||
void CancelAllTasks(Client *client);
|
|
||||||
void RemoveTask(Client *client, int sequence_number, TaskType task_type);
|
|
||||||
void RemoveTaskByTaskID(Client *client, uint32 task_id);
|
|
||||||
bool UpdateTasksByNPC(Client *client, int activity_type, int npc_type_id);
|
|
||||||
void UpdateTasksOnKill(Client *client, int npc_type_id);
|
|
||||||
void UpdateTasksForItem(Client *client, ActivityType activity_type, int item_id, int count = 1);
|
|
||||||
void UpdateTasksOnExplore(Client *client, int explore_id);
|
|
||||||
bool UpdateTasksOnSpeakWith(Client *client, int npc_type_id);
|
|
||||||
bool UpdateTasksOnDeliver(Client *client, std::list<EQ::ItemInstance *> &items, int cash, int npc_type_id);
|
|
||||||
void UpdateTasksOnTouch(Client *client, int zone_id);
|
|
||||||
void ProcessTaskProximities(Client *client, float x, float y, float z);
|
|
||||||
bool TaskOutOfTime(TaskType task_type, int index);
|
|
||||||
void TaskPeriodicChecks(Client *client);
|
|
||||||
void SendTaskHistory(Client *client, int task_index);
|
|
||||||
void RewardTask(Client *client, TaskInformation *task_information);
|
|
||||||
void EnableTask(int character_id, int task_count, int *task_list);
|
|
||||||
void DisableTask(int character_id, int task_count, int *task_list);
|
|
||||||
bool IsTaskEnabled(int task_id);
|
|
||||||
int EnabledTaskCount(int task_set_id);
|
|
||||||
int ActiveSpeakTask(int npc_type_id);
|
|
||||||
int ActiveSpeakActivity(int npc_type_id, int task_id);
|
|
||||||
int ActiveTasksInSet(int task_set_id);
|
|
||||||
int CompletedTasksInSet(int task_set_id);
|
|
||||||
bool HasSlotForTask(TaskInformation *task);
|
|
||||||
|
|
||||||
inline bool HasFreeTaskSlot() { return active_task.task_id == TASKSLOTEMPTY; }
|
|
||||||
|
|
||||||
friend class TaskManager;
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool UnlockActivities(int character_id, ClientTaskInformation &task_info);
|
|
||||||
void IncrementDoneCount(
|
|
||||||
Client *client,
|
|
||||||
TaskInformation *task_information,
|
|
||||||
int task_index,
|
|
||||||
int activity_id,
|
|
||||||
int count = 1,
|
|
||||||
bool ignore_quest_update = false
|
|
||||||
);
|
|
||||||
inline ClientTaskInformation *GetClientTaskInfo(TaskType task_type, int index)
|
|
||||||
{
|
|
||||||
ClientTaskInformation *info = nullptr;
|
|
||||||
switch (task_type) {
|
|
||||||
case TaskType::Task:
|
|
||||||
if (index == 0) {
|
|
||||||
info = &active_task;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TaskType::Shared:
|
|
||||||
break;
|
|
||||||
case TaskType::Quest:
|
|
||||||
if (index < MAXACTIVEQUESTS) {
|
|
||||||
info = &active_quests[index];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
int active_task_count;
|
|
||||||
|
|
||||||
union { // easier to loop over
|
|
||||||
struct {
|
|
||||||
ClientTaskInformation active_task; // only one
|
|
||||||
ClientTaskInformation active_quests[MAXACTIVEQUESTS];
|
|
||||||
};
|
|
||||||
ClientTaskInformation active_tasks[MAXACTIVEQUESTS + 1];
|
|
||||||
};
|
|
||||||
// Shared tasks should be limited to 1 as well
|
|
||||||
std::vector<int> enabled_tasks;
|
|
||||||
std::vector<CompletedTaskInformation> completed_tasks;
|
|
||||||
int last_completed_task_loaded;
|
|
||||||
bool checked_touch_activities;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class TaskManager {
|
|
||||||
|
|
||||||
public:
|
|
||||||
TaskManager();
|
|
||||||
~TaskManager();
|
|
||||||
int GetActivityCount(int task_id);
|
|
||||||
bool LoadTasks(int single_task = 0);
|
|
||||||
void ReloadGoalLists();
|
|
||||||
inline void LoadProximities(int zone_id)
|
|
||||||
{
|
|
||||||
proximity_manager.LoadProximities(zone_id);
|
|
||||||
}
|
|
||||||
bool LoadTaskSets();
|
|
||||||
bool LoadClientState(Client *client, ClientTaskState *client_task_state);
|
|
||||||
bool SaveClientState(Client *client, ClientTaskState *client_task_state);
|
|
||||||
void SendTaskSelector(Client *client, Mob *mob, int task_count, int *task_list);
|
|
||||||
void SendTaskSelectorNew(Client *client, Mob *mob, int task_count, int *task_list);
|
|
||||||
bool ValidateLevel(int task_id, int player_level);
|
|
||||||
std::string GetTaskName(uint32 task_id);
|
|
||||||
TaskType GetTaskType(uint32 task_id);
|
|
||||||
void TaskSetSelector(Client *client, ClientTaskState *client_task_state, Mob *mob, int task_set_id);
|
|
||||||
// task list provided by QuestManager (perl/lua)
|
|
||||||
void TaskQuestSetSelector(
|
|
||||||
Client *client,
|
|
||||||
ClientTaskState *client_task_state,
|
|
||||||
Mob *mob,
|
|
||||||
int count,
|
|
||||||
int *tasks
|
|
||||||
);
|
|
||||||
void SendActiveTasksToClient(Client *client, bool task_complete = false);
|
|
||||||
void SendSingleActiveTaskToClient(
|
|
||||||
Client *client,
|
|
||||||
ClientTaskInformation &task_info,
|
|
||||||
bool task_complete,
|
|
||||||
bool bring_up_task_journal = false
|
|
||||||
);
|
|
||||||
void SendTaskActivityShort(Client *client, int task_id, int activity_id, int client_task_index);
|
|
||||||
void SendTaskActivityLong(
|
|
||||||
Client *client,
|
|
||||||
int task_id,
|
|
||||||
int activity_id,
|
|
||||||
int client_task_index,
|
|
||||||
bool optional,
|
|
||||||
bool task_complete = false
|
|
||||||
);
|
|
||||||
void SendTaskActivityNew(
|
|
||||||
Client *client,
|
|
||||||
int task_id,
|
|
||||||
int activity_id,
|
|
||||||
int client_task_index,
|
|
||||||
bool optional,
|
|
||||||
bool task_complete = false
|
|
||||||
);
|
|
||||||
void SendCompletedTasksToClient(Client *c, ClientTaskState *client_task_state);
|
|
||||||
void ExplainTask(Client *client, int task_id);
|
|
||||||
int FirstTaskInSet(int task_set);
|
|
||||||
int LastTaskInSet(int task_set);
|
|
||||||
int NextTaskInSet(int task_set, int task_id);
|
|
||||||
bool IsTaskRepeatable(int task_id);
|
|
||||||
|
|
||||||
friend class ClientTaskState;
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
TaskGoalListManager goal_list_manager;
|
|
||||||
TaskProximityManager proximity_manager;
|
|
||||||
TaskInformation *p_task_data[MAXTASKS]{};
|
|
||||||
std::vector<int> task_sets[MAXTASKSETS];
|
|
||||||
void SendActiveTaskDescription(
|
|
||||||
Client *client,
|
|
||||||
int task_id,
|
|
||||||
ClientTaskInformation &task_info,
|
|
||||||
int start_time,
|
|
||||||
int duration,
|
|
||||||
bool bring_up_task_journal = false
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user