From b0dff0c0062c6dc1f9c616a170dbfed594c95d0b Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Thu, 30 May 2019 02:00:29 -0400 Subject: [PATCH] Some work on world's task activity states --- world/shared_tasks.cpp | 20 ++++++++++++++++++++ world/shared_tasks.h | 9 +++++++++ 2 files changed, 29 insertions(+) diff --git a/world/shared_tasks.cpp b/world/shared_tasks.cpp index c9dc04b3a..efb3312ad 100644 --- a/world/shared_tasks.cpp +++ b/world/shared_tasks.cpp @@ -10,6 +10,7 @@ extern ClientList client_list; extern ZSList zoneserver_list; +extern SharedTaskManager shared_tasks; void SharedTaskManager::HandleTaskRequest(ServerPacket *pack) { @@ -152,6 +153,7 @@ void SharedTaskManager::HandleTaskRequest(ServerPacket *pack) // this will also prevent any of these clients from requesting or being added to another, lets do it now before we tell zone task.SetCLESharedTasks(); + task.InitActivities(); // fire off to zone we're done! SerializeBuffer buf(10 + 10 * players.size()); buf.WriteInt32(id); // shared task's ID @@ -528,3 +530,21 @@ void SharedTask::Save() const { } +/* + * sets up activity stuff + */ +void SharedTask::InitActivities() +{ + task_state.TaskID = task_id; + task_state.AcceptedTime = time(nullptr); + task_state.Updated = true; + task_state.CurrentStep = -1; + + for (int i = 0; i < shared_tasks.GetTaskActivityCount(task_id); i++) { + task_state.Activity[i].ActivityID = i; + task_state.Activity[i].DoneCount = 0; + task_state.Activity[i].State = ActivityHidden; + task_state.Activity[i].Updated = true; + } +} + diff --git a/world/shared_tasks.h b/world/shared_tasks.h index 6d4b1f8d3..e730d8041 100644 --- a/world/shared_tasks.h +++ b/world/shared_tasks.h @@ -42,6 +42,7 @@ public: void SerializeMembers(SerializeBuffer &buf, bool include_leader = true) const; void SetCLESharedTasks(); + void InitActivities(); void Save() const; // save to database @@ -79,6 +80,14 @@ public: return nullptr; } + inline int GetTaskActivityCount(int task_id) const { + auto it = task_information.find(task_id); + if (it != task_information.end()) + return it->second.ActivityCount; + else + return 0; // hmm + } + // IPC packet processing void HandleTaskRequest(ServerPacket *pack); void HandleTaskZoneCreated(ServerPacket *pack);