[Commits] [wesnoth/wesnoth] 67e7f4: add end_play_signal type and visitors

GitHub noreply at github.com
Sun Jun 8 01:51:55 UTC 2014


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 67e7f4c873b5bfd1fde24fddae05c0cdb872f7d1
      https://github.com/wesnoth/wesnoth/commit/67e7f4c873b5bfd1fde24fddae05c0cdb872f7d1
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-07 (Sat, 07 Jun 2014)

  Changed paths:
    M src/game_end_exceptions.hpp

  Log Message:
  -----------
  add end_play_signal type and visitors

This commit adds an "end_play_signal" type. It is meant to be used
in play_controller classes to prevent crashes due to bad exception
handling / collisions, and should help us to make assumptions more
easily about when networking operations will happen

It also adds some macros to avoid the proliferation of unreadable
try catch blocks. It is expected that many of these can be
expanded and simplified after the refactor.


  Commit: c11088c4b42625b901c62794a190579eebd47269
      https://github.com/wesnoth/wesnoth/commit/c11088c4b42625b901c62794a190579eebd47269
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-07 (Sat, 07 Jun 2014)

  Changed paths:
    M src/playsingle_controller.cpp
    M src/playsingle_controller.hpp

  Log Message:
  -----------
  push end_play exceptions down one level in playsingle_controller

This uses the macros introduced to handle game end exceptions.
It should be a strict refactor.

Rebased to accomodate conflict here: https://github.com/wesnoth/wesnoth/commit/516206a0ee2fc0826707da9d54b44ed051638050
Still a strict refactor.

Note:
If end_turn_exception propogates to the top of
playsingle_controller, there is no handler beyond that and the
program will terminate. If an end turn signal gets there, we
also will terminate. This commit adds an assertion failure with
a message clarifying what happened.


  Commit: b7c18c81d94282e4241a20f2f91b1d067958ba67
      https://github.com/wesnoth/wesnoth/commit/b7c18c81d94282e4241a20f2f91b1d067958ba67
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-07 (Sat, 07 Jun 2014)

  Changed paths:
    M src/playsingle_controller.cpp
    M src/playsingle_controller.hpp

  Log Message:
  -----------
  push end_play_exceptions one down in call stack, at "play_turn()"

Continues trend of previous commit. play_turn becomes no throw
with respect to these exceptions, and so we can switch calls to it
to use the "PROPOGATE_END_PLAY_SIGNAL" instead of "HANDLE_...".

It looks like by progressively doing this and unit testing at each
step, we will be able to successfully convert all of the functions
in play_controller to use PROPOGATE, which is a cheap if else and
not an exception handler, and increase the stability of the engine
by avoiding the use of exceptions for control flow. If we continue
this way, we could push all the throws into the event handler
and the replay module. Perhaps could continue from there, but
likely at some point the exceptions might be the simpler solution
esp. for breaking recursion in WML / lua or things like this.


  Commit: 554af4bd362df8f90b6d9ae2873dbda6457d6d67
      https://github.com/wesnoth/wesnoth/commit/554af4bd362df8f90b6d9ae2873dbda6457d6d67
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-07 (Sat, 07 Jun 2014)

  Changed paths:
    M src/playsingle_controller.cpp

  Log Message:
  -----------
  remove unnecessary handler macro from events::raise_draw_event

After discussion on irc, it seems that this function doesn't
throw end level or end turn exceptions, and some play testing
suggests that removing the handler macros here is alright.


  Commit: cb9a84b4e8dee92b5b3a557ea3442d742c6efa09
      https://github.com/wesnoth/wesnoth/commit/cb9a84b4e8dee92b5b3a557ea3442d742c6efa09
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-07 (Sat, 07 Jun 2014)

  Changed paths:
    M src/playsingle_controller.cpp
    M src/playsingle_controller.hpp

  Log Message:
  -----------
  push end play exceptions out of play_controller::check_time_over


  Commit: 570e0a40d133d3fb6d29a1ea2ea6c47f412bae9b
      https://github.com/wesnoth/wesnoth/commit/570e0a40d133d3fb6d29a1ea2ea6c47f412bae9b
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-07 (Sat, 07 Jun 2014)

  Changed paths:
    M src/play_controller.hpp
    M src/playsingle_controller.cpp

  Log Message:
  -----------
  finish_turn() cannot throw end play exceptions, remove handlers


  Commit: 7c20ca5f23f693d9562a83c66e3c9f5f48cd4adc
      https://github.com/wesnoth/wesnoth/commit/7c20ca5f23f693d9562a83c66e3c9f5f48cd4adc
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-07 (Sat, 07 Jun 2014)

  Changed paths:
    M src/playsingle_controller.cpp

  Log Message:
  -----------
  remove handler from finish_side_done

This function won't throw end level or end turn. game_event pump
will not throw these, although the SDL event pump may throw them
in response to keyboard / menu events.


  Commit: 22ee9bc0cee42b1b0e8ac985b92a230f768be096
      https://github.com/wesnoth/wesnoth/commit/22ee9bc0cee42b1b0e8ac985b92a230f768be096
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-07 (Sat, 07 Jun 2014)

  Changed paths:
    M src/replay_controller.cpp
    M src/replay_controller.hpp

  Log Message:
  -----------
  push end play exceptions out of replay controller top level

This commit starts the process for replay_controller at the
play_replay_level function.


  Commit: 6eb71ad6eb00097cac31897466b74ddc261b2f8d
      https://github.com/wesnoth/wesnoth/commit/6eb71ad6eb00097cac31897466b74ddc261b2f8d
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-07 (Sat, 07 Jun 2014)

  Changed paths:
    M src/hotkey/command_executor.hpp
    M src/replay_controller.cpp
    M src/replay_controller.hpp

  Log Message:
  -----------
  push end play exceptions out of replay_controller::play_replay

Returns a "possible_end_play_signal" now instead. This also
required changes to the header in hotkey/command_executor. This
seems pretty minor, and could perhaps be refactored later.


  Commit: fed87a93837bde3651a26d426cf8a92335c6be4d
      https://github.com/wesnoth/wesnoth/commit/fed87a93837bde3651a26d426cf8a92335c6be4d
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-07 (Sat, 07 Jun 2014)

  Changed paths:
    M src/play_controller.hpp

  Log Message:
  -----------
  remove unnecessary pure virtual function definition

This is overrided differently in playsingle, playmp, and replay
controllers, and never is it called abstractly, which is what
this virtual declaration would suggest.


  Commit: 051b204113a737905364e9d4f4b1bf2e23227e18
      https://github.com/wesnoth/wesnoth/commit/051b204113a737905364e9d4f4b1bf2e23227e18
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-07 (Sat, 07 Jun 2014)

  Changed paths:
    M src/playmp_controller.cpp
    M src/playmp_controller.hpp
    M src/playsingle_controller.cpp
    M src/playsingle_controller.hpp
    M src/replay_controller.cpp

  Log Message:
  -----------
  push end play exceptions out of play_side()

This changes both the playsingle and playmp implementations,
but not the replay_controller implementation which is separate.

( squashed: fixup an oversight in replay_controller::play_side )


  Commit: 34d294eb55ea06fb64a79ae67c712db57e47f2d4
      https://github.com/wesnoth/wesnoth/commit/34d294eb55ea06fb64a79ae67c712db57e47f2d4
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-07 (Sat, 07 Jun 2014)

  Changed paths:
    M src/hotkey/command_executor.hpp
    M src/replay_controller.cpp
    M src/replay_controller.hpp

  Log Message:
  -----------
  replay_next_turn signals rather than throws, in replay_controller


  Commit: ccbe0b574bbe8175b14cfe84040b3bd4066be2e3
      https://github.com/wesnoth/wesnoth/commit/ccbe0b574bbe8175b14cfe84040b3bd4066be2e3
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-07 (Sat, 07 Jun 2014)

  Changed paths:
    M src/hotkey/command_executor.hpp
    M src/replay_controller.cpp
    M src/replay_controller.hpp

  Log Message:
  -----------
  replay_next_side signals rather than throws, in replay_controller


  Commit: 08edc7702a40717a9a27a3f8143560a33d02dc12
      https://github.com/wesnoth/wesnoth/commit/08edc7702a40717a9a27a3f8143560a33d02dc12
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-07 (Sat, 07 Jun 2014)

  Changed paths:
    M src/replay_controller.cpp
    M src/replay_controller.hpp

  Log Message:
  -----------
  play_turn signals instead of throwing in replay_controller


  Commit: 2034f066177569ff80f696fa43072aabc157b610
      https://github.com/wesnoth/wesnoth/commit/2034f066177569ff80f696fa43072aabc157b610
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-07 (Sat, 07 Jun 2014)

  Changed paths:
    M src/replay_controller.cpp
    M src/replay_controller.hpp

  Log Message:
  -----------
  replay_controller::play_side signals rather than throws


  Commit: de026e6215b9673b2dfdfddb7ba7ce4e5275e119
      https://github.com/wesnoth/wesnoth/commit/de026e6215b9673b2dfdfddb7ba7ce4e5275e119
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-07 (Sat, 07 Jun 2014)

  Changed paths:
    M src/play_controller.cpp
    M src/play_controller.hpp
    M src/playsingle_controller.cpp
    M src/replay_controller.cpp

  Log Message:
  -----------
  play_controller::init_side signals rather than throws


  Commit: 154f3db8124683fd09856d6b4169f116dee18d2e
      https://github.com/wesnoth/wesnoth/commit/154f3db8124683fd09856d6b4169f116dee18d2e
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-07 (Sat, 07 Jun 2014)

  Changed paths:
    M src/playmp_controller.cpp
    M src/playmp_controller.hpp
    M src/playsingle_controller.cpp
    M src/playsingle_controller.hpp

  Log Message:
  -----------
  play_network_turn now signals rather than throws


  Commit: 13f5b2797131a9d2b37887cc924a4db4403248eb
      https://github.com/wesnoth/wesnoth/commit/13f5b2797131a9d2b37887cc924a4db4403248eb
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-07 (Sat, 07 Jun 2014)

  Changed paths:
    M src/playmp_controller.cpp
    M src/playmp_controller.hpp
    M src/playsingle_controller.cpp
    M src/playsingle_controller.hpp

  Log Message:
  -----------
  play_human_turn signals rather than throwing


  Commit: 29ad76c3958a781681122550854fc9e6c450cd31
      https://github.com/wesnoth/wesnoth/commit/29ad76c3958a781681122550854fc9e6c450cd31
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-07 (Sat, 07 Jun 2014)

  Changed paths:
    M src/playmp_controller.cpp
    M src/playmp_controller.hpp
    M src/playsingle_controller.cpp
    M src/playsingle_controller.hpp

  Log Message:
  -----------
  play_idle_loop signals rather than throwing


  Commit: 5e0f420277a9fa3e210a7a7b657634a1293c6a69
      https://github.com/wesnoth/wesnoth/commit/5e0f420277a9fa3e210a7a7b657634a1293c6a69
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-07 (Sat, 07 Jun 2014)

  Changed paths:
    M src/playmp_controller.cpp
    M src/playmp_controller.hpp
    M src/playsingle_controller.cpp
    M src/playsingle_controller.hpp

  Log Message:
  -----------
  before_human_turn signals rather than throwing


  Commit: 9da0b4c4c849b5b87d8d9d7e9c04e9f46a858e23
      https://github.com/wesnoth/wesnoth/commit/9da0b4c4c849b5b87d8d9d7e9c04e9f46a858e23
  Author: Chris Beck <beck.ct at gmail.com>
  Date:   2014-06-07 (Sat, 07 Jun 2014)

  Changed paths:
    M src/game_end_exceptions.hpp
    M src/hotkey/command_executor.hpp
    M src/play_controller.cpp
    M src/play_controller.hpp
    M src/playmp_controller.cpp
    M src/playmp_controller.hpp
    M src/playsingle_controller.cpp
    M src/playsingle_controller.hpp
    M src/replay_controller.cpp
    M src/replay_controller.hpp

  Log Message:
  -----------
  Merge pull request #191 from cbeck88/fixup_exceptions

Fixup exceptions in playcontroller

This sequence of commits attempts to refactor the engine so that at least the play controller does not use "end_level_exception" and "end_turn_exception" for normal flow control. This helps us to simplify the normal working of the engine and make it less opaque, and should help to get the networking logic working as intended more easily.

I suppose that if we continue this way, we could push all the throws into the 
event handler and the replay module. Perhaps could continue from there, 
but likely at some point the exceptions might be the simpler solution. This
seems to be enough for now, and it has been tested thoroughly.


Compare: https://github.com/wesnoth/wesnoth/compare/8f428f93a93b...9da0b4c4c849


More information about the Commits mailing list