Fixed nullptr dereference in ItemUse

This commit is contained in:
Deukhoofd committed 2022-05-14 14:56:00 +02:00
1 parent a8c80a3c66
commit cd50b2c2e8
1 file changed
+4 -1
+4 -1
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());