don't allow loading quests in incorrect game mode

This commit is contained in:
Martin Michelsen
2024-05-01 08:31:00 -07:00
parent dfeeed2b1a
commit 636309952e
+8
View File
@@ -2002,6 +2002,14 @@ void set_lobby_quest(shared_ptr<Lobby> l, shared_ptr<const Quest> q, bool substi
throw runtime_error("lobby already has an assigned quest");
}
// Only allow loading battle/challenge quests if the game mode is correct
if ((q->challenge_template_index >= 0) != (l->mode == GameMode::CHALLENGE)) {
throw runtime_error("incorrect game mode");
}
if ((q->battle_rules != nullptr) != (l->mode == GameMode::BATTLE)) {
throw runtime_error("incorrect game mode");
}
auto s = l->require_server_state();
if (q->joinable) {