From 636309952e279232f1aef0993b4560dd5462d079 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Wed, 1 May 2024 08:31:00 -0700 Subject: [PATCH] don't allow loading quests in incorrect game mode --- src/ReceiveCommands.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index d0fb16b7..3ef81297 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -2002,6 +2002,14 @@ void set_lobby_quest(shared_ptr l, shared_ptr 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) {