Skip to content

Commit

Permalink
move animation cache from play_controller to only fcn that uses it
Browse files Browse the repository at this point in the history
This allows us to eliminate two headers and move code out of
play_controller, and keep related code together. The cache is
now a static variable in the only function that calls it.
  • Loading branch information
cbeck88 committed Jun 17, 2014
1 parent a8a1326 commit 3d6bcb4
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
2 changes: 0 additions & 2 deletions src/play_controller.cpp
Expand Up @@ -52,7 +52,6 @@
#include "synced_context.hpp"
#include "tooltips.hpp"
#include "unit.hpp"
#include "unit_animation.hpp"
#include "unit_id.hpp"
#include "whiteboard/manager.hpp"
#include "wml_exception.hpp"
Expand Down Expand Up @@ -102,7 +101,6 @@ play_controller::play_controller(const config& level, saved_game& state_of_game,
controller_base(ticks, game_config, video),
observer(),
savegame_config(),
animation_cache(),
prefs_disp_manager_(),
tooltips_manager_(),
events_manager_(),
Expand Down
2 changes: 0 additions & 2 deletions src/play_controller.hpp
Expand Up @@ -36,7 +36,6 @@ class saved_game;
class game_data;
class team;
class unit;
class unit_animation;

namespace actions {
class undo_list;
Expand Down Expand Up @@ -172,7 +171,6 @@ class play_controller : public controller_base, public events::observer, public
events::mouse_handler& get_mouse_handler_base();
events::menu_handler& get_menu_handler() { return menu_handler_; }

std::map< std::string, std::vector<unit_animation> > animation_cache;
static const std::string wml_menu_hotkey_prefix;
protected:
void slice_before_scroll();
Expand Down
5 changes: 2 additions & 3 deletions src/unit_animation_component.cpp
Expand Up @@ -17,8 +17,6 @@
#include "config.hpp"
#include "display.hpp"
#include "map.hpp"
#include "play_controller.hpp" //Only needed to access animations cache
#include "resources.hpp" //Only needed to access animations cache
#include "preferences.hpp"
#include "unit_animation.hpp"
#include "unit.hpp"
Expand Down Expand Up @@ -199,7 +197,8 @@ void unit_animation_component::apply_new_animation_effect(const config & effect)
if(effect["id"].empty()) {
unit_animation::add_anims(animations_, effect);
} else {
std::vector<unit_animation> &built = resources::controller->animation_cache[effect["id"]];
static std::map< std::string, std::vector<unit_animation> > animation_cache;
std::vector<unit_animation> &built = animation_cache[effect["id"]];
if(built.empty()) {
unit_animation::add_anims(built, effect);
}
Expand Down

0 comments on commit 3d6bcb4

Please sign in to comment.