From 8897f2282f72704ccb65a83979d9e0ec11eb5bbe Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 7 Dec 2019 12:49:18 +0100 Subject: [PATCH] Put the check for slots filled behind the check whether all choices are set. This because this check can be more expensive, and should run as little times as possible. In this case it should only run when all choices are set, which should be in most cases once a turn. --- src/Battling/Models/Battle.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Battling/Models/Battle.cpp b/src/Battling/Models/Battle.cpp index 57f6e21..a5767a6 100644 --- a/src/Battling/Models/Battle.cpp +++ b/src/Battling/Models/Battle.cpp @@ -26,13 +26,16 @@ bool Battle::TrySetChoice(BaseTurnChoice* choice) { void Battle::CheckChoicesSetAndRun() { for (auto side : _sides) { - if (!side->AllPossibleSlotsFilled()) { - return; - } if (!side->AllChoicesSet()) { return; } } + for (auto side : _sides) { + if (!side->AllPossibleSlotsFilled()) { + return; + } + } + auto choices = std::vector(_numberOfSides * _creaturesPerSide); auto i = 0; for (auto side : _sides) {