Disable keymapper during Wizard Eye (spell and crystal ball effect)
so it can be controlled via the cursor keys again.
This was a regression introduced in
12a47d956e
"Add support for ScummVM keymapper".
SpellViewGump and SpellView:
When handling a MouseDown event, do not call target_spell() if
event_mode is set, as Events expects us to select a spell in that case.
Prevents calling Events::target_spell() with callback_target set to
nullptr and subsequentially crashing the game.
To reproduce:
1. Start/load a game
2. Acquire a spellbook (obj num 57)
3. Acquire a staff (obj num 78)
4. Enable cheats (CTRL+c)
5. Enable unlimited casting (ALT+w)
6. (C)ast enchant
7. Select the staff as target
8. When prompted to select a spell, press LMB somewhere on the map
instead
Close spellbook in cancelAction when resuming magic.
Additionally, as a precaution, do not propagate RMB events
from SpellViewGump to DraggableView.
On an RMB-down event, SpellViewGump::MouseDown() calls
Events::close_spellbook(), which uses cancelAction() to actually
close the spellbook.
However, this skipped doing so if Magic::is_waiting_to_resume() was
true.
In that case, the still open SpellViewGump received the RMB-up event,
which lead to it getting closed and deleted from
DraggableView::MouseUp().
This resulted in a crash, since the book's SpellViewGump is not
expected to be deleted during gameplay.
To reproduce:
1. Start/load a game in enhanced-mode
2. Acquire a spellbook (obj num 57)
3. Acquire a staff (obj num 78)
4. Enable cheats (CTRL+c)
5. Enable unlimited casting (ALT+w)
6. (C)ast enchant
7. Select the staff as target
8. When prompted to select a spell, press RMB instead
When casting enchant in new-style mode, after selecting an object
to enchant, the spellbook is opened to choose a spell.
While the book was open, walking and other actions were still
possible. This could lead to crashes, e.g. when pressing c to cast
instead of selecting a spell.
To prevent this, lock input to the spellbook's SpellViewGump and
unlock it again in endAction().
Do not delete widgets marked for deletion in GUI::AddWidget, so it
can safely be used from widget event handlers.
Fixes the following crashes in enhanced mode:
Using the look action on a spellbook in inventory eventually causes
a call to Events::look(Obj *obj) from ContainerWidget::try_click().
For spellbooks, look() then calls view_manager->close_all_gumps().
This closes all open gumps and marks them for deletion, including
the inventory ContainerWidget.
When the spellbook gump gets added via addWidget, this executes
the deletion.
Once control returns to ContainerWidget::try_click(), the
ContainerWidget has been deleted and the game will crash when it
tries to assign to member variable ready_obj.
A similar crash happens when selecting a staff in inventory
as the target for the enchant spell.
Fixes#14957
Disable the keymapper when entering KEYINPUT_MODE and restore
its previous state when changing mode.
Makes Events::key_redirect() work again.
The key_redirect method should cause all keyboard input to be
sent to a callback, but it was broken since commit
12a47d956e
"Add support for ScummVM keymapper".
This caused problems with spellcasting:
1. Keymapper-bound actions (including movement) were still
possible while the spellbook was open
2. Spell syllables whose keys were bound via the keymapper
could not be entered.
Fixes#14959
Remove unnecessary check. Prevents infnite pause mode when dropping
an object onto an actor that is at an impassable location.
To reproduce:
1. Start/load a game in non-enhanced mode
2. Get Sherry in your party
3. Drop a chest onto Sherry
4. Drop an item onto the chest
Ultima 6 does not consider party members to be blocking when the party
is following the player. It avoids stacking them via the is_contiguous()
check instead, which also has an exception for Sherry the mouse.