widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #07920
[Merge] lp:~widelands-dev/widelands/bug-986611-cppcheck_performance-logic into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-986611-cppcheck_performance-logic into lp:widelands.
Commit message:
Fixed performance issues that were flagged up by cppcheck in logic, economy and map_io:
- Passing parameters per reference.
- Constructor initialization.
- Replaced postfix ++ operator with range-based for loops in Trainingsite code.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #986611 in widelands: "Issues reported by cppcheck"
https://bugs.launchpad.net/widelands/+bug/986611
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-986611-cppcheck_performance-logic/+merge/301007
Fixed performance issues that were flagged up by cppcheck in logic, economy and map_io:
- Passing parameters per reference.
- Constructor initialization.
- Replaced postfix ++ operator with range-based for loops in Trainingsite code.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-986611-cppcheck_performance-logic into lp:widelands.
=== modified file 'src/ai/ai_help_structs.cc'
--- src/ai/ai_help_structs.cc 2016-05-09 14:20:16 +0000
+++ src/ai/ai_help_structs.cc 2016-07-24 18:05:26 +0000
@@ -63,7 +63,7 @@
return true;
}
-bool CheckStepRoadAI::reachable_dest(Map& map, FCoords const dest) const {
+bool CheckStepRoadAI::reachable_dest(const Map& map, const FCoords& dest) const {
NodeCaps const caps = dest.field->nodecaps();
if (!(caps & movecaps)) {
=== modified file 'src/ai/ai_help_structs.h'
--- src/ai/ai_help_structs.h 2016-04-11 06:45:29 +0000
+++ src/ai/ai_help_structs.h 2016-07-24 18:05:26 +0000
@@ -74,7 +74,7 @@
CheckStepRoadAI(Player* const pl, uint8_t const mc, bool const oe);
bool allowed(Map&, FCoords start, FCoords end, int32_t dir, CheckStep::StepId) const;
- bool reachable_dest(Map&, FCoords dest) const;
+ bool reachable_dest(const Map&, const FCoords& dest) const;
Player* player;
uint8_t movecaps;
=== modified file 'src/ai/defaultai.cc'
--- src/ai/defaultai.cc 2016-05-10 07:08:55 +0000
+++ src/ai/defaultai.cc 2016-07-24 18:05:26 +0000
@@ -4808,8 +4808,8 @@
bool DefaultAI::other_player_accessible(const uint32_t max_distance,
uint32_t* tested_fields,
uint16_t* mineable_fields_count,
- const Widelands::Coords starting_spot,
- const WalkSearch type) {
+ const Coords& starting_spot,
+ const WalkSearch& type) {
Map& map = game().map();
std::list<uint32_t> queue;
std::unordered_set<uint32_t> done;
@@ -5335,7 +5335,7 @@
// This calculates strength of vector of soldiers, f.e. soldiers in a building or
// ones ready to attack
-int32_t DefaultAI::calculate_strength(const std::vector<Widelands::Soldier*> soldiers) {
+int32_t DefaultAI::calculate_strength(const std::vector<Widelands::Soldier*>& soldiers) {
if (soldiers.empty()) {
return 0;
=== modified file 'src/ai/defaultai.h'
--- src/ai/defaultai.h 2016-04-01 07:24:00 +0000
+++ src/ai/defaultai.h 2016-07-24 18:05:26 +0000
@@ -184,7 +184,7 @@
bool check_enemy_sites(uint32_t);
void print_stats();
// return single number of strength of vector of soldiers
- int32_t calculate_strength(const std::vector<Widelands::Soldier*>);
+ int32_t calculate_strength(const std::vector<Widelands::Soldier*>&);
uint32_t get_stocklevel_by_hint(size_t);
uint32_t get_stocklevel(Widelands::BuildingObserver&);
uint32_t get_warehoused_stock(Widelands::DescriptionIndex wt);
@@ -198,8 +198,8 @@
bool other_player_accessible(uint32_t max_distance,
uint32_t* tested_fields,
uint16_t* mineable_fields_count,
- const Widelands::Coords starting_spot,
- const WalkSearch type);
+ const Widelands::Coords& starting_spot,
+ const WalkSearch& type);
int32_t recalc_with_border_range(const Widelands::BuildableField&, int32_t);
=== modified file 'src/economy/flag.cc'
--- src/economy/flag.cc 2016-02-18 18:27:52 +0000
+++ src/economy/flag.cc 2016-07-24 18:05:26 +0000
@@ -111,7 +111,7 @@
* Create a flag at the given location
*/
Flag::Flag
- (EditorGameBase & egbase, Player & owning_player, Coords const coords)
+ (EditorGameBase & egbase, Player & owning_player, const Coords& coords)
:
PlayerImmovable (g_flag_descr),
building_ (nullptr),
=== modified file 'src/economy/flag.h'
--- src/economy/flag.h 2016-02-09 16:29:48 +0000
+++ src/economy/flag.h 2016-07-24 18:05:26 +0000
@@ -73,7 +73,7 @@
const FlagDescr& descr() const;
Flag(); /// empty flag for savegame loading
- Flag(EditorGameBase &, Player & owner, Coords); /// create a new flag
+ Flag(EditorGameBase &, Player & owner, const Coords&); /// create a new flag
~Flag() override;
void load_finish(EditorGameBase &) override;
=== modified file 'src/economy/itransport_cost_calculator.h'
--- src/economy/itransport_cost_calculator.h 2014-07-14 19:44:28 +0000
+++ src/economy/itransport_cost_calculator.h 2016-07-24 18:05:26 +0000
@@ -37,7 +37,7 @@
ITransportCostCalculator() = default;
virtual ~ITransportCostCalculator() {}
- virtual int32_t calc_cost_estimate(Coords, Coords) const = 0;
+ virtual int32_t calc_cost_estimate(const Coords&, const Coords&) const = 0;
private:
DISALLOW_COPY_AND_ASSIGN(ITransportCostCalculator);
=== modified file 'src/economy/test/test_road.cc'
--- src/economy/test/test_road.cc 2015-11-29 09:43:15 +0000
+++ src/economy/test/test_road.cc 2016-07-24 18:05:26 +0000
@@ -38,7 +38,7 @@
/* Helper classes */
/******************/
struct TestingFlag : public Flag {
- TestingFlag(EditorGameBase &, Coords const c) : Flag() {
+ TestingFlag(EditorGameBase &, const Coords& c) : Flag() {
set_flag_position(c);
}
=== modified file 'src/economy/test/test_routing.cc'
--- src/economy/test/test_routing.cc 2016-02-09 16:29:48 +0000
+++ src/economy/test/test_routing.cc 2016-07-24 18:05:26 +0000
@@ -85,7 +85,7 @@
}
class TestingTransportCostCalculator : public ITransportCostCalculator {
- int32_t calc_cost_estimate(Coords c1, Coords c2) const override {
+ int32_t calc_cost_estimate(const Coords& c1, const Coords& c2) const override {
// We use an euclidian metric here. It is much easier for
// test cases
double xd = (c1.x - c2.x);
@@ -405,7 +405,7 @@
*/
TestingRoutingNode * new_node_w_neighbour
(TestingRoutingNode * const d,
- Coords const pos = Coords(0, 0),
+ const Coords& pos = Coords(0, 0),
int32_t = 1,
int32_t const waitcost = 0)
{
=== modified file 'src/logic/cmd_delete_message.h'
--- src/logic/cmd_delete_message.h 2015-11-27 12:46:45 +0000
+++ src/logic/cmd_delete_message.h 2016-07-24 18:05:26 +0000
@@ -37,7 +37,7 @@
/// the savegame.
struct CmdDeleteMessage : public Command {
CmdDeleteMessage
- (uint32_t const t, PlayerNumber const p, MessageId const m)
+ (uint32_t const t, PlayerNumber const p, const MessageId& m)
: Command(t), player(p), message(m)
{}
=== modified file 'src/logic/editor_game_base.cc'
--- src/logic/editor_game_base.cc 2016-04-03 09:03:03 +0000
+++ src/logic/editor_game_base.cc 2016-07-24 18:05:26 +0000
@@ -260,7 +260,7 @@
* \li former_buildings is the list of former buildings
*/
Building & EditorGameBase::warp_building
- (Coords const c, PlayerNumber const owner, DescriptionIndex const idx,
+ (const Coords& c, PlayerNumber const owner, DescriptionIndex const idx,
Building::FormerBuildings former_buildings)
{
Player & plr = player(owner);
@@ -279,7 +279,7 @@
* an enhancement.
*/
Building & EditorGameBase::warp_constructionsite
- (Coords const c, PlayerNumber const owner,
+ (const Coords& c, PlayerNumber const owner,
DescriptionIndex idx, bool loading,
Building::FormerBuildings former_buildings)
{
@@ -296,7 +296,7 @@
* except during loading.
*/
Building & EditorGameBase::warp_dismantlesite
- (Coords const c, PlayerNumber const owner,
+ (const Coords& c, PlayerNumber const owner,
bool loading, Building::FormerBuildings former_buildings)
{
Player & plr = player(owner);
@@ -327,11 +327,11 @@
*
*/
-Bob& EditorGameBase::create_critter(Coords const c, DescriptionIndex const bob_type_idx, Player* owner) {
+Bob& EditorGameBase::create_critter(const Coords& c, DescriptionIndex const bob_type_idx, Player* owner) {
return create_bob(c, *world().get_bob_descr(bob_type_idx), owner);
}
-Bob& EditorGameBase::create_critter(Coords c, const std::string& name, Player* owner) {
+Bob& EditorGameBase::create_critter(const Coords& c, const std::string& name, Player* owner) {
const BobDescr* descr = world().get_bob_descr(name);
if (descr == nullptr)
throw GameDataError("create_critter(%i,%i,%s,%s): critter not found", c.x, c.y, name.c_str(),
@@ -349,7 +349,7 @@
===============
*/
Immovable & EditorGameBase::create_immovable
- (Coords const c, DescriptionIndex const idx, MapObjectDescr::OwnerType type)
+ (const Coords& c, DescriptionIndex const idx, MapObjectDescr::OwnerType type)
{
const ImmovableDescr & descr =
*
@@ -364,7 +364,7 @@
}
Immovable & EditorGameBase::create_immovable
- (Coords const c, const std::string & name, MapObjectDescr::OwnerType type)
+ (const Coords& c, const std::string & name, MapObjectDescr::OwnerType type)
{
DescriptionIndex idx;
if (type == MapObjectDescr::OwnerType::kTribe) {
@@ -391,12 +391,12 @@
* idx is the bob type.
*/
-Bob& EditorGameBase::create_ship(Coords const c, int const ship_type_idx, Player* owner) {
+Bob& EditorGameBase::create_ship(const Coords& c, int const ship_type_idx, Player* owner) {
const BobDescr* descr = dynamic_cast<const BobDescr*>(tribes().get_ship_descr(ship_type_idx));
return create_bob(c, *descr, owner);
}
-Bob& EditorGameBase::create_ship(Coords c, const std::string& name, Player* owner) {
+Bob& EditorGameBase::create_ship(const Coords& c, const std::string& name, Player* owner) {
try {
int idx = tribes().safe_ship_index(name);
return create_ship(c, idx, owner);
@@ -482,7 +482,7 @@
void EditorGameBase::set_road
- (FCoords const f, uint8_t const direction, uint8_t const roadtype)
+ (const FCoords& f, uint8_t const direction, uint8_t const roadtype)
{
const Map & m = map();
const Field & first_field = m[0];
=== modified file 'src/logic/editor_game_base.h'
--- src/logic/editor_game_base.h 2016-04-03 09:03:03 +0000
+++ src/logic/editor_game_base.h 2016-07-24 18:05:26 +0000
@@ -119,35 +119,35 @@
void load_graphics(UI::ProgressWindow& loader_ui);
virtual void cleanup_for_load();
- void set_road(FCoords, uint8_t direction, uint8_t roadtype);
+ void set_road(const FCoords&, uint8_t direction, uint8_t roadtype);
// warping stuff. instantly creating map_objects
Building&
- warp_building(Coords,
+ warp_building(const Coords&,
PlayerNumber,
DescriptionIndex,
Building::FormerBuildings former_buildings = Building::FormerBuildings());
Building&
- warp_constructionsite(Coords,
+ warp_constructionsite(const Coords&,
PlayerNumber,
DescriptionIndex,
bool loading = false,
Building::FormerBuildings former_buildings = Building::FormerBuildings());
Building&
- warp_dismantlesite(Coords,
+ warp_dismantlesite(const Coords&,
PlayerNumber,
bool loading = false,
Building::FormerBuildings former_buildings = Building::FormerBuildings());
- Bob& create_critter(Coords, DescriptionIndex bob_type_idx, Player* owner = nullptr);
- Bob& create_critter(Coords, const std::string& name, Player* owner = nullptr);
- Immovable& create_immovable(Coords,
+ Bob& create_critter(const Coords&, DescriptionIndex bob_type_idx, Player* owner = nullptr);
+ Bob& create_critter(const Coords&, const std::string& name, Player* owner = nullptr);
+ Immovable& create_immovable(const Coords&,
DescriptionIndex idx,
MapObjectDescr::OwnerType = MapObjectDescr::OwnerType::kWorld);
- Immovable& create_immovable(Coords,
+ Immovable& create_immovable(const Coords&,
const std::string& name,
MapObjectDescr::OwnerType = MapObjectDescr::OwnerType::kWorld);
- Bob& create_ship(Coords, int ship_type_idx, Player* owner = nullptr);
- Bob& create_ship(Coords, const std::string& name, Player* owner = nullptr);
+ Bob& create_ship(const Coords&, int ship_type_idx, Player* owner = nullptr);
+ Bob& create_ship(const Coords&, const std::string& name, Player* owner = nullptr);
uint32_t get_gametime() const {
return gametime_;
=== modified file 'src/logic/game.cc'
--- src/logic/game.cc 2016-03-20 16:05:19 +0000
+++ src/logic/game.cc 2016-07-24 18:05:26 +0000
@@ -711,13 +711,13 @@
void Game::send_player_build
- (int32_t const pid, Coords const coords, DescriptionIndex const id)
+ (int32_t const pid, const Coords& coords, DescriptionIndex const id)
{
assert(tribes().building_exists(id));
send_player_command (*new CmdBuild(get_gametime(), pid, coords, id));
}
-void Game::send_player_build_flag (int32_t const pid, Coords const coords)
+void Game::send_player_build_flag (int32_t const pid, const Coords& coords)
{
send_player_command (*new CmdBuildFlag(get_gametime(), pid, coords));
}
=== modified file 'src/logic/game.h'
--- src/logic/game.h 2016-02-21 18:57:49 +0000
+++ src/logic/game.h 2016-07-24 18:05:26 +0000
@@ -170,8 +170,8 @@
void send_player_bulldoze (PlayerImmovable &, bool recurse = false);
void send_player_dismantle (PlayerImmovable &);
- void send_player_build (int32_t, Coords, DescriptionIndex);
- void send_player_build_flag (int32_t, Coords);
+ void send_player_build (int32_t, const Coords&, DescriptionIndex);
+ void send_player_build_flag (int32_t, const Coords&);
void send_player_build_road (int32_t, Path &);
void send_player_flagaction (Flag &);
void send_player_start_stop_building (Building &);
=== modified file 'src/logic/game_settings.h'
--- src/logic/game_settings.h 2016-03-19 11:47:00 +0000
+++ src/logic/game_settings.h 2016-07-24 18:05:26 +0000
@@ -162,7 +162,7 @@
virtual void set_player_tribe (uint8_t number, const std::string &, bool const random_tribe = false) = 0;
virtual void set_player_init (uint8_t number, uint8_t index) = 0;
virtual void set_player_name (uint8_t number, const std::string &) = 0;
- virtual void set_player (uint8_t number, PlayerSettings) = 0;
+ virtual void set_player (uint8_t number, const PlayerSettings&) = 0;
virtual void set_player_number (uint8_t number) = 0;
virtual void set_player_team (uint8_t number, Widelands::TeamNumber team) = 0;
virtual void set_player_closeable(uint8_t number, bool closeable) = 0;
=== modified file 'src/logic/map.cc'
--- src/logic/map.cc 2016-07-17 19:34:09 +0000
+++ src/logic/map.cc 2016-07-24 18:05:26 +0000
@@ -81,7 +81,7 @@
cleanup();
}
-void Map::recalc_border(const FCoords fc) {
+void Map::recalc_border(const FCoords& fc) {
if (const PlayerNumber owner = fc.field->get_owned_by()) {
// A node that is owned by a player and has a neighbour that is not owned
// by that player is a border node.
@@ -335,7 +335,7 @@
}
-void Map::set_origin(Coords const new_origin) {
+void Map::set_origin(const Coords& new_origin) {
assert(0 <= new_origin.x);
assert (new_origin.x < width_);
assert(0 <= new_origin.y);
@@ -528,7 +528,7 @@
Set the starting coordinates of a player
===============
*/
-void Map::set_starting_pos(PlayerNumber const plnum, Coords const c)
+void Map::set_starting_pos(PlayerNumber const plnum, const Coords& c)
{
assert(1 <= plnum && plnum <= get_nrplayers());
starting_pos_[plnum - 1] = c;
@@ -586,7 +586,7 @@
/// \returns the immovable at the given coordinate
-BaseImmovable * Map::get_immovable(const Coords coord) const
+BaseImmovable * Map::get_immovable(const Coords& coord) const
{
return operator[](coord).get_immovable();
}
@@ -602,7 +602,7 @@
*/
template<typename functorT>
void Map::find_reachable
- (Area<FCoords> const area, const CheckStep & checkstep, functorT & functor)
+ (const Area<FCoords>& area, const CheckStep & checkstep, functorT & functor)
{
std::vector<Coords> queue;
boost::shared_ptr<Pathfields> pathfields = pathfieldmgr_->allocate();
@@ -654,7 +654,7 @@
===============
*/
template<typename functorT>
-void Map::find(const Area<FCoords> area, functorT & functor) const {
+void Map::find(const Area<FCoords>& area, functorT & functor) const {
MapRegion<Area<FCoords> > mr(*this, area);
do functor(*this, mr.location()); while (mr.advance(*this));
}
@@ -671,7 +671,7 @@
FindBobsCallback(std::vector<Bob *> * const list, const FindBob & functor)
: list_(list), functor_(functor), found_(0) {}
- void operator()(const Map &, const FCoords cur) {
+ void operator()(const Map &, const FCoords& cur) {
for
(Bob * bob = cur.field->get_first_bob();
bob;
@@ -758,7 +758,7 @@
(std::vector<ImmovableFound> * const list, const FindImmovable & functor)
: list_(list), functor_(functor), found_(0) {}
- void operator()(const Map &, const FCoords cur) {
+ void operator()(const Map &, const FCoords& cur) {
BaseImmovable * const imm = cur.field->get_immovable();
if (!imm)
@@ -869,7 +869,7 @@
(std::vector<Coords> * const list, const FindNode & functor)
: list_(list), functor_(functor), found_(0) {}
- void operator()(const Map & map, const FCoords cur) {
+ void operator()(const Map & map, const FCoords& cur) {
if (functor_.accept(map, cur)) {
if (list_)
list_->push_back(cur);
@@ -962,7 +962,7 @@
Fetch the slopes to neighbours and call the actual logic in Field
===============
*/
-void Map::recalc_brightness(FCoords const f) {
+void Map::recalc_brightness(const FCoords& f) {
int32_t left, right, top_left, top_right, bottom_left, bottom_right;
Field::Height const height = f.field->get_height();
@@ -1007,11 +1007,11 @@
above recalc_brightness.
===============
*/
-void Map::recalc_nodecaps_pass1(const World& world, FCoords const f) {
+void Map::recalc_nodecaps_pass1(const World& world, const FCoords& f) {
f.field->caps = calc_nodecaps_pass1(world, f, true);
}
-NodeCaps Map::calc_nodecaps_pass1(const World& world, FCoords const f, bool consider_mobs) {
+NodeCaps Map::calc_nodecaps_pass1(const World& world, const FCoords& f, bool consider_mobs) {
uint8_t caps = CAPS_NONE;
// 1a) Get all the neighbours to make life easier
@@ -1125,7 +1125,7 @@
}
NodeCaps Map::calc_nodecaps_pass2
- (const World& world, FCoords const f, bool consider_mobs, NodeCaps initcaps)
+ (const World& world, const FCoords& f, bool consider_mobs, NodeCaps initcaps)
{
uint8_t caps = consider_mobs ? f.field->caps : static_cast<uint8_t>(initcaps);
@@ -1401,7 +1401,7 @@
* Calculate the (Manhattan) distance from a to b
* a and b are expected to be normalized!
*/
-uint32_t Map::calc_distance(const Coords a, const Coords b) const
+uint32_t Map::calc_distance(const Coords& a, const Coords& b) const
{
uint32_t dist;
int32_t dy;
@@ -1475,7 +1475,7 @@
This function is used mainly for the path-finding estimate.
===============
*/
-int32_t Map::calc_cost_estimate(const Coords a, const Coords b) const
+int32_t Map::calc_cost_estimate(const Coords& a, const Coords& b) const
{
return calc_distance(a, b) * BASE_COST_PER_FIELD;
}
@@ -1484,7 +1484,7 @@
/**
* \return a lower bound on the time required to walk from \p a to \p b
*/
-int32_t Map::calc_cost_lowerbound(const Coords a, const Coords b) const
+int32_t Map::calc_cost_lowerbound(const Coords& a, const Coords& b) const
{
return calc_distance(a, b) * calc_cost(-SLOPE_COST_STEPS);
}
@@ -1536,7 +1536,7 @@
direction, in milliseconds.
===============
*/
-int32_t Map::calc_cost(const Coords coords, const int32_t dir) const
+int32_t Map::calc_cost(const Coords& coords, const int32_t dir) const
{
FCoords f;
int32_t startheight;
@@ -1558,7 +1558,7 @@
Calculate the average cost of walking the given step in both directions.
===============
*/
-int32_t Map::calc_bidi_cost(const Coords coords, const int32_t dir) const
+int32_t Map::calc_bidi_cost(const Coords& coords, const int32_t dir) const
{
FCoords f;
int32_t startheight;
@@ -1820,7 +1820,7 @@
}
-bool Map::can_reach_by_water(const Coords field) const
+bool Map::can_reach_by_water(const Coords& field) const
{
FCoords fc = get_fcoords(field);
=== modified file 'src/logic/map.h'
--- src/logic/map.h 2016-05-07 18:54:04 +0000
+++ src/logic/map.h 2016-07-24 18:05:26 +0000
@@ -200,7 +200,7 @@
void set_nrplayers(PlayerNumber);
- void set_starting_pos(PlayerNumber, Coords);
+ void set_starting_pos(PlayerNumber, const Coords&);
Coords get_starting_pos(PlayerNumber const p) const {
assert(1 <= p && p <= get_nrplayers());
return starting_pos_[p - 1];
@@ -258,7 +258,7 @@
/// \returns the maximum theoretical possible nodecaps (no blocking bobs, etc.)
NodeCaps get_max_nodecaps(const World& world, const FCoords &);
- BaseImmovable * get_immovable(Coords) const;
+ BaseImmovable * get_immovable(const Coords&) const;
uint32_t find_bobs
(const Area<FCoords>,
std::vector<Bob *> * list,
@@ -302,13 +302,13 @@
FCoords get_fcoords(Field &) const;
void get_coords(Field & f, Coords & c) const;
- uint32_t calc_distance(Coords, Coords) const;
+ uint32_t calc_distance(const Coords&, const Coords&) const;
- int32_t calc_cost_estimate(Coords, Coords) const override;
- int32_t calc_cost_lowerbound(Coords, Coords) const;
+ int32_t calc_cost_estimate(const Coords&, const Coords&) const override;
+ int32_t calc_cost_lowerbound(const Coords&, const Coords&) const;
int32_t calc_cost(int32_t slope) const;
- int32_t calc_cost(Coords, int32_t dir) const;
- int32_t calc_bidi_cost(Coords, int32_t dir) const;
+ int32_t calc_cost(const Coords&, int32_t dir) const;
+ int32_t calc_bidi_cost(const Coords&, int32_t dir) const;
void calc_cost(const Path &, int32_t * forward, int32_t * backward) const;
void get_ln (const Coords &, Coords *) const;
@@ -353,7 +353,7 @@
* We can reach a field by water either if it has MOVECAPS_SWIM or if it has
* MOVECAPS_WALK and at least one of the neighbours has MOVECAPS_SWIM
*/
- bool can_reach_by_water(Coords) const;
+ bool can_reach_by_water(const Coords&) const;
/// Sets the height to a value. Recalculates brightness. Changes the
/// surrounding nodes if necessary. Returns the radius that covers all
@@ -425,7 +425,7 @@
MilitaryInfluence calc_influence(Coords, Area<>) const;
/// Translate the whole map so that the given point becomes the new origin.
- void set_origin(Coords);
+ void set_origin(const Coords&);
/// Port space specific functions
bool is_port_space(const Coords& c) const;
@@ -441,7 +441,7 @@
void set_size(uint32_t w, uint32_t h);
private:
- void recalc_border(FCoords);
+ void recalc_border(const FCoords&);
/// # of players this map supports (!= Game's number of players!)
PlayerNumber nrplayers_;
@@ -474,12 +474,12 @@
PortSpacesSet port_spaces_;
Objectives objectives_;
- void recalc_brightness(FCoords);
- void recalc_nodecaps_pass1(const World& world, FCoords);
+ void recalc_brightness(const FCoords&);
+ void recalc_nodecaps_pass1(const World& world, const FCoords&);
void recalc_nodecaps_pass2(const World& world, const FCoords & f);
- NodeCaps calc_nodecaps_pass1(const World& world, FCoords, bool consider_mobs = true);
+ NodeCaps calc_nodecaps_pass1(const World& world, const FCoords&, bool consider_mobs = true);
NodeCaps calc_nodecaps_pass2(const World& world,
- FCoords,
+ const FCoords&,
bool consider_mobs = true,
NodeCaps initcaps = CAPS_NONE);
void check_neighbour_heights(FCoords, uint32_t & radius);
@@ -489,8 +489,8 @@
bool is_cycle_connected
(const FCoords & start, uint32_t length, const WalkingDir * dirs);
template<typename functorT>
- void find_reachable(Area<FCoords>, const CheckStep &, functorT &);
- template<typename functorT> void find(const Area<FCoords>, functorT &) const;
+ void find_reachable(const Area<FCoords>&, const CheckStep &, functorT &);
+ template<typename functorT> void find(const Area<FCoords>&, functorT &) const;
MapVersion map_version_;
};
=== modified file 'src/logic/map_objects/checkstep.cc'
--- src/logic/map_objects/checkstep.cc 2016-02-07 09:30:20 +0000
+++ src/logic/map_objects/checkstep.cc 2016-07-24 18:05:26 +0000
@@ -71,7 +71,7 @@
return true;
}
-bool CheckStepAnd::reachable_dest(Map & map, FCoords const dest) const
+bool CheckStepAnd::reachable_dest(Map & map, const FCoords& dest) const
{
for (const CheckStep& checkstep : subs) {
if (!checkstep.reachable_dest(map, dest)) {
@@ -103,7 +103,7 @@
return false;
}
-bool CheckStepDefault::reachable_dest(Map & map, FCoords const dest) const
+bool CheckStepDefault::reachable_dest(Map & map, const FCoords& dest) const
{
NodeCaps const caps = dest.field->nodecaps();
@@ -193,7 +193,7 @@
return true;
}
-bool CheckStepRoad::reachable_dest(Map & map, FCoords const dest) const
+bool CheckStepRoad::reachable_dest(Map & map, const FCoords& dest) const
{
NodeCaps const caps = dest.field->nodecaps();
@@ -210,7 +210,7 @@
bool CheckStepLimited::allowed
- (Map &, FCoords, FCoords const end, int32_t, CheckStep::StepId) const
+ (Map &, FCoords, const FCoords& end, int32_t, CheckStep::StepId) const
{
return allowed_locations_.find(end) != allowed_locations_.end();
}
=== modified file 'src/logic/map_objects/checkstep.h'
--- src/logic/map_objects/checkstep.h 2016-02-09 16:29:48 +0000
+++ src/logic/map_objects/checkstep.h 2016-07-24 18:05:26 +0000
@@ -114,7 +114,7 @@
int32_t dir,
CheckStep::StepId id)
const;
- bool reachable_dest(Map &, FCoords dest) const;
+ bool reachable_dest(Map &, const FCoords& dest) const;
private:
std::vector<CheckStep> subs;
@@ -133,7 +133,7 @@
bool allowed
(Map &, FCoords start, FCoords end, int32_t dir, CheckStep::StepId)
const;
- bool reachable_dest(Map &, FCoords dest) const;
+ bool reachable_dest(Map &, const FCoords& dest) const;
private:
uint8_t movecaps_;
@@ -175,7 +175,7 @@
bool allowed
(Map &, FCoords start, FCoords end, int32_t dir, CheckStep::StepId)
const;
- bool reachable_dest(Map &, FCoords dest) const;
+ bool reachable_dest(Map &, const FCoords& dest) const;
private:
const Player & player_;
@@ -189,7 +189,7 @@
struct CheckStepLimited {
void add_allowed_location(const Coords & c) {allowed_locations_.insert(c);}
bool allowed
- (Map &, FCoords start, FCoords end, int32_t dir, CheckStep::StepId)
+ (Map &, FCoords start, const FCoords& end, int32_t dir, CheckStep::StepId)
const;
bool reachable_dest(Map &, FCoords dest) const;
=== modified file 'src/logic/map_objects/immovable.cc'
--- src/logic/map_objects/immovable.cc 2016-05-17 15:02:21 +0000
+++ src/logic/map_objects/immovable.cc 2016-07-24 18:05:26 +0000
@@ -98,7 +98,7 @@
*
* \note this function will remove the immovable (if existing) currently connected to this position.
*/
-void BaseImmovable::set_position(EditorGameBase & egbase, Coords const c)
+void BaseImmovable::set_position(EditorGameBase & egbase, const Coords& c)
{
assert(c);
@@ -118,7 +118,7 @@
*
* Only call this during cleanup.
*/
-void BaseImmovable::unset_position(EditorGameBase & egbase, Coords const c)
+void BaseImmovable::unset_position(EditorGameBase & egbase, const Coords& c)
{
Map & map = egbase.map();
FCoords const f = map.get_fcoords(c);
@@ -333,7 +333,7 @@
* Create an immovable of this type
*/
Immovable & ImmovableDescr::create
- (EditorGameBase & egbase, Coords const coords) const
+ (EditorGameBase & egbase, const Coords& coords) const
{
assert(this != nullptr);
Immovable & result = *new Immovable(*this);
=== modified file 'src/logic/map_objects/immovable.h'
--- src/logic/map_objects/immovable.h 2016-05-12 07:51:17 +0000
+++ src/logic/map_objects/immovable.h 2016-07-24 18:05:26 +0000
@@ -100,8 +100,8 @@
static std::string size_to_string(int32_t size);
protected:
- void set_position(EditorGameBase &, Coords);
- void unset_position(EditorGameBase &, Coords);
+ void set_position(EditorGameBase &, const Coords&);
+ void unset_position(EditorGameBase &, const Coords&);
};
@@ -126,7 +126,7 @@
int32_t get_size() const {return size_;}
ImmovableProgram const * get_program(const std::string &) const;
- Immovable & create(EditorGameBase &, Coords) const;
+ Immovable & create(EditorGameBase &, const Coords&) const;
MapObjectDescr::OwnerType owner_type() const {return owner_type_;}
=== modified file 'src/logic/map_objects/tribes/building.cc'
--- src/logic/map_objects/tribes/building.cc 2016-04-01 09:29:17 +0000
+++ src/logic/map_objects/tribes/building.cc 2016-07-24 18:05:26 +0000
@@ -188,7 +188,7 @@
}
-int32_t BuildingDescr::suitability(const Map &, FCoords const fc) const {
+int32_t BuildingDescr::suitability(const Map &, const FCoords& fc) const {
return size_ <= (fc.field->nodecaps() & Widelands::BUILDCAPS_SIZEMASK);
}
=== modified file 'src/logic/map_objects/tribes/building.h'
--- src/logic/map_objects/tribes/building.h 2016-03-19 09:58:41 +0000
+++ src/logic/map_objects/tribes/building.h 2016-07-24 18:05:26 +0000
@@ -125,7 +125,7 @@
WorkareaInfo workarea_info_;
- virtual int32_t suitability(const Map &, FCoords) const;
+ virtual int32_t suitability(const Map &, const FCoords&) const;
const BuildingHints & hints() const {return hints_;}
protected:
=== modified file 'src/logic/map_objects/tribes/ship.h'
--- src/logic/map_objects/tribes/ship.h 2016-04-03 08:01:49 +0000
+++ src/logic/map_objects/tribes/ship.h 2016-07-24 18:05:26 +0000
@@ -52,7 +52,7 @@
enum class Message {kLost, kGained, kWaitingForCommand};
Message message;
- NoteShipMessage(Ship* const init_ship, Message const init_message)
+ NoteShipMessage(Ship* const init_ship, const Message& init_message)
: ship(init_ship), message(init_message) {
}
};
=== modified file 'src/logic/map_objects/tribes/trainingsite.cc'
--- src/logic/map_objects/tribes/trainingsite.cc 2016-04-11 06:45:29 +0000
+++ src/logic/map_objects/tribes/trainingsite.cc 2016-07-24 18:05:26 +0000
@@ -813,18 +813,15 @@
void
TrainingSite::training_done()
{
- TrainFailCount::iterator it;
- for (it = training_failure_count_.begin(); it != training_failure_count_.end(); it++)
- {
+ for (auto& fail_and_presence : training_failure_count_) {
// If a soldier is present at this training level, deteoriate
- if (it->second.second)
+ if (fail_and_presence.second.second)
{
- it->second.first++;
- it->second.second = 0;
+ fail_and_presence.second.first++;
+ fail_and_presence.second.second = 0;
+ } else if (0 < fail_and_presence.second.first) { // If no soldier, let's become optimistic
+ fail_and_presence.second.first--;
}
- else // If no soldier, let's become optimistic
- if (0 < it->second.first)
- it->second.first--;
}
}
=== modified file 'src/logic/map_objects/world/map_gen.cc'
--- src/logic/map_objects/world/map_gen.cc 2016-01-18 19:35:25 +0000
+++ src/logic/map_objects/world/map_gen.cc 2016-07-24 18:05:26 +0000
@@ -30,10 +30,10 @@
namespace Widelands {
-MapGenBobCategory::MapGenBobCategory(const LuaTable& table) {
- immovables_ = table.get_table("immovables")->array_entries<std::string>();
- critters_ = table.get_table("critters")->array_entries<std::string>();
-}
+MapGenBobCategory::MapGenBobCategory(const LuaTable& table) :
+ immovables_(table.get_table("immovables")->array_entries<std::string>()),
+ critters_(table.get_table("critters")->array_entries<std::string>())
+{}
const MapGenBobCategory*
MapGenLandResource::get_bob_category(MapGenAreaInfo::MapGenTerrainType terrType) const {
=== modified file 'src/logic/maptriangleregion.h'
--- src/logic/maptriangleregion.h 2016-02-22 07:25:15 +0000
+++ src/logic/maptriangleregion.h 2016-07-24 18:05:26 +0000
@@ -64,7 +64,7 @@
bool advance(const Map &);
};
template <> struct MapTriangleRegion<FCoords> {
- MapTriangleRegion(const Map & map, const Area<FCoords> area) :
+ MapTriangleRegion(const Map & map, const Area<FCoords>& area) :
area_(TCoords<FCoords>(area, TCoords<FCoords>::D), area.radius + 1),
rowwidth_ (area_.radius * 2 + 1),
remaining_in_row_(rowwidth_),
=== modified file 'src/logic/message.h'
--- src/logic/message.h 2016-01-02 12:36:38 +0000
+++ src/logic/message.h 2016-07-24 18:05:26 +0000
@@ -70,7 +70,7 @@
const std::string& init_icon_filename,
const std::string& init_heading,
const std::string& init_body,
- Widelands::Coords const c = Coords::null(),
+ const Widelands::Coords& c = Coords::null(),
Widelands::Serial ser = 0,
Status s = Status::kNew)
:
=== modified file 'src/logic/player.cc'
--- src/logic/player.cc 2016-03-12 07:07:12 +0000
+++ src/logic/player.cc 2016-07-24 18:05:26 +0000
@@ -59,7 +59,7 @@
void terraform_for_building
(Widelands::EditorGameBase& egbase, const Widelands::PlayerNumber player_number,
- const Widelands::Coords location, const Widelands::BuildingDescr* descr)
+ const Widelands::Coords& location, const Widelands::BuildingDescr* descr)
{
Widelands::Map & map = egbase.map();
Widelands::FCoords c[4]; // Big buildings occupy 4 locations.
@@ -387,7 +387,7 @@
Return filtered buildcaps that take the player's territory into account.
===============
*/
-NodeCaps Player::get_buildcaps(FCoords const fc) const {
+NodeCaps Player::get_buildcaps(const FCoords& fc) const {
const Map & map = egbase().map();
uint8_t buildcaps = fc.field->nodecaps();
@@ -421,7 +421,7 @@
* Build a flag, checking that it's legal to do so. Returns
* the flag in case of success, else returns 0;
*/
-Flag * Player::build_flag(Coords const c) {
+Flag * Player::build_flag(const Coords& c) {
int32_t buildcaps = get_buildcaps(egbase().map().get_fcoords(c));
if (buildcaps & BUILDCAPS_FLAG)
@@ -430,7 +430,7 @@
}
-Flag & Player::force_flag(FCoords const c) {
+Flag & Player::force_flag(const FCoords& c) {
log("Forcing flag at (%i, %i)\n", c.x, c.y);
const Map & map = egbase().map();
if (BaseImmovable * const immovable = c.field->get_immovable()) {
@@ -983,7 +983,7 @@
void Player::rediscover_node
(const Map & map,
const Widelands::Field & first_map_field,
- FCoords const f)
+ const FCoords& f)
{
assert(0 <= f.x);
@@ -1097,7 +1097,7 @@
void Player::see_node
(const Map & map,
const Widelands::Field & first_map_field,
- FCoords const f,
+ const FCoords& f,
Time const gametime,
bool const forward)
{
=== modified file 'src/logic/player.h'
--- src/logic/player.h 2016-05-09 14:20:16 +0000
+++ src/logic/player.h 2016-07-24 18:05:26 +0000
@@ -128,7 +128,7 @@
void create_default_infrastructure();
- NodeCaps get_buildcaps(FCoords) const;
+ NodeCaps get_buildcaps(const FCoords&) const;
bool is_hostile(const Player &) const;
@@ -416,7 +416,7 @@
void see_node
(const Map &,
const Widelands::Field & first_map_field,
- const FCoords,
+ const FCoords&,
const Time,
const bool forward = false)
;
@@ -472,8 +472,8 @@
// Player commands
// Only to be called indirectly via CmdQueue
- Flag & force_flag(FCoords); /// Do what it takes to create the flag.
- Flag * build_flag(Coords); /// Build a flag if it is allowed.
+ Flag & force_flag(const FCoords&); /// Do what it takes to create the flag.
+ Flag * build_flag(const Coords&); /// Build a flag if it is allowed.
Road & force_road(const Path &);
Road * build_road(const Path &); /// Build a road if it is allowed.
Building& force_building(Coords, const Building::FormerBuildings&);
@@ -569,7 +569,7 @@
// Called when a node becomes seen or has changed. Discovers the node and
// those of the 6 surrounding edges/triangles that are not seen from another
// node.
- void rediscover_node(const Map&, const Widelands::Field&, FCoords);
+ void rediscover_node(const Map&, const Widelands::Field&, const FCoords&);
std::unique_ptr<Notifications::Subscriber<NoteImmovable>> immovable_subscriber_;
std::unique_ptr<Notifications::Subscriber<NoteFieldTerrainChanged>>
=== modified file 'src/logic/playercommand.cc'
--- src/logic/playercommand.cc 2016-03-19 12:51:22 +0000
+++ src/logic/playercommand.cc 2016-07-24 18:05:26 +0000
@@ -283,10 +283,9 @@
/*** class Cmd_BuildFlag ***/
CmdBuildFlag::CmdBuildFlag (StreamRead & des) :
-PlayerCommand (0, des.unsigned_8())
-{
- coords = read_coords_32(&des);
-}
+PlayerCommand (0, des.unsigned_8()),
+ coords(read_coords_32(&des))
+{}
void CmdBuildFlag::execute (Game & game)
{
@@ -339,17 +338,16 @@
{}
CmdBuildRoad::CmdBuildRoad (StreamRead & des) :
-PlayerCommand (0, des.unsigned_8())
+PlayerCommand (0, des.unsigned_8()),
+ // We cannot completely deserialize the path here because we don't have a Map
+ path(nullptr),
+ start(read_coords_32(&des)),
+ nsteps(des.unsigned_16()),
+ steps(new char[nsteps])
{
- start = read_coords_32(&des);
- nsteps = des.unsigned_16();
-
- // we cannot completely deserialize the path here because we don't have a Map
- path = nullptr;
- steps = new char[nsteps];
-
- for (Path::StepVector::size_type i = 0; i < nsteps; ++i)
+ for (Path::StepVector::size_type i = 0; i < nsteps; ++i) {
steps[i] = des.unsigned_8();
+ }
}
CmdBuildRoad::~CmdBuildRoad ()
=== modified file 'src/logic/playercommand.h'
--- src/logic/playercommand.h 2016-03-02 17:13:06 +0000
+++ src/logic/playercommand.h 2016-07-24 18:05:26 +0000
@@ -94,7 +94,7 @@
CmdBuild
(const uint32_t init_duetime,
const int32_t p,
- const Coords c,
+ const Coords& c,
const DescriptionIndex i)
: PlayerCommand(init_duetime, p), coords(c), bi(i)
{}
@@ -116,7 +116,7 @@
struct CmdBuildFlag:public PlayerCommand {
CmdBuildFlag() : PlayerCommand() {} // For savegame loading
- CmdBuildFlag (const uint32_t t, const int32_t p, const Coords c) :
+ CmdBuildFlag (const uint32_t t, const int32_t p, const Coords& c) :
PlayerCommand(t, p), coords(c)
{}
@@ -683,7 +683,7 @@
struct PlayerMessageCommand : public PlayerCommand {
PlayerMessageCommand () : PlayerCommand() {} // for savegames
PlayerMessageCommand
- (const uint32_t t, const PlayerNumber p, const MessageId i)
+ (const uint32_t t, const PlayerNumber p, const MessageId& i)
: PlayerCommand(t, p), message_id_(i)
{}
@@ -701,7 +701,7 @@
struct CmdMessageSetStatusRead : public PlayerMessageCommand {
CmdMessageSetStatusRead () : PlayerMessageCommand() {}
CmdMessageSetStatusRead
- (const uint32_t t, const PlayerNumber p, const MessageId i)
+ (const uint32_t t, const PlayerNumber p, const MessageId& i)
: PlayerMessageCommand(t, p, i)
{}
@@ -716,7 +716,7 @@
struct CmdMessageSetStatusArchived : public PlayerMessageCommand {
CmdMessageSetStatusArchived () : PlayerMessageCommand() {}
CmdMessageSetStatusArchived
- (const uint32_t t, const PlayerNumber p, const MessageId i)
+ (const uint32_t t, const PlayerNumber p, const MessageId& i)
: PlayerMessageCommand(t, p, i)
{}
=== modified file 'src/logic/single_player_game_settings_provider.cc'
--- src/logic/single_player_game_settings_provider.cc 2016-04-01 07:50:48 +0000
+++ src/logic/single_player_game_settings_provider.cc 2016-07-24 18:05:26 +0000
@@ -210,7 +210,7 @@
s.players[number].name = name;
}
-void SinglePlayerGameSettingsProvider::set_player(uint8_t const number, PlayerSettings const ps) {
+void SinglePlayerGameSettingsProvider::set_player(uint8_t const number, const PlayerSettings& ps) {
if (number < s.players.size())
s.players[number] = ps;
}
=== modified file 'src/logic/single_player_game_settings_provider.h'
--- src/logic/single_player_game_settings_provider.h 2015-03-01 09:21:20 +0000
+++ src/logic/single_player_game_settings_provider.h 2016-07-24 18:05:26 +0000
@@ -53,7 +53,7 @@
void set_player_closeable(uint8_t, bool) override;
void set_player_shared(uint8_t, uint8_t) override;
void set_player_name(uint8_t const number, const std::string & name) override;
- void set_player(uint8_t const number, PlayerSettings const ps) override;
+ void set_player(uint8_t const number, const PlayerSettings& ps) override;
void set_player_number(uint8_t const number) override;
std::string get_win_condition_script() override;
=== modified file 'src/logic/widelands_geometry.h'
--- src/logic/widelands_geometry.h 2016-02-18 17:28:50 +0000
+++ src/logic/widelands_geometry.h 2016-07-24 18:05:26 +0000
@@ -155,10 +155,10 @@
: node(Node), triangle(Triangle)
{}
- bool operator== (NodeAndTriangle<> const other) const {
+ bool operator== (const NodeAndTriangle<>& other) const {
return node == other.node && triangle == other.triangle;
}
- bool operator!= (NodeAndTriangle<> const other) const {
+ bool operator!= (const NodeAndTriangle<>& other) const {
return !(*this == other);
}
=== modified file 'src/logic/widelands_geometry_io.cc'
--- src/logic/widelands_geometry_io.cc 2015-03-01 09:21:20 +0000
+++ src/logic/widelands_geometry_io.cc 2016-07-24 18:05:26 +0000
@@ -100,7 +100,7 @@
wr->unsigned_16(c.y);
}
-void write_area_48(StreamWrite* wr, Area<Coords, uint16_t> const area) {
+void write_area_48(StreamWrite* wr, const Area<Coords, uint16_t>& area) {
write_coords_32(wr, area);
wr->unsigned_16(area.radius);
}
=== modified file 'src/logic/widelands_geometry_io.h'
--- src/logic/widelands_geometry_io.h 2015-03-01 09:21:20 +0000
+++ src/logic/widelands_geometry_io.h 2016-07-24 18:05:26 +0000
@@ -106,7 +106,7 @@
void write_coords_32(StreamWrite* wr, const Coords& c);
// Writes 'area' to 'wr'.
-void write_area_48(StreamWrite* wr, Area<Coords, uint16_t> const area);
+void write_area_48(StreamWrite* wr, const Area<Coords, uint16_t>& area);
} // namespace Widelands
=== modified file 'src/map_io/map_bob_packet.cc'
--- src/map_io/map_bob_packet.cc 2015-11-28 22:29:26 +0000
+++ src/map_io/map_bob_packet.cc 2016-07-24 18:05:26 +0000
@@ -34,7 +34,7 @@
void MapBobPacket::read_bob(FileRead& fr,
EditorGameBase& egbase,
MapObjectLoader&,
- Coords const coords,
+ const Coords& coords,
const WorldLegacyLookupTable& lookup_table) {
const std::string owner = fr.c_string();
char const* const read_name = fr.c_string();
=== modified file 'src/map_io/map_bob_packet.h'
--- src/map_io/map_bob_packet.h 2015-09-18 18:17:01 +0000
+++ src/map_io/map_bob_packet.h 2016-07-24 18:05:26 +0000
@@ -43,7 +43,7 @@
void read_bob(FileRead&,
EditorGameBase&,
MapObjectLoader&,
- Coords,
+ const Coords&,
const WorldLegacyLookupTable& lookup_table);
};
}
=== modified file 'src/map_io/map_buildingdata_packet.cc'
--- src/map_io/map_buildingdata_packet.cc 2016-04-11 06:45:29 +0000
+++ src/map_io/map_buildingdata_packet.cc 2016-07-24 18:05:26 +0000
@@ -1308,16 +1308,12 @@
("Save TrainingSite: Failure counter has ridiculously many entries! (%u)\n",
static_cast<uint16_t>(trainingsite.training_failure_count_.size()));
fw.unsigned_16(static_cast<uint16_t> (trainingsite.training_failure_count_.size()));
- for
- (TrainingSite::TrainFailCount::const_iterator i = trainingsite.training_failure_count_.begin();
- i != trainingsite.training_failure_count_.end(); i++)
- {
- fw.unsigned_8(static_cast<uint8_t>(i->first.first));
- fw.unsigned_16(i->first.second);
- fw.unsigned_16(i->second.first);
- fw.unsigned_8(i->second.second);
+ for (const auto& fail_and_presence : trainingsite.training_failure_count_) {
+ fw.unsigned_8(static_cast<uint8_t>(fail_and_presence.first.first));
+ fw.unsigned_16(fail_and_presence.first.second);
+ fw.unsigned_16(fail_and_presence.second.first);
+ fw.unsigned_8(fail_and_presence.second.second);
}
-
// DONE
}
}
=== modified file 'src/map_io/map_message_saver.h'
--- src/map_io/map_message_saver.h 2014-09-19 12:54:54 +0000
+++ src/map_io/map_message_saver.h 2016-07-24 18:05:26 +0000
@@ -41,11 +41,11 @@
/// that will be used as the id of the message when the game is loaded.
struct MapMessageSaver : private std::map<MessageId, MessageId> {
MapMessageSaver() : counter(0) {}
- void add(MessageId const id) {
+ void add(const MessageId& id) {
assert(find(id) == end());
insert(std::pair<MessageId, MessageId>(id, ++counter));
}
- MessageId operator[](MessageId const id) const {
+ MessageId operator[](const MessageId& id) const {
return find(id) != end() ? find(id)->second : MessageId::null();
}
private:
=== modified file 'src/network/netclient.cc'
--- src/network/netclient.cc 2016-05-14 18:18:51 +0000
+++ src/network/netclient.cc 2016-07-24 18:05:26 +0000
@@ -417,7 +417,7 @@
// launchgame-menu, here properly should be a set_name function
}
-void NetClient::set_player(uint8_t, PlayerSettings)
+void NetClient::set_player(uint8_t, const PlayerSettings&)
{
// do nothing here - the request for a positionchange is send in
// set_player_number(uint8_t) to the host.
=== modified file 'src/network/netclient.h'
--- src/network/netclient.h 2016-05-14 18:18:51 +0000
+++ src/network/netclient.h 2016-07-24 18:05:26 +0000
@@ -86,7 +86,7 @@
(uint8_t number, const std::string & tribe, bool const random_tribe = false) override;
void set_player_init (uint8_t number, uint8_t index) override;
void set_player_name (uint8_t number, const std::string & name) override;
- void set_player (uint8_t number, PlayerSettings ps) override;
+ void set_player (uint8_t number, const PlayerSettings& ps) override;
void set_player_number (uint8_t number) override;
void set_player_team (uint8_t number, Widelands::TeamNumber team) override;
void set_player_closeable(uint8_t number, bool closeable) override;
=== modified file 'src/network/nethost.cc'
--- src/network/nethost.cc 2016-05-15 07:48:41 +0000
+++ src/network/nethost.cc 2016-07-24 18:05:26 +0000
@@ -266,7 +266,7 @@
host_->set_player_name(number, name);
}
- void set_player(uint8_t const number, PlayerSettings const ps) override {
+ void set_player(uint8_t const number, const PlayerSettings& ps) override {
if (number >= host_->settings().players.size())
return;
host_->set_player(number, ps);
@@ -1409,7 +1409,7 @@
}
-void NetHost::set_player(uint8_t const number, PlayerSettings const ps)
+void NetHost::set_player(uint8_t const number, const PlayerSettings& ps)
{
if (number >= d->settings.players.size())
return;
=== modified file 'src/network/nethost.h'
--- src/network/nethost.h 2016-05-14 18:18:51 +0000
+++ src/network/nethost.h 2016-07-24 18:05:26 +0000
@@ -71,7 +71,7 @@
void set_player_init (uint8_t number, uint8_t index);
void set_player_ai (uint8_t number, const std::string & name, bool const random_ai = false);
void set_player_name (uint8_t number, const std::string & name);
- void set_player (uint8_t number, PlayerSettings);
+ void set_player (uint8_t number, const PlayerSettings&);
void set_player_number (uint8_t number);
void set_player_team (uint8_t number, Widelands::TeamNumber team);
void set_player_closeable(uint8_t number, bool closeable);
Follow ups