widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #05805
Re: [Merge] lp:~widelands-dev/widelands/obsolete_format_macro into lp:widelands
Review: Approve
Great improvements. One nit and travis green and this is good to go.
Diff comments:
> === modified file 'src/logic/map_objects/tribes/building.cc'
> --- src/logic/map_objects/tribes/building.cc 2016-01-29 08:37:22 +0000
> +++ src/logic/map_objects/tribes/building.cc 2016-02-01 17:54:54 +0000
> @@ -481,66 +481,28 @@
> egbase.create_immovable(pos, "destroyed_building", MapObjectDescr::OwnerType::kTribe);
> }
>
> -
> -#define FORMAT(key, value) case key: result << value; break
> -std::string Building::info_string(const std::string & format) {
> - std::ostringstream result;
> -
> - for (std::string::const_iterator format_iter = format.begin();
> - format_iter != format.end();
> - ++format_iter) {
> -
> - if (*format_iter == '%') {
> - if (++format_iter == format.end()) { // unterminated format sequence
> - result << '%';
> - break;
> - }
> -
> - switch (*format_iter) {
> - FORMAT('%', '%');
> - FORMAT('i', serial());
> - FORMAT('t', update_and_get_statistics_string());
> - FORMAT
> - ('s',
> - (descr().get_ismine() ? _("mine") :
> - get_size () == BaseImmovable::SMALL ? _("small") :
> - get_size () == BaseImmovable::MEDIUM ? _("medium") : _("big")));
> - FORMAT
> - ('S',
> - (descr().get_ismine() ? _("Mine") :
> - get_size () == BaseImmovable::SMALL ? _("Small") :
> - get_size () == BaseImmovable::MEDIUM ? _("Medium") : _("Big")));
> - FORMAT('x', get_position().x);
> - FORMAT('y', get_position().y);
> - FORMAT
> - ('c', '(' << get_position().x << ", " << get_position().y << ')');
> - FORMAT('A', descr().descname());
> - FORMAT('a', descr().name());
> - case 'N':
> - if (upcast(ConstructionSite const, constructionsite, this))
> - result << constructionsite->building().descname();
> - else
> - result << descr().descname();
> - break;
> - case 'n':
> - if (upcast(ConstructionSite const, constructionsite, this))
> - result << constructionsite->building().name();
> - else
> - result << descr().name();
> - break;
> - case 'r':
> - if (upcast(ProductionSite const, productionsite, this))
> - result << productionsite->production_result();
> - break;
> - default: // invalid format sequence
> - result << '%' << *format_iter;
> - break;
> - }
> - } else
> - result << *format_iter;
> +std::string Building::info_string(InfoStringFormat format) {
const InfoStringFormat format
> + std::string result = "";
> + switch (format) {
> + case InfoStringFormat::kCensus:
> + if (upcast(ConstructionSite const, constructionsite, this)) {
> + result = constructionsite->building().descname();
> + } else {
> + result = descr().descname();
> + }
> + break;
> + case InfoStringFormat::kStatistics:
> + result = update_and_get_statistics_string();
> + break;
> + case InfoStringFormat::kTooltip:
> + if (upcast(ProductionSite const, productionsite, this)) {
> + result = productionsite->production_result();
> + }
> + break;
> + default:
> + NEVER_HERE();
> }
> - const std::string result_str = result.str();
> - return result_str.empty() ? result_str : as_uifont(result_str);
> + return result.empty() ? result : as_uifont(result);
> }
>
>
--
https://code.launchpad.net/~widelands-dev/widelands/obsolete_format_macro/+merge/284590
Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/obsolete_format_macro.
References