From 7fec227478d9beb008f807ac5888094e83121814 Mon Sep 17 00:00:00 2001 From: Chris Beck Date: Sun, 6 Jul 2014 13:40:21 -0400 Subject: [PATCH] move is_observer from game_board to display_context, b/c editor uses --- src/display_context.cpp | 15 +++++++++++++++ src/display_context.hpp | 5 +++++ src/game_board.cpp | 11 ----------- src/game_board.hpp | 4 ---- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/display_context.cpp b/src/display_context.cpp index 591fd89db109..0d76fe1a8a6e 100644 --- a/src/display_context.cpp +++ b/src/display_context.cpp @@ -20,6 +20,8 @@ #include "unit.hpp" #include "unit_map.hpp" +#include + const unit * display_context::get_visible_unit(const map_location & loc, const team ¤t_team, bool see_all) const { if (!map().on_board(loc)) return NULL; @@ -82,3 +84,16 @@ int display_context::village_owner(const map_location& loc) const return -1; } +/** + * Determine if we are an observer, by checking if every team is not locally controlled + */ +bool display_context::is_observer() const +{ + BOOST_FOREACH(const team &t, teams()) { + if (t.is_local()) + return false; + } + + return true; +} + diff --git a/src/display_context.hpp b/src/display_context.hpp index b30b29e23588..ddfb81ccd89f 100644 --- a/src/display_context.hpp +++ b/src/display_context.hpp @@ -53,6 +53,11 @@ class display_context { */ int village_owner(const map_location & loc) const; + // Accessor from team.cpp + + /// Check if we are an observer in this game + bool is_observer() const; + // Dtor virtual ~display_context() {} diff --git a/src/game_board.cpp b/src/game_board.cpp index e3a520223490..aae98f7d6f3d 100644 --- a/src/game_board.cpp +++ b/src/game_board.cpp @@ -237,17 +237,6 @@ bool game_board::change_terrain(const map_location &loc, const std::string &t_st return true; } -bool game_board::is_observer() const -{ - BOOST_FOREACH(const team &t, teams_) { - if (t.is_local()) - return false; - } - - return true; -} - - void game_board::write_config(config & cfg) const { for(std::vector::const_iterator t = teams_.begin(); t != teams_.end(); ++t) { int side_num = t - teams_.begin() + 1; diff --git a/src/game_board.hpp b/src/game_board.hpp index cad1a9958cff..badb9bc5ed45 100644 --- a/src/game_board.hpp +++ b/src/game_board.hpp @@ -136,10 +136,6 @@ class game_board : public display_context { // Wrapped functions from unit_map. These should ultimately provide notification to observers, pathfinding. unit_map::iterator find_unit(const map_location & loc) { return units_.find(loc); } - - // Accessor from team.cpp - - bool is_observer() const; }; void swap(game_board & one, game_board & other);