Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[common] [arcana] Resolve potential race condition in crafting_magic_routine #7038

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions common-arcana.lic
Original file line number Diff line number Diff line change
Expand Up @@ -836,14 +836,14 @@ module DRCA
return if training_spells.empty?
return if DRStats.mana <= settings.waggle_spells_mana_threshold

if !XMLData.prepared_spell.eql?('None') && checkcastrt == 0
if checkcastrt > 0
return
elsif !XMLData.prepared_spell.eql?('None') && checkcastrt == 0
spell = XMLData.prepared_spell
data = training_spells.find { |_skill, info| info['name'] == spell }.last
crafting_cast_spell(data, settings)
Comment on lines +839 to 844
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if checkcastrt > 0
return
elsif !XMLData.prepared_spell.eql?('None') && checkcastrt == 0
spell = XMLData.prepared_spell
data = training_spells.find { |_skill, info| info['name'] == spell }.last
crafting_cast_spell(data, settings)
unless XMLData.prepared_spell.eql?('None') && checkcastrt == 0
return
else
spell = XMLData.prepared_spell
data = training_spells.find { |_skill, info| info['name'] == spell }.last
crafting_cast_spell(data, settings)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me we want to return in all cases where we have no spell prepped. If that's correct, I prefer an unless else, versus and if/elsif not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me we want to return in all cases where we have no spell prepped. If that's correct, I prefer an unless else, versus and if/elsif not.

No, we want to fall through to preparing a spell if none are prepared.

end

return if checkcastrt > 0

needs_training = %w[Warding Utility Augmentation]
needs_training.append("Sorcery") if (settings.crafting_training_spells_enable_sorcery && !Script.running?('forge')) ||
(settings.crafting_training_spells_enable_sorcery && settings.crafting_training_spells_enable_sorcery_forging)
Expand Down
Loading