From bb4fd8456c156d2601a4151731c8166989cf3936 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 29 Aug 2021 17:06:45 +0200 Subject: [PATCH] Fixes CreatePokemon initializing invalid moves. --- src/Battling/Pokemon/CreatePokemon.cpp | 4 +++- src/Battling/Pokemon/CreatePokemon.hpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Battling/Pokemon/CreatePokemon.cpp b/src/Battling/Pokemon/CreatePokemon.cpp index 4cc3417..2c058ef 100644 --- a/src/Battling/Pokemon/CreatePokemon.cpp +++ b/src/Battling/Pokemon/CreatePokemon.cpp @@ -76,7 +76,9 @@ namespace PkmnLib::Battling { for (size_t i = 0; i < _attacks.Count(); i++) { auto& kv = _attacks[i]; auto move = kv.Move; - attacks[i] = new LearnedMove(move, kv.LearnMethod); + if (move.HasValue()) { + attacks[i] = new LearnedMove(move.GetValue(), kv.LearnMethod); + } } auto ivs = CreatureLib::Library::ClampedStatisticSet(_ivHp, _ivAttack, _ivDefense, _ivSpAtt, _ivSpDef, _ivSpeed); diff --git a/src/Battling/Pokemon/CreatePokemon.hpp b/src/Battling/Pokemon/CreatePokemon.hpp index dbe0880..7212c5f 100644 --- a/src/Battling/Pokemon/CreatePokemon.hpp +++ b/src/Battling/Pokemon/CreatePokemon.hpp @@ -18,7 +18,7 @@ namespace PkmnLib::Battling { uint32_t _identifier = 0; struct ToLearnMethod { - ArbUt::BorrowedPtr Move; + ArbUt::OptionalBorrowedPtr Move; CreatureLib::Battling::AttackLearnMethod LearnMethod; ToLearnMethod(ArbUt::BorrowedPtr move, CreatureLib::Battling::AttackLearnMethod method)