[wesnoth-commits] [wesnoth/wesnoth] 7b250e: Fix assert with custom synced AI commands

mattsc noreply at github.com
Thu Jun 10 19:55:21 UTC 2021


  Branch: refs/heads/1.14
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 7b250e28acf2d5a7847e5805ea1449e874b0cffd
      https://github.com/wesnoth/wesnoth/commit/7b250e28acf2d5a7847e5805ea1449e874b0cffd
  Author: mattsc <mattsc000 at gmail.com>
  Date:   2021-06-10 (Thu, 10 Jun 2021)

  Changed paths:
    M src/ai/actions.cpp

  Log Message:
  -----------
  Fix assert with custom synced AI commands

Function run() at the beginning of synced_context.cpp asserts when a command is configured not to be undoable (use_undo=false), but the undo stack is not empty (resources::undo_stack->can_undo() returns true). Thus, the undo stack needs to be cleared before executing commands that are not supposed to be undoable.

Most AI commands use use_undo=false, but custom synced commands route through do_command, which uses a hard-coded use_undo=true. That, by itself, is not a problem, but if the next AI action uses use_undo and does not clear the undo stack first, the assert is triggered. AI actions with use_undo=false therefore need to clear the undo stack. This commit adds that for recruiting and recalling, the only AI actions that did not already do so.





More information about the Commits mailing list