wesnoth / wesnoth

An open source, turn-based strategy game with a high fantasy theme.
https://www.wesnoth.org/
GNU General Public License v2.0
5.45k stars 998 forks source link

Undo command fires an event (GNA #21285) #1349

Closed wesnoth-bugs closed 7 years ago

wesnoth-bugs commented 7 years ago

Original submission by beetlenaut on 2013-11-19

Currently, there is no way to detect that a user has hit undo. That means that no ability or effect that modifies the game state with a moveto event can allow the user to undo the move. On the other hand, if the command could be detected, it would be possible for the author to reset the game state afterward.

I would like an event type named "user undo" or something similar that detects that command. In order to be more useful, it should store the unit that was un-moved and the hex it came from, but that's not entirely necessary.

(Reproduced on Linux) Release: 1.11.7+dev Priority: 5 - Normal Severity: 1 - Wish

wesnoth-bugs commented 7 years ago

Modified on 2013-11-19

beetlenaut changed severity: 3 - Normal -> 1 - Wish

wesnoth-bugs commented 7 years ago

Modified on 2014-02-16

involution wrote:

Poking around in the source, it seems there's a couple places you might try to add something like this but also a couple issues.

One place is in src/playcontroller.cpp:

https://github.com/wesnoth/wesnoth-old/blob/master/src/play_controller.cpp#L510

I'm not sure if that's the best idea.

A different place is in the undo-stack code, maybe here:

https://github.com/wesnoth/wesnoth-old/blob/master/src/actions/undo.cpp#L559

However it raises some issues. What will you do if the user then "redoes" the action? As I understand this doesn't quite play out the same as performing the action. Do you also want a "redo" event? The comments in the source code in undo.cpp seem to suggest that maybe you should disallow undo in the case you have in mind.

wesnoth-bugs commented 7 years ago

Modified on 2014-02-16

beetlenaut wrote:

I assumed that redo events actually were the same as regular actions. Apparently we would need a redo event too. (In most cases, it would just fire the original moveto event so that the same actions would occur. The redo event would have to store the unit for that to work.)

I could just disallow undo, but the case I had in mind was a unit ability. Some UMC authors have, in fact, disallowed undo for scenarios or entire campaigns in order to use an ability like that. However, from the player's standpoint, it seems like a frustrating bug. I'm not willing to do that to a user, so I gave up on my idea instead.

wesnoth-bugs commented 7 years ago

Modified on 2017-03-23

gfgtdf wrote:

1.13 supports a [on_undo] tgha that contsins actionwml that is exscuted when the action that fired the event that is appears in is undone.

gfgtdf changed status: None -> Fixed

CelticMinstrel commented 7 years ago

Wow, this is old.