[Commits] [wesnoth/wesnoth] 654fd2: pass display as an argument to unit::invalidate

GitHub noreply at github.com
Tue Jun 10 17:03:59 UTC 2014


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 654fd22ba89f7bb197160a0f3e36eb0521715b1e
      https://github.com/wesnoth/wesnoth/commit/654fd22ba89f7bb197160a0f3e36eb0521715b1e
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-09 (Mon, 09 Jun 2014)

  Changed paths:
    M src/actions/move.cpp
    M src/display.cpp
    M src/game_events/action_wml.cpp
    M src/unit.cpp
    M src/unit.hpp
    M src/whiteboard/manager.cpp

  Log Message:
  -----------
  pass display as an argument to unit::invalidate

Previously it always used the singleton display function, but this
seems better.


  Commit: 2282f6e90a19737ca7fe6c4f8c9248f927e7c8f9
      https://github.com/wesnoth/wesnoth/commit/2282f6e90a19737ca7fe6c4f8c9248f927e7c8f9
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-09 (Mon, 09 Jun 2014)

  Changed paths:
    M src/actions/move.cpp
    M src/display.cpp
    M src/game_events/action_wml.cpp
    M src/unit.cpp
    M src/unit.hpp
    M src/whiteboard/manager.cpp

  Log Message:
  -----------
  remove unnnecessary location argument from unit::invalidate

This function was always called with the current location of the
unit as the argument, so we simplify it.


  Commit: 390babf184b9da26cc4be5672be21c90c422701a
      https://github.com/wesnoth/wesnoth/commit/390babf184b9da26cc4be5672be21c90c422701a
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

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

  Log Message:
  -----------
  unit animation fcns become const

This commit makes the main unit animation accessor / mutator
functions applicable to const units, and makes the animation
state member variables mutable to allow this.

const'ed member functions:

set standning
idling
selecting
ghosted
disabed_ghosted
clear_haloes
refresh
invalidate
redraw

mutable member variables:

animation state enum
boost scoped pointer anim_ (can be reset in the redraw fcn)
next_idling_
frame_begin_time_
unit_halo_
refreshing_
draw_bars_

The purpose of this is to improve encapsulation of units, as now
we can use const units in the display functions, and reserve non-
const unit references for use in the game logic.


  Commit: 829c66e6bc56d95bf072e3a50b8bb0dc21d88150
      https://github.com/wesnoth/wesnoth/commit/829c66e6bc56d95bf072e3a50b8bb0dc21d88150
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

  Changed paths:
    M src/display.cpp
    M src/display.hpp
    M src/game_display.cpp
    M src/game_display.hpp

  Log Message:
  -----------
  invalidate units fcn treats units as const

Since the relevant functions are const from previous commit.


  Commit: 16db25b1197a0a7f194e622f32680e64116b3042
      https://github.com/wesnoth/wesnoth/commit/16db25b1197a0a7f194e622f32680e64116b3042
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

  Changed paths:
    M src/display.cpp

  Log Message:
  -----------
  unit redraw fcn treats units as const


  Commit: 76907870dcfd4db52489e0bbeadd1056745ed4ac
      https://github.com/wesnoth/wesnoth/commit/76907870dcfd4db52489e0bbeadd1056745ed4ac
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

  Changed paths:
    M src/display.hpp

  Log Message:
  -----------
  display object uses a const unit_map * internally

This was made possible because const units may now be drawn and
animated. There are some clients of the display object that still
call display::get_units, which is a non const getter, and which
we support by a const cast. The next step of refactor is to get
rid of that, but in this step we have at least gotten rid of all
internal uses of the non-const unit map.


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

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

  Log Message:
  -----------
  display::change_units takes a const argument


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

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

  Log Message:
  -----------
  facing and hidden become mutable attributes of unit

This is needed to be able to do animation with const units.


  Commit: 4459277f773781649932d97ac718a5c326f851c0
      https://github.com/wesnoth/wesnoth/commit/4459277f773781649932d97ac718a5c326f851c0
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

  Changed paths:
    M src/actions/attack.cpp
    M src/display.hpp
    M src/game_board.hpp
    M src/leader_scroll_dialog.cpp
    M src/unit_animation.cpp
    M src/unit_animation.hpp
    M src/unit_display.cpp
    M src/unit_display.hpp

  Log Message:
  -----------
  only const unit_map in display, unit_attack fcn uses game_board

This commit makes all the necessary changes to allow
display::get_units() to return a const unit_map rather than non-
const, and to eliminate display::get_const_units(). This allows
us to eliminate a const cast introduced in prior commit.

In leader_scroll_dialog, unit_animation, and some places in
unit_display, we change the call display::get_const_units to
get_units, and mark the return type as const.

In unit_display::unit_attack, we can't do this because that fcn
also calls unit::take_hit which is part of the game logic and
should not become const. We make that function take a reference
to game_board instead and pass resources::game_board from the
caller. Also we pass display in as an argument from the caller,
to improve encapsulation marginally.


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

  Changed paths:
    M src/actions/attack.cpp
    M src/actions/move.cpp
    M src/display.cpp
    M src/display.hpp
    M src/game_board.hpp
    M src/game_display.cpp
    M src/game_display.hpp
    M src/game_events/action_wml.cpp
    M src/leader_scroll_dialog.cpp
    M src/unit.cpp
    M src/unit.hpp
    M src/unit_animation.cpp
    M src/unit_animation.hpp
    M src/unit_display.cpp
    M src/unit_display.hpp
    M src/whiteboard/manager.cpp

  Log Message:
  -----------
  Merge branch 'units_draw_const'


Compare: https://github.com/wesnoth/wesnoth/compare/534e3514eefc...5dad318849fd


More information about the Commits mailing list