Config: remove implicit conversion to int and bool (#9444)
Resolves #9009, closes #9384. Besides the issues that came from having both int and bool conversions (even with bool marked explicit), it doesn't make sense to use int for all numeric assignments. I didn't test whether it would be an issue in practice, but it seems better to let callers be explicit about what type they want for numeric values than risking overflow or wrapping for very large values.
This commit is contained in:
parent
f13d4fe2a4
commit
56cc3aee0f
81 changed files with 216 additions and 211 deletions
|
@ -75,7 +75,7 @@ namespace
|
|||
bool always_display = false;
|
||||
|
||||
for (const config& advance : u.get_modification_advances()) {
|
||||
if (advance["always_display"]) {
|
||||
if (advance["always_display"].to_bool()) {
|
||||
always_display = true;
|
||||
}
|
||||
previews.push_back(get_amla_unit(u, advance));
|
||||
|
@ -296,7 +296,7 @@ void advance_unit_at(const advance_unit_params& params)
|
|||
config selected = mp_sync::get_user_choice("choose",
|
||||
unit_advancement_choice(params.loc_, unit_helper::number_of_possible_advances(*u), u->side(), params.force_dialog_), side_for);
|
||||
//calls actions::advance_unit.
|
||||
bool result = animate_unit_advancement(params.loc_, selected["value"], params.fire_events_, params.animate_);
|
||||
bool result = animate_unit_advancement(params.loc_, selected["value"].to_size_t(), params.fire_events_, params.animate_);
|
||||
|
||||
DBG_NG << "animate_unit_advancement result = " << result;
|
||||
u = resources::gameboard->units().find(params.loc_);
|
||||
|
|
|
@ -1505,9 +1505,9 @@ void attack::perform()
|
|||
void attack::check_replay_attack_result(
|
||||
bool& hits, int ran_num, int& damage, config replay_results, unit_info& attacker)
|
||||
{
|
||||
int results_chance = replay_results["chance"];
|
||||
int results_chance = replay_results["chance"].to_int();
|
||||
bool results_hits = replay_results["hits"].to_bool();
|
||||
int results_damage = replay_results["damage"];
|
||||
int results_damage = replay_results["damage"].to_int();
|
||||
|
||||
#if 0
|
||||
errbuf_ << "SYNC: In attack " << a_.dump() << " vs " << d_.dump()
|
||||
|
|
|
@ -69,7 +69,7 @@ undo_action_base * undo_list::create_action(const config & cfg)
|
|||
|
||||
if ( str == "move" ) {
|
||||
res = new undo::move_action(cfg, cfg.child_or_empty("unit"),
|
||||
cfg["starting_moves"],
|
||||
cfg["starting_moves"].to_int(),
|
||||
map_location::parse_direction(cfg["starting_direction"]));
|
||||
}
|
||||
|
||||
|
|
|
@ -77,8 +77,8 @@ undo_event::undo_event(const config& first, const config& second, const config&
|
|||
, loc2(second["x"], second["y"], wml_loc())
|
||||
, filter_loc1(first["filter_x"], first["filter_y"], wml_loc())
|
||||
, filter_loc2(second["filter_x"], second["filter_y"], wml_loc())
|
||||
, uid1(first["underlying_id"])
|
||||
, uid2(second["underlying_id"])
|
||||
, uid1(first["underlying_id"].to_size_t())
|
||||
, uid2(second["underlying_id"].to_size_t())
|
||||
, id1(first["id"])
|
||||
, id2(second["id"])
|
||||
{
|
||||
|
@ -102,7 +102,7 @@ undo_action::undo_action()
|
|||
|
||||
undo_action::undo_action(const config& cfg)
|
||||
: undo_action_base()
|
||||
, unit_id_diff(cfg["unit_id_diff"])
|
||||
, unit_id_diff(cfg["unit_id_diff"].to_int())
|
||||
{
|
||||
read_event_vector(umc_commands_undo, cfg, "undo_actions");
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ namespace {
|
|||
config::attribute_value& y1 = resources::gamedata->get_variable("y1");
|
||||
config::attribute_value& x2 = resources::gamedata->get_variable("x2");
|
||||
config::attribute_value& y2 = resources::gamedata->get_variable("y2");
|
||||
int oldx1 = x1, oldy1 = y1, oldx2 = x2, oldy2 = y2;
|
||||
int oldx1 = x1.to_int(), oldy1 = y1.to_int(), oldx2 = x2.to_int(), oldy2 = y2.to_int();
|
||||
x1 = e.filter_loc1.wml_x(); y1 = e.filter_loc1.wml_y();
|
||||
x2 = e.filter_loc2.wml_x(); y2 = e.filter_loc2.wml_y();
|
||||
|
||||
|
|
|
@ -80,9 +80,9 @@ void addon_info::read(const config& cfg)
|
|||
current_version = cfg["version"].str();
|
||||
versions.emplace(cfg["version"].str());
|
||||
author = cfg["author"].str();
|
||||
size = cfg["size"];
|
||||
downloads = cfg["downloads"];
|
||||
uploads = cfg["uploads"];
|
||||
size = cfg["size"].to_int();
|
||||
downloads = cfg["downloads"].to_int();
|
||||
uploads = cfg["uploads"].to_int();
|
||||
type = get_addon_type(cfg["type"].str());
|
||||
|
||||
for(const config& version : cfg.child_range("version")) {
|
||||
|
|
|
@ -154,7 +154,7 @@ bool check_case_insensitive_duplicates_internal(const config& dir, const std::st
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if (!check_case_insensitive_duplicates_internal(path, prefix + filename + "/", badlist) && !badlist){
|
||||
if(!check_case_insensitive_duplicates_internal(path, with_prefix + "/", badlist) && !badlist) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ engine_cpp::~engine_cpp()
|
|||
|
||||
void engine_cpp::do_parse_aspect_from_config( const config &cfg, const std::string &id, std::back_insert_iterator<std::vector< aspect_ptr >> b )
|
||||
{
|
||||
const std::string aspect_factory_key = id+"*"+cfg["name"];//@note: hack which combines aspect id and name to get the std::string key of the aspect factory
|
||||
const std::string aspect_factory_key = id + "*" + cfg["name"].str(); //@note: hack which combines aspect id and name to get the std::string key of the aspect factory
|
||||
aspect_factory::factory_map::iterator f = aspect_factory::get_list().find(aspect_factory_key);
|
||||
if (f == aspect_factory::get_list().end()){
|
||||
ERR_AI_ENGINE_CPP << "side "<<ai_.get_side()<< " : UNKNOWN aspect["<<aspect_factory_key<<"]";
|
||||
|
|
|
@ -66,9 +66,9 @@ using ca_ptr = wfl::candidate_action_ptr;
|
|||
ca_ptr formula_ai::load_candidate_action_from_config(const config& rc_action)
|
||||
{
|
||||
ca_ptr new_ca;
|
||||
const t_string &name = rc_action["name"];
|
||||
const std::string name = rc_action["name"];
|
||||
try {
|
||||
const t_string &type = rc_action["type"];
|
||||
const std::string& type = rc_action["type"];
|
||||
|
||||
if( type == "movement") {
|
||||
new_ca = std::make_shared<move_candidate_action>(name, type, rc_action, &function_table_);
|
||||
|
@ -627,11 +627,11 @@ void formula_ai::on_create(){
|
|||
|
||||
for(const config &func : cfg_.child_range("function"))
|
||||
{
|
||||
const t_string &name = func["name"];
|
||||
const t_string &inputs = func["inputs"];
|
||||
const t_string &formula_str = func["formula"];
|
||||
const std::string name = func["name"];
|
||||
const std::string inputs = func["inputs"];
|
||||
const std::string formula_str = func["formula"];
|
||||
|
||||
std::vector<std::string> args = utils::split(inputs.str());
|
||||
std::vector<std::string> args = utils::split(inputs);
|
||||
try {
|
||||
add_formula_function(name,
|
||||
create_optional_formula(formula_str),
|
||||
|
|
|
@ -149,11 +149,8 @@ public:
|
|||
std::string to(const std::string& def) const { return str(def); }
|
||||
|
||||
// Implicit conversions:
|
||||
operator int() const { return to_int(); }
|
||||
operator std::string() const { return str(); }
|
||||
operator t_string() const { return t_str(); }
|
||||
// This is to prevent int conversion being used when an attribute value is tested in an if statement
|
||||
explicit operator bool() const {return to_bool(); }
|
||||
|
||||
/** Tests for an attribute that was never set. */
|
||||
bool blank() const;
|
||||
|
@ -183,7 +180,7 @@ public:
|
|||
v = comp;
|
||||
return *this == v;
|
||||
} else {
|
||||
return utils::holds_alternative<T>(value_) && T(*this) == comp;
|
||||
return utils::holds_alternative<T>(value_) && this->to(T{}) == comp;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ brush::brush(const config& cfg)
|
|||
, name_(cfg["name"])
|
||||
, id_(cfg["id"])
|
||||
{
|
||||
int radius = cfg["radius"];
|
||||
int radius = cfg["radius"].to_int();
|
||||
if (radius > 0) {
|
||||
std::vector<map_location> in_radius;
|
||||
get_tiles_in_radius(map_location(0, 0), radius, in_radius);
|
||||
|
@ -44,8 +44,8 @@ brush::brush(const config& cfg)
|
|||
}
|
||||
for (const config &relative : cfg.child_range("relative"))
|
||||
{
|
||||
int x = relative["x"];
|
||||
int y = relative["y"];
|
||||
int x = relative["x"].to_int();
|
||||
int y = relative["y"].to_int();
|
||||
add_relative_location(x, y);
|
||||
}
|
||||
if (relative_tiles_.empty()) {
|
||||
|
|
|
@ -38,7 +38,7 @@ static lg::log_domain log_engine_enemies("engine/enemies");
|
|||
game_board::game_board(const config& level)
|
||||
: teams_()
|
||||
, map_(std::make_unique<gamemap>(level["map_data"]))
|
||||
, unit_id_manager_(level["next_underlying_unit_id"])
|
||||
, unit_id_manager_(level["next_underlying_unit_id"].to_size_t())
|
||||
, units_()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -394,8 +394,8 @@ static void show_deprecated_warnings(config& umc_cfg)
|
|||
for(auto& unit_type : units.child_range("unit_type")) {
|
||||
for(const auto& advancefrom : unit_type.child_range("advancefrom")) {
|
||||
auto symbols = utils::string_map {
|
||||
{"lower_level", advancefrom["unit"]},
|
||||
{"higher_level", unit_type["id"]}
|
||||
{"lower_level", advancefrom["unit"].str()},
|
||||
{"higher_level", unit_type["id"].str()}
|
||||
};
|
||||
auto message = VGETTEXT(
|
||||
// TRANSLATORS: For example, 'Cuttle Fish' units will not be able to advance to 'Kraken'.
|
||||
|
|
|
@ -179,7 +179,7 @@ game_data::PHASE game_data::read_phase(const config& cfg)
|
|||
if(cfg["playing_team"].empty()) {
|
||||
return game_data::PRELOAD;
|
||||
}
|
||||
if(!cfg["init_side_done"]) {
|
||||
if(!cfg["init_side_done"].to_bool()) {
|
||||
return game_data::TURN_STARTING_WAITING;
|
||||
}
|
||||
if(cfg.has_child("end_level_data")) {
|
||||
|
|
|
@ -399,7 +399,7 @@ WML_HANDLER_FUNCTION(move_units_fake,, cfg)
|
|||
for (const vconfig& config : unit_cfgs) {
|
||||
const std::vector<std::string> xvals = utils::split(config["x"]);
|
||||
const std::vector<std::string> yvals = utils::split(config["y"]);
|
||||
int skip_steps = config["skip_steps"];
|
||||
int skip_steps = config["skip_steps"].to_int();
|
||||
fake_unit_ptr u = create_fake_unit(config);
|
||||
units.push_back(u);
|
||||
paths.push_back(fake_unit_path(*u, xvals, yvals));
|
||||
|
@ -638,7 +638,7 @@ WML_HANDLER_FUNCTION(set_global_variable,,pcfg)
|
|||
|
||||
WML_HANDLER_FUNCTION(set_variables,, cfg)
|
||||
{
|
||||
const t_string& name = cfg["name"];
|
||||
const std::string name = cfg["name"];
|
||||
variable_access_create dest = resources::gamedata->get_variable_access_write(name);
|
||||
if(name.empty()) {
|
||||
ERR_NG << "trying to set a variable with an empty name:\n" << cfg.get_config().debug();
|
||||
|
|
|
@ -147,10 +147,10 @@ namespace
|
|||
|
||||
pump_manager::pump_manager(pump_impl& impl)
|
||||
: impl_(impl)
|
||||
, x1_(resources::gamedata->get_variable("x1"))
|
||||
, x2_(resources::gamedata->get_variable("x2"))
|
||||
, y1_(resources::gamedata->get_variable("y1"))
|
||||
, y2_(resources::gamedata->get_variable("y2"))
|
||||
, x1_(resources::gamedata->get_variable("x1").to_int())
|
||||
, x2_(resources::gamedata->get_variable("x2").to_int())
|
||||
, y1_(resources::gamedata->get_variable("y1").to_int())
|
||||
, y2_(resources::gamedata->get_variable("y2").to_int())
|
||||
, queue_()
|
||||
, pumped_count_(0) // Filled later with a swap().
|
||||
{
|
||||
|
|
|
@ -830,7 +830,7 @@ side_engine::side_engine(const config& cfg, connect_engine& parent_engine, const
|
|||
, team_(0)
|
||||
, color_(std::min(index, gamemap::MAX_PLAYERS - 1))
|
||||
, gold_(cfg["gold"].to_int(100))
|
||||
, income_(cfg["income"])
|
||||
, income_(cfg["income"].to_int())
|
||||
, reserved_for_(cfg["current_player"])
|
||||
, player_id_()
|
||||
, ai_algorithm_()
|
||||
|
|
|
@ -405,7 +405,7 @@ void create_engine::prepare_for_campaign(const std::string& difficulty)
|
|||
state_.classification().abbrev = current_level_data["abbrev"].str();
|
||||
|
||||
state_.classification().end_text = current_level_data["end_text"].str();
|
||||
state_.classification().end_text_duration = current_level_data["end_text_duration"];
|
||||
state_.classification().end_text_duration = current_level_data["end_text_duration"].to_unsigned();
|
||||
state_.classification().end_credits = current_level_data["end_credits"].to_bool(true);
|
||||
|
||||
state_.classification().campaign_define = current_level_data["define"].str();
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace mp {
|
|||
user_info::user_info(const config& c)
|
||||
: name(c["name"])
|
||||
, forum_id(c["forum_id"].to_int())
|
||||
, game_id(c["game_id"])
|
||||
, game_id(c["game_id"].to_int())
|
||||
, registered(c["registered"].to_bool())
|
||||
, observing(c["status"] == "observing")
|
||||
, moderator(c["moderator"].to_bool(false))
|
||||
|
@ -109,7 +109,7 @@ std::string make_game_type_marker(const std::string& text, bool color_for_missin
|
|||
} // end anon namespace
|
||||
|
||||
game_info::game_info(const config& game, const std::vector<std::string>& installed_addons)
|
||||
: id(game["id"])
|
||||
: id(game["id"].to_int())
|
||||
, map_data(game["map_data"])
|
||||
, name(font::escape_text(game["name"]))
|
||||
, scenario()
|
||||
|
|
|
@ -164,7 +164,7 @@ bool lobby_info::process_gamelist_diff_impl(const config& data)
|
|||
for(config& c : gamelist_.mandatory_child("gamelist").child_range("game")) {
|
||||
DBG_LB << "data process: " << c["id"] << " (" << c[config::diff_track_attribute] << ")";
|
||||
|
||||
const int game_id = c["id"];
|
||||
const int game_id = c["id"].to_int();
|
||||
if(game_id == 0) {
|
||||
ERR_LB << "game with id 0 in gamelist config";
|
||||
return false;
|
||||
|
|
|
@ -396,7 +396,7 @@ std::unique_ptr<wesnothd_connection> mp_manager::open_connection(std::string hos
|
|||
|
||||
const auto extra_data = error->optional_child("data");
|
||||
if(extra_data) {
|
||||
i18n_symbols["duration"] = utils::format_timespan((*extra_data)["duration"]);
|
||||
i18n_symbols["duration"] = utils::format_timespan((*extra_data)["duration"].to_time_t());
|
||||
}
|
||||
|
||||
const std::string ec = (*error)["error_code"];
|
||||
|
@ -764,7 +764,7 @@ void start_local_game_commandline(const commandline_options& cmdline_opts)
|
|||
// Should number of turns be determined from scenario data?
|
||||
if(parameters.use_map_settings && state.get_starting_point().has_attribute("turns")) {
|
||||
DBG_MP << "setting turns from scenario data: " << state.get_starting_point()["turns"];
|
||||
parameters.num_turns = state.get_starting_point()["turns"];
|
||||
parameters.num_turns = state.get_starting_point()["turns"].to_int();
|
||||
}
|
||||
|
||||
DBG_MP << "entering connect mode";
|
||||
|
|
|
@ -38,16 +38,12 @@ cave_map_generator::cave_map_generator(const config &cfg) :
|
|||
castle_(t_translation::DWARVEN_CASTLE),
|
||||
keep_(t_translation::DWARVEN_KEEP),
|
||||
cfg_(cfg),
|
||||
width_(50),
|
||||
height_(50),
|
||||
village_density_(0),
|
||||
flipx_chance_(cfg_["flipx_chance"]),
|
||||
flipy_chance_(cfg_["flipy_chance"])
|
||||
width_(cfg_["map_width"].to_int(50)),
|
||||
height_(cfg_["map_height"].to_int(50)),
|
||||
village_density_(cfg_["village_density"].to_int(0)),
|
||||
flipx_chance_(cfg_["flipx_chance"].to_int()),
|
||||
flipy_chance_(cfg_["flipy_chance"].to_int())
|
||||
{
|
||||
width_ = cfg_["map_width"];
|
||||
height_ = cfg_["map_height"];
|
||||
|
||||
village_density_ = cfg_["village_density"];
|
||||
}
|
||||
|
||||
std::string cave_map_generator::config_name() const
|
||||
|
@ -187,7 +183,7 @@ void cave_map_generator::cave_map_generator_job::generate_chambers()
|
|||
const std::size_t y = translate_y(min_ypos + (rng_()%(max_ypos-min_ypos)));
|
||||
|
||||
int chamber_size = ch["size"].to_int(3);
|
||||
int jagged_edges = ch["jagged"];
|
||||
int jagged_edges = ch["jagged"].to_int();
|
||||
|
||||
chamber new_chamber;
|
||||
new_chamber.center = map_location(x,y);
|
||||
|
@ -319,8 +315,7 @@ void cave_map_generator::cave_map_generator_job::place_passage(const passage& p)
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
int windiness = p.cfg["windiness"];
|
||||
int windiness = p.cfg["windiness"].to_int();
|
||||
double laziness = std::max<double>(1.0, p.cfg["laziness"].to_double());
|
||||
|
||||
passage_path_calculator calc(map_, params.wall_, laziness, windiness, rng_);
|
||||
|
@ -328,7 +323,7 @@ void cave_map_generator::cave_map_generator_job::place_passage(const passage& p)
|
|||
pathfind::plain_route rt = a_star_search(p.src, p.dst, 10000.0, calc, params.width_, params.height_);
|
||||
|
||||
int width = std::max<int>(1, p.cfg["width"].to_int());
|
||||
int jagged = p.cfg["jagged"];
|
||||
int jagged = p.cfg["jagged"].to_int();
|
||||
|
||||
for(std::vector<map_location>::const_iterator i = rt.steps.begin(); i != rt.steps.end(); ++i) {
|
||||
std::set<map_location> locs;
|
||||
|
|
|
@ -165,7 +165,7 @@ namespace {
|
|||
};
|
||||
|
||||
terrain_height_mapper::terrain_height_mapper(const config& cfg) :
|
||||
terrain_height(cfg["height"]),
|
||||
terrain_height(cfg["height"].to_int()),
|
||||
to(t_translation::GRASS_LAND)
|
||||
{
|
||||
const std::string& terrain = cfg["terrain"];
|
||||
|
@ -637,7 +637,7 @@ static map_location place_village(const t_translation::ter_map& map,
|
|||
adjacent_liked = &(adj_liked_cache[t]);
|
||||
}
|
||||
|
||||
int rating = child["rating"];
|
||||
int rating = child["rating"].to_int();
|
||||
for(const map_location& adj : get_adjacent_tiles({i.x, i.y})) {
|
||||
if(adj.x < 0 || adj.y < 0 || adj.x >= map.w || adj.y >= map.h) {
|
||||
continue;
|
||||
|
@ -810,7 +810,7 @@ std::string default_map_generator_job::default_generate_map(generator_data data,
|
|||
continue;
|
||||
}
|
||||
|
||||
std::vector<map_location> river = generate_river(heights, terrain, x, y, cfg["river_frequency"]);
|
||||
std::vector<map_location> river = generate_river(heights, terrain, x, y, cfg["river_frequency"].to_int());
|
||||
|
||||
if(!river.empty() && misc_labels != nullptr) {
|
||||
const std::string base_name = base_name_generator->generate();
|
||||
|
@ -832,7 +832,7 @@ std::string default_map_generator_job::default_generate_map(generator_data data,
|
|||
LOG_NG << "Generating lake...";
|
||||
|
||||
std::set<map_location> locs;
|
||||
if(generate_lake(terrain, x, y, cfg["lake_size"], locs) && misc_labels != nullptr) {
|
||||
if(generate_lake(terrain, x, y, cfg["lake_size"].to_int(), locs) && misc_labels != nullptr) {
|
||||
bool touches_other_lake = false;
|
||||
|
||||
std::string base_name = base_name_generator->generate();
|
||||
|
@ -885,8 +885,8 @@ std::string default_map_generator_job::default_generate_map(generator_data data,
|
|||
* more interesting types than the default.
|
||||
*/
|
||||
const height_map temperature_map = generate_height_map(data.width,data.height,
|
||||
static_cast<size_t>(cfg["temperature_iterations"].to_int()) * data.width * data.height / default_dimensions,
|
||||
cfg["temperature_size"], 0, 0);
|
||||
cfg["temperature_iterations"].to_size_t() * data.width * data.height / default_dimensions,
|
||||
cfg["temperature_size"].to_size_t(), 0, 0);
|
||||
|
||||
LOG_NG << "Generated temperature map. " << (SDL_GetTicks() - ticks) << " ticks elapsed";
|
||||
ticks = SDL_GetTicks();
|
||||
|
@ -941,7 +941,7 @@ std::string default_map_generator_job::default_generate_map(generator_data data,
|
|||
const int min_y = data.height/3 + 3;
|
||||
const int max_x = (data.width/3)*2 - 4;
|
||||
const int max_y = (data.height/3)*2 - 4;
|
||||
int min_distance = castle_config["min_distance"];
|
||||
int min_distance = castle_config["min_distance"].to_int();
|
||||
|
||||
map_location best_loc;
|
||||
int best_ranking = 0;
|
||||
|
@ -985,7 +985,7 @@ std::string default_map_generator_job::default_generate_map(generator_data data,
|
|||
// Place roads.
|
||||
// We select two tiles at random locations on the borders of the map
|
||||
// and try to build roads between them.
|
||||
int nroads = cfg["roads"];
|
||||
int nroads = cfg["roads"].to_int();
|
||||
if(data.link_castles) {
|
||||
nroads += castles.size()*castles.size();
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ std::vector<game_tip> load(const config& cfg)
|
|||
std::vector<game_tip> result;
|
||||
|
||||
for(const auto& tip : cfg.child_range("tip")) {
|
||||
result.emplace_back(tip["text"], tip["source"], tip["encountered_units"]);
|
||||
result.emplace_back(tip["text"].t_str(), tip["source"].t_str(), tip["encountered_units"].str());
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -55,7 +55,7 @@ line_shape::line_shape(const config& cfg)
|
|||
, x2_(cfg["x2"])
|
||||
, y2_(cfg["y2"])
|
||||
, color_(cfg["color"])
|
||||
, thickness_(cfg["thickness"])
|
||||
, thickness_(cfg["thickness"].to_unsigned())
|
||||
{
|
||||
const std::string& debug = (cfg["debug"]);
|
||||
if(!debug.empty()) {
|
||||
|
@ -87,7 +87,7 @@ void line_shape::draw(wfl::map_formula_callable& variables)
|
|||
|
||||
rectangle_shape::rectangle_shape(const config& cfg)
|
||||
: rect_bounded_shape(cfg)
|
||||
, border_thickness_(cfg["border_thickness"])
|
||||
, border_thickness_(cfg["border_thickness"].to_int())
|
||||
, border_color_(cfg["border_color"], color_t::null_color())
|
||||
, fill_color_(cfg["fill_color"], color_t::null_color())
|
||||
{
|
||||
|
@ -149,7 +149,7 @@ void rectangle_shape::draw(wfl::map_formula_callable& variables)
|
|||
round_rectangle_shape::round_rectangle_shape(const config& cfg)
|
||||
: rect_bounded_shape(cfg)
|
||||
, r_(cfg["corner_radius"])
|
||||
, border_thickness_(cfg["border_thickness"])
|
||||
, border_thickness_(cfg["border_thickness"].to_int())
|
||||
, border_color_(cfg["border_color"], color_t::null_color())
|
||||
, fill_color_(cfg["fill_color"], color_t::null_color())
|
||||
{
|
||||
|
@ -420,7 +420,7 @@ text_shape::text_shape(const config& cfg, wfl::action_function_symbol_table& fun
|
|||
, link_aware_(cfg["text_link_aware"], false)
|
||||
, link_color_(cfg["text_link_color"], color_t::from_hex_string("ffff00"))
|
||||
, maximum_width_(cfg["maximum_width"], -1)
|
||||
, characters_per_line_(cfg["text_characters_per_line"])
|
||||
, characters_per_line_(cfg["text_characters_per_line"].to_unsigned())
|
||||
, maximum_height_(cfg["maximum_height"], -1)
|
||||
, highlight_start_(cfg["highlight_start"])
|
||||
, highlight_end_(cfg["highlight_end"])
|
||||
|
@ -699,7 +699,7 @@ void canvas::parse_cfg(const config& cfg)
|
|||
for(const auto [func_key, func_cfg] : data.all_children_range())
|
||||
{
|
||||
if(func_key == "blur") {
|
||||
blur_depth_ = func_cfg["depth"];
|
||||
blur_depth_ = func_cfg["depth"].to_unsigned();
|
||||
} else {
|
||||
ERR_GUI_P << "Canvas: found a pre commit function"
|
||||
<< " of an invalid type " << type << ".";
|
||||
|
|
|
@ -124,12 +124,12 @@ gui_definition::gui_definition(const config& cfg)
|
|||
*/
|
||||
const config& settings = cfg.mandatory_child("settings");
|
||||
|
||||
popup_show_delay_ = settings["popup_show_delay"];
|
||||
popup_show_time_ = settings["popup_show_time"];
|
||||
help_show_time_ = settings["help_show_time"];
|
||||
double_click_time_ = settings["double_click_time"];
|
||||
popup_show_delay_ = settings["popup_show_delay"].to_unsigned();
|
||||
popup_show_time_ = settings["popup_show_time"].to_unsigned();
|
||||
help_show_time_ = settings["help_show_time"].to_unsigned();
|
||||
double_click_time_ = settings["double_click_time"].to_unsigned();
|
||||
|
||||
repeat_button_repeat_time_ = settings["repeat_button_repeat_time"];
|
||||
repeat_button_repeat_time_ = settings["repeat_button_repeat_time"].to_unsigned();
|
||||
|
||||
VALIDATE(double_click_time_, missing_mandatory_wml_key("settings", "double_click_time"));
|
||||
|
||||
|
@ -138,7 +138,7 @@ gui_definition::gui_definition(const config& cfg)
|
|||
sound_toggle_panel_click_ = settings["sound_toggle_panel_click"].str();
|
||||
sound_slider_adjust_ = settings["sound_slider_adjust"].str();
|
||||
|
||||
has_helptip_message_ = settings["has_helptip_message"];
|
||||
has_helptip_message_ = settings["has_helptip_message"].t_str();
|
||||
|
||||
VALIDATE(!has_helptip_message_.empty(), missing_mandatory_wml_key("settings", "has_helptip_message"));
|
||||
}
|
||||
|
|
|
@ -30,17 +30,17 @@ state_definition::state_definition(const config& cfg)
|
|||
{}
|
||||
|
||||
resolution_definition::resolution_definition(const config& cfg)
|
||||
: window_width(cfg["window_width"])
|
||||
, window_height(cfg["window_height"])
|
||||
, min_width(cfg["min_width"])
|
||||
, min_height(cfg["min_height"])
|
||||
, default_width(cfg["default_width"])
|
||||
, default_height(cfg["default_height"])
|
||||
, max_width(cfg["max_width"])
|
||||
, max_height(cfg["max_height"])
|
||||
: window_width(cfg["window_width"].to_unsigned())
|
||||
, window_height(cfg["window_height"].to_unsigned())
|
||||
, min_width(cfg["min_width"].to_unsigned())
|
||||
, min_height(cfg["min_height"].to_unsigned())
|
||||
, default_width(cfg["default_width"].to_unsigned())
|
||||
, default_height(cfg["default_height"].to_unsigned())
|
||||
, max_width(cfg["max_width"].to_unsigned())
|
||||
, max_height(cfg["max_height"].to_unsigned())
|
||||
, linked_groups()
|
||||
, text_extra_width(cfg["text_extra_width"])
|
||||
, text_extra_height(cfg["text_extra_height"])
|
||||
, text_extra_width(cfg["text_extra_width"].to_unsigned())
|
||||
, text_extra_height(cfg["text_extra_height"].to_unsigned())
|
||||
, text_font_size(cfg["text_font_size"])
|
||||
, text_font_family(font::str_to_family_class(cfg["text_font_family"]))
|
||||
, text_font_style(decode_font_style(cfg["text_font_style"]))
|
||||
|
|
|
@ -137,8 +137,8 @@ void builder_window::read(const config& cfg)
|
|||
}
|
||||
|
||||
builder_window::window_resolution::window_resolution(const config& cfg)
|
||||
: window_width(cfg["window_width"])
|
||||
, window_height(cfg["window_height"])
|
||||
: window_width(cfg["window_width"].to_unsigned())
|
||||
, window_height(cfg["window_height"].to_unsigned())
|
||||
, automatic_placement(cfg["automatic_placement"].to_bool(true))
|
||||
, x(cfg["x"])
|
||||
, y(cfg["y"])
|
||||
|
@ -202,13 +202,13 @@ builder_grid::builder_grid(const config& cfg)
|
|||
for(const auto& row : cfg.child_range("row")) {
|
||||
unsigned col = 0;
|
||||
|
||||
row_grow_factor.push_back(row["grow_factor"]);
|
||||
row_grow_factor.push_back(row["grow_factor"].to_unsigned());
|
||||
|
||||
for(const auto& c : row.child_range("column")) {
|
||||
flags.push_back(implementation::read_flags(c));
|
||||
border_size.push_back(c["border_size"]);
|
||||
border_size.push_back(c["border_size"].to_unsigned());
|
||||
if(rows == 0) {
|
||||
col_grow_factor.push_back(c["grow_factor"]);
|
||||
col_grow_factor.push_back(c["grow_factor"].to_unsigned());
|
||||
}
|
||||
|
||||
widgets.push_back(create_widget_builder(c));
|
||||
|
|
|
@ -100,7 +100,7 @@ void campaign_selection::campaign_selected()
|
|||
laurel = game_config::images::victory_laurel;
|
||||
}
|
||||
|
||||
entry["image"] = laurel + "~BLIT(" + entry["image"] + ")";
|
||||
entry["image"] = laurel + "~BLIT(" + entry["image"].str() + ")";
|
||||
}
|
||||
|
||||
if(!cfg["description"].empty()) {
|
||||
|
|
|
@ -583,7 +583,7 @@ void editor_edit_unit::save_unit_type() {
|
|||
void editor_edit_unit::update_resistances() {
|
||||
find_widget<slider>("resistances_slider")
|
||||
.set_value(
|
||||
100 - resistances_[find_widget<menu_button>("resistances_list").get_value_string()]);
|
||||
100 - resistances_[find_widget<menu_button>("resistances_list").get_value_string()].to_int());
|
||||
|
||||
find_widget<slider>("resistances_slider")
|
||||
.set_active(res_toggles_[find_widget<menu_button>("resistances_list").get_value()]);
|
||||
|
@ -606,7 +606,7 @@ void editor_edit_unit::enable_resistances_slider() {
|
|||
void editor_edit_unit::update_defenses() {
|
||||
find_widget<slider>("defense_slider")
|
||||
.set_value(
|
||||
100 - defenses_[find_widget<menu_button>("defense_list").get_value_string()]);
|
||||
100 - defenses_[find_widget<menu_button>("defense_list").get_value_string()].to_int());
|
||||
|
||||
find_widget<slider>("defense_slider")
|
||||
.set_active(def_toggles_[find_widget<menu_button>("defense_list").get_value()]);
|
||||
|
@ -629,7 +629,7 @@ void editor_edit_unit::enable_defense_slider() {
|
|||
void editor_edit_unit::update_movement_costs() {
|
||||
find_widget<slider>("movement_costs_slider")
|
||||
.set_value(
|
||||
movement_[find_widget<menu_button>("movement_costs_list").get_value_string()]);
|
||||
movement_[find_widget<menu_button>("movement_costs_list").get_value_string()].to_int());
|
||||
|
||||
find_widget<slider>("movement_costs_slider")
|
||||
.set_active(move_toggles_[find_widget<menu_button>("movement_costs_list").get_value()]);
|
||||
|
@ -693,8 +693,8 @@ void editor_edit_unit::update_attacks() {
|
|||
find_widget<text_box>("atk_name_box").set_value(attack["description"]);
|
||||
find_widget<text_box>("path_attack_image").set_value(attack["icon"]);
|
||||
update_image("attack_image");
|
||||
find_widget<slider>("dmg_box").set_value(attack["damage"]);
|
||||
find_widget<slider>("dmg_num_box").set_value(attack["number"]);
|
||||
find_widget<slider>("dmg_box").set_value(attack["damage"].to_int());
|
||||
find_widget<slider>("dmg_num_box").set_value(attack["number"].to_int());
|
||||
find_widget<combobox>("range_list").set_value(attack["range"]);
|
||||
|
||||
set_selected_from_string(
|
||||
|
|
|
@ -433,7 +433,7 @@ void mp_join_game::generate_side_list()
|
|||
data.emplace("side_gold", item);
|
||||
}
|
||||
|
||||
const int income_amt = side["income"];
|
||||
const int income_amt = side["income"].to_int();
|
||||
if(income_amt != 0) {
|
||||
const std::string income_string = formatter() << (income_amt > 0 ? "+" : "") << income_amt << " " << _("Income");
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ namespace implementation
|
|||
builder_button::builder_button(const config& cfg)
|
||||
: builder_styled_widget(cfg)
|
||||
, retval_id_(cfg["return_value_id"])
|
||||
, retval_(cfg["return_value"])
|
||||
, retval_(cfg["return_value"].to_int())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -420,7 +420,7 @@ namespace implementation
|
|||
|
||||
builder_combobox::builder_combobox(const config& cfg)
|
||||
: builder_styled_widget(cfg)
|
||||
, max_input_length(cfg["max_input_length"])
|
||||
, max_input_length(cfg["max_input_length"].to_size_t())
|
||||
, hint_text(cfg["hint_text"].t_str())
|
||||
, hint_image(cfg["hint_image"])
|
||||
, options_()
|
||||
|
|
|
@ -114,10 +114,10 @@ horizontal_scrollbar_definition::horizontal_scrollbar_definition(
|
|||
|
||||
horizontal_scrollbar_definition::resolution::resolution(const config& cfg)
|
||||
: resolution_definition(cfg)
|
||||
, minimum_positioner_length(cfg["minimum_positioner_length"])
|
||||
, maximum_positioner_length(cfg["maximum_positioner_length"])
|
||||
, left_offset(cfg["left_offset"])
|
||||
, right_offset(cfg["right_offset"])
|
||||
, minimum_positioner_length(cfg["minimum_positioner_length"].to_unsigned())
|
||||
, maximum_positioner_length(cfg["maximum_positioner_length"].to_unsigned())
|
||||
, left_offset(cfg["left_offset"].to_unsigned())
|
||||
, right_offset(cfg["right_offset"].to_unsigned())
|
||||
{
|
||||
VALIDATE(minimum_positioner_length,
|
||||
missing_mandatory_wml_key("resolution",
|
||||
|
|
|
@ -246,7 +246,7 @@ namespace implementation
|
|||
builder_label::builder_label(const config& cfg)
|
||||
: builder_styled_widget(cfg)
|
||||
, wrap(cfg["wrap"].to_bool())
|
||||
, characters_per_line(cfg["characters_per_line"])
|
||||
, characters_per_line(cfg["characters_per_line"].to_unsigned())
|
||||
, text_alignment(decode_text_alignment(cfg["text_alignment"]))
|
||||
, can_shrink(cfg["can_shrink"].to_bool(false))
|
||||
, link_aware(cfg["link_aware"].to_bool(false))
|
||||
|
|
|
@ -490,7 +490,7 @@ namespace implementation
|
|||
builder_multiline_text::builder_multiline_text(const config& cfg)
|
||||
: builder_styled_widget(cfg)
|
||||
, history(cfg["history"])
|
||||
, max_input_length(cfg["max_input_length"])
|
||||
, max_input_length(cfg["max_input_length"].to_size_t())
|
||||
, hint_text(cfg["hint_text"].t_str())
|
||||
, hint_image(cfg["hint_image"])
|
||||
, editable(cfg["editable"].to_bool(true))
|
||||
|
|
|
@ -355,7 +355,7 @@ namespace implementation
|
|||
builder_pane::builder_pane(const config& cfg)
|
||||
: builder_widget(cfg)
|
||||
, grow_dir(*grow_direction::get_enum(cfg["grow_direction"].str()))
|
||||
, parallel_items(cfg["parallel_items"])
|
||||
, parallel_items(cfg["parallel_items"].to_int())
|
||||
, item_definition(new builder_grid(VALIDATE_WML_CHILD(cfg, "item_definition", missing_mandatory_wml_tag("pane", "item_definition"))))
|
||||
{
|
||||
VALIDATE(parallel_items > 0, _("Need at least 1 parallel item."));
|
||||
|
|
|
@ -108,10 +108,10 @@ panel_definition::panel_definition(const config& cfg)
|
|||
|
||||
panel_definition::resolution::resolution(const config& cfg)
|
||||
: resolution_definition(cfg)
|
||||
, top_border(cfg["top_border"])
|
||||
, bottom_border(cfg["bottom_border"])
|
||||
, left_border(cfg["left_border"])
|
||||
, right_border(cfg["right_border"])
|
||||
, top_border(cfg["top_border"].to_unsigned())
|
||||
, bottom_border(cfg["bottom_border"].to_unsigned())
|
||||
, left_border(cfg["left_border"].to_unsigned())
|
||||
, right_border(cfg["right_border"].to_unsigned())
|
||||
{
|
||||
// The panel needs to know the order.
|
||||
state.emplace_back(VALIDATE_WML_CHILD(cfg, "background", missing_mandatory_wml_tag("panel_definition][resolution", "background")));
|
||||
|
|
|
@ -302,9 +302,9 @@ slider_definition::slider_definition(const config& cfg)
|
|||
|
||||
slider_definition::resolution::resolution(const config& cfg)
|
||||
: resolution_definition(cfg)
|
||||
, positioner_length(cfg["minimum_positioner_length"])
|
||||
, left_offset(cfg["left_offset"])
|
||||
, right_offset(cfg["right_offset"])
|
||||
, positioner_length(cfg["minimum_positioner_length"].to_unsigned())
|
||||
, left_offset(cfg["left_offset"].to_unsigned())
|
||||
, right_offset(cfg["right_offset"].to_unsigned())
|
||||
{
|
||||
VALIDATE(positioner_length, missing_mandatory_wml_key("resolution", "minimum_positioner_length"));
|
||||
|
||||
|
@ -321,11 +321,11 @@ namespace implementation
|
|||
{
|
||||
builder_slider::builder_slider(const config& cfg)
|
||||
: implementation::builder_styled_widget(cfg)
|
||||
, best_slider_length_(cfg["best_slider_length"])
|
||||
, minimum_value_(cfg["minimum_value"])
|
||||
, maximum_value_(cfg["maximum_value"])
|
||||
, best_slider_length_(cfg["best_slider_length"].to_unsigned())
|
||||
, minimum_value_(cfg["minimum_value"].to_int())
|
||||
, maximum_value_(cfg["maximum_value"].to_int())
|
||||
, step_size_(cfg["step_size"].to_int(1))
|
||||
, value_(cfg["value"])
|
||||
, value_(cfg["value"].to_int())
|
||||
, minimum_value_label_(cfg["minimum_value_label"].t_str())
|
||||
, maximum_value_label_(cfg["maximum_value_label"].t_str())
|
||||
, value_labels_()
|
||||
|
|
|
@ -420,7 +420,7 @@ namespace implementation
|
|||
builder_text_box::builder_text_box(const config& cfg)
|
||||
: builder_styled_widget(cfg)
|
||||
, history(cfg["history"])
|
||||
, max_input_length(cfg["max_input_length"])
|
||||
, max_input_length(cfg["max_input_length"].to_size_t())
|
||||
, hint_text(cfg["hint_text"].t_str())
|
||||
, hint_image(cfg["hint_image"])
|
||||
, editable(cfg["editable"].to_bool(true))
|
||||
|
|
|
@ -225,7 +225,7 @@ builder_toggle_button::builder_toggle_button(const config& cfg)
|
|||
: builder_styled_widget(cfg)
|
||||
, icon_name_(cfg["icon"])
|
||||
, retval_id_(cfg["return_value_id"])
|
||||
, retval_(cfg["return_value"])
|
||||
, retval_(cfg["return_value"].to_int())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -291,10 +291,10 @@ toggle_panel_definition::toggle_panel_definition(const config& cfg)
|
|||
|
||||
toggle_panel_definition::resolution::resolution(const config& cfg)
|
||||
: resolution_definition(cfg)
|
||||
, top_border(cfg["top_border"])
|
||||
, bottom_border(cfg["bottom_border"])
|
||||
, left_border(cfg["left_border"])
|
||||
, right_border(cfg["right_border"])
|
||||
, top_border(cfg["top_border"].to_unsigned())
|
||||
, bottom_border(cfg["bottom_border"].to_unsigned())
|
||||
, left_border(cfg["left_border"].to_unsigned())
|
||||
, right_border(cfg["right_border"].to_unsigned())
|
||||
{
|
||||
// Note the order should be the same as the enum state_t in toggle_panel.hpp.
|
||||
for(const auto& c : cfg.child_range("state"))
|
||||
|
@ -314,7 +314,7 @@ builder_toggle_panel::builder_toggle_panel(const config& cfg)
|
|||
: builder_styled_widget(cfg)
|
||||
, grid(nullptr)
|
||||
, retval_id_(cfg["return_value_id"])
|
||||
, retval_(cfg["return_value"])
|
||||
, retval_(cfg["return_value"].to_int())
|
||||
{
|
||||
auto c = cfg.optional_child("grid");
|
||||
|
||||
|
|
|
@ -280,7 +280,7 @@ builder_tree_view::builder_tree_view(const config& cfg)
|
|||
: builder_styled_widget(cfg)
|
||||
, vertical_scrollbar_mode(get_scrollbar_mode(cfg["vertical_scrollbar_mode"]))
|
||||
, horizontal_scrollbar_mode(get_scrollbar_mode(cfg["horizontal_scrollbar_mode"]))
|
||||
, indentation_step_size(cfg["indentation_step_size"])
|
||||
, indentation_step_size(cfg["indentation_step_size"].to_unsigned())
|
||||
, nodes()
|
||||
{
|
||||
for(const auto& node : cfg.child_range("node")) {
|
||||
|
|
|
@ -107,10 +107,10 @@ vertical_scrollbar_definition::vertical_scrollbar_definition(
|
|||
|
||||
vertical_scrollbar_definition::resolution::resolution(const config& cfg)
|
||||
: resolution_definition(cfg)
|
||||
, minimum_positioner_length(cfg["minimum_positioner_length"])
|
||||
, maximum_positioner_length(cfg["maximum_positioner_length"])
|
||||
, top_offset(cfg["top_offset"])
|
||||
, bottom_offset(cfg["bottom_offset"])
|
||||
, minimum_positioner_length(cfg["minimum_positioner_length"].to_unsigned())
|
||||
, maximum_positioner_length(cfg["maximum_positioner_length"].to_unsigned())
|
||||
, top_offset(cfg["top_offset"].to_unsigned())
|
||||
, bottom_offset(cfg["bottom_offset"].to_unsigned())
|
||||
{
|
||||
VALIDATE(minimum_positioner_length,
|
||||
missing_mandatory_wml_key("resolution",
|
||||
|
|
|
@ -1475,7 +1475,7 @@ static config parse_text_until(std::string::const_iterator& beg, std::string::co
|
|||
throw parse_error("unexpected eos after entity");
|
||||
}
|
||||
if(entity.has_attribute("code_point")) {
|
||||
s << unicode_cast<std::string>(entity["code_point"]);
|
||||
s << unicode_cast<std::string>(entity["code_point"].to_int());
|
||||
} else {
|
||||
// TODO: Adding the text here seems wrong in the case that the stream BEGINS with an entity...
|
||||
res.add_child("text", config("text", s.str()));
|
||||
|
@ -1555,7 +1555,7 @@ static std::pair<std::string, std::string> parse_attribute(std::string::const_it
|
|||
throw parse_error("unexpected eos after entity");
|
||||
}
|
||||
if(entity.has_attribute("code_point")) {
|
||||
s << unicode_cast<std::string>(entity["code_point"]);
|
||||
s << unicode_cast<std::string>(entity["code_point"].to_int());
|
||||
} else {
|
||||
throw parse_error("unsupported entity in attribute value");
|
||||
}
|
||||
|
|
|
@ -45,6 +45,11 @@ std::ostream &operator<<(std::ostream &s, const std::vector<map_location>& v) {
|
|||
return s;
|
||||
}
|
||||
|
||||
map_location::map_location(const config_attribute_value& x, const config_attribute_value& y, wml_loc)
|
||||
: map_location(x.to_int(), y.to_int(), wml_loc{})
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Default list of directions
|
||||
*
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#pragma once
|
||||
|
||||
class config;
|
||||
class config_attribute_value;
|
||||
class variable_set;
|
||||
|
||||
#include <array>
|
||||
|
@ -76,6 +77,7 @@ struct map_location {
|
|||
map_location() : x(-1000), y(-1000) {}
|
||||
map_location(int x, int y) : x(x), y(y) {}
|
||||
map_location(int x, int y, wml_loc) : x(x - 1), y(y - 1) {}
|
||||
map_location(const config_attribute_value& x, const config_attribute_value& y, wml_loc);
|
||||
map_location(const config& cfg, const variable_set *variables = nullptr);
|
||||
|
||||
static const map_location & ZERO()
|
||||
|
|
|
@ -69,14 +69,14 @@ mp_game_settings::mp_game_settings(const config& cfg)
|
|||
, mp_scenario_name(cfg["mp_scenario_name"].str())
|
||||
, mp_campaign(cfg["mp_campaign"].str())
|
||||
, side_users(utils::map_split(cfg["side_users"]))
|
||||
, num_turns(cfg["mp_num_turns"])
|
||||
, village_gold(cfg["mp_village_gold"])
|
||||
, village_support(cfg["mp_village_support"])
|
||||
, num_turns(cfg["mp_num_turns"].to_int())
|
||||
, village_gold(cfg["mp_village_gold"].to_int())
|
||||
, village_support(cfg["mp_village_support"].to_int())
|
||||
, xp_modifier(cfg["experience_modifier"].to_int(100))
|
||||
, mp_countdown_init_time(cfg["mp_countdown_init_time"])
|
||||
, mp_countdown_reservoir_time(cfg["mp_countdown_reservoir_time"])
|
||||
, mp_countdown_turn_bonus(cfg["mp_countdown_turn_bonus"])
|
||||
, mp_countdown_action_bonus(cfg["mp_countdown_action_bonus"])
|
||||
, mp_countdown_init_time(cfg["mp_countdown_init_time"].to_int())
|
||||
, mp_countdown_reservoir_time(cfg["mp_countdown_reservoir_time"].to_int())
|
||||
, mp_countdown_turn_bonus(cfg["mp_countdown_turn_bonus"].to_int())
|
||||
, mp_countdown_action_bonus(cfg["mp_countdown_action_bonus"].to_int())
|
||||
, mp_countdown(cfg["mp_countdown"].to_bool())
|
||||
, use_map_settings(cfg["mp_use_map_settings"].to_bool())
|
||||
, random_start_time(cfg["mp_random_start_time"].to_bool())
|
||||
|
|
|
@ -170,7 +170,7 @@ void verify_and_set_global_variable(const vconfig &pcfg)
|
|||
}
|
||||
if (resources::controller->is_networked_mp()) {
|
||||
config::attribute_value pcfg_side = pcfg["side"];
|
||||
int side = pcfg_side;
|
||||
int side = pcfg_side.to_int();
|
||||
//Check side matching only if the side is not "global" or empty.
|
||||
if (pcfg_side.str() != "global" && !pcfg_side.empty()) {
|
||||
//Ensure that the side is valid.
|
||||
|
|
|
@ -403,7 +403,7 @@ playmp_controller::PROCESS_DATA_RESULT playmp_controller::process_network_data_i
|
|||
|
||||
if (const auto message = cfg.optional_child("message"))
|
||||
{
|
||||
game_display::get_singleton()->get_chat_manager().add_chat_message(std::time(nullptr), message.value()["sender"], message.value()["side"],
|
||||
game_display::get_singleton()->get_chat_manager().add_chat_message(std::time(nullptr), message.value()["sender"], message.value()["side"].to_int(),
|
||||
message.value()["message"], events::chat_handler::MESSAGE_PUBLIC,
|
||||
prefs::get().message_bell());
|
||||
}
|
||||
|
|
|
@ -330,7 +330,7 @@ void playsingle_controller::play_scenario_main_loop()
|
|||
get_saved_game().statistics().clear_current_scenario();
|
||||
}
|
||||
|
||||
reset_gamestate(*ex.level, (*ex.level)["replay_pos"]);
|
||||
reset_gamestate(*ex.level, (*ex.level)["replay_pos"].to_int());
|
||||
|
||||
for(std::size_t i = 0; i < local_players.size(); ++i) {
|
||||
resources::gameboard->teams()[i].set_local(local_players[i]);
|
||||
|
|
|
@ -931,7 +931,7 @@ bool prefs::use_twelve_hour_clock_format()
|
|||
|
||||
sort_order::type prefs::addon_manager_saved_order_direction()
|
||||
{
|
||||
return sort_order::get_enum(preferences_[prefs_list::addon_manager_saved_order_direction]).value_or(sort_order::type::none);
|
||||
return sort_order::get_enum(preferences_[prefs_list::addon_manager_saved_order_direction].to_int()).value_or(sort_order::type::none);
|
||||
}
|
||||
|
||||
void prefs::set_addon_manager_saved_order_direction(sort_order::type value)
|
||||
|
@ -1640,7 +1640,7 @@ void prefs::clear_countdown_turn_bonus()
|
|||
|
||||
int prefs::countdown_action_bonus()
|
||||
{
|
||||
return std::clamp<int>(preferences_[prefs_list::mp_countdown_action_bonus], 0, 30);
|
||||
return std::clamp<int>(preferences_[prefs_list::mp_countdown_action_bonus].to_int(), 0, 30);
|
||||
}
|
||||
|
||||
void prefs::set_countdown_action_bonus(int value)
|
||||
|
|
|
@ -769,7 +769,7 @@ REPLAY_RETURN do_replay_handle(bool one_move)
|
|||
if(resources::recorder->add_chat_message_location()) {
|
||||
DBG_REPLAY << "tried to add a chat message twice.";
|
||||
if (!resources::controller->is_skipping_replay() || is_whisper) {
|
||||
int side = speak["side"];
|
||||
int side = speak["side"].to_int();
|
||||
game_display::get_singleton()->get_chat_manager().add_chat_message(get_time(*speak), speaker_name, side, message,
|
||||
(team_name.empty() ? events::chat_handler::MESSAGE_PUBLIC
|
||||
: events::chat_handler::MESSAGE_PRIVATE),
|
||||
|
@ -856,8 +856,8 @@ REPLAY_RETURN do_replay_handle(bool one_move)
|
|||
}
|
||||
else if (auto countdown_update = cfg->optional_child("countdown_update"))
|
||||
{
|
||||
int val = countdown_update["value"];
|
||||
int tval = countdown_update["team"];
|
||||
int val = countdown_update["value"].to_int();
|
||||
int tval = countdown_update["team"].to_int();
|
||||
if (tval <= 0 || tval > static_cast<int>(resources::gameboard->teams().size())) {
|
||||
std::stringstream errbuf;
|
||||
errbuf << "Illegal countdown update \n"
|
||||
|
|
|
@ -452,7 +452,7 @@ void extract_summary_from_config(config& cfg_save, config& cfg_summary)
|
|||
std::string leader_image;
|
||||
std::string leader_image_tc_modifier;
|
||||
std::string leader_name;
|
||||
int gold = side["gold"];
|
||||
int gold = side["gold"].to_int();
|
||||
int units = 0, recall_units = 0;
|
||||
|
||||
if(side["controller"] != side_controller::human) {
|
||||
|
|
|
@ -180,7 +180,7 @@ public:
|
|||
/** Build the filename according to the specific savegame's needs. */
|
||||
std::string create_filename() const
|
||||
{
|
||||
return create_filename(gamestate().get_starting_point()["turn_at"]);
|
||||
return create_filename(gamestate().get_starting_point()["turn_at"].to_int());
|
||||
}
|
||||
|
||||
/** Build the filename for the specified turn. */
|
||||
|
|
|
@ -2772,8 +2772,8 @@ int game_lua_kernel::intf_put_unit(lua_State *L)
|
|||
const vconfig* vcfg = nullptr;
|
||||
config cfg = luaW_checkconfig(L, 1, vcfg);
|
||||
if (!map().on_board(loc)) {
|
||||
loc.set_wml_x(cfg["x"]);
|
||||
loc.set_wml_y(cfg["y"]);
|
||||
loc.set_wml_x(cfg["x"].to_int());
|
||||
loc.set_wml_y(cfg["y"].to_int());
|
||||
if (!map().on_board(loc))
|
||||
return luaL_argerror(L, 2, "invalid location");
|
||||
}
|
||||
|
@ -4554,7 +4554,7 @@ static int intf_modify_ai_old(lua_State *L)
|
|||
{
|
||||
config cfg;
|
||||
luaW_toconfig(L, 1, cfg);
|
||||
int side = cfg["side"];
|
||||
int side = cfg["side"].to_int();
|
||||
ai::manager::get_singleton().modify_active_ai_for_side(side, cfg);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ static int impl_music_set(lua_State* L) {
|
|||
// Don't clear the playlist
|
||||
cfg["append"] = true;
|
||||
// Don't allow play_once=yes
|
||||
if(cfg["play_once"]) {
|
||||
if(cfg["play_once"].to_bool()) {
|
||||
return luaL_argerror(L, 3, "For play_once, use wesnoth.music_list.play instead");
|
||||
}
|
||||
if(i >= sound::get_num_tracks()) {
|
||||
|
|
|
@ -212,7 +212,7 @@ void preproc_define::read(const config& cfg)
|
|||
{
|
||||
value = cfg["value"].str();
|
||||
textdomain = cfg["textdomain"].str();
|
||||
linenum = cfg["linenum"];
|
||||
linenum = cfg["linenum"].to_int();
|
||||
location = cfg["location"].str();
|
||||
|
||||
if(auto deprecated = cfg.optional_child("deprecated")) {
|
||||
|
|
|
@ -43,8 +43,8 @@ music_track::music_track(const config& node) :
|
|||
id_(node["name"]),
|
||||
file_path_(),
|
||||
title_(node["title"]),
|
||||
ms_before_(node["ms_before"]),
|
||||
ms_after_(node["ms_after"]),
|
||||
ms_before_(node["ms_before"].to_int()),
|
||||
ms_after_(node["ms_after"].to_int()),
|
||||
once_(node["play_once"].to_bool()),
|
||||
append_(node["append"].to_bool()),
|
||||
immediate_(node["immediate"].to_bool()),
|
||||
|
|
|
@ -239,7 +239,7 @@ sourcespec::sourcespec(const config& cfg) :
|
|||
files_(cfg["sounds"]),
|
||||
min_delay_(cfg["delay"].to_int(DEFAULT_DELAY)),
|
||||
chance_(cfg["chance"].to_int(DEFAULT_CHANCE)),
|
||||
loops_(cfg["loop"]),
|
||||
loops_(cfg["loop"].to_int()),
|
||||
range_(cfg["full_range"].to_int(3)),
|
||||
faderange_(cfg["fade_range"].to_int(14)),
|
||||
check_fogged_(cfg["check_fogged"].to_bool(true)),
|
||||
|
|
|
@ -104,7 +104,7 @@ static stats_t::battle_result_map read_battle_result_map(const config& cfg)
|
|||
stats_t::battle_result_map m;
|
||||
for(const config& i : cfg.child_range("sequence")) {
|
||||
config item = i;
|
||||
int key = item["_num"];
|
||||
int key = item["_num"].to_int();
|
||||
item.remove_attribute("_num");
|
||||
m[key] = read_str_int_map(item);
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ static stats_t::hitrate_map read_by_cth_map(const config& cfg)
|
|||
{
|
||||
stats_t::hitrate_map m;
|
||||
for(const config& i : cfg.child_range("hitrate_map_entry")) {
|
||||
m.emplace(i["cth"], stats_t::hitrate_t(i.mandatory_child("stats")));
|
||||
m.emplace(i["cth"].to_int(), stats_t::hitrate_t(i.mandatory_child("stats")));
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
@ -458,8 +458,8 @@ config stats_t::hitrate_t::write() const
|
|||
}
|
||||
|
||||
stats_t::hitrate_t::hitrate_t(const config& cfg)
|
||||
: strikes(cfg["strikes"])
|
||||
, hits(cfg["hits"])
|
||||
: strikes(cfg["strikes"].to_int())
|
||||
, hits(cfg["hits"].to_int())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -27,9 +27,9 @@ namespace storyscreen
|
|||
{
|
||||
floating_image::floating_image(const config& cfg)
|
||||
: file_(cfg["file"])
|
||||
, x_(cfg["x"])
|
||||
, y_(cfg["y"])
|
||||
, delay_(cfg["delay"])
|
||||
, x_(cfg["x"].to_int())
|
||||
, y_(cfg["y"].to_int())
|
||||
, delay_(cfg["delay"].to_int())
|
||||
, resize_with_background_(cfg["resize_with_background"].to_bool())
|
||||
, centered_(cfg["centered"].to_bool())
|
||||
{
|
||||
|
|
|
@ -168,7 +168,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(attack, child, /*use_undo*/, show, error_handler
|
|||
const map_location src(source.value(), resources::gamedata);
|
||||
const map_location dst(destination.value(), resources::gamedata);
|
||||
|
||||
int weapon_num = child["weapon"];
|
||||
int weapon_num = child["weapon"].to_int();
|
||||
// having defender_weapon in the replay fixes a bug (OOS) where one player (or observer) chooses a different defensive weapon.
|
||||
// Xan pointed out this was a possibility: we calculate defense weapon
|
||||
// now based on attack_prediction code, but this uses floating point
|
||||
|
|
|
@ -350,7 +350,7 @@ config synced_context::ask_server_choice(const server_choice& sch)
|
|||
}
|
||||
|
||||
config res = action->mandatory_child(sch.name());
|
||||
if(res["request_id"] != sch.request_id()) {
|
||||
if(res["request_id"].to_int() != sch.request_id()) {
|
||||
WRN_REPLAY << "Unexpected request_id: " << res["request_id"] << " expected: " << sch.request_id();
|
||||
}
|
||||
return res;
|
||||
|
|
12
src/team.cpp
12
src/team.cpp
|
@ -164,8 +164,8 @@ team::team_info::team_info()
|
|||
|
||||
void team::team_info::read(const config& cfg)
|
||||
{
|
||||
gold = cfg["gold"];
|
||||
income = cfg["income"];
|
||||
gold = cfg["gold"].to_int();
|
||||
income = cfg["income"].to_int();
|
||||
team_name = cfg["team_name"].str();
|
||||
user_team_name = cfg["user_team_name"];
|
||||
side_name = cfg["side_name"];
|
||||
|
@ -174,7 +174,7 @@ void team::team_info::read(const config& cfg)
|
|||
save_id = cfg["save_id"].str();
|
||||
current_player = cfg["current_player"].str();
|
||||
countdown_time = cfg["countdown_time"].str();
|
||||
action_bonus_count = cfg["action_bonus_count"];
|
||||
action_bonus_count = cfg["action_bonus_count"].to_int();
|
||||
flag = cfg["flag"].str();
|
||||
flag_icon = cfg["flag_icon"].str();
|
||||
id = cfg["id"].str();
|
||||
|
@ -217,7 +217,7 @@ void team::team_info::read(const config& cfg)
|
|||
// at the start of a scenario "start_gold" is not set, we need to take the
|
||||
// value from the gold setting (or fall back to the gold default)
|
||||
if(!cfg["start_gold"].empty()) {
|
||||
start_gold = cfg["start_gold"];
|
||||
start_gold = cfg["start_gold"].to_int();
|
||||
} else if(!cfg["gold"].empty()) {
|
||||
start_gold = gold;
|
||||
} else {
|
||||
|
@ -392,8 +392,8 @@ void team::build(const config& cfg, const gamemap& map, int gold)
|
|||
}
|
||||
}
|
||||
|
||||
countdown_time_ = cfg["countdown_time"];
|
||||
action_bonus_count_ = cfg["action_bonus_count"];
|
||||
countdown_time_ = cfg["countdown_time"].to_int();
|
||||
action_bonus_count_ = cfg["action_bonus_count"].to_int();
|
||||
|
||||
planned_actions_.reset(new wb::side_actions());
|
||||
planned_actions_->set_team_index(info_.side - 1);
|
||||
|
|
|
@ -112,7 +112,7 @@ void team_builder::gold()
|
|||
{
|
||||
log_step("gold");
|
||||
|
||||
gold_info_ngold_ = side_cfg_["gold"];
|
||||
gold_info_ngold_ = side_cfg_["gold"].to_int();
|
||||
|
||||
DBG_NG_TC << "set gold to '" << gold_info_ngold_ << "'";
|
||||
}
|
||||
|
|
|
@ -678,7 +678,7 @@ terrain_builder::rule_image_variant::rule_image_variant(const std::string& image
|
|||
void terrain_builder::add_images_from_config(rule_imagelist& images, const config& cfg, bool global, int dx, int dy)
|
||||
{
|
||||
for(const config& img : cfg.child_range("image")) {
|
||||
int layer = img["layer"];
|
||||
int layer = img["layer"].to_int();
|
||||
|
||||
int basex = tilewidth_ / 2 + dx, basey = tilewidth_ / 2 + dy;
|
||||
if(const config::attribute_value* base_ = img.get("base")) {
|
||||
|
@ -906,16 +906,16 @@ void terrain_builder::parse_config(const game_config_view& cfg, bool local)
|
|||
// of terrain constraints, if it does not exist.
|
||||
map_location loc;
|
||||
if(const config::attribute_value* v = tc.get("x")) {
|
||||
loc.x = *v;
|
||||
loc.x = v->to_int();
|
||||
}
|
||||
if(const config::attribute_value* v = tc.get("y")) {
|
||||
loc.y = *v;
|
||||
loc.y = v->to_int();
|
||||
}
|
||||
if(loc.valid()) {
|
||||
add_constraints(pbr.constraints, loc, tc, br);
|
||||
}
|
||||
if(const config::attribute_value* v = tc.get("pos")) {
|
||||
int pos = *v;
|
||||
int pos = v->to_int();
|
||||
if(anchors.find(pos) == anchors.end()) {
|
||||
WRN_NG << "Invalid anchor!";
|
||||
continue;
|
||||
|
@ -946,7 +946,7 @@ void terrain_builder::parse_config(const game_config_view& cfg, bool local)
|
|||
// Handles rotations
|
||||
const std::string& rotations = br["rotations"];
|
||||
|
||||
pbr.precedence = br["precedence"];
|
||||
pbr.precedence = br["precedence"].to_int();
|
||||
|
||||
add_rotated_rules(building_rules_, pbr, rotations);
|
||||
|
||||
|
|
|
@ -84,14 +84,14 @@ terrain_type::terrain_type(const config& cfg) :
|
|||
vision_type_(),
|
||||
def_type_(),
|
||||
union_type_(),
|
||||
height_adjust_(cfg["unit_height_adjust"]),
|
||||
height_adjust_(cfg["unit_height_adjust"].to_int()),
|
||||
height_adjust_set_(!cfg["unit_height_adjust"].empty()),
|
||||
submerge_(cfg["submerge"].to_double()),
|
||||
submerge_set_(!cfg["submerge"].empty()),
|
||||
light_modification_(cfg["light"]),
|
||||
light_modification_(cfg["light"].to_int()),
|
||||
max_light_(cfg["max_light"].to_int(light_modification_)),
|
||||
min_light_(cfg["min_light"].to_int(light_modification_)),
|
||||
heals_(cfg["heals"]),
|
||||
heals_(cfg["heals"].to_int()),
|
||||
income_description_(),
|
||||
income_description_ally_(),
|
||||
income_description_enemy_(),
|
||||
|
|
|
@ -229,6 +229,12 @@ BOOST_AUTO_TEST_CASE(test_config_attribute_value)
|
|||
BOOST_CHECK_EQUAL(c["x"], true);
|
||||
c["x"] = false;
|
||||
BOOST_CHECK_EQUAL(c["x"], "no");
|
||||
c["x"] = 1.23456789;
|
||||
BOOST_CHECK_EQUAL(c["x"], 1.23456789);
|
||||
#if 0 // FIXME: this should work. it doesn't work. looks like it's getting stored as 9.8765432099999995
|
||||
c["x"] = "9.87654321";
|
||||
BOOST_CHECK_EQUAL(c["x"], 9.87654321);
|
||||
#endif
|
||||
c["x"] = "sfvsdgdsfg";
|
||||
BOOST_CHECK_NE(c["x"], 0);
|
||||
BOOST_CHECK_NE(c["x"], true);
|
||||
|
|
|
@ -67,7 +67,7 @@ struct mp_connect_fixture {
|
|||
|
||||
state->set_scenario(config_manager->game_config().find_mandatory_child("multiplayer", "id", state->mp_settings().name));
|
||||
|
||||
state->mp_settings().num_turns = state->get_starting_point()["turns"];
|
||||
state->mp_settings().num_turns = state->get_starting_point()["turns"].to_int();
|
||||
|
||||
rng.reset(new randomness::mt_rng());
|
||||
}
|
||||
|
|
|
@ -433,7 +433,7 @@ theme::label::label(std::size_t sw, std::size_t sh, const config& cfg)
|
|||
: object(sw, sh, cfg)
|
||||
, text_(cfg["prefix"].str() + cfg["prefix_literal"].str() + cfg["text"].str() + cfg["postfix_literal"].str() + cfg["postfix"].str())
|
||||
, icon_(cfg["icon"])
|
||||
, font_(cfg["font_size"])
|
||||
, font_(cfg["font_size"].to_size_t())
|
||||
, font_rgb_set_(false)
|
||||
, font_rgb_(DefaultFontRGB)
|
||||
{
|
||||
|
@ -451,7 +451,7 @@ theme::status_item::status_item(std::size_t sw, std::size_t sh, const config& cf
|
|||
, prefix_(cfg["prefix"].str() + cfg["prefix_literal"].str())
|
||||
, postfix_(cfg["postfix_literal"].str() + cfg["postfix"].str())
|
||||
, label_()
|
||||
, font_(cfg["font_size"])
|
||||
, font_(cfg["font_size"].to_size_t())
|
||||
, font_rgb_set_(false)
|
||||
, font_rgb_(DefaultFontRGB)
|
||||
{
|
||||
|
@ -610,8 +610,8 @@ bool theme::set_resolution(const SDL_Rect& screen)
|
|||
int current_rating = 1000000;
|
||||
const config* current = nullptr;
|
||||
for(const config& i : cfg_.child_range("resolution")) {
|
||||
int width = i["width"];
|
||||
int height = i["height"];
|
||||
int width = i["width"].to_int();
|
||||
int height = i["height"].to_int();
|
||||
LOG_DP << "comparing resolution " << screen.w << "," << screen.h << " to " << width << "," << height;
|
||||
if(screen.w >= width && screen.h >= height) {
|
||||
LOG_DP << "loading theme: " << width << "," << height;
|
||||
|
@ -633,8 +633,8 @@ bool theme::set_resolution(const SDL_Rect& screen)
|
|||
}
|
||||
return false;
|
||||
}
|
||||
cur_spec_width_ = (*current)["width"];
|
||||
cur_spec_height_ = (*current)["height"];
|
||||
cur_spec_width_ = (*current)["width"].to_size_t();
|
||||
cur_spec_height_ = (*current)["height"].to_size_t();
|
||||
|
||||
std::map<std::string, std::string> title_stash_menus;
|
||||
std::vector<theme::menu>::iterator m;
|
||||
|
|
|
@ -25,14 +25,14 @@ std::ostream& operator<<(std::ostream& s, const tod_color& c)
|
|||
}
|
||||
|
||||
time_of_day::time_of_day(const config& cfg)
|
||||
: lawful_bonus(cfg["lawful_bonus"])
|
||||
: lawful_bonus(cfg["lawful_bonus"].to_int())
|
||||
, bonus_modified(0)
|
||||
, image(cfg["image"])
|
||||
, name(cfg["name"].t_str())
|
||||
, description(cfg["description"].t_str())
|
||||
, id(cfg["id"])
|
||||
, image_mask(cfg["mask"])
|
||||
, color(cfg["red"], cfg["green"], cfg["blue"])
|
||||
, color(cfg["red"].to_int(), cfg["green"].to_int(), cfg["blue"].to_int())
|
||||
, sounds(cfg["sound"])
|
||||
{
|
||||
}
|
||||
|
|
|
@ -276,8 +276,8 @@ unit_animation::unit_animation(const config& cfg,const std::string& frame_string
|
|||
, unit_filter_()
|
||||
, secondary_unit_filter_()
|
||||
, directions_()
|
||||
, frequency_(cfg["frequency"])
|
||||
, base_score_(cfg["base_score"])
|
||||
, frequency_(cfg["frequency"].to_int())
|
||||
, base_score_(cfg["base_score"].to_int())
|
||||
, event_()
|
||||
, value_()
|
||||
, primary_attack_filter_()
|
||||
|
@ -936,7 +936,7 @@ unit_animation::particle::particle(const config& cfg, const std::string& frame_s
|
|||
starting_frame_time_ = std::min(starting_frame_time_, frame["begin"].to_int());
|
||||
}
|
||||
} else {
|
||||
starting_frame_time_ = cfg[frame_string + "start_time"];
|
||||
starting_frame_time_ = cfg[frame_string + "start_time"].to_int();
|
||||
}
|
||||
|
||||
for(const config& frame : range) {
|
||||
|
|
|
@ -81,14 +81,14 @@ attack_type::attack_type(const config& cfg) :
|
|||
min_range_(cfg["min_range"].to_int(1)),
|
||||
max_range_(cfg["max_range"].to_int(1)),
|
||||
alignment_str_(),
|
||||
damage_(cfg["damage"]),
|
||||
num_attacks_(cfg["number"]),
|
||||
damage_(cfg["damage"].to_int()),
|
||||
num_attacks_(cfg["number"].to_int()),
|
||||
attack_weight_(cfg["attack_weight"].to_double(1.0)),
|
||||
defense_weight_(cfg["defense_weight"].to_double(1.0)),
|
||||
accuracy_(cfg["accuracy"]),
|
||||
accuracy_(cfg["accuracy"].to_int()),
|
||||
movement_used_(cfg["movement_used"].to_int(100000)),
|
||||
attacks_used_(cfg["attacks_used"].to_int(1)),
|
||||
parry_(cfg["parry"]),
|
||||
parry_(cfg["parry"].to_int()),
|
||||
specials_(cfg.child_or_empty("specials")),
|
||||
changed_(true)
|
||||
{
|
||||
|
|
|
@ -80,7 +80,7 @@ frame_builder::frame_builder(const config& cfg,const std::string& frame_string)
|
|||
}
|
||||
|
||||
if(const config::attribute_value* v = cfg.get(frame_string + "duration")) {
|
||||
duration(*v);
|
||||
duration(v->to_int());
|
||||
} else if(!cfg.get(frame_string + "end")) {
|
||||
int halo_duration = (progressive_string(halo_, 1)).duration();
|
||||
int image_duration = (progressive_image(image_, 1)).duration();
|
||||
|
|
|
@ -70,7 +70,7 @@ unit_race::unit_race(const config& cfg) :
|
|||
icon_(cfg["editor_icon"]),
|
||||
plural_name_(cfg["plural_name"].t_str()),
|
||||
description_(cfg["description"].t_str()),
|
||||
ntraits_(cfg["num_traits"]),
|
||||
ntraits_(cfg["num_traits"].to_int()),
|
||||
traits_(cfg.child_range("trait")),
|
||||
topics_(cfg.child_range("topic")),
|
||||
global_traits_(!cfg["ignore_global_traits"].to_bool()),
|
||||
|
|
|
@ -247,7 +247,7 @@ void unit_type::build_help_index(
|
|||
type_name_ = cfg["name"];
|
||||
description_ = cfg["description"];
|
||||
hitpoints_ = cfg["hitpoints"].to_int(1);
|
||||
level_ = cfg["level"];
|
||||
level_ = cfg["level"].to_int();
|
||||
recall_cost_ = cfg["recall_cost"].to_int(-1);
|
||||
movement_ = cfg["movement"].to_int(1);
|
||||
vision_ = cfg["vision"].to_int(-1);
|
||||
|
|
|
@ -411,8 +411,8 @@ void unit::init(const config& cfg, bool use_traits, const vconfig* vcfg)
|
|||
//, facing_(map_location::NDIRECTIONS)
|
||||
//, anim_comp_(new unit_animation_component(*this))
|
||||
hidden_ = cfg["hidden"].to_bool(false);
|
||||
hp_bar_scaling_ = cfg["hp_bar_scaling"].blank() ? type_->hp_bar_scaling() : cfg["hp_bar_scaling"];
|
||||
xp_bar_scaling_ = cfg["xp_bar_scaling"].blank() ? type_->xp_bar_scaling() : cfg["xp_bar_scaling"];
|
||||
hp_bar_scaling_ = cfg["hp_bar_scaling"].blank() ? type_->hp_bar_scaling() : cfg["hp_bar_scaling"].to_double();
|
||||
xp_bar_scaling_ = cfg["xp_bar_scaling"].blank() ? type_->xp_bar_scaling() : cfg["xp_bar_scaling"].to_double();
|
||||
random_traits_ = true;
|
||||
generate_name_ = true;
|
||||
side_ = cfg["side"].to_int();
|
||||
|
@ -542,7 +542,7 @@ void unit::init(const config& cfg, bool use_traits, const vconfig* vcfg)
|
|||
}
|
||||
|
||||
if(const config::attribute_value* v = cfg.get("cost")) {
|
||||
unit_value_ = *v;
|
||||
unit_value_ = v->to_int();
|
||||
}
|
||||
|
||||
if(const config::attribute_value* v = cfg.get("ellipse")) {
|
||||
|
@ -705,7 +705,7 @@ void unit::init(const config& cfg, bool use_traits, const vconfig* vcfg)
|
|||
// change the unit hp when it was not intended.
|
||||
hit_points_ = cfg["hitpoints"].to_int(max_hit_points_);
|
||||
|
||||
experience_ = cfg["experience"];
|
||||
experience_ = cfg["experience"].to_int();
|
||||
resting_ = cfg["resting"].to_bool();
|
||||
unrenamable_ = cfg["unrenamable"].to_bool();
|
||||
|
||||
|
|
|
@ -653,7 +653,7 @@ void manager::process_network_data(const config& cfg)
|
|||
std::size_t count = wb_cfg->child_count("net_cmd");
|
||||
LOG_WB << "Received wb data (" << count << ").";
|
||||
|
||||
team& team_from = resources::gameboard->get_team(wb_cfg["side"]);
|
||||
team& team_from = resources::gameboard->get_team(wb_cfg["side"].to_int());
|
||||
for(const side_actions::net_cmd& cmd : wb_cfg->child_range("net_cmd"))
|
||||
team_from.get_side_actions()->execute_net_cmd(cmd);
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ move::move(const config& cfg, bool hidden)
|
|||
, fake_unit_hidden_(false)
|
||||
{
|
||||
// Construct and validate unit_
|
||||
unit_map::iterator unit_itor = resources::gameboard->units().find(cfg["unit_"]);
|
||||
unit_map::iterator unit_itor = resources::gameboard->units().find(cfg["unit_"].to_size_t());
|
||||
if(unit_itor == resources::gameboard->units().end())
|
||||
throw action::ctor_err("move: Invalid underlying_id");
|
||||
unit_underlying_id_ = unit_itor->underlying_id();
|
||||
|
@ -112,13 +112,13 @@ move::move(const config& cfg, bool hidden)
|
|||
auto route_cfg = cfg.optional_child("route_");
|
||||
if(!route_cfg)
|
||||
throw action::ctor_err("move: Invalid route_");
|
||||
route_->move_cost = route_cfg["move_cost"];
|
||||
route_->move_cost = route_cfg["move_cost"].to_int();
|
||||
for(const config& loc_cfg : route_cfg->child_range("step")) {
|
||||
route_->steps.emplace_back(loc_cfg["x"],loc_cfg["y"], wml_loc());
|
||||
}
|
||||
for(const config& mark_cfg : route_cfg->child_range("mark")) {
|
||||
route_->marks[map_location(mark_cfg["x"],mark_cfg["y"], wml_loc())]
|
||||
= pathfind::marked_route::mark(mark_cfg["turns"],
|
||||
= pathfind::marked_route::mark(mark_cfg["turns"].to_int(),
|
||||
mark_cfg["zoc"].to_bool(),
|
||||
mark_cfg["capture"].to_bool(),
|
||||
mark_cfg["invisible"].to_bool());
|
||||
|
|
|
@ -77,7 +77,7 @@ recall::recall(const config& cfg, bool hidden)
|
|||
, original_recall_pos_(0)
|
||||
{
|
||||
// Construct and validate temp_unit_
|
||||
std::size_t underlying_id = cfg["temp_unit_"];
|
||||
std::size_t underlying_id = cfg["temp_unit_"].to_size_t();
|
||||
for(const unit_ptr & recall_unit : resources::gameboard->teams().at(team_index()).recall_list())
|
||||
{
|
||||
if(recall_unit->underlying_id()==underlying_id)
|
||||
|
|
|
@ -67,7 +67,7 @@ suppose_dead::suppose_dead(const config& cfg, bool hidden)
|
|||
, loc_(cfg.mandatory_child("loc_")["x"],cfg.mandatory_child("loc_")["y"], wml_loc())
|
||||
{
|
||||
// Construct and validate unit_
|
||||
unit_map::iterator unit_itor = resources::gameboard->units().find(cfg["unit_"]);
|
||||
unit_map::iterator unit_itor = resources::gameboard->units().find(cfg["unit_"].to_size_t());
|
||||
if(unit_itor == resources::gameboard->units().end())
|
||||
throw action::ctor_err("suppose_dead: Invalid underlying_id");
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue