GCC complains about float/double and useless cast

This commit is contained in:
Gregory A Lundberg 2016-10-13 16:45:58 -05:00
parent 0ecbbef033
commit 86adfc47f8
20 changed files with 42 additions and 42 deletions

View File

@ -113,11 +113,11 @@ namespace {
if(u1) {
unit_ptr who = get_unit(e.uid1, e.id1);
who->set_location(map_location(real1));
who->set_location(real1);
}
if(u2) {
unit_ptr who = get_unit(e.uid2, e.id2);
who->set_location(map_location(real2));
who->set_location(real2);
}
x1 = oldx1; y1 = oldy1;

View File

@ -99,16 +99,16 @@ std::string describe_addon_status(const addon_tracking_info& info)
// Consider add-ons without version information as installed
// for the main display. Their Description info should elaborate
// on their status.
return font::GOOD_TEXT + std::string(
return font::GOOD_TEXT + (
info.can_publish ? _("addon_state^Published") : _("addon_state^Installed"));
case ADDON_INSTALLED_UPGRADABLE:
return color_upgradable + std::string(
return color_upgradable + (
info.can_publish ? _("addon_state^Published, upgradable") : _("addon_state^Installed, upgradable"));
case ADDON_INSTALLED_OUTDATED:
return color_outdated + std::string(
return color_outdated + (
info.can_publish ? _("addon_state^Published, outdated on server") : _("addon_state^Installed, outdated on server"));
case ADDON_INSTALLED_BROKEN:
return font::BAD_TEXT + std::string(
return font::BAD_TEXT + (
info.can_publish ? _("addon_state^Published, broken") : _("addon_state^Installed, broken"));
default:
return font::color2markup(font::GRAY_COLOR) + _("addon_state^Unknown");
@ -127,7 +127,7 @@ bool try_fetch_addon(CVideo & v, addons_client & client, const addon_info & addo
const std::string& server_error = client.get_last_server_error();
if(!server_error.empty()) {
gui2::show_error_message(v,
std::string(_("The server responded with an error:")) + "\n" + server_error);
_("The server responded with an error:") + "\n" + server_error);
}
return false;
} else {
@ -369,7 +369,7 @@ void do_remote_addon_delete(CVideo& video, addons_client& client, const std::str
std::string server_msg;
if(!client.delete_remote_addon(addon_id, server_msg)) {
gui2::show_error_message(video,
std::string(_("The server responded with an error:")) + "\n" +
_("The server responded with an error:") + "\n" +
client.get_last_server_error());
} else {
// FIXME: translation needed!
@ -401,12 +401,12 @@ void do_remote_addon_publish(CVideo& video, addons_client& client, const std::st
gui2::show_error_message(video, _("Invalid icon path. Make sure the path points to a valid image."));
} else if(!client.request_distribution_terms(server_msg)) {
gui2::show_error_message(video,
std::string(_("The server responded with an error:")) + "\n" +
_("The server responded with an error:") + "\n" +
client.get_last_server_error());
} else if(gui2::show_message(video, _("Terms"), server_msg, gui2::tmessage::ok_cancel_buttons) == gui2::twindow::OK) {
if(!client.upload_addon(addon_id, server_msg, cfg)) {
gui2::show_error_message(video,
std::string(_("The server responded with an error:")) + "\n" +
_("The server responded with an error:") + "\n" +
client.get_last_server_error());
} else {
gui2::show_transient_message(video, _("Response"), server_msg);

View File

@ -126,7 +126,7 @@ variant variant_iterator::operator*() const
{
if (type_ == TYPE_LIST)
{
return variant( *list_iterator_);
return *list_iterator_;
} else if (type_ == TYPE_MAP)
{
game_logic::key_value_pair* p = new game_logic::key_value_pair( map_iterator_->first, map_iterator_->second );

View File

@ -111,7 +111,7 @@ connect_engine::connect_engine(saved_game& state,
// Set the team name lists and modify the original level sides,
// if necessary.
std::vector<std::string> original_team_names;
std::string team_prefix(std::string(_("Team")) + " ");
std::string team_prefix(_("Team") + " ");
int side_count = 1;
for (config& side : sides) {
const std::string side_str = std::to_string(side_count);

View File

@ -55,7 +55,7 @@ configure::nolock_settings::nolock_settings(CVideo& video)
, village_support_label_(video, "", font::SIZE_SMALL, font::LOBBY_COLOR)
, xp_modifier_slider_(video)
, xp_modifier_label_(video, "", font::SIZE_SMALL, font::LOBBY_COLOR)
, generic_label_(video, "`~ " + std::string(_("Generic")), font::SIZE_PLUS, font::LOBBY_COLOR)
, generic_label_(video, "`~ " + _("Generic"), font::SIZE_PLUS, font::LOBBY_COLOR)
, use_map_settings_(video, _("Use map settings"), gui::button::TYPE_CHECK)
, random_start_time_(video, _("Random start time"), gui::button::TYPE_CHECK)
, fog_game_(video, _("Fog of war"), gui::button::TYPE_CHECK)

View File

@ -809,10 +809,10 @@ void gamebrowser::populate_game_item(gamebrowser::game_item & item, const config
} else {
item.started = false;
if (item.vacant_slots > 0) {
item.status = std::string(_n("Vacant Slot:", "Vacant Slots:",
item.vacant_slots)) + " " + slots;
item.status = _n("Vacant Slot:", "Vacant Slots:",
item.vacant_slots) + " " + slots;
if (item.password_required) {
item.status += std::string(" (") + std::string(_("Password Required")) + ")";
item.status += std::string(" (") + _("Password Required") + ")";
}
}
}

View File

@ -299,10 +299,10 @@ LEVEL_RESULT campaign_controller::play_game()
gui2::show_error_message(video_, _("Error while playing the game: ") + e.message);
return LEVEL_RESULT::QUIT;
} catch(incorrect_map_format_error& e) {
gui2::show_error_message(video_, std::string(_("The game map could not be loaded: ")) + e.message);
gui2::show_error_message(video_, _("The game map could not be loaded: ") + e.message);
return LEVEL_RESULT::QUIT;
} catch (mapgen_exception& e) {
gui2::show_error_message(video_, std::string(_("Map generator error: ") + e.message));
gui2::show_error_message(video_, _("Map generator error: ") + e.message);
} catch(config::error& e) {
gui2::show_error_message(video_, _("Error while reading the WML: ") + e.message);
return LEVEL_RESULT::QUIT;

View File

@ -850,7 +850,7 @@ bool game_launcher::play_multiplayer(mp_selection res)
} catch(game::game_error& e) {
gui2::show_error_message(video(), _("Error while playing the game: ") + e.message);
} catch (mapgen_exception& e) {
gui2::show_error_message(video(), std::string(_("Map generator error: ") + e.message));
gui2::show_error_message(video(), _("Map generator error: ") + e.message);
} catch(wesnothd_error& e) {
if(e.message != "") {
ERR_NET << "caught network error: " << e.message << std::endl;
@ -868,7 +868,7 @@ bool game_launcher::play_multiplayer(mp_selection res)
ERR_CONFIG << "caught config::error" << std::endl;
}
} catch(incorrect_map_format_error& e) {
gui2::show_error_message(video(), std::string(_("The game map could not be loaded: ")) + e.message);
gui2::show_error_message(video(), _("The game map could not be loaded: ") + e.message);
} catch (savegame::load_game_exception & e) {
load_data_.reset(new savegame::load_game_metadata(std::move(e.data_)));
//this will make it so next time through the title screen loop, this game is loaded

View File

@ -162,10 +162,10 @@ static void draw_circle(surface& canvas,
<< " with radius " << radius << " canvas width " << w
<< " canvas height " << canvas->h << ".\n";
assert(static_cast<int>(x_center + radius) < canvas->w);
assert(static_cast<int>(x_center - radius) >= 0);
assert(static_cast<int>(y_center + radius) < canvas->h);
assert(static_cast<int>(y_center - radius) >= 0);
assert((x_center + radius) < canvas->w);
assert((x_center - radius) >= 0);
assert((y_center + radius) < canvas->h);
assert((y_center - radius) >= 0);
set_renderer_color(renderer, color);

View File

@ -710,7 +710,7 @@ void thandler::key_down(const SDL_Event& event)
void thandler::text_input(const std::string& unicode)
{
key_down(static_cast<SDL_Keycode>(0), static_cast<SDL_Keymod>(0), unicode);
key_down(0, static_cast<SDL_Keymod>(0), unicode);
}
bool thandler::hotkey_pressed(const hotkey::hotkey_ptr key)

View File

@ -410,7 +410,7 @@ game_info::game_info(const config& game, const config& game_config, const std::v
} else {
started = false;
if(vacant_slots > 0) {
status = std::string(_n("Vacant Slot:", "Vacant Slots:", vacant_slots)) + " " + game["slots"];
status = _n("Vacant Slot:", "Vacant Slots:", vacant_slots) + " " + game["slots"];
}
}

View File

@ -558,7 +558,7 @@ std::string help_text_area::ref_at(const int x, const int y)
{
const int local_x = x - location().x;
const int local_y = y - location().y;
if (local_y < static_cast<int>(height()) && local_y > 0) {
if (local_y < height() && local_y > 0) {
const int cmp_y = local_y + get_position();
const std::list<item>::const_iterator it =
std::find_if(items_.begin(), items_.end(), item_at(local_x, cmp_y));

View File

@ -209,7 +209,7 @@ void play_controller::hotkey_handler::toggle_accelerated_speed()
{
utils::string_map symbols;
symbols["hk"] = hotkey::get_names(hotkey::hotkey_command::get_command_by_command(hotkey::HOTKEY_ACCELERATED).command);
gui()->announce(std::string(_("Accelerated speed enabled!")) + "\n" + vgettext("(press $hk to disable)", symbols), font::NORMAL_COLOR);
gui()->announce(_("Accelerated speed enabled!") + "\n" + vgettext("(press $hk to disable)", symbols), font::NORMAL_COLOR);
}
else
{

View File

@ -86,7 +86,7 @@ bool playturn_network_adapter::read(config& dst)
}
config& child = dst.add_child(next_->key);
//TODO: implement a non const version of ordered children
config& child_old = const_cast<config&>(next_->cfg);
config& child_old = next_->cfg;
if(next_->key == "turn")
{
//split [turn] indo different [turn] for each child.
@ -94,7 +94,7 @@ bool playturn_network_adapter::read(config& dst)
config::all_children_iterator itor = child_old.ordered_begin();
std::advance(itor, next_command_num_);
//TODO: implement a non const version of ordered children
config& childchild_old = const_cast<config&>(itor->cfg);
config& childchild_old = itor->cfg;
config& childchild = child.add_child(itor->key);
childchild.swap(childchild_old);

View File

@ -202,7 +202,7 @@ static int impl_vconfig_get(lua_State *L)
lua_createtable(L, 2, 0);
lua_pushstring(L, i.get_key().c_str());
lua_rawseti(L, -2, 1);
luaW_pushvconfig(L, vconfig(i.get_child()));
luaW_pushvconfig(L, i.get_child());
lua_rawseti(L, -2, 2);
return 1;
}

View File

@ -562,10 +562,10 @@ surface scale_surface_sharp(const surface& surf, int w, int h, bool optimize)
}
if (alpha != 0) {
red = red / alpha + 0.5;
green = green / alpha + 0.5;
blue = blue / alpha + 0.5;
alpha = alpha / summation + 0.5;
red = red / alpha + 0.5f;
green = green / alpha + 0.5f;
blue = blue / alpha + 0.5f;
alpha = alpha / summation + 0.5f;
}
dst_pixels[ydst*dst->w + xdst] = SDL_MapRGBA(
@ -1948,8 +1948,8 @@ surface rotate_any_surface(const surface& surf, float angle, int zoom, int offse
float max_x, max_y;
// convert angle to radiant (angle * 2 * PI) / 360
const float radians = angle * boost::math::constants::pi<float>() / 180;
cosine = static_cast<float>(cos(radians));
sine = static_cast<float>(sin(radians));
cosine = cos(radians);
sine = sin(radians);
// calculate the size of the dst image
src_w = surf->w * zoom;
src_h = surf->h * zoom;

View File

@ -203,7 +203,7 @@ dialog_frame::dimension_measurements dialog_frame::layout(int x, int y, int w, i
}
y -= dim_.title.h;
w = std::max<int>(w,std::max<int>(int(dim_.title.w),int(buttons_width)));
w = std::max<int>(w,std::max<int>(dim_.title.w,int(buttons_width)));
h += dim_.title.h + dim_.button_row.h;
dim_.button_row.x += x + w;

View File

@ -168,7 +168,7 @@ bool terrain_filter::match_internal(const map_location& loc, const bool ignore_x
if (!u.valid())
return false;
if (!cache_.ufilter_)
cache_.ufilter_.reset(new unit_filter(vconfig(cfg_.child("filter")), fc_, flat_));
cache_.ufilter_.reset(new unit_filter(cfg_.child("filter"), fc_, flat_));
if (!cache_.ufilter_->matches(*u, loc))
return false;
}

View File

@ -121,7 +121,7 @@ static config &find_ref(const std::string &id, config &cfg, bool remove = false)
config::all_children_itors itors = cfg.all_children_range();
for (config::all_children_iterator i = itors.begin(); i != itors.end(); ++i)
{
config &icfg = const_cast<config &>(i->cfg);
config &icfg = i->cfg;
if (i->cfg["id"] == id) {
if (remove) {
cfg.erase(i);

View File

@ -134,7 +134,7 @@ void update_rect(const SDL_Rect& rect_value)
surface const fb = nullptr;
if(fb != nullptr) {
if(rect.x < 0) {
if(rect.x*-1 >= int(rect.w))
if(rect.x*-1 >= rect.w)
return;
rect.w += rect.x;
@ -142,7 +142,7 @@ void update_rect(const SDL_Rect& rect_value)
}
if(rect.y < 0) {
if(rect.y*-1 >= int(rect.h))
if(rect.y*-1 >= rect.h)
return;
rect.h += rect.y;