fix quest expr checks from lobby

This commit is contained in:
Martin Michelsen
2024-03-15 10:20:19 -07:00
parent 4e733b0dc6
commit dc36d2ae8d
3 changed files with 42 additions and 12 deletions
+6 -4
View File
@@ -816,8 +816,9 @@ Lobby::JoinError Lobby::join_error_for_client(std::shared_ptr<Client> c, const s
if (this->quest) {
size_t num_clients = this->count_clients() + 1;
bool v1_present = is_v1(c->version()) || this->any_v1_clients_present();
if (!c->can_see_quest(this->quest, this->event, this->difficulty, num_clients, v1_present) ||
!c->can_play_quest(this->quest, this->event, this->difficulty, num_clients, v1_present)) {
auto this_sh = this->shared_from_this();
if (!c->can_see_quest(this->quest, this_sh, this->event, this->difficulty, num_clients, v1_present) ||
!c->can_play_quest(this->quest, this_sh, this->event, this->difficulty, num_clients, v1_present)) {
return JoinError::NO_ACCESS_TO_QUEST;
}
}
@@ -930,10 +931,11 @@ QuestIndex::IncludeCondition Lobby::quest_include_condition() const {
return [this, num_players, v1_present](shared_ptr<const Quest> q) -> QuestIndex::IncludeState {
bool is_enabled = true;
for (const auto& lc : this->clients) {
if (lc && !lc->can_see_quest(q, this->event, this->difficulty, num_players, v1_present)) {
auto this_sh = this->shared_from_this();
if (lc && !lc->can_see_quest(q, this_sh, this->event, this->difficulty, num_players, v1_present)) {
return QuestIndex::IncludeState::HIDDEN;
}
if (lc && !lc->can_play_quest(q, this->event, this->difficulty, num_players, v1_present)) {
if (lc && !lc->can_play_quest(q, this_sh, this->event, this->difficulty, num_players, v1_present)) {
is_enabled = false;
}
}