[Commits] [wesnoth/wesnoth] 16ce2a: Made display class no longer inherit from filter_c...
GitHub
noreply at github.com
Mon Jan 29 04:54:31 UTC 2018
Branch: refs/heads/master
Home: https://github.com/wesnoth/wesnoth
Commit: 16ce2af32ecce6ef0370bfd36440ae97b293bed2
https://github.com/wesnoth/wesnoth/commit/16ce2af32ecce6ef0370bfd36440ae97b293bed2
Author: Charles Dang <exodia339 at gmail.com>
Date: 2018-01-29 (Mon, 29 Jan 2018)
Changed paths:
M src/actions/create.cpp
M src/ai/composite/goal.cpp
M src/ai/default/aspect_attacks.cpp
M src/ai/default/recruitment.cpp
M src/ai/lua/lua_object.cpp
M src/display.cpp
M src/display.hpp
M src/editor/editor_display.cpp
M src/editor/editor_display.hpp
M src/editor/map/context_manager.cpp
M src/editor/map/context_manager.hpp
M src/editor/map/map_context.hpp
M src/game_display.cpp
M src/game_display.hpp
M src/game_events/action_wml.cpp
M src/game_events/conditional_wml.cpp
M src/game_events/entity_location.cpp
M src/game_state.hpp
M src/pathfind/teleport.cpp
M src/play_controller.cpp
M src/scripting/game_lua_kernel.cpp
M src/side_filter.cpp
M src/terrain/filter.cpp
M src/tests/utils/fake_display.cpp
M src/tooltips.cpp
M src/units/abilities.cpp
M src/units/animation.cpp
M src/units/filter.cpp
M src/units/filter.hpp
M src/units/unit.cpp
Log Message:
-----------
Made display class no longer inherit from filter_context
The only function that display meaningfully implemented was get_disp_context. It did implement
get_tod_man, but only meaningfully in its two derived classes (it returned the result of
resources::tod_manager in display). Additionally, the long-ass comment in the header stated the
display class should *not* inherit from filter_context. Do note that get_disp_context was retained
as a display member function.
Upon further investigation, I found that there were only two places where the display class was
passed to unit_filter. All others passed resources::filter_con. The editor_display class was also
assigned to resources::filter_con in editor::context_manager. So, I removed the second filter_context
argument from unit_filter and initialized it from resources::filter_con in all cases.
unit_filter only used the filter_context to get its display_context and the unit_map within anyway.
When using display::get_disp_context in-game, that would return a game_board object. Using
resources::filter_con in the same context would return the game_state object that owned the
aforementioned game_board, and calling get_disp_context on that game_state would return the board
as well. So we end up in the same place.
To be complete, I also made editor::context_manager inherit from filter_context. It makes much more
sense, since it can nicely implement 2/4 of the fc functions. It also ensures resources::filter_con
is valid in the editor, in case it's needed. I'm not 100% sure it is, but since it was assigned
before (to editor_display), it's very likely.
Another side effect of the above is that get_tod_man is now implemented in a more apropos class
in the editor. Essentially, editor_display (where it was implemented before by reaching into the
context_manager) holds an editor_controller which holds a context_manager (where it's now implemented).
It wasn't even really needed in editor_display and was only called once.
Similarly, get_tod_man has been removed from game_display. Again, it was only present to "properly"
implement the function in display, which only existed because display inherited from filter_context.
And get_tod_man wasn't even needed in display, game_display, or editor_display (save for the one
aforementioned call)!!! AND in game_display, it simply dereferenced a pointer to the *actual* ToD
manager in the game_state class, WHICH IN AND OF ITSELF INHERITS FROM FILTER_CONTEXT!!!
I have removed the tod_manager pointer in game_display and replaced its use with resources::tod_manager,
which in the context of the game (where game_display) would be use, point to the same thing the class
pointer did. I suppose I could have left it, since I'm trying to remove/improve the use of the
resources pointers, but I felt it better to decouple the two classes (game_display and game_state)
slightly, especially since its main purpose for existing (overriding display::get_tod_man) no longer
exists.
Finally, some of the instances where a unit_filter object is created had to be changed to use brace
initialization or else the build failed. @celticminstrel tells me this might be because of some "most
vexing parse" issue.
Some formatting and virtual/override specifiers were also applied/added.
*huffs*
Commit: 654a688616969841db0865cdf04367989f73c174
https://github.com/wesnoth/wesnoth/commit/654a688616969841db0865cdf04367989f73c174
Author: Charles Dang <exodia339 at gmail.com>
Date: 2018-01-29 (Mon, 29 Jan 2018)
Changed paths:
M src/game_display.cpp
M src/game_display.hpp
Log Message:
-----------
Game Display: added more virtual/override specifiers and removed duplicate function
set_playing_team was implemented the same as in the base class.
Compare: https://github.com/wesnoth/wesnoth/compare/16c3fdae7554...654a68861696
More information about the Commits
mailing list