mirror of
https://github.com/EQEmu/Server.git
synced 2026-09-03 13:36:36 +00:00
Merge pull request #1229 from EQEmu/akkadius/task-code-cleanup
[Refactor and Cleanup] Task Code
This commit is contained in:
+10
-4
@@ -133,6 +133,10 @@ SET(zone_sources
|
||||
special_attacks.cpp
|
||||
spell_effects.cpp
|
||||
spells.cpp
|
||||
task_client_state.cpp
|
||||
task_goal_list_manager.cpp
|
||||
task_manager.cpp
|
||||
task_proximity_manager.cpp
|
||||
tasks.cpp
|
||||
titles.cpp
|
||||
tradeskills.cpp
|
||||
@@ -151,8 +155,7 @@ SET(zone_sources
|
||||
zonedb.cpp
|
||||
zone_reload.cpp
|
||||
zone_store.cpp
|
||||
zoning.cpp
|
||||
)
|
||||
zoning.cpp)
|
||||
|
||||
SET(zone_headers
|
||||
aa.h
|
||||
@@ -252,6 +255,10 @@ SET(zone_headers
|
||||
spawn2.h
|
||||
spawngroup.h
|
||||
string_ids.h
|
||||
task_client_state.h
|
||||
task_goal_list_manager.h
|
||||
task_manager.h
|
||||
task_proximity_manager.h
|
||||
tasks.h
|
||||
titles.h
|
||||
trap.h
|
||||
@@ -265,8 +272,7 @@ SET(zone_headers
|
||||
zonedb.h
|
||||
zonedump.h
|
||||
zone_reload.h
|
||||
zone_store.h
|
||||
)
|
||||
zone_store.h)
|
||||
|
||||
ADD_EXECUTABLE(zone ${zone_sources} ${zone_headers})
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
|
||||
extern QueryServ* QServ;
|
||||
extern WorldServer worldserver;
|
||||
extern TaskManager *taskmanager;
|
||||
extern TaskManager *task_manager;
|
||||
void CatchSignal(int sig_num);
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -258,7 +258,7 @@ Client::Client(EQStreamInterface* ieqs)
|
||||
tgb = false;
|
||||
tribute_master_id = 0xFFFFFFFF;
|
||||
tribute_timer.Disable();
|
||||
taskstate = nullptr;
|
||||
task_state = nullptr;
|
||||
TotalSecondsPlayed = 0;
|
||||
keyring.clear();
|
||||
bind_sight_target = nullptr;
|
||||
@@ -452,7 +452,7 @@ Client::~Client() {
|
||||
// will need this data right away
|
||||
Save(2); // This fails when database destructor is called first on shutdown
|
||||
|
||||
safe_delete(taskstate);
|
||||
safe_delete(task_state);
|
||||
safe_delete(KarmaUpdateTimer);
|
||||
safe_delete(GlobalChatLimiterTimer);
|
||||
safe_delete(qGlobals);
|
||||
|
||||
+240
-45
@@ -65,6 +65,8 @@ namespace EQ
|
||||
#include "zone.h"
|
||||
#include "zonedb.h"
|
||||
#include "zone_store.h"
|
||||
#include "task_manager.h"
|
||||
#include "task_client_state.h"
|
||||
|
||||
#ifdef _WINDOWS
|
||||
// since windows defines these within windef.h (which windows.h include)
|
||||
@@ -86,7 +88,7 @@ namespace EQ
|
||||
#define XTARGET_HARDCAP 20
|
||||
|
||||
extern Zone* zone;
|
||||
extern TaskManager *taskmanager;
|
||||
extern TaskManager *task_manager;
|
||||
|
||||
class CLIENTPACKET
|
||||
{
|
||||
@@ -1006,7 +1008,7 @@ public:
|
||||
uint32 GetSpellIDByBookSlot(int book_slot);
|
||||
int GetNextAvailableSpellBookSlot(int starting_slot = 0);
|
||||
inline uint32 GetSpellByBookSlot(int book_slot) { return m_pp.spell_book[book_slot]; }
|
||||
inline bool HasSpellScribed(int spellid) { return (FindSpellBookSlotBySpellID(spellid) != -1 ? true : false); }
|
||||
inline bool HasSpellScribed(int spellid) { return FindSpellBookSlotBySpellID(spellid) != -1; }
|
||||
uint16 GetMaxSkillAfterSpecializationRules(EQ::skills::SkillType skillid, uint16 maxSkill);
|
||||
void SendPopupToClient(const char *Title, const char *Text, uint32 PopupID = 0, uint32 Buttons = 0, uint32 Duration = 0);
|
||||
void SendFullPopup(const char *Title, const char *Text, uint32 PopupID = 0, uint32 NegativeID = 0, uint32 Buttons = 0, uint32 Duration = 0, const char *ButtonName0 = 0, const char *ButtonName1 = 0, uint32 SoundControls = 0);
|
||||
@@ -1021,48 +1023,241 @@ public:
|
||||
// Task System Methods
|
||||
void LoadClientTaskState();
|
||||
void RemoveClientTaskState();
|
||||
void SendTaskActivityComplete(int TaskID, int ActivityID, int TaskIndex, TaskType type, int TaskIncomplete=1);
|
||||
void SendTaskFailed(int TaskID, int TaskIndex, TaskType type);
|
||||
void SendTaskComplete(int TaskIndex);
|
||||
inline ClientTaskState *GetTaskState() const { return taskstate; }
|
||||
|
||||
inline void CancelTask(int TaskIndex, TaskType type) { if(taskstate) taskstate->CancelTask(this, TaskIndex, type); }
|
||||
inline bool SaveTaskState() { return (taskmanager ? taskmanager->SaveClientState(this, taskstate) : false); }
|
||||
inline bool IsTaskStateLoaded() { return taskstate != nullptr; }
|
||||
inline bool IsTaskActive(int TaskID) { return (taskstate ? taskstate->IsTaskActive(TaskID) : false); }
|
||||
inline bool IsTaskActivityActive(int TaskID, int ActivityID) { return (taskstate ? taskstate->IsTaskActivityActive(TaskID, ActivityID) : false); }
|
||||
inline ActivityState GetTaskActivityState(TaskType type, int index, int ActivityID) { return (taskstate ? taskstate->GetTaskActivityState(type, index, ActivityID) : ActivityHidden); }
|
||||
inline void UpdateTaskActivity(int TaskID, int ActivityID, int Count, bool ignore_quest_update = false) { if (taskstate) taskstate->UpdateTaskActivity(this, TaskID, ActivityID, Count, ignore_quest_update); }
|
||||
inline void RemoveTaskByTaskID(uint32 task_id) { if (taskstate) taskstate->RemoveTaskByTaskID(this, task_id); }
|
||||
inline void ResetTaskActivity(int TaskID, int ActivityID) { if(taskstate) taskstate->ResetTaskActivity(this, TaskID, ActivityID); }
|
||||
inline void UpdateTasksOnKill(int NPCTypeID) { if(taskstate) taskstate->UpdateTasksOnKill(this, NPCTypeID); }
|
||||
inline void UpdateTasksForItem(ActivityType Type, int ItemID, int Count=1) { if(taskstate) taskstate->UpdateTasksForItem(this, Type, ItemID, Count); }
|
||||
inline void UpdateTasksOnExplore(int ExploreID) { if(taskstate) taskstate->UpdateTasksOnExplore(this, ExploreID); }
|
||||
inline bool UpdateTasksOnSpeakWith(int NPCTypeID) { if(taskstate) return taskstate->UpdateTasksOnSpeakWith(this, NPCTypeID); else return false; }
|
||||
inline bool UpdateTasksOnDeliver(std::list<EQ::ItemInstance*>& Items, int Cash, int NPCTypeID) { if (taskstate) return taskstate->UpdateTasksOnDeliver(this, Items, Cash, NPCTypeID); else return false; }
|
||||
inline void TaskSetSelector(Mob *mob, int TaskSetID) { if(taskmanager) taskmanager->TaskSetSelector(this, taskstate, mob, TaskSetID); }
|
||||
inline void TaskQuestSetSelector(Mob *mob, int count, int *tasks) { if(taskmanager) taskmanager->TaskQuestSetSelector(this, taskstate, mob, count, tasks); }
|
||||
inline void EnableTask(int TaskCount, int *TaskList) { if(taskstate) taskstate->EnableTask(CharacterID(), TaskCount, TaskList); }
|
||||
inline void DisableTask(int TaskCount, int *TaskList) { if(taskstate) taskstate->DisableTask(CharacterID(), TaskCount, TaskList); }
|
||||
inline bool IsTaskEnabled(int TaskID) { return (taskstate ? taskstate->IsTaskEnabled(TaskID) : false); }
|
||||
inline void ProcessTaskProximities(float X, float Y, float Z) { if(taskstate) taskstate->ProcessTaskProximities(this, X, Y, Z); }
|
||||
inline void AssignTask(int TaskID, int NPCID, bool enforce_level_requirement = false) { if (taskstate) taskstate->AcceptNewTask(this, TaskID, NPCID, enforce_level_requirement); }
|
||||
inline int ActiveSpeakTask(int NPCID) { if(taskstate) return taskstate->ActiveSpeakTask(NPCID); else return 0; }
|
||||
inline int ActiveSpeakActivity(int NPCID, int TaskID) { if(taskstate) return taskstate->ActiveSpeakActivity(NPCID, TaskID); else return 0; }
|
||||
inline void FailTask(int TaskID) { if(taskstate) taskstate->FailTask(this, TaskID); }
|
||||
inline int TaskTimeLeft(int TaskID) { return (taskstate ? taskstate->TaskTimeLeft(TaskID) : 0); }
|
||||
inline int EnabledTaskCount(int TaskSetID) { return (taskstate ? taskstate->EnabledTaskCount(TaskSetID) : -1); }
|
||||
inline int IsTaskCompleted(int TaskID) { return (taskstate ? taskstate->IsTaskCompleted(TaskID) : -1); }
|
||||
inline void ShowClientTasks() { if(taskstate) taskstate->ShowClientTasks(this); }
|
||||
inline void CancelAllTasks() { if(taskstate) taskstate->CancelAllTasks(this); }
|
||||
inline int GetActiveTaskCount() { return (taskstate ? taskstate->GetActiveTaskCount() : 0); }
|
||||
inline int GetActiveTaskID(int index) { return (taskstate ? taskstate->GetActiveTaskID(index) : -1); }
|
||||
inline int GetTaskStartTime(TaskType type, int index) { return (taskstate ? taskstate->GetTaskStartTime(type, index) : -1); }
|
||||
inline bool IsTaskActivityCompleted(TaskType type, int index, int ActivityID) { return (taskstate ? taskstate->IsTaskActivityCompleted(type, index, ActivityID) : false); }
|
||||
inline int GetTaskActivityDoneCount(TaskType type, int ClientTaskIndex, int ActivityID) { return (taskstate ? taskstate->GetTaskActivityDoneCount(type, ClientTaskIndex, ActivityID) :0); }
|
||||
inline int GetTaskActivityDoneCountFromTaskID(int TaskID, int ActivityID) { return (taskstate ? taskstate->GetTaskActivityDoneCountFromTaskID(TaskID, ActivityID) :0); }
|
||||
inline int ActiveTasksInSet(int TaskSet) { return (taskstate ? taskstate->ActiveTasksInSet(TaskSet) :0); }
|
||||
inline int CompletedTasksInSet(int TaskSet) { return (taskstate ? taskstate->CompletedTasksInSet(TaskSet) :0); }
|
||||
void SendTaskActivityComplete(int task_id, int activity_id, int task_index, TaskType task_type, int task_incomplete=1);
|
||||
void SendTaskFailed(int task_id, int task_index, TaskType task_type);
|
||||
void SendTaskComplete(int task_index);
|
||||
inline ClientTaskState *GetTaskState() const { return task_state; }
|
||||
inline void CancelTask(int task_index, TaskType task_type)
|
||||
{
|
||||
if (task_state) {
|
||||
task_state->CancelTask(
|
||||
this,
|
||||
task_index,
|
||||
task_type
|
||||
);
|
||||
}
|
||||
}
|
||||
inline bool SaveTaskState()
|
||||
{
|
||||
return task_manager != nullptr && task_manager->SaveClientState(this, task_state);
|
||||
}
|
||||
inline bool IsTaskStateLoaded() { return task_state != nullptr; }
|
||||
inline bool IsTaskActive(int task_id) { return task_state != nullptr && task_state->IsTaskActive(task_id); }
|
||||
inline bool IsTaskActivityActive(int task_id, int activity_id)
|
||||
{
|
||||
return task_state != nullptr &&
|
||||
task_state->IsTaskActivityActive(
|
||||
task_id,
|
||||
activity_id
|
||||
);
|
||||
}
|
||||
inline ActivityState GetTaskActivityState(TaskType task_type, int index, int activity_id)
|
||||
{
|
||||
return (task_state ? task_state->GetTaskActivityState(task_type, index, activity_id) : ActivityHidden);
|
||||
}
|
||||
inline void UpdateTaskActivity(
|
||||
int task_id,
|
||||
int activity_id,
|
||||
int count,
|
||||
bool ignore_quest_update = false
|
||||
)
|
||||
{
|
||||
if (task_state) {
|
||||
task_state->UpdateTaskActivity(this, task_id, activity_id, count, ignore_quest_update);
|
||||
}
|
||||
}
|
||||
inline void RemoveTaskByTaskID(uint32 task_id) {
|
||||
if (task_state) {
|
||||
task_state->RemoveTaskByTaskID(this, task_id);
|
||||
}
|
||||
}
|
||||
inline void ResetTaskActivity(int task_id, int activity_id)
|
||||
{
|
||||
if (task_state) {
|
||||
task_state->ResetTaskActivity(
|
||||
this,
|
||||
task_id,
|
||||
activity_id
|
||||
);
|
||||
}
|
||||
}
|
||||
inline void UpdateTasksOnKill(int npc_type_id)
|
||||
{
|
||||
if (task_state) {
|
||||
task_state->UpdateTasksOnKill(
|
||||
this,
|
||||
npc_type_id
|
||||
);
|
||||
}
|
||||
}
|
||||
inline void UpdateTasksForItem(
|
||||
ActivityType activity_type,
|
||||
int item_id,
|
||||
int count = 1
|
||||
)
|
||||
{
|
||||
if (task_state) {
|
||||
task_state->UpdateTasksForItem(this, activity_type, item_id, count);
|
||||
}
|
||||
}
|
||||
inline void UpdateTasksOnExplore(int explore_id)
|
||||
{
|
||||
if (task_state) {
|
||||
task_state->UpdateTasksOnExplore(
|
||||
this,
|
||||
explore_id
|
||||
);
|
||||
}
|
||||
}
|
||||
inline bool UpdateTasksOnSpeakWith(int npc_type_id)
|
||||
{
|
||||
if (task_state) {
|
||||
return task_state->UpdateTasksOnSpeakWith(
|
||||
this,
|
||||
npc_type_id
|
||||
);
|
||||
}
|
||||
else { return false; }
|
||||
}
|
||||
inline bool UpdateTasksOnDeliver(
|
||||
std::list<EQ::ItemInstance *> &items,
|
||||
int cash,
|
||||
int npc_type_id
|
||||
)
|
||||
{
|
||||
if (task_state) {
|
||||
return task_state->UpdateTasksOnDeliver(
|
||||
this,
|
||||
items,
|
||||
cash,
|
||||
npc_type_id
|
||||
);
|
||||
}
|
||||
else { return false; }
|
||||
}
|
||||
inline void TaskSetSelector(Mob *mob, int task_set_id)
|
||||
{
|
||||
if (task_manager) {
|
||||
task_manager->TaskSetSelector(
|
||||
this,
|
||||
task_state,
|
||||
mob,
|
||||
task_set_id
|
||||
);
|
||||
}
|
||||
}
|
||||
inline void TaskQuestSetSelector(Mob *mob, int count, int *tasks)
|
||||
{
|
||||
if (task_manager) {
|
||||
task_manager->TaskQuestSetSelector(
|
||||
this,
|
||||
task_state,
|
||||
mob,
|
||||
count,
|
||||
tasks
|
||||
);
|
||||
}
|
||||
}
|
||||
inline void EnableTask(int task_count, int *task_list)
|
||||
{
|
||||
if (task_state) {
|
||||
task_state->EnableTask(
|
||||
CharacterID(),
|
||||
task_count,
|
||||
task_list
|
||||
);
|
||||
}
|
||||
}
|
||||
inline void DisableTask(int task_count, int *task_list)
|
||||
{
|
||||
if (task_state) {
|
||||
task_state->DisableTask(
|
||||
CharacterID(),
|
||||
task_count,
|
||||
task_list
|
||||
);
|
||||
}
|
||||
}
|
||||
inline bool IsTaskEnabled(int task_id) {
|
||||
return task_state != nullptr && task_state->IsTaskEnabled(task_id);
|
||||
}
|
||||
inline void ProcessTaskProximities(float x, float y, float z)
|
||||
{
|
||||
if (task_state) {
|
||||
task_state->ProcessTaskProximities(
|
||||
this,
|
||||
x,
|
||||
y,
|
||||
z
|
||||
);
|
||||
}
|
||||
}
|
||||
inline void AssignTask(
|
||||
int task_id,
|
||||
int npc_id,
|
||||
bool enforce_level_requirement = false
|
||||
) {
|
||||
if (task_state) {
|
||||
task_state->AcceptNewTask(this, task_id, npc_id, enforce_level_requirement);
|
||||
}
|
||||
}
|
||||
inline int ActiveSpeakTask(int npc_type_id)
|
||||
{
|
||||
if (task_state) {
|
||||
return task_state->ActiveSpeakTask(npc_type_id);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
inline int ActiveSpeakActivity(int npc_type_id, int task_id)
|
||||
{
|
||||
if (task_state) {
|
||||
return task_state->ActiveSpeakActivity(
|
||||
npc_type_id,
|
||||
task_id
|
||||
);
|
||||
}
|
||||
else { return 0; }
|
||||
}
|
||||
inline void FailTask(int task_id) { if (task_state) { task_state->FailTask(this, task_id); }}
|
||||
inline int TaskTimeLeft(int task_id) { return (task_state ? task_state->TaskTimeLeft(task_id) : 0); }
|
||||
inline int EnabledTaskCount(int task_set_id)
|
||||
{
|
||||
return (task_state ? task_state->EnabledTaskCount(task_set_id) : -1);
|
||||
}
|
||||
inline int IsTaskCompleted(int task_id) { return (task_state ? task_state->IsTaskCompleted(task_id) : -1); }
|
||||
inline void ShowClientTasks(Client *client) { if (task_state) { task_state->ShowClientTasks(client); }}
|
||||
inline void CancelAllTasks() { if (task_state) { task_state->CancelAllTasks(this); }}
|
||||
inline int GetActiveTaskCount() { return (task_state ? task_state->GetActiveTaskCount() : 0); }
|
||||
inline int GetActiveTaskID(int index) { return (task_state ? task_state->GetActiveTaskID(index) : -1); }
|
||||
inline int GetTaskStartTime(TaskType task_type, int index)
|
||||
{
|
||||
return (task_state ? task_state->GetTaskStartTime(
|
||||
task_type,
|
||||
index
|
||||
) : -1);
|
||||
}
|
||||
inline bool IsTaskActivityCompleted(TaskType task_type, int index, int activity_id)
|
||||
{
|
||||
return task_state != nullptr && task_state->IsTaskActivityCompleted(task_type, index, activity_id);
|
||||
}
|
||||
inline int GetTaskActivityDoneCount(TaskType task_type, int client_task_index, int activity_id)
|
||||
{
|
||||
return (task_state ? task_state->GetTaskActivityDoneCount(task_type, client_task_index, activity_id) : 0);
|
||||
}
|
||||
inline int GetTaskActivityDoneCountFromTaskID(int task_id, int activity_id)
|
||||
{
|
||||
return (task_state ? task_state->GetTaskActivityDoneCountFromTaskID(task_id, activity_id) : 0);
|
||||
}
|
||||
inline int ActiveTasksInSet(int task_set_id)
|
||||
{
|
||||
return (task_state ? task_state->ActiveTasksInSet(task_set_id) : 0);
|
||||
}
|
||||
inline int CompletedTasksInSet(int task_set_id)
|
||||
{
|
||||
return (task_state ? task_state->CompletedTasksInSet(task_set_id) : 0);
|
||||
}
|
||||
|
||||
inline const EQ::versions::ClientVersion ClientVersion() const { return m_ClientVersion; }
|
||||
inline const uint32 ClientVersionBit() const { return m_ClientVersionBit; }
|
||||
@@ -1645,7 +1840,7 @@ private:
|
||||
|
||||
std::set<uint32> zone_flags;
|
||||
|
||||
ClientTaskState *taskstate;
|
||||
ClientTaskState *task_state;
|
||||
int TotalSecondsPlayed;
|
||||
|
||||
//Anti Spam Stuff
|
||||
|
||||
@@ -1821,8 +1821,8 @@ void Client::Handle_OP_AcceptNewTask(const EQApplicationPacket *app)
|
||||
}
|
||||
AcceptNewTask_Struct *ant = (AcceptNewTask_Struct*)app->pBuffer;
|
||||
|
||||
if (ant->task_id > 0 && RuleB(TaskSystem, EnableTaskSystem) && taskstate)
|
||||
taskstate->AcceptNewTask(this, ant->task_id, ant->task_master_id);
|
||||
if (ant->task_id > 0 && RuleB(TaskSystem, EnableTaskSystem) && task_state)
|
||||
task_state->AcceptNewTask(this, ant->task_id, ant->task_master_id);
|
||||
}
|
||||
|
||||
void Client::Handle_OP_AdventureInfoRequest(const EQApplicationPacket *app)
|
||||
@@ -4004,8 +4004,8 @@ void Client::Handle_OP_CancelTask(const EQApplicationPacket *app)
|
||||
}
|
||||
CancelTask_Struct *cts = (CancelTask_Struct*)app->pBuffer;
|
||||
|
||||
if (RuleB(TaskSystem, EnableTaskSystem) && taskstate)
|
||||
taskstate->CancelTask(this, cts->SequenceNumber, static_cast<TaskType>(cts->type));
|
||||
if (RuleB(TaskSystem, EnableTaskSystem) && task_state)
|
||||
task_state->CancelTask(this, cts->SequenceNumber, static_cast<TaskType>(cts->type));
|
||||
}
|
||||
|
||||
void Client::Handle_OP_CancelTrade(const EQApplicationPacket *app)
|
||||
@@ -13996,8 +13996,8 @@ void Client::Handle_OP_TaskHistoryRequest(const EQApplicationPacket *app)
|
||||
}
|
||||
TaskHistoryRequest_Struct *ths = (TaskHistoryRequest_Struct*)app->pBuffer;
|
||||
|
||||
if (RuleB(TaskSystem, EnableTaskSystem) && taskstate)
|
||||
taskstate->SendTaskHistory(this, ths->TaskIndex);
|
||||
if (RuleB(TaskSystem, EnableTaskSystem) && task_state)
|
||||
task_state->SendTaskHistory(this, ths->TaskIndex);
|
||||
}
|
||||
|
||||
void Client::Handle_OP_Taunt(const EQApplicationPacket *app)
|
||||
|
||||
@@ -158,8 +158,8 @@ bool Client::Process() {
|
||||
CalcItemScale();
|
||||
}
|
||||
|
||||
if (TaskPeriodic_Timer.Check() && taskstate)
|
||||
taskstate->TaskPeriodicChecks(this);
|
||||
if (TaskPeriodic_Timer.Check() && task_state)
|
||||
task_state->TaskPeriodicChecks(this);
|
||||
|
||||
if (dynamiczone_removal_timer.Check() && zone && zone->GetInstanceID() != 0)
|
||||
{
|
||||
|
||||
+100
-41
@@ -77,7 +77,7 @@
|
||||
|
||||
extern QueryServ* QServ;
|
||||
extern WorldServer worldserver;
|
||||
extern TaskManager *taskmanager;
|
||||
extern TaskManager *task_manager;
|
||||
extern FastMath g_Math;
|
||||
void CatchSignal(int sig_num);
|
||||
|
||||
@@ -10169,76 +10169,135 @@ void command_rules(Client *c, const Seperator *sep) {
|
||||
void command_task(Client *c, const Seperator *sep) {
|
||||
//super-command for managing tasks
|
||||
if(sep->arg[1][0] == '\0' || !strcasecmp(sep->arg[1], "help")) {
|
||||
c->Message(Chat::White, "Syntax: #task [subcommand].");
|
||||
c->Message(Chat::White, "-- Task System Commands --");
|
||||
c->Message(Chat::White, "...show - List active tasks for a client");
|
||||
c->Message(Chat::White, "...update <TaskID> <ActivityID> [Count]");
|
||||
c->Message(Chat::White, "...reloadall - Reload all Task information from the database");
|
||||
c->Message(Chat::White, "...reload task <TaskID> - Reload Task and Activity informnation for a single task");
|
||||
c->Message(Chat::White, "...reload lists - Reload goal/reward list information");
|
||||
c->Message(Chat::White, "...reload prox - Reload proximity information");
|
||||
c->Message(Chat::White, "...reload sets - Reload task set information");
|
||||
c->Message(Chat::White, "Syntax: #task [subcommand]");
|
||||
c->Message(Chat::White, "------------------------------------------------");
|
||||
c->Message(Chat::White, "# Task System Commands");
|
||||
c->Message(Chat::White, "------------------------------------------------");
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"--- [{}] List active tasks for a client",
|
||||
EQ::SayLinkEngine::GenerateQuestSaylink("#task show", false, "show")
|
||||
).c_str()
|
||||
);
|
||||
c->Message(Chat::White, "--- update <task_id> <activity_id> [count] | Updates task");
|
||||
c->Message(Chat::White, "--- assign <task_id> | Assigns task to client");
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"--- [{}] Reload all Task information from the database",
|
||||
EQ::SayLinkEngine::GenerateQuestSaylink("#task reloadall", false, "reloadall")
|
||||
).c_str()
|
||||
);
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"--- [{}] <task_id> Reload Task and Activity information for a single task",
|
||||
EQ::SayLinkEngine::GenerateQuestSaylink("#task reload task", false, "reload task")
|
||||
).c_str()
|
||||
);
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"--- [{}] Reload goal/reward list information",
|
||||
EQ::SayLinkEngine::GenerateQuestSaylink("#task reload lists", false, "reload lists")
|
||||
).c_str()
|
||||
);
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"--- [{}] Reload proximity information",
|
||||
EQ::SayLinkEngine::GenerateQuestSaylink("#task reload prox", false, "reload prox")
|
||||
).c_str()
|
||||
);
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"--- [{}] Reload task set information",
|
||||
EQ::SayLinkEngine::GenerateQuestSaylink("#task reload sets", false, "reload sets")
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!strcasecmp(sep->arg[1], "show")) {
|
||||
if(c->GetTarget() && c->GetTarget()->IsClient())
|
||||
c->GetTarget()->CastToClient()->ShowClientTasks();
|
||||
else
|
||||
c->ShowClientTasks();
|
||||
Client *client_target = c;
|
||||
if (c->GetTarget() && c->GetTarget()->IsClient()) {
|
||||
client_target = c->GetTarget()->CastToClient();
|
||||
}
|
||||
|
||||
if (!strcasecmp(sep->arg[1], "show")) {
|
||||
c->ShowClientTasks(client_target);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!strcasecmp(sep->arg[1], "update")) {
|
||||
if(sep->argnum>=3) {
|
||||
int TaskID = atoi(sep->arg[2]);
|
||||
int ActivityID = atoi(sep->arg[3]);
|
||||
int Count=1;
|
||||
if (!strcasecmp(sep->arg[1], "update")) {
|
||||
if (sep->argnum >= 3) {
|
||||
int task_id = atoi(sep->arg[2]);
|
||||
int activity_id = atoi(sep->arg[3]);
|
||||
int count = 1;
|
||||
|
||||
if(sep->argnum>=4) {
|
||||
Count = atoi(sep->arg[4]);
|
||||
if(Count <= 0)
|
||||
Count = 1;
|
||||
if (sep->argnum >= 4) {
|
||||
count = atoi(sep->arg[4]);
|
||||
if (count <= 0) {
|
||||
count = 1;
|
||||
}
|
||||
}
|
||||
c->Message(Chat::Yellow, "Updating Task %i, Activity %i, Count %i", TaskID, ActivityID, Count);
|
||||
c->UpdateTaskActivity(TaskID, ActivityID, Count);
|
||||
c->Message(
|
||||
Chat::Yellow,
|
||||
"Updating Task [%i] Activity [%i] Count [%i] for client [%s]",
|
||||
task_id,
|
||||
activity_id,
|
||||
count,
|
||||
client_target->GetCleanName()
|
||||
);
|
||||
client_target->UpdateTaskActivity(task_id, activity_id, count);
|
||||
c->ShowClientTasks(client_target);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(!strcasecmp(sep->arg[1], "reloadall")) {
|
||||
|
||||
if (!strcasecmp(sep->arg[1], "assign")) {
|
||||
int task_id = atoi(sep->arg[2]);
|
||||
if ((task_id > 0) && (task_id < MAXTASKS)) {
|
||||
client_target->AssignTask(task_id, 0, false);
|
||||
c->Message(Chat::Yellow, "Assigned task [%i] to [%s]", task_id, client_target->GetCleanName());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strcasecmp(sep->arg[1], "reloadall")) {
|
||||
c->Message(Chat::Yellow, "Sending reloadtasks to world");
|
||||
worldserver.SendReloadTasks(RELOADTASKS);
|
||||
c->Message(Chat::Yellow, "Back again");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!strcasecmp(sep->arg[1], "reload")) {
|
||||
if(sep->arg[2][0] != '\0') {
|
||||
if(!strcasecmp(sep->arg[2], "lists")) {
|
||||
if (!strcasecmp(sep->arg[1], "reload")) {
|
||||
if (sep->arg[2][0] != '\0') {
|
||||
if (!strcasecmp(sep->arg[2], "lists")) {
|
||||
c->Message(Chat::Yellow, "Sending reload lists to world");
|
||||
worldserver.SendReloadTasks(RELOADTASKGOALLISTS);
|
||||
c->Message(Chat::Yellow, "Back again");
|
||||
c->Message(Chat::Yellow, "Reloaded");
|
||||
return;
|
||||
}
|
||||
if(!strcasecmp(sep->arg[2], "prox")) {
|
||||
if (!strcasecmp(sep->arg[2], "prox")) {
|
||||
c->Message(Chat::Yellow, "Sending reload proximities to world");
|
||||
worldserver.SendReloadTasks(RELOADTASKPROXIMITIES);
|
||||
c->Message(Chat::Yellow, "Back again");
|
||||
c->Message(Chat::Yellow, "Reloaded");
|
||||
return;
|
||||
}
|
||||
if(!strcasecmp(sep->arg[2], "sets")) {
|
||||
if (!strcasecmp(sep->arg[2], "sets")) {
|
||||
c->Message(Chat::Yellow, "Sending reload task sets to world");
|
||||
worldserver.SendReloadTasks(RELOADTASKSETS);
|
||||
c->Message(Chat::Yellow, "Back again");
|
||||
c->Message(Chat::Yellow, "Reloaded");
|
||||
return;
|
||||
}
|
||||
if(!strcasecmp(sep->arg[2], "task") && (sep->arg[3][0] != '\0')) {
|
||||
int TaskID = atoi(sep->arg[3]);
|
||||
if((TaskID > 0) && (TaskID < MAXTASKS)) {
|
||||
c->Message(Chat::Yellow, "Sending reload task %i to world", TaskID);
|
||||
worldserver.SendReloadTasks(RELOADTASKS, TaskID);
|
||||
c->Message(Chat::Yellow, "Back again");
|
||||
if (!strcasecmp(sep->arg[2], "task") && (sep->arg[3][0] != '\0')) {
|
||||
int task_id = atoi(sep->arg[3]);
|
||||
if ((task_id > 0) && (task_id < MAXTASKS)) {
|
||||
c->Message(Chat::Yellow, "Sending reload task %i to world", task_id);
|
||||
worldserver.SendReloadTasks(RELOADTASKS, task_id);
|
||||
c->Message(Chat::Yellow, "Reloaded");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
+10
-7
@@ -32,6 +32,7 @@
|
||||
#include "../common/features.h"
|
||||
#include "../common/guilds.h"
|
||||
|
||||
#include "entity.h"
|
||||
#include "dynamiczone.h"
|
||||
#include "guild_mgr.h"
|
||||
#include "petitions.h"
|
||||
@@ -3900,22 +3901,24 @@ void EntityList::ProcessProximitySay(const char *Message, Client *c, uint8 langu
|
||||
|
||||
void EntityList::SaveAllClientsTaskState()
|
||||
{
|
||||
if (!taskmanager)
|
||||
if (!task_manager) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto it = client_list.begin();
|
||||
while (it != client_list.end()) {
|
||||
Client *client = it->second;
|
||||
if (client->IsTaskStateLoaded())
|
||||
if (client->IsTaskStateLoaded()) {
|
||||
client->SaveTaskState();
|
||||
}
|
||||
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
void EntityList::ReloadAllClientsTaskState(int TaskID)
|
||||
void EntityList::ReloadAllClientsTaskState(int task_id)
|
||||
{
|
||||
if (!taskmanager)
|
||||
if (!task_manager)
|
||||
return;
|
||||
|
||||
auto it = client_list.begin();
|
||||
@@ -3924,11 +3927,11 @@ void EntityList::ReloadAllClientsTaskState(int TaskID)
|
||||
if (client->IsTaskStateLoaded()) {
|
||||
// If we have been passed a TaskID, only reload the client state if they have
|
||||
// that Task active.
|
||||
if ((!TaskID) || (TaskID && client->IsTaskActive(TaskID))) {
|
||||
if ((!task_id) || (task_id && client->IsTaskActive(task_id))) {
|
||||
Log(Logs::General, Logs::Tasks, "[CLIENTLOAD] Reloading Task State For Client %s", client->GetName());
|
||||
client->RemoveClientTaskState();
|
||||
client->LoadClientTaskState();
|
||||
taskmanager->SendActiveTasksToClient(client);
|
||||
task_manager->SendActiveTasksToClient(client);
|
||||
}
|
||||
}
|
||||
++it;
|
||||
@@ -4136,7 +4139,7 @@ void EntityList::AddTempPetsToHateList(Mob *owner, Mob* other, bool bFrenzy)
|
||||
if (n->GetSwarmInfo()) {
|
||||
if (n->GetSwarmInfo()->owner_id == owner->GetID()) {
|
||||
if (
|
||||
!n->GetSpecialAbility(IMMUNE_AGGRO) &&
|
||||
!n->GetSpecialAbility(IMMUNE_AGGRO) &&
|
||||
!(n->GetSpecialAbility(IMMUNE_AGGRO_CLIENT) && other->IsClient()) &&
|
||||
!(n->GetSpecialAbility(IMMUNE_AGGRO_NPC) && other->IsNPC())
|
||||
) {
|
||||
|
||||
+1
-1
@@ -483,7 +483,7 @@ public:
|
||||
void SendGroupLeader(uint32 gid, const char *lname, const char *oldlname);
|
||||
|
||||
void SaveAllClientsTaskState();
|
||||
void ReloadAllClientsTaskState(int TaskID=0);
|
||||
void ReloadAllClientsTaskState(int task_id=0);
|
||||
uint16 CreateGroundObject(uint32 itemid, const glm::vec4& position, uint32 decay_time = 300000);
|
||||
uint16 CreateGroundObjectFromModel(const char *model, const glm::vec4& position, uint8 type = 0x00, uint32 decay_time = 0);
|
||||
uint16 CreateDoor(const char *model, const glm::vec4& position, uint8 type = 0, uint16 size = 100);
|
||||
|
||||
+6
-26
@@ -22,26 +22,18 @@
|
||||
#define PLATFORM_ZONE 1
|
||||
|
||||
#include "../common/global_define.h"
|
||||
#include "../common/features.h"
|
||||
#include "../common/queue.h"
|
||||
#include "../common/timer.h"
|
||||
#include "../common/eq_packet_structs.h"
|
||||
#include "../common/mutex.h"
|
||||
#include "../common/version.h"
|
||||
#include "../common/packet_dump_file.h"
|
||||
#include "../common/opcodemgr.h"
|
||||
#include "../common/guilds.h"
|
||||
#include "../common/eq_stream_ident.h"
|
||||
#include "../common/patches/patches.h"
|
||||
#include "../common/rulesys.h"
|
||||
#include "../common/profanity_manager.h"
|
||||
#include "../common/misc_functions.h"
|
||||
#include "../common/string_util.h"
|
||||
#include "../common/platform.h"
|
||||
#include "../common/crash.h"
|
||||
#include "../common/ipc_mutex.h"
|
||||
#include "../common/memory_mapped_file.h"
|
||||
#include "../common/eqemu_exception.h"
|
||||
#include "../common/spdat.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
|
||||
@@ -57,32 +49,21 @@
|
||||
#endif
|
||||
#include "zonedb.h"
|
||||
#include "zone_store.h"
|
||||
#include "zone_config.h"
|
||||
#include "titles.h"
|
||||
#include "guild_mgr.h"
|
||||
#include "tasks.h"
|
||||
#include "task_manager.h"
|
||||
#include "quest_parser_collection.h"
|
||||
#include "embparser.h"
|
||||
#include "lua_parser.h"
|
||||
#include "questmgr.h"
|
||||
#include "npc_scale_manager.h"
|
||||
|
||||
#include "../common/event/event_loop.h"
|
||||
#include "../common/event/timer.h"
|
||||
#include "../common/net/eqstream.h"
|
||||
#include "../common/net/servertalk_server.h"
|
||||
#include "../common/content/world_content_service.h"
|
||||
#include "../common/repositories/content_flags_repository.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <ctime>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
#ifdef _CRTDBG_MAP_ALLOC
|
||||
@@ -115,8 +96,8 @@ char errorname[32];
|
||||
extern Zone* zone;
|
||||
npcDecayTimes_Struct npcCorpseDecayTimes[100];
|
||||
TitleManager title_manager;
|
||||
QueryServ *QServ = 0;
|
||||
TaskManager *taskmanager = 0;
|
||||
QueryServ *QServ = 0;
|
||||
TaskManager *task_manager = 0;
|
||||
NpcScaleManager *npc_scale_manager;
|
||||
QuestParserCollection *parse = 0;
|
||||
EQEmuLogSys LogSys;
|
||||
@@ -426,9 +407,8 @@ int main(int argc, char** argv) {
|
||||
#endif
|
||||
|
||||
if (RuleB(TaskSystem, EnableTaskSystem)) {
|
||||
Log(Logs::General, Logs::Tasks, "[INIT] Loading Tasks");
|
||||
taskmanager = new TaskManager;
|
||||
taskmanager->LoadTasks();
|
||||
task_manager = new TaskManager;
|
||||
task_manager->LoadTasks();
|
||||
}
|
||||
|
||||
parse = new QuestParserCollection();
|
||||
@@ -607,7 +587,7 @@ int main(int argc, char** argv) {
|
||||
if (zone != 0)
|
||||
Zone::Shutdown(true);
|
||||
//Fix for Linux world server problem.
|
||||
safe_delete(taskmanager);
|
||||
safe_delete(task_manager);
|
||||
command_deinit();
|
||||
#ifdef BOTS
|
||||
bot_command_deinit();
|
||||
|
||||
+14
-14
@@ -2223,27 +2223,27 @@ bool QuestManager::createBot(const char *name, const char *lastname, uint8 level
|
||||
|
||||
void QuestManager::taskselector(int taskcount, int *tasks) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && owner && taskmanager)
|
||||
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && owner && task_manager)
|
||||
initiator->TaskQuestSetSelector(owner, taskcount, tasks);
|
||||
}
|
||||
void QuestManager::enabletask(int taskcount, int *tasks) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
|
||||
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && taskmanager)
|
||||
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && task_manager)
|
||||
initiator->EnableTask(taskcount, tasks);
|
||||
}
|
||||
|
||||
void QuestManager::disabletask(int taskcount, int *tasks) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
|
||||
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && taskmanager)
|
||||
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && task_manager)
|
||||
initiator->DisableTask(taskcount, tasks);
|
||||
}
|
||||
|
||||
bool QuestManager::istaskenabled(int taskid) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
|
||||
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && taskmanager)
|
||||
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && task_manager)
|
||||
return initiator->IsTaskEnabled(taskid);
|
||||
|
||||
return false;
|
||||
@@ -2252,7 +2252,7 @@ bool QuestManager::istaskenabled(int taskid) {
|
||||
void QuestManager::tasksetselector(int tasksetid) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
Log(Logs::General, Logs::Tasks, "[UPDATE] TaskSetSelector called for task set %i", tasksetid);
|
||||
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && owner && taskmanager)
|
||||
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && owner && task_manager)
|
||||
initiator->TaskSetSelector(owner, tasksetid);
|
||||
}
|
||||
|
||||
@@ -2341,8 +2341,8 @@ int QuestManager::enabledtaskcount(int taskset) {
|
||||
int QuestManager::firsttaskinset(int taskset) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
|
||||
if(RuleB(TaskSystem, EnableTaskSystem) && taskmanager)
|
||||
return taskmanager->FirstTaskInSet(taskset);
|
||||
if(RuleB(TaskSystem, EnableTaskSystem) && task_manager)
|
||||
return task_manager->FirstTaskInSet(taskset);
|
||||
|
||||
return -1;
|
||||
}
|
||||
@@ -2350,8 +2350,8 @@ int QuestManager::firsttaskinset(int taskset) {
|
||||
int QuestManager::lasttaskinset(int taskset) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
|
||||
if(RuleB(TaskSystem, EnableTaskSystem) && taskmanager)
|
||||
return taskmanager->LastTaskInSet(taskset);
|
||||
if(RuleB(TaskSystem, EnableTaskSystem) && task_manager)
|
||||
return task_manager->LastTaskInSet(taskset);
|
||||
|
||||
return -1;
|
||||
}
|
||||
@@ -2359,8 +2359,8 @@ int QuestManager::lasttaskinset(int taskset) {
|
||||
int QuestManager::nexttaskinset(int taskset, int taskid) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
|
||||
if(RuleB(TaskSystem, EnableTaskSystem) && taskmanager)
|
||||
return taskmanager->NextTaskInSet(taskset, taskid);
|
||||
if(RuleB(TaskSystem, EnableTaskSystem) && task_manager)
|
||||
return task_manager->NextTaskInSet(taskset, taskid);
|
||||
|
||||
return -1;
|
||||
}
|
||||
@@ -2412,8 +2412,8 @@ int QuestManager::completedtasksinset(int taskset) {
|
||||
bool QuestManager::istaskappropriate(int task) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
|
||||
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && taskmanager)
|
||||
return taskmanager->AppropriateLevel(task, initiator->GetLevel());
|
||||
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && task_manager)
|
||||
return task_manager->ValidateLevel(task, initiator->GetLevel());
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -2422,7 +2422,7 @@ std::string QuestManager::gettaskname(uint32 task_id) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
|
||||
if (RuleB(TaskSystem, EnableTaskSystem)) {
|
||||
return taskmanager->GetTaskName(task_id);
|
||||
return task_manager->GetTaskName(task_id);
|
||||
}
|
||||
|
||||
return std::string();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,111 @@
|
||||
#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 m_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 m_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 = &m_active_task;
|
||||
}
|
||||
break;
|
||||
case TaskType::Shared:
|
||||
break;
|
||||
case TaskType::Quest:
|
||||
if (index < MAXACTIVEQUESTS) {
|
||||
info = &m_active_quests[index];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
union { // easier to loop over
|
||||
struct {
|
||||
ClientTaskInformation m_active_task; // only one
|
||||
ClientTaskInformation m_active_quests[MAXACTIVEQUESTS];
|
||||
};
|
||||
ClientTaskInformation m_active_tasks[MAXACTIVEQUESTS + 1];
|
||||
};
|
||||
// Shared tasks should be limited to 1 as well
|
||||
int m_active_task_count;
|
||||
std::vector<int> m_enabled_tasks;
|
||||
std::vector<CompletedTaskInformation> m_completed_tasks;
|
||||
int m_last_completed_task_loaded;
|
||||
bool m_checked_touch_activities;
|
||||
};
|
||||
|
||||
|
||||
#endif //EQEMU_TASK_CLIENT_STATE_H
|
||||
@@ -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()
|
||||
{
|
||||
m_goal_lists_count = 0;
|
||||
}
|
||||
|
||||
TaskGoalListManager::~TaskGoalListManager() {}
|
||||
|
||||
bool TaskGoalListManager::LoadLists()
|
||||
{
|
||||
m_task_goal_lists.clear();
|
||||
m_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;
|
||||
}
|
||||
|
||||
m_goal_lists_count = results.RowCount();
|
||||
LogTasks("Loaded [{}] GoalLists", m_goal_lists_count);
|
||||
|
||||
m_task_goal_lists.reserve(m_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]);
|
||||
|
||||
m_task_goal_lists.push_back({list_id, 0, 0});
|
||||
|
||||
m_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 < m_goal_lists_count; list_index++) {
|
||||
|
||||
int list_id = m_task_goal_lists[list_index].ListID;
|
||||
|
||||
for (auto &entry: goal_lists) {
|
||||
if (entry.listid == list_id) {
|
||||
if (entry.entry < m_task_goal_lists[list_index].Min) {
|
||||
m_task_goal_lists[list_index].Min = entry.entry;
|
||||
}
|
||||
|
||||
if (entry.entry > m_task_goal_lists[list_index].Max) {
|
||||
m_task_goal_lists[list_index].Max = entry.entry;
|
||||
}
|
||||
|
||||
m_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(
|
||||
m_task_goal_lists.begin(),
|
||||
m_task_goal_lists.end(),
|
||||
[list_id](const TaskGoalList_Struct &t) { return t.ListID == list_id; }
|
||||
);
|
||||
|
||||
if (it == m_task_goal_lists.end()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return std::distance(m_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 >= m_goal_lists_count)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (m_task_goal_lists[list_by_id].GoalItemEntries.empty()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return m_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 >= m_goal_lists_count)) {
|
||||
return list_contents;
|
||||
}
|
||||
|
||||
list_contents = m_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 >= m_goal_lists_count)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((entry < m_task_goal_lists[list_index].Min) || (entry > m_task_goal_lists[list_index].Max)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int first_entry = 0;
|
||||
auto &task = m_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;
|
||||
}
|
||||
@@ -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> m_task_goal_lists;
|
||||
int m_goal_lists_count;
|
||||
};
|
||||
|
||||
|
||||
#endif //EQEMU_TASK_GOAL_LIST_MANAGER_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,98 @@
|
||||
#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)
|
||||
{
|
||||
m_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 m_goal_list_manager;
|
||||
TaskProximityManager m_proximity_manager;
|
||||
TaskInformation *m_task_data[MAXTASKS]{};
|
||||
std::vector<int> m_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
|
||||
@@ -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{};
|
||||
m_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;
|
||||
|
||||
m_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 : m_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;
|
||||
}
|
||||
@@ -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> m_task_proximities;
|
||||
};
|
||||
|
||||
#endif //EQEMU_TASK_PROXIMITY_MANAGER_H
|
||||
+43
-3523
File diff suppressed because it is too large
Load Diff
+99
-282
@@ -1,27 +1,7 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TASKS_H
|
||||
#define TASKS_H
|
||||
|
||||
#include "../common/types.h"
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
@@ -29,304 +9,141 @@ Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
#define MAXTASKS 10000
|
||||
#define MAXTASKSETS 1000
|
||||
// The Client has a hard cap of 19 active quests, 29 in SoD+
|
||||
#define MAXACTIVEQUESTS 19
|
||||
// The Max Chooser (Task Selector entries) is capped at 40 in the Titanium Client.
|
||||
#define MAXCHOOSERENTRIES 40
|
||||
// The Client has a hard cap of 20 activities per task.
|
||||
#define MAXACTIVITIESPERTASK 20
|
||||
// This is used to determine if a client's active task slot is empty.
|
||||
#define TASKSLOTEMPTY 0
|
||||
#define MAXACTIVEQUESTS 19 // The Client has a hard cap of 19 active quests, 29 in SoD+
|
||||
#define MAXCHOOSERENTRIES 40 // The Max Chooser (Task Selector entries) is capped at 40 in the Titanium Client.
|
||||
#define MAXACTIVITIESPERTASK 20 // The Client has a hard cap of 20 activities per task.
|
||||
#define TASKSLOTEMPTY 0 // This is used to determine if a client's active task slot is empty.
|
||||
|
||||
// Command Codes for worldserver ServerOP_ReloadTasks
|
||||
//
|
||||
#define RELOADTASKS 0
|
||||
#define RELOADTASKGOALLISTS 1
|
||||
#define RELOADTASKPROXIMITIES 2
|
||||
#define RELOADTASKSETS 3
|
||||
#define RELOADTASKS 0
|
||||
#define RELOADTASKGOALLISTS 1
|
||||
#define RELOADTASKPROXIMITIES 2
|
||||
#define RELOADTASKSETS 3
|
||||
|
||||
class Client;
|
||||
class Mob;
|
||||
|
||||
namespace EQ
|
||||
{
|
||||
namespace EQ {
|
||||
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 ListID);
|
||||
bool IsInList(int ListID, int Entry);
|
||||
int GetFirstEntry(int ListID);
|
||||
std::vector<int> GetListContents(int ListIndex);
|
||||
|
||||
private:
|
||||
|
||||
std::vector<TaskGoalList_Struct> TaskGoalLists;
|
||||
int NumberOfLists;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int ExploreID;
|
||||
float MinX, MaxX, MinY, MaxY, MinZ, MaxZ;
|
||||
} TaskProximity;
|
||||
|
||||
// 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 ZoneID);
|
||||
int CheckProximities(float X, float Y, float Z);
|
||||
|
||||
private:
|
||||
std::vector<TaskProximity> TaskProximities;
|
||||
};
|
||||
|
||||
typedef enum { METHODSINGLEID = 0, METHODLIST = 1, METHODQUEST = 2 } TaskMethodType;
|
||||
typedef enum {
|
||||
METHODSINGLEID = 0,
|
||||
METHODLIST = 1,
|
||||
METHODQUEST = 2
|
||||
} TaskMethodType;
|
||||
|
||||
struct ActivityInformation {
|
||||
int StepNumber;
|
||||
int Type;
|
||||
std::string target_name; // name mob, location -- default empty
|
||||
std::string item_list; // likely defaults to empty
|
||||
std::string skill_list; // IDs ; separated -- default -1
|
||||
std::string spell_list; // IDs ; separated -- default 0
|
||||
std::string desc_override; // overrides auto generated description -- default empty
|
||||
int skill_id; // older clients, first id from above
|
||||
int spell_id; // older clients, first id from above
|
||||
int GoalID;
|
||||
TaskMethodType GoalMethod;
|
||||
int GoalCount;
|
||||
int DeliverToNPC;
|
||||
std::vector<int> ZoneIDs;
|
||||
std::string zones; // IDs ; searated, ZoneID is the first in this list for older clients -- default empty string
|
||||
bool Optional;
|
||||
int step_number;
|
||||
int activity_type;
|
||||
std::string target_name; // name mob, location -- default empty
|
||||
std::string item_list; // likely defaults to empty
|
||||
std::string skill_list; // IDs ; separated -- default -1
|
||||
std::string spell_list; // IDs ; separated -- default 0
|
||||
std::string description_override; // overrides auto generated description -- default empty
|
||||
int skill_id; // older clients, first id from above
|
||||
int spell_id; // older clients, first id from above
|
||||
int goal_id;
|
||||
TaskMethodType goal_method;
|
||||
int goal_count;
|
||||
int deliver_to_npc;
|
||||
std::vector<int> zone_ids;
|
||||
std::string zones; // IDs ; searated, ZoneID is the first in this list for older clients -- default empty string
|
||||
bool optional;
|
||||
|
||||
inline bool CheckZone(int zone_id) {
|
||||
if (ZoneIDs.empty())
|
||||
inline bool CheckZone(int zone_id)
|
||||
{
|
||||
if (zone_ids.empty()) {
|
||||
return true;
|
||||
return std::find(ZoneIDs.begin(), ZoneIDs.end(), zone_id) != ZoneIDs.end();
|
||||
}
|
||||
return std::find(zone_ids.begin(), zone_ids.end(), zone_id) != zone_ids.end();
|
||||
}
|
||||
};
|
||||
|
||||
typedef enum { ActivitiesSequential = 0, ActivitiesStepped = 1 } SequenceType;
|
||||
typedef enum {
|
||||
ActivitiesSequential = 0,
|
||||
ActivitiesStepped = 1
|
||||
} SequenceType;
|
||||
|
||||
enum class TaskType {
|
||||
Task = 0, // can have at max 1
|
||||
Shared = 1, // can have at max 1
|
||||
Quest = 2, // can have at max 19 or 29 depending on client
|
||||
E = 3 // can have at max 19 or 29 depending on client, not present in live anymore
|
||||
Task = 0, // can have at max 1
|
||||
Shared = 1, // can have at max 1
|
||||
Quest = 2, // can have at max 19 or 29 depending on client
|
||||
E = 3 // can have at max 19 or 29 depending on client, not present in live anymore
|
||||
};
|
||||
|
||||
enum class DurationCode {
|
||||
None = 0,
|
||||
Short = 1,
|
||||
None = 0,
|
||||
Short = 1,
|
||||
Medium = 2,
|
||||
Long = 3
|
||||
Long = 3
|
||||
};
|
||||
|
||||
struct TaskInformation {
|
||||
TaskType type;
|
||||
int Duration;
|
||||
DurationCode dur_code; // description for time investment for when Duration == 0
|
||||
std::string Title; // max length 64
|
||||
std::string Description; // max length 4000, 2048 on Tit
|
||||
std::string Reward;
|
||||
std::string item_link; // max length 128 older clients, item link gets own string
|
||||
std::string completion_emote; // emote after completing task, yellow. Maybe should make more generic ... but yellow for now!
|
||||
int RewardID;
|
||||
int CashReward; // Expressed in copper
|
||||
int XPReward;
|
||||
int faction_reward; // just a npc_faction_id
|
||||
TaskMethodType RewardMethod;
|
||||
int ActivityCount;
|
||||
SequenceType SequenceMode;
|
||||
int LastStep;
|
||||
short MinLevel;
|
||||
short MaxLevel;
|
||||
bool Repeatable;
|
||||
ActivityInformation Activity[MAXACTIVITIESPERTASK];
|
||||
TaskType type;
|
||||
int duration;
|
||||
DurationCode duration_code; // description for time investment for when duration == 0
|
||||
std::string title; // max length 64
|
||||
std::string description; // max length 4000, 2048 on Tit
|
||||
std::string reward;
|
||||
std::string item_link; // max length 128 older clients, item link gets own string
|
||||
std::string completion_emote; // emote after completing task, yellow. Maybe should make more generic ... but yellow for now!
|
||||
int reward_id;
|
||||
int cash_reward; // Expressed in copper
|
||||
int experience_reward;
|
||||
int faction_reward; // just a npc_faction_id
|
||||
TaskMethodType reward_method;
|
||||
int activity_count;
|
||||
SequenceType sequence_mode;
|
||||
int last_step;
|
||||
short min_level;
|
||||
short max_level;
|
||||
bool repeatable;
|
||||
ActivityInformation activity_information[MAXACTIVITIESPERTASK];
|
||||
};
|
||||
|
||||
typedef enum { ActivityHidden = 0, ActivityActive = 1, ActivityCompleted = 2 } ActivityState;
|
||||
|
||||
typedef enum { ActivityDeliver = 1, ActivityKill = 2, ActivityLoot = 3, ActivitySpeakWith = 4, ActivityExplore = 5,
|
||||
ActivityTradeSkill = 6, ActivityFish = 7, ActivityForage = 8, ActivityCastOn = 9, ActivitySkillOn = 10,
|
||||
ActivityTouch = 11, ActivityCollect = 13, ActivityGiveCash = 100 } ActivityType;
|
||||
typedef enum {
|
||||
ActivityHidden = 0,
|
||||
ActivityActive = 1,
|
||||
ActivityCompleted = 2
|
||||
} ActivityState;
|
||||
|
||||
typedef enum {
|
||||
ActivityDeliver = 1,
|
||||
ActivityKill = 2,
|
||||
ActivityLoot = 3,
|
||||
ActivitySpeakWith = 4,
|
||||
ActivityExplore = 5,
|
||||
ActivityTradeSkill = 6,
|
||||
ActivityFish = 7,
|
||||
ActivityForage = 8,
|
||||
ActivityCastOn = 9,
|
||||
ActivitySkillOn = 10,
|
||||
ActivityTouch = 11,
|
||||
ActivityCollect = 13,
|
||||
ActivityGiveCash = 100
|
||||
} ActivityType;
|
||||
|
||||
struct ClientActivityInformation {
|
||||
int ActivityID;
|
||||
int DoneCount;
|
||||
ActivityState State;
|
||||
bool Updated; // Flag so we know if we need to update the database
|
||||
int activity_id;
|
||||
int done_count;
|
||||
ActivityState activity_state;
|
||||
bool updated; // Flag so we know if we need to updated the database
|
||||
};
|
||||
|
||||
struct ClientTaskInformation {
|
||||
int slot; // intrusive, but makes things easier :P
|
||||
int TaskID;
|
||||
int CurrentStep;
|
||||
int AcceptedTime;
|
||||
bool Updated;
|
||||
ClientActivityInformation Activity[MAXACTIVITIESPERTASK];
|
||||
int slot; // intrusive, but makes things easier :P
|
||||
int task_id;
|
||||
int current_step;
|
||||
int accepted_time;
|
||||
bool updated;
|
||||
ClientActivityInformation activity[MAXACTIVITIESPERTASK];
|
||||
};
|
||||
|
||||
struct CompletedTaskInformation {
|
||||
int TaskID;
|
||||
int CompletedTime;
|
||||
bool ActivityDone[MAXACTIVITIESPERTASK];
|
||||
};
|
||||
|
||||
class ClientTaskState {
|
||||
|
||||
public:
|
||||
ClientTaskState();
|
||||
~ClientTaskState();
|
||||
void ShowClientTasks(Client *c);
|
||||
inline int GetActiveTaskCount() { return ActiveTaskCount; }
|
||||
int GetActiveTaskID(int index);
|
||||
bool IsTaskActivityCompleted(TaskType type, int index, int ActivityID);
|
||||
int GetTaskActivityDoneCount(TaskType type, int index, int ActivityID);
|
||||
int GetTaskActivityDoneCountFromTaskID(int TaskID, int ActivityID);
|
||||
int GetTaskStartTime(TaskType type, int index);
|
||||
void AcceptNewTask(Client *c, int TaskID, int NPCID, bool enforce_level_requirement = false);
|
||||
void FailTask(Client *c, int TaskID);
|
||||
int TaskTimeLeft(int TaskID);
|
||||
int IsTaskCompleted(int TaskID);
|
||||
bool IsTaskActive(int TaskID);
|
||||
bool IsTaskActivityActive(int TaskID, int ActivityID);
|
||||
ActivityState GetTaskActivityState(TaskType type, int index, int ActivityID);
|
||||
void UpdateTaskActivity(Client *c, int TaskID, int ActivityID, int Count, bool ignore_quest_update = false);
|
||||
void ResetTaskActivity(Client *c, int TaskID, int ActivityID);
|
||||
void CancelTask(Client *c, int SequenceNumber, TaskType type, bool RemoveFromDB = true);
|
||||
void CancelAllTasks(Client *c);
|
||||
void RemoveTask(Client *c, int SequenceNumber, TaskType type);
|
||||
void RemoveTaskByTaskID(Client *c, uint32 task_id);
|
||||
bool UpdateTasksByNPC(Client *c, int ActivityType, int NPCTypeID);
|
||||
void UpdateTasksOnKill(Client *c, int NPCTypeID);
|
||||
void UpdateTasksForItem(Client *c, ActivityType Type, int ItemID, int Count=1);
|
||||
void UpdateTasksOnExplore(Client *c, int ExploreID);
|
||||
bool UpdateTasksOnSpeakWith(Client *c, int NPCTypeID);
|
||||
bool UpdateTasksOnDeliver(Client *c, std::list<EQ::ItemInstance*>& Items, int Cash, int NPCTypeID);
|
||||
void UpdateTasksOnTouch(Client *c, int ZoneID);
|
||||
void ProcessTaskProximities(Client *c, float X, float Y, float Z);
|
||||
bool TaskOutOfTime(TaskType type, int Index);
|
||||
void TaskPeriodicChecks(Client *c);
|
||||
void SendTaskHistory(Client *c, int TaskIndex);
|
||||
void RewardTask(Client *c, TaskInformation *Task);
|
||||
void EnableTask(int CharID, int TaskCount, int *TaskList);
|
||||
void DisableTask(int CharID, int TaskCount, int *TaskList);
|
||||
bool IsTaskEnabled(int TaskID);
|
||||
int EnabledTaskCount(int TaskSetID);
|
||||
int ActiveSpeakTask(int NPCID);
|
||||
int ActiveSpeakActivity(int NPCID, int TaskID);
|
||||
int ActiveTasksInSet(int TaskSetID);
|
||||
int CompletedTasksInSet(int TaskSetID);
|
||||
bool HasSlotForTask(TaskInformation *task);
|
||||
|
||||
inline bool HasFreeTaskSlot() { return ActiveTask.TaskID == TASKSLOTEMPTY; }
|
||||
|
||||
friend class TaskManager;
|
||||
|
||||
private:
|
||||
bool UnlockActivities(int CharID, ClientTaskInformation &task_info);
|
||||
void IncrementDoneCount(Client *c, TaskInformation *Task, int TaskIndex, int ActivityID, int Count = 1, bool ignore_quest_update = false);
|
||||
inline ClientTaskInformation *GetClientTaskInfo(TaskType type, int index)
|
||||
{
|
||||
ClientTaskInformation *info = nullptr;
|
||||
switch (type) {
|
||||
case TaskType::Task:
|
||||
if (index == 0)
|
||||
info = &ActiveTask;
|
||||
break;
|
||||
case TaskType::Shared:
|
||||
break;
|
||||
case TaskType::Quest:
|
||||
if (index < MAXACTIVEQUESTS)
|
||||
info = &ActiveQuests[index];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
int ActiveTaskCount;
|
||||
union { // easier to loop over
|
||||
struct {
|
||||
ClientTaskInformation ActiveTask; // only one
|
||||
ClientTaskInformation ActiveQuests[MAXACTIVEQUESTS];
|
||||
};
|
||||
ClientTaskInformation ActiveTasks[MAXACTIVEQUESTS + 1];
|
||||
};
|
||||
// Shared tasks should be limited to 1 as well
|
||||
std::vector<int> EnabledTasks;
|
||||
std::vector<CompletedTaskInformation> CompletedTasks;
|
||||
int LastCompletedTaskLoaded;
|
||||
bool CheckedTouchActivities;
|
||||
};
|
||||
|
||||
|
||||
class TaskManager {
|
||||
|
||||
public:
|
||||
TaskManager();
|
||||
~TaskManager();
|
||||
int GetActivityCount(int TaskID);
|
||||
bool LoadSingleTask(int TaskID);
|
||||
bool LoadTasks(int SingleTask=0);
|
||||
void ReloadGoalLists();
|
||||
inline void LoadProximities(int ZoneID) { ProximityManager.LoadProximities(ZoneID); }
|
||||
bool LoadTaskSets();
|
||||
bool LoadClientState(Client *c, ClientTaskState *state);
|
||||
bool SaveClientState(Client *c, ClientTaskState *state);
|
||||
void SendTaskSelector(Client *c, Mob *mob, int TaskCount, int *TaskList);
|
||||
void SendTaskSelectorNew(Client *c, Mob *mob, int TaskCount, int *TaskList);
|
||||
bool AppropriateLevel(int TaskID, int PlayerLevel);
|
||||
int GetTaskMinLevel(int TaskID);
|
||||
int GetTaskMaxLevel(int TaskID);
|
||||
std::string GetTaskName(uint32 task_id);
|
||||
TaskType GetTaskType(uint32 task_id);
|
||||
void TaskSetSelector(Client *c, ClientTaskState *state, Mob *mob, int TaskSetID);
|
||||
void TaskQuestSetSelector(Client *c, ClientTaskState *state, Mob *mob, int count, int *tasks); // task list provided by QuestManager (perl/lua)
|
||||
void SendActiveTasksToClient(Client *c, bool TaskComplete=false);
|
||||
void SendSingleActiveTaskToClient(Client *c, ClientTaskInformation &task_info, bool TaskComplete, bool BringUpTaskJournal = false);
|
||||
void SendTaskActivityShort(Client *c, int TaskID, int ActivityID, int ClientTaskIndex);
|
||||
void SendTaskActivityLong(Client *c, int TaskID, int ActivityID, int ClientTaskIndex,
|
||||
bool Optional, bool TaskComplete=false);
|
||||
void SendTaskActivityNew(Client *c, int TaskID, int ActivityID, int ClientTaskIndex,
|
||||
bool Optional, bool TaskComplete=false);
|
||||
void SendCompletedTasksToClient(Client *c, ClientTaskState *state);
|
||||
void ExplainTask(Client *c, int TaskID);
|
||||
int FirstTaskInSet(int TaskSet);
|
||||
int LastTaskInSet(int TaskSet);
|
||||
int NextTaskInSet(int TaskSet, int TaskID);
|
||||
bool IsTaskRepeatable(int TaskID);
|
||||
friend class ClientTaskState;
|
||||
|
||||
|
||||
private:
|
||||
TaskGoalListManager GoalListManager;
|
||||
TaskProximityManager ProximityManager;
|
||||
TaskInformation* Tasks[MAXTASKS];
|
||||
std::vector<int> TaskSets[MAXTASKSETS];
|
||||
void SendActiveTaskDescription(Client *c, int TaskID, ClientTaskInformation &task_info, int StartTime, int Duration, bool BringUpTaskJournal=false);
|
||||
|
||||
int task_id;
|
||||
int completed_time;
|
||||
bool activity_done[MAXACTIVITIESPERTASK];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+18
-18
@@ -2455,7 +2455,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
CZTaskDisablePlayer_Struct* CZUA = (CZTaskDisablePlayer_Struct*) pack->pBuffer;
|
||||
auto client = entity_list.GetClientByCharID(CZUA->character_id);
|
||||
if (client) {
|
||||
client->DisableTask(1, (int*) CZUA->task_id);
|
||||
client->DisableTask(1, reinterpret_cast<int *>(CZUA->task_id));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2467,7 +2467,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) {
|
||||
if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) {
|
||||
auto group_member = client_group->members[member_index]->CastToClient();
|
||||
group_member->DisableTask(1, (int*) CZUA->task_id);
|
||||
group_member->DisableTask(1, reinterpret_cast<int *>(CZUA->task_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2481,7 +2481,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) {
|
||||
if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) {
|
||||
auto raid_member = client_raid->members[member_index].member->CastToClient();
|
||||
raid_member->DisableTask(1, (int*) CZUA->task_id);
|
||||
raid_member->DisableTask(1, reinterpret_cast<int *>(CZUA->task_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2492,7 +2492,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
CZTaskDisableGuild_Struct* CZUA = (CZTaskDisableGuild_Struct*) pack->pBuffer;
|
||||
for (auto &client : entity_list.GetClientList()) {
|
||||
if (client.second->GuildID() > 0 && client.second->GuildID() == CZUA->guild_id) {
|
||||
client.second->DisableTask(1, (int*) CZUA->task_id);
|
||||
client.second->DisableTask(1, reinterpret_cast<int *>(CZUA->task_id));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -2502,7 +2502,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
CZTaskEnablePlayer_Struct* CZUA = (CZTaskEnablePlayer_Struct*) pack->pBuffer;
|
||||
auto client = entity_list.GetClientByCharID(CZUA->character_id);
|
||||
if (client) {
|
||||
client->EnableTask(1, (int*) CZUA->task_id);
|
||||
client->EnableTask(1, reinterpret_cast<int *>(CZUA->task_id));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2514,7 +2514,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) {
|
||||
if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) {
|
||||
auto group_member = client_group->members[member_index]->CastToClient();
|
||||
group_member->EnableTask(1, (int*) CZUA->task_id);
|
||||
group_member->EnableTask(1, reinterpret_cast<int *>(CZUA->task_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2528,7 +2528,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) {
|
||||
if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) {
|
||||
auto raid_member = client_raid->members[member_index].member->CastToClient();
|
||||
raid_member->EnableTask(1, (int*) CZUA->task_id);
|
||||
raid_member->EnableTask(1, reinterpret_cast<int *>(CZUA->task_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2539,7 +2539,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
CZTaskEnableGuild_Struct* CZUA = (CZTaskEnableGuild_Struct*) pack->pBuffer;
|
||||
for (auto &client : entity_list.GetClientList()) {
|
||||
if (client.second->GuildID() > 0 && client.second->GuildID() == CZUA->guild_id) {
|
||||
client.second->EnableTask(1, (int*) CZUA->task_id);
|
||||
client.second->EnableTask(1, reinterpret_cast<int *>(CZUA->task_id));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -2666,7 +2666,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
for (auto &client : entity_list.GetClientList()) {
|
||||
auto client_status = client.second->Admin();
|
||||
if (client_status >= WWDT->min_status && (client_status <= WWDT->max_status || WWDT->max_status == 0)) {
|
||||
client.second->DisableTask(1, (int *) WWDT->task_id);
|
||||
client.second->DisableTask(1, reinterpret_cast<int *>(WWDT->task_id));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -2677,7 +2677,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
for (auto &client : entity_list.GetClientList()) {
|
||||
auto client_status = client.second->Admin();
|
||||
if (client_status >= WWET->min_status && (client_status <= WWET->max_status || WWET->max_status == 0)) {
|
||||
client.second->EnableTask(1, (int *) WWET->task_id);
|
||||
client.second->EnableTask(1, reinterpret_cast<int *>(WWET->task_id));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -3100,16 +3100,16 @@ void WorldServer::HandleReloadTasks(ServerPacket *pack)
|
||||
|
||||
if (rts->Parameter == 0) {
|
||||
Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload ALL tasks");
|
||||
safe_delete(taskmanager);
|
||||
taskmanager = new TaskManager;
|
||||
taskmanager->LoadTasks();
|
||||
safe_delete(task_manager);
|
||||
task_manager = new TaskManager;
|
||||
task_manager->LoadTasks();
|
||||
if (zone)
|
||||
taskmanager->LoadProximities(zone->GetZoneID());
|
||||
task_manager->LoadProximities(zone->GetZoneID());
|
||||
entity_list.ReloadAllClientsTaskState();
|
||||
}
|
||||
else {
|
||||
Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload only task %i", rts->Parameter);
|
||||
taskmanager->LoadTasks(rts->Parameter);
|
||||
task_manager->LoadTasks(rts->Parameter);
|
||||
entity_list.ReloadAllClientsTaskState(rts->Parameter);
|
||||
}
|
||||
|
||||
@@ -3118,18 +3118,18 @@ void WorldServer::HandleReloadTasks(ServerPacket *pack)
|
||||
case RELOADTASKPROXIMITIES:
|
||||
if (zone) {
|
||||
Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload task proximities");
|
||||
taskmanager->LoadProximities(zone->GetZoneID());
|
||||
task_manager->LoadProximities(zone->GetZoneID());
|
||||
}
|
||||
break;
|
||||
|
||||
case RELOADTASKGOALLISTS:
|
||||
Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload task goal lists");
|
||||
taskmanager->ReloadGoalLists();
|
||||
task_manager->ReloadGoalLists();
|
||||
break;
|
||||
|
||||
case RELOADTASKSETS:
|
||||
Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload task sets");
|
||||
taskmanager->LoadTaskSets();
|
||||
task_manager->LoadTaskSets();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
+1
-1
@@ -964,7 +964,7 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name)
|
||||
lootvar = 0;
|
||||
|
||||
if(RuleB(TaskSystem, EnableTaskSystem)) {
|
||||
taskmanager->LoadProximities(zoneid);
|
||||
task_manager->LoadProximities(zoneid);
|
||||
}
|
||||
|
||||
short_name = strcpy(new char[strlen(in_short_name)+1], in_short_name);
|
||||
|
||||
Reference in New Issue
Block a user