Merge lp:~widelands-dev/widelands/gcc7 into lp:widelands
- gcc7
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 8379 | ||||
Proposed branch: | lp:~widelands-dev/widelands/gcc7 | ||||
Merge into: | lp:widelands | ||||
Diff against target: |
825 lines (+147/-77) 32 files modified
.travis.yml (+4/-4) CMakeLists.txt (+3/-2) src/CMakeLists.txt (+1/-0) src/base/macros.h (+12/-0) src/graphic/gl/fill_rect_program.cc (+3/-3) src/logic/CMakeLists.txt (+14/-4) src/logic/game_controller.h (+1/-1) src/logic/game_settings.cc (+1/-0) src/logic/game_settings.h (+7/-4) src/logic/map_objects/immovable.cc (+1/-1) src/logic/map_objects/tribes/battle.cc (+0/-1) src/logic/map_objects/tribes/production_program.cc (+1/-2) src/logic/map_objects/tribes/ship.cc (+2/-3) src/logic/mapfringeregion.cc (+10/-4) src/logic/player_end_result.h (+32/-0) src/logic/playersmanager.h (+1/-7) src/logic/single_player_game_controller.h (+1/-0) src/network/gameclient.cc (+1/-2) src/network/gameclient.h (+1/-0) src/network/gamehost.cc (+4/-4) src/network/gamehost.h (+1/-0) src/scripting/CMakeLists.txt (+1/-0) src/scripting/lua_game.cc (+1/-0) src/ui_basic/dropdown.cc (+1/-0) src/ui_basic/editbox.cc (+11/-10) src/ui_basic/listselect.cc (+6/-4) src/ui_basic/multilineeditbox.cc (+9/-8) src/ui_fsmenu/loadgame.cc (+3/-2) src/wui/buildingwindow.cc (+1/-1) src/wui/game_summary.cc (+6/-5) src/wui/interactive_base.cc (+6/-4) src/wui/interactive_player.cc (+1/-1) |
||||
To merge this branch: | bzr merge lp:~widelands-dev/widelands/gcc7 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
kaputtnik (community) | testing | Approve | |
GunChleoc | Needs Resubmitting | ||
Review via email: mp+323576@code.launchpad.net |
Commit message
Added support for gcc7. Removed "redundant-decls" flag for Windows builds due to conflict between SDL and MinGW. New Macro FALLS_THROUGH; for use in switch statements. Got rid of predeclaration of Widelands:
Description of the change
Hello,
You may have found this merge proposal while looking for a fix for the GCC7 build failure. This particular patch targets the development version, but fear not, we have also backported it for build19! You can find that version of the patch here: http://
See also the complete build19 branch as we've also updated the en_GB translation since the original build 19 shipped with a few translation mistakes: https:/
So if you are a package maintainer or just trying to get Widelands build19 to build with GCC7, the patch above should get things working again :)
Original description:
(Note: at the moment this is mainly for testing, not merging. I think branches need a merge proposal in order to find build results from bunnybot, right?)
I don't remember the details, but we didn't add GCC7 in the last round of compiler updates due to some issue. Since then, Ubuntu has done a rebuild of the whole archive with GCC7 [1], and Widelands was among the build failures [2]. GCC 7.1 has now been officially released [3], so it is likely only a question of time before it becomes the default compiler on a lot of systems.
I pushed this branch now to check if we still have a build failure in the development version and if we do, it should naturally be fixed. It isn't unlikely that someone will look for a similar patch for build19 too in the future, so we should probably mark it in such a way that it is easily findable. Could save people some time and duplicated work, assuming the code hasn't changed too much in the meantime. For instance, distros tend to treat build failures pretty seriously since if they cannot build the package it becomes impossible to ship patches or updates to it so they will want to keep build19 buildable.
[1] more details on https:/
[2] http://
[3] https:/
bunnybot (widelandsofficial) wrote : | # |
GunChleoc (gunchleoc) wrote : | # |
Yes, merge requests are the way to ping bunnybot.
Travis still doesn't have GCC7 out of the box, but we could try this:
Hans Joachim Desserud (hjd) wrote : | # |
>Travis still doesn't have GCC7 out of the box, but we could try this:
We already do :)
If you check `.travis.sh`, we add the Ubuntu toolchain PPA [1] before attempting to install gcc. It contains gcc-7, but on closer inspection that package is only published for 17.04. (I believe Travis is still running 14.04 images)
So it should have worked if the package had been available ;) I'll do some digging and see if there's a plan to add GCC7 for older releases now that it has been officially released.
[1] https:/
GunChleoc (gunchleoc) wrote : | # |
I guess the package to keep watching is this one:
SirVer (sirver) wrote : | # |
Seems like this one can go back to in progress, right?
Hans Joachim Desserud (hjd) wrote : | # |
The gcc-7 package should be available now https:/
I suspect this might be related to the MP status, so I've taken the liberty of moving it back to needs review.
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 2266. State: failed. Details: https:/
Appveyor build 2101. State: success. Details: https:/
GunChleoc (gunchleoc) wrote : | # |
And it's working :)
The Travis failure is a compiler error that's only thrown by GCC7.
GunChleoc (gunchleoc) wrote : | # |
P.S: we're getting a lot of warnings generated by -Wimplicit-
Hans Joachim Desserud (hjd) wrote : | # |
>The Travis failure is a compiler error that's only thrown by GCC7.
In fact, only the release build. The debug build is fine, not that I know what the difference might be. (I honestly didn't expect any errors now since I've built it successfully with gcc 7.x on arch)
-Wimplicit-
GunChleoc (gunchleoc) wrote : | # |
I have had a look at the results from the debug build, it's 10 warnings for intended fallthroughs. We could disable the compiler flag around them, it's not that many after all.
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 2273. State: passed. Details: https:/
Appveyor build 2108. State: success. Details: https:/
GunChleoc (gunchleoc) wrote : | # |
Travis logs should be clean now, except for a warning with buffer size in a map_io packet. Since I already have a macro purge branch setup for that one, I'd rather not deal with the merge conflicts.
I'm not happy with the code duplication caused by the new GCC7_DIAG_ON/OFF macros, but it's the best I can do without installing gcc7.
kaputtnik (franku) wrote : | # |
Could compile a release build with gcc 7.1
As far as i can see i get no warnings any more.
SirVer (sirver) wrote : | # |
qq: why not use __attribute__ ((fallthrough)); [1] to get rid of the warnings? This is slightly ugly - so we could hide it in a macro:
#define FALLTHROUGH_
This would make it explicit that we did intend for this to fall through. It should also be compatible across all compilers.
[1] https:/
GunChleoc (gunchleoc) wrote : | # |
A macro is much better, thank you :)
Travis & AppVeyor logs are clean now, so let's get this in.
@bunnybot merge
Preview Diff
1 | === modified file '.travis.yml' |
2 | --- .travis.yml 2017-02-13 17:15:49 +0000 |
3 | +++ .travis.yml 2017-06-15 16:43:33 +0000 |
4 | @@ -36,14 +36,14 @@ |
5 | - compiler: gcc |
6 | env: GCC_VERSION="4.9" BUILD_TYPE="Debug" |
7 | - compiler: gcc |
8 | - env: GCC_VERSION="5" BUILD_TYPE="Debug" |
9 | - - compiler: gcc |
10 | env: GCC_VERSION="6" BUILD_TYPE="Debug" |
11 | - compiler: gcc |
12 | + env: GCC_VERSION="7" BUILD_TYPE="Debug" |
13 | + - compiler: gcc |
14 | env: GCC_VERSION="4.8" BUILD_TYPE="Release" |
15 | - compiler: gcc |
16 | env: GCC_VERSION="4.9" BUILD_TYPE="Release" |
17 | - compiler: gcc |
18 | - env: GCC_VERSION="5" BUILD_TYPE="Release" |
19 | - - compiler: gcc |
20 | env: GCC_VERSION="6" BUILD_TYPE="Release" |
21 | + - compiler: gcc |
22 | + env: GCC_VERSION="7" BUILD_TYPE="Release" |
23 | |
24 | === modified file 'CMakeLists.txt' |
25 | --- CMakeLists.txt 2017-06-01 13:50:48 +0000 |
26 | +++ CMakeLists.txt 2017-06-15 16:43:33 +0000 |
27 | @@ -127,7 +127,6 @@ |
28 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wno-padded") |
29 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wno-sign-conversion") |
30 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wno-missing-noreturn") |
31 | - wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wno-implicit-fallthrough") |
32 | |
33 | # TODO(sirver): weak-vtables should be enabled, but leads to lot of errors right now. |
34 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wno-weak-vtables") |
35 | @@ -143,6 +142,9 @@ |
36 | if(WIN32) |
37 | # This is needed for getenv(). |
38 | wl_add_flag(WL_GENERIC_CXX_FLAGS "-std=gnu++11") |
39 | + else() |
40 | + # SDL and MinGW both declare 'unsigned int __builtin_ia32_crc32qi(unsigned int, unsigned char)', resulting in lots of warnings. So, we can't have this flag in Windows. |
41 | + wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wredundant-decls") |
42 | endif() |
43 | |
44 | # Because of: https://svn.boost.org/trac/boost/ticket/9240. |
45 | @@ -165,7 +167,6 @@ |
46 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Woverlength-strings") |
47 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wpacked") |
48 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wpointer-arith") |
49 | - wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wredundant-decls") |
50 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wsign-promo") |
51 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wsync-nand") |
52 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wtrampolines") |
53 | |
54 | === modified file 'src/CMakeLists.txt' |
55 | --- src/CMakeLists.txt 2017-05-14 20:06:48 +0000 |
56 | +++ src/CMakeLists.txt 2017-06-15 16:43:33 +0000 |
57 | @@ -116,6 +116,7 @@ |
58 | logic |
59 | logic_game_controller |
60 | logic_game_settings |
61 | + logic_single_player_game_settings |
62 | map_io_map_loader |
63 | network |
64 | profile |
65 | |
66 | === modified file 'src/base/macros.h' |
67 | --- src/base/macros.h 2017-01-25 18:55:59 +0000 |
68 | +++ src/base/macros.h 2017-06-15 16:43:33 +0000 |
69 | @@ -67,6 +67,18 @@ |
70 | #define DIAG_OFF(x) GCC_DIAG_OFF(x) CLANG_DIAG_OFF(x) |
71 | #define DIAG_ON(x) GCC_DIAG_ON(x) CLANG_DIAG_ON(x) |
72 | |
73 | +// For switch statements: Tell gcc7 and clang that a fallthrough is intended |
74 | +// https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/ |
75 | +#ifdef __clang__ |
76 | +#define FALLS_THROUGH /* Falls through */ \ |
77 | + [[clang::fallthrough]] |
78 | +#elif __GNUC__ >= 7 |
79 | +#define FALLS_THROUGH /* Falls through */ \ |
80 | + [[gnu::fallthrough]] |
81 | +#else |
82 | +#define FALLS_THROUGH /* Falls through */ |
83 | +#endif |
84 | + |
85 | // disallow copying or assigning a class |
86 | #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ |
87 | TypeName(const TypeName&) = delete; \ |
88 | |
89 | === modified file 'src/graphic/gl/fill_rect_program.cc' |
90 | --- src/graphic/gl/fill_rect_program.cc 2017-01-25 18:55:59 +0000 |
91 | +++ src/graphic/gl/fill_rect_program.cc 2017-06-15 16:43:33 +0000 |
92 | @@ -21,7 +21,7 @@ |
93 | |
94 | #include <vector> |
95 | |
96 | -#include "base/log.h" |
97 | +#include "base/macros.h" |
98 | #include "base/wexception.h" |
99 | |
100 | // static |
101 | @@ -66,7 +66,7 @@ |
102 | switch (template_args.blend_mode) { |
103 | case BlendMode::Subtract: |
104 | glBlendEquation(GL_FUNC_REVERSE_SUBTRACT); |
105 | - /* fallthrough intended */ |
106 | + FALLS_THROUGH; |
107 | case BlendMode::UseAlpha: |
108 | glBlendFunc(GL_ONE, GL_ONE); |
109 | break; |
110 | @@ -132,7 +132,7 @@ |
111 | switch (template_args.blend_mode) { |
112 | case BlendMode::Subtract: |
113 | glBlendEquation(GL_FUNC_ADD); |
114 | - /* fallthrough intended */ |
115 | + FALLS_THROUGH; |
116 | case BlendMode::UseAlpha: |
117 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
118 | break; |
119 | |
120 | === modified file 'src/logic/CMakeLists.txt' |
121 | --- src/logic/CMakeLists.txt 2017-05-21 11:16:46 +0000 |
122 | +++ src/logic/CMakeLists.txt 2017-06-15 16:43:33 +0000 |
123 | @@ -6,17 +6,26 @@ |
124 | |
125 | wl_library(logic_game_settings |
126 | SRCS |
127 | + game_settings.cc |
128 | game_settings.h |
129 | + player_end_result.h |
130 | + DEPENDS |
131 | + io_filesystem |
132 | + logic |
133 | + logic_constants |
134 | + scripting_lua_interface |
135 | + scripting_lua_table |
136 | +) |
137 | + |
138 | +wl_library(logic_single_player_game_settings |
139 | + SRCS |
140 | single_player_game_settings_provider.cc |
141 | single_player_game_settings_provider.h |
142 | DEPENDS |
143 | ai |
144 | base_exceptions |
145 | - io_filesystem |
146 | logic |
147 | - logic_constants |
148 | - scripting_lua_interface |
149 | - scripting_lua_table |
150 | + logic_game_settings |
151 | ) |
152 | |
153 | wl_library(logic_game_controller |
154 | @@ -30,6 +39,7 @@ |
155 | ai |
156 | logic |
157 | logic_constants |
158 | + logic_game_settings |
159 | profile |
160 | ui_basic |
161 | wui |
162 | |
163 | === modified file 'src/logic/game_controller.h' |
164 | --- src/logic/game_controller.h 2017-01-25 18:55:59 +0000 |
165 | +++ src/logic/game_controller.h 2017-06-15 16:43:33 +0000 |
166 | @@ -22,12 +22,12 @@ |
167 | |
168 | #include <string> |
169 | |
170 | +#include "logic/player_end_result.h" |
171 | #include "logic/widelands.h" |
172 | |
173 | namespace Widelands { |
174 | class Game; |
175 | class PlayerCommand; |
176 | -enum class PlayerEndResult : uint8_t; |
177 | } |
178 | |
179 | /** |
180 | |
181 | === added file 'src/logic/game_settings.cc' |
182 | --- src/logic/game_settings.cc 1970-01-01 00:00:00 +0000 |
183 | +++ src/logic/game_settings.cc 2017-06-15 16:43:33 +0000 |
184 | @@ -0,0 +1,1 @@ |
185 | +// Dummy to make CMake happy |
186 | |
187 | === modified file 'src/logic/game_settings.h' |
188 | --- src/logic/game_settings.h 2017-02-10 14:12:36 +0000 |
189 | +++ src/logic/game_settings.h 2017-06-15 16:43:33 +0000 |
190 | @@ -26,14 +26,11 @@ |
191 | |
192 | #include "io/filesystem/layered_filesystem.h" |
193 | #include "logic/map_objects/tribes/tribe_basic_info.h" |
194 | +#include "logic/player_end_result.h" |
195 | #include "logic/widelands.h" |
196 | #include "scripting/lua_interface.h" |
197 | #include "scripting/lua_table.h" |
198 | |
199 | -namespace Widelands { |
200 | -enum class PlayerEndResult : uint8_t; |
201 | -} |
202 | - |
203 | struct PlayerSettings { |
204 | enum State { stateOpen, stateHuman, stateComputer, stateClosed, stateShared }; |
205 | |
206 | @@ -60,6 +57,12 @@ |
207 | return not_connected() - 1; |
208 | } |
209 | |
210 | + UserSettings(Widelands::PlayerEndResult init_result, bool init_ready) |
211 | + : position(0), name(""), result(init_result), win_condition_string(""), ready(init_ready) { |
212 | + } |
213 | + UserSettings() : UserSettings(Widelands::PlayerEndResult::kUndefined, false) { |
214 | + } |
215 | + |
216 | uint8_t position; |
217 | std::string name; |
218 | Widelands::PlayerEndResult result; |
219 | |
220 | === modified file 'src/logic/map_objects/immovable.cc' |
221 | --- src/logic/map_objects/immovable.cc 2017-04-23 12:11:19 +0000 |
222 | +++ src/logic/map_objects/immovable.cc 2017-06-15 16:43:33 +0000 |
223 | @@ -986,7 +986,7 @@ |
224 | probability = value; |
225 | // fallthrough |
226 | } |
227 | - /* no break */ |
228 | + FALLS_THROUGH; |
229 | case '\0': |
230 | goto end; |
231 | default: |
232 | |
233 | === modified file 'src/logic/map_objects/tribes/battle.cc' |
234 | --- src/logic/map_objects/tribes/battle.cc 2017-05-20 19:54:02 +0000 |
235 | +++ src/logic/map_objects/tribes/battle.cc 2017-06-15 16:43:33 +0000 |
236 | @@ -130,7 +130,6 @@ |
237 | } |
238 | |
239 | Soldier* Battle::opponent(const Soldier& soldier) const { |
240 | - assert(&soldier != nullptr); |
241 | assert(first_ == &soldier || second_ == &soldier); |
242 | Soldier* other_soldier = first_ == &soldier ? second_ : first_; |
243 | return other_soldier; |
244 | |
245 | === modified file 'src/logic/map_objects/tribes/production_program.cc' |
246 | --- src/logic/map_objects/tribes/production_program.cc 2017-02-28 12:59:39 +0000 |
247 | +++ src/logic/map_objects/tribes/production_program.cc 2017-06-15 16:43:33 +0000 |
248 | @@ -263,9 +263,8 @@ |
249 | "the specified ware type(s) is only %u, so the group can " |
250 | "never be fulfilled by the site", |
251 | count, count_max); |
252 | - // fallthrough |
253 | } |
254 | - /* no break */ |
255 | + FALLS_THROUGH; |
256 | case '\0': |
257 | case ' ': |
258 | group.second = count; |
259 | |
260 | === modified file 'src/logic/map_objects/tribes/ship.cc' |
261 | --- src/logic/map_objects/tribes/ship.cc 2017-05-03 07:24:06 +0000 |
262 | +++ src/logic/map_objects/tribes/ship.cc 2017-06-15 16:43:33 +0000 |
263 | @@ -275,14 +275,13 @@ |
264 | return; |
265 | } |
266 | log("Oh no... this ship has no sinking animation :(!\n"); |
267 | - // fall trough |
268 | + FALLS_THROUGH; |
269 | case ShipStates::kSinkAnimation: |
270 | // The sink animation has been played, so finally remove the ship from the map |
271 | pop_task(game); |
272 | remove(game); |
273 | return; |
274 | } |
275 | - |
276 | // if the real update function failed (e.g. nothing to transport), the ship goes idle |
277 | ship_update_idle(game, state); |
278 | } |
279 | @@ -686,7 +685,7 @@ |
280 | return start_task_idle(game, descr().main_animation(), 1500); |
281 | } |
282 | } |
283 | - |
284 | + FALLS_THROUGH; |
285 | case ShipStates::kExpeditionWaiting: |
286 | case ShipStates::kExpeditionPortspaceFound: |
287 | case ShipStates::kSinkRequest: |
288 | |
289 | === modified file 'src/logic/mapfringeregion.cc' |
290 | --- src/logic/mapfringeregion.cc 2017-01-25 18:55:59 +0000 |
291 | +++ src/logic/mapfringeregion.cc 2017-06-15 16:43:33 +0000 |
292 | @@ -29,9 +29,11 @@ |
293 | if (area_.radius) { |
294 | remaining_in_phase_ = area_.radius; |
295 | phase_ = 6; |
296 | - } else |
297 | + // Fallthrough |
298 | + } else { |
299 | return false; |
300 | - /* no break */ |
301 | + } |
302 | + FALLS_THROUGH; |
303 | case 1: |
304 | map.get_trn(area_, &area_); |
305 | break; |
306 | @@ -53,6 +55,7 @@ |
307 | default: |
308 | NEVER_HERE(); |
309 | } |
310 | + |
311 | if (--remaining_in_phase_ == 0) { |
312 | remaining_in_phase_ = area_.radius; |
313 | --phase_; |
314 | @@ -66,9 +69,11 @@ |
315 | if (area_.radius) { |
316 | remaining_in_phase_ = area_.radius; |
317 | phase_ = 6; |
318 | - } else |
319 | + // Fallthrough |
320 | + } else { |
321 | return false; |
322 | - /* no break */ |
323 | + } |
324 | + FALLS_THROUGH; |
325 | case 1: |
326 | map.get_trn(area_, &area_); |
327 | break; |
328 | @@ -90,6 +95,7 @@ |
329 | default: |
330 | NEVER_HERE(); |
331 | } |
332 | + |
333 | if (--remaining_in_phase_ == 0) { |
334 | remaining_in_phase_ = area_.radius; |
335 | --phase_; |
336 | |
337 | === added file 'src/logic/player_end_result.h' |
338 | --- src/logic/player_end_result.h 1970-01-01 00:00:00 +0000 |
339 | +++ src/logic/player_end_result.h 2017-06-15 16:43:33 +0000 |
340 | @@ -0,0 +1,32 @@ |
341 | +/* |
342 | + * Copyright (C) 2008-2017 by the Widelands Development Team |
343 | + * |
344 | + * This program is free software; you can redistribute it and/or |
345 | + * modify it under the terms of the GNU General Public License |
346 | + * as published by the Free Software Foundation; either version 2 |
347 | + * of the License, or (at your option) any later version. |
348 | + * |
349 | + * This program is distributed in the hope that it will be useful, |
350 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
351 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
352 | + * GNU General Public License for more details. |
353 | + * |
354 | + * You should have received a copy of the GNU General Public License |
355 | + * along with this program; if not, write to the Free Software |
356 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
357 | + * |
358 | + */ |
359 | + |
360 | +#ifndef WL_LOGIC_PLAYER_END_RESULT_H |
361 | +#define WL_LOGIC_PLAYER_END_RESULT_H |
362 | + |
363 | +namespace Widelands { |
364 | +enum class PlayerEndResult : uint8_t { |
365 | + kLost = 0, |
366 | + kWon = 1, |
367 | + kResigned = 2, |
368 | + kUndefined = 255 |
369 | +}; |
370 | +} |
371 | + |
372 | +#endif // end of include guard: WL_LOGIC_PLAYER_END_RESULT_H |
373 | |
374 | === modified file 'src/logic/playersmanager.h' |
375 | --- src/logic/playersmanager.h 2017-01-25 18:55:59 +0000 |
376 | +++ src/logic/playersmanager.h 2017-06-15 16:43:33 +0000 |
377 | @@ -24,6 +24,7 @@ |
378 | #include <vector> |
379 | |
380 | #include "graphic/playercolor.h" |
381 | +#include "logic/player_end_result.h" |
382 | #include "logic/widelands.h" |
383 | |
384 | namespace Widelands { |
385 | @@ -32,13 +33,6 @@ |
386 | class Player; |
387 | class Player; |
388 | |
389 | -enum class PlayerEndResult : uint8_t { |
390 | - PLAYER_LOST = 0, |
391 | - PLAYER_WON = 1, |
392 | - PLAYER_RESIGNED = 2, |
393 | - UNDEFINED = 255 |
394 | -}; |
395 | - |
396 | /** |
397 | * Hold data once a player left the game, or on game ends. |
398 | * Allowed values for the info string, as key=value pairs separated |
399 | |
400 | === modified file 'src/logic/single_player_game_controller.h' |
401 | --- src/logic/single_player_game_controller.h 2017-01-25 18:55:59 +0000 |
402 | +++ src/logic/single_player_game_controller.h 2017-06-15 16:43:33 +0000 |
403 | @@ -22,6 +22,7 @@ |
404 | |
405 | #include "ai/computer_player.h" |
406 | #include "logic/game_controller.h" |
407 | +#include "logic/player_end_result.h" |
408 | |
409 | class SinglePlayerGameController : public GameController { |
410 | public: |
411 | |
412 | === modified file 'src/network/gameclient.cc' |
413 | --- src/network/gameclient.cc 2017-05-14 06:50:28 +0000 |
414 | +++ src/network/gameclient.cc 2017-06-15 16:43:33 +0000 |
415 | @@ -460,8 +460,7 @@ |
416 | |
417 | // This might happen, if a users connects after the game starts. |
418 | if (number == d->settings.users.size()) { |
419 | - UserSettings newuser; |
420 | - d->settings.users.push_back(newuser); |
421 | + d->settings.users.push_back(*new UserSettings()); |
422 | } |
423 | |
424 | d->settings.users.at(number).name = packet.string(); |
425 | |
426 | === modified file 'src/network/gameclient.h' |
427 | --- src/network/gameclient.h 2017-06-10 16:36:29 +0000 |
428 | +++ src/network/gameclient.h 2017-06-15 16:43:33 +0000 |
429 | @@ -23,6 +23,7 @@ |
430 | #include "chat/chat.h" |
431 | #include "logic/game_controller.h" |
432 | #include "logic/game_settings.h" |
433 | +#include "logic/player_end_result.h" |
434 | #include "network/netclient.h" |
435 | |
436 | struct GameClientImpl; |
437 | |
438 | === modified file 'src/network/gamehost.cc' |
439 | --- src/network/gamehost.cc 2017-05-14 06:50:28 +0000 |
440 | +++ src/network/gamehost.cc 2017-06-15 16:43:33 +0000 |
441 | @@ -143,7 +143,7 @@ |
442 | newstate = PlayerSettings::stateClosed; |
443 | break; |
444 | } // else fall through |
445 | - /* no break */ |
446 | + FALLS_THROUGH; |
447 | case PlayerSettings::stateComputer: { |
448 | const ComputerPlayer::ImplementationVector& impls = ComputerPlayer::get_implementations(); |
449 | ComputerPlayer::ImplementationVector::const_iterator it = impls.begin(); |
450 | @@ -1592,14 +1592,14 @@ |
451 | for (uint32_t i = 0; i < d->settings.users.size(); ++i) |
452 | if (d->settings.users[i].position == UserSettings::not_connected()) { |
453 | client.usernum = i; |
454 | - d->settings.users[i].result = Widelands::PlayerEndResult::UNDEFINED; |
455 | + d->settings.users[i].result = Widelands::PlayerEndResult::kUndefined; |
456 | d->settings.users[i].ready = true; |
457 | break; |
458 | } |
459 | if (client.usernum == -1) { |
460 | client.usernum = d->settings.users.size(); |
461 | UserSettings newuser; |
462 | - newuser.result = Widelands::PlayerEndResult::UNDEFINED; |
463 | + newuser.result = Widelands::PlayerEndResult::kUndefined; |
464 | newuser.ready = true; |
465 | d->settings.users.push_back(newuser); |
466 | } |
467 | @@ -2371,7 +2371,7 @@ |
468 | if (user.position == p_nr - 1) { |
469 | user.result = result; |
470 | user.win_condition_string = info; |
471 | - if (result == Widelands::PlayerEndResult::PLAYER_LOST) { |
472 | + if (result == Widelands::PlayerEndResult::kLost) { |
473 | send_system_message_code("PLAYER_DEFEATED", user.name); |
474 | } |
475 | } |
476 | |
477 | === modified file 'src/network/gamehost.h' |
478 | --- src/network/gamehost.h 2017-05-10 18:06:13 +0000 |
479 | +++ src/network/gamehost.h 2017-06-15 16:43:33 +0000 |
480 | @@ -22,6 +22,7 @@ |
481 | |
482 | #include "logic/game_controller.h" |
483 | #include "logic/game_settings.h" |
484 | +#include "logic/player_end_result.h" |
485 | #include "logic/widelands.h" |
486 | #include "network/nethost.h" |
487 | #include "network/network.h" |
488 | |
489 | === modified file 'src/scripting/CMakeLists.txt' |
490 | --- src/scripting/CMakeLists.txt 2017-02-28 12:59:39 +0000 |
491 | +++ src/scripting/CMakeLists.txt 2017-06-15 16:43:33 +0000 |
492 | @@ -111,6 +111,7 @@ |
493 | logic_campaign_visibility |
494 | logic_constants |
495 | logic_game_controller |
496 | + logic_game_settings |
497 | logic_widelands_geometry |
498 | map_io |
499 | scripting_base |
500 | |
501 | === modified file 'src/scripting/lua_game.cc' |
502 | --- src/scripting/lua_game.cc 2017-05-09 09:18:14 +0000 |
503 | +++ src/scripting/lua_game.cc 2017-06-15 16:43:33 +0000 |
504 | @@ -32,6 +32,7 @@ |
505 | #include "logic/objective.h" |
506 | #include "logic/path.h" |
507 | #include "logic/player.h" |
508 | +#include "logic/player_end_result.h" |
509 | #include "logic/playersmanager.h" |
510 | #include "scripting/globals.h" |
511 | #include "scripting/lua_interface.h" |
512 | |
513 | === modified file 'src/ui_basic/dropdown.cc' |
514 | --- src/ui_basic/dropdown.cc 2017-05-08 09:26:55 +0000 |
515 | +++ src/ui_basic/dropdown.cc 2017-06-15 16:43:33 +0000 |
516 | @@ -291,6 +291,7 @@ |
517 | if (list_->is_visible()) { |
518 | set_value(); |
519 | } |
520 | + break; |
521 | case SDLK_ESCAPE: |
522 | if (list_->is_visible()) { |
523 | list_->select(current_selection_); |
524 | |
525 | === modified file 'src/ui_basic/editbox.cc' |
526 | --- src/ui_basic/editbox.cc 2017-05-25 12:30:40 +0000 |
527 | +++ src/ui_basic/editbox.cc 2017-06-15 16:43:33 +0000 |
528 | @@ -209,15 +209,16 @@ |
529 | if (code.mod & KMOD_NUM) { |
530 | break; |
531 | } |
532 | - /* no break */ |
533 | + FALLS_THROUGH; |
534 | case SDLK_DELETE: |
535 | if (m_->caret < m_->text.size()) { |
536 | while ((m_->text[++m_->caret] & 0xc0) == 0x80) { |
537 | }; |
538 | - // now handle it like Backspace |
539 | - } else |
540 | + // Now fallthrough to handle it like Backspace |
541 | + } else { |
542 | return true; |
543 | - /* no break */ |
544 | + } |
545 | + FALLS_THROUGH; |
546 | case SDLK_BACKSPACE: |
547 | if (m_->caret > 0) { |
548 | while ((m_->text[--m_->caret] & 0xc0) == 0x80) |
549 | @@ -232,7 +233,7 @@ |
550 | if (code.mod & KMOD_NUM) { |
551 | break; |
552 | } |
553 | - /* no break */ |
554 | + FALLS_THROUGH; |
555 | case SDLK_LEFT: |
556 | if (m_->caret > 0) { |
557 | while ((m_->text[--m_->caret] & 0xc0) == 0x80) { |
558 | @@ -250,7 +251,7 @@ |
559 | if (code.mod & KMOD_NUM) { |
560 | break; |
561 | } |
562 | - /* no break */ |
563 | + FALLS_THROUGH; |
564 | case SDLK_RIGHT: |
565 | if (m_->caret < m_->text.size()) { |
566 | while ((m_->text[++m_->caret] & 0xc0) == 0x80) { |
567 | @@ -270,7 +271,7 @@ |
568 | if (code.mod & KMOD_NUM) { |
569 | break; |
570 | } |
571 | - /* no break */ |
572 | + FALLS_THROUGH; |
573 | case SDLK_HOME: |
574 | if (m_->caret != 0) { |
575 | m_->caret = 0; |
576 | @@ -283,7 +284,7 @@ |
577 | if (code.mod & KMOD_NUM) { |
578 | break; |
579 | } |
580 | - /* no break */ |
581 | + FALLS_THROUGH; |
582 | case SDLK_END: |
583 | if (m_->caret != m_->text.size()) { |
584 | m_->caret = m_->text.size(); |
585 | @@ -295,7 +296,7 @@ |
586 | if (code.mod & KMOD_NUM) { |
587 | break; |
588 | } |
589 | - /* no break */ |
590 | + FALLS_THROUGH; |
591 | case SDLK_UP: |
592 | // Load entry from history if active and text is not empty |
593 | if (history_active_) { |
594 | @@ -313,7 +314,7 @@ |
595 | if (code.mod & KMOD_NUM) { |
596 | break; |
597 | } |
598 | - /* no break */ |
599 | + FALLS_THROUGH; |
600 | case SDLK_DOWN: |
601 | // Load entry from history if active and text is not equivalent to the current one |
602 | if (history_active_) { |
603 | |
604 | === modified file 'src/ui_basic/listselect.cc' |
605 | --- src/ui_basic/listselect.cc 2017-05-25 12:30:40 +0000 |
606 | +++ src/ui_basic/listselect.cc 2017-06-15 16:43:33 +0000 |
607 | @@ -509,9 +509,10 @@ |
608 | uint32_t selected_idx; |
609 | switch (code.sym) { |
610 | case SDLK_KP_2: |
611 | - if (code.mod & KMOD_NUM) |
612 | + if (code.mod & KMOD_NUM) { |
613 | break; |
614 | - /* no break */ |
615 | + } |
616 | + FALLS_THROUGH; |
617 | case SDLK_DOWN: |
618 | selected_idx = selection_index() + 1; |
619 | if (selected_idx < size()) |
620 | @@ -523,9 +524,10 @@ |
621 | } |
622 | return true; |
623 | case SDLK_KP_8: |
624 | - if (code.mod & KMOD_NUM) |
625 | + if (code.mod & KMOD_NUM) { |
626 | break; |
627 | - /* no break */ |
628 | + } |
629 | + FALLS_THROUGH; |
630 | case SDLK_UP: |
631 | selected_idx = selection_index(); |
632 | if (selected_idx > 0) |
633 | |
634 | === modified file 'src/ui_basic/multilineeditbox.cc' |
635 | --- src/ui_basic/multilineeditbox.cc 2017-05-14 04:38:39 +0000 |
636 | +++ src/ui_basic/multilineeditbox.cc 2017-06-15 16:43:33 +0000 |
637 | @@ -237,9 +237,10 @@ |
638 | // Let the panel handle the tab key |
639 | return get_parent()->handle_key(true, code); |
640 | case SDLK_KP_PERIOD: |
641 | - if (code.mod & KMOD_NUM) |
642 | + if (code.mod & KMOD_NUM) { |
643 | break; |
644 | - /* no break */ |
645 | + } |
646 | + FALLS_THROUGH; |
647 | case SDLK_DELETE: |
648 | if (d_->cursor_pos < d_->text.size()) { |
649 | d_->erase_bytes(d_->cursor_pos, d_->next_char(d_->cursor_pos)); |
650 | @@ -258,7 +259,7 @@ |
651 | if (code.mod & KMOD_NUM) { |
652 | break; |
653 | } |
654 | - /* no break */ |
655 | + FALLS_THROUGH; |
656 | case SDLK_LEFT: { |
657 | if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) { |
658 | uint32_t newpos = d_->prev_char(d_->cursor_pos); |
659 | @@ -281,7 +282,7 @@ |
660 | if (code.mod & KMOD_NUM) { |
661 | break; |
662 | } |
663 | - /* no break */ |
664 | + FALLS_THROUGH; |
665 | case SDLK_RIGHT: |
666 | if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) { |
667 | uint32_t newpos = d_->next_char(d_->cursor_pos); |
668 | @@ -299,7 +300,7 @@ |
669 | if (code.mod & KMOD_NUM) { |
670 | break; |
671 | } |
672 | - /* no break */ |
673 | + FALLS_THROUGH; |
674 | case SDLK_DOWN: |
675 | if (d_->cursor_pos < d_->text.size()) { |
676 | d_->refresh_ww(); |
677 | @@ -328,7 +329,7 @@ |
678 | if (code.mod & KMOD_NUM) { |
679 | break; |
680 | } |
681 | - /* no break */ |
682 | + FALLS_THROUGH; |
683 | case SDLK_UP: |
684 | if (d_->cursor_pos > 0) { |
685 | d_->refresh_ww(); |
686 | @@ -355,7 +356,7 @@ |
687 | if (code.mod & KMOD_NUM) { |
688 | break; |
689 | } |
690 | - /* no break */ |
691 | + FALLS_THROUGH; |
692 | case SDLK_HOME: |
693 | if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) { |
694 | d_->set_cursor_pos(0); |
695 | @@ -373,7 +374,7 @@ |
696 | if (code.mod & KMOD_NUM) { |
697 | break; |
698 | } |
699 | - /* no break */ |
700 | + FALLS_THROUGH; |
701 | case SDLK_END: |
702 | if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) { |
703 | d_->set_cursor_pos(d_->text.size()); |
704 | |
705 | === modified file 'src/ui_fsmenu/loadgame.cc' |
706 | --- src/ui_fsmenu/loadgame.cc 2017-05-14 06:01:19 +0000 |
707 | +++ src/ui_fsmenu/loadgame.cc 2017-06-15 16:43:33 +0000 |
708 | @@ -678,9 +678,10 @@ |
709 | |
710 | switch (code.sym) { |
711 | case SDLK_KP_PERIOD: |
712 | - if (code.mod & KMOD_NUM) |
713 | + if (code.mod & KMOD_NUM) { |
714 | break; |
715 | - /* no break */ |
716 | + } |
717 | + FALLS_THROUGH; |
718 | case SDLK_DELETE: |
719 | clicked_delete(); |
720 | return true; |
721 | |
722 | === modified file 'src/wui/buildingwindow.cc' |
723 | --- src/wui/buildingwindow.cc 2017-06-06 05:37:57 +0000 |
724 | +++ src/wui/buildingwindow.cc 2017-06-15 16:43:33 +0000 |
725 | @@ -78,7 +78,7 @@ |
726 | // The building is no more |
727 | case Widelands::NoteBuilding::Action::kStartWarp: |
728 | igbase()->add_wanted_building_window(building().get_position(), get_pos(), is_minimal()); |
729 | - // Fallthrough intended |
730 | + FALLS_THROUGH; |
731 | case Widelands::NoteBuilding::Action::kDeleted: |
732 | die(); |
733 | break; |
734 | |
735 | === modified file 'src/wui/game_summary.cc' |
736 | --- src/wui/game_summary.cc 2017-05-14 14:40:24 +0000 |
737 | +++ src/wui/game_summary.cc 2017-06-15 16:43:33 +0000 |
738 | @@ -28,6 +28,7 @@ |
739 | #include "logic/game.h" |
740 | #include "logic/game_controller.h" |
741 | #include "logic/player.h" |
742 | +#include "logic/player_end_result.h" |
743 | #include "logic/playersmanager.h" |
744 | #include "ui_basic/box.h" |
745 | #include "ui_basic/button.h" |
746 | @@ -143,7 +144,7 @@ |
747 | Widelands::PlayerEndStatus pes = players_status.at(i); |
748 | if (ipl && pes.player == ipl->player_number()) { |
749 | local_in_game = true; |
750 | - local_won = pes.result == Widelands::PlayerEndResult::PLAYER_WON; |
751 | + local_won = pes.result == Widelands::PlayerEndResult::kWon; |
752 | current_player_position = i; |
753 | } |
754 | Widelands::Player* p = game_.get_player(pes.player); |
755 | @@ -160,11 +161,11 @@ |
756 | // Status |
757 | std::string stat_str; |
758 | switch (pes.result) { |
759 | - case Widelands::PlayerEndResult::PLAYER_LOST: |
760 | + case Widelands::PlayerEndResult::kLost: |
761 | /** TRANSLATORS: This is shown in the game summary for the players who have lost. */ |
762 | stat_str = _("Lost"); |
763 | break; |
764 | - case Widelands::PlayerEndResult::PLAYER_WON: |
765 | + case Widelands::PlayerEndResult::kWon: |
766 | /** TRANSLATORS: This is shown in the game summary for the players who have won. */ |
767 | stat_str = _("Won"); |
768 | if (!single_won) { |
769 | @@ -173,11 +174,11 @@ |
770 | teawon_ = p->team_number(); |
771 | } |
772 | break; |
773 | - case Widelands::PlayerEndResult::PLAYER_RESIGNED: |
774 | + case Widelands::PlayerEndResult::kResigned: |
775 | /** TRANSLATORS: This is shown in the game summary for the players who have resigned. */ |
776 | stat_str = _("Resigned"); |
777 | break; |
778 | - case Widelands::PlayerEndResult::UNDEFINED: |
779 | + case Widelands::PlayerEndResult::kUndefined: |
780 | /** TRANSLATORS: This is shown in the game summary when we don't know */ |
781 | /** TRANSLATORS: if the player has lost or won. */ |
782 | stat_str = pgettext("player_won", "Unknown"); |
783 | |
784 | === modified file 'src/wui/interactive_base.cc' |
785 | --- src/wui/interactive_base.cc 2017-05-25 12:30:40 +0000 |
786 | +++ src/wui/interactive_base.cc 2017-06-15 16:43:33 +0000 |
787 | @@ -754,9 +754,10 @@ |
788 | if (down) { |
789 | switch (code.sym) { |
790 | case SDLK_KP_9: |
791 | - if (code.mod & KMOD_NUM) |
792 | + if (code.mod & KMOD_NUM) { |
793 | break; |
794 | - /* no break */ |
795 | + } |
796 | + FALLS_THROUGH; |
797 | case SDLK_PAGEUP: |
798 | if (upcast(Game, game, &egbase_)) { |
799 | if (GameController* const ctrl = game->game_controller()) { |
800 | @@ -774,9 +775,10 @@ |
801 | return true; |
802 | |
803 | case SDLK_KP_3: |
804 | - if (code.mod & KMOD_NUM) |
805 | + if (code.mod & KMOD_NUM) { |
806 | break; |
807 | - /* no break */ |
808 | + } |
809 | + FALLS_THROUGH; |
810 | case SDLK_PAGEDOWN: |
811 | if (upcast(Widelands::Game, game, &egbase_)) { |
812 | if (GameController* const ctrl = game->game_controller()) { |
813 | |
814 | === modified file 'src/wui/interactive_player.cc' |
815 | --- src/wui/interactive_player.cc 2017-02-22 20:23:49 +0000 |
816 | +++ src/wui/interactive_player.cc 2017-06-15 16:43:33 +0000 |
817 | @@ -272,7 +272,7 @@ |
818 | case SDLK_KP_7: |
819 | if (code.mod & KMOD_NUM) |
820 | break; |
821 | - /* no break */ |
822 | + FALLS_THROUGH; |
823 | case SDLK_HOME: |
824 | scroll_to_field(game().map().get_starting_pos(player_number_), Transition::Smooth); |
825 | return true; |
Continuous integration builds have changed state:
Travis build 2146. State: failed. Details: https:/ /travis- ci.org/ widelands/ widelands/ builds/ 228487468. /ci.appveyor. com/project/ widelands- dev/widelands/ build/_ widelands_ dev_widelands_ gcc7-1981.
Appveyor build 1981. State: success. Details: https:/