[Shared Tasks] Implement Activity Locking (#2339)

* Add shared task element locking

This adds the `lock_activity_id` field to the tasks table which will
automatically lock a shared task when that element becomes active.

A method was added to world analogous to zone's UnlockActivities to
determine when an activity is active with respect to task steps.

Also adds quest apis to manually lock or unlock a client's shared task

* Add comment
This commit is contained in:
hg
2022-07-30 20:57:57 -04:00
committed by GitHub
parent ea878ed27f
commit f64d072af7
15 changed files with 149 additions and 30 deletions
@@ -42,6 +42,7 @@ public:
std::string completion_emote;
int replay_timer_seconds;
int request_timer_seconds;
int lock_activity_id;
};
static std::string PrimaryKey()
@@ -75,6 +76,7 @@ public:
"completion_emote",
"replay_timer_seconds",
"request_timer_seconds",
"lock_activity_id",
};
}
@@ -104,6 +106,7 @@ public:
"completion_emote",
"replay_timer_seconds",
"request_timer_seconds",
"lock_activity_id",
};
}
@@ -167,6 +170,7 @@ public:
entry.completion_emote = "";
entry.replay_timer_seconds = 0;
entry.request_timer_seconds = 0;
entry.lock_activity_id = -1;
return entry;
}
@@ -225,6 +229,7 @@ public:
entry.completion_emote = row[20] ? row[20] : "";
entry.replay_timer_seconds = atoi(row[21]);
entry.request_timer_seconds = atoi(row[22]);
entry.lock_activity_id = atoi(row[23]);
return entry;
}
@@ -281,6 +286,7 @@ public:
update_values.push_back(columns[20] + " = '" + Strings::Escape(tasks_entry.completion_emote) + "'");
update_values.push_back(columns[21] + " = " + std::to_string(tasks_entry.replay_timer_seconds));
update_values.push_back(columns[22] + " = " + std::to_string(tasks_entry.request_timer_seconds));
update_values.push_back(columns[23] + " = " + std::to_string(tasks_entry.lock_activity_id));
auto results = db.QueryDatabase(
fmt::format(
@@ -325,6 +331,7 @@ public:
insert_values.push_back("'" + Strings::Escape(tasks_entry.completion_emote) + "'");
insert_values.push_back(std::to_string(tasks_entry.replay_timer_seconds));
insert_values.push_back(std::to_string(tasks_entry.request_timer_seconds));
insert_values.push_back(std::to_string(tasks_entry.lock_activity_id));
auto results = db.QueryDatabase(
fmt::format(
@@ -377,6 +384,7 @@ public:
insert_values.push_back("'" + Strings::Escape(tasks_entry.completion_emote) + "'");
insert_values.push_back(std::to_string(tasks_entry.replay_timer_seconds));
insert_values.push_back(std::to_string(tasks_entry.request_timer_seconds));
insert_values.push_back(std::to_string(tasks_entry.lock_activity_id));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
}
@@ -433,6 +441,7 @@ public:
entry.completion_emote = row[20] ? row[20] : "";
entry.replay_timer_seconds = atoi(row[21]);
entry.request_timer_seconds = atoi(row[22]);
entry.lock_activity_id = atoi(row[23]);
all_entries.push_back(entry);
}
@@ -480,6 +489,7 @@ public:
entry.completion_emote = row[20] ? row[20] : "";
entry.replay_timer_seconds = atoi(row[21]);
entry.request_timer_seconds = atoi(row[22]);
entry.lock_activity_id = atoi(row[23]);
all_entries.push_back(entry);
}
+9
View File
@@ -28,6 +28,7 @@
#define ServerOP_SharedTaskPlayerList 0x0313 // zone -> world /taskplayerlist command
#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
enum class SharedTaskRequestGroupType {
Solo = 0,
@@ -105,6 +106,8 @@ struct SharedTaskActivityStateEntry {
uint32 max_done_count; // goalcount
uint32 updated_time;
uint32 completed_time;
int step;
bool optional;
};
struct ServerSharedTaskActivityUpdate_Struct {
@@ -162,6 +165,12 @@ struct ServerSharedTaskKickPlayers_Struct {
uint32 task_id;
};
struct ServerSharedTaskLock_Struct {
uint32 source_character_id;
uint32 task_id;
bool lock;
};
class SharedTask {
public:
// used in both zone and world validation
+1 -1
View File
@@ -34,7 +34,7 @@
* Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
*/
#define CURRENT_BINARY_DATABASE_VERSION 9190
#define CURRENT_BINARY_DATABASE_VERSION 9192
#ifdef BOTS
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9029