[Quest API] Add apis to end shared tasks (#2521)

This required some minor shared task refactoring

- Shared task expiration handling was moved to world. Previously this
  was handled by zone and had clients self remove when a shared task
  expired. This resulted in wrong messages when a task ended.

- FailTask is now implemented for shared tasks which previously only
  made the client quit the shared task. It now fails the task for all
  members by ending the shared task.

The `Client::EndSharedTask` api will end the client's current shared
task (removing all members). This is similiar to the `FailTask` api
except it doesn't require a `task_id` and the red task fail banner is
optional (live doesn't use it for shared tasks).

The global `end_dz_task` api was added for when a client context isn't
available. This will end a shared task if the current zone is a dynamic
zone for a shared task mission. Currently only shared tasks use dynamic
zones but this api can be expanded if support is added for tasks/quests.

The global `get_dz_task_id` was added to conveniently get the task id
for the current dynamic zone if it's used for a mission. Note this is
a database hit since that information is not available at zone level.
This commit is contained in:
hg
2022-11-06 11:04:39 -05:00
committed by GitHub
parent 3d7c43e92f
commit de63eaa4b2
20 changed files with 247 additions and 30 deletions
+5
View File
@@ -150,3 +150,8 @@ SharedTaskMember SharedTask::GetLeader() const
}
return {};
}
bool SharedTask::IsExpired() const
{
return m_db_shared_task.expire_time > 0 && m_db_shared_task.expire_time < std::time(nullptr);
}
+16
View File
@@ -31,6 +31,9 @@
#define ServerOP_SharedTaskMemberChange 0x0314 // world -> zone. Send shared task single member added/removed (client also handles message)
#define ServerOP_SharedTaskKickPlayers 0x0315 // zone -> world /kickplayers task
#define ServerOP_SharedTaskLock 0x0316 // zone -> world
#define ServerOP_SharedTaskEnd 0x0317 // zone -> world
#define ServerOP_SharedTaskEndByDz 0x0318 // zone -> world
#define ServerOP_SharedTaskFailed 0x0319 // world -> zone. Sends red text task failed banner to client
enum class SharedTaskRequestGroupType {
Solo = 0,
@@ -176,6 +179,18 @@ struct ServerSharedTaskLock_Struct {
bool lock;
};
struct ServerSharedTaskCharacterTask_Struct {
uint32 character_id;
uint32 task_id;
};
struct ServerSharedTaskEnd_Struct {
uint32 character_id;
uint32 task_id;
uint32 dz_id;
bool send_fail; // if true members receive red text failure banner
};
class SharedTask {
public:
// used in both zone and world validation
@@ -187,6 +202,7 @@ public:
SharedTaskMember GetLeader() const;
std::vector<SharedTaskActivityStateEntry> GetActivityState() const;
const std::vector<SharedTaskMember>& GetMembers() const;
bool IsExpired() const;
// getters
const std::vector<TaskActivitiesRepository::TaskActivities> &GetTaskActivityData() const;