prevent player from joining game if a quest they don't have access to is in progress

This commit is contained in:
Martin Michelsen
2023-12-04 21:42:07 -08:00
parent 330dbecada
commit da0ffea7e0
5 changed files with 35 additions and 21 deletions
+3 -19
View File
@@ -404,25 +404,9 @@ unordered_map<uint32_t, shared_ptr<Client>> Lobby::clients_by_serial_number() co
QuestIndex::IncludeCondition Lobby::quest_include_condition() const {
return [this](shared_ptr<const Quest> q) -> bool {
if (q->require_flag >= 0) {
for (const auto& lc : this->clients) {
if (lc && !lc->game_data.character()->quest_flags.get(this->difficulty, q->require_flag)) {
return false;
}
}
}
if (!q->require_team_reward_key.empty()) {
// TODO: Technically we should check that all clients are on the SAME
// team, but I'm lazy (for now), so we allow clients on different teams
// to access the quest as long as all their teams have the quest reward.
for (const auto& lc : this->clients) {
if (!lc) {
continue;
}
auto team = lc->team();
if (!team || !team->has_reward(q->require_team_reward_key)) {
return false;
}
for (const auto& lc : this->clients) {
if (lc && !lc->can_access_quest(q, this->difficulty)) {
return false;
}
}
return true;