mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-24 17:04:12 +00:00
move is_observer to gameboard, with accessor in playcontroller
This commit is contained in:
parent
f5a9de40d5
commit
e62553139c
@ -237,6 +237,17 @@ 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<team>::const_iterator t = teams_.begin(); t != teams_.end(); ++t) {
|
||||
int side_num = t - teams_.begin() + 1;
|
||||
|
@ -136,6 +136,10 @@ 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);
|
||||
|
@ -930,7 +930,7 @@ void game_display::add_chat_message(const time_t& time, const std::string& speak
|
||||
preferences::parse_admin_authentication(sender, message);
|
||||
|
||||
if (bell) {
|
||||
if ((type == events::chat_handler::MESSAGE_PRIVATE && (!is_observer() || whisper))
|
||||
if ((type == events::chat_handler::MESSAGE_PRIVATE && (!resources::gameboard->is_observer() || whisper))
|
||||
|| utils::word_match(message, preferences::login())) {
|
||||
sound::play_UI_sound(game_config::sounds::receive_message_highlight);
|
||||
} else if (preferences::is_friend(sender)) {
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "global.hpp"
|
||||
|
||||
#include "display.hpp"
|
||||
#include "game_board.hpp"
|
||||
#include "game_data.hpp"
|
||||
#include "map_label.hpp"
|
||||
#include "resources.hpp"
|
||||
@ -523,7 +524,7 @@ bool terrain_label::viewable() const
|
||||
return true;
|
||||
|
||||
// Observers are not privvy to team labels.
|
||||
const bool can_see_team_labels = !is_observer();
|
||||
const bool can_see_team_labels = !resources::gameboard->is_observer();
|
||||
|
||||
// Global labels are shown unless covered by a team label.
|
||||
if ( team_name_.empty() )
|
||||
|
@ -517,7 +517,7 @@ void menu_handler::show_help()
|
||||
void menu_handler::speak()
|
||||
{
|
||||
textbox_info_.show(gui::TEXTBOX_MESSAGE,_("Message:"),
|
||||
has_friends() ? is_observer() ? _("Send to observers only") : _("Send to allies only")
|
||||
has_friends() ? resources::gameboard->is_observer() ? _("Send to observers only") : _("Send to allies only")
|
||||
: "", preferences::message_private(), *gui_);
|
||||
}
|
||||
|
||||
@ -535,7 +535,7 @@ void menu_handler::shout()
|
||||
|
||||
bool menu_handler::has_friends() const
|
||||
{
|
||||
if(is_observer()) {
|
||||
if(resources::gameboard->is_observer()) {
|
||||
return !gui_->observers().empty();
|
||||
}
|
||||
|
||||
@ -1199,7 +1199,7 @@ void menu_handler::label_terrain(mouse_handler& mousehandler, bool team_only)
|
||||
void menu_handler::clear_labels()
|
||||
{
|
||||
if (gui_->team_valid()
|
||||
&& !is_observer())
|
||||
&& !resources::gameboard->is_observer())
|
||||
{
|
||||
gui_->labels().clear(gui_->current_team_name(), false);
|
||||
recorder.clear_labels(gui_->current_team_name(), false);
|
||||
@ -2549,15 +2549,15 @@ void menu_handler::send_chat_message(const std::string& message, bool allies_onl
|
||||
ss << time;
|
||||
cfg["time"] = ss.str();
|
||||
|
||||
const int side = is_observer() ? 0 : gui_->viewing_side();
|
||||
if(!is_observer()) {
|
||||
const int side = resources::gameboard->is_observer() ? 0 : gui_->viewing_side();
|
||||
if(!resources::gameboard->is_observer()) {
|
||||
cfg["side"] = side;
|
||||
}
|
||||
|
||||
bool private_message = has_friends() && allies_only;
|
||||
|
||||
if(private_message) {
|
||||
if (is_observer()) {
|
||||
if (resources::gameboard->is_observer()) {
|
||||
cfg["team_name"] = game_config::observer_team_name;
|
||||
} else {
|
||||
cfg["team_name"] = teams_[gui_->viewing_team()].team_name();
|
||||
|
@ -149,6 +149,10 @@ public:
|
||||
return gamestate_.tod_manager_;
|
||||
}
|
||||
|
||||
bool is_observer() const {
|
||||
return gamestate_.board_.is_observer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a side has won, and throws an end_level_exception.
|
||||
* Will also remove control of villages from sides with dead leaders.
|
||||
|
@ -68,7 +68,7 @@ static void show_carryover_message(saved_game& gamestate, playsingle_controller&
|
||||
std::ostringstream report;
|
||||
std::string title;
|
||||
|
||||
bool obs = is_observer();
|
||||
bool obs = playcontroller.is_observer();
|
||||
|
||||
if (obs) {
|
||||
title = _("Scenario Report");
|
||||
|
@ -207,7 +207,7 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg
|
||||
resources::controller->on_not_observer();
|
||||
}
|
||||
|
||||
if (is_observer() || (resources::gameboard->teams())[resources::screen->playing_team()].is_human()) {
|
||||
if (resources::gameboard->is_observer() || (resources::gameboard->teams())[resources::screen->playing_team()].is_human()) {
|
||||
resources::screen->set_team(resources::screen->playing_team());
|
||||
resources::screen->redraw_everything();
|
||||
resources::screen->recalculate_minimap();
|
||||
|
14
src/team.cpp
14
src/team.cpp
@ -607,20 +607,6 @@ int team::nteams()
|
||||
}
|
||||
}
|
||||
|
||||
bool is_observer()
|
||||
{
|
||||
if(teams == NULL) {
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOST_FOREACH(const team &t, *teams) {
|
||||
if (t.is_local())
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void validate_side(int side)
|
||||
{
|
||||
if(teams == NULL) {
|
||||
|
@ -381,10 +381,6 @@ namespace teams_manager {
|
||||
const std::vector<team> &get_teams();
|
||||
}
|
||||
|
||||
//FIXME: this global method really needs to be moved into play_controller,
|
||||
//or somewhere else that makes sense.
|
||||
bool is_observer();
|
||||
|
||||
//function which will validate a side. Throws game::game_error
|
||||
//if the side is invalid
|
||||
void validate_side(int side); //throw game::game_error
|
||||
|
@ -146,7 +146,7 @@ bool manager::can_modify_game_state() const
|
||||
if(wait_for_side_init_
|
||||
|| resources::teams == NULL
|
||||
|| executing_actions_
|
||||
|| is_observer()
|
||||
|| resources::gameboard->is_observer()
|
||||
|| resources::controller->is_linger_mode())
|
||||
{
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user