-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
casting a spell casts the wrong spell #76137
casting a spell casts the wrong spell #76137
Conversation
the wrong spell to be cast currently selecting a spell in a long sorted spell list will cast the wrong spell due to select spell returing a sorted spell id while handle_action.cpp looks only at the unsorted spells fixes CleverRaven#76042 Fix an issue where trying to cast a spell causes the wrong spell to be cast
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
original_spell_index = std::find(known_spells_sorted.begin(), known_spells_sorted.end(), selected_spell->id() ) Might be neater than creating a new function. |
@CLIDragon |
It returns an iterator which points to the location of the spell in the list. You can convert that to an index with |
the reason I put it on draft is that I found a bug (when exiting spell menu without casting a spell, aka when selected id is negative). currently fixing along with the improvement of changing the return type of select spell instead of using the get_spell_index function |
selected streamline the feature and fix a bug
took some effort due to my rusty cpp, but got it to where I wanted. Works with the new test and all the previous ones, and is much much cleaner and more error proof (since we now return the exact spell instead of a disconnected index). |
the previous commit
local astyle somehow missed those Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
list. Remove broken color tags in spells Currently the new ui does not display spell components, and there are colors tags in spell data that are ignored resolves CleverRaven#75669 and CleverRaven#76137
* show spell components again in the new imGui spell list. Remove broken color tags in spells Currently the new ui does not display spell components, and there are colors tags in spell data that are ignored resolves #75669 and #76137 * colors regression in spell info will be fixed will use correct enery type when displaying "not enough" fixing spell list regression from imgui uilist update * removed unused properties of spellcasting_callback * fix warnings in magic.cpp
currently selecting a spell in a long sorted spell list will cast the wrong spell due to select spell returning a sorted spell index while handle_action.cpp looks only at the unsorted spells
Summary
Bugfixes "Fix issues with the spell menu where choosing a spell to cast chooses the wrong one"
Purpose of change
fixes #76042 (and duplicate #76192)
makes is so the spell a player selected is cast.
reproduction:
Describe the solution
select_spell
will now returns the selected spell instead of an index, making the internal sorting of the function irrelevant forhandle_action.cpp
Describe alternatives you've considered
returning
spell_id
directly from theuilist
instead of returning an index and converting to a spell. but I am not sure ifspell_id
is always int based, and there is no easy way I saw to convert an int to astring_id
even if there is an easy way to convert it back to int from one, and returning a spell is more convenient.Testing
The steps detailed in purpose of change, casting multiple spells, using hotkeys and mouse clicks. Also checking that casting spells works as expected when changing spell hotkeys.
enter spell menu and exit it without casting a spell (by pressing esc for example).
Additional context