widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #08802
[Merge] lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/compiler_warnings_201611/+merge/311329
Fixed some compiler warnings. Do not review this yet, I want to go through the Travis/AppVeyor logs first.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands.
=== modified file 'src/ai/defaultai.cc'
--- src/ai/defaultai.cc 2016-11-19 18:25:49 +0000
+++ src/ai/defaultai.cc 2016-11-20 10:15:14 +0000
@@ -2997,8 +2997,7 @@
if (RoadCandidates.get_winner(&winner_hash, (gametime % 4 > 0) ? 1 : 2)) {
const Widelands::Coords target_coords = Coords::unhash(winner_hash);
Path& path = *new Path();
- const int32_t pathcost = map.findpath(flag.get_position(), target_coords, 0, path, check);
- assert(pathcost >= 0);
+ assert(map.findpath(flag.get_position(), target_coords, 0, path, check) >= 0);
game().send_player_build_road(player_number(), path);
return true;
}
@@ -3561,11 +3560,11 @@
if (!ship_free) {
enough_ships = FleetStatus::kNeedShip;
- // we want at least as many free ships as we have ports
+ // we want at least as many free ships as we have ports
} else if (int(allships.size()) - ports_count - expeditions_in_progress < 0) {
enough_ships = FleetStatus::kNeedShip;
- // if ships utilization is too high
+ // if ships utilization is too high
} else if (persistent_data->ships_utilization > 5000) {
enough_ships = FleetStatus::kNeedShip;
@@ -3599,7 +3598,7 @@
}
// starting an expedition? if yes, find a port and order it to start an expedition
- if (ports_count > 0 && expeditions_in_progress == 0 && expeditions_in_prep == 0 &&
+ if (ports_count > 0 && expeditions_in_progress == 0 && expeditions_in_prep == 0 &&
persistent_data->no_more_expeditions == kFalse && ship_free) {
// we need to find a port
@@ -3724,7 +3723,7 @@
/**
* This is part of check_ships() function separated due to readibility purpuses
*/
- void DefaultAI::check_ship_in_expedition(ShipObserver& so, uint32_t const gametime) {
+void DefaultAI::check_ship_in_expedition(ShipObserver& so, uint32_t const gametime) {
// consistency check
assert(expedition_ship_ == so.ship->serial() || expedition_ship_ == kNoShip);
@@ -4885,8 +4884,8 @@
// abort if any player - including self - is too near to the spot (radius 8)
// TODO(toptopple): extract function for player distance only
- if (other_player_accessible(8, &tested_fields, &mineable_fields_count,
- candidate_spot, WalkSearch::kAnyPlayer)) {
+ if (other_player_accessible(
+ 8, &tested_fields, &mineable_fields_count, candidate_spot, WalkSearch::kAnyPlayer)) {
return 0;
}
@@ -4900,7 +4899,7 @@
// abort if we run into other player
if (other_player_accessible(persistent_data->colony_scan_area, &tested_fields,
- &mineable_fields_count, candidate_spot, search_type)) {
+ &mineable_fields_count, candidate_spot, search_type)) {
return 0;
}
@@ -4945,12 +4944,11 @@
return score;
}
-
// this is called whenever ship received a notification that requires
// navigation decisions (these notifiation are processes not in 'real time')
void DefaultAI::expedition_management(ShipObserver& so) {
- Map& map = game().map();
+ Map& map = game().map();
const int32_t gametime = game().get_gametime();
// probability for island exploration repetition
const int repeat_island_prob = 20;
@@ -4966,7 +4964,7 @@
if (!so.ship->exp_port_spaces().empty()) { // making sure we have possible portspaces
// we score the place (value max == 8)
- const uint8_t spot_score = spot_scoring(so.ship->exp_port_spaces().front()) *2;
+ const uint8_t spot_score = spot_scoring(so.ship->exp_port_spaces().front()) * 2;
if (game().logic_rand() % 8 < spot_score) { // we build a port here
game().send_player_ship_construct_port(*so.ship, so.ship->exp_port_spaces().front());
@@ -4988,20 +4986,20 @@
// 2. Go on with expedition
- // we were not here before
+ // we were not here before
if (first_time_here) {
game().send_player_ship_explore_island(*so.ship, so.island_circ_direction);
- // we were here before but we might randomly repeat island exploration
+ // we were here before but we might randomly repeat island exploration
} else if (game().logic_rand() % 100 < repeat_island_prob) {
// let's add randomness to the Brown's molecule movement of ship
// TODO(toptopple): make the following decision dependent on ship state != circle-island
- Widelands::IslandExploreDirection dir = game().logic_rand() % 10 < 5 ?
- Widelands::IslandExploreDirection::kClockwise :
- Widelands::IslandExploreDirection::kCounterClockwise;
+ Widelands::IslandExploreDirection dir =
+ game().logic_rand() % 10 < 5 ? Widelands::IslandExploreDirection::kClockwise :
+ Widelands::IslandExploreDirection::kCounterClockwise;
game().send_player_ship_explore_island(*so.ship, dir);
- // we head for open sea again
+ // we head for open sea again
} else {
// determine swimmable directions
std::vector<Direction> possible_directions;
@@ -5026,7 +5024,8 @@
// 2.A No there is no open sea
// ## test-out of cancel-expedition method
// ## circle island has danger of endless repetition
- // TODO(unknown): we should implement a 'rescue' procedure like 'sail for x fields and rethink'
+ // TODO(unknown): we should implement a 'rescue' procedure like 'sail for x fields and
+ // rethink'
game().send_player_cancel_expedition_ship(*so.ship);
// game().send_player_ship_explore_island(*so.ship, so.island_circ_direction);
=== modified file 'src/editor/ui_menus/tool_place_bob_options_menu.cc'
--- src/editor/ui_menus/tool_place_bob_options_menu.cc 2016-10-16 09:31:42 +0000
+++ src/editor/ui_menus/tool_place_bob_options_menu.cc 2016-11-20 10:15:14 +0000
@@ -48,7 +48,7 @@
const Widelands::World& world = parent.egbase().world();
int32_t const nr_bobs = world.get_nr_bobs();
const uint32_t bobs_in_row =
- std::max(std::min(static_cast<uint32_t>(ceil(sqrt(static_cast<float>(nr_bobs)))), 24U), 12U);
+ std::max(std::min(static_cast<uint32_t>(ceil(sqrt(static_cast<double>(nr_bobs)))), 24U), 12U);
set_center_panel(&tabpanel_);
=== modified file 'src/network/netclient.cc'
--- src/network/netclient.cc 2016-08-04 15:49:05 +0000
+++ src/network/netclient.cc 2016-11-20 10:15:14 +0000
@@ -23,7 +23,6 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/format.hpp>
-#include <boost/lexical_cast.hpp>
#include "base/i18n.h"
#include "base/warning.h"
@@ -894,7 +893,7 @@
} catch (const DisconnectException& e) {
disconnect(e.what());
} catch (const ProtocolException& e) {
- disconnect("PROTOCOL_EXCEPTION", boost::lexical_cast<std::string>(e.number()));
+ disconnect("PROTOCOL_EXCEPTION", e.what());
} catch (const std::exception& e) {
disconnect("SOMETHING_WRONG", e.what());
}
=== modified file 'src/network/nethost.cc'
--- src/network/nethost.cc 2016-11-19 18:25:49 +0000
+++ src/network/nethost.cc 2016-11-20 10:15:14 +0000
@@ -26,7 +26,6 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/format.hpp>
-#include <boost/lexical_cast.hpp>
#ifndef _WIN32
#include <unistd.h> // for usleep
#endif
@@ -2007,8 +2006,7 @@
} catch (const DisconnectException& e) {
disconnect_client(i, e.what());
} catch (const ProtocolException& e) {
- disconnect_client(
- i, "PROTOCOL_EXCEPTION", true, boost::lexical_cast<std::string>(e.number()));
+ disconnect_client(i, "PROTOCOL_EXCEPTION", true, e.what());
} catch (const std::exception& e) {
disconnect_client(i, "MALFORMED_COMMANDS", true, e.what());
}
@@ -2241,8 +2239,8 @@
uint32_t part = r.unsigned_32();
std::string x = r.string();
if (x != file_->md5sum) {
- log("[Host]: File transfer checksum mismatch %s != %s\n", x.c_str(),
- file_->md5sum.c_str());
+ log(
+ "[Host]: File transfer checksum mismatch %s != %s\n", x.c_str(), file_->md5sum.c_str());
return; // Surely the file was changed, so we cancel here.
}
if (part >= file_->parts.size())
=== modified file 'src/network/network.h'
--- src/network/network.h 2016-08-04 15:49:05 +0000
+++ src/network/network.h 2016-11-20 10:15:14 +0000
@@ -25,6 +25,7 @@
#include <vector>
#include <SDL_net.h>
+#include <boost/lexical_cast.hpp>
#include "base/wexception.h"
#include "io/streamread.h"
@@ -175,23 +176,16 @@
*/
struct ProtocolException : public std::exception {
explicit ProtocolException(uint8_t code) {
- what_ = code;
+ what_ = boost::lexical_cast<std::string>(static_cast<unsigned int>(code)).c_str();
}
- /// do NOT use!!! This exception shall only return the command number of the received message
- /// via \ref ProtocolException:number()
+ /// \returns the command number of the received message
const char* what() const noexcept override {
- NEVER_HERE();
- }
-
- /// \returns the command number of the received message
- virtual int number() const {
return what_;
}
private:
- // no uint8_t, as lexical_cast does not support that format
- int what_;
+ const char* what_;
};
#endif // end of include guard: WL_NETWORK_NETWORK_H
=== modified file 'src/third_party/gettext/gettext.h'
--- src/third_party/gettext/gettext.h 2016-11-03 07:20:57 +0000
+++ src/third_party/gettext/gettext.h 2016-11-20 10:15:14 +0000
@@ -163,7 +163,7 @@
ISO C++ supports variable-size arrays, but some older PGI and Sun compilers
don't. */
#define GETTEXT_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
- !(__GNUC__ >= 3 || (defined __cplusplus && !(defined __PGI || defined __SUNPRO_CC)))
+ !(__GNUC__ >= 3 || (defined(__cplusplus) && !(defined(__PGI) || defined(__SUNPRO_CC))))
#if !GETTEXT_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
#include <stdlib.h>
=== modified file 'src/wui/mapviewpixelfunctions.cc'
--- src/wui/mapviewpixelfunctions.cc 2016-10-24 20:07:22 +0000
+++ src/wui/mapviewpixelfunctions.cc 2016-11-20 10:15:14 +0000
@@ -94,7 +94,7 @@
float MapviewPixelFunctions::calc_pix_distance(const Map& map, Vector2f a, Vector2f b) {
normalize_pix(map, &a);
normalize_pix(map, &b);
- uint32_t dx = abs(a.x - b.x), dy = abs(a.y - b.y);
+ uint32_t dx = std::abs(a.x - b.x), dy = std::abs(a.y - b.y);
{
const uint32_t map_end_screen_x = get_map_end_screen_x(map);
if (dx > map_end_screen_x / 2)
Follow ups
-
[Merge] lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands
From: noreply, 2016-12-06
-
[Merge] lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands
From: GunChleoc, 2016-12-06
-
[Merge] lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands
From: GunChleoc, 2016-12-06
-
[Merge] lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands
From: GunChleoc, 2016-12-06
-
Re: [Merge] lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands
From: GunChleoc, 2016-12-06
-
Re: [Merge] lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands
From: SirVer, 2016-12-06
-
Re: [Merge] lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands
From: GunChleoc, 2016-12-05
-
[Merge] lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands
From: bunnybot, 2016-12-04
-
Re: [Merge] lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands
From: GunChleoc, 2016-12-02
-
[Merge] lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands
From: bunnybot, 2016-12-02
-
Re: [Merge] lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands
From: SirVer, 2016-12-02
-
[Merge] lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands
From: bunnybot, 2016-12-01
-
[Merge] lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands
From: bunnybot, 2016-12-01
-
[Merge] lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands
From: bunnybot, 2016-11-30
-
[Merge] lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands
From: bunnybot, 2016-11-30
-
Re: [Merge] lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands
From: SirVer, 2016-11-29
-
[Merge] lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands
From: bunnybot, 2016-11-28
-
[Merge] lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands
From: bunnybot, 2016-11-28
-
[Merge] lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands
From: bunnybot, 2016-11-28
-
Re: [Merge] lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands
From: Notabilis, 2016-11-28
-
[Merge] lp:~widelands-dev/widelands/compiler_warnings_201611 into lp:widelands
From: bunnybot, 2016-11-20