widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #02967
Re: [Merge] lp:~widelands-dev/widelands/bug-1385859 into lp:widelands
Review: Approve
Solid change! Lots of small but impactful improvements here.
Diff comments:
> === modified file 'src/base/scoped_timer.cc'
> --- src/base/scoped_timer.cc 2014-07-05 13:14:42 +0000
> +++ src/base/scoped_timer.cc 2014-10-27 10:39:23 +0000
> @@ -33,8 +33,8 @@
>
> ScopedTimer::~ScopedTimer() {
> uint32_t ms_in_existance = SDL_GetTicks() - startime_;
> -
> - log("%s\n", (boost::format(message_) % ms_in_existance).str().c_str());
fwiw this is actually save: the method log() gets called with a temporary of type string that is guaranteed to live for the duration of the function call. Therefore it's .c_str() pointer also stays valid. Since log() is not keeping a copy of the c_str() pointer that oulives the lifetime of the std::string, this does not lead to invalid memory.
However, pulling it out is also fine.
> + const std::string logmessage = (boost::format(message_) % ms_in_existance).str();
> + log("%s\n", logmessage.c_str());
> }
>
> uint32_t ScopedTimer::ms_since_last_query() {
>
> === modified file 'src/editor/ui_menus/editor_main_menu_load_map.cc'
> --- src/editor/ui_menus/editor_main_menu_load_map.cc 2014-09-30 05:41:55 +0000
> +++ src/editor/ui_menus/editor_main_menu_load_map.cc 2014-10-27 10:39:23 +0000
> @@ -177,7 +177,7 @@
>
> m_size ->set_text((boost::format(_("%1$ix%2$i"))
> % map.get_width()
> - % map.get_height()).str().c_str());
> + % map.get_height()).str());
+1 for these changes: not using c_str() when not needed can be quite beneficial for performance.
> } else {
> m_name ->set_text("");
> m_name ->set_tooltip("");
> @@ -207,13 +207,12 @@
> #else
> m_parentdir = m_curdir.substr(0, m_curdir.rfind('\\'));
> #endif
> - std::string parent_string =
> +
> + m_ls->add
> /** TRANSLATORS: Parent directory */
> - (boost::format("\\<%s\\>") % _("parent")).str();
> - m_ls->add
> - (parent_string.c_str(),
> - m_parentdir.c_str(),
> - g_gr->images().get("pics/ls_dir.png"));
> + ((boost::format("\\<%s\\>") % _("parent")).str(),
> + m_parentdir.c_str(),
> + g_gr->images().get("pics/ls_dir.png"));
> }
>
> const FilenameSet::const_iterator mapfiles_end = m_mapfiles.end();
> @@ -248,7 +247,7 @@
> try {
> map_loader->preload_map(true);
> m_ls->add
> - (FileSystem::filename_without_ext(name).c_str(),
> + (FileSystem::filename_without_ext(name),
> name,
> g_gr->images().get
> (dynamic_cast<WidelandsMapLoader*>(map_loader.get())
>
> === modified file 'src/editor/ui_menus/editor_main_menu_map_options.cc'
> --- src/editor/ui_menus/editor_main_menu_map_options.cc 2014-09-30 05:41:55 +0000
> +++ src/editor/ui_menus/editor_main_menu_map_options.cc 2014-10-27 10:39:23 +0000
> @@ -118,7 +118,7 @@
>
> m_size ->set_text((boost::format(_("%1$ix%2$i"))
> % map.get_width()
> - % map.get_height()).str().c_str());
> + % map.get_height()).str());
> m_author->set_text(map.get_author());
> m_name ->set_text(map.get_name());
> m_nrplayers->set_text(std::to_string(static_cast<unsigned int>(map.get_nrplayers())));
>
> === modified file 'src/editor/ui_menus/editor_main_menu_new_map.cc'
> --- src/editor/ui_menus/editor_main_menu_new_map.cc 2014-09-30 05:41:55 +0000
> +++ src/editor/ui_menus/editor_main_menu_new_map.cc 2014-10-27 10:39:23 +0000
> @@ -62,7 +62,7 @@
> }
>
> m_width = new UI::Textarea(this, posx + spacing + 20, posy,
> - (boost::format(_("Width: %u")) % Widelands::MAP_DIMENSIONS[m_w]).str().c_str());
> + (boost::format(_("Width: %u")) % Widelands::MAP_DIMENSIONS[m_w]).str());
>
> UI::Button * widthupbtn = new UI::Button
> (this, "width_up",
> @@ -82,7 +82,7 @@
>
> m_height = new UI::Textarea(this, posx + spacing + 20, posy,
> (boost::format(_("Height: %u"))
> - % Widelands::MAP_DIMENSIONS[m_h]).str().c_str());
> + % Widelands::MAP_DIMENSIONS[m_h]).str());
>
> UI::Button * heightupbtn = new UI::Button
> (this, "height_up",
>
> === modified file 'src/editor/ui_menus/editor_main_menu_random_map.cc'
> --- src/editor/ui_menus/editor_main_menu_random_map.cc 2014-10-12 06:26:38 +0000
> +++ src/editor/ui_menus/editor_main_menu_random_map.cc 2014-10-27 10:39:23 +0000
> @@ -123,7 +123,7 @@
>
> m_width = new UI::Textarea(this, posx + spacing + height, posy,
> (boost::format(_("Width: %u"))
> - % Widelands::MAP_DIMENSIONS[m_w]).str().c_str());
> + % Widelands::MAP_DIMENSIONS[m_w]).str());
>
> posy += height + 2 * spacing;
>
> @@ -131,7 +131,7 @@
>
> m_height = new UI::Textarea(this, posx + spacing + height, posy,
> (boost::format(_("Height: %u"))
> - % Widelands::MAP_DIMENSIONS[m_h]).str().c_str());
> + % Widelands::MAP_DIMENSIONS[m_h]).str());
>
> UI::Button * heightupbtn = new UI::Button
> (this, "height_up",
> @@ -171,7 +171,7 @@
> (boost::bind(&MainMenuNewRandomMap::button_clicked, this, ButtonId::WATER_MINUS));
>
> m_water = new UI::Textarea(this, posx + spacing + height, posy,
> - (boost::format(_("Water: %i %%")) % m_waterval).str().c_str());
> + (boost::format(_("Water: %i %%")) % m_waterval).str());
>
> posy += height + 2 * spacing;
>
> @@ -196,7 +196,7 @@
> (boost::bind(&MainMenuNewRandomMap::button_clicked, this, ButtonId::LAND_MINUS));
>
> m_land = new UI::Textarea(this, posx + spacing + height, posy,
> - (boost::format(_("Land: %i %%")) % m_landval).str().c_str());
> + (boost::format(_("Land: %i %%")) % m_landval).str());
>
> posy += height + 2 * spacing;
>
> @@ -221,7 +221,7 @@
> (boost::bind(&MainMenuNewRandomMap::button_clicked, this, ButtonId::WASTE_MINUS));
>
> m_wasteland = new UI::Textarea(this, posx + spacing + height, posy,
> - (boost::format(_("Wasteland: %i %%")) % m_wastelandval).str().c_str());
> + (boost::format(_("Wasteland: %i %%")) % m_wastelandval).str());
>
> posy += height + 2 * spacing;
>
> @@ -230,7 +230,7 @@
> // ---------- Mountains -----------
>
> m_mountains = new UI::Textarea(this, posx + spacing + height, posy,
> - (boost::format(_("Mountains: %i %%")) % m_mountainsval).str().c_str());
> + (boost::format(_("Mountains: %i %%")) % m_mountainsval).str());
>
> posy += height + 2 * spacing;
>
> @@ -317,7 +317,7 @@
>
> m_players = new UI::Textarea(this, posx + spacing + height, posy,
> (boost::format(_("Players: %u"))
> - % static_cast<unsigned int>(m_pn)).str().c_str());
> + % static_cast<unsigned int>(m_pn)).str());
>
> posy += height + 2 * spacing;
>
> @@ -424,14 +424,14 @@
> if (m_h < 0) m_h = 0;
> if (m_h >= NUMBER_OF_MAP_DIMENSIONS) m_h = NUMBER_OF_MAP_DIMENSIONS - 1;
>
> - m_width ->set_text((boost::format(_("Width: %u")) % Widelands::MAP_DIMENSIONS[m_w]).str().c_str());
> - m_height->set_text((boost::format(_("Height: %u")) % Widelands::MAP_DIMENSIONS[m_h]).str().c_str());
> - m_water->set_text((boost::format(_("Water: %i %%")) % m_waterval).str().c_str());
> - m_land->set_text((boost::format(_("Land: %i %%")) % m_landval).str().c_str());
> - m_wasteland->set_text((boost::format(_("Wasteland: %i %%")) % m_wastelandval).str().c_str());
> - m_mountains->set_text((boost::format(_("Mountains: %i %%")) % m_mountainsval).str().c_str());
> + m_width ->set_text((boost::format(_("Width: %u")) % Widelands::MAP_DIMENSIONS[m_w]).str());
> + m_height->set_text((boost::format(_("Height: %u")) % Widelands::MAP_DIMENSIONS[m_h]).str());
> + m_water->set_text((boost::format(_("Water: %i %%")) % m_waterval).str());
> + m_land->set_text((boost::format(_("Land: %i %%")) % m_landval).str());
> + m_wasteland->set_text((boost::format(_("Wasteland: %i %%")) % m_wastelandval).str());
> + m_mountains->set_text((boost::format(_("Mountains: %i %%")) % m_mountainsval).str());
> m_players->set_text((boost::format(_("Players: %u"))
> - % static_cast<unsigned int>(m_pn)).str().c_str());
> + % static_cast<unsigned int>(m_pn)).str());
>
> nr_edit_box_changed(); // Update ID String
> }
>
> === modified file 'src/editor/ui_menus/editor_main_menu_save_map.cc'
> --- src/editor/ui_menus/editor_main_menu_save_map.cc 2014-09-30 05:41:55 +0000
> +++ src/editor/ui_menus/editor_main_menu_save_map.cc 2014-10-27 10:39:23 +0000
> @@ -236,7 +236,7 @@
> m_nrplayers->set_text(std::to_string(static_cast<unsigned int>(map.get_nrplayers())));
>
> m_size->set_text((boost::format(_("%1$ix%2$i"))
> - % map.get_width() % map.get_height()).str().c_str());
> + % map.get_width() % map.get_height()).str());
> } else {
> m_name ->set_text(FileSystem::fs_filename(name));
> m_name ->set_tooltip("");
> @@ -286,13 +286,12 @@
> #else
> m_parentdir = m_curdir.substr(0, m_curdir.rfind('\\'));
> #endif
> - std::string parent_string =
> +
> + m_ls->add
> /** TRANSLATORS: Parent directory */
> - (boost::format("\\<%s\\>") % _("parent")).str();
> - m_ls->add
> - (parent_string.c_str(),
> - m_parentdir.c_str(),
> - g_gr->images().get("pics/ls_dir.png"));
> + ((boost::format("\\<%s\\>") % _("parent")).str(),
> + m_parentdir.c_str(),
> + g_gr->images().get("pics/ls_dir.png"));
> }
>
> const FilenameSet::const_iterator mapfiles_end = m_mapfiles.end();
> @@ -329,7 +328,7 @@
> try {
> wml->preload_map(true);
> m_ls->add
> - (FileSystem::filename_without_ext(name).c_str(),
> + (FileSystem::filename_without_ext(name),
> name,
> g_gr->images().get("pics/ls_wlmap.png"));
> } catch (const WException &) {} // we simply skip illegal entries
>
> === modified file 'src/editor/ui_menus/editor_player_menu.cc'
> --- src/editor/ui_menus/editor_player_menu.cc 2014-09-20 09:37:47 +0000
> +++ src/editor/ui_menus/editor_player_menu.cc 2014-10-27 10:39:23 +0000
> @@ -208,7 +208,7 @@
> number += '0' + nr_players_10;
> number += '0' + nr_players % 10;
> /** TRANSLATORS: Default player name, e.g. Player 1 */
> - std::string name = (boost::format(_("Player %s")) % number).str();
> + const std::string name = (boost::format(_("Player %s")) % number).str();
> map.set_scenario_player_name(nr_players, name);
> }
> map.set_scenario_player_tribe(nr_players, m_tribes[0]);
>
> === modified file 'src/editor/ui_menus/editor_player_menu_allowed_buildings_menu.cc'
> --- src/editor/ui_menus/editor_player_menu_allowed_buildings_menu.cc 2014-09-10 14:08:25 +0000
> +++ src/editor/ui_menus/editor_player_menu_allowed_buildings_menu.cc 2014-10-27 10:39:23 +0000
> @@ -116,7 +116,7 @@
> if (!building.is_enhanced() && !building.is_buildable())
> continue;
> (m_player.is_building_type_allowed(i) ? m_allowed : m_forbidden).add
> - (building.descname().c_str(), i, building.get_icon());
> + (building.descname(), i, building.get_icon());
> }
> m_forbidden.sort();
> m_allowed .sort();
> @@ -156,7 +156,7 @@
> const Widelands::BuildingDescr & building =
> *m_player.tribe().get_building_descr(building_index);
> target.add
> - (building.descname().c_str(),
> + (building.descname(),
> building_index,
> building.get_icon());
> target.sort();
>
> === modified file 'src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc'
> --- src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc 2014-09-29 18:01:06 +0000
> +++ src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc 2014-10-27 10:39:23 +0000
> @@ -126,7 +126,7 @@
> /** TRANSLATORS: %1% = terrain name, %2% = list of terrain types */
> const std::string tooltip = ((boost::format("%1%: %2%"))
> % terrain_descr.descname()
> - % i18n::localize_item_list(tooltips, i18n::ConcatenateWith::AND)).str().c_str();
> + % i18n::localize_item_list(tooltips, i18n::ConcatenateWith::AND)).str();
>
> std::unique_ptr<const Image>& image = offscreen_images->back();
> UI::Checkbox* cb = new UI::Checkbox(parent, Point(0, 0), image.get(), tooltip);
>
> === modified file 'src/io/filesystem/zip_filesystem.cc'
> --- src/io/filesystem/zip_filesystem.cc 2014-09-30 05:41:55 +0000
> +++ src/io/filesystem/zip_filesystem.cc 2014-10-27 10:39:23 +0000
> @@ -329,11 +329,9 @@
> break;
> if (len < 0) {
> unzCloseCurrentFile(m_unzipfile);
> + const std::string errormessage = (boost::format("read error %i") % len).str();
> throw ZipOperationError
> - ("ZipFilesystem::load",
> - fname,
> - m_zipfilename,
> - (boost::format("read error %i") % len).str().c_str());
> + ("ZipFilesystem::load", fname, m_zipfilename, errormessage.c_str());
> }
>
> totallen += len;
>
> === modified file 'src/logic/critter.cc'
> --- src/logic/critter.cc 2014-09-30 05:41:55 +0000
> +++ src/logic/critter.cc 2014-10-27 10:39:23 +0000
> @@ -154,7 +154,7 @@
> add_attributes(attributes, std::set<uint32_t>());
> }
>
> - const std::string defaultpics = (boost::format("%s_walk_!!_??.png") % _name).str().c_str();
> + const std::string defaultpics = (boost::format("%s_walk_!!_??.png") % _name).str();
> m_walk_anims.parse(*this, directory, prof, "walk", false, defaultpics);
>
> while (Section::Value const * const v = global_s.get_next_val("program")) {
>
> === modified file 'src/logic/production_program.cc'
> --- src/logic/production_program.cc 2014-09-30 20:31:43 +0000
> +++ src/logic/production_program.cc 2014-10-27 10:39:23 +0000
> @@ -54,8 +54,6 @@
>
> namespace {
>
> -// For formation of better translateable texts
> -using boost::format;
>
> /**
> * Convert std::string to any sstream-compatible type
> @@ -268,15 +266,17 @@
> // TODO(GunChleoc): We can make this more elegant if we add another definition to the conf files,
> // so for "Log"; we will also have "logs" (numberless plural)
> /** TRANSLATORS: e.g. Completed/Skipped/Did not start ... because the economy needs the ware ‘%s’*/
> - return (boost::format(_("the economy needs the ware ‘%s’"))
> + std::string result = (boost::format(_("the economy needs the ware ‘%s’"))
> % tribe.get_ware_descr(ware_type)->descname()).str();
> + return result;
> }
> std::string ProductionProgram::ActReturn::EconomyNeedsWare::description_negation
> (const TribeDescr & tribe) const
> {
> /** TRANSLATORS: e.g. Completed/Skipped/Did not start ... because the economy doesn’t need the ware ‘%s’*/
> - return (boost::format(_("the economy doesn’t need the ware ‘%s’"))
> + std::string result = (boost::format(_("the economy doesn’t need the ware ‘%s’"))
> % tribe.get_ware_descr(ware_type)->descname()).str();
> + return result;
> }
>
> bool ProductionProgram::ActReturn::EconomyNeedsWorker::evaluate
> @@ -288,8 +288,9 @@
> (const TribeDescr & tribe) const
> {
> /** TRANSLATORS: e.g. Completed/Skipped/Did not start ... because the economy needs the worker ‘%s’*/
> - return (boost::format(_("the economy needs the worker ‘%s’"))
> + std::string result = (boost::format(_("the economy needs the worker ‘%s’"))
> % tribe.get_worker_descr(worker_type)->descname()).str();
> + return result;
> }
>
> std::string ProductionProgram::ActReturn::EconomyNeedsWorker::description_negation
> @@ -297,8 +298,9 @@
> {
> /** TRANSLATORS: e.g. Completed/Skipped/Did not start ...*/
> /** TRANSLATORS: ... because the economy doesn’t need the worker ‘%s’*/
> - return (boost::format(_("the economy doesn’t need the worker ‘%s’"))
> + std::string result = (boost::format(_("the economy doesn’t need the worker ‘%s’"))
> % tribe.get_worker_descr(worker_type)->descname()).str();
> + return result;
> }
>
>
> @@ -955,7 +957,7 @@
> /** TRANSLATORS: e.g. 'Did not start working because fish, meat or pitta bread is missing' */
> (boost::format(ngettext("%s is missing", "%s are missing", nr_missing_groups))
> % i18n::localize_item_list(group_list, i18n::ConcatenateWith::AND))
> - .str().c_str();
> + .str();
>
> std::string result_string =
> /** TRANSLATORS: e.g. 'Did not start working because 3x water and 3x wheat are missing' */
> @@ -1068,9 +1070,9 @@
> }
> std::string ware_list = i18n::localize_item_list(ware_descnames, i18n::ConcatenateWith::AND);
>
> - // Keep translateability in mind!
> /** TRANSLATORS: %s is a list of wares */
> - ps.set_production_result(str(format(_("Produced %s")) % ware_list));
> + const std::string result_string = (boost::format(_("Produced %s")) % ware_list).str();
> + ps.set_production_result(result_string);
> }
>
> bool ProductionProgram::ActProduce::get_building_work
> @@ -1164,7 +1166,8 @@
> std::string unit_string = i18n::localize_item_list(worker_descnames, i18n::ConcatenateWith::AND);
>
> /** TRANSLATORS: %s is a list of workers */
> - ps.set_production_result((boost::format(_("Recruited %s")) % unit_string).str());
> + const std::string result_string = (boost::format(_("Recruited %s")) % unit_string).str();
> + ps.set_production_result(result_string);
> }
>
> bool ProductionProgram::ActRecruit::get_building_work
>
> === modified file 'src/logic/productionsite.cc'
> --- src/logic/productionsite.cc 2014-09-24 21:06:00 +0000
> +++ src/logic/productionsite.cc 2014-10-27 10:39:23 +0000
> @@ -299,7 +299,7 @@
> ++lastOk;
> }
> }
> - // Somehow boost::format doesn't handle correctly uint8_t in this case
> + // boost::format would treat uint8_t as char
> const unsigned int percOk = (ok * 100) / STATISTICS_VECTOR_LENGTH;
> m_last_stat_percent = percOk;
>
>
> === modified file 'src/logic/soldier.cc'
> --- src/logic/soldier.cc 2014-09-30 05:41:55 +0000
> +++ src/logic/soldier.cc 2014-10-27 10:39:23 +0000
> @@ -137,23 +137,23 @@
> for (uint32_t i = 0; i <= m_max_hp_level; ++i) {
> m_hp_pics_fn[i] = dir;
> m_hp_pics_fn[i] += global_s.get_safe_string((boost::format("hp_level_%u_pic")
> - % i).str().c_str());
> + % i).str());
>
> }
> for (uint32_t i = 0; i <= m_max_attack_level; ++i) {
> m_attack_pics_fn[i] = dir;
> m_attack_pics_fn[i] += global_s.get_safe_string((boost::format("attack_level_%u_pic")
> - % i).str().c_str());
> + % i).str());
> }
> for (uint32_t i = 0; i <= m_max_defense_level; ++i) {
> m_defense_pics_fn[i] = dir;
> m_defense_pics_fn[i] += global_s.get_safe_string((boost::format("defense_level_%u_pic")
> - % i).str().c_str());
> + % i).str());
> }
> for (uint32_t i = 0; i <= m_max_evade_level; ++i) {
> m_evade_pics_fn[i] = dir;
> m_evade_pics_fn[i] += global_s.get_safe_string((boost::format("evade_level_%u_pic")
> - % i).str().c_str());
> + % i).str());
> }
>
> { /// Battle animations
> @@ -1550,7 +1550,7 @@
> BaseImmovable const * const immovable_dest =
> map[dest] .get_immovable();
>
> - std::string messagetext =
> + const std::string messagetext =
> (boost::format("The game engine has encountered a logic error. The %s "
> "#%u of player %u could not find a way from (%i, %i) "
> "(with %s immovable) to the opponent (%s #%u of player "
>
> === modified file 'src/logic/trainingsite.cc'
> --- src/logic/trainingsite.cc 2014-09-30 05:41:55 +0000
> +++ src/logic/trainingsite.cc 2014-10-27 10:39:23 +0000
> @@ -659,7 +659,7 @@
>
> return program_start(game, (boost::format("%s%i")
> % upgrade.prefix.c_str()
> - % level).str().c_str());
> + % level).str());
> }
>
> TrainingSite::Upgrade * TrainingSite::get_upgrade(TrainingAttribute const atr)
>
> === modified file 'src/logic/tribe.cc'
> --- src/logic/tribe.cc 2014-09-30 05:41:55 +0000
> +++ src/logic/tribe.cc 2014-10-27 10:39:23 +0000
> @@ -433,7 +433,7 @@
>
> return get_immovable_index((boost::format("resi_%s%i")
> % res->name().c_str()
> - % bestmatch).str().c_str());
> + % bestmatch).str());
> }
>
> /*
>
> === modified file 'src/logic/worker.cc'
> --- src/logic/worker.cc 2014-10-18 13:39:27 +0000
> +++ src/logic/worker.cc 2014-10-27 10:39:23 +0000
> @@ -939,7 +939,7 @@
> (boost::format("<rt image=world/resources/pics/%s4.png>"
> "<p font-size=14 font-face=DejaVuSerif>%s</p></rt>")
> % rdescr->name().c_str()
> - % _("A geologist found resources.")).str().c_str();
> + % _("A geologist found resources.")).str();
>
> // We should add a message to the player's message queue - but only,
> // if there is not already a similar one in list.
> @@ -1841,7 +1841,7 @@
> molog("[return]: Failed to return\n");
> const std::string message =
> (boost::format(_("Your %s can't find a way home and will likely die."))
> - % descr().descname().c_str()).str().c_str();
> + % descr().descname().c_str()).str();
>
> owner().add_message
> (game,
>
> === modified file 'src/map_io/coords_profile.cc'
> --- src/map_io/coords_profile.cc 2014-06-18 13:20:33 +0000
> +++ src/map_io/coords_profile.cc 2014-10-27 10:39:23 +0000
> @@ -71,7 +71,7 @@
>
> Coords
> get_safe_coords(const std::string& name, const Extent& extent, Section* section) {
> - return parse_coords(name, section->get_safe_string(name.c_str()), extent);
> + return parse_coords(name, section->get_safe_string(name), extent);
> }
>
> } // namespace Widelands
>
> === modified file 'src/map_io/map_allowed_building_types_packet.cc'
> --- src/map_io/map_allowed_building_types_packet.cc 2014-09-30 05:41:55 +0000
> +++ src/map_io/map_allowed_building_types_packet.cc 2014-10-27 10:39:23 +0000
> @@ -72,7 +72,7 @@
> player->allow_building_type(--i, false);
> try {
> Section & s = prof.get_safe_section((boost::format("player_%u")
> - % static_cast<unsigned int>(p)).str().c_str());
> + % static_cast<unsigned int>(p)).str());
>
> bool allowed;
> while (const char * const name = s.get_next_bool(nullptr, &allowed)) {
> @@ -108,8 +108,9 @@
> PlayerNumber const nr_players = egbase.map().get_nrplayers();
> iterate_players_existing_const(p, nr_players, egbase, player) {
> const TribeDescr & tribe = player->tribe();
> - Section & section = prof.create_section((boost::format("player_%u")
> - % static_cast<unsigned int>(p)).str().c_str());
> + const std::string section_key = (boost::format("player_%u")
> + % static_cast<unsigned int>(p)).str();
> + Section & section = prof.create_section(section_key.c_str());
>
> // Write for all buildings if it is enabled.
> BuildingIndex const nr_buildings = tribe.get_nrbuildings();
>
> === modified file 'src/map_io/map_allowed_worker_types_packet.cc'
> --- src/map_io/map_allowed_worker_types_packet.cc 2014-09-30 05:41:55 +0000
> +++ src/map_io/map_allowed_worker_types_packet.cc 2014-10-27 10:39:23 +0000
> @@ -59,7 +59,7 @@
> const TribeDescr & tribe = player->tribe();
> try {
> Section* s = prof.get_section((boost::format("player_%u")
> - % static_cast<unsigned int>(p)).str().c_str());
> + % static_cast<unsigned int>(p)).str());
> if (s == nullptr)
> continue;
>
> @@ -93,8 +93,9 @@
> bool forbidden_worker_seen = false;
> iterate_players_existing_const(p, egbase.map().get_nrplayers(), egbase, player) {
> const TribeDescr & tribe = player->tribe();
> - Section & section = prof.create_section((boost::format("player_%u")
> - % static_cast<unsigned int>(p)).str().c_str());
> + const std::string section_key = (boost::format("player_%u")
> + % static_cast<unsigned int>(p)).str();
> + Section & section = prof.create_section(section_key.c_str());
>
> // Only write the workers which are disabled.
> for (WareIndex b = 0; b < tribe.get_nrworkers(); ++b) {
>
> === modified file 'src/map_io/map_player_names_and_tribes_packet.cc'
> --- src/map_io/map_player_names_and_tribes_packet.cc 2014-09-30 05:41:55 +0000
> +++ src/map_io/map_player_names_and_tribes_packet.cc 2014-10-27 10:39:23 +0000
> @@ -68,7 +68,7 @@
> PlayerNumber const nr_players = map->get_nrplayers();
> iterate_player_numbers(p, nr_players) {
> Section & s = prof.get_safe_section((boost::format("player_%u")
> - % static_cast<unsigned int>(p)).str().c_str());
> + % static_cast<unsigned int>(p)).str());
> map->set_scenario_player_name (p, s.get_string("name", ""));
> map->set_scenario_player_tribe (p, s.get_string("tribe", ""));
> map->set_scenario_player_ai (p, s.get_string("ai", ""));
> @@ -94,8 +94,9 @@
> const Map & map = egbase.map();
> PlayerNumber const nr_players = map.get_nrplayers();
> iterate_player_numbers(p, nr_players) {
> - Section & s = prof.create_section((boost::format("player_%u")
> - % static_cast<unsigned int>(p)).str().c_str());
> + const std::string section_key = (boost::format("player_%u")
> + % static_cast<unsigned int>(p)).str();
> + Section & s = prof.create_section(section_key.c_str());
> s.set_string("name", map.get_scenario_player_name (p));
> s.set_string("tribe", map.get_scenario_player_tribe (p));
> s.set_string("ai", map.get_scenario_player_ai (p));
>
> === modified file 'src/map_io/map_player_position_packet.cc'
> --- src/map_io/map_player_position_packet.cc 2014-09-30 05:41:55 +0000
> +++ src/map_io/map_player_position_packet.cc 2014-10-27 10:39:23 +0000
> @@ -52,7 +52,7 @@
> try {
> map.set_starting_pos(p,
> get_safe_coords((boost::format("player_%u")
> - % static_cast<unsigned int>(p)).str().c_str(),
> + % static_cast<unsigned int>(p)).str(),
> extent, &s));
> } catch (const WException & e) {
> throw GameDataError("player %u: %s", p, e.what());
> @@ -79,7 +79,7 @@
> const Map & map = egbase.map();
> const PlayerNumber nr_players = map.get_nrplayers();
> iterate_player_numbers(p, nr_players) {
> - set_coords((boost::format("player_%u") % static_cast<unsigned int>(p)).str().c_str(),
> + set_coords((boost::format("player_%u") % static_cast<unsigned int>(p)).str(),
> map.get_starting_pos(p), &s);
> }
>
>
> === modified file 'src/map_io/map_players_messages_packet.cc'
> --- src/map_io/map_players_messages_packet.cc 2014-09-30 05:41:55 +0000
> +++ src/map_io/map_players_messages_packet.cc 2014-10-27 10:39:23 +0000
> @@ -46,8 +46,9 @@
> try {
> Profile prof;
> try {
> - prof.read((boost::format(FILENAME_TEMPLATE) % static_cast<unsigned int>(p)).str().c_str(),
> - nullptr, fs);
> + const std::string profile_filename =
> + (boost::format(FILENAME_TEMPLATE) % static_cast<unsigned int>(p)).str();
> + prof.read(profile_filename.c_str(), nullptr, fs);
> } catch (...) {continue;}
> prof.get_safe_section("global").get_positive
> ("packet_version", CURRENT_PACKET_VERSION);
> @@ -183,9 +184,11 @@
> }
> }
> fs.ensure_directory_exists((boost::format(PLAYERDIRNAME_TEMPLATE)
> - % static_cast<unsigned int>(p)).str().c_str());
> - prof.write((boost::format(FILENAME_TEMPLATE)
> - % static_cast<unsigned int>(p)).str().c_str(), false, fs);
> + % static_cast<unsigned int>(p)).str());
> +
> + const std::string profile_filename =
> + (boost::format(FILENAME_TEMPLATE) % static_cast<unsigned int>(p)).str();
> + prof.write(profile_filename.c_str(), false, fs);
> }
> }
>
>
> === modified file 'src/map_io/map_players_view_packet.cc'
> --- src/map_io/map_players_view_packet.cc 2014-09-30 05:41:55 +0000
> +++ src/map_io/map_players_view_packet.cc 2014-10-27 10:39:23 +0000
> @@ -1179,9 +1179,9 @@
> char filename[FILENAME_SIZE];
>
> fs.ensure_directory_exists((boost::format(PLAYERDIRNAME_TEMPLATE)
> - % static_cast<unsigned int>(plnum)).str().c_str());
> + % static_cast<unsigned int>(plnum)).str());
> fs.ensure_directory_exists((boost::format(DIRNAME_TEMPLATE)
> - % static_cast<unsigned int>(plnum)).str().c_str());
> + % static_cast<unsigned int>(plnum)).str());
>
> WRITE
> (unseen_times_file,
>
> === modified file 'src/network/nethost.cc'
> --- src/network/nethost.cc 2014-10-26 12:17:01 +0000
> +++ src/network/nethost.cc 2014-10-27 10:39:23 +0000
> @@ -64,9 +64,6 @@
> #include "wui/interactive_player.h"
> #include "wui/interactive_spectator.h"
>
> -using boost::format;
> -
> -
>
> struct HostGameSettingsProvider : public GameSettingsProvider {
> HostGameSettingsProvider(NetHost * const _h) : h(_h), m_lua(nullptr), m_cur_wincondition(0) {}
> @@ -418,9 +415,9 @@
> } else if (num == -1) {
> if (!h->is_dedicated())
> c.recipient = h->get_local_playername();
> - c.msg = (format(_("The client %s could not be found.")) % arg1).str();
> + c.msg = (boost::format(_("The client %s could not be found.")) % arg1).str();
> } else {
> - c.msg = (format("HOST WARNING FOR %s: ") % arg1).str();
> + c.msg = (boost::format("HOST WARNING FOR %s: ") % arg1).str();
> c.msg += arg2;
> }
> }
> @@ -444,12 +441,12 @@
> } else
> c.msg = _("You can not kick the dedicated server");
> else if (num == -1)
> - c.msg = (format(_("The client %s could not be found.")) % arg1).str();
> + c.msg = (boost::format(_("The client %s could not be found.")) % arg1).str();
> else {
> kickClient = num;
> - c.msg = (format(_("Are you sure you want to kick %s?")) % arg1).str() + "<br>";
> - c.msg += (format(_("The stated reason was: %s")) % kickReason).str() + "<br>";
> - c.msg += (format(_("If yes, type: /ack_kick %s")) % arg1).str();
> + c.msg = (boost::format(_("Are you sure you want to kick %s?")) % arg1).str() + "<br>";
> + c.msg += (boost::format(_("The stated reason was: %s")) % kickReason).str() + "<br>";
> + c.msg += (boost::format(_("If yes, type: /ack_kick %s")) % arg1).str();
> }
> }
> if (!h->is_dedicated())
> @@ -736,14 +733,13 @@
> // May be the server is password protected?
> Section & s = g_options.pull_section("global");
> m_password = s.get_string("dedicated_password", "");
> +
> // And we read the message of the day
> - m_dedicated_motd =
> - s.get_string
> - ("dedicated_motd",
> - (format
> - (_("This is a dedicated server. Send \"@%s help\" to get a full list of available commands."))
> - % d->localplayername)
> - .str().c_str());
> + const std::string dedicated_motd_key =
> + (boost::format
> + (_("This is a dedicated server. Send \"@%s help\" to get a full list of available commands."))
> + % d->localplayername).str();
> + m_dedicated_motd = s.get_string("dedicated_motd", dedicated_motd_key.c_str());
>
> // Maybe this is the first run, so we try to setup the DedicatedLog
> // empty strings are treated as "do not write this type of log"
> @@ -1242,7 +1238,7 @@
> return;
> }
> std::string temp = arg1 + " " + arg2;
> - c.msg = (format(_("%1$s told me to run the command: \"%2$s\"")) % sender % temp).str();
> + c.msg = (boost::format(_("%1$s told me to run the command: \"%2$s\"")) % sender % temp).str();
> c.recipient = "";
> send(c);
> d->chat.send(temp);
> @@ -1269,7 +1265,7 @@
> c.msg = _("Game successfully saved!");
> else
> c.msg =
> - (format(_("Could not save the game to the file \"%1$s\"! (%2$s)"))
> + (boost::format(_("Could not save the game to the file \"%1$s\"! (%2$s)"))
> % savename % error)
> .str();
> send(c);
> @@ -1300,7 +1296,7 @@
>
> // default
> } else {
> - c.msg = (format(_("Unknown dedicated server command \"%s\"!")) % cmd).str();
> + c.msg = (boost::format(_("Unknown dedicated server command \"%s\"!")) % cmd).str();
> send(c);
> }
> }
> @@ -2163,7 +2159,7 @@
> if (m_password.size() > 1) {
> c.msg += "<br>";
> c.msg +=
> - (format
> + (boost::format
> (_("This server is password protected. You can send the password with: \"@%s pwd PASSWORD\""))
> % d->localplayername)
> .str();
> @@ -2286,7 +2282,7 @@
> if ((d->clients.at(i).hung_since < (time(nullptr) - 300)) && m_is_dedicated) {
> disconnect_client(i, "CLIENT_TIMEOUTED");
> // Try to save the game
> - std::string savename = (boost::format("save/client_hung_%i.wmf") % time(nullptr)).str();;
> + std::string savename = (boost::format("save/client_hung_%i.wmf") % time(nullptr)).str();
> std::string * error = new std::string();
> SaveHandler & sh = d->game->save_handler();
> if (sh.save_game(*d->game, savename, error))
>
> === modified file 'src/scripting/lua_bases.cc'
> --- src/scripting/lua_bases.cc 2014-09-18 18:52:34 +0000
> +++ src/scripting/lua_bases.cc 2014-10-27 10:39:23 +0000
> @@ -317,8 +317,10 @@
> }
>
> int LuaPlayerBase::__tostring(lua_State * L) {
> - lua_pushstring(L, (boost::format("Player(%i)")
> - % static_cast<unsigned int>(get(L, get_egbase(L)).player_number())).str().c_str());
> + const std::string pushme =
> + (boost::format("Player(%i)")
> + % static_cast<unsigned int>(get(L, get_egbase(L)).player_number())).str();
> + lua_pushstring(L, pushme.c_str());
> return 1;
> }
> /* RST
>
> === modified file 'src/scripting/lua_map.cc'
> --- src/scripting/lua_map.cc 2014-10-11 11:14:25 +0000
> +++ src/scripting/lua_map.cc 2014-10-27 10:39:23 +0000
> @@ -3522,7 +3522,8 @@
> */
> // Hash is used to identify a class in a Set
> int LuaField::get___hash(lua_State * L) {
> - lua_pushstring(L, (boost::format("%i_%i") % m_c.x % m_c.y).str().c_str());
> + const std::string pushme = (boost::format("%i_%i") % m_c.x % m_c.y).str();
> + lua_pushstring(L, pushme.c_str());
> return 1;
> }
>
> @@ -3851,7 +3852,8 @@
> }
>
> int LuaField::__tostring(lua_State * L) {
> - lua_pushstring(L, (boost::format("Field(%i,%i)") % m_c.x % m_c.y).str().c_str());
> + const std::string pushme = (boost::format("Field(%i,%i)") % m_c.x % m_c.y).str();
> + lua_pushstring(L, pushme);
> return 1;
> }
>
>
> === modified file 'src/ui_basic/helpwindow.cc'
> --- src/ui_basic/helpwindow.cc 2014-09-30 05:41:55 +0000
> +++ src/ui_basic/helpwindow.cc 2014-10-27 10:39:23 +0000
> @@ -37,9 +37,6 @@
> #include "ui_basic/window.h"
> #include "wui/text_constants.h"
>
> -
> -using boost::format;
> -
> namespace UI {
>
> HelpWindow::HelpWindow
> @@ -48,7 +45,7 @@
> uint32_t fontsize,
> uint32_t width, uint32_t height)
> :
> - Window(parent, "help_window", 0, 0, 20, 20, (boost::format(_("Help: %s")) % caption).str().c_str()),
> + Window(parent, "help_window", 0, 0, 20, 20, (boost::format(_("Help: %s")) % caption).str()),
> textarea(new MultilineTextarea(this, 5, 5, 30, 30, std::string(), Align_Left)),
> m_h1(std::to_string(fontsize < 12 ? 18 : fontsize * 3 / 2)),
> m_h2(std::to_string(fontsize < 12 ? 12 : fontsize)),
> @@ -191,7 +188,7 @@
> uint32_t width, uint32_t height)
> :
> UI::UniqueWindow(parent, "help_window", ®, width, height,
> - (boost::format(_("Help: %s")) % building_description.descname()).str().c_str()),
> + (boost::format(_("Help: %s")) % building_description.descname()).str()),
> textarea(new MultilineTextarea(this, 5, 5, width - 10, height -10, std::string(), Align_Left))
> {
> try {
>
> === modified file 'src/ui_basic/listselect.cc'
> --- src/ui_basic/listselect.cc 2014-09-10 14:48:40 +0000
> +++ src/ui_basic/listselect.cc 2014-10-27 10:39:23 +0000
> @@ -119,7 +119,7 @@
> * sel if true, directly select the new entry
> */
> void BaseListselect::add
> - (char const * const name,
> + (const std::string& name,
+1 for this change too :) Killing const char* will rid us of these kind of bugs.
> uint32_t entry,
> const Image* pic,
> bool const sel,
> @@ -130,7 +130,7 @@
> er->m_entry = entry;
> er->pic = pic;
> er->use_clr = false;
> - er->name = std::string(name);
> + er->name = name;
> er->tooltip = tooltip_text;
> uint32_t entry_height = 0;
> if (!pic) {
> @@ -158,7 +158,7 @@
> }
>
> void BaseListselect::add_front
> - (char const * const name,
> + (const std::string& name,
> const Image* pic,
> bool const sel,
> const std::string & tooltip_text)
> @@ -172,7 +172,7 @@
>
> er->pic = pic;
> er->use_clr = false;
> - er->name = std::string(name);
> + er->name = name;
> er->tooltip = tooltip_text;
>
> uint32_t entry_height = 0;
>
> === modified file 'src/ui_basic/listselect.h'
> --- src/ui_basic/listselect.h 2014-09-14 11:31:58 +0000
> +++ src/ui_basic/listselect.h 2014-10-27 10:39:23 +0000
> @@ -60,13 +60,13 @@
> (const uint32_t Begin = 0,
> uint32_t End = std::numeric_limits<uint32_t>::max());
> void add
> - (const char * const name,
> + (const std::string& name,
> uint32_t value,
> const Image* pic = nullptr,
> const bool select_this = false,
> const std::string & tooltip_text = std::string());
> void add_front
> - (const char * const name,
> + (const std::string& name,
> const Image* pic = nullptr,
> const bool select_this = false,
> const std::string & tooltip_text = std::string());
> @@ -166,7 +166,7 @@
> {}
>
> void add
> - (const char * const name,
> + (const std::string& name,
> Entry value,
> const Image* pic = nullptr,
> const bool select_this = false,
> @@ -176,7 +176,7 @@
> BaseListselect::add(name, m_entry_cache.size() - 1, pic, select_this, tooltip_text);
> }
> void add_front
> - (const char * const name,
> + (const std::string& name,
> Entry value,
> const Image* pic = nullptr,
> const bool select_this = false,
> @@ -221,7 +221,7 @@
> {}
>
> void add
> - (const char * const name,
> + (const std::string& name,
> Entry & value,
> const Image* pic = nullptr,
> const bool select_this = false,
> @@ -230,7 +230,7 @@
> Base::add(name, &value, pic, select_this, tooltip_text);
> }
> void add_front
> - (const char * const name,
> + (const std::string& name,
> Entry & value,
> const Image* pic = nullptr,
> const bool select_this = false,
>
> === modified file 'src/ui_fsmenu/editor_mapselect.cc'
> --- src/ui_fsmenu/editor_mapselect.cc 2014-09-30 05:41:55 +0000
> +++ src/ui_fsmenu/editor_mapselect.cc 2014-10-27 10:39:23 +0000
> @@ -209,12 +209,11 @@
> #else
> m_parentdir = m_curdir.substr(0, m_curdir.rfind('\\'));
> #endif
> - std::string parent_string =
> +
> + m_list.add
> /** TRANSLATORS: Parent directory */
> - (boost::format("\\<%s\\>") % _("parent")).str();
> - m_list.add
> - (parent_string.c_str(),
> - m_parentdir.c_str(),
> + ((boost::format("\\<%s\\>") % _("parent")).str(),
> + m_parentdir.c_str(),
> g_gr->images().get("pics/ls_dir.png"));
> }
>
>
> === modified file 'src/ui_fsmenu/internet_lobby.cc'
> --- src/ui_fsmenu/internet_lobby.cc 2014-09-20 09:37:47 +0000
> +++ src/ui_fsmenu/internet_lobby.cc 2014-10-27 10:39:23 +0000
> @@ -249,7 +249,7 @@
> // than one server with the same name.
> if (games.at(i).name == localservername)
> hostgame.set_enabled(false);
> - opengames.add(games.at(i).name.c_str(), games.at(i), pic, false, games.at(i).build_id);
> + opengames.add(games.at(i).name, games.at(i), pic, false, games.at(i).build_id);
> }
> }
>
>
> === modified file 'src/ui_fsmenu/launch_mpg.cc'
> --- src/ui_fsmenu/launch_mpg.cc 2014-10-26 12:17:01 +0000
> +++ src/ui_fsmenu/launch_mpg.cc 2014-10-27 10:39:23 +0000
> @@ -45,8 +45,6 @@
> #include "wui/multiplayersetupgroup.h"
> #include "wui/text_constants.h"
>
> -using boost::format;
> -
> /// Simple user interaction window for selecting either map, save or cancel
> struct MapOrSaveSelectionWindow : public UI::Window {
> MapOrSaveSelectionWindow
> @@ -484,10 +482,10 @@
> std::string temp =
> (settings.playernum > -1) && (settings.playernum < MAX_PLAYERS)
> ?
> - (format(_("Player %i")) % (settings.playernum + 1)).str()
> + (boost::format(_("Player %i")) % (settings.playernum + 1)).str()
> :
> _("Spectator");
> - temp = (format(_("At the moment you are %s")) % temp.c_str()).str() + "\n\n";
> + temp = (boost::format(_("At the moment you are %s")) % temp.c_str()).str() + "\n\n";
> temp += _("Click on the ‘?’ in the top right corner to get help.");
> m_client_info.set_text(temp);
> }
> @@ -557,7 +555,7 @@
> for (; i <= m_nr_players; ++i) {
> infotext += "\n* ";
> Section & s = prof.get_safe_section((boost::format("player_%u")
> - % static_cast<unsigned int>(i)).str().c_str());
> + % static_cast<unsigned int>(i)).str());
> player_save_name [i - 1] = s.get_string("name");
> player_save_tribe[i - 1] = s.get_string("tribe");
> player_save_ai [i - 1] = s.get_string("ai");
> @@ -639,12 +637,12 @@
>
> std::string infotext;
> infotext += std::string(_("Map details:")) + "\n";
> - infotext += std::string("• ") + (format(_("Size: %1$u x %2$u"))
> + infotext += std::string("• ") + (boost::format(_("Size: %1$u x %2$u"))
> % map.get_width() % map.get_height()).str() + "\n";
> - infotext += std::string("• ") + (format(ngettext("%u Player", "%u Players", m_nr_players))
> + infotext += std::string("• ") + (boost::format(ngettext("%u Player", "%u Players", m_nr_players))
> % m_nr_players).str() + "\n";
> if (m_settings->settings().scenario)
> - infotext += std::string("• ") + (format(_("Scenario mode selected"))).str() + "\n";
> + infotext += std::string("• ") + (boost::format(_("Scenario mode selected"))).str() + "\n";
> infotext += "\n";
> infotext += map.get_description();
> infotext += "\n";
>
> === modified file 'src/ui_fsmenu/loadgame.cc'
> --- src/ui_fsmenu/loadgame.cc 2014-10-11 16:08:10 +0000
> +++ src/ui_fsmenu/loadgame.cc 2014-10-27 10:39:23 +0000
> @@ -294,7 +294,7 @@
> if (m_settings && !m_settings->settings().saved_games.empty()) {
> for (uint32_t i = 0; i < m_settings->settings().saved_games.size(); ++i) {
> const char * path = m_settings->settings().saved_games.at(i).path.c_str();
> - m_list.add(FileSystem::filename_without_ext(path).c_str(), path);
> + m_list.add(FileSystem::filename_without_ext(path), path);
> }
> } else { // Normal case
> // Fill it with all files we find.
> @@ -365,7 +365,7 @@
> }
> // End localization section
>
> - m_list.add(displaytitle.c_str(), name);
> + m_list.add(displaytitle, name);
> } catch (const WException &) {
> // we simply skip illegal entries
> }
>
> === modified file 'src/ui_fsmenu/loadreplay.cc'
> --- src/ui_fsmenu/loadreplay.cc 2014-10-11 16:08:10 +0000
> +++ src/ui_fsmenu/loadreplay.cc 2014-10-27 10:39:23 +0000
> @@ -291,7 +291,7 @@
> }
> // End localization section
>
> - m_list.add(displaytitle.c_str(), *pname);
> + m_list.add(displaytitle, *pname);
> } catch (const WException &) {} // we simply skip illegal entries
> }
>
>
> === modified file 'src/ui_fsmenu/options.cc'
> --- src/ui_fsmenu/options.cc 2014-09-29 19:25:24 +0000
> +++ src/ui_fsmenu/options.cc 2014-10-27 10:39:23 +0000
> @@ -79,7 +79,7 @@
> std::sort(entries.begin(), entries.end());
>
> for (const LanguageEntry& entry : entries) {
> - list->add(entry.descname.c_str(), entry.abbreviation, nullptr, entry.abbreviation == language);
> + list->add(entry.descname, entry.abbreviation, nullptr, entry.abbreviation == language);
> }
> }
>
> @@ -367,13 +367,13 @@
> /** TRANSLATORS: Screen resolution, e.g. 800 x 600*/
> m_reslist.add((boost::format(_("%1% x %2%"))
> % m_resolutions[i].xres
> - % m_resolutions[i].yres).str().c_str(),
> + % m_resolutions[i].yres).str(),
> nullptr, nullptr, selected);
> }
> if (!did_select_a_res) {
> m_reslist.add((boost::format(_("%1% x %2%"))
> % opt.xres
> - % opt.yres).str().c_str(),
> + % opt.yres).str(),
> nullptr, nullptr, true);
> uint32_t entry = m_resolutions.size();
> m_resolutions.resize(entry + 1);
>
> === modified file 'src/wlapplication.cc'
> --- src/wlapplication.cc 2014-10-16 05:54:05 +0000
> +++ src/wlapplication.cc 2014-10-27 10:39:23 +0000
> @@ -532,7 +532,7 @@
> g_fs->ensure_directory_exists(SCREENSHOT_DIR);
> for (uint32_t nr = 0; nr < 10000; ++nr) {
> const std::string filename = (boost::format(SCREENSHOT_DIR "/shot%04u.png")
> - % nr).str().c_str();
> + % nr).str();
> if (g_fs->file_exists(filename))
> continue;
> g_gr->screenshot(filename);
>
> === modified file 'src/wui/actionconfirm.cc'
> --- src/wui/actionconfirm.cc 2014-09-10 14:48:40 +0000
> +++ src/wui/actionconfirm.cc 2014-10-27 10:39:23 +0000
> @@ -31,7 +31,6 @@
> #include "ui_basic/window.h"
> #include "wui/interactive_player.h"
>
> -using boost::format;
>
> struct ActionConfirm : public UI::Window {
> ActionConfirm
> @@ -148,7 +147,7 @@
> new UI::MultilineTextarea
> (this,
> 0, 0, 200, 74,
> - (format(message) % building.descr().descname()).str(),
> + (boost::format(message) % building.descr().descname()).str(),
> UI::Align_Center);
>
> UI::Button * okbtn =
>
> === modified file 'src/wui/encyclopedia_window.cc'
> --- src/wui/encyclopedia_window.cc 2014-09-30 05:41:55 +0000
> +++ src/wui/encyclopedia_window.cc 2014-10-27 10:39:23 +0000
> @@ -99,7 +99,7 @@
>
> for (uint32_t i = 0; i < ware_vec.size(); i++) {
> Ware cur = ware_vec[i];
> - wares.add(cur.m_descr->descname().c_str(), cur.m_i, cur.m_descr->icon());
> + wares.add(cur.m_descr->descname(), cur.m_i, cur.m_descr->icon());
> }
> }
>
> @@ -124,7 +124,7 @@
> &&
> de->output_ware_types().count(wares.get_selected()))
> {
> - prodSites.add(de->descname().c_str(), i, de->get_icon());
> + prodSites.add(de->descname(), i, de->get_icon());
> found = true;
> }
> }
>
> === modified file 'src/wui/game_debug_ui.cc'
> --- src/wui/game_debug_ui.cc 2014-09-30 05:41:55 +0000
> +++ src/wui/game_debug_ui.cc 2014-10-27 10:39:23 +0000
> @@ -180,7 +180,7 @@
> }
> UI::Window::think();
> } else {
> - set_title((boost::format("DEAD: %u") % m_serial).str().c_str());
> + set_title((boost::format("DEAD: %u") % m_serial).str());
> }
>
> }
> @@ -375,7 +375,7 @@
> {
> m_ui_immovable.set_title((boost::format("%s (%u)")
> % imm->descr().name().c_str()
> - % imm->serial()).str().c_str());
> + % imm->serial()).str());
> m_ui_immovable.set_enabled(true);
> } else {
> m_ui_immovable.set_title("no immovable");
> @@ -420,7 +420,7 @@
> m_ui_bobs.add(
> (boost::format("%s (%u)")
> % temp_bob->descr().name()
> - % temp_bob->serial()).str().c_str(),
> + % temp_bob->serial()).str(),
> temp_bob->serial());
> }
> }
>
> === modified file 'src/wui/game_main_menu_save_game.cc'
> --- src/wui/game_main_menu_save_game.cc 2014-10-07 10:20:18 +0000
> +++ src/wui/game_main_menu_save_game.cc 2014-10-27 10:39:23 +0000
> @@ -34,8 +34,6 @@
> #include "profile/profile.h"
> #include "wui/interactive_gamebase.h"
>
> -using boost::format;
> -
> InteractiveGameBase & GameMainMenuSaveGame::igbase() {
> return ref_cast<InteractiveGameBase, UI::Panel>(*get_parent());
> }
> @@ -168,14 +166,10 @@
> m_gametime.set_text(gametimestring(gametime));
>
> if (gpdp.get_number_of_players() > 0) {
> - char buf[200];
> - sprintf
> - (buf, "%i %s", gpdp.get_number_of_players(),
> - // TODO(GunChleoc): This should be ngettext(" %i player" etc.
> - // with boost::format, but it refuses to work
> - /** TRANSLATORS: This is preceded by a number */
> - ngettext("player", "players", gpdp.get_number_of_players()));
> - m_players_label.set_text(buf);
> + const std::string text =
> + (boost::format(ngettext("%u Player", "%u Players", gpdp.get_number_of_players()))
> + % static_cast<unsigned int>(gpdp.get_number_of_players())).str();
> + m_players_label.set_text(text);
> } else {
> // Keep label empty
> m_players_label.set_text("");
> @@ -212,7 +206,7 @@
> try {
> Widelands::GameLoader gl(name, igbase().game());
> gl.preload_game(gpdp);
> - m_ls.add(FileSystem::filename_without_ext(name).c_str(), name);
> + m_ls.add(FileSystem::filename_without_ext(name), name);
> } catch (const WException &) {} // we simply skip illegal entries
> }
> }
> @@ -325,7 +319,7 @@
> (&parent,
> _("File deletion"),
> str
> - (format(_("Do you really want to delete the file %s?")) %
> + (boost::format(_("Do you really want to delete the file %s?")) %
> FileSystem::fs_filename(filename.c_str())),
> YESNO),
> m_filename(filename)
>
> === modified file 'src/wui/game_objectives_menu.cc'
> --- src/wui/game_objectives_menu.cc 2014-09-14 11:31:58 +0000
> +++ src/wui/game_objectives_menu.cc 2014-10-27 10:39:23 +0000
> @@ -71,7 +71,7 @@
> for (uint32_t j = 0;; ++j)
> if (j == list_size) { // the objective is not in our list
> if (should_show)
> - list.add(obj.descname().c_str(), obj);
> + list.add(obj.descname(), obj);
> break;
> } else if (&list[j] == &obj) { // the objective is in our list
> if (!should_show)
> @@ -79,7 +79,7 @@
> else if (list[j].descname() != obj.descname() || list[j].descr() != obj.descr()) {
> // Update
> list.remove(j);
> - list.add(obj.descname().c_str(), obj);
> + list.add(obj.descname(), obj);
> }
> break;
> }
>
> === modified file 'src/wui/general_statistics_menu.cc'
> --- src/wui/general_statistics_menu.cc 2014-09-18 18:52:34 +0000
> +++ src/wui/general_statistics_menu.cc 2014-10-27 10:39:23 +0000
> @@ -148,7 +148,7 @@
>
> iterate_players_existing_const(p, nr_players, game, player) {
> const std::string pic = (boost::format("pics/genstats_enable_plr_%02u.png")
> - % static_cast<unsigned int>(p)).str().c_str();
> + % static_cast<unsigned int>(p)).str();
> UI::Button & cb =
> *new UI::Button
> (hbox1, "playerbutton",
>
> === modified file 'src/wui/interactive_base.cc'
> --- src/wui/interactive_base.cc 2014-10-19 16:24:33 +0000
> +++ src/wui/interactive_base.cc 2014-10-27 10:39:23 +0000
> @@ -57,7 +57,6 @@
> #include "wui/text_layout.h"
> #include "wui/unique_window_handler.h"
>
> -using boost::format;
> using Widelands::Area;
> using Widelands::CoordPath;
> using Widelands::Coords;
> @@ -329,12 +328,12 @@
> (real == 1000 ? std::string() : speed_string(real));
> else {
> m_label_speed.set_text(
> - (format
> + (boost::format
> /** TRANSLATORS: actual_speed (desired_speed) */
> (_("%1$s (%2$s)"))
> % speed_string(real).c_str()
> % speed_string(desired).c_str()
> - ).str().c_str()
> + ).str()
> );
> }
> } else
> @@ -407,7 +406,7 @@
> const std::string gametime(gametimestring(egbase().get_gametime()));
> const std::string gametime_text = as_uifont(gametime, UI_FONT_SIZE_SMALL);
> dst.blit(Point(5, 5), UI::g_fh1->render(gametime_text), CM_Normal, UI::Align_TopLeft);
> - static format node_format("(%i, %i)");
> + static boost::format node_format("(%i, %i)");
>
> const std::string node_text = as_uifont
> ((node_format % m_sel.pos.node.x % m_sel.pos.node.y).str(), UI_FONT_SIZE_SMALL);
> @@ -421,7 +420,7 @@
>
> // Blit FPS when in debug mode.
> if (get_display_flag(dfDebug)) {
> - static format fps_format("%5.1f fps (avg: %5.1f fps)");
> + static boost::format fps_format("%5.1f fps (avg: %5.1f fps)");
> const std::string fps_text = as_uifont
> ((fps_format %
> (1000.0 / m_frametime) % (1000.0 / (m_avg_usframetime / 1000)))
> @@ -993,7 +992,7 @@
>
> if (!obj) {
> DebugConsole::write
> - (str(format("No MapObject with serial number %1%") % serial));
> + (str(boost::format("No MapObject with serial number %1%") % serial));
> return;
> }
>
>
> === modified file 'src/wui/interactive_player.cc'
> --- src/wui/interactive_player.cc 2014-09-19 12:54:54 +0000
> +++ src/wui/interactive_player.cc 2014-10-27 10:39:23 +0000
> @@ -60,8 +60,6 @@
>
> using Widelands::Building;
> using Widelands::Map;
> -using boost::format;
> -
>
> namespace {
>
> @@ -456,13 +454,13 @@
>
> int const n = atoi(args[1].c_str());
> if (n < 1 || n > MAX_PLAYERS || !game().get_player(n)) {
> - DebugConsole::write(str(format("Player #%1% does not exist.") % n));
> + DebugConsole::write(str(boost::format("Player #%1% does not exist.") % n));
> return;
> }
>
> DebugConsole::write
> (str
> - (format("Switching from #%1% to #%2%.")
> + (boost::format("Switching from #%1% to #%2%.")
> % static_cast<int>(m_player_number) % n));
> m_player_number = n;
> Map & map = egbase().map();
>
> === modified file 'src/wui/multiplayersetupgroup.cc'
> --- src/wui/multiplayersetupgroup.cc 2014-10-26 12:17:01 +0000
> +++ src/wui/multiplayersetupgroup.cc 2014-10-27 10:39:23 +0000
> @@ -121,7 +121,7 @@
> pic = (boost::format("pics/genstats_enable_plr_0%u.png")
> % static_cast<unsigned int>(us.position + 1)).str();
> temp_tooltip = (boost::format(_("Player %u"))
> - % static_cast<unsigned int>(us.position + 1)).str().c_str();
> + % static_cast<unsigned int>(us.position + 1)).str();
> } else {
> pic = "pics/menu_tab_watch.png";
> temp_tooltip = _("Spectator");
> @@ -174,7 +174,7 @@
> set_size(w, h);
>
> const std::string pic = (boost::format("pics/fsel_editor_set_player_0%i_pos.png")
> - % static_cast<unsigned int>(id + 1)).str().c_str();
> + % static_cast<unsigned int>(id + 1)).str();
> player =
> new UI::Icon(this, 0, 0, h, h, g_gr->images().get(pic));
> add(player, UI::Box::AlignCenter);
> @@ -288,11 +288,11 @@
> type ->set_pic(g_gr->images().get("pics/shared_in.png"));
>
> const std::string pic = (boost::format("pics/fsel_editor_set_player_0%u_pos.png")
> - % static_cast<unsigned int>(player_setting.shared_in)).str().c_str();
> + % static_cast<unsigned int>(player_setting.shared_in)).str();
>
> tribe->set_pic(g_gr->images().get(pic));
> tribe->set_tooltip((boost::format(_("Player %u"))
> - % static_cast<unsigned int>(player_setting.shared_in)).str().c_str());
> + % static_cast<unsigned int>(player_setting.shared_in)).str());
>
> team ->set_visible(false);
> team ->set_enabled(false);
>
> === modified file 'src/wui/plot_area.cc'
> --- src/wui/plot_area.cc 2014-09-18 18:52:34 +0000
> +++ src/wui/plot_area.cc 2014-10-27 10:39:23 +0000
> @@ -35,7 +35,6 @@
> #include "wui/text_layout.h"
>
> using namespace std;
> -using boost::format;
>
> namespace {
>
> @@ -71,7 +70,8 @@
> };
>
> string ytick_text_style(const string& text, const RGBColor& clr) {
> - static format f("<rt><p><font face=DejaVuSansCondensed size=13 color=%02x%02x%02x>%s</font></p></rt>");
> + static boost::format
> + f("<rt><p><font face=DejaVuSansCondensed size=13 color=%02x%02x%02x>%s</font></p></rt>");
> f % int(clr.r) % int(clr.g) % int(clr.b);
> f % text;
> return f.str();
>
--
https://code.launchpad.net/~widelands-dev/widelands/bug-1385859/+merge/239705
Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/bug-1385859.
References