void game_state::init(const config& level, play_controller & pc) { events_manager_->read_scenario(level); gui2::tloadscreen::progress("init teams"); if (level["modify_placing"].to_bool()) { LOG_NG << "modifying placing..." << std::endl; place_sides_in_preferred_locations(level); } LOG_NG << "initialized time of day regions... " << (SDL_GetTicks() - pc.ticks()) << std::endl; for (const config &t : level.child_range("time_area")) { tod_manager_.add_time_area(board_.map(),t); } LOG_NG << "initialized teams... " << (SDL_GetTicks() - pc.ticks()) << std::endl; board_.teams_.resize(level.child_count("side")); std::vector<team_builder_ptr> team_builders; int team_num = 0; for (const config &side : level.child_range("side")) { if (first_human_team_ == -1) { const std::string &controller = side["controller"]; if (controller == "human") { first_human_team_ = team_num; } } team_builder_ptr tb_ptr = create_team_builder(side, board_.teams_, level, board_); ++team_num; build_team_stage_one(tb_ptr); team_builders.push_back(tb_ptr); } { //sync traits of start units and the random start time. random_new::set_random_determinstic deterministic(gamedata_.rng()); tod_manager_.resolve_random(*random_new::generator); for(team_builder_ptr tb_ptr : team_builders) { build_team_stage_two(tb_ptr); } for(size_t i = 0; i < board_.teams_.size(); i++) { // Labels from players in your ignore list default to hidden if(preferences::is_ignored(board_.teams_[i].current_player())) { std::string label_cat = "side:" + std::to_string(i + 1); board_.hidden_label_categories_ref().push_back(label_cat); } } } pathfind_manager_.reset(new pathfind::manager(level)); lua_kernel_.reset(new game_lua_kernel(nullptr, *this, pc, *reports_)); }
void tlobby_main::process_gamelist_diff(const config& data) { if(lobby_info_.process_gamelist_diff(data)) { DBG_LB << "Received gamelist diff\n"; gamelist_dirty_ = true; } else { ERR_LB << "process_gamelist_diff failed!" << std::endl; } int joined = data.child_count("insert_child"); int left = data.child_count("remove_child"); if(joined > 0 || left > 0) { if(left > joined) { do_notify(NOTIFY_LOBBY_QUIT); } else { do_notify(NOTIFY_LOBBY_JOIN); } } }
void lobby_main::process_gamelist_diff(const config& data) { if(lobby_info_.process_gamelist_diff(data)) { DBG_LB << "Received gamelist diff\n"; gamelist_dirty_ = true; } else { ERR_LB << "process_gamelist_diff failed!" << std::endl; wesnothd_connection_.send_data(config("refresh_lobby")); } const int joined = data.child_count("insert_child"); const int left = data.child_count("remove_child"); if(joined > 0 || left > 0) { if(left > joined) { do_notify(mp::NOTIFY_LOBBY_QUIT); } else { do_notify(mp::NOTIFY_LOBBY_JOIN); } } }
void game_state::init(const int ticks, play_controller & pc, const config& level) { int ticks1 = SDL_GetTicks(); if (level["modify_placing"].to_bool()) { LOG_NG << "modifying placing..." << std::endl; place_sides_in_preferred_locations(level); } LOG_NG << "initialized time of day regions... " << (SDL_GetTicks() - ticks) << std::endl; BOOST_FOREACH(const config &t, level.child_range("time_area")) { tod_manager_.add_time_area(board_.map(),t); } LOG_NG << "initialized teams... " << (SDL_GetTicks() - ticks) << std::endl; //loadscreen::start_stage("init teams"); board_.teams_.resize(level.child_count("side")); std::vector<team_builder_ptr> team_builders; int team_num = 0; BOOST_FOREACH(const config &side, level.child_range("side")) { if (first_human_team_ == -1) { const std::string &controller = side["controller"]; if (controller == "human") { first_human_team_ = team_num; } } team_builder_ptr tb_ptr = create_team_builder(side, board_.teams_, level, board_); ++team_num; build_team_stage_one(tb_ptr); team_builders.push_back(tb_ptr); } { //sync traits of start units and the random start time. random_new::set_random_determinstic deterministic(gamedata_.rng()); tod_manager_.resolve_random(*random_new::generator); BOOST_FOREACH(team_builder_ptr tb_ptr, team_builders) { build_team_stage_two(tb_ptr); } for(size_t i = 0; i < board_.teams_.size(); i++) { // Labels from players in your ignore list default to hidden if(preferences::is_ignored(board_.teams_[i].current_player())) { std::string label_cat = "side:" + str_cast(i + 1); board_.hidden_label_categories_ref().push_back(label_cat); } } }
result_t operator()(config& child, const std::string& key, int /*startindex*/, int /*endindex*/) const { // append == insert at end. int insert_pos = child.child_count(key); return insert_range_h::operator()(child, key, insert_pos, insert_pos /*ignored by insert_range_h*/); }