From 152ac7e407a8cc3e673a1546de2af9bda13ac896 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 29 Aug 2021 17:16:36 +0200 Subject: [PATCH] Don't throw an exception when teaching an attack when we don't have the max amount of attacks yet. Signed-off-by: Deukhoofd --- src/Battling/Models/Creature.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Battling/Models/Creature.cpp b/src/Battling/Models/Creature.cpp index 1309bc5..733b76f 100644 --- a/src/Battling/Models/Creature.cpp +++ b/src/Battling/Models/Creature.cpp @@ -302,13 +302,14 @@ namespace CreatureLib::Battling { bool Creature::HasVolatileScript(const ArbUt::BasicStringView& name) const { return _volatile.Has(name); } void Creature::AddAttack(LearnedAttack* attack) { for (size_t i = 0; i < _attacks.Count(); i++) { - if (_attacks[i] == nullptr) { + if (!_attacks[i].HasValue()) { _attacks.Set(i, attack); return; } } if (_attacks.Count() < _library->GetStaticLib()->GetSettings()->GetMaximalAttacks()) { _attacks.Append(attack); + return; } THROW("Can't add attack. The creature already has the maximum amount of attacks."); }