Ensure no invalid move pointer is passed to LearnMove.
This commit is contained in:
parent
a470d11b25
commit
9ac60dfa42
|
@ -144,13 +144,14 @@ PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithHeldItem
|
||||||
PkmnLib::Battling::CreatePokemon*
|
PkmnLib::Battling::CreatePokemon*
|
||||||
PkmnLib::Battling::CreatePokemon::LearnMove(const Arbutils::CaseInsensitiveConstString& moveName,
|
PkmnLib::Battling::CreatePokemon::LearnMove(const Arbutils::CaseInsensitiveConstString& moveName,
|
||||||
CreatureLib::Battling::AttackLearnMethod method) {
|
CreatureLib::Battling::AttackLearnMethod method) {
|
||||||
const PkmnLib::Library::MoveData* move;
|
const PkmnLib::Library::MoveData* move = nullptr;
|
||||||
if (!_library->GetMoveLibrary()->TryGet(moveName, move)) {
|
if (!_library->GetMoveLibrary()->TryGet(moveName, move)) {
|
||||||
throw CreatureException("Invalid Move given: " + moveName.std_str());
|
throw CreatureException("Invalid Move given: " + moveName.std_str());
|
||||||
}
|
}
|
||||||
if (_attacks.size() >= _library->GetSettings()->GetMaximalMoves()) {
|
if (_attacks.size() >= _library->GetSettings()->GetMaximalMoves()) {
|
||||||
throw CreatureException("This pokemon already has the maximal allowed moves.");
|
throw CreatureException("This pokemon already has the maximal allowed moves.");
|
||||||
}
|
}
|
||||||
|
Assert(move != nullptr);
|
||||||
_attacks.emplace_back(move, method);
|
_attacks.emplace_back(move, method);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue