Fixed nullptr dereference in ItemUse

This commit is contained in:
Deukhoofd 2022-05-14 14:56:00 +02:00
parent a8c80a3c66
commit cd50b2c2e8
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 4 additions and 1 deletions

View File

@ -368,7 +368,10 @@ void TurnHandler::ExecuteItemChoice(const ArbUt::BorrowedPtr<ItemTurnChoice>& ch
return;
}
auto* script = battle.GetValue()->GetLibrary()->GetScriptResolver()->LoadItemScript(choice->GetItem());
auto targetIndex = choice->GetTarget();
if (script == nullptr) {
return;
}
const auto& targetIndex = choice->GetTarget();
ArbUt::OptionalBorrowedPtr<Creature> target = nullptr;
if (targetIndex.has_value()) {
target = battle.GetValue()->GetCreature(targetIndex.value());