Merge lp:~qcumber-some/widelands/cppcheck_const_refs into lp:widelands

Proposed by Jens Beyer
Status: Merged
Merged at revision: 6416
Proposed branch: lp:~qcumber-some/widelands/cppcheck_const_refs
Merge into: lp:widelands
Diff against target: 1062 lines (+123/-123)
44 files modified
src/descr_maintainer.h (+2/-2)
src/economy/economy.h (+10/-10)
src/economy/test/test_road.cc (+1/-1)
src/economy/test/test_routing.cc (+1/-1)
src/economy/warehousesupply.h (+2/-2)
src/gamesettings.h (+1/-1)
src/graphic/animation_gfx.h (+2/-2)
src/graphic/render/gameview.cc (+5/-5)
src/graphic/render/terrain_sdl.h (+2/-2)
src/io/basic_fileread.h (+3/-3)
src/io/basic_filewrite.h (+2/-2)
src/journal.cc (+2/-2)
src/logic/cmd_expire_message.h (+1/-1)
src/logic/dismantlesite.cc (+1/-1)
src/logic/dismantlesite.h (+1/-1)
src/logic/immovable.cc (+1/-1)
src/logic/immovable.h (+1/-1)
src/logic/map.cc (+3/-3)
src/logic/message_id.h (+3/-3)
src/logic/message_queue.h (+3/-3)
src/logic/path.cc (+2/-2)
src/logic/path.h (+4/-4)
src/logic/player.cc (+4/-4)
src/logic/player.h (+9/-9)
src/logic/playercommand.h (+7/-7)
src/logic/production_program.h (+2/-2)
src/logic/productionsite.h (+3/-3)
src/logic/soldier.cc (+1/-1)
src/logic/soldier.h (+1/-1)
src/logic/tribe.h (+5/-5)
src/logic/warelist.h (+1/-1)
src/manager.h (+2/-2)
src/map_generator.cc (+2/-2)
src/map_generator.h (+2/-2)
src/map_io/widelands_map_message_saver.h (+2/-2)
src/network/netclient.cc (+1/-1)
src/network/netclient.h (+1/-1)
src/network/nethost.cc (+1/-1)
src/rect.h (+1/-1)
src/ui_basic/checkbox.h (+1/-1)
src/vector.h (+2/-2)
src/wlapplication.cc (+15/-15)
src/wui/encyclopedia_window.h (+1/-1)
src/wui/overlay_manager.h (+6/-6)
To merge this branch: bzr merge lp:~qcumber-some/widelands/cppcheck_const_refs
Reviewer Review Type Date Requested Status
Widelands Developers Pending
Review via email: mp+114312@code.launchpad.net

Description of the change

I did my share of tedious work to get rid of >100 (const) reference recommendations by cppcheck 1.55

Most of them were simple, but about a few I'm not sure. But it compiles and runs, so I guess it is right ;-)

To post a comment you must log in.
Revision history for this message
SirVer (sirver) wrote :

Well... I start to dislike cppcheck. Most of them are harmless, but replacing the passing of a 8 bit integer through a const reference to a 8 bit integer effectively increases the amount of data passed to the functions. It will hardly matter in any case, but it seems futile to mark this as an error.

I merged this for the sake of shutting cppcheck up. But I feel we should maybe just ignore non-compiler warnings or at least use something that understands more of what it parses like LLVM.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/descr_maintainer.h'
2--- src/descr_maintainer.h 2012-04-25 07:26:30 +0000
3+++ src/descr_maintainer.h 2012-07-11 00:26:24 +0000
4@@ -66,7 +66,7 @@
5 typename T::Index nitemsw;
6 T * * items;
7
8- void reserve(const typename T::Index n) {
9+ void reserve(const typename T::Index & n) {
10 T * * const new_items =
11 static_cast<T * *>(realloc(items, sizeof(T *) * n));
12 if (not new_items)
13@@ -130,7 +130,7 @@
14 idx == -1 ? T_Index::Null() :
15 T_Index(static_cast<typename T_Index::value_t>(idx));
16 }
17- T * get(T_Index const idx) const {
18+ T * get(T_Index const & idx) const {
19 return idx ? Descr_Maintainer<T>::get(idx.value()) : 0;
20 }
21 };
22
23=== modified file 'src/economy/economy.h'
24--- src/economy/economy.h 2012-02-15 21:25:34 +0000
25+++ src/economy/economy.h 2012-07-11 00:26:24 +0000
26@@ -109,10 +109,10 @@
27 void remove_supply(Supply &);
28
29 /// information about this economy
30- WareList::count_type stock_ware (Ware_Index const i) {
31+ WareList::count_type stock_ware (Ware_Index const & i) {
32 return m_wares .stock(i);
33 }
34- WareList::count_type stock_worker(Ware_Index const i) {
35+ WareList::count_type stock_worker(Ware_Index const & i) {
36 return m_workers.stock(i);
37 }
38
39@@ -126,16 +126,16 @@
40 /// ware type by overproducing a worker type from it.
41 bool needs_worker(Ware_Index) const;
42
43- Target_Quantity const & ware_target_quantity (Ware_Index const i) const {
44- return m_ware_target_quantities[i.value()];
45- }
46- Target_Quantity & ware_target_quantity (Ware_Index const i) {
47- return m_ware_target_quantities[i.value()];
48- }
49- Target_Quantity const & worker_target_quantity(Ware_Index const i) const {
50+ Target_Quantity const & ware_target_quantity (Ware_Index const & i) const {
51+ return m_ware_target_quantities[i.value()];
52+ }
53+ Target_Quantity & ware_target_quantity (Ware_Index const & i) {
54+ return m_ware_target_quantities[i.value()];
55+ }
56+ Target_Quantity const & worker_target_quantity(Ware_Index const & i) const {
57 return m_worker_target_quantities[i.value()];
58 }
59- Target_Quantity & worker_target_quantity(Ware_Index const i) {
60+ Target_Quantity & worker_target_quantity(Ware_Index const & i) {
61 return m_worker_target_quantities[i.value()];
62 }
63
64
65=== modified file 'src/economy/test/test_road.cc'
66--- src/economy/test/test_road.cc 2012-03-03 19:23:20 +0000
67+++ src/economy/test/test_road.cc 2012-07-11 00:26:24 +0000
68@@ -32,7 +32,7 @@
69 /* Helper classes */
70 /******************/
71 struct TestingFlag : public Flag {
72- TestingFlag(Editor_Game_Base &, Coords const c) : Flag() {
73+ TestingFlag(Editor_Game_Base &, Coords const & c) : Flag() {
74 set_flag_position(c);
75 }
76
77
78=== modified file 'src/economy/test/test_routing.cc'
79--- src/economy/test/test_routing.cc 2012-04-06 19:26:17 +0000
80+++ src/economy/test/test_routing.cc 2012-07-11 00:26:24 +0000
81@@ -408,7 +408,7 @@
82 */
83 TestingRoutingNode * new_node_w_neighbour
84 (TestingRoutingNode * const d,
85- Coords const pos = Coords(0, 0),
86+ Coords const & pos = Coords(0, 0),
87 int32_t = 1,
88 int32_t const waitcost = 0)
89 {
90
91=== modified file 'src/economy/warehousesupply.h'
92--- src/economy/warehousesupply.h 2012-02-15 21:25:34 +0000
93+++ src/economy/warehousesupply.h 2012-07-11 00:26:24 +0000
94@@ -41,10 +41,10 @@
95
96 WareList const & get_wares () const {return m_wares;}
97 WareList const & get_workers() const {return m_workers;}
98- uint32_t stock_wares (Ware_Index const i) const {
99+ uint32_t stock_wares (Ware_Index const & i) const {
100 return m_wares .stock(i);
101 }
102- uint32_t stock_workers(Ware_Index const i) const {
103+ uint32_t stock_workers(Ware_Index const & i) const {
104 return m_workers.stock(i);
105 }
106 void add_wares (Ware_Index, uint32_t count);
107
108=== modified file 'src/gamesettings.h'
109--- src/gamesettings.h 2012-02-15 21:25:34 +0000
110+++ src/gamesettings.h 2012-07-11 00:26:24 +0000
111@@ -146,7 +146,7 @@
112 virtual void setPlayerTribe (uint8_t number, std::string const &, bool const random_tribe = false) = 0;
113 virtual void setPlayerInit (uint8_t number, uint8_t index) = 0;
114 virtual void setPlayerName (uint8_t number, std::string const &) = 0;
115- virtual void setPlayer (uint8_t number, PlayerSettings) = 0;
116+ virtual void setPlayer (uint8_t number, PlayerSettings const &) = 0;
117 virtual void setPlayerNumber (uint8_t number) = 0;
118 virtual void setPlayerTeam (uint8_t number, Widelands::TeamNumber team) = 0;
119 virtual void setPlayerCloseable(uint8_t number, bool closeable) = 0;
120
121=== modified file 'src/graphic/animation_gfx.h'
122--- src/graphic/animation_gfx.h 2012-02-15 21:25:34 +0000
123+++ src/graphic/animation_gfx.h 2012-07-11 00:26:24 +0000
124@@ -38,7 +38,7 @@
125 }
126
127 const PictureID & get_frame
128- (Index const i,
129+ (Index const & i,
130 Widelands::Player_Number const player_number,
131 const RGBColor & playercolor)
132 {
133@@ -54,7 +54,7 @@
134 return m_plrframes[player_number][i];
135 }
136
137- const PictureID & get_frame(Index const i) const {
138+ const PictureID & get_frame(Index const & i) const {
139 assert(i < nr_frames());
140 return m_plrframes[0][i];
141 }
142
143=== modified file 'src/graphic/render/gameview.cc'
144--- src/graphic/render/gameview.cc 2012-06-08 22:33:16 +0000
145+++ src/graphic/render/gameview.cc 2012-07-11 00:26:24 +0000
146@@ -1127,8 +1127,8 @@
147 template<typename T>
148 static bool draw_minimap_frameborder
149 (Widelands::FCoords const f,
150- Point const ptopleft,
151- Point const pbottomright,
152+ Point const & ptopleft,
153+ Point const & pbottomright,
154 int32_t const mapwidth,
155 int32_t const mapheight,
156 int32_t const modx,
157@@ -1188,9 +1188,9 @@
158 int32_t const mapwidth,
159 Widelands::Editor_Game_Base const & egbase,
160 Widelands::Player const * const player,
161- Rect const rc,
162- Point const viewpoint,
163- Point const framepoint,
164+ Rect const & rc,
165+ Point const & viewpoint,
166+ Point const & framepoint,
167 uint32_t const flags)
168 {
169 Widelands::Map const & map = egbase.map();
170
171=== modified file 'src/graphic/render/terrain_sdl.h'
172--- src/graphic/render/terrain_sdl.h 2012-02-15 21:25:34 +0000
173+++ src/graphic/render/terrain_sdl.h 2012-07-11 00:26:24 +0000
174@@ -533,7 +533,7 @@
175 }
176
177 template<typename T> static void render_road_horiz
178- (SurfaceSDL & dst, Point const start, Point const end, SurfaceSDL const & src)
179+ (SurfaceSDL & dst, Point const & start, Point const & end, SurfaceSDL const & src)
180 {
181 int32_t const dstw = dst.get_w();
182 int32_t const dsth = dst.get_h();
183@@ -560,7 +560,7 @@
184 }
185
186 template<typename T> static void render_road_vert
187- (SurfaceSDL & dst, Point const start, Point const end, SurfaceSDL const & src)
188+ (SurfaceSDL & dst, Point const & start, Point const & end, SurfaceSDL const & src)
189 {
190 int32_t const dstw = dst.get_w();
191 int32_t const dsth = dst.get_h();
192
193=== modified file 'src/io/basic_fileread.h'
194--- src/io/basic_fileread.h 2012-05-06 16:28:43 +0000
195+++ src/io/basic_fileread.h 2012-07-11 00:26:24 +0000
196@@ -95,7 +95,7 @@
197
198 /// Set the file pointer to the given location.
199 /// \throws File_Boundary_Exceeded if the pointer is out of bound.
200- void SetFilePos(Pos const pos) {
201+ void SetFilePos(Pos const & pos) {
202 assert(data);
203 if (pos >= length)
204 throw File_Boundary_Exceeded();
205@@ -114,7 +114,7 @@
206 return read;
207 }
208
209- char * Data(uint32_t const bytes, const Pos pos = Pos::Null()) {
210+ char * Data(uint32_t const bytes, const Pos & pos = Pos::Null()) {
211 assert(data);
212
213 Pos i = pos;
214@@ -127,7 +127,7 @@
215 return data + i;
216 }
217
218- char * CString(Pos const pos) {
219+ char * CString(Pos const & pos) {
220 assert(data);
221
222 Pos i = pos.isNull() ? filepos : pos;
223
224=== modified file 'src/io/basic_filewrite.h'
225--- src/io/basic_filewrite.h 2012-02-15 21:25:34 +0000
226+++ src/io/basic_filewrite.h 2012-07-11 00:26:24 +0000
227@@ -76,14 +76,14 @@
228
229 /// Set the file pointer to a new location. The position can be beyond the
230 /// current end of file.
231- void SetPos(const Pos pos) throw () {filepos = pos;}
232+ void SetPos(const Pos & pos) throw () {filepos = pos;}
233
234 /**
235 * Write data at the given location. If pos is NoPos(), write at the
236 * file pointer and advance the file pointer.
237 */
238 void Data
239- (const void * const src, const size_t size, Pos const pos = Pos::Null())
240+ (const void * const src, const size_t size, Pos const & pos = Pos::Null())
241 {
242 assert(data or not filelength);
243
244
245=== modified file 'src/journal.cc'
246--- src/journal.cc 2012-02-15 21:25:34 +0000
247+++ src/journal.cc 2012-07-11 00:26:24 +0000
248@@ -216,7 +216,7 @@
249 m_record = true;
250 log("Recording into %s\n", m_recordname.c_str());
251 }
252- catch (std::ofstream::failure e) {
253+ catch (std::ofstream::failure & e) {
254 //TODO: use exception mask to find out what happened
255 //TODO: there should be a messagebox to tell the user.
256 log
257@@ -266,7 +266,7 @@
258 m_playback = true;
259 log("Playing back from %s\n", m_playbackname.c_str());
260 }
261- catch (std::ifstream::failure e) {
262+ catch (std::ifstream::failure & e) {
263 //TODO: use exception mask to find out what happened
264 //TODO: there should be a messagebox to tell the user.
265 log
266
267=== modified file 'src/logic/cmd_expire_message.h'
268--- src/logic/cmd_expire_message.h 2012-02-15 21:25:34 +0000
269+++ src/logic/cmd_expire_message.h 2012-07-11 00:26:24 +0000
270@@ -35,7 +35,7 @@
271 /// the savegame.
272 struct Cmd_ExpireMessage : public Command {
273 Cmd_ExpireMessage
274- (int32_t const t, Player_Number const p, Message_Id const m)
275+ (int32_t const t, Player_Number const p, Message_Id const & m)
276 : Command(t), player(p), message(m)
277 {}
278
279
280=== modified file 'src/logic/dismantlesite.cc'
281--- src/logic/dismantlesite.cc 2012-06-25 21:25:22 +0000
282+++ src/logic/dismantlesite.cc 2012-07-11 00:26:24 +0000
283@@ -64,7 +64,7 @@
284 {}
285
286 DismantleSite::DismantleSite
287- (const DismantleSite_Descr & descr, Editor_Game_Base & egbase, Coords const c,
288+ (const DismantleSite_Descr & descr, Editor_Game_Base & egbase, Coords const & c,
289 Player & plr, const Building_Descr & bdscr, bool loading)
290 :
291 Partially_Finished_Building(descr)
292
293=== modified file 'src/logic/dismantlesite.h'
294--- src/logic/dismantlesite.h 2012-06-25 21:25:22 +0000
295+++ src/logic/dismantlesite.h 2012-07-11 00:26:24 +0000
296@@ -63,7 +63,7 @@
297 DismantleSite(const DismantleSite_Descr & descr);
298 DismantleSite
299 (const DismantleSite_Descr & descr, Editor_Game_Base &,
300- Coords const, Player &, const Building_Descr &, bool);
301+ Coords const &, Player &, const Building_Descr &, bool);
302
303 char const * type_name() const throw () {return "dismantlesite";}
304 virtual std::string get_statistics_string();
305
306=== modified file 'src/logic/immovable.cc'
307--- src/logic/immovable.cc 2012-06-08 22:33:16 +0000
308+++ src/logic/immovable.cc 2012-07-11 00:26:24 +0000
309@@ -506,7 +506,7 @@
310 }
311
312 void Immovable::draw_construction
313- (const Editor_Game_Base & game, RenderTarget & dst, const Point pos)
314+ (const Editor_Game_Base & game, RenderTarget & dst, const Point & pos)
315 {
316 const ImmovableProgram::ActConstruction * constructionact = 0;
317 if (m_program_ptr < m_program->size())
318
319=== modified file 'src/logic/immovable.h'
320--- src/logic/immovable.h 2012-02-15 21:25:34 +0000
321+++ src/logic/immovable.h 2012-07-11 00:26:24 +0000
322@@ -252,7 +252,7 @@
323 void increment_program_pointer();
324
325 void draw_construction
326- (const Editor_Game_Base &, RenderTarget &, const Point);
327+ (const Editor_Game_Base &, RenderTarget &, const Point &);
328 };
329
330
331
332=== modified file 'src/logic/map.cc'
333--- src/logic/map.cc 2012-03-09 10:37:34 +0000
334+++ src/logic/map.cc 2012-07-11 00:26:24 +0000
335@@ -809,7 +809,7 @@
336 FindBobsCallback(std::vector<Bob *> * const list, FindBob const & functor)
337 : m_list(list), m_functor(functor), m_found(0) {}
338
339- void operator()(const Map &, const FCoords cur) {
340+ void operator()(const Map &, const FCoords & cur) {
341 for
342 (Bob * bob = cur.field->get_first_bob();
343 bob;
344@@ -896,7 +896,7 @@
345 (std::vector<ImmovableFound> * const list, FindImmovable const & functor)
346 : m_list(list), m_functor(functor), m_found(0) {}
347
348- void operator()(const Map &, const FCoords cur) {
349+ void operator()(const Map &, const FCoords & cur) {
350 BaseImmovable * const imm = cur.field->get_immovable();
351
352 if (!imm)
353@@ -1005,7 +1005,7 @@
354 (std::vector<Coords> * const list, FindNode const & functor)
355 : m_list(list), m_functor(functor), m_found(0) {}
356
357- void operator()(const Map & map, const FCoords cur) {
358+ void operator()(const Map & map, const FCoords & cur) {
359 if (m_functor.accept(map, cur)) {
360 if (m_list)
361 m_list->push_back(cur);
362
363=== modified file 'src/logic/message_id.h'
364--- src/logic/message_id.h 2012-02-15 21:25:34 +0000
365+++ src/logic/message_id.h 2012-07-11 00:26:24 +0000
366@@ -46,9 +46,9 @@
367 /// Constant value for no message.
368 static Message_Id Null() {Message_Id result; result.id = 0; return result;}
369
370- bool operator== (Message_Id const other) const {return id == other.id;}
371- bool operator!= (Message_Id const other) const {return id != other.id;}
372- bool operator< (Message_Id const other) const {return id < other.id;}
373+ bool operator== (Message_Id const & other) const {return id == other.id;}
374+ bool operator!= (Message_Id const & other) const {return id != other.id;}
375+ bool operator< (Message_Id const & other) const {return id < other.id;}
376 operator bool () const {return *this != Null();}
377 uint32_t value() const {return id;}
378
379
380=== modified file 'src/logic/message_queue.h'
381--- src/logic/message_queue.h 2012-04-07 11:22:36 +0000
382+++ src/logic/message_queue.h 2012-07-11 00:26:24 +0000
383@@ -67,7 +67,7 @@
384 }
385
386 /// \returns a pointer to the message if it exists, otherwise 0.
387- Message const * operator[](Message_Id const id) const {
388+ Message const * operator[](Message_Id const & id) const {
389 assert_counts();
390 const_iterator const it = find(Message_Id(id));
391 return it != end() ? it->second : 0;
392@@ -106,7 +106,7 @@
393 }
394
395 /// Sets the status of the message with the given id, if it exists.
396- void set_message_status(Message_Id const id, Message::Status const status) {
397+ void set_message_status(Message_Id const & id, Message::Status const status) {
398 assert_counts();
399 assert(status < 3);
400 iterator const it = find(id);
401@@ -122,7 +122,7 @@
402
403 /// Expire the message with the given id so that it no longer exists.
404 /// Assumes that a message with the given id exists.
405- void expire_message(Message_Id const id) {
406+ void expire_message(Message_Id const & id) {
407 assert_counts();
408 iterator const it = find(id);
409 assert(it != end());
410
411=== modified file 'src/logic/path.cc'
412--- src/logic/path.cc 2012-02-15 21:25:34 +0000
413+++ src/logic/path.cc 2012-07-11 00:26:24 +0000
414@@ -147,7 +147,7 @@
415 Truncate the path after the given number of steps
416 ===============
417 */
418-void CoordPath::truncate(const std::vector<char>::size_type after) {
419+void CoordPath::truncate(const std::vector<char>::size_type & after) {
420 assert(after <= m_path.size());
421
422 m_path.erase(m_path.begin() + after, m_path.end());
423@@ -159,7 +159,7 @@
424 Opposite of truncate: remove the first n steps of the path.
425 ===============
426 */
427-void CoordPath::starttrim(const std::vector<char>::size_type before) {
428+void CoordPath::starttrim(const std::vector<char>::size_type & before) {
429 assert(before <= m_path.size());
430
431 m_path.erase(m_path.begin(), m_path.begin() + before);
432
433=== modified file 'src/logic/path.h'
434--- src/logic/path.h 2012-02-15 21:25:34 +0000
435+++ src/logic/path.h 2012-07-11 00:26:24 +0000
436@@ -51,7 +51,7 @@
437
438 typedef std::vector<Direction> Step_Vector;
439 Step_Vector::size_type get_nsteps() const throw () {return m_path.size();}
440- Direction operator[](Step_Vector::size_type const i) const {
441+ Direction operator[](Step_Vector::size_type const & i) const {
442 assert(i < m_path.size());
443 return m_path[m_path.size() - i - 1];
444 }
445@@ -84,7 +84,7 @@
446
447 typedef std::vector<Direction> Step_Vector;
448 Step_Vector::size_type get_nsteps() const throw () {return m_path.size();}
449- Direction operator[](Step_Vector::size_type const i) const {
450+ Direction operator[](Step_Vector::size_type const & i) const {
451 assert(i < m_path.size());
452 return m_path[i];
453 }
454@@ -93,8 +93,8 @@
455 int32_t get_index(Coords field) const;
456
457 void reverse();
458- void truncate (const std::vector<char>::size_type after);
459- void starttrim(const std::vector<char>::size_type before);
460+ void truncate (const std::vector<char>::size_type & after);
461+ void starttrim(const std::vector<char>::size_type & before);
462 void append(const Map & map, const Path & tail);
463 void append(CoordPath const & tail);
464
465
466=== modified file 'src/logic/player.cc'
467--- src/logic/player.cc 2012-07-07 17:09:03 +0000
468+++ src/logic/player.cc 2012-07-11 00:26:24 +0000
469@@ -612,7 +612,7 @@
470 _enhance_or_dismantle(building);
471 }
472 void Player::_enhance_or_dismantle
473- (Building * building, Building_Index const index_of_new_building)
474+ (Building * building, Building_Index const & index_of_new_building)
475 {
476 if
477 (&building->owner() == this
478@@ -1126,7 +1126,7 @@
479 * Get current ware production statistics
480 */
481 const std::vector<uint32_t> * Player::get_ware_production_statistics
482- (Ware_Index const ware) const
483+ (Ware_Index const & ware) const
484 {
485 assert(ware.value() < m_ware_productions.size());
486
487@@ -1138,7 +1138,7 @@
488 * Get current ware consumption statistics
489 */
490 const std::vector<uint32_t> * Player::get_ware_consumption_statistics
491- (Ware_Index const ware) const {
492+ (Ware_Index const & ware) const {
493
494 assert(ware.value() < m_ware_consumptions.size());
495
496@@ -1146,7 +1146,7 @@
497 }
498
499 const std::vector<uint32_t> * Player::get_ware_stock_statistics
500- (Ware_Index const ware) const
501+ (Ware_Index const & ware) const
502 {
503 assert(ware.value() < m_ware_stocks.size());
504
505
506=== modified file 'src/logic/player.h'
507--- src/logic/player.h 2012-04-30 12:32:59 +0000
508+++ src/logic/player.h 2012-07-11 00:26:24 +0000
509@@ -99,7 +99,7 @@
510 Message_Id add_message_with_timeout
511 (Game &, Message &, uint32_t timeout, uint32_t radius);
512
513- void set_message_status(Message_Id const id, Message::Status const status) {
514+ void set_message_status(Message_Id const & id, Message::Status const status) {
515 messages().set_message_status(id, status);
516 }
517
518@@ -420,13 +420,13 @@
519 return m_fields[i].military_influence;
520 }
521
522- bool is_worker_type_allowed(Ware_Index const i) const throw () {
523+ bool is_worker_type_allowed(Ware_Index const & i) const throw () {
524 return m_allowed_worker_types.at(i);
525 }
526 void allow_worker_type(Ware_Index, bool allow);
527
528 // Allowed buildings
529- bool is_building_type_allowed(Building_Index const i) const throw () {
530+ bool is_building_type_allowed(Building_Index const & i) const throw () {
531 return m_allowed_building_types[i];
532 }
533 void allow_building_type(Building_Index, bool allow);
534@@ -465,7 +465,7 @@
535 bool has_economy(Economy &) const throw ();
536 typedef std::vector<Economy *> Economies;
537 Economies::size_type get_economy_number(Economy const *) const throw ();
538- Economy * get_economy_by_number(Economies::size_type const i) const {
539+ Economy * get_economy_by_number(Economies::size_type const & i) const {
540 return m_economies[i];
541 }
542 uint32_t get_nr_economies() const {return m_economies.size();}
543@@ -523,19 +523,19 @@
544
545 // Statistics
546 Building_Stats_vector const & get_building_statistics
547- (Building_Index const i) const
548+ (Building_Index const & i) const
549 {
550 return m_building_stats[i];
551 }
552
553 std::vector<uint32_t> const * get_ware_production_statistics
554- (Ware_Index const) const;
555+ (Ware_Index const &) const;
556
557 std::vector<uint32_t> const * get_ware_consumption_statistics
558- (Ware_Index const) const;
559+ (Ware_Index const &) const;
560
561 std::vector<uint32_t> const * get_ware_stock_statistics
562- (Ware_Index const) const;
563+ (Ware_Index const &) const;
564
565 void ReadStatistics(FileRead &, uint32_t version);
566 void WriteStatistics(FileWrite &) const;
567@@ -563,7 +563,7 @@
568 void update_team_players();
569 void play_message_sound(const std::string & sender);
570 void _enhance_or_dismantle
571- (Building *, Building_Index const index_of_new_building = Building_Index::Null());
572+ (Building *, Building_Index const & index_of_new_building = Building_Index::Null());
573
574 private:
575 MessageQueue m_messages;
576
577=== modified file 'src/logic/playercommand.h'
578--- src/logic/playercommand.h 2012-02-15 21:25:34 +0000
579+++ src/logic/playercommand.h 2012-07-11 00:26:24 +0000
580@@ -89,8 +89,8 @@
581 Cmd_Build
582 (int32_t const _duetime,
583 int32_t const p,
584- Coords const c,
585- Building_Index const i)
586+ Coords const & c,
587+ Building_Index const & i)
588 : PlayerCommand(_duetime, p), coords(c), bi(i)
589 {}
590
591@@ -111,7 +111,7 @@
592
593 struct Cmd_BuildFlag:public PlayerCommand {
594 Cmd_BuildFlag() : PlayerCommand() {} // For savegame loading
595- Cmd_BuildFlag (int32_t const t, int32_t const p, Coords const c) :
596+ Cmd_BuildFlag (int32_t const t, int32_t const p, Coords const & c) :
597 PlayerCommand(t, p), coords(c)
598 {}
599
600@@ -198,7 +198,7 @@
601 (int32_t const _duetime,
602 int32_t const p,
603 Building & b,
604- Building_Index const i)
605+ Building_Index const & i)
606 : PlayerCommand(_duetime, p), serial(b.serial()), bi(i)
607 {}
608
609@@ -540,7 +540,7 @@
610 struct PlayerMessageCommand : public PlayerCommand {
611 PlayerMessageCommand () : PlayerCommand() {} // for savegames
612 PlayerMessageCommand
613- (uint32_t const t, Player_Number const p, Message_Id const i)
614+ (uint32_t const t, Player_Number const p, Message_Id const & i)
615 : PlayerCommand(t, p), m_message_id(i)
616 {}
617
618@@ -558,7 +558,7 @@
619 struct Cmd_MessageSetStatusRead : public PlayerMessageCommand {
620 Cmd_MessageSetStatusRead () : PlayerMessageCommand() {}
621 Cmd_MessageSetStatusRead
622- (uint32_t const t, Player_Number const p, Message_Id const i)
623+ (uint32_t const t, Player_Number const p, Message_Id const & i)
624 : PlayerMessageCommand(t, p, i)
625 {}
626
627@@ -573,7 +573,7 @@
628 struct Cmd_MessageSetStatusArchived : public PlayerMessageCommand {
629 Cmd_MessageSetStatusArchived () : PlayerMessageCommand() {}
630 Cmd_MessageSetStatusArchived
631- (uint32_t const t, Player_Number const p, Message_Id const i)
632+ (uint32_t const t, Player_Number const p, Message_Id const & i)
633 : PlayerMessageCommand(t, p, i)
634 {}
635
636
637=== modified file 'src/logic/production_program.h'
638--- src/logic/production_program.h 2012-02-15 21:25:34 +0000
639+++ src/logic/production_program.h 2012-07-11 00:26:24 +0000
640@@ -177,7 +177,7 @@
641
642 /// Tests whether the economy needs a ware of type ware_type.
643 struct Economy_Needs_Ware : public Condition {
644- Economy_Needs_Ware(Ware_Index const i) : ware_type(i) {}
645+ Economy_Needs_Ware(Ware_Index const & i) : ware_type(i) {}
646 virtual bool evaluate(ProductionSite const &) const;
647 std::string description(Tribe_Descr const &) const;
648 #ifdef WRITE_GAME_DATA_AS_HTML
649@@ -190,7 +190,7 @@
650
651 /// Tests whether the economy needs a worker of type worker_type.
652 struct Economy_Needs_Worker : public Condition {
653- Economy_Needs_Worker(Ware_Index const i) : worker_type(i) {}
654+ Economy_Needs_Worker(Ware_Index const & i) : worker_type(i) {}
655 virtual bool evaluate(ProductionSite const &) const;
656 std::string description(Tribe_Descr const &) const;
657 #ifdef WRITE_GAME_DATA_AS_HTML
658
659=== modified file 'src/logic/productionsite.h'
660--- src/logic/productionsite.h 2012-06-06 14:51:03 +0000
661+++ src/logic/productionsite.h 2012-07-11 00:26:24 +0000
662@@ -74,10 +74,10 @@
663 Ware_Types const & working_positions() const throw () {
664 return m_working_positions;
665 }
666- bool is_output_ware_type (Ware_Index const i) const throw () {
667+ bool is_output_ware_type (Ware_Index const & i) const throw () {
668 return m_output_ware_types .count(i);
669 }
670- bool is_output_worker_type(Ware_Index const i) const throw () {
671+ bool is_output_worker_type(Ware_Index const & i) const throw () {
672 return m_output_worker_types.count(i);
673 }
674 Ware_Types const & inputs() const throw () {return m_inputs;}
675@@ -265,7 +265,7 @@
676 * releasing some wares out of a building
677 */
678 struct Input {
679- Input(Ware_Index const Ware, uint8_t const Max) : m_ware(Ware), m_max(Max)
680+ Input(Ware_Index const & Ware, uint8_t const Max) : m_ware(Ware), m_max(Max)
681 {}
682 ~Input() {}
683
684
685=== modified file 'src/logic/soldier.cc'
686--- src/logic/soldier.cc 2012-06-06 19:32:13 +0000
687+++ src/logic/soldier.cc 2012-07-11 00:26:24 +0000
688@@ -533,7 +533,7 @@
689 * Draw this soldier. This basically draws him as a worker, but add hitpoints
690 */
691 void Soldier::draw
692- (Editor_Game_Base const & game, RenderTarget & dst, Point const pos) const
693+ (Editor_Game_Base const & game, RenderTarget & dst, Point const & pos) const
694 {
695 if (const uint32_t anim = get_current_anim()) {
696
697
698=== modified file 'src/logic/soldier.h'
699--- src/logic/soldier.h 2012-02-15 21:25:34 +0000
700+++ src/logic/soldier.h 2012-07-11 00:26:24 +0000
701@@ -200,7 +200,7 @@
702 Point calc_drawpos(Editor_Game_Base const &, Point) const;
703 /// Draw this soldier
704 virtual void draw
705- (const Editor_Game_Base &, RenderTarget &, const Point) const;
706+ (const Editor_Game_Base &, RenderTarget &, const Point &) const;
707
708 static void calc_info_icon_size
709 (Tribe_Descr const &, uint32_t & w, uint32_t & h);
710
711=== modified file 'src/logic/tribe.h'
712--- src/logic/tribe.h 2012-03-10 16:58:50 +0000
713+++ src/logic/tribe.h 2012-07-11 00:26:24 +0000
714@@ -74,7 +74,7 @@
715 const World & world() const throw () {return m_world;}
716
717 Ware_Index get_nrworkers() const {return m_workers.get_nitems();}
718- Worker_Descr const * get_worker_descr(Ware_Index const index) const {
719+ Worker_Descr const * get_worker_descr(Ware_Index const & index) const {
720 return m_workers.get(index);
721 }
722 Ware_Index worker_index(std::string const & workername) const {
723@@ -93,13 +93,13 @@
724 Ware_Index safe_ware_index(const char * const warename) const;
725 Ware_Index ware_index(std::string const & warename) const;
726 Ware_Index ware_index(char const * const warename) const;
727- Item_Ware_Descr const * get_ware_descr(Ware_Index const index) const {
728+ Item_Ware_Descr const * get_ware_descr(Ware_Index const & index) const {
729 return m_wares.get(index);
730 }
731- void set_ware_type_has_demand_check(Ware_Index const index) const {
732+ void set_ware_type_has_demand_check(Ware_Index const & index) const {
733 m_wares.get(index)->set_has_demand_check();
734 }
735- void set_worker_type_has_demand_check(Ware_Index const index) const {
736+ void set_worker_type_has_demand_check(Ware_Index const & index) const {
737 m_workers.get(index)->set_has_demand_check();
738 }
739 Ware_Index safe_worker_index(std::string const & workername) const;
740@@ -108,7 +108,7 @@
741 return m_buildings.get_nitems();
742 }
743 Building_Index safe_building_index(char const * name) const;
744- Building_Descr const * get_building_descr(Building_Index const index) const
745+ Building_Descr const * get_building_descr(Building_Index const & index) const
746 {
747 return m_buildings.get(index);
748 }
749
750=== modified file 'src/logic/warelist.h'
751--- src/logic/warelist.h 2012-02-15 21:25:34 +0000
752+++ src/logic/warelist.h 2012-07-11 00:26:24 +0000
753@@ -52,7 +52,7 @@
754 void remove(WareList const & wl);
755 count_type stock(Ware_Index) const;
756
757- void set_nrwares(Ware_Index const i) {
758+ void set_nrwares(Ware_Index const & i) {
759 assert(m_wares.empty());
760 m_wares.resize(i.value(), 0);
761 }
762
763=== modified file 'src/manager.h'
764--- src/manager.h 2012-02-15 21:25:34 +0000
765+++ src/manager.h 2012-07-11 00:26:24 +0000
766@@ -94,11 +94,11 @@
767 typedef std::vector<T *> container;
768 typedef typename container::size_type Index;
769 Index size() const {return items.size();}
770- T const & operator[](Index const i) const {
771+ T const & operator[](Index const & i) const {
772 assert(i < size());
773 return *items[i];
774 }
775- T & operator[](Index const i) {
776+ T & operator[](Index const & i) {
777 assert(i < size());
778 return *items[i];
779 }
780
781=== modified file 'src/map_generator.cc'
782--- src/map_generator.cc 2012-02-15 21:25:34 +0000
783+++ src/map_generator.cc 2012-07-11 00:26:24 +0000
784@@ -130,7 +130,7 @@
785 uint32_t const * const random2,
786 uint32_t const * const random3,
787 uint32_t const * const random4,
788- FCoords const fc)
789+ FCoords const & fc)
790 {
791 // We'll take the "D" terrain at first...
792 // TODO: Check how the editor handles this...
793@@ -439,7 +439,7 @@
794 (uint32_t * const random2,
795 uint32_t * const random3,
796 uint32_t * const random4,
797- Coords const c0, Coords const c1, Coords const c2,
798+ Coords const & c0, Coords const & c1, Coords const & c2,
799 uint32_t const h1, uint32_t const h2, uint32_t const h3,
800 RNG & rng,
801 MapGenAreaInfo::MapGenTerrainType & terrType)
802
803=== modified file 'src/map_generator.h'
804--- src/map_generator.h 2012-02-15 21:25:34 +0000
805+++ src/map_generator.h 2012-07-11 00:26:24 +0000
806@@ -98,7 +98,7 @@
807 uint32_t const * const random2,
808 uint32_t const * const random3,
809 uint32_t const * const random4,
810- FCoords const fc);
811+ FCoords const & fc);
812
813 uint8_t make_node_elevation
814 (double elevation, Coords);
815@@ -110,7 +110,7 @@
816 (uint32_t * const random2,
817 uint32_t * const random3,
818 uint32_t * const random4,
819- Coords const c0, Coords const c1, Coords const c2,
820+ Coords const & c0, Coords const & c1, Coords const & c2,
821 uint32_t const h1, uint32_t const h2, uint32_t const h3,
822 RNG & rng,
823 MapGenAreaInfo::MapGenTerrainType & terrType);
824
825=== modified file 'src/map_io/widelands_map_message_saver.h'
826--- src/map_io/widelands_map_message_saver.h 2012-02-15 21:25:34 +0000
827+++ src/map_io/widelands_map_message_saver.h 2012-07-11 00:26:24 +0000
828@@ -40,11 +40,11 @@
829 /// that will be used as the id of the message when the game is loaded.
830 struct Map_Message_Saver : private std::map<Message_Id, Message_Id> {
831 Map_Message_Saver() : counter(0) {}
832- void add(Message_Id const id) {
833+ void add(Message_Id const & id) {
834 assert(find(id) == end());
835 insert(std::pair<Message_Id, Message_Id>(id, ++counter));
836 }
837- Message_Id operator[](Message_Id const id) const {
838+ Message_Id operator[](Message_Id const & id) const {
839 return find(id) != end() ? find(id)->second : Message_Id::Null();
840 }
841 private:
842
843=== modified file 'src/network/netclient.cc'
844--- src/network/netclient.cc 2012-06-08 22:33:16 +0000
845+++ src/network/netclient.cc 2012-07-11 00:26:24 +0000
846@@ -490,7 +490,7 @@
847 // launchgame-menu, here properly should be a set_name function
848 }
849
850-void NetClient::setPlayer(uint8_t, PlayerSettings)
851+void NetClient::setPlayer(uint8_t, PlayerSettings const &)
852 {
853 // do nothing here - the request for a positionchange is send in
854 // setPlayerNumber(uint8_t) to the host.
855
856=== modified file 'src/network/netclient.h'
857--- src/network/netclient.h 2012-02-15 21:25:34 +0000
858+++ src/network/netclient.h 2012-07-11 00:26:24 +0000
859@@ -81,7 +81,7 @@
860 virtual void setPlayerTribe (uint8_t number, std::string const & tribe, bool const random_tribe = false);
861 virtual void setPlayerInit (uint8_t number, uint8_t index);
862 virtual void setPlayerName (uint8_t number, std::string const & name);
863- virtual void setPlayer (uint8_t number, PlayerSettings ps);
864+ virtual void setPlayer (uint8_t number, PlayerSettings const & ps);
865 virtual void setPlayerNumber (uint8_t number);
866 virtual void setPlayerTeam (uint8_t number, Widelands::TeamNumber team);
867 virtual void setPlayerCloseable(uint8_t number, bool closeable);
868
869=== modified file 'src/network/nethost.cc'
870--- src/network/nethost.cc 2012-07-04 18:51:43 +0000
871+++ src/network/nethost.cc 2012-07-11 00:26:24 +0000
872@@ -261,7 +261,7 @@
873 h->setPlayerName(number, name);
874 }
875
876- virtual void setPlayer(uint8_t const number, PlayerSettings const ps) {
877+ virtual void setPlayer(uint8_t const number, PlayerSettings const & ps) {
878 if (number >= h->settings().players.size())
879 return;
880 h->setPlayer(number, ps);
881
882=== modified file 'src/rect.h'
883--- src/rect.h 2012-02-15 21:25:34 +0000
884+++ src/rect.h 2012-07-11 00:26:24 +0000
885@@ -24,7 +24,7 @@
886
887 struct Rect : public Point {
888 Rect() throw () {}
889- Rect(const Point p, const uint32_t W, const uint32_t H) throw ()
890+ Rect(const Point & p, const uint32_t W, const uint32_t H) throw ()
891 : Point(p), w(W), h(H)
892 {}
893 Point bottom_right() const {return *this + Point(w, h);}
894
895=== modified file 'src/ui_basic/checkbox.h'
896--- src/ui_basic/checkbox.h 2012-06-06 15:15:12 +0000
897+++ src/ui_basic/checkbox.h 2012-07-11 00:26:24 +0000
898@@ -94,7 +94,7 @@
899 struct Checkbox : public Statebox {
900 Checkbox
901 (Panel * const parent,
902- Point const p,
903+ Point const & p,
904 PictureID const picid = g_gr->get_no_picture(),
905 std::string const & tooltip_text = std::string())
906 : Statebox(parent, p, picid, tooltip_text)
907
908=== modified file 'src/vector.h'
909--- src/vector.h 2012-02-15 21:25:34 +0000
910+++ src/vector.h 2012-07-11 00:26:24 +0000
911@@ -41,12 +41,12 @@
912 }
913
914 // vector addition
915- Vector operator+ (Vector const other) const {
916+ Vector operator+ (Vector const & other) const {
917 return Vector(x + other.x, y + other.y, z + other.z);
918 }
919
920 // inner product
921- float operator* (Vector const other) const {
922+ float operator* (Vector const & other) const {
923 return x * other.x + y * other.y + z * other.z;
924 }
925
926
927=== modified file 'src/wlapplication.cc'
928--- src/wlapplication.cc 2012-05-27 07:29:33 +0000
929+++ src/wlapplication.cc 2012-07-11 00:26:24 +0000
930@@ -123,11 +123,11 @@
931 (std::string(INSTALL_PREFIX) + '/' + INSTALL_DATADIR));
932 #endif
933 }
934- catch (FileNotFound_error e) {}
935- catch (FileAccessDenied_error e) {
936+ catch (FileNotFound_error & e) {}
937+ catch (FileAccessDenied_error & e) {
938 log("Access denied on %s. Continuing.\n", e.m_filename.c_str());
939 }
940- catch (FileType_error e) {
941+ catch (FileType_error & e) {
942 //TODO: handle me
943 }
944
945@@ -138,11 +138,11 @@
946 g_fs->AddFileSystem(FileSystem::Create("/usr/share/games/widelands"));
947 #endif
948 }
949- catch (FileNotFound_error e) {}
950- catch (FileAccessDenied_error e) {
951+ catch (FileNotFound_error & e) {}
952+ catch (FileAccessDenied_error & e) {
953 log("Access denied on %s. Continuing.\n", e.m_filename.c_str());
954 }
955- catch (FileType_error e) {
956+ catch (FileType_error & e) {
957 //TODO: handle me
958 }
959
960@@ -156,11 +156,11 @@
961 g_fs->AddFileSystem(FileSystem::Create("."));
962 #endif
963 }
964- catch (FileNotFound_error e) {}
965- catch (FileAccessDenied_error e) {
966+ catch (FileNotFound_error & e) {}
967+ catch (FileAccessDenied_error & e) {
968 log("Access denied on %s. Continuing.\n", e.m_filename.c_str());
969 }
970- catch (FileType_error e) {
971+ catch (FileType_error & e) {
972 //TODO: handle me
973 }
974
975@@ -186,11 +186,11 @@
976 g_fs->AddFileSystem(new Datafile(argv0.c_str()));
977 #endif
978 }
979- catch (FileNotFound_error e) {}
980- catch (FileAccessDenied_error e) {
981+ catch (FileNotFound_error & e) {}
982+ catch (FileAccessDenied_error & e) {
983 log ("Access denied on %s. Continuing.\n", e.m_filename.c_str());
984 }
985- catch (FileType_error e) {
986+ catch (FileType_error & e) {
987 //TODO: handle me
988 }
989 }
990@@ -1246,7 +1246,7 @@
991
992 try {
993 journal->start_recording(m_commandline["record"]);
994- } catch (Journalfile_error e) {
995+ } catch (Journalfile_error & e) {
996 wout << "Journal file error: " << e.what() << endl;
997 }
998
999@@ -1260,7 +1260,7 @@
1000 try {
1001 journal->start_playback(m_commandline["playback"]);
1002 }
1003- catch (Journalfile_error e) {
1004+ catch (Journalfile_error & e) {
1005 wout << "Journal file error: " << e.what() << endl;
1006 }
1007
1008@@ -1916,7 +1916,7 @@
1009 s.players[number].name = name;
1010 }
1011
1012- virtual void setPlayer(uint8_t const number, PlayerSettings const ps) {
1013+ virtual void setPlayer(uint8_t const number, PlayerSettings const & ps) {
1014 if (number < s.players.size())
1015 s.players[number] = ps;
1016 }
1017
1018=== modified file 'src/wui/encyclopedia_window.h'
1019--- src/wui/encyclopedia_window.h 2012-02-15 21:25:34 +0000
1020+++ src/wui/encyclopedia_window.h 2012-07-11 00:26:24 +0000
1021@@ -49,7 +49,7 @@
1022 Widelands::Ware_Index m_i;
1023 const Widelands::Item_Ware_Descr * m_descr;
1024
1025- bool operator<(const Ware o) const {
1026+ bool operator<(const Ware & o) const {
1027 return m_descr->descname() < o.m_descr->descname();
1028 }
1029 };
1030
1031=== modified file 'src/wui/overlay_manager.h'
1032--- src/wui/overlay_manager.h 2012-02-15 21:25:34 +0000
1033+++ src/wui/overlay_manager.h 2012-07-11 00:26:24 +0000
1034@@ -65,11 +65,11 @@
1035 static Job_Id Null() {Job_Id result; result.id = 0; return result;}
1036
1037 operator bool() const throw () {return id;}
1038- bool operator<(const Job_Id other) const throw () {return id < other.id;}
1039+ bool operator<(const Job_Id & other) const throw () {return id < other.id;}
1040 private:
1041 friend struct Overlay_Manager;
1042 Job_Id operator++() throw () {++id; return *this;}
1043- bool operator== (Job_Id const other) const throw () {
1044+ bool operator== (Job_Id const & other) const throw () {
1045 return id == other.id;
1046 }
1047 uint32_t id;
1048@@ -168,10 +168,10 @@
1049 private:
1050 struct Registered_Overlays {
1051 Registered_Overlays
1052- (const Job_Id Jobid,
1053- const PictureID Picid,
1054- const Point Hotspot,
1055- const int32_t Level)
1056+ (const Job_Id & Jobid,
1057+ const PictureID & Picid,
1058+ const Point & Hotspot,
1059+ const int32_t Level)
1060 :
1061 picid(Picid),
1062 hotspot(Hotspot),

Subscribers

People subscribed via source and target branches

to status/vote changes: