From fe79921c206d19281a4e07f8d6e8ef295f988595 Mon Sep 17 00:00:00 2001 From: gfgtdf Date: Mon, 16 Mar 2020 19:11:03 +0100 Subject: [PATCH] fix assertion error in case that the scenario has no [side]s fixes #2818 --- src/play_controller.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/play_controller.cpp b/src/play_controller.cpp index 327484c8eece..f6adc3115f9f 100644 --- a/src/play_controller.cpp +++ b/src/play_controller.cpp @@ -36,6 +36,7 @@ #include "hotkey/hotkey_item.hpp" #include "hotkey/hotkey_handler.hpp" #include "map/label.hpp" +#include "game_errors.hpp" #include "gettext.hpp" #include "gui/dialogs/loading_screen.hpp" #include "gui/dialogs/transient_message.hpp" @@ -712,12 +713,18 @@ void play_controller::tab() team& play_controller::current_team() { + if(gamestate().board_.teams().size() == 0) { + throw game::game_error("The scenario has no sides defined"); + } assert(gamestate().board_.has_team(current_side())); return gamestate().board_.get_team(current_side()); } const team& play_controller::current_team() const { + if(gamestate().board_.teams().size() == 0) { + throw game::game_error("The scenario has no sides defined"); + } assert(gamestate().board_.has_team(current_side())); return gamestate().board_.get_team(current_side()); }