mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-03 07:33:40 +00:00
move code managing preference encounters out of play controller
This commit is contained in:
parent
2afe4f4f5a
commit
8b6339af9b
@ -16,6 +16,7 @@
|
||||
|
||||
#define GETTEXT_DOMAIN "wesnoth-lib"
|
||||
|
||||
#include "game_board.hpp"
|
||||
#include "game_display.hpp"
|
||||
#include "game_preferences.hpp"
|
||||
#include "gamestatus.hpp"
|
||||
@ -1043,22 +1044,22 @@ bool confirm_no_moves()
|
||||
}
|
||||
|
||||
|
||||
void encounter_recruitable_units(std::vector<team>& teams){
|
||||
for (std::vector<team>::iterator help_team_it = teams.begin();
|
||||
void encounter_recruitable_units(const std::vector<team>& teams){
|
||||
for (std::vector<team>::const_iterator help_team_it = teams.begin();
|
||||
help_team_it != teams.end(); ++help_team_it) {
|
||||
help_team_it->log_recruitable();
|
||||
encountered_units_set.insert(help_team_it->recruits().begin(), help_team_it->recruits().end());
|
||||
}
|
||||
}
|
||||
|
||||
void encounter_start_units(unit_map& units){
|
||||
void encounter_start_units(const unit_map& units){
|
||||
for (unit_map::const_iterator help_unit_it = units.begin();
|
||||
help_unit_it != units.end(); ++help_unit_it) {
|
||||
encountered_units_set.insert(help_unit_it->type_id());
|
||||
}
|
||||
}
|
||||
|
||||
void encounter_recallable_units(std::vector<team>& teams){
|
||||
void encounter_recallable_units(const std::vector<team>& teams){
|
||||
BOOST_FOREACH(const team& t, teams) {
|
||||
BOOST_FOREACH(const unit& u, t.recall_list()) {
|
||||
encountered_units_set.insert(u.type_id());
|
||||
@ -1066,7 +1067,7 @@ void encounter_recallable_units(std::vector<team>& teams){
|
||||
}
|
||||
}
|
||||
|
||||
void encounter_map_terrain(gamemap& map){
|
||||
void encounter_map_terrain(const gamemap& map){
|
||||
for (int map_x = 0; map_x < map.w(); ++map_x) {
|
||||
for (int map_y = 0; map_y < map.h(); ++map_y) {
|
||||
const t_translation::t_terrain t = map.get_terrain(map_location(map_x, map_y));
|
||||
@ -1079,6 +1080,13 @@ void encounter_map_terrain(gamemap& map){
|
||||
}
|
||||
}
|
||||
|
||||
void encounter_all_content(const game_board & gameboard_) {
|
||||
preferences::encounter_recruitable_units(gameboard_.teams_);
|
||||
preferences::encounter_start_units(gameboard_.units_);
|
||||
preferences::encounter_recallable_units(gameboard_.teams_);
|
||||
preferences::encounter_map_terrain(gameboard_.map_);
|
||||
}
|
||||
|
||||
void acquaintance::load_from_config(const config& cfg)
|
||||
{
|
||||
nick_ = cfg["nick"].str();
|
||||
|
@ -14,6 +14,7 @@
|
||||
#ifndef GAME_PREFERENCES_HPP_INCLUDED
|
||||
#define GAME_PREFERENCES_HPP_INCLUDED
|
||||
|
||||
struct game_board;
|
||||
class gamemap;
|
||||
class game_state;
|
||||
class team;
|
||||
@ -260,15 +261,18 @@ class acquaintance;
|
||||
|
||||
// Add all recruitable units as encountered so that information
|
||||
// about them are displayed to the user in the help system.
|
||||
void encounter_recruitable_units(std::vector<team>& teams);
|
||||
void encounter_recruitable_units(const std::vector<team>& teams);
|
||||
// Add all units that exist at the start to the encountered units so
|
||||
// that information about them are displayed to the user in the help
|
||||
// system.
|
||||
void encounter_start_units(unit_map& units);
|
||||
void encounter_start_units(const unit_map& units);
|
||||
// Add all units that are recallable as encountered units.
|
||||
void encounter_recallable_units(std::vector<team>& teams);
|
||||
// Add all terrains on the map as encountered terrains.
|
||||
void encounter_map_terrain(gamemap& map);
|
||||
void encounter_map_terrain(const gamemap& map);
|
||||
|
||||
// Calls all of the above functions on the current game board
|
||||
void encounter_all_content(const game_board & gb);
|
||||
|
||||
class acquaintance {
|
||||
public:
|
||||
|
@ -240,11 +240,7 @@ void play_controller::init(CVideo& video){
|
||||
|
||||
LOG_NG << "loading units..." << (SDL_GetTicks() - ticks_) << std::endl;
|
||||
loadscreen::start_stage("load units");
|
||||
preferences::encounter_recruitable_units(gameboard_.teams_);
|
||||
preferences::encounter_start_units(gameboard_.units_);
|
||||
preferences::encounter_recallable_units(gameboard_.teams_);
|
||||
preferences::encounter_map_terrain(gameboard_.map_);
|
||||
|
||||
preferences::encounter_all_content(gameboard_);
|
||||
|
||||
LOG_NG << "initializing theme... " << (SDL_GetTicks() - ticks_) << std::endl;
|
||||
loadscreen::start_stage("init theme");
|
||||
|
@ -823,7 +823,7 @@ std::string team::get_side_highlight_pango(int side)
|
||||
return rgb2highlight_pango(get_side_color_range(side+1).mid());
|
||||
}
|
||||
|
||||
void team::log_recruitable(){
|
||||
void team::log_recruitable() const {
|
||||
LOG_NG << "Adding recruitable units: \n";
|
||||
for (std::set<std::string>::const_iterator it = info_.can_recruit.begin();
|
||||
it != info_.can_recruit.end(); ++it) {
|
||||
|
@ -308,7 +308,7 @@ public:
|
||||
static std::string get_side_highlight(int side);
|
||||
static std::string get_side_highlight_pango(int side);
|
||||
|
||||
void log_recruitable();
|
||||
void log_recruitable() const;
|
||||
|
||||
/**set the share maps attribute */
|
||||
void set_share_maps( bool share_maps );
|
||||
|
Loading…
x
Reference in New Issue
Block a user