Use smart ArbUt pointers for returning scripts.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -367,8 +367,8 @@ void TurnHandler::ExecuteItemChoice(const ArbUt::BorrowedPtr<ItemTurnChoice>& ch
|
||||
if (!battle.HasValue()) {
|
||||
return;
|
||||
}
|
||||
auto* script = battle.GetValue()->GetLibrary()->GetScriptResolver()->LoadItemScript(choice->GetItem());
|
||||
if (script == nullptr) {
|
||||
auto script = battle.GetValue()->GetLibrary()->GetScriptResolver()->LoadItemScript(choice->GetItem());
|
||||
if (!script.HasValue()) {
|
||||
return;
|
||||
}
|
||||
const auto& targetIndex = choice->GetTarget();
|
||||
@@ -376,17 +376,17 @@ void TurnHandler::ExecuteItemChoice(const ArbUt::BorrowedPtr<ItemTurnChoice>& ch
|
||||
if (targetIndex.has_value()) {
|
||||
target = battle.GetValue()->GetCreature(targetIndex.value());
|
||||
}
|
||||
auto isCreatureUseItem = script->IsCreatureUseItem();
|
||||
auto isCreatureUseItem = script.GetValue()->IsCreatureUseItem();
|
||||
if (isCreatureUseItem && !target.HasValue()) {
|
||||
target = choice->GetUser();
|
||||
}
|
||||
|
||||
if (isCreatureUseItem) {
|
||||
if (!script->IsUseValidForCreature(target.GetValue())) {
|
||||
if (!script.GetValue()->IsUseValidForCreature(target.GetValue())) {
|
||||
return;
|
||||
}
|
||||
script->OnCreatureUse(target.GetValue(), true);
|
||||
script.GetValue()->OnCreatureUse(target.GetValue(), true);
|
||||
} else {
|
||||
script->OnUse(battle.GetValue());
|
||||
script.GetValue()->OnUse(battle.GetValue());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user