Strip trailing whitespace.
This commit is contained in:
parent
7efb1ba73b
commit
e35f4bb501
93 changed files with 436 additions and 436 deletions
|
@ -898,7 +898,7 @@ namespace {
|
|||
resources::gamedata->get_variable("damage_inflicted") = damage;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Make sure that if we're serializing a game here,
|
||||
// we got the same results as the game did originally.
|
||||
const config local_results = config_of("chance", attacker.cth_)("hits", hits)("damage", damage);
|
||||
|
@ -906,19 +906,19 @@ namespace {
|
|||
bool equals_replay = checkup_instance->local_checkup(local_results, replay_results);
|
||||
if (!equals_replay)
|
||||
{
|
||||
|
||||
|
||||
int results_chance = replay_results["chance"];
|
||||
bool results_hits = replay_results["hits"].to_bool();
|
||||
int results_damage = replay_results["damage"];
|
||||
/*
|
||||
errbuf_ << "SYNC: In attack " << a_.dump() << " vs " << d_.dump()
|
||||
errbuf_ << "SYNC: In attack " << a_.dump() << " vs " << d_.dump()
|
||||
<< " replay data differs from local calculated data:"
|
||||
<< " chance to hit in data source: " << results_chance
|
||||
<< " chance to hit in data source: " << results_chance
|
||||
<< " chance to hit in calculated: " << attacker.cth_
|
||||
<< " chance to hit in data source: " << results_chance
|
||||
<< " chance to hit in data source: " << results_chance
|
||||
<< " chance to hit in calculated: " << attacker.cth_
|
||||
;
|
||||
|
||||
|
||||
attacker.cth_ = results_chance;
|
||||
hits = results_hits;
|
||||
damage = results_damage;
|
||||
|
@ -1011,7 +1011,7 @@ namespace {
|
|||
: statistics::attack_context::MISSES, damage_done, drains_damage);
|
||||
}
|
||||
|
||||
|
||||
|
||||
replay_results.clear();
|
||||
// there was also a attribute cfg["unit_hit"] which was never used so i deleted.
|
||||
equals_replay = checkup_instance->local_checkup(config_of("dies", dies), replay_results);
|
||||
|
@ -1370,34 +1370,34 @@ namespace
|
|||
public:
|
||||
unit_advancement_choice(const map_location& loc, int total_opt, int side_num, const ai::unit_advancements_aspect& ai_advancement, bool force_dialog)
|
||||
: loc_ (loc), nb_options_(total_opt), side_num_(side_num), ai_advancement_(ai_advancement), force_dialog_(force_dialog)
|
||||
{
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~unit_advancement_choice()
|
||||
|
||||
virtual ~unit_advancement_choice()
|
||||
{
|
||||
}
|
||||
|
||||
virtual config query_user(int /*side*/) const
|
||||
{
|
||||
//the 'side' parameter might differ from side_num_-
|
||||
//the 'side' parameter might differ from side_num_-
|
||||
int res = 0;
|
||||
team t = (*resources::teams)[side_num_ - 1];
|
||||
//i wonder how this got included here ?
|
||||
//i wonder how this got included here ?
|
||||
bool is_mp = network::nconnections() != 0;
|
||||
bool is_current_side = resources::controller->current_side() == side_num_;
|
||||
//note, that the advancements for networked sides are also determined on the current playing side.
|
||||
|
||||
|
||||
//to make mp games equal we only allow selecting advancements to the current side.
|
||||
//otherwise we'd give an unfair advantage to the side that hosts ai sides if units advance during ai turns.
|
||||
if(!non_interactive() && (force_dialog_ || (t.is_human() && (is_current_side || !is_mp))))
|
||||
{
|
||||
res = dialogs::advance_unit_dialog(loc_);
|
||||
res = dialogs::advance_unit_dialog(loc_);
|
||||
}
|
||||
else if(t.is_ai() || t.is_network_ai() || t.is_empty() || t.is_idle())
|
||||
{
|
||||
res = rand() % nb_options_;
|
||||
|
||||
//if ai_advancement_ is the default advancement the following code will
|
||||
//if ai_advancement_ is the default advancement the following code will
|
||||
//have no effect because get_advancements returns an empty list.
|
||||
unit_map::iterator u = resources::units->find(loc_);
|
||||
const std::vector<std::string>& options = u->advances_to();
|
||||
|
@ -1424,7 +1424,7 @@ namespace
|
|||
return retv;
|
||||
|
||||
}
|
||||
virtual config random_choice(int /*side*/) const
|
||||
virtual config random_choice(int /*side*/) const
|
||||
{
|
||||
config retv;
|
||||
retv["value"] = 0;
|
||||
|
@ -1453,18 +1453,18 @@ void advance_unit_at(const map_location& loc, const ai::unit_advancements_aspect
|
|||
if(!unit_helper::will_certainly_advance(u)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//we don't want to let side 1 decide it during start/prestart.
|
||||
int side_for = resources::gamedata->phase() == game_data::PLAY ? 0: u->side();
|
||||
config selected = mp_sync::get_user_choice("choose",
|
||||
unit_advancement_choice(loc, unit_helper::number_of_possible_advances(*u),u->side(), ai_advancement, force_dialog), side_for);
|
||||
unit_advancement_choice(loc, unit_helper::number_of_possible_advances(*u),u->side(), ai_advancement, force_dialog), side_for);
|
||||
//calls actions::advance_unit.
|
||||
bool result = dialogs::animate_unit_advancement(loc, selected["value"], true, true);
|
||||
|
||||
DBG_NG << "animate_unit_advancement result = " << result << std::endl;
|
||||
u = resources::units->find(loc);
|
||||
// level 10 unit gives 80 XP and the highest mainline is level 5
|
||||
if (u.valid() && u->experience() > 80)
|
||||
if (u.valid() && u->experience() > 80)
|
||||
{
|
||||
ERR_NG << "Unit has too many (" << u->experience() << ") XP left; cascade leveling goes on still." << std::endl;
|
||||
}
|
||||
|
@ -1474,7 +1474,7 @@ void advance_unit_at(const map_location& loc, const ai::unit_advancements_aspect
|
|||
|
||||
|
||||
void attack_unit_and_advance(const map_location &attacker, const map_location &defender,
|
||||
int attack_with, int defend_with, bool update_display,
|
||||
int attack_with, int defend_with, bool update_display,
|
||||
const ai::unit_advancements_aspect& ai_advancement)
|
||||
{ try
|
||||
{
|
||||
|
@ -1484,7 +1484,7 @@ void attack_unit_and_advance(const map_location &attacker, const map_location &d
|
|||
{
|
||||
|
||||
unit_map::const_iterator atku = resources::units->find(attacker);
|
||||
|
||||
|
||||
if (atku != resources::units->end()) {
|
||||
advance_unit_at(attacker, ai_advancement);
|
||||
}
|
||||
|
|
|
@ -198,10 +198,10 @@ void attack_unit(const map_location &attacker, const map_location &defender,
|
|||
|
||||
/** Performs an attack, and advanced the units afterwards */
|
||||
void attack_unit_and_advance(const map_location &attacker, const map_location &defender,
|
||||
int attack_with, int defend_with, bool update_display = true,
|
||||
int attack_with, int defend_with, bool update_display = true,
|
||||
const ai::unit_advancements_aspect& ai_advancement = ai::unit_advancements_aspect());
|
||||
|
||||
/**
|
||||
/**
|
||||
advances the unit at loc if it has enough experience, maximum 20 times.
|
||||
if the unit is on the currently active side, and that side is controlled by a human, a dialog pops up.
|
||||
if we are in a non mp game, and the side is controlled by a human then a dialog is shown too.
|
||||
|
|
|
@ -980,7 +980,7 @@ void recruit_unit(const unit_type & u_type, int side_num, const map_location & l
|
|||
if ( use_undo ) {
|
||||
resources::undo_stack->add_recruit(new_unit, loc, from);
|
||||
// Check for information uncovered or randomness used.
|
||||
|
||||
|
||||
if ( mutated || !synced_context::can_undo()) {
|
||||
resources::undo_stack->clear();
|
||||
}
|
||||
|
@ -1006,7 +1006,7 @@ bool recall_unit(const std::string & id, team & current_team,
|
|||
std::vector<unit>::iterator recall_it = find_if_matches_id(recall_list, id);
|
||||
if ( recall_it == recall_list.end() )
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
// Make a copy of the unit before erasing it from the list.
|
||||
unit recall(*recall_it);
|
||||
|
|
|
@ -927,7 +927,7 @@ namespace { // Private helpers for move_unit()
|
|||
static const std::string enter_hex_str("enter_hex");
|
||||
static const std::string exit_hex_str("exit_hex");
|
||||
|
||||
|
||||
|
||||
bool obstructed_stop = false;
|
||||
|
||||
|
||||
|
@ -1183,18 +1183,18 @@ static size_t move_unit_internal(undo_list* undo_stack,
|
|||
|
||||
// Attempt moving.
|
||||
mover.try_actual_movement(show_move);
|
||||
|
||||
|
||||
config co;
|
||||
config cn = config_of("stopped_early", mover.stopped_early())("final_hex_x", mover.final_hex().x + 1)("final_hex_y", mover.final_hex().y + 1);
|
||||
bool matches_replay = checkup_instance->local_checkup(cn,co);
|
||||
if(!matches_replay)
|
||||
{
|
||||
replay::process_error("calculated movement destination (x="+ cn["final_hex_x"].str() + " y=" + cn["final_hex_y"].str() +
|
||||
replay::process_error("calculated movement destination (x="+ cn["final_hex_x"].str() + " y=" + cn["final_hex_y"].str() +
|
||||
")didn't match the original destination(x="+ co["final_hex_x"].str() + " y=" + co["final_hex_y"].str());
|
||||
|
||||
//TODO: move the unit by force to the desired destination with something like mover.reset_final_hex(co["x"], co["y"]);
|
||||
}
|
||||
|
||||
|
||||
// Bookkeeping, etc.
|
||||
// also fires the moveto event
|
||||
mover.post_move(undo_stack);
|
||||
|
@ -1235,7 +1235,7 @@ size_t move_unit_and_record(const std::vector<map_location> &steps,
|
|||
bool* interrupted,
|
||||
move_unit_spectator* move_spectator)
|
||||
{
|
||||
|
||||
|
||||
// Avoid some silliness.
|
||||
if ( steps.size() < 2 || (steps.size() == 2 && steps.front() == steps.back()) ) {
|
||||
DBG_NG << "Ignoring a unit trying to jump on its hex at " <<
|
||||
|
@ -1279,7 +1279,7 @@ size_t move_unit_from_replay(const std::vector<map_location> &steps,
|
|||
{
|
||||
// Evaluate this move.
|
||||
unit_mover mover(steps, NULL, continued_move,skip_ally_sighted, NULL);
|
||||
if ( !mover.check_expected_movement() )
|
||||
if ( !mover.check_expected_movement() )
|
||||
{
|
||||
replay::process_error("found corrupt movement in replay.");
|
||||
return 0;
|
||||
|
|
|
@ -102,7 +102,7 @@ bool get_village(const map_location& loc, int side, int *time_bonus = NULL);
|
|||
/// And enters the synced context.
|
||||
size_t move_unit_and_record(const std::vector<map_location> &steps,
|
||||
undo_list* undo_stack,
|
||||
bool continued_move = false,
|
||||
bool continued_move = false,
|
||||
bool show_move = true,
|
||||
bool* interrupted = NULL,
|
||||
move_unit_spectator* move_spectator = NULL);
|
||||
|
@ -111,7 +111,7 @@ size_t move_unit_and_record(const std::vector<map_location> &steps,
|
|||
/// to be called from replay when we are already in the synced context.
|
||||
size_t move_unit_from_replay(const std::vector<map_location> &steps,
|
||||
undo_list* undo_stack,
|
||||
bool continued_move, bool skip_ally_sighted,
|
||||
bool continued_move, bool skip_ally_sighted,
|
||||
bool show_move = true);
|
||||
|
||||
/**
|
||||
|
|
|
@ -777,7 +777,7 @@ bool undo_list::update_shroud_action::undo(int /*side*/, undo_list & undos)
|
|||
undos.undo();
|
||||
// Now keep the shroud update at the top of the undo stack.
|
||||
recorder.add_synced_command("update_shroud", replay_helper::get_update_shroud());
|
||||
|
||||
|
||||
undos.add_update_shroud();
|
||||
// Shroud actions never get moved to the redo stack, so claim an error.
|
||||
return false;
|
||||
|
|
|
@ -91,7 +91,7 @@ class undo_list : boost::noncopyable {
|
|||
|
||||
// Data:
|
||||
/// the replay data to do this action, this is only !empty() when this action is on the redo stack
|
||||
/// we need this because we dont recalculate the redos like they would be in real game,
|
||||
/// we need this because we dont recalculate the redos like they would be in real game,
|
||||
/// but even undoable comands can have "dependent" (= user_input) commands, which we save here.
|
||||
config replay_data;
|
||||
|
||||
|
|
|
@ -290,7 +290,7 @@ void attack_result::do_execute()
|
|||
{
|
||||
attack_unit_and_advance(attacker_loc_, defender_loc_, attacker_weapon, defender_weapon, true, advancements_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
set_gamestate_changed();
|
||||
//start of ugly hack. @todo 1.9 rework that via extended event system
|
||||
|
@ -611,9 +611,9 @@ void recall_result::do_execute()
|
|||
// Do the actual recalling.
|
||||
//we ignore possible erros (=unit doesnt exist on the recall list)
|
||||
//becasue that was the previous behaviour.
|
||||
synced_context::run_in_synced_context_if_not_already("recall",
|
||||
synced_context::run_in_synced_context_if_not_already("recall",
|
||||
replay_helper::get_recall(unit_id_, recall_location_, recall_from_),
|
||||
false,
|
||||
false,
|
||||
preferences::show_ai_moves(),
|
||||
synced_context::ignore_error_function);
|
||||
|
||||
|
@ -752,7 +752,7 @@ void recruit_result::do_execute()
|
|||
// This should be implied by is_success() once check_before() has been
|
||||
// called, so this is a guard against future breakage.
|
||||
assert(location_checked_ && u != NULL);
|
||||
|
||||
|
||||
synced_context::run_in_synced_context_if_not_already("recruit", replay_helper::get_recruit(u->id(), recruit_location_, recruit_from_), false, preferences::show_ai_moves());
|
||||
//TODO: should we do something to pass use_undo = false in replays and ai moves ?
|
||||
//::actions::recruit_unit(*u, get_side(), recruit_location_, recruit_from_,
|
||||
|
@ -903,9 +903,9 @@ void synced_command_result::do_execute()
|
|||
s << "local x1 = " << location_.x << " local y1 = " << location_.y << " ";
|
||||
}
|
||||
s << lua_code_;
|
||||
|
||||
|
||||
synced_context::run_in_synced_context_if_not_already("lua_ai", replay_helper::get_lua_ai(s.str()));
|
||||
|
||||
|
||||
try {
|
||||
set_gamestate_changed();
|
||||
manager::raise_gamestate_changed();
|
||||
|
|
|
@ -1959,7 +1959,7 @@ simple_move_and_targeting_phase::~simple_move_and_targeting_phase()
|
|||
|
||||
double simple_move_and_targeting_phase::evaluate()
|
||||
{
|
||||
// Pick first enemy leader, move all units as close to
|
||||
// Pick first enemy leader, move all units as close to
|
||||
// enemy leader as possible.
|
||||
// Own leader should not be moved.
|
||||
// Code does not support multiple leaders per side.
|
||||
|
|
|
@ -242,7 +242,7 @@ void carryover_info::transfer_to(config& level){
|
|||
|
||||
}
|
||||
|
||||
const config carryover_info::to_config()
|
||||
const config carryover_info::to_config()
|
||||
{
|
||||
config cfg;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
{
|
||||
this->operator()(tagname, child);
|
||||
}
|
||||
|
||||
|
||||
template <typename AT>
|
||||
config_of& operator()(const std::string& attrname, AT value)
|
||||
{
|
||||
|
|
|
@ -181,10 +181,10 @@ bool controller_base::handle_scroll(CKey& key, int mousex, int mousey, int mouse
|
|||
}
|
||||
if ((mouse_flags & SDL_BUTTON_MMASK) != 0 && preferences::middle_click_scrolls()) {
|
||||
const map_location original_loc = get_mouse_handler_base().get_scroll_start();
|
||||
|
||||
|
||||
if (get_mouse_handler_base().scroll_started()) {
|
||||
const SDL_Rect& rect = get_display().map_outside_area();
|
||||
if (sdl::point_in_rect(mousex, mousey,rect) &&
|
||||
if (sdl::point_in_rect(mousex, mousey,rect) &&
|
||||
get_mouse_handler_base().scroll_started()) {
|
||||
// Scroll speed is proportional from the distance from the first
|
||||
// middle click and scrolling speed preference.
|
||||
|
@ -192,7 +192,7 @@ bool controller_base::handle_scroll(CKey& key, int mousex, int mousey, int mouse
|
|||
const double snap_dist = 16; // Snap to horizontal/vertical scrolling
|
||||
const double x_diff = (mousex - original_loc.x);
|
||||
const double y_diff = (mousey - original_loc.y);
|
||||
|
||||
|
||||
if (fabs(x_diff) > snap_dist || fabs(y_diff) <= snap_dist) dx += speed * x_diff;
|
||||
if (fabs(y_diff) > snap_dist || fabs(x_diff) <= snap_dist) dy += speed * y_diff;
|
||||
}
|
||||
|
|
|
@ -532,7 +532,7 @@ int recall_dialog(display& disp, std::vector< const unit* >& units, int side, co
|
|||
options.push_back(option.str());
|
||||
options_to_filter.push_back(option_to_filter.str());
|
||||
}
|
||||
|
||||
|
||||
gui::dialog rmenu(disp, _("Recall") + title_suffix,
|
||||
_("Select unit:") + std::string("\n"),
|
||||
gui::OK_CANCEL, gui::dialog::default_style);
|
||||
|
@ -843,7 +843,7 @@ void save_preview_pane::draw_contents()
|
|||
case game_classification::TEST:
|
||||
str << _("Test scenario");
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (bad_lexical_cast &) {
|
||||
str << campaign_type;
|
||||
}
|
||||
|
|
|
@ -159,7 +159,7 @@ editor_controller::~editor_controller()
|
|||
resources::units = NULL;
|
||||
resources::tod_manager = NULL;
|
||||
resources::teams = NULL;
|
||||
|
||||
|
||||
resources::classification = NULL;
|
||||
resources::mp_settings = NULL;
|
||||
}
|
||||
|
@ -960,7 +960,7 @@ void editor_controller::show_menu(const std::vector<std::string>& items_arg, int
|
|||
|
||||
const hotkey::hotkey_command& command = hotkey::get_hotkey_command(*i);
|
||||
|
||||
if ( ( can_execute_command(command)
|
||||
if ( ( can_execute_command(command)
|
||||
&& (!context_menu || in_context_menu(command.id)) )
|
||||
|| command.id == hotkey::HOTKEY_NULL) {
|
||||
items.push_back(*i);
|
||||
|
|
|
@ -86,7 +86,7 @@ public:
|
|||
context_manager_.gui().replace_overlay_map(&context_manager_.get_map_context().get_overlays());
|
||||
|
||||
resources::teams = &context_manager_.get_map_context().get_teams();
|
||||
|
||||
|
||||
resources::classification = &context_manager_.get_map_context().get_game_state().classification();
|
||||
resources::mp_settings = &context_manager_.get_map_context().get_game_state().mp_settings();
|
||||
|
||||
|
@ -567,7 +567,7 @@ void context_manager::save_map_as_dialog()
|
|||
input_name = get_dir(default_dir_ + "/maps");
|
||||
}
|
||||
const std::string old_input_name = input_name;
|
||||
|
||||
|
||||
int overwrite_res = 1;
|
||||
do {
|
||||
input_name = old_input_name;
|
||||
|
|
|
@ -121,7 +121,7 @@ public:
|
|||
}
|
||||
|
||||
void replace_schedule(const std::vector<time_of_day>& schedule);
|
||||
|
||||
|
||||
/**
|
||||
* Replace the [time]s of the currently active area.
|
||||
*/
|
||||
|
@ -149,7 +149,7 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return the index of the currently active area.
|
||||
*/
|
||||
int get_active_area() const {
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
//event handling
|
||||
|
||||
virtual handler_vector handler_members() { return handler_vector(); }
|
||||
|
||||
|
||||
virtual void select_fg_item(const std::string& item_id) = 0;
|
||||
virtual void select_bg_item(const std::string& item_id) = 0;
|
||||
|
||||
|
|
|
@ -200,8 +200,8 @@ void flg_manager::reset_gender_combo(gui::combo& combo_gender) const
|
|||
}
|
||||
|
||||
bool flg_manager::is_random_faction()
|
||||
{
|
||||
return (*current_faction_)["random_faction"].to_bool();
|
||||
{
|
||||
return (*current_faction_)["random_faction"].to_bool();
|
||||
}
|
||||
|
||||
void flg_manager::resolve_random() {
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace formula_tokenizer
|
|||
|
||||
typedef std::string::const_iterator iterator;
|
||||
|
||||
/// TOKEN_TYPE is already defined in a Winnt.h (a windows header wich is included under some conditions.)
|
||||
/// TOKEN_TYPE is already defined in a Winnt.h (a windows header wich is included under some conditions.)
|
||||
enum TOKEN_TYPE { TOKEN_OPERATOR, TOKEN_STRING_LITERAL,
|
||||
TOKEN_IDENTIFIER, TOKEN_INTEGER, TOKEN_DECIMAL,
|
||||
TOKEN_LPARENS, TOKEN_RPARENS,
|
||||
|
|
|
@ -62,7 +62,7 @@ class game_board {
|
|||
friend class events::menu_handler;
|
||||
|
||||
friend class game_display;
|
||||
/**
|
||||
/**
|
||||
* Temporary unit move structs:
|
||||
*
|
||||
* Probably don't remove these friends, this is actually fairly useful. These structs are used by:
|
||||
|
@ -72,14 +72,14 @@ class game_board {
|
|||
* For AI, the ai wants to move two units next to eachother so it can ask for attack calculations. This should not trigger
|
||||
* pathfinding modifications, so the version that directly changes the unit map is probably preferable, although it should be
|
||||
* refactored.
|
||||
* For whiteboard and wml actions, we generally do want pathfinding to be updated, so use the game_board constructors which I
|
||||
* For whiteboard and wml actions, we generally do want pathfinding to be updated, so use the game_board constructors which I
|
||||
* have added to these structs instead.
|
||||
*
|
||||
**/
|
||||
friend struct temporary_unit_placer;
|
||||
friend struct temporary_unit_mover;
|
||||
friend struct temporary_unit_remover;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors and const accessors
|
||||
|
|
|
@ -326,7 +326,7 @@ namespace game_config
|
|||
team_rgb_name[id] = teamC["name"];
|
||||
//generate palette of same name;
|
||||
std::vector<Uint32> tp = palette(team_rgb_range[id]);
|
||||
if (tp.empty()) {
|
||||
if (tp.empty()) {
|
||||
continue;
|
||||
}
|
||||
team_rgb_colors.insert(std::make_pair(id,tp));
|
||||
|
|
|
@ -264,7 +264,7 @@ void game_config_manager::load_addons_cfg()
|
|||
|
||||
const std::string info_cfg = uc + "/_info.cfg";
|
||||
if (file_exists(info_cfg)) {
|
||||
|
||||
|
||||
config info;
|
||||
cache_.get_config(info_cfg, info);
|
||||
const config info_tag = info.child_or_empty("info");
|
||||
|
|
|
@ -250,7 +250,7 @@ game_controller::game_controller(const commandline_options& cmdline_opts, const
|
|||
if (!cmdline_opts_.unit_test->empty()) {
|
||||
test_scenario_ = *cmdline_opts_.unit_test;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (cmdline_opts_.windowed)
|
||||
preferences::set_fullscreen(false);
|
||||
|
@ -475,7 +475,7 @@ int game_controller::unit_test()
|
|||
}
|
||||
|
||||
savegame::clean_saves(state_.classification().label);
|
||||
|
||||
|
||||
if (cmdline_opts_.noreplaycheck)
|
||||
return 0; //we passed, huzzah!
|
||||
|
||||
|
@ -498,10 +498,10 @@ int game_controller::unit_test()
|
|||
|
||||
try {
|
||||
//LEVEL_RESULT res = play_game(disp(), state_, resources::config_manager->game_config(), IO_NONE, false,false,false,true);
|
||||
LEVEL_RESULT res = ::play_replay(disp(), state_, resources::config_manager->game_config(), video_, true);
|
||||
LEVEL_RESULT res = ::play_replay(disp(), state_, resources::config_manager->game_config(), video_, true);
|
||||
if (!(res == VICTORY || res == NONE)) {
|
||||
std::cerr << "Observed failure on replay" << std::endl;
|
||||
return 4;
|
||||
return 4;
|
||||
}
|
||||
/*::play_replay(disp(),state_,resources::config_manager->game_config(),
|
||||
video_);*/
|
||||
|
@ -728,7 +728,7 @@ bool game_controller::new_campaign()
|
|||
const config &campaign = campaigns[campaign_num];
|
||||
state_.classification().campaign = campaign["id"].str();
|
||||
state_.classification().abbrev = campaign["abbrev"].str();
|
||||
|
||||
|
||||
std::string random_mode = use_deterministic_mode ? "deterministic" : "";
|
||||
state_.carryover_sides_start["random_mode"] = random_mode;
|
||||
state_.classification().random_mode = random_mode;
|
||||
|
|
|
@ -2234,7 +2234,7 @@ WML_HANDLER_FUNCTION(sound_source, /*event_info*/, cfg)
|
|||
}
|
||||
|
||||
/// Store the relative direction from one hex to antoher in a WML variable.
|
||||
/// This is mainly useful as a diagnostic tool, but could be useful
|
||||
/// This is mainly useful as a diagnostic tool, but could be useful
|
||||
/// for some kind of scenario.
|
||||
WML_HANDLER_FUNCTION(store_relative_dir, /*event_info*/, cfg)
|
||||
{
|
||||
|
@ -2264,7 +2264,7 @@ WML_HANDLER_FUNCTION(store_relative_dir, /*event_info*/, cfg)
|
|||
|
||||
/// Store the rotation of one hex around another in a WML variable.
|
||||
/// In increments of 60 degrees, clockwise.
|
||||
/// This is mainly useful as a diagnostic tool, but could be useful
|
||||
/// This is mainly useful as a diagnostic tool, but could be useful
|
||||
/// for some kind of scenario.
|
||||
WML_HANDLER_FUNCTION(store_rotate_map_location, /*event_info*/, cfg)
|
||||
{
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace game_events
|
|||
typedef boost::weak_ptr<event_handler> internal_ptr;
|
||||
/// The underlying list.
|
||||
typedef utils::smart_list<internal_ptr> list_t;
|
||||
|
||||
|
||||
public: // types
|
||||
/// Handler list iterators are rather limited. They can be constructed
|
||||
/// from a reference iterator (not default constructed), incremented,
|
||||
|
|
|
@ -324,7 +324,7 @@ protected:
|
|||
//if this is a start-of-scenario save then playcampaign.cpp merged
|
||||
//units in [replay_start][side] merged with [side] already
|
||||
//units that are in '[scenario][side]' are 'first'
|
||||
|
||||
|
||||
//for create-or-recall semantics to work: for each unit with non-empty
|
||||
//id, unconditionally put OTHER, later, units with same id directly to
|
||||
//recall list, not including them in unit_configs_
|
||||
|
|
|
@ -159,7 +159,7 @@ public:
|
|||
std::string end_text; /**< end-of-campaign text */
|
||||
unsigned int end_text_duration; /**< for how long the end-of-campaign text is shown */
|
||||
std::string difficulty; /**< The difficulty level the game is being played on. */
|
||||
std::string random_mode;
|
||||
std::string random_mode;
|
||||
};
|
||||
MAKE_ENUM_STREAM_OPS2(game_classification, CAMPAIGN_TYPE)
|
||||
|
||||
|
|
|
@ -278,13 +278,13 @@ hotkey_preferences_dialog::hotkey_preferences_dialog(display& disp) :
|
|||
|
||||
// Populate the command vectors, this needs to happen only once.
|
||||
const boost::ptr_vector<hotkey::hotkey_command>& list = hotkey::get_hotkey_commands();
|
||||
|
||||
|
||||
//for (size_t i = 0; list[i].id != hotkey::HOTKEY_NULL; ++i) {
|
||||
BOOST_FOREACH(const hotkey::hotkey_command& command, list)
|
||||
{
|
||||
if (command.hidden)
|
||||
if (command.hidden)
|
||||
{
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (command.scope) {
|
||||
|
|
|
@ -186,7 +186,7 @@ public:
|
|||
* Constructor.
|
||||
* @pre @zoom >= @offset Otherwise the result will have empty pixels.
|
||||
* @pre @offset > 0 Otherwise the procedure will not return.
|
||||
*
|
||||
*
|
||||
* @param degrees Amount of rotation (in degrees).
|
||||
* Positive values are clockwise; negative are counter-clockwise.
|
||||
* @param zoom The zoom level to calculate the rotation from.
|
||||
|
|
|
@ -166,9 +166,9 @@ std::string get_timespan(const time_t& t) {
|
|||
static void print_precise_timestamp(std::ostream & out)
|
||||
{
|
||||
facet.put(
|
||||
std::ostreambuf_iterator<char>(out),
|
||||
out,
|
||||
' ',
|
||||
std::ostreambuf_iterator<char>(out),
|
||||
out,
|
||||
' ',
|
||||
boost::posix_time::microsec_clock::local_time());
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ std::ostream &logger::operator()(log_domain const &domain, bool show_names, bool
|
|||
ss << "Error (strict mode, strict_level = " << strict_level_ << "): wesnoth reported on channel " << name_ << " " << domain.domain_->first;
|
||||
std::cerr << ss.str() << std::endl;
|
||||
strict_threw_ = true;
|
||||
}
|
||||
}
|
||||
std::ostream& stream = output();
|
||||
if(do_indent) {
|
||||
for(int i = 0; i != indent; ++i)
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
// Defines the MAKE_ENUM macro,
|
||||
// and companion macro MAKE_ENUM_STREAM_OPS, which also enables lexical_cast
|
||||
// Defines the MAKE_ENUM macro,
|
||||
// and companion macro MAKE_ENUM_STREAM_OPS, which also enables lexical_cast
|
||||
// Currently this has 1 argument and 2 argument variety.
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Example Usage:
|
||||
|
@ -27,7 +27,7 @@
|
|||
#include "make_enum.hpp"
|
||||
|
||||
namespace foo {
|
||||
|
||||
|
||||
MAKE_ENUM(enumname,
|
||||
(val1, "name1")
|
||||
(val2, "name2")
|
||||
|
@ -42,7 +42,7 @@ namespace foo {
|
|||
|
||||
|
||||
class bar {
|
||||
public:
|
||||
public:
|
||||
|
||||
MAKE_ENUM(another,
|
||||
(val1, "name1")
|
||||
|
@ -66,7 +66,7 @@ MAKE_ENUM_STREAM_OPS2(bar , another)
|
|||
* foo::string_to_enumname(std::string); //throws bad_enum_cast
|
||||
* foo::string_to_enumname(std::string, foo::enumname default); //no throw
|
||||
* foo::enumname_to_string(foo::enumname); //no throw
|
||||
*
|
||||
*
|
||||
* The stream ops define
|
||||
* std::ostream & operator<< (std::ostream &, foo::enumname) //no throw. asserts false if enum has an illegal value.
|
||||
* std::istream & operator>> (std::istream &, foo::enumname &) //throws twml_exception including line number and arguments, IF game_config::debug is true.
|
||||
|
@ -76,21 +76,21 @@ MAKE_ENUM_STREAM_OPS2(bar , another)
|
|||
* //and then proceeding, or use a wrapper like lexical_cast_default which will assign the
|
||||
* //default value and proceed after the dialog passes.
|
||||
*
|
||||
* In case of a bad string -> enum conversion from istream output,
|
||||
* In case of a bad string -> enum conversion from istream output,
|
||||
* the istream will have its fail bit set.
|
||||
* This means that lexical_casts will throw a bad_lexical_cast,
|
||||
* in the similar scenario. (but, that exception won't have any
|
||||
* details about the error.)
|
||||
*
|
||||
* It is recommended to use this type either the built-in wesnoth
|
||||
* lexical_cast or lexical_cast default.
|
||||
* lexical_cast or lexical_cast default.
|
||||
*
|
||||
* HOWEVER, if you DON'T want twml_exceptions to be thrown in any
|
||||
* circumstance, then use the string_to_enumname functions instead.
|
||||
*
|
||||
* To get lexical_cast, you must separately include util.hpp
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* For example code, see src/tests/test_make_enum.cpp
|
||||
*
|
||||
|
@ -117,18 +117,18 @@ public:
|
|||
bad_enum_cast(const std::string& enumname, const std::string str)
|
||||
: message("Failed to convert String \"" + str + "\" to type " + enumname)
|
||||
{}
|
||||
|
||||
|
||||
virtual ~bad_enum_cast() throw() {}
|
||||
|
||||
|
||||
const char * what() const throw()
|
||||
{
|
||||
return message.c_str();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
const std::string message;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define CAT2( A, B ) A ## B
|
||||
#define CAT3( A, B, C ) A ## B ## C
|
||||
|
@ -145,25 +145,25 @@ private:
|
|||
|
||||
#define EXPANDENUMVALUE( a, b ) a ,
|
||||
#define EXPANDENUMTYPE( r, data, elem ) EXPANDENUMVALUE elem
|
||||
|
||||
|
||||
#define EXPANDENUMFUNCTIONRETURN( a, b ) if ( str == b ) return a;
|
||||
#define EXPANDENUMFUNCTION( r, data, elem ) EXPANDENUMFUNCTIONRETURN elem
|
||||
|
||||
|
||||
#define EXPANDENUMFUNCTIONREVRETURN( a, b ) if ( val == a ) return b;
|
||||
#define EXPANDENUMFUNCTIONREV( r, data, elem ) EXPANDENUMFUNCTIONREVRETURN elem
|
||||
|
||||
|
||||
#define ADD_PAREN_1( A, B ) ((A, B)) ADD_PAREN_2
|
||||
#define ADD_PAREN_2( A, B ) ((A, B)) ADD_PAREN_1
|
||||
#define ADD_PAREN_1_END
|
||||
#define ADD_PAREN_2_END
|
||||
#define MAKEPAIRS( INPUT ) BOOST_PP_CAT(ADD_PAREN_1 INPUT,_END)
|
||||
|
||||
#define MAKEPAIRS( INPUT ) BOOST_PP_CAT(ADD_PAREN_1 INPUT,_END)
|
||||
|
||||
#define MAKEENUMTYPE( NAME, CONTENT ) \
|
||||
enum NAME { \
|
||||
BOOST_PP_SEQ_FOR_EACH(EXPANDENUMTYPE, , MAKEPAIRS(CONTENT)) \
|
||||
}; \
|
||||
|
||||
|
||||
|
||||
|
||||
#define MAKEENUMCAST( NAME, PREFIX, CONTENT ) \
|
||||
PREFIX NAME CAT3(string_to_, NAME, _default) (const std::string& str, NAME def) \
|
||||
{ \
|
||||
|
@ -183,11 +183,11 @@ PREFIX std::string CAT2(NAME,_to_string) (NAME val) \
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#define MAKE_ENUM( NAME, CONTENT ) \
|
||||
MAKEENUMTYPE( NAME, CONTENT ) \
|
||||
MAKEENUMCAST( NAME, static , CONTENT )
|
||||
|
||||
|
||||
#define MAKE_ENUM_STREAM_OPS1( NAME ) \
|
||||
inline std::ostream& operator<< (std::ostream & os, NAME val) \
|
||||
{ \
|
||||
|
|
|
@ -142,7 +142,7 @@ map_location::DIRECTION map_location::get_relative_dir(const map_location & loc,
|
|||
{
|
||||
if (opt == map_location::DEFAULT) {
|
||||
map_location::DIRECTION dir = NDIRECTIONS;
|
||||
|
||||
|
||||
int dx = loc.x - x;
|
||||
int dy = loc.y - y;
|
||||
if (loc.x%2==1 && x%2==0) dy--;
|
||||
|
@ -152,7 +152,7 @@ map_location::DIRECTION map_location::get_relative_dir(const map_location & loc,
|
|||
int dist = abs(dx); // Distance from north-south line
|
||||
int dist_diag_SW_NE = abs(dy + (dx + (dy>0?0:1) )/2); // Distance from diagonal line SW-NE
|
||||
int dist_diag_SE_NW = abs(dy - (dx - (dy>0?0:1) )/2); // Distance from diagonal line SE-NW
|
||||
|
||||
|
||||
if (dy > 0) dir = SOUTH;
|
||||
else dir = NORTH;
|
||||
|
||||
|
@ -206,7 +206,7 @@ std::pair<int,int> map_location::get_in_basis_N_NE() const {
|
|||
ret.second = temp.x;
|
||||
temp = temp.get_direction(SOUTH_WEST,temp.x);
|
||||
assert(temp.x == 0);
|
||||
|
||||
|
||||
ret.first = -temp.y;
|
||||
temp = temp.get_direction(NORTH,temp.y);
|
||||
assert(temp.y == 0);
|
||||
|
|
|
@ -132,8 +132,8 @@ std::vector<map_location> parse_location_range(const std::string& xvals,
|
|||
*/
|
||||
void write_location_range(const std::set<map_location>& locs, config& cfg);
|
||||
|
||||
/**
|
||||
* Parse x,y keys of a config into a vector of locations
|
||||
/**
|
||||
* Parse x,y keys of a config into a vector of locations
|
||||
*
|
||||
* Throws bad_lexical_cast if it fails to parse.
|
||||
*/
|
||||
|
@ -258,7 +258,7 @@ inline map_location map_location::get_direction(
|
|||
int x_factor = (dir <= 2u) ? 1 : -1; //whether we go east + or west -
|
||||
|
||||
unsigned int tmp_y = dir - 2; //South East => 0, South => 1, South West => 2, North West => 3, North => INT_MAX, North East => INT_MAX - 1
|
||||
int y_factor = (tmp_y <= 2u) ? 1 : -1; //whether we go south + or north -
|
||||
int y_factor = (tmp_y <= 2u) ? 1 : -1; //whether we go south + or north -
|
||||
|
||||
if (tmp_y <= 2u) {
|
||||
return map_location(x + x_factor * n, y + y_factor * ((n + ((x & 1) == 1)) / 2));
|
||||
|
@ -331,7 +331,7 @@ inline bool tiles_adjacent(const map_location& a, const map_location& b)
|
|||
// and the x value of the hex with the greater y value is even.
|
||||
|
||||
switch (a.y - b.y) {
|
||||
case 1 :
|
||||
case 1 :
|
||||
switch (a.x - b.x) {
|
||||
case 1:
|
||||
case -1:
|
||||
|
@ -341,7 +341,7 @@ inline bool tiles_adjacent(const map_location& a, const map_location& b)
|
|||
default:
|
||||
return false;
|
||||
}
|
||||
case -1 :
|
||||
case -1 :
|
||||
switch (a.x - b.x) {
|
||||
case 1:
|
||||
case -1:
|
||||
|
|
|
@ -646,7 +646,7 @@ bool menu_handler::do_recruit(const std::string &name, int side_num,
|
|||
current_team.set_action_bonus_count(1 + current_team.action_bonus_count());
|
||||
|
||||
// Do the recruiting.
|
||||
|
||||
|
||||
synced_context::run_in_synced_context("recruit", replay_helper::get_recruit(u_type->id(), loc, recruited_from));
|
||||
return true;
|
||||
}
|
||||
|
@ -695,7 +695,7 @@ void menu_handler::recall(int side_num, const map_location &last_hex)
|
|||
|
||||
int res = dialogs::recall_dialog(*gui_, recall_list_team, side_num, get_title_suffix(side_num), current_team.recall_cost());
|
||||
int unit_cost = current_team.recall_cost();
|
||||
if (res < 0) {
|
||||
if (res < 0) {
|
||||
return;
|
||||
}
|
||||
// we need to check if unit has a specific recall cost
|
||||
|
@ -733,7 +733,7 @@ void menu_handler::recall(int side_num, const map_location &last_hex)
|
|||
}
|
||||
|
||||
if (!resources::whiteboard->save_recall(*recall_list_team[res], side_num, recall_location)) {
|
||||
bool success = synced_context::run_in_synced_context("recall",
|
||||
bool success = synced_context::run_in_synced_context("recall",
|
||||
replay_helper::get_recall(recall_list_team[res]->id(), recall_location, recall_from),
|
||||
true,
|
||||
true,
|
||||
|
@ -3159,7 +3159,7 @@ void console_handler::do_unit() {
|
|||
int int_value = lexical_cast<int>(value);
|
||||
for (int levels=0; levels<int_value; levels++) {
|
||||
i->set_experience(i->max_experience());
|
||||
|
||||
|
||||
advance_unit_at(loc,true);
|
||||
i = menu_handler_.units_.find(loc);
|
||||
if (!i.valid()) {
|
||||
|
@ -3311,7 +3311,7 @@ void menu_handler::request_control_change ( int side_num, const std::string& pla
|
|||
LOG_NG << " *** It's us, throwing end turn exception " << std::endl;
|
||||
} else {
|
||||
LOG_NG << " *** It's not us, changing sides now as usual, then throwing end_turn " << std::endl;
|
||||
change_side_controller(side,player);
|
||||
change_side_controller(side,player);
|
||||
}
|
||||
throw end_turn_exception(side_num);
|
||||
} else {
|
||||
|
|
|
@ -63,7 +63,7 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::
|
|||
double ratio = std::min<double>( w*1.0 / map_width, h*1.0 / map_height);
|
||||
return create_neutral_surface(map_width * ratio, map_height * ratio);
|
||||
}
|
||||
|
||||
|
||||
surface minimap(create_neutral_surface(map_width, map_height));
|
||||
if(minimap == NULL)
|
||||
return surface(NULL);
|
||||
|
|
|
@ -570,7 +570,7 @@ void mouse_handler::move_action(bool browse)
|
|||
// clear current unit selection so that any other unit selected
|
||||
// triggers a new selection
|
||||
selected_hex_ = map_location();
|
||||
|
||||
|
||||
attack_enemy(u->get_location(), clicked_u->get_location(), choice);
|
||||
}
|
||||
}
|
||||
|
@ -613,19 +613,19 @@ void mouse_handler::move_action(bool browse)
|
|||
// clear current unit selection so that any other unit selected
|
||||
// triggers a new selection
|
||||
selected_hex_ = map_location();
|
||||
|
||||
|
||||
if (not_interrupted)
|
||||
attack_enemy(attack_from, hex, choice); // Fight !!
|
||||
|
||||
|
||||
//TODO: Maybe store the attack choice so "press t to continue"
|
||||
// can also continue the attack?
|
||||
|
||||
|
||||
if (alt_unit_selected && !selected_hex_.valid()) {
|
||||
//reselect other unit if selected during movement animation
|
||||
select_hex(src, browse);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -859,7 +859,7 @@ size_t mouse_handler::move_unit_along_route(const std::vector<map_location> & st
|
|||
|
||||
size_t moves = 0;
|
||||
try {
|
||||
|
||||
|
||||
LOG_NG << "move unit along route from " << steps.front() << " to " << steps.back() << "\n";
|
||||
moves = actions::move_unit_and_record(steps, resources::undo_stack,
|
||||
false, true, &interrupted);
|
||||
|
@ -1067,7 +1067,7 @@ int mouse_handler::show_attack_dialog(const map_location& attacker_loc, const ma
|
|||
BOOST_FOREACH(int i, disable_items_skip) {
|
||||
if (i<=res) res++;
|
||||
}
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -1246,15 +1246,15 @@ void mouse_handler::set_current_paths(const pathfind::paths & new_paths) {
|
|||
}
|
||||
|
||||
team & mouse_handler::viewing_team() {
|
||||
return board_.teams_[gui().viewing_team()];
|
||||
return board_.teams_[gui().viewing_team()];
|
||||
}
|
||||
|
||||
const team& mouse_handler::viewing_team() const {
|
||||
return board_.teams()[gui().viewing_team()];
|
||||
const team& mouse_handler::viewing_team() const {
|
||||
return board_.teams()[gui().viewing_team()];
|
||||
}
|
||||
|
||||
team & mouse_handler::current_team() {
|
||||
return board_.teams_[side_num_ - 1];
|
||||
team & mouse_handler::current_team() {
|
||||
return board_.teams_[side_num_ - 1];
|
||||
}
|
||||
|
||||
mouse_handler *mouse_handler::singleton_ = NULL;
|
||||
|
|
|
@ -165,7 +165,7 @@ void mouse_handler_base::mouse_press(const SDL_MouseButtonEvent& event, const bo
|
|||
if (event.state == SDL_PRESSED) {
|
||||
set_scroll_start(event.x, event.y);
|
||||
scroll_started_ = true;
|
||||
|
||||
|
||||
map_location loc = gui().minimap_location_on(event.x,event.y);
|
||||
minimap_scrolling_ = false;
|
||||
if(loc.valid()) {
|
||||
|
|
|
@ -107,7 +107,7 @@ public:
|
|||
* Overridden in derived class. Called on drag+drop movements.
|
||||
*/
|
||||
virtual void move_action(bool browse);
|
||||
|
||||
|
||||
/**
|
||||
* Called whenever the left mouse drag has "ended".
|
||||
*/
|
||||
|
@ -200,7 +200,7 @@ protected:
|
|||
|
||||
/** Show context menu flag */
|
||||
bool show_menu_;
|
||||
|
||||
|
||||
/** Relative to middle click scrolling */
|
||||
int scroll_start_x_;
|
||||
int scroll_start_y_;
|
||||
|
|
|
@ -418,7 +418,7 @@ bool manager::is_modification_active(int index) const
|
|||
std::string id = depinfo_.child("modification", index)["id"];
|
||||
return std::find(mods_.begin(), mods_.end(), id) != mods_.end();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool manager::enable_mods_dialog(const std::vector<std::string>& mods,
|
||||
|
|
|
@ -434,7 +434,7 @@ void connect_engine::start_game(LOAD_USERS load_users)
|
|||
{
|
||||
int j_side = playable_sides[rand() % i];
|
||||
int i_side = playable_sides[i - 1];
|
||||
|
||||
|
||||
if (i_side == j_side) continue; //nothing to swap
|
||||
|
||||
// First we swap everything about a side with another
|
||||
|
@ -875,7 +875,7 @@ side_engine::side_engine(const config& cfg, connect_engine& parent_engine,
|
|||
|
||||
// Tweak the controllers.
|
||||
if (cfg_["controller"] == "human_ai" ||
|
||||
cfg_["controller"] == "network_ai" ||
|
||||
cfg_["controller"] == "network_ai" ||
|
||||
(cfg_["controller"] == "network" && !allow_player_ && parent_.params_.saved_game)) { //this is a workaround for bug #21797
|
||||
|
||||
cfg_["controller"] = "ai";
|
||||
|
|
|
@ -178,7 +178,7 @@ public:
|
|||
void set_team(int team) { team_ = team; }
|
||||
std::vector<std::string> get_children_to_swap();
|
||||
std::multimap<std::string, config> get_side_children();
|
||||
void set_side_children(std::multimap<std::string, config> children);
|
||||
void set_side_children(std::multimap<std::string, config> children);
|
||||
int color() const { return color_; }
|
||||
void set_color(int color) { color_ = color; }
|
||||
int gold() const { return gold_; }
|
||||
|
|
|
@ -855,7 +855,7 @@ void create_engine::init_all_levels()
|
|||
{
|
||||
if (!data["allow_new_game"].to_bool(true))
|
||||
continue;
|
||||
|
||||
|
||||
if (!data["map_generation"].empty()) {
|
||||
random_map_ptr new_random_map(new random_map(data));
|
||||
random_maps_.push_back(new_random_map);
|
||||
|
|
|
@ -268,7 +268,7 @@ void gamebrowser::draw_row(const size_t index, const SDL_Rect& item_rect, ROW_TY
|
|||
|
||||
xpos += xp_text->w + 2 * h_padding_;
|
||||
}
|
||||
|
||||
|
||||
if(!game.map_data.empty()) {
|
||||
// Draw map size icon
|
||||
const surface map_size_icon(image::get_image(map_size_icon_locator_));
|
||||
|
@ -277,7 +277,7 @@ void gamebrowser::draw_row(const size_t index, const SDL_Rect& item_rect, ROW_TY
|
|||
|
||||
xpos += map_size_icon->w + h_padding_image_to_text_;
|
||||
}
|
||||
|
||||
|
||||
// Draw map size text
|
||||
const surface map_size_text(font::get_rendered_text(game.map_info_size,
|
||||
font::SIZE_NORMAL, font::NORMAL_COLOR));
|
||||
|
@ -887,7 +887,7 @@ lobby::lobby(game_display& disp, const config& cfg, chat& c, config& gamelist) :
|
|||
if (preferences::skip_mp_replay()) {
|
||||
replay_options_.set_selected(1);
|
||||
}
|
||||
|
||||
|
||||
if (preferences::blindfold_replay()) {
|
||||
replay_options_.set_selected(2);
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ protected:
|
|||
else
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
else
|
||||
return &cfg;
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ protected:
|
|||
else
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
else
|
||||
return &cfg;
|
||||
}
|
||||
|
||||
|
|
|
@ -129,8 +129,8 @@ void verify_and_get_global_variable(const vconfig &pcfg)
|
|||
if (unsigned (side - 1) >= resources::teams->size()) {
|
||||
LOG_PERSIST << "Error: [get_global_variable] attribute \"side\" specifies invalid side number." << "\n";
|
||||
valid = false;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
DBG_PERSIST << "end verify_and_get_global_variable with from_global=" << pcfg["from_global"] << " from side " << pcfg["side"] << "\n";
|
||||
|
|
|
@ -86,7 +86,7 @@ static void clear_resources()
|
|||
resources::units = NULL;
|
||||
resources::whiteboard = NULL;
|
||||
|
||||
|
||||
|
||||
resources::classification = NULL;
|
||||
resources::mp_settings = NULL;
|
||||
|
||||
|
@ -150,7 +150,7 @@ play_controller::play_controller(const config& level, game_state& state_of_game,
|
|||
resources::undo_stack = undo_stack_.get();
|
||||
resources::units = &gameboard_.units_;
|
||||
|
||||
|
||||
|
||||
resources::classification = &gamestate_.classification();
|
||||
resources::mp_settings = &gamestate_.mp_settings();
|
||||
|
||||
|
@ -592,11 +592,11 @@ void play_controller::fire_start(bool execute){
|
|||
time(NULL),
|
||||
"game_engine",
|
||||
0,
|
||||
mes,
|
||||
mes,
|
||||
events::chat_handler::MESSAGE_PUBLIC,
|
||||
preferences::message_bell());
|
||||
replay::process_error(mes);
|
||||
}
|
||||
}
|
||||
gamedata_.set_phase(game_data::PLAY);
|
||||
}
|
||||
|
||||
|
@ -626,7 +626,7 @@ possible_end_play_signal play_controller::init_side(bool is_replay){
|
|||
gamedata_.last_selected = map_location::null_location();
|
||||
|
||||
HANDLE_END_PLAY_SIGNAL( maybe_do_init_side(is_replay, only_visual) );
|
||||
|
||||
|
||||
loading_game_ = false;
|
||||
|
||||
return boost::none;
|
||||
|
@ -773,7 +773,7 @@ config play_controller::to_config() const
|
|||
//Write the game events.
|
||||
game_events::write_events(cfg);
|
||||
|
||||
|
||||
|
||||
if(gui_.get() != NULL){
|
||||
cfg["playing_team"] = str_cast(gui_->playing_team());
|
||||
gui_->labels().write(cfg);
|
||||
|
@ -783,9 +783,9 @@ config play_controller::to_config() const
|
|||
//TODO: move id_manager handling to play_controller
|
||||
cfg["next_underlying_unit_id"] = str_cast(n_unit::id_manager::instance().get_save_id());
|
||||
|
||||
|
||||
|
||||
gamedata_.write_snapshot(cfg);
|
||||
|
||||
|
||||
cfg.merge_attributes(gamestate_.classification().to_config());
|
||||
return cfg;
|
||||
}
|
||||
|
@ -801,7 +801,7 @@ void play_controller::finish_side_turn(){
|
|||
|
||||
const std::string turn_num = str_cast(turn());
|
||||
const std::string side_num = str_cast(player_number_);
|
||||
|
||||
|
||||
{ //Block for set_scontext_synced
|
||||
set_scontext_synced sync(1);
|
||||
game_events::fire("side turn end");
|
||||
|
@ -1409,14 +1409,14 @@ void play_controller::check_victory()
|
|||
}
|
||||
// Clear villages for teams that have no leader and
|
||||
// mark side as lost if it should be removed from carryover.
|
||||
if (not_defeated.find(tm.side()) == not_defeated.end())
|
||||
if (not_defeated.find(tm.side()) == not_defeated.end())
|
||||
{
|
||||
tm.clear_villages();
|
||||
// invalidate_all() is overkill and expensive but this code is
|
||||
// run rarely so do it the expensive way.
|
||||
gui_->invalidate_all();
|
||||
|
||||
if (remove_from_carryover_on_defeat_)
|
||||
|
||||
if (remove_from_carryover_on_defeat_)
|
||||
{
|
||||
tm.set_lost();
|
||||
}
|
||||
|
|
|
@ -345,7 +345,7 @@ static LEVEL_RESULT playmp_scenario(const config& game_config,
|
|||
}
|
||||
|
||||
LEVEL_RESULT play_game(game_display& disp, game_state& gamestate,
|
||||
const config& game_config, io_type_t io_type, bool skip_replay,
|
||||
const config& game_config, io_type_t io_type, bool skip_replay,
|
||||
bool network_game, bool blindfold_replay, bool is_unit_test)
|
||||
{
|
||||
const std::string campaign_type_str = lexical_cast_default<std::string> (gamestate.classification().campaign_type);
|
||||
|
@ -505,7 +505,7 @@ LEVEL_RESULT play_game(game_display& disp, game_state& gamestate,
|
|||
|
||||
// On DEFEAT, QUIT, or OBSERVER_END, we're done now
|
||||
//if(res == QUIT || ((res != VICTORY) && gamestate.carryover_sides_start["next_scenario"].empty()))
|
||||
|
||||
|
||||
//If there is no next scenario we're done now.
|
||||
if(res == QUIT || !end_level.proceed_to_next_level || gamestate.carryover_sides_start["next_scenario"].empty())
|
||||
{
|
||||
|
|
|
@ -51,8 +51,8 @@ playmp_controller::playmp_controller(const config& level,
|
|||
if ( replay_last_turn_ <= 1)
|
||||
{
|
||||
skip_replay_ = false;
|
||||
}
|
||||
if (blindfold_replay_) {
|
||||
}
|
||||
if (blindfold_replay_) {
|
||||
LOG_NG << "Putting on the blindfold now " << std::endl;
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ playmp_controller::~playmp_controller() {
|
|||
if(beep_warning_time_ < 0) {
|
||||
sound::stop_bell();
|
||||
}
|
||||
|
||||
|
||||
turn_data_.host_transfer().detach_handler(this);
|
||||
} catch (...) {}
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ possible_end_play_signal playmp_controller::play_human_turn(){
|
|||
|
||||
HANDLE_END_PLAY_SIGNAL( play_slice() );
|
||||
HANDLE_END_PLAY_SIGNAL( check_end_level() );
|
||||
|
||||
|
||||
if (!linger_ && (current_team().countdown_time() > 0) && gamestate_.mp_settings().mp_countdown) {
|
||||
SDL_Delay(1);
|
||||
const int ticks = SDL_GetTicks();
|
||||
|
@ -247,7 +247,7 @@ possible_end_play_signal playmp_controller::play_human_turn(){
|
|||
// Current solution end remaining turns automatically
|
||||
current_team().set_countdown_time(10);
|
||||
}
|
||||
|
||||
|
||||
return possible_end_play_signal(end_turn_exception().to_struct());
|
||||
//throw end_turn_exception();
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ possible_end_play_signal playmp_controller::play_idle_loop()
|
|||
if(network_reader_.read(cfg)) {
|
||||
turn_info::PROCESS_DATA_RESULT res;
|
||||
HANDLE_END_PLAY_SIGNAL( res = turn_data_.process_network_data(cfg, skip_replay_) );
|
||||
|
||||
|
||||
if (res == turn_info::PROCESS_RESTART_TURN || res == turn_info::PROCESS_RESTART_TURN_TEMPORARY_LOCAL)
|
||||
{
|
||||
end_turn_struct ets = {static_cast<unsigned>(gui_->playing_side())};
|
||||
|
@ -433,7 +433,7 @@ void playmp_controller::after_human_turn(){
|
|||
void playmp_controller::finish_side_turn(){
|
||||
play_controller::finish_side_turn();
|
||||
|
||||
|
||||
|
||||
//halt and cancel the countdown timer
|
||||
reset_countdown();
|
||||
|
||||
|
@ -444,7 +444,7 @@ possible_end_play_signal playmp_controller::play_network_turn(){
|
|||
|
||||
end_turn_enable(false);
|
||||
turn_data_.send_data();
|
||||
|
||||
|
||||
for(;;) {
|
||||
|
||||
if (!network_processing_stopped_){
|
||||
|
@ -543,7 +543,7 @@ void playmp_controller::handle_generic_event(const std::string& name){
|
|||
{
|
||||
expected_controller_changes++;
|
||||
}
|
||||
//If we still expect controler changes we cannot return.
|
||||
//If we still expect controler changes we cannot return.
|
||||
//Becasue we might get into the situation that we want to do a decision that has already been name on another client.
|
||||
//FIXME: if the server failed to process a transfer_side this is an infinite loop.
|
||||
//as a temporary fix we abort the loop if it runs too long.
|
||||
|
@ -563,7 +563,7 @@ void playmp_controller::handle_generic_event(const std::string& name){
|
|||
expected_controller_changes++;
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
}
|
||||
turn_data_.send_data();
|
||||
}
|
||||
else if (name == "host_transfer"){
|
||||
|
@ -584,7 +584,7 @@ bool playmp_controller::can_execute_command(const hotkey::hotkey_command& cmd, i
|
|||
switch (command){
|
||||
case hotkey::HOTKEY_ENDTURN:
|
||||
if (linger_)
|
||||
{
|
||||
{
|
||||
bool has_next_scenario = !resources::gamedata->next_scenario().empty() &&
|
||||
resources::gamedata->next_scenario() != "null";
|
||||
return is_host() || !has_next_scenario;
|
||||
|
@ -616,12 +616,12 @@ bool playmp_controller::can_execute_command(const hotkey::hotkey_command& cmd, i
|
|||
|
||||
void playmp_controller::do_idle_notification()
|
||||
{
|
||||
resources::screen->add_chat_message(time(NULL), "", 0,
|
||||
resources::screen->add_chat_message(time(NULL), "", 0,
|
||||
_("This side is in an idle state. To proceed with the game, it must be assigned to another controller. You may use :droid, :control or :give_control for example."),
|
||||
events::chat_handler::MESSAGE_PUBLIC, false);
|
||||
events::chat_handler::MESSAGE_PUBLIC, false);
|
||||
}
|
||||
|
||||
void playmp_controller::maybe_linger()
|
||||
void playmp_controller::maybe_linger()
|
||||
{
|
||||
if (!get_end_level_data_const().transient.linger_mode) {
|
||||
if(!is_host()) {
|
||||
|
|
|
@ -56,7 +56,7 @@ protected:
|
|||
virtual possible_end_play_signal play_network_turn();
|
||||
virtual void do_idle_notification();
|
||||
virtual possible_end_play_signal play_idle_loop();
|
||||
|
||||
|
||||
void linger();
|
||||
/** Wait for the host to upload the next scenario. */
|
||||
void wait_for_upload();
|
||||
|
|
|
@ -70,7 +70,7 @@ playsingle_controller::playsingle_controller(const config& level,
|
|||
textbox_info_(),
|
||||
replay_sender_(recorder),
|
||||
network_reader_(),
|
||||
turn_data_(replay_sender_, network_reader_),
|
||||
turn_data_(replay_sender_, network_reader_),
|
||||
end_turn_(false),
|
||||
player_type_changed_(false),
|
||||
replaying_(false),
|
||||
|
@ -164,7 +164,7 @@ void playsingle_controller::check_end_level()
|
|||
}
|
||||
return;
|
||||
}
|
||||
get_end_level_data().proceed_to_next_level = (level_result_ == VICTORY);
|
||||
get_end_level_data().proceed_to_next_level = (level_result_ == VICTORY);
|
||||
throw end_level_exception(level_result_);
|
||||
}
|
||||
|
||||
|
@ -346,7 +346,7 @@ possible_end_play_signal playsingle_controller::play_scenario_init(end_level_dat
|
|||
gamestate_.replay_start() = to_config();
|
||||
}
|
||||
HANDLE_END_PLAY_SIGNAL( fire_preload() );
|
||||
|
||||
|
||||
replaying_ = (recorder.at_end() == false);
|
||||
|
||||
if(!loading_game_ )
|
||||
|
@ -354,7 +354,7 @@ possible_end_play_signal playsingle_controller::play_scenario_init(end_level_dat
|
|||
if(replaying_)
|
||||
{
|
||||
//can this codepath be reached ?
|
||||
//note this when we are entering an mp game and see the 'replay' of the game
|
||||
//note this when we are entering an mp game and see the 'replay' of the game
|
||||
//this path is not reached because we receive the replay later
|
||||
config* pstart = recorder.get_next_action();
|
||||
assert(pstart->has_child("start"));
|
||||
|
@ -367,7 +367,7 @@ possible_end_play_signal playsingle_controller::play_scenario_init(end_level_dat
|
|||
}
|
||||
//we can only use a set_scontext_synced with a non empty recorder.
|
||||
set_scontext_synced sync;
|
||||
|
||||
|
||||
HANDLE_END_PLAY_SIGNAL( fire_prestart() );
|
||||
init_gui();
|
||||
past_prestart = true;
|
||||
|
@ -482,7 +482,7 @@ LEVEL_RESULT playsingle_controller::play_scenario(
|
|||
);
|
||||
update_rect(0, 0, gui_->video().getx(), gui_->video().gety());
|
||||
}
|
||||
|
||||
|
||||
ai_testing::log_game_end();
|
||||
LEVEL_RESULT end_level_result = boost::apply_visitor( get_result(), *signal );
|
||||
if (!end_level.transient.custom_endlevel_music.empty()) {
|
||||
|
@ -492,12 +492,12 @@ LEVEL_RESULT playsingle_controller::play_scenario(
|
|||
set_victory_music_list(end_level.transient.custom_endlevel_music);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (gameboard_.teams_.empty())
|
||||
{
|
||||
//store persistent teams
|
||||
gamestate_.snapshot = config();
|
||||
|
||||
|
||||
return VICTORY; // this is probably only a story scenario, i.e. has its endlevel in the prestart event
|
||||
}
|
||||
const bool obs = is_observer();
|
||||
|
@ -522,7 +522,7 @@ LEVEL_RESULT playsingle_controller::play_scenario(
|
|||
return OBSERVER_END;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (end_level_result == QUIT) {
|
||||
return QUIT;
|
||||
}
|
||||
|
@ -530,12 +530,12 @@ LEVEL_RESULT playsingle_controller::play_scenario(
|
|||
{
|
||||
gamestate_.classification().completion = "defeat";
|
||||
game_events::fire("defeat");
|
||||
|
||||
|
||||
if (!obs) {
|
||||
const std::string& defeat_music = select_defeat_music();
|
||||
if(defeat_music.empty() != true)
|
||||
sound::play_music_once(defeat_music);
|
||||
|
||||
|
||||
persist_.end_transaction();
|
||||
return DEFEAT;
|
||||
} else {
|
||||
|
@ -547,7 +547,7 @@ LEVEL_RESULT playsingle_controller::play_scenario(
|
|||
gamestate_.classification().completion =
|
||||
!end_level.transient.linger_mode ? "running" : "victory";
|
||||
game_events::fire("victory");
|
||||
|
||||
|
||||
//
|
||||
// Play victory music once all victory events
|
||||
// are finished, if we aren't observers.
|
||||
|
@ -562,7 +562,7 @@ LEVEL_RESULT playsingle_controller::play_scenario(
|
|||
if(victory_music.empty() != true)
|
||||
sound::play_music_once(victory_music);
|
||||
}
|
||||
|
||||
|
||||
// Add all the units that survived the scenario.
|
||||
LOG_NG << "Add units that survived the scenario to the recall list.\n";
|
||||
gameboard_.all_survivors_to_recall();
|
||||
|
@ -571,7 +571,7 @@ LEVEL_RESULT playsingle_controller::play_scenario(
|
|||
if(!is_observer()) {
|
||||
persist_.end_transaction();
|
||||
}
|
||||
|
||||
|
||||
return VICTORY;
|
||||
}
|
||||
else if (end_level_result == SKIP_TO_LINGER)
|
||||
|
@ -584,7 +584,7 @@ LEVEL_RESULT playsingle_controller::play_scenario(
|
|||
}
|
||||
return VICTORY;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
//END CASES
|
||||
} // END SWITCH
|
||||
|
@ -723,7 +723,7 @@ possible_end_play_signal playsingle_controller::play_side()
|
|||
if (side_units(player_number_) != 0
|
||||
|| (resources::units->size() == 0 && player_number_ == 1))
|
||||
{
|
||||
possible_end_play_signal signal = before_human_turn();
|
||||
possible_end_play_signal signal = before_human_turn();
|
||||
|
||||
if (!signal) {
|
||||
signal = play_human_turn();
|
||||
|
@ -784,7 +784,7 @@ possible_end_play_signal playsingle_controller::play_side()
|
|||
|
||||
if (!signal) {
|
||||
signal = play_idle_loop();
|
||||
}
|
||||
}
|
||||
|
||||
if (signal) {
|
||||
switch (boost::apply_visitor(get_signal_type(), *signal)) {
|
||||
|
@ -967,7 +967,7 @@ void playsingle_controller::play_ai_turn(){
|
|||
|
||||
turn_data_.send_data();
|
||||
turn_info_sync sync_safe(turn_data_);
|
||||
|
||||
|
||||
try {
|
||||
ai::manager::play_turn(player_number_);
|
||||
} catch (end_turn_exception&) {
|
||||
|
@ -986,7 +986,7 @@ void playsingle_controller::play_ai_turn(){
|
|||
*/
|
||||
void playsingle_controller::do_idle_notification()
|
||||
{
|
||||
resources::screen->add_chat_message(time(NULL), "Wesnoth", 0,
|
||||
resources::screen->add_chat_message(time(NULL), "Wesnoth", 0,
|
||||
"This side is in an idle state. To proceed with the game, the host must assign it to another controller.",
|
||||
events::chat_handler::MESSAGE_PUBLIC, false);
|
||||
}
|
||||
|
@ -1030,7 +1030,7 @@ possible_end_play_signal playsingle_controller::check_time_over(){
|
|||
}
|
||||
|
||||
HANDLE_END_PLAY_SIGNAL( check_victory() );
|
||||
|
||||
|
||||
get_end_level_data().proceed_to_next_level = false;
|
||||
|
||||
end_level_struct els = {DEFEAT};
|
||||
|
@ -1118,12 +1118,12 @@ bool playsingle_controller::can_execute_command(const hotkey::hotkey_command& cm
|
|||
return res;
|
||||
}
|
||||
|
||||
bool playsingle_controller::is_host() const
|
||||
bool playsingle_controller::is_host() const
|
||||
{
|
||||
return turn_data_.is_host();
|
||||
}
|
||||
|
||||
void playsingle_controller::maybe_linger()
|
||||
void playsingle_controller::maybe_linger()
|
||||
{
|
||||
if (get_end_level_data_const().transient.linger_mode) {
|
||||
linger();
|
||||
|
|
|
@ -118,8 +118,8 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data_from_reader(bool
|
|||
|
||||
turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg, bool skip_replay)
|
||||
{
|
||||
// we cannot be connected to multiple peers anymore because
|
||||
// the simple wesnothserver implementation in wesnoth was removed years ago.
|
||||
// we cannot be connected to multiple peers anymore because
|
||||
// the simple wesnothserver implementation in wesnoth was removed years ago.
|
||||
assert(network::nconnections() <= 1);
|
||||
assert(cfg.all_children_count() == 1);
|
||||
assert(cfg.attribute_range().first == cfg.attribute_range().second);
|
||||
|
@ -183,7 +183,7 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg
|
|||
} catch (bad_enum_cast & e) {
|
||||
ERR_NW << "Bad [change_controller] message from server:\n" << e.what() << std::endl << change.debug() << std::endl;
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
bool was_local = tm.is_local();
|
||||
const team::CONTROLLER old_controller = tm.controller();
|
||||
|
@ -215,7 +215,7 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg
|
|||
ERR_NW << "Bad [change_controller] signal from server, side out of bounds: " << change.debug() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
else if (const config &side_drop_c = cfg.child("side_drop"))
|
||||
{
|
||||
const std::string& side_drop = side_drop_c["side_num"].str();
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
|
||||
|
||||
|
||||
enum PROCESS_DATA_RESULT
|
||||
enum PROCESS_DATA_RESULT
|
||||
{
|
||||
PROCESS_CONTINUE,
|
||||
PROCESS_RESTART_TURN,
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
|
||||
//function which will process incoming network data received with playturn_network_adapter, and act on it.
|
||||
PROCESS_DATA_RESULT process_network_data(const config& cfg, bool skip_replay);
|
||||
|
||||
|
||||
//reads as much data from network_reader_ as possible and processed it.
|
||||
PROCESS_DATA_RESULT process_network_data_from_reader(bool skip_replay);
|
||||
|
||||
|
@ -85,8 +85,8 @@ private:
|
|||
};
|
||||
|
||||
/**
|
||||
class that sends data on destruction
|
||||
to make sure data is sended in any case.
|
||||
class that sends data on destruction
|
||||
to make sure data is sended in any case.
|
||||
*/
|
||||
class turn_info_send
|
||||
{
|
||||
|
@ -105,8 +105,8 @@ private:
|
|||
};
|
||||
|
||||
/**
|
||||
class that syncs data on destruction
|
||||
to make sure data is synced in any case.
|
||||
class that syncs data on destruction
|
||||
to make sure data is synced in any case.
|
||||
*/
|
||||
class turn_info_sync
|
||||
{
|
||||
|
|
|
@ -16,11 +16,11 @@ static lg::log_domain log_network("network");
|
|||
void playturn_network_adapter::read_from_network()
|
||||
{
|
||||
assert(!data_.empty());
|
||||
|
||||
|
||||
this->data_.push_back(config());
|
||||
config& back = data_.back();
|
||||
bool has_data = false;
|
||||
try
|
||||
try
|
||||
{
|
||||
has_data = this->network_reader_(back);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ void playturn_network_adapter::read_from_network()
|
|||
return;
|
||||
}
|
||||
assert(!data_.back().empty());
|
||||
|
||||
|
||||
if(back.has_attribute("side_drop"))
|
||||
{
|
||||
config child;
|
||||
|
@ -97,7 +97,7 @@ bool playturn_network_adapter::read(config& dst)
|
|||
config& childchild_old = const_cast<config&>(itor->cfg);
|
||||
config& childchild = child.add_child(itor->key);
|
||||
childchild.swap(childchild_old);
|
||||
|
||||
|
||||
++next_command_num_;
|
||||
if(next_->cfg.all_children_count() == next_command_num_)
|
||||
{
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
class playturn_network_adapter
|
||||
{
|
||||
public:
|
||||
typedef boost::function1<bool, config&> source_type;
|
||||
|
||||
typedef boost::function1<bool, config&> source_type;
|
||||
|
||||
playturn_network_adapter(source_type source = read_network);
|
||||
~playturn_network_adapter();
|
||||
|
||||
|
@ -37,7 +37,7 @@ private:
|
|||
std::list<config> data_;
|
||||
//the position of the next to be received element in data_->front().
|
||||
config::all_children_iterator next_;
|
||||
//if we are processing a [turn] with mutiple [command] we want to split them.
|
||||
//if we are processing a [turn] with mutiple [command] we want to split them.
|
||||
//In this case next_command_num_ is the next to be processed turn into a command otherwise it's 0;
|
||||
unsigned int next_command_num_;
|
||||
//a function to receive data from the network.
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace random_new
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
unsigned int rng::get_random_calls()
|
||||
{
|
||||
return random_calls_;
|
||||
|
@ -53,7 +53,7 @@ namespace random_new
|
|||
{
|
||||
//getting here means random was called form outsiude a synced context.
|
||||
int retv = rand();
|
||||
|
||||
|
||||
LOG_RND << "random_new::rng::next_random returned " << retv;
|
||||
return retv;
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@ namespace random_new
|
|||
|
||||
// this generator is autmatilcy synced during synced context.
|
||||
// calling this should automaticly clear the undo stack.
|
||||
//
|
||||
//
|
||||
extern rng* generator;
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -15,13 +15,13 @@
|
|||
|
||||
namespace random_new
|
||||
{
|
||||
|
||||
|
||||
rng_deterministic::rng_deterministic(rand_rng::simple_rng& gen)
|
||||
: generator_(gen)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
rng_deterministic::~rng_deterministic()
|
||||
{
|
||||
|
||||
|
|
|
@ -33,11 +33,11 @@ namespace random_new
|
|||
}
|
||||
//getting here means random was called form inside a synced context.
|
||||
int retv = gen_.get_next_random();
|
||||
|
||||
|
||||
LOG_RND << "random_new::rng::next_random_impl returned " << retv;
|
||||
return retv;
|
||||
}
|
||||
|
||||
|
||||
void synced_rng::initialize()
|
||||
{
|
||||
int new_seed = seed_generator_();
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace random_new
|
|||
private:
|
||||
void initialize();
|
||||
bool has_valid_seed_;
|
||||
boost::function0<int> seed_generator_;
|
||||
boost::function0<int> seed_generator_;
|
||||
//TODO: replayce this by boost::random::mt19937 or similar
|
||||
rand_rng::simple_rng gen_;
|
||||
};
|
||||
|
|
|
@ -401,7 +401,7 @@ const std::vector<chat_msg>& replay::build_chat_log()
|
|||
for (loc_it = message_locations.begin(); loc_it != message_locations.end(); ++loc_it)
|
||||
{
|
||||
last_location = *loc_it;
|
||||
|
||||
|
||||
const config &speak = command(last_location).child("speak");
|
||||
assert(speak);
|
||||
add_chat_log_entry(speak, chat_log_appender);
|
||||
|
@ -443,7 +443,7 @@ void replay::redo(const config& cfg)
|
|||
/*config &cfg = */cfg_.add_child("command", cmd);
|
||||
}
|
||||
pos_ = ncommands();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -520,8 +520,8 @@ void replay::undo_cut(config& dst)
|
|||
remove_command(cmd_2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
config &c = command(cmd);
|
||||
|
||||
if (const config &child = c.child("move"))
|
||||
|
@ -622,7 +622,7 @@ config* replay::get_next_action()
|
|||
return NULL;
|
||||
|
||||
LOG_REPLAY << "up to replay action " << pos_ + 1 << '/' << ncommands() << '\n';
|
||||
|
||||
|
||||
config* retv = &command(pos_);
|
||||
++pos_;
|
||||
return retv;
|
||||
|
@ -728,14 +728,14 @@ REPLAY_RETURN do_replay()
|
|||
|
||||
REPLAY_RETURN do_replay_handle()
|
||||
{
|
||||
|
||||
|
||||
//team ¤t_team = (*resources::teams)[side_num - 1];
|
||||
|
||||
const int side_num = resources::controller->current_side();
|
||||
for(;;) {
|
||||
const config *cfg = get_replay_source().get_next_action();
|
||||
const bool is_synced = (synced_context::get_synced_state() == synced_context::SYNCED);
|
||||
|
||||
|
||||
DBG_REPLAY << "in do replay with is_synced=" << is_synced << "\n";
|
||||
|
||||
if (cfg != NULL)
|
||||
|
@ -813,7 +813,7 @@ REPLAY_RETURN do_replay_handle()
|
|||
|
||||
else if (cfg->child("init_side"))
|
||||
{
|
||||
|
||||
|
||||
if(is_synced)
|
||||
{
|
||||
replay::process_error("found init_side in replay while is_synced=true\n" );
|
||||
|
@ -880,7 +880,7 @@ REPLAY_RETURN do_replay_handle()
|
|||
}
|
||||
//this means user choice.
|
||||
// it never makes sense to try to execute a user choice.
|
||||
// but we are called from
|
||||
// but we are called from
|
||||
// the only other option for "dependent" command is checksum wich is already checked.
|
||||
assert(cfg->all_children_count() == 1);
|
||||
std::string child_name = cfg->all_children_range().first->key;
|
||||
|
@ -893,7 +893,7 @@ REPLAY_RETURN do_replay_handle()
|
|||
//we checked for empty commands at the beginning.
|
||||
const std::string & commandname = cfg->ordered_begin()->key;
|
||||
config data = cfg->ordered_begin()->cfg;
|
||||
|
||||
|
||||
if(is_synced)
|
||||
{
|
||||
replay::process_error("found " + commandname + " command in replay while is_synced=true\n" );
|
||||
|
@ -945,10 +945,10 @@ void replay_network_sender::commit_and_sync()
|
|||
{
|
||||
if(network::nconnections() > 0) {
|
||||
resources::whiteboard->send_network_data();
|
||||
|
||||
|
||||
config cfg;
|
||||
const config& data = cfg.add_child("turn",obj_.get_data_range(upto_,obj_.ncommands()));
|
||||
|
||||
|
||||
if(data.empty() == false) {
|
||||
network::send_data(cfg, 0);
|
||||
}
|
||||
|
@ -961,7 +961,7 @@ void replay_network_sender::commit_and_sync()
|
|||
static std::map<int, config> get_user_choice_internal(const std::string &name, const mp_sync::user_choice &uch, const std::set<int>& sides)
|
||||
{
|
||||
const int max_side = static_cast<int>(resources::teams->size());
|
||||
|
||||
|
||||
BOOST_FOREACH(int side, sides)
|
||||
{
|
||||
//the caller has to ensure this.
|
||||
|
@ -973,7 +973,7 @@ static std::map<int, config> get_user_choice_internal(const std::string &name, c
|
|||
//this should never change during the execution of this function.
|
||||
const int current_side = resources::controller->current_side();
|
||||
const bool is_mp_game = network::nconnections() != 0;
|
||||
|
||||
|
||||
std::map<int,config> retv;
|
||||
/*
|
||||
when we got all our answers we stop.
|
||||
|
@ -1008,7 +1008,7 @@ static std::map<int, config> get_user_choice_internal(const std::string &name, c
|
|||
|
||||
bool has_local_side = local_side != 0;
|
||||
bool is_replay_end = get_replay_source().at_end();
|
||||
|
||||
|
||||
if (is_replay_end && has_local_side)
|
||||
{
|
||||
set_scontext_local_choice sync;
|
||||
|
@ -1016,7 +1016,7 @@ static std::map<int, config> get_user_choice_internal(const std::string &name, c
|
|||
into the replay. */
|
||||
DBG_REPLAY << "MP synchronization: local choice\n";
|
||||
config cfg = uch.query_user(local_side);
|
||||
|
||||
|
||||
recorder.user_input(name, cfg, local_side);
|
||||
retv[local_side]= cfg;
|
||||
|
||||
|
@ -1033,7 +1033,7 @@ static std::map<int, config> get_user_choice_internal(const std::string &name, c
|
|||
{
|
||||
//we are in a mp game, and the data has not been recieved yet.
|
||||
DBG_REPLAY << "MP synchronization: waiting for remote choice\n";
|
||||
|
||||
|
||||
assert(is_mp_game);
|
||||
synced_context::pull_remote_user_input();
|
||||
|
||||
|
@ -1043,14 +1043,14 @@ static std::map<int, config> get_user_choice_internal(const std::string &name, c
|
|||
else if(!is_replay_end)
|
||||
{
|
||||
DBG_REPLAY << "MP synchronization: extracting choice from replay with has_local_side=" << has_local_side << "\n";
|
||||
|
||||
|
||||
const config *action = get_replay_source().get_next_action();
|
||||
if (!action)
|
||||
if (!action)
|
||||
{
|
||||
replay::process_error("[" + name + "] expected but none found\n");
|
||||
//this is weird, because it means that there is data on the replay but get_next_action returned an invalid config which should be impossible.
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
else if( !action->has_child(name))
|
||||
{
|
||||
replay::process_error("[" + name + "] expected but none found\n. found instead:\n" + action->debug());
|
||||
|
@ -1090,7 +1090,7 @@ static std::map<int, config> get_user_choice_internal(const std::string &name, c
|
|||
|
||||
std::map<int,config> mp_sync::get_user_choice_multiple_sides(const std::string &name, const mp_sync::user_choice &uch,
|
||||
std::set<int> sides)
|
||||
{
|
||||
{
|
||||
//pass sides by copy because we need a copy.
|
||||
const bool is_synced = synced_context::get_synced_state() == synced_context::SYNCED;
|
||||
const int max_side = static_cast<int>(resources::teams->size());
|
||||
|
@ -1122,7 +1122,7 @@ std::map<int,config> mp_sync::get_user_choice_multiple_sides(const std::string &
|
|||
}
|
||||
|
||||
std::map<int,config> retv = get_user_choice_internal(name, uch, sides);
|
||||
|
||||
|
||||
BOOST_FOREACH(int side, empty_sides)
|
||||
{
|
||||
retv[side] = uch.random_choice(side);
|
||||
|
@ -1143,13 +1143,13 @@ config mp_sync::get_user_choice(const std::string &name, const mp_sync::user_cho
|
|||
const int max_side = static_cast<int>(resources::teams->size());
|
||||
const int current_side = resources::controller->current_side();
|
||||
bool is_side_null_controlled;
|
||||
|
||||
|
||||
if(!is_synced)
|
||||
{
|
||||
//we got called from inside luas wesnoth.synchronize_choice or from a select event (or maybe a preload event?).
|
||||
//This doesn't cause problems and someone could use it for example to use a [message][option] inside a wesnoth.synchronize_choice which could be useful,
|
||||
//This doesn't cause problems and someone could use it for example to use a [message][option] inside a wesnoth.synchronize_choice which could be useful,
|
||||
//so just give a warning.
|
||||
WRN_REPLAY << "MP synchronization called during an unsynced context.";;
|
||||
WRN_REPLAY << "MP synchronization called during an unsynced context.";;
|
||||
return uch.query_user(side);
|
||||
}
|
||||
if(is_too_early && uch.is_visible())
|
||||
|
@ -1160,11 +1160,11 @@ config mp_sync::get_user_choice(const std::string &name, const mp_sync::user_cho
|
|||
//Quotation form event wiki: "For things displayed on-screen such as character dialog, use start instead"
|
||||
return uch.random_choice(side);
|
||||
}
|
||||
//in start events it's unclear to decide on which side the function should be executed (default= side1 still).
|
||||
//in start events it's unclear to decide on which side the function should be executed (default= side1 still).
|
||||
//But for advancements we can just decide on the side that owns the unit and that's in the responsibility of advance_unit_at.
|
||||
//For [message][option] and luas sync_choice the scenario designer is responsible for that.
|
||||
//For [get_global_variable] side is never null.
|
||||
|
||||
|
||||
/*
|
||||
side = 0 should default to the currently active side per definition.
|
||||
*/
|
||||
|
@ -1178,7 +1178,7 @@ config mp_sync::get_user_choice(const std::string &name, const mp_sync::user_cho
|
|||
LOG_REPLAY << " side changed to " << side << "\n";
|
||||
}
|
||||
is_side_null_controlled = (*resources::teams)[side-1].is_empty();
|
||||
|
||||
|
||||
LOG_REPLAY << "get_user_choice_called with"
|
||||
<< " name=" << name
|
||||
<< " is_synced=" << is_synced
|
||||
|
@ -1188,9 +1188,9 @@ config mp_sync::get_user_choice(const std::string &name, const mp_sync::user_cho
|
|||
if (is_side_null_controlled)
|
||||
{
|
||||
DBG_REPLAY << "MP synchronization: side 1 being null-controlled in get_user_choice.\n";
|
||||
//most likely we are in a start event with an empty side 1
|
||||
//most likely we are in a start event with an empty side 1
|
||||
//but calling [set_global_variable] to an empty side might also cause this.
|
||||
//i think in that case we should better use uch.random_choice(),
|
||||
//i think in that case we should better use uch.random_choice(),
|
||||
//which could return something like config_of("invalid", true);
|
||||
side = 1;
|
||||
while ( side <= max_side && (*resources::teams)[side-1].is_empty() )
|
||||
|
@ -1200,7 +1200,7 @@ config mp_sync::get_user_choice(const std::string &name, const mp_sync::user_cho
|
|||
|
||||
|
||||
assert(1 <= side && side <= max_side);
|
||||
|
||||
|
||||
if(current_side != side)
|
||||
{
|
||||
//if side != current_side we send the data over the network, that means undoing is impossible
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
void init_side();
|
||||
/*
|
||||
returns a reference to the newest config that us not dependent or has undo =no
|
||||
|
||||
|
||||
*/
|
||||
config& get_last_real_command();
|
||||
/**
|
||||
|
@ -99,7 +99,7 @@ public:
|
|||
config get_data_range(int cmd_start, int cmd_end, DATA_TYPE data_type=ALL_DATA);
|
||||
config get_last_turn(int num_turns=1);
|
||||
const config& get_replay_data() const { return cfg_; }
|
||||
|
||||
|
||||
void undo();
|
||||
/*
|
||||
undoes the last move and puts it into given config to be reone with redo
|
||||
|
@ -143,7 +143,7 @@ private:
|
|||
* @return a reference to the added command
|
||||
*/
|
||||
config& add_command();
|
||||
/**
|
||||
/**
|
||||
* adds a new command to the command list at the current position.
|
||||
*
|
||||
* @return a reference to the added command
|
||||
|
@ -161,7 +161,7 @@ replay& get_replay_source();
|
|||
|
||||
extern replay recorder;
|
||||
|
||||
enum REPLAY_RETURN
|
||||
enum REPLAY_RETURN
|
||||
{
|
||||
REPLAY_RETURN_AT_END,
|
||||
REPLAY_FOUND_DEPENDENT,
|
||||
|
@ -210,7 +210,7 @@ struct user_choice
|
|||
* client is responsible for making the choice.
|
||||
* otherwise this function waits for a remote choice and returns it when it is received.
|
||||
* information about the choice made is saved in replay with dependent=true
|
||||
*
|
||||
*
|
||||
* @param name Tag used for storing the choice into the replay.
|
||||
* @param side The number of the side responsible for making the choice.
|
||||
* If zero, it defaults to the currently active side.
|
||||
|
|
|
@ -349,7 +349,7 @@ void replay_controller::reset_replay()
|
|||
because set_scontext_synced sets the checkup to the last added command
|
||||
*/
|
||||
set_scontext_synced sync;
|
||||
|
||||
|
||||
fire_prestart();
|
||||
init_gui();
|
||||
fire_start(true);
|
||||
|
|
|
@ -48,7 +48,7 @@ config replay_helper::get_disband(const std::string& unit_id)
|
|||
config val;
|
||||
|
||||
val["value"] = unit_id;
|
||||
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ config replay_helper::get_disband(const std::string& unit_id)
|
|||
config replay_helper::get_movement(const std::vector<map_location>& steps, bool skip_sighted, bool skip_ally_sighted)
|
||||
{
|
||||
assert(!steps.empty());
|
||||
|
||||
|
||||
config move;
|
||||
if(skip_sighted)
|
||||
{
|
||||
|
@ -72,7 +72,7 @@ config replay_helper::get_movement(const std::vector<map_location>& steps, bool
|
|||
{
|
||||
move["skip_sighted"] = "only_ally";
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
//leave it empty
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
|
||||
static config get_init_side();
|
||||
/*
|
||||
|
||||
|
||||
*/
|
||||
static config get_event(const std::string& name, const map_location& loc, const map_location* last_select_loc);
|
||||
|
||||
|
|
|
@ -379,11 +379,11 @@ void delete_game(const std::string& name)
|
|||
|
||||
|
||||
|
||||
create_save_info::create_save_info(const std::string* d)
|
||||
: dir(d ? *d : get_saves_dir())
|
||||
create_save_info::create_save_info(const std::string* d)
|
||||
: dir(d ? *d : get_saves_dir())
|
||||
{
|
||||
}
|
||||
save_info create_save_info::operator()(const std::string& filename) const
|
||||
save_info create_save_info::operator()(const std::string& filename) const
|
||||
{
|
||||
std::string name = filename;
|
||||
replace_underbar2space(name);
|
||||
|
@ -414,7 +414,7 @@ void extract_summary_from_config(config& cfg_save, config& cfg_summary)
|
|||
} else {
|
||||
cfg_summary["scenario"] = cfg_save["scenario"];
|
||||
}
|
||||
|
||||
|
||||
cfg_summary["difficulty"] = cfg_save["difficulty"];
|
||||
cfg_summary["random_mode"] = cfg_save["random_mode"];
|
||||
|
||||
|
|
|
@ -1184,7 +1184,7 @@ static int impl_side_get(lua_State *L)
|
|||
return_cstring_attrib("controller", team::CONTROLLER_to_string(t.controller()).c_str());
|
||||
return_string_attrib("defeat_condition", team::DEFEAT_CONDITION_to_string(t.defeat_condition()));
|
||||
return_bool_attrib("lost", t.lost());
|
||||
|
||||
|
||||
if (strcmp(m, "recruit") == 0) {
|
||||
std::set<std::string> const &recruits = t.recruits();
|
||||
lua_createtable(L, recruits.size(), 0);
|
||||
|
@ -1542,9 +1542,9 @@ static int impl_game_config_get(lua_State *L)
|
|||
return_bool_attrib("debug", game_config::debug);
|
||||
return_bool_attrib("debug_lua", game_config::debug_lua);
|
||||
return_bool_attrib("mp_debug", game_config::mp_debug);
|
||||
|
||||
const mp_game_settings& mp_settings = *resources::mp_settings;
|
||||
const game_classification & classification = *resources::classification;
|
||||
|
||||
const mp_game_settings& mp_settings = *resources::mp_settings;
|
||||
const game_classification & classification = *resources::classification;
|
||||
|
||||
return_string_attrib("campaign_type", lexical_cast<std::string>(classification.campaign_type));
|
||||
if(classification.campaign_type==game_classification::MULTIPLAYER) {
|
||||
|
@ -1560,7 +1560,7 @@ static int impl_game_config_get(lua_State *L)
|
|||
eras_list = eras_list + "," + (*(its.first))["id"];
|
||||
}
|
||||
return_string_attrib("eras", eras_list);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1591,7 +1591,7 @@ static int impl_game_config_set(lua_State *L)
|
|||
*/
|
||||
static std::string synced_state()
|
||||
{
|
||||
//maybe return "initial" for game_data::INITIAL?
|
||||
//maybe return "initial" for game_data::INITIAL?
|
||||
if(resources::gamedata->phase() == game_data::PRELOAD || resources::gamedata->phase() == game_data::INITIAL)
|
||||
{
|
||||
return "preload";
|
||||
|
@ -2508,8 +2508,8 @@ static void luaW_pushsimweapon(lua_State *L, const battle_context_unit_stats &bc
|
|||
lua_pushnumber(L, bcustats.drain_percent);
|
||||
lua_setfield(L, -2, "drain_percent");
|
||||
|
||||
|
||||
//if we called simulate_combat without giving an explicit weapon this can be useful.
|
||||
|
||||
//if we called simulate_combat without giving an explicit weapon this can be useful.
|
||||
lua_pushnumber(L, bcustats.attack_num);
|
||||
lua_setfield(L, -2, "attack_num");
|
||||
//this is NULL when there is no counter weapon
|
||||
|
@ -2719,7 +2719,7 @@ static int intf_synchronize_choice(lua_State *L)
|
|||
{
|
||||
std::set<int> vals;
|
||||
//read the third parameter
|
||||
lua_pushnil(L);
|
||||
lua_pushnil(L);
|
||||
while (lua_next(L, 3) != 0) {
|
||||
/* uses 'key' (at index -2) and 'value' (at index -1) */
|
||||
int val = luaL_checkint(L, -1);
|
||||
|
|
|
@ -179,7 +179,7 @@ surface stretch_surface_vertical(
|
|||
surface scale_surface(const surface &surf, int w, int h, bool optimize=true);
|
||||
|
||||
/** Scale a surface using modified nearest neighbour algorithm. Use only if
|
||||
* preserving sharp edges is a priority (e.g. minimap).
|
||||
* preserving sharp edges is a priority (e.g. minimap).
|
||||
* @param surf The source surface.
|
||||
* @param w The width of the resulting surface.
|
||||
* @param h The height of the resulting surface.
|
||||
|
|
|
@ -443,10 +443,10 @@ void read_compressed(config &cfg, std::istream &file, abstract_validator * valid
|
|||
// we never create empty compressed gzip files because boosts gzip fails at doing that.
|
||||
// but empty compressed bz2 files are possible.
|
||||
if(filter.peek() == EOF) {
|
||||
LOG_CF << "Empty compressed file or error at reading a compressed file.";
|
||||
LOG_CF << "Empty compressed file or error at reading a compressed file.";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(!filter.good()) {
|
||||
LOG_CF << " filter.peek() != EOF but !filter.good(), this indicates a malformed gz stream, and can make wesnoth crash.";
|
||||
|
@ -461,7 +461,7 @@ void read_gz(config &cfg, std::istream &file, abstract_validator * validator)
|
|||
read_compressed<boost::iostreams::gzip_decompressor>(cfg, file, validator);
|
||||
}
|
||||
|
||||
/// might throw a std::ios_base::failure especially bzip2_error
|
||||
/// might throw a std::ios_base::failure especially bzip2_error
|
||||
void read_bz2(config &cfg, std::istream &file, abstract_validator * validator)
|
||||
{
|
||||
read_compressed<boost::iostreams::bzip2_decompressor>(cfg, file, validator);
|
||||
|
|
|
@ -158,7 +158,7 @@ std::string game::list_users(user_vector users, const std::string& func) const
|
|||
void game::perform_controller_tweaks() {
|
||||
const simple_wml::node::child_list & sides = level_.root().children("side");
|
||||
|
||||
DBG_GAME << "****\n Performing controller tweaks. sides = " << std::endl;
|
||||
DBG_GAME << "****\n Performing controller tweaks. sides = " << std::endl;
|
||||
DBG_GAME << debug_sides_info() << std::endl;
|
||||
DBG_GAME << "****" << std::endl;
|
||||
|
||||
|
@ -170,7 +170,7 @@ void game::perform_controller_tweaks() {
|
|||
nsides_++;
|
||||
if ((**s)["controller"] != "null") {
|
||||
int side_num = (**s)["side"].to_int() - 1;
|
||||
|
||||
|
||||
if (sides_[side_num] == 0) {
|
||||
sides_[side_num] = owner_;
|
||||
std::stringstream msg;
|
||||
|
@ -178,12 +178,12 @@ void game::perform_controller_tweaks() {
|
|||
LOG_GAME << msg.str() << " (game id: " << id_ << ")\n";
|
||||
send_and_record_server_message(msg.str());
|
||||
}
|
||||
|
||||
|
||||
const player_map::const_iterator user = player_info_->find(sides_[side_num]);
|
||||
std::string user_name = "null (server missing user)";
|
||||
if (user == player_info_->end()) {
|
||||
missing_user(user->first, __func__);
|
||||
} else {
|
||||
} else {
|
||||
user_name = username(user);
|
||||
}
|
||||
|
||||
|
@ -207,14 +207,14 @@ void game::perform_controller_tweaks() {
|
|||
|
||||
update_side_data(); // this is the last time that update_side_data will actually run, as now the game will start and started_ will be true.
|
||||
|
||||
//TODO: Does it matter that the server is telling the host to change a bunch of sides?
|
||||
//TODO: Does it matter that the server is telling the host to change a bunch of sides?
|
||||
//According to playturn.cpp, the host should ignore all such messages. Still might be better
|
||||
//not to send them at all, although not if it complicates the server code.
|
||||
}
|
||||
|
||||
void game::start_game(const player_map::const_iterator starter) {
|
||||
const simple_wml::node::child_list & sides = level_.root().children("side");
|
||||
DBG_GAME << "****\n Starting game. sides = " << std::endl;
|
||||
DBG_GAME << "****\n Starting game. sides = " << std::endl;
|
||||
DBG_GAME << debug_sides_info() << std::endl;
|
||||
DBG_GAME << "****" << std::endl;
|
||||
|
||||
|
@ -326,7 +326,7 @@ bool game::take_side(const player_map::const_iterator user)
|
|||
}
|
||||
|
||||
void game::update_side_data() {
|
||||
//added by iceiceice: since level_ will now reflect how an observer
|
||||
//added by iceiceice: since level_ will now reflect how an observer
|
||||
if (started_) return; //views the replay start position and not the current position, the sides_, side_controllers_,
|
||||
//players_ info should not be updated from the level_ after the game has started.
|
||||
//controller changes are now stored in the history, so an observer that joins will get up to
|
||||
|
@ -383,7 +383,7 @@ void game::update_side_data() {
|
|||
} else if ((**side)["controller"] == "network_ai") {
|
||||
side_controllers_[side_num] = "ai"; //on server this field should only contain "ai" for ais. (there are no ais local to server)
|
||||
sides_[side_num] = owner_;
|
||||
side_found = true;
|
||||
side_found = true;
|
||||
} else {
|
||||
// "null"
|
||||
side_controllers_[side_num] = (**side)["controller"].to_string();
|
||||
|
@ -820,7 +820,7 @@ bool game::is_legal_command(const simple_wml::node& command, bool is_player) {
|
|||
if (command.child("speak")) return true;
|
||||
/*
|
||||
assume the following situation: there are 2 sides, its side 1's turn, side 1 has a very slow pc, the following wml is executed:
|
||||
|
||||
|
||||
[get_global_variable]
|
||||
namespace=my_addon
|
||||
from_global=my_variable_name1
|
||||
|
@ -833,10 +833,10 @@ bool game::is_legal_command(const simple_wml::node& command, bool is_player) {
|
|||
to_local=foo2
|
||||
side=2
|
||||
[/get_global_variable]
|
||||
after the first [get_global_variable], both clients run the event simultaniously,
|
||||
after the first [get_global_variable], both clients run the event simultaniously,
|
||||
if player 1's pc is much faster side 2 sends the second [global_variable] before it is required on side 1 and the server doesnt accept it.
|
||||
thats why i deleted the foolowing lines.
|
||||
|
||||
|
||||
if (is_player && command.child("global_variable")) {
|
||||
const simple_wml::node *gvar = (command.child("global_variable"));
|
||||
if ((*gvar)["side"].to_int() == global_wait_side_) {
|
||||
|
@ -846,8 +846,8 @@ bool game::is_legal_command(const simple_wml::node& command, bool is_player) {
|
|||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
if (is_player && command.has_attr("dependent") /*&& command.has_attr("from_side")*/)
|
||||
|
||||
if (is_player && command.has_attr("dependent") /*&& command.has_attr("from_side")*/)
|
||||
//AKA it's generated by get_user_input for example [global_variable]
|
||||
{
|
||||
return true;
|
||||
|
@ -922,7 +922,7 @@ bool game::process_turn(simple_wml::document& data, const player_map::const_iter
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if((**command).has_attr("from_side"))
|
||||
{
|
||||
if((**command)["from_side"] == "server")
|
||||
|
@ -1013,7 +1013,7 @@ bool game::process_turn(simple_wml::document& data, const player_map::const_iter
|
|||
void game::require_random(const simple_wml::document &/*data*/, const player_map::iterator /*user*/)
|
||||
{
|
||||
// note, that during end turn events, it's side=1 for the server but side= side_count() on the clients.
|
||||
|
||||
|
||||
int seed = rand() & 0x7FFFFFFF;
|
||||
simple_wml::document* mdata = new simple_wml::document;
|
||||
simple_wml::node& turn = mdata->root().add_child("turn");
|
||||
|
@ -1267,14 +1267,14 @@ void game::load_next_scenario(const player_map::const_iterator user) {
|
|||
|
||||
const simple_wml::node::child_list & sides = next_scen.children("side");
|
||||
|
||||
DBG_GAME << "****\n loading next scenario for a client. sides info = " << std::endl;
|
||||
DBG_GAME << "****\n loading next scenario for a client. sides info = " << std::endl;
|
||||
DBG_GAME << debug_sides_info() << std::endl;
|
||||
DBG_GAME << "****" << std::endl;
|
||||
|
||||
for(simple_wml::node::child_list::const_iterator s = sides.begin(); s != sides.end(); ++s) {
|
||||
if ((**s)["controller"] != "null") {
|
||||
int side_num = (**s)["side"].to_int() - 1;
|
||||
|
||||
|
||||
if (sides_[side_num] == 0) {
|
||||
sides_[side_num] = owner_;
|
||||
std::stringstream msg;
|
||||
|
@ -1466,7 +1466,7 @@ void game::save_replay() {
|
|||
<< "version=\"" << level_["version"] << "\"\n"
|
||||
<< "[replay]\n"
|
||||
<< "\t[command]\n\t\t[start]\n\t\t[/start]\n\t[/command]\n" //this is required by gfgtdf's sync mechanism, in PR 121
|
||||
<< replay_commands
|
||||
<< replay_commands
|
||||
<< "[/replay]\n"
|
||||
<< "[replay_start]\n" << level_.output() << "[/replay_start]\n";
|
||||
|
||||
|
@ -1575,9 +1575,9 @@ std::string game::debug_sides_info() const {
|
|||
|
||||
result << "\t\t level, server\n";
|
||||
for(simple_wml::node::child_list::const_iterator s = sides.begin(); s != sides.end(); ++s) {
|
||||
result << "side " << (**s)["side"].to_int() << " :\t" << (**s)["controller"].to_string()
|
||||
result << "side " << (**s)["side"].to_int() << " :\t" << (**s)["controller"].to_string()
|
||||
<< "\t, " << side_controllers_[(**s)["side"].to_int() - 1]
|
||||
<< "\t( " << sides_[(**s)["side"].to_int()-1] << ",\t"
|
||||
<< "\t( " << sides_[(**s)["side"].to_int()-1] << ",\t"
|
||||
<< (**s)["current_player"].to_string() << " )\n";
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ public:
|
|||
|
||||
void start_game(const player_map::const_iterator starter);
|
||||
void perform_controller_tweaks(); //this is performed just before starting and before [start_game] signal
|
||||
//send scenario_diff's specific to each client so that they locally
|
||||
//send scenario_diff's specific to each client so that they locally
|
||||
//control their human sides
|
||||
|
||||
void update_game();
|
||||
|
|
|
@ -505,7 +505,7 @@ int un_recall_unit_cost(const unit& u) // this really belongs elsewhere, perhap
|
|||
s.recalls[u.type_id()]--;
|
||||
return u.recall_cost();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void advance_unit(const unit& u)
|
||||
{
|
||||
|
|
|
@ -226,7 +226,7 @@ void part::resolve_wml(const vconfig &cfg)
|
|||
}
|
||||
background_layers_.push_back(bl);
|
||||
|
||||
|
||||
|
||||
if(cfg.has_attribute("show_title")) {
|
||||
show_title_ = cfg["show_title"].to_bool();
|
||||
}
|
||||
|
|
|
@ -328,7 +328,7 @@ public:
|
|||
const std::vector<background_layer>& get_background_layers() const {
|
||||
return background_layers_;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
/** Takes care of initializing and branching properties. */
|
||||
void resolve_wml(const vconfig &cfg);
|
||||
|
|
|
@ -110,11 +110,11 @@ void part_ui::prepare_background()
|
|||
base_rect_.h = video_.gety();
|
||||
has_background_ = false;
|
||||
bool no_base_yet = true;
|
||||
|
||||
|
||||
// Build background surface
|
||||
BOOST_FOREACH(const background_layer& bl, p_.get_background_layers()) {
|
||||
surface layer;
|
||||
|
||||
|
||||
if(bl.file().empty() != true) {
|
||||
layer.assign( image::get_image(bl.file()) );
|
||||
}
|
||||
|
@ -122,9 +122,9 @@ void part_ui::prepare_background()
|
|||
if(layer.null() || layer->w * layer->h == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
layer = make_neutral_surface(layer);
|
||||
|
||||
|
||||
const double xscale = 1.0 * video_.getx() / layer->w;
|
||||
const double yscale = 1.0 * video_.gety() / layer->h;
|
||||
const bool scalev = bl.scale_vertically();
|
||||
|
|
|
@ -42,7 +42,7 @@ void checkup::unit_checksum(const map_location& loc, bool local)
|
|||
bool equals;
|
||||
config real;
|
||||
config expected;
|
||||
|
||||
|
||||
if (!u.valid()) {
|
||||
std::stringstream message;
|
||||
message << "non existent unit to checksum at " << loc.x+1 << "," << loc.y+1 << "!";
|
||||
|
@ -67,7 +67,7 @@ void checkup::unit_checksum(const map_location& loc, bool local)
|
|||
{
|
||||
std::stringstream message;
|
||||
message << "checksum mismatch at " << loc.x+1 << "," << loc.y+1 << "!";
|
||||
resources::screen->add_chat_message(time(NULL), "verification", 1, message.str(),
|
||||
resources::screen->add_chat_message(time(NULL), "verification", 1, message.str(),
|
||||
events::chat_handler::MESSAGE_PRIVATE, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
*/
|
||||
virtual bool local_checkup(const config& expected_data, config& real_data) = 0;
|
||||
/*
|
||||
compares data on all clients in a networked game, the disadvantage is,
|
||||
compares data on all clients in a networked game, the disadvantage is,
|
||||
that the clients have to communicate more which might be not wanted if some persons have laggy inet.
|
||||
returns whether the two config objects are equal.
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(attack, child, /*use_undo*/, show, error_handler
|
|||
}
|
||||
|
||||
DBG_REPLAY << "Attacker XP (before attack): " << u->experience() << "\n";
|
||||
|
||||
|
||||
resources::undo_stack->clear();
|
||||
attack_unit_and_advance(src, dst, weapon_num, def_weapon_num, show);
|
||||
return true;
|
||||
|
@ -217,7 +217,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(attack, child, /*use_undo*/, show, error_handler
|
|||
|
||||
SYNCED_COMMAND_HANDLER_FUNCTION(disband, child, /*use_undo*/, /*show*/, error_handler)
|
||||
{
|
||||
|
||||
|
||||
int current_team_num = resources::controller->current_side();
|
||||
team ¤t_team = (*resources::teams)[current_team_num - 1];
|
||||
|
||||
|
@ -248,7 +248,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(move, child, use_undo, show, error_handler)
|
|||
return false;
|
||||
}
|
||||
|
||||
if(steps.empty())
|
||||
if(steps.empty())
|
||||
{
|
||||
WRN_REPLAY << "Warning: Missing path data found in [move]" << std::endl;
|
||||
return false;
|
||||
|
@ -261,7 +261,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(move, child, use_undo, show, error_handler)
|
|||
WRN_REPLAY << "Warning: Move with identical source and destination. Skipping..." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// The nominal destination should appear to be unoccupied.
|
||||
unit_map::iterator u = resources::gameboard->find_visible_unit(dst, current_team);
|
||||
if ( u.valid() ) {
|
||||
|
@ -296,7 +296,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(move, child, use_undo, show, error_handler)
|
|||
show_move = show_move && preferences::show_ai_moves();
|
||||
}
|
||||
actions::move_unit_from_replay(steps, use_undo ? resources::undo_stack : NULL, skip_sighted, skip_ally_sighted, show_move);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,16 +21,16 @@
|
|||
class synced_command {
|
||||
public:
|
||||
/*
|
||||
the parameters or error handlers are
|
||||
the parameters or error handlers are
|
||||
1) the message of the error
|
||||
2) a boolean that indicates whether the error is heavy enough to make proceeding impossible.
|
||||
TODO: remove the second argument because it isn't used.
|
||||
|
||||
|
||||
*/
|
||||
typedef boost::function2<void, const std::string&, bool> error_handler_function;
|
||||
/*
|
||||
returns: true if the action succeeded correclty,
|
||||
|
||||
returns: true if the action succeeded correclty,
|
||||
|
||||
*/
|
||||
typedef bool (*handler)(const config &, bool use_undo, bool show, error_handler_function error_handler);
|
||||
typedef std::map<std::string, handler> map;
|
||||
|
|
|
@ -61,7 +61,7 @@ bool synced_context::run_in_synced_context(const std::string& commandname, const
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// this might also be a good point to call resources::controller->check_victory();
|
||||
// because before for example if someone kills all units during a moveto event they don't loose.
|
||||
resources::controller->check_victory();
|
||||
|
@ -107,12 +107,12 @@ void synced_context::default_error_function(const std::string& message, bool /*h
|
|||
|
||||
void synced_context::just_log_error_function(const std::string& message, bool /*heavy*/)
|
||||
{
|
||||
ERR_REPLAY << "Error during synced execution: " << message;
|
||||
ERR_REPLAY << "Error during synced execution: " << message;
|
||||
}
|
||||
|
||||
void synced_context::ignore_error_function(const std::string& message, bool /*heavy*/)
|
||||
{
|
||||
DBG_REPLAY << "Ignored during synced execution: " << message;
|
||||
DBG_REPLAY << "Ignored during synced execution: " << message;
|
||||
}
|
||||
|
||||
synced_context::synced_state synced_context::get_synced_state()
|
||||
|
@ -224,18 +224,18 @@ boost::shared_ptr<random_new::rng> synced_context::get_rng_for_action()
|
|||
config synced_context::ask_server(const std::string &name, const mp_sync::user_choice &uch)
|
||||
{
|
||||
assert(get_synced_state() == synced_context::SYNCED);
|
||||
|
||||
|
||||
int current_side = resources::controller->current_side();
|
||||
int side = current_side;
|
||||
bool is_mp_game = network::nconnections() != 0;
|
||||
const int max_side = static_cast<int>(resources::teams->size());
|
||||
bool did_require = false;
|
||||
|
||||
|
||||
|
||||
if ((*resources::teams)[side-1].is_empty())
|
||||
{
|
||||
/*
|
||||
|
||||
|
||||
*/
|
||||
DBG_REPLAY << "MP synchronization: side 1 being null-controlled in get_user_choice.\n";
|
||||
side = 1;
|
||||
|
@ -245,7 +245,7 @@ config synced_context::ask_server(const std::string &name, const mp_sync::user_c
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
assert(1 <= side && side <= max_side);
|
||||
assert(1 <= current_side && current_side <= max_side);
|
||||
|
||||
|
@ -260,7 +260,7 @@ config synced_context::ask_server(const std::string &name, const mp_sync::user_c
|
|||
while(true){
|
||||
|
||||
do_replay_handle();
|
||||
// the current_side on the server is a lie because it can happen on one client we are already executing side 2
|
||||
// the current_side on the server is a lie because it can happen on one client we are already executing side 2
|
||||
bool is_local_side = (*resources::teams)[side-1].is_local();
|
||||
bool is_replay_end = get_replay_source().at_end();
|
||||
|
||||
|
@ -274,7 +274,7 @@ config synced_context::ask_server(const std::string &name, const mp_sync::user_c
|
|||
recorder.user_input(name, cfg, -1);
|
||||
return cfg;
|
||||
|
||||
}
|
||||
}
|
||||
else if(is_replay_end && is_mp_game)
|
||||
{
|
||||
DBG_REPLAY << "MP synchronization: remote server choice\n";
|
||||
|
@ -296,7 +296,7 @@ config synced_context::ask_server(const std::string &name, const mp_sync::user_c
|
|||
{
|
||||
if(resources::gamedata->phase() != game_data::PLAY && resources::gamedata->phase() != game_data::START)
|
||||
{
|
||||
//this is needed becasue sometimes a package gets stuck on the server
|
||||
//this is needed becasue sometimes a package gets stuck on the server
|
||||
//and in this case sending any package can free that package
|
||||
//especialy when this function is called from prestart events where the screen is locked, we don't want to make the user wait.
|
||||
//I currently can only reproduce this bug on local wesnothd (windows 7x64, msvc 32 bit release build), not on the offical server
|
||||
|
@ -309,14 +309,14 @@ config synced_context::ask_server(const std::string &name, const mp_sync::user_c
|
|||
continue;
|
||||
|
||||
}
|
||||
else if (!is_replay_end)
|
||||
else if (!is_replay_end)
|
||||
{
|
||||
/* The decision has already been made, and must
|
||||
be extracted from the replay. */
|
||||
DBG_REPLAY << "MP synchronization: replay server choice\n";
|
||||
do_replay_handle();
|
||||
const config *action = get_replay_source().get_next_action();
|
||||
if (!action)
|
||||
if (!action)
|
||||
{
|
||||
replay::process_error("[" + name + "] expected but none found\n");
|
||||
get_replay_source().revert_action();
|
||||
|
@ -325,7 +325,7 @@ config synced_context::ask_server(const std::string &name, const mp_sync::user_c
|
|||
if (!action->has_child(name))
|
||||
{
|
||||
replay::process_error("[" + name + "] expected but none found, found instead:\n " + action->debug() + "\n");
|
||||
|
||||
|
||||
get_replay_source().revert_action();
|
||||
return uch.query_user(-1);
|
||||
}
|
||||
|
@ -356,10 +356,10 @@ set_scontext_synced::set_scontext_synced(int number)
|
|||
*/
|
||||
void set_scontext_synced::init()
|
||||
{
|
||||
|
||||
|
||||
LOG_REPLAY << "set_scontext_synced::set_scontext_synced\n";
|
||||
assert(synced_context::get_synced_state() == synced_context::UNSYNCED);
|
||||
|
||||
|
||||
synced_context::set_synced_state(synced_context::SYNCED);
|
||||
synced_context::reset_is_simultaneously();
|
||||
|
||||
|
@ -383,7 +383,7 @@ set_scontext_synced::~set_scontext_synced()
|
|||
|
||||
random_new::generator = old_rng_;
|
||||
synced_context::set_synced_state(synced_context::UNSYNCED);
|
||||
|
||||
|
||||
checkup_instance = old_checkup_;
|
||||
}
|
||||
|
||||
|
@ -395,11 +395,11 @@ int set_scontext_synced::get_random_calls()
|
|||
|
||||
set_scontext_local_choice::set_scontext_local_choice()
|
||||
{
|
||||
|
||||
|
||||
assert(synced_context::get_synced_state() == synced_context::SYNCED);
|
||||
synced_context::set_synced_state(synced_context::LOCAL_CHOICE);
|
||||
|
||||
|
||||
|
||||
old_rng_ = random_new::generator;
|
||||
//calling the synced rng form inside a local_choice would cause oos.
|
||||
//TODO use a member variable instead if new/delete
|
||||
|
@ -422,7 +422,7 @@ set_scontext_leave_for_draw::set_scontext_leave_for_draw()
|
|||
}
|
||||
synced_context::set_synced_state(synced_context::LOCAL_CHOICE);
|
||||
|
||||
|
||||
|
||||
old_rng_ = random_new::generator;
|
||||
//calling the synced rng form inside a local_choice would cause oos.
|
||||
//TODO use a member variable instead if new/delete
|
||||
|
@ -456,7 +456,7 @@ config random_seed_choice::query_user(int /*side*/) const
|
|||
{
|
||||
//getting here means we are in a sp game
|
||||
|
||||
|
||||
|
||||
config retv;
|
||||
retv["new_seed"] = rand();
|
||||
return retv;
|
||||
|
|
|
@ -31,28 +31,28 @@ class synced_context
|
|||
public:
|
||||
enum synced_state {UNSYNCED, SYNCED, LOCAL_CHOICE};
|
||||
/**
|
||||
|
||||
|
||||
Sets the context to 'synced', initialises random context, and calls the given function.
|
||||
The plan is that in replay and in real game the same function is called.
|
||||
however, if you cannot call this function you can also use set_scontext_synced directly (use it like it's used in this method).
|
||||
|
||||
movement commands are currently treated specially,
|
||||
movement commands are currently treated specially,
|
||||
thats because actions::move_unit returns a value and some function use that value.
|
||||
maybe i should add a way here to return a value.
|
||||
|
||||
|
||||
ai's attacks are also treated special because the ai wants to pass advancement_aspects.
|
||||
|
||||
|
||||
redoing does normaly not take place in a synced context, because we saved the dependent=true replaycommands in the replaystack data.
|
||||
redoing does normaly not take place in a synced context, because we saved the dependent=true replaycommands in the replaystack data.
|
||||
also there are no events of similar fired when redoing an action (in most cases).
|
||||
|
||||
|
||||
@param use_undo this parameter is used to ignore undos during an ai move to optimize.
|
||||
@param store_in_replay only true if called by do_replay_handle
|
||||
@param error_handler an error handler for the case that data contains invalid data.
|
||||
|
||||
|
||||
@return true if the action was successful.
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
static bool run_in_synced_context(const std::string& commandname,const config& data, bool use_undo = true, bool show = true , bool store_in_replay = true , synced_command::error_handler_function error_handler = default_error_function);
|
||||
|
@ -74,7 +74,7 @@ public:
|
|||
*/
|
||||
static int generate_random_seed();
|
||||
/*
|
||||
called from get_user_choice;
|
||||
called from get_user_choice;
|
||||
*/
|
||||
static void pull_remote_user_input();
|
||||
/*
|
||||
|
@ -117,7 +117,7 @@ private:
|
|||
/*
|
||||
As soon as get_user_choice is used with side != current_side (for example in generate_random_seed) other sides execute the command simultaneously and is_simultaneously is set to true.
|
||||
It's impossible to undo data that has been sended over the network.
|
||||
|
||||
|
||||
false = we are on a local turn and haven't sended anything yet.
|
||||
*/
|
||||
static bool is_simultaneously_;
|
||||
|
@ -184,7 +184,7 @@ private:
|
|||
*/
|
||||
class random_seed_choice : public mp_sync::user_choice
|
||||
{
|
||||
public:
|
||||
public:
|
||||
random_seed_choice();
|
||||
virtual ~random_seed_choice();
|
||||
virtual config query_user(int /*side*/) const;
|
||||
|
|
|
@ -238,7 +238,7 @@ public:
|
|||
void make_ai() { info_.controller = AI; }
|
||||
void make_idle() { info_.controller = IDLE; }
|
||||
void change_controller(const std::string& new_controller) {
|
||||
info_.controller = lexical_cast_default<CONTROLLER> (new_controller, AI);
|
||||
info_.controller = lexical_cast_default<CONTROLLER> (new_controller, AI);
|
||||
}
|
||||
void change_controller(CONTROLLER controller) { info_.controller = controller; }
|
||||
|
||||
|
|
|
@ -29,121 +29,121 @@ BOOST_AUTO_TEST_CASE ( test_config_attribute_value )
|
|||
double x_dbl;
|
||||
|
||||
c["x"] = 1;
|
||||
x_str = c["x"].str();
|
||||
x_str = c["x"].str();
|
||||
BOOST_CHECK_EQUAL(x_str, "1");
|
||||
x_int = c["x"].to_int();
|
||||
x_int = c["x"].to_int();
|
||||
BOOST_CHECK_EQUAL(x_int, 1);
|
||||
x_sll = c["x"].to_long_long();
|
||||
x_sll = c["x"].to_long_long();
|
||||
BOOST_CHECK_EQUAL(x_sll, 1ll);
|
||||
x_dbl = c["x"].to_double();
|
||||
x_dbl = c["x"].to_double();
|
||||
BOOST_CHECK_EQUAL(x_dbl, 1.0);
|
||||
|
||||
|
||||
c["x"] = 10000000;
|
||||
x_int = c["x"].to_int();
|
||||
x_int = c["x"].to_int();
|
||||
BOOST_CHECK_EQUAL(x_int, 10000000);
|
||||
x_str = c["x"].str();
|
||||
x_str = c["x"].str();
|
||||
BOOST_CHECK_EQUAL(x_str, "10000000");
|
||||
x_sll = c["x"].to_long_long();
|
||||
x_sll = c["x"].to_long_long();
|
||||
BOOST_CHECK_EQUAL(x_sll, 10000000ll);
|
||||
x_dbl = c["x"].to_double();
|
||||
x_dbl = c["x"].to_double();
|
||||
BOOST_CHECK_EQUAL(x_dbl, 1e7);
|
||||
|
||||
c["x"] = "";
|
||||
x_sll = c["x"].to_long_long();
|
||||
x_sll = c["x"].to_long_long();
|
||||
BOOST_CHECK_EQUAL(x_sll, 0ll);
|
||||
x_str = c["x"].str();
|
||||
x_str = c["x"].str();
|
||||
BOOST_CHECK_EQUAL(x_str, "");
|
||||
x_int = c["x"].to_int();
|
||||
x_int = c["x"].to_int();
|
||||
BOOST_CHECK_EQUAL(x_int, 0);
|
||||
x_dbl = c["x"].to_double();
|
||||
x_dbl = c["x"].to_double();
|
||||
BOOST_CHECK_EQUAL(x_dbl, 0.0);
|
||||
|
||||
|
||||
c["x"] = "0x11";
|
||||
x_int = c["x"].to_int();
|
||||
x_int = c["x"].to_int();
|
||||
BOOST_CHECK_EQUAL(x_int, 0);
|
||||
x_str = c["x"].str();
|
||||
BOOST_CHECK_EQUAL(x_str, "0x11");
|
||||
x_sll = c["x"].to_long_long();
|
||||
x_sll = c["x"].to_long_long();
|
||||
BOOST_CHECK_EQUAL(x_sll, 0ll);
|
||||
x_dbl = c["x"].to_double();
|
||||
x_dbl = c["x"].to_double();
|
||||
BOOST_CHECK_EQUAL(x_dbl, 0.0);
|
||||
|
||||
|
||||
c["x"] = "0xab";
|
||||
x_int = c["x"].to_int();
|
||||
x_int = c["x"].to_int();
|
||||
BOOST_CHECK_EQUAL(x_int, 0);
|
||||
x_str = c["x"].str();
|
||||
x_str = c["x"].str();
|
||||
BOOST_CHECK_EQUAL(x_str, "0xab");
|
||||
x_sll = c["x"].to_long_long();
|
||||
x_sll = c["x"].to_long_long();
|
||||
BOOST_CHECK_EQUAL(x_sll, 0ll);
|
||||
x_dbl = c["x"].to_double();
|
||||
x_dbl = c["x"].to_double();
|
||||
BOOST_CHECK_EQUAL(x_dbl, 0.0);
|
||||
|
||||
|
||||
c["x"] = "00001111";
|
||||
x_int = c["x"].to_int();
|
||||
x_int = c["x"].to_int();
|
||||
BOOST_CHECK_EQUAL(x_int, 1111);
|
||||
x_str = c["x"].str();
|
||||
x_str = c["x"].str();
|
||||
BOOST_CHECK_EQUAL(x_str, "00001111");
|
||||
x_sll = c["x"].to_long_long();
|
||||
x_sll = c["x"].to_long_long();
|
||||
BOOST_CHECK_EQUAL(x_sll, 1111ll);
|
||||
x_dbl = c["x"].to_double();
|
||||
x_dbl = c["x"].to_double();
|
||||
BOOST_CHECK_EQUAL(x_dbl, 1.111e3);
|
||||
|
||||
|
||||
c["x"] = "000000";
|
||||
x_int = c["x"].to_int();
|
||||
x_int = c["x"].to_int();
|
||||
BOOST_CHECK_EQUAL(x_int, 0);
|
||||
x_str = c["x"].str();
|
||||
x_str = c["x"].str();
|
||||
BOOST_CHECK_EQUAL(x_str,"000000");
|
||||
x_sll = c["x"].to_long_long();
|
||||
x_sll = c["x"].to_long_long();
|
||||
BOOST_CHECK_EQUAL(x_sll, 0ll);
|
||||
x_dbl = c["x"].to_double();
|
||||
x_dbl = c["x"].to_double();
|
||||
BOOST_CHECK_EQUAL(x_dbl, 0.0);
|
||||
|
||||
|
||||
c["x"] = "01234567890123456789";
|
||||
x_sll = c["x"].to_long_long();
|
||||
x_sll = c["x"].to_long_long();
|
||||
BOOST_CHECK_EQUAL(x_sll,1234567890123456789ll);
|
||||
x_str = c["x"].str();
|
||||
x_str = c["x"].str();
|
||||
BOOST_CHECK_EQUAL(x_str,"01234567890123456789");
|
||||
x_int = c["x"].to_int();
|
||||
x_int = c["x"].to_int();
|
||||
BOOST_CHECK_EQUAL(x_int, 0);
|
||||
x_dbl = c["x"].to_double();
|
||||
x_dbl = c["x"].to_double();
|
||||
BOOST_CHECK_EQUAL(x_dbl, 1.23456789012345678e18);
|
||||
|
||||
|
||||
c["x"] = "99999999999999999999";
|
||||
x_sll = c["x"].to_long_long();
|
||||
x_sll = c["x"].to_long_long();
|
||||
BOOST_CHECK_EQUAL(x_sll, 0ll);
|
||||
x_str = c["x"].str();
|
||||
x_str = c["x"].str();
|
||||
BOOST_CHECK_EQUAL(x_str, "99999999999999999999");
|
||||
x_int = c["x"].to_int();
|
||||
x_int = c["x"].to_int();
|
||||
BOOST_CHECK_EQUAL(x_int, 0);
|
||||
x_dbl = c["x"].to_double();
|
||||
x_dbl = c["x"].to_double();
|
||||
BOOST_CHECK_EQUAL(x_dbl, 1e20);
|
||||
|
||||
c["x"] = 1.499;
|
||||
x_sll = c["x"].to_long_long();
|
||||
x_sll = c["x"].to_long_long();
|
||||
BOOST_CHECK_EQUAL(x_sll, 1ll);
|
||||
x_str = c["x"].str();
|
||||
x_str = c["x"].str();
|
||||
BOOST_CHECK_EQUAL(x_str, "1.499");
|
||||
x_int = c["x"].to_int();
|
||||
x_int = c["x"].to_int();
|
||||
BOOST_CHECK_EQUAL(x_int, 1);
|
||||
x_dbl = c["x"].to_double();
|
||||
x_dbl = c["x"].to_double();
|
||||
BOOST_CHECK(std::abs(x_dbl - 1.499) < 1e-6);
|
||||
|
||||
|
||||
c["x"] = 123456789123ll;
|
||||
x_int = c["x"].to_int();
|
||||
x_int = c["x"].to_int();
|
||||
BOOST_CHECK_EQUAL(x_int, -1097262461);
|
||||
x_dbl = c["x"].to_double();
|
||||
x_dbl = c["x"].to_double();
|
||||
BOOST_CHECK_EQUAL(x_dbl, 1.23456789123e11);
|
||||
x_sll = c["x"].to_long_long();
|
||||
x_sll = c["x"].to_long_long();
|
||||
BOOST_CHECK_EQUAL(x_sll, 123456789123ll);
|
||||
x_str = c["x"].str();
|
||||
x_str = c["x"].str();
|
||||
BOOST_CHECK_EQUAL(x_str, "123456789123");
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "util.hpp"
|
||||
|
||||
namespace foo {
|
||||
|
||||
|
||||
MAKE_ENUM(enumname,
|
||||
(con1, "name1")
|
||||
(con2, "name2")
|
||||
|
@ -37,14 +37,14 @@ namespace foo {
|
|||
enum enumname {con1, con2 ,con3}
|
||||
}
|
||||
|
||||
foo::enumname lexical_cast<std::string> ( std::string str ) throws bad_lexical_cast
|
||||
{
|
||||
foo::enumname lexical_cast<std::string> ( std::string str ) throws bad_lexical_cast
|
||||
{
|
||||
...
|
||||
}
|
||||
*/
|
||||
|
||||
class bar {
|
||||
public:
|
||||
public:
|
||||
|
||||
MAKE_ENUM(another,
|
||||
(val1, "name1")
|
||||
|
@ -76,7 +76,7 @@ BOOST_AUTO_TEST_CASE ( test_make_enum_namespace )
|
|||
|
||||
bool threw_exception_when_it_wasnt_supposed_to = false;
|
||||
|
||||
try {
|
||||
try {
|
||||
e = lexical_cast<foo::enumname> ("name3"); //returns con3
|
||||
} catch (bad_lexical_cast & e) {
|
||||
//std::cerr << "enum lexical cast didn't work!" << std::endl;
|
||||
|
@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE ( test_make_enum_namespace )
|
|||
|
||||
bool threw_exception_when_it_was_supposed_to = false;
|
||||
|
||||
try {
|
||||
try {
|
||||
e = lexical_cast<foo::enumname> ("name4"); //throw bad_lexical_cast
|
||||
} catch (bad_lexical_cast & e) {
|
||||
//std::cerr << "enum lexical cast worked!" << std::endl;
|
||||
|
@ -117,7 +117,7 @@ BOOST_AUTO_TEST_CASE ( test_make_enum_class )
|
|||
|
||||
bool threw_exception_when_it_wasnt_supposed_to = false;
|
||||
|
||||
try {
|
||||
try {
|
||||
e = lexical_cast<bar::another> ("name3"); //returns val3
|
||||
} catch (bad_lexical_cast & e) {
|
||||
//std::cerr << "enum lexical cast didn't work!" << std::endl;
|
||||
|
@ -128,7 +128,7 @@ BOOST_AUTO_TEST_CASE ( test_make_enum_class )
|
|||
|
||||
bool threw_exception_when_it_was_supposed_to = false;
|
||||
|
||||
try {
|
||||
try {
|
||||
e = lexical_cast<bar::another> ("name4"); //throw bad_lexical_cast
|
||||
} catch (bad_lexical_cast & e) {
|
||||
//std::cerr << "enum lexical cast worked!" << std::endl;
|
||||
|
|
|
@ -31,7 +31,7 @@ static map_location::DIRECTION se = map_location::SOUTH_EAST;
|
|||
static map_location::DIRECTION sw = map_location::SOUTH_WEST;
|
||||
|
||||
|
||||
struct MLFixture
|
||||
struct MLFixture
|
||||
{
|
||||
MLFixture()
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ struct MLFixture
|
|||
vs2 = vz.get_direction(n).get_direction(ne);
|
||||
vs3 = vz.get_direction(s).get_direction(se);
|
||||
vs4 = vz.get_direction(sw).get_direction(se);
|
||||
|
||||
|
||||
preset_locs.push_back(va);
|
||||
preset_locs.push_back(vb);
|
||||
preset_locs.push_back(vc);
|
||||
|
@ -91,14 +91,14 @@ static void characterization_distance_direction (const std::vector<map_location>
|
|||
const map_location & a = *it_a;
|
||||
const map_location & b = *it_b;
|
||||
#ifdef MAP_LOCATION_GET_OUTPUT
|
||||
std::cout << "(std::make_pair(" << distance_between(a,b) << ",\t\""
|
||||
std::cout << "(std::make_pair(" << distance_between(a,b) << ",\t\""
|
||||
<< map_location::write_direction( a.get_relative_dir(b,mode)) << "\"))" << std::endl;
|
||||
#else
|
||||
int expected_dist = *(int_it++);
|
||||
map_location::DIRECTION expected_dir = *(dir_it++);
|
||||
BOOST_CHECK_EQUAL( expected_dist, distance_between(a,b) );
|
||||
BOOST_CHECK_EQUAL( expected_dist, distance_between(b,a) );
|
||||
BOOST_CHECK_EQUAL( expected_dir, a.get_relative_dir(b, mode) );
|
||||
BOOST_CHECK_EQUAL( expected_dir, a.get_relative_dir(b, mode) );
|
||||
//Note: This is not a valid assertion. get_relative_dir has much symmetry but not radial.
|
||||
if (mode == map_location::RADIAL_SYMMETRY) {
|
||||
BOOST_CHECK_EQUAL( map_location::get_opposite_dir(expected_dir), b.get_relative_dir(a,mode) );
|
||||
|
@ -322,7 +322,7 @@ BOOST_AUTO_TEST_CASE ( reality_check_get_direction )
|
|||
reality_check_get_direction_helper(b,se);
|
||||
}
|
||||
|
||||
static map_location::DIRECTION legacy_get_opposite_dir(map_location::DIRECTION d)
|
||||
static map_location::DIRECTION legacy_get_opposite_dir(map_location::DIRECTION d)
|
||||
{
|
||||
switch (d) {
|
||||
case map_location::NORTH:
|
||||
|
@ -403,12 +403,12 @@ BOOST_AUTO_TEST_CASE ( check_rotate_around_center )
|
|||
|
||||
/**
|
||||
* This commented block was used to visualize the output of get_relative_dir
|
||||
* and to help derive the implementation in commit
|
||||
* and to help derive the implementation in commit
|
||||
* 829b74c2beaa18eda42710c364b12c987f9caed5
|
||||
*/
|
||||
|
||||
/*
|
||||
static std::string dir_to_terrain (const map_location::DIRECTION dir)
|
||||
static std::string dir_to_terrain (const map_location::DIRECTION dir)
|
||||
{
|
||||
switch(dir) {
|
||||
case map_location::NORTH: return "Gg";
|
||||
|
@ -452,4 +452,4 @@ BOOST_AUTO_TEST_CASE ( visualize_get_relative_dir )
|
|||
std::cout << "***" << std::endl;
|
||||
}*/
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
|
@ -44,7 +44,7 @@ tod_manager::tod_manager(const config& scenario_cfg):
|
|||
num_turns_(scenario_cfg["turns"].to_int(-1))
|
||||
{
|
||||
// ? : operator doesn't work in this case.
|
||||
if (scenario_cfg["current_time"].to_int(-17403) == -17403)
|
||||
if (scenario_cfg["current_time"].to_int(-17403) == -17403)
|
||||
random_tod_ = scenario_cfg["random_start_time"];
|
||||
else
|
||||
random_tod_ = false;
|
||||
|
@ -52,7 +52,7 @@ tod_manager::tod_manager(const config& scenario_cfg):
|
|||
time_of_day::parse_times(scenario_cfg,times_);
|
||||
//We need to call parse_times before calculate_current_time because otherwise the first parameter will always be 0.
|
||||
currentTime_ = calculate_current_time(times_.size(), turn_, scenario_cfg["current_time"].to_int(0), true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
tod_manager& tod_manager::operator=(const tod_manager& manager)
|
||||
|
@ -88,14 +88,14 @@ void tod_manager::resolve_random(random_new::rng& r)
|
|||
//process the random_start_time string, which can be boolean yes/no true/false or a
|
||||
//comma-separated string of integers >= 1 referring to the times_ array indices
|
||||
std::vector<int> output;
|
||||
boost::copy( utils::split(random_tod_.str())
|
||||
boost::copy( utils::split(random_tod_.str())
|
||||
| boost::adaptors::transformed(boost::bind(lexical_cast_default<int, std::string>, _1 , 0))
|
||||
| boost::adaptors::filtered(greater<int>(0))
|
||||
, std::back_inserter(output) );
|
||||
|
||||
if(!output.empty())
|
||||
{
|
||||
int chosen = output[r.next_random() % output.size()];
|
||||
int chosen = output[r.next_random() % output.size()];
|
||||
currentTime_ = calculate_current_time(times_.size(), turn_, chosen, true);
|
||||
r.next_random();
|
||||
}
|
||||
|
|
16
src/unit.cpp
16
src/unit.cpp
|
@ -817,7 +817,7 @@ void unit::advance_to(const config &old_cfg, const unit_type &u_type,
|
|||
max_experience_ = new_type.experience_needed(false);
|
||||
level_ = new_type.level();
|
||||
recall_cost_ = new_type.recall_cost();
|
||||
/* Need to add a check to see if the unit's old cost is equal
|
||||
/* Need to add a check to see if the unit's old cost is equal
|
||||
to the unit's old unit_type cost first. If it is change the cost
|
||||
otherwise keep the old cost. */
|
||||
if(old_type.recall_cost() == recall_cost_) {
|
||||
|
@ -1517,12 +1517,12 @@ bool unit::internal_matches_filter(const vconfig& cfg, const map_location& loc,
|
|||
if (!cfg_canrecruit.blank() && cfg_canrecruit.to_bool() != can_recruit()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
config::attribute_value cfg_recall_cost = cfg["recall_cost"];
|
||||
if (!cfg_recall_cost.blank() && cfg_recall_cost.to_int(-1) != recall_cost_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
config::attribute_value cfg_level = cfg["level"];
|
||||
if (!cfg_level.blank() && cfg_level.to_int(-1) != level_) {
|
||||
return false;
|
||||
|
@ -1673,7 +1673,7 @@ void unit::write(config& cfg) const
|
|||
cfg["experience"] = experience_;
|
||||
cfg["max_experience"] = max_experience_;
|
||||
cfg["recall_cost"] = recall_cost_;
|
||||
|
||||
|
||||
cfg["side"] = side_;
|
||||
|
||||
cfg["type"] = type_id();
|
||||
|
@ -1905,7 +1905,7 @@ void unit::redraw_unit()
|
|||
|
||||
if (refreshing_) return;
|
||||
refreshing_ = true;
|
||||
|
||||
|
||||
anim_->update_last_draw_time();
|
||||
frame_parameters params;
|
||||
const t_translation::t_terrain terrain = map.get_terrain(loc_);
|
||||
|
@ -1922,7 +1922,7 @@ void unit::redraw_unit()
|
|||
if (loc_ == disp.selected_hex() && params.highlight_ratio == 1.0) {
|
||||
params.highlight_ratio = 1.5;
|
||||
}
|
||||
|
||||
|
||||
int height_adjust = static_cast<int>(terrain_info.unit_height_adjust() * disp.get_zoom_factor());
|
||||
if (is_flying() && height_adjust < 0) {
|
||||
height_adjust = 0;
|
||||
|
@ -2134,7 +2134,7 @@ void unit::redraw_unit()
|
|||
|
||||
// Smooth unit movements from terrain of different elevation.
|
||||
// Do this separately from above so that the health bar doesn't go up and down.
|
||||
|
||||
|
||||
const t_translation::t_terrain terrain_dst = map.get_terrain(dst);
|
||||
const terrain_type& terrain_dst_info = map.get_terrain_info(terrain_dst);
|
||||
|
||||
|
@ -2146,7 +2146,7 @@ void unit::redraw_unit()
|
|||
}
|
||||
params.y -= height_adjust_unit - height_adjust;
|
||||
params.halo_y -= height_adjust_unit - height_adjust;
|
||||
|
||||
|
||||
anim_->redraw(params);
|
||||
refreshing_ = false;
|
||||
}
|
||||
|
|
|
@ -785,7 +785,7 @@ namespace { // Helpers for attack_type::special_active()
|
|||
// is active, in that it can be used, even though the player might
|
||||
// need to select an appropriate opponent.)
|
||||
return true;
|
||||
|
||||
|
||||
const config & filter_child = filter.child(child_tag);
|
||||
if ( !filter_child )
|
||||
// The special does not filter on this unit, so we pass.
|
||||
|
|
|
@ -333,7 +333,7 @@ frame_builder::frame_builder(const config& cfg,const std::string& frame_string)
|
|||
int image_duration = (progressive_image(image_,1)).duration();
|
||||
int image_diagonal_duration = (progressive_image(image_diagonal_,1)).duration();
|
||||
duration(std::max(std::max(image_duration,image_diagonal_duration),halo_duration));
|
||||
|
||||
|
||||
} else {
|
||||
duration(cfg[frame_string + "end"].to_int() - cfg[frame_string + "begin"].to_int());
|
||||
}
|
||||
|
@ -697,14 +697,14 @@ void unit_frame::redraw(const int frame_time,bool on_start_time,bool in_scope_of
|
|||
ftofxp(current_data.highlight_ratio), current_data.blend_with,
|
||||
current_data.blend_ratio,current_data.submerge,!facing_north);
|
||||
}
|
||||
|
||||
|
||||
halo::remove(*halo_id);
|
||||
*halo_id = halo::NO_HALO;
|
||||
|
||||
|
||||
if (!in_scope_of_frame) { //check after frame as first/last frame image used in defense/attack anims
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(!current_data.halo.empty()) {
|
||||
halo::ORIENTATION orientation;
|
||||
switch(direction)
|
||||
|
@ -736,7 +736,7 @@ void unit_frame::redraw(const int frame_time,bool on_start_time,bool in_scope_of
|
|||
orientation = halo::NORMAL;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(direction != map_location::SOUTH_WEST && direction != map_location::NORTH_WEST) {
|
||||
*halo_id = halo::add(static_cast<int>(x+current_data.halo_x* game_display::get_singleton()->get_zoom_factor()),
|
||||
static_cast<int>(y+current_data.halo_y* game_display::get_singleton()->get_zoom_factor()),
|
||||
|
|
|
@ -281,7 +281,7 @@ public:
|
|||
/// to the HELP_INDEXED status.
|
||||
const std::vector<unit_race::GENDER>& genders() const { return genders_; }
|
||||
std::vector<std::string> variations() const;
|
||||
|
||||
|
||||
/**
|
||||
* @param variation_id The id of the variation we search for.
|
||||
* @return Iff one of the type's variations' (or the sibling's if the unit_type is a variation itself) id matches @variation_id.
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace utils
|
|||
/// an element for removal from the list. Flagged elements are ignored by list
|
||||
/// functions, but they still exist from the perspective of iterators that had
|
||||
/// pointed (and still point) to the element.
|
||||
///
|
||||
///
|
||||
/// Assignment is incompatible with the goal of preserving iterators, so it is
|
||||
/// not implemented (declared private though, to emphasize that this is
|
||||
/// intentional).
|
||||
|
|
|
@ -618,12 +618,12 @@ std::vector<std::pair<int, int> > CVideo::get_available_resolutions()
|
|||
std::cerr << "No modes supported\n";
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
const std::pair<int,int> min_res = std::make_pair(preferences::min_allowed_width(),preferences::min_allowed_height());
|
||||
|
||||
|
||||
if (getSurface()->w >= min_res.first && getSurface()->h >= min_res.second)
|
||||
result.push_back(std::make_pair(getSurface()->w, getSurface()->h));
|
||||
|
||||
|
||||
for(int i = 0; modes[i] != NULL; ++i) {
|
||||
if (modes[i]->w >= min_res.first && modes[i]->h >= min_res.second)
|
||||
result.push_back(std::make_pair(modes[i]->w,modes[i]->h));
|
||||
|
|
|
@ -122,9 +122,9 @@ void recall::execute(bool& success, bool& complete)
|
|||
cost=temp_unit_->recall_cost();
|
||||
}
|
||||
current_team.get_side_actions()->change_gold_spent_by(-cost);
|
||||
bool const result = synced_context::run_in_synced_context("recall",
|
||||
bool const result = synced_context::run_in_synced_context("recall",
|
||||
replay_helper::get_recall(temp_unit_->id(), recall_hex_, map_location::null_location()),
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
synced_context::ignore_error_function);
|
||||
|
|
|
@ -131,7 +131,7 @@ int path_cost(std::vector<map_location> const& path, unit const& u)
|
|||
temporary_unit_hider::temporary_unit_hider(unit& u)
|
||||
: unit_(&u)
|
||||
{unit_->set_hidden(true);}
|
||||
temporary_unit_hider::~temporary_unit_hider()
|
||||
temporary_unit_hider::~temporary_unit_hider()
|
||||
{
|
||||
try {
|
||||
unit_->set_hidden(false);
|
||||
|
|
Loading…
Add table
Reference in a new issue