Merge lp:~widelands-dev/widelands/b19_gcc7 into lp:widelands/build19
- b19_gcc7
- Merge into b19
Proposed by
GunChleoc
Status: | Merged |
---|---|
Merged at revision: | 8149 |
Proposed branch: | lp:~widelands-dev/widelands/b19_gcc7 |
Merge into: | lp:widelands/build19 |
Diff against target: |
816 lines (+143/-88) 29 files modified
.travis.yml (+8/-16) CMakeLists.txt (+3/-2) src/CMakeLists.txt (+1/-0) src/base/macros.h (+10/-0) src/graphic/gl/fill_rect_program.cc (+3/-3) src/logic/CMakeLists.txt (+15/-5) 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/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 (+27/-0) src/logic/playersmanager.h (+1/-7) src/logic/single_player_game_controller.h (+1/-0) src/network/netclient.cc (+1/-2) src/network/netclient.h (+1/-0) src/network/nethost.cc (+4/-4) src/network/nethost.h (+1/-0) src/scripting/CMakeLists.txt (+1/-0) src/scripting/lua_game.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/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/b19_gcc7 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Widelands Developers | Pending | ||
Review via email: mp+325798@code.launchpad.net |
Commit message
Description of the change
Ported support for gcc7 from trunk.
This can go in as soon as Travis is clean.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.travis.yml' |
2 | --- .travis.yml 2016-10-09 09:36:13 +0000 |
3 | +++ .travis.yml 2017-06-17 14:22:37 +0000 |
4 | @@ -20,25 +20,17 @@ |
5 | - compiler: clang |
6 | env: CLANG_VERSION="3.5" BUILD_TYPE="Debug" |
7 | - compiler: clang |
8 | - env: CLANG_VERSION="3.6" BUILD_TYPE="Debug" |
9 | - - compiler: clang |
10 | - env: CLANG_VERSION="3.7" BUILD_TYPE="Debug" |
11 | - - compiler: clang |
12 | - env: CLANG_VERSION="3.8" BUILD_TYPE="Debug" |
13 | - - compiler: clang |
14 | env: CLANG_VERSION="3.9" BUILD_TYPE="Debug" |
15 | - compiler: clang |
16 | + env: CLANG_VERSION="4.0" BUILD_TYPE="Debug" |
17 | + - compiler: clang |
18 | env: CLANG_VERSION="3.4" BUILD_TYPE="Release" |
19 | - compiler: clang |
20 | env: CLANG_VERSION="3.5" BUILD_TYPE="Release" |
21 | - compiler: clang |
22 | - env: CLANG_VERSION="3.6" BUILD_TYPE="Release" |
23 | - - compiler: clang |
24 | - env: CLANG_VERSION="3.7" BUILD_TYPE="Release" |
25 | - - compiler: clang |
26 | - env: CLANG_VERSION="3.8" BUILD_TYPE="Release" |
27 | - - compiler: clang |
28 | env: CLANG_VERSION="3.9" BUILD_TYPE="Release" |
29 | + - compiler: clang |
30 | + env: CLANG_VERSION="4.0" BUILD_TYPE="Release" |
31 | - compiler: gcc |
32 | env: GCC_VERSION="4.7" BUILD_TYPE="Debug" |
33 | - compiler: gcc |
34 | @@ -46,16 +38,16 @@ |
35 | - compiler: gcc |
36 | env: GCC_VERSION="4.9" BUILD_TYPE="Debug" |
37 | - compiler: gcc |
38 | - env: GCC_VERSION="5" BUILD_TYPE="Debug" |
39 | - - compiler: gcc |
40 | env: GCC_VERSION="6" BUILD_TYPE="Debug" |
41 | - compiler: gcc |
42 | + env: GCC_VERSION="7" BUILD_TYPE="Debug" |
43 | + - compiler: gcc |
44 | env: GCC_VERSION="4.7" BUILD_TYPE="Release" |
45 | - compiler: gcc |
46 | env: GCC_VERSION="4.8" BUILD_TYPE="Release" |
47 | - compiler: gcc |
48 | env: GCC_VERSION="4.9" BUILD_TYPE="Release" |
49 | - compiler: gcc |
50 | - env: GCC_VERSION="5" BUILD_TYPE="Release" |
51 | - - compiler: gcc |
52 | env: GCC_VERSION="6" BUILD_TYPE="Release" |
53 | + - compiler: gcc |
54 | + env: GCC_VERSION="7" BUILD_TYPE="Release" |
55 | |
56 | === modified file 'CMakeLists.txt' |
57 | --- CMakeLists.txt 2016-09-04 07:54:45 +0000 |
58 | +++ CMakeLists.txt 2017-06-17 14:22:37 +0000 |
59 | @@ -116,7 +116,6 @@ |
60 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wno-padded") |
61 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wno-sign-conversion") |
62 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wno-missing-noreturn") |
63 | - wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wno-implicit-fallthrough") |
64 | |
65 | # TODO(sirver): weak-vtables should be enabled, but leads to lot of errors right now. |
66 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wno-weak-vtables") |
67 | @@ -132,6 +131,9 @@ |
68 | if(WIN32) |
69 | # This is needed for getenv(). |
70 | wl_add_flag(WL_GENERIC_CXX_FLAGS "-std=gnu++11") |
71 | + else() |
72 | + # 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. |
73 | + wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wredundant-decls") |
74 | endif() |
75 | |
76 | if (NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)) |
77 | @@ -167,7 +169,6 @@ |
78 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Woverlength-strings") |
79 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wpacked") |
80 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wpointer-arith") |
81 | - wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wredundant-decls") |
82 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wsign-promo") |
83 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wsync-nand") |
84 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wtrampolines") |
85 | |
86 | === modified file 'src/CMakeLists.txt' |
87 | --- src/CMakeLists.txt 2016-05-17 15:57:06 +0000 |
88 | +++ src/CMakeLists.txt 2017-06-17 14:22:37 +0000 |
89 | @@ -113,6 +113,7 @@ |
90 | logic |
91 | logic_game_controller |
92 | logic_game_settings |
93 | + logic_single_player_game_settings |
94 | map_io_map_loader |
95 | network |
96 | profile |
97 | |
98 | === modified file 'src/base/macros.h' |
99 | --- src/base/macros.h 2016-08-04 15:49:05 +0000 |
100 | +++ src/base/macros.h 2017-06-17 14:22:37 +0000 |
101 | @@ -67,6 +67,16 @@ |
102 | #define DIAG_OFF(x) GCC_DIAG_OFF(x) CLANG_DIAG_OFF(x) |
103 | #define DIAG_ON(x) GCC_DIAG_ON(x) CLANG_DIAG_ON(x) |
104 | |
105 | +// For switch statements: Tell gcc7 and clang that a fallthrough is intended |
106 | +// https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/ |
107 | +#ifdef __clang__ |
108 | +#define FALLS_THROUGH /* Falls through */ [[clang::fallthrough]] |
109 | +#elif __GNUC__ >= 7 |
110 | +#define FALLS_THROUGH /* Falls through */ [[gnu::fallthrough]] |
111 | +#else |
112 | +#define FALLS_THROUGH /* Falls through */ |
113 | +#endif |
114 | + |
115 | // disallow copying or assigning a class |
116 | #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ |
117 | TypeName(const TypeName&) = delete; \ |
118 | |
119 | === modified file 'src/graphic/gl/fill_rect_program.cc' |
120 | --- src/graphic/gl/fill_rect_program.cc 2016-08-04 15:49:05 +0000 |
121 | +++ src/graphic/gl/fill_rect_program.cc 2017-06-17 14:22:37 +0000 |
122 | @@ -21,7 +21,7 @@ |
123 | |
124 | #include <vector> |
125 | |
126 | -#include "base/log.h" |
127 | +#include "base/macros.h" |
128 | #include "base/wexception.h" |
129 | |
130 | // static |
131 | @@ -66,7 +66,7 @@ |
132 | switch (template_args.blend_mode) { |
133 | case BlendMode::Subtract: |
134 | glBlendEquation(GL_FUNC_REVERSE_SUBTRACT); |
135 | - /* fallthrough intended */ |
136 | + FALLS_THROUGH; |
137 | case BlendMode::UseAlpha: |
138 | glBlendFunc(GL_ONE, GL_ONE); |
139 | break; |
140 | @@ -132,7 +132,7 @@ |
141 | switch (template_args.blend_mode) { |
142 | case BlendMode::Subtract: |
143 | glBlendEquation(GL_FUNC_ADD); |
144 | - /* fallthrough intended */ |
145 | + FALLS_THROUGH; |
146 | case BlendMode::UseAlpha: |
147 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
148 | break; |
149 | |
150 | === modified file 'src/logic/CMakeLists.txt' |
151 | --- src/logic/CMakeLists.txt 2016-05-14 07:35:39 +0000 |
152 | +++ src/logic/CMakeLists.txt 2017-06-17 14:22:37 +0000 |
153 | @@ -4,19 +4,28 @@ |
154 | widelands_geometry.h |
155 | ) |
156 | |
157 | -wl_library(logic_game_settings |
158 | + wl_library(logic_game_settings |
159 | SRCS |
160 | + game_settings.cc |
161 | game_settings.h |
162 | + player_end_result.h |
163 | + DEPENDS |
164 | + io_filesystem |
165 | + logic |
166 | + scripting_lua_interface |
167 | + scripting_lua_table |
168 | +) |
169 | + |
170 | +wl_library(logic_single_player_game_settings |
171 | + SRCS |
172 | single_player_game_settings_provider.cc |
173 | single_player_game_settings_provider.h |
174 | DEPENDS |
175 | ai |
176 | base_exceptions |
177 | - io_filesystem |
178 | logic |
179 | - scripting_lua_interface |
180 | - scripting_lua_table |
181 | -) |
182 | + logic_game_settings |
183 | + ) |
184 | |
185 | wl_library(logic_game_controller |
186 | SRCS |
187 | @@ -28,6 +37,7 @@ |
188 | DEPENDS |
189 | ai |
190 | logic |
191 | + logic_game_settings |
192 | profile |
193 | ui_basic |
194 | widelands_ball_of_mud |
195 | |
196 | === modified file 'src/logic/game_controller.h' |
197 | --- src/logic/game_controller.h 2016-08-04 15:49:05 +0000 |
198 | +++ src/logic/game_controller.h 2017-06-17 14:22:37 +0000 |
199 | @@ -22,12 +22,12 @@ |
200 | |
201 | #include <string> |
202 | |
203 | +#include "logic/player_end_result.h" |
204 | #include "logic/widelands.h" |
205 | |
206 | namespace Widelands { |
207 | class Game; |
208 | class PlayerCommand; |
209 | -enum class PlayerEndResult : uint8_t; |
210 | } |
211 | |
212 | /** |
213 | |
214 | === added file 'src/logic/game_settings.cc' |
215 | --- src/logic/game_settings.cc 1970-01-01 00:00:00 +0000 |
216 | +++ src/logic/game_settings.cc 2017-06-17 14:22:37 +0000 |
217 | @@ -0,0 +1,1 @@ |
218 | +// Dummy to make CMake happy |
219 | |
220 | === modified file 'src/logic/game_settings.h' |
221 | --- src/logic/game_settings.h 2016-08-04 15:49:05 +0000 |
222 | +++ src/logic/game_settings.h 2017-06-17 14:22:37 +0000 |
223 | @@ -26,14 +26,11 @@ |
224 | |
225 | #include "io/filesystem/layered_filesystem.h" |
226 | #include "logic/map_objects/tribes/tribe_basic_info.h" |
227 | +#include "logic/player_end_result.h" |
228 | #include "logic/widelands.h" |
229 | #include "scripting/lua_interface.h" |
230 | #include "scripting/lua_table.h" |
231 | |
232 | -namespace Widelands { |
233 | -enum class PlayerEndResult : uint8_t; |
234 | -} |
235 | - |
236 | struct PlayerSettings { |
237 | enum State { stateOpen, stateHuman, stateComputer, stateClosed, stateShared }; |
238 | |
239 | @@ -60,6 +57,12 @@ |
240 | return not_connected() - 1; |
241 | } |
242 | |
243 | + UserSettings(Widelands::PlayerEndResult init_result, bool init_ready) |
244 | + : position(0), name(""), result(init_result), win_condition_string(""), ready(init_ready) { |
245 | + } |
246 | + UserSettings() : UserSettings(Widelands::PlayerEndResult::kUndefined, false) { |
247 | + } |
248 | + |
249 | uint8_t position; |
250 | std::string name; |
251 | Widelands::PlayerEndResult result; |
252 | |
253 | === modified file 'src/logic/map_objects/immovable.cc' |
254 | --- src/logic/map_objects/immovable.cc 2016-08-04 15:49:05 +0000 |
255 | +++ src/logic/map_objects/immovable.cc 2017-06-17 14:22:37 +0000 |
256 | @@ -947,7 +947,7 @@ |
257 | probability = value; |
258 | // fallthrough |
259 | } |
260 | - /* no break */ |
261 | + FALLS_THROUGH; |
262 | case '\0': |
263 | goto end; |
264 | default: |
265 | |
266 | === modified file 'src/logic/map_objects/tribes/production_program.cc' |
267 | --- src/logic/map_objects/tribes/production_program.cc 2016-09-10 16:50:51 +0000 |
268 | +++ src/logic/map_objects/tribes/production_program.cc 2017-06-17 14:22:37 +0000 |
269 | @@ -245,9 +245,8 @@ |
270 | "the specified ware type(s) is only %u, so the group can " |
271 | "never be fulfilled by the site", |
272 | count, count_max); |
273 | - // fallthrough |
274 | } |
275 | - /* no break */ |
276 | + FALLS_THROUGH; |
277 | case '\0': |
278 | case ' ': |
279 | group.second = count; |
280 | |
281 | === modified file 'src/logic/map_objects/tribes/ship.cc' |
282 | --- src/logic/map_objects/tribes/ship.cc 2016-09-07 09:30:49 +0000 |
283 | +++ src/logic/map_objects/tribes/ship.cc 2017-06-17 14:22:37 +0000 |
284 | @@ -274,14 +274,13 @@ |
285 | return; |
286 | } |
287 | log("Oh no... this ship has no sinking animation :(!\n"); |
288 | - // fall trough |
289 | + FALLS_THROUGH; |
290 | case ShipStates::kSinkAnimation: |
291 | // The sink animation has been played, so finally remove the ship from the map |
292 | pop_task(game); |
293 | remove(game); |
294 | return; |
295 | } |
296 | - |
297 | // if the real update function failed (e.g. nothing to transport), the ship goes idle |
298 | ship_update_idle(game, state); |
299 | } |
300 | @@ -685,7 +684,7 @@ |
301 | return start_task_idle(game, descr().main_animation(), 1500); |
302 | } |
303 | } |
304 | - |
305 | + FALLS_THROUGH; |
306 | case ShipStates::kExpeditionWaiting: |
307 | case ShipStates::kExpeditionPortspaceFound: |
308 | case ShipStates::kSinkRequest: |
309 | |
310 | === modified file 'src/logic/mapfringeregion.cc' |
311 | --- src/logic/mapfringeregion.cc 2016-08-04 15:49:05 +0000 |
312 | +++ src/logic/mapfringeregion.cc 2017-06-17 14:22:37 +0000 |
313 | @@ -29,9 +29,11 @@ |
314 | if (area_.radius) { |
315 | remaining_in_phase_ = area_.radius; |
316 | phase_ = 6; |
317 | - } else |
318 | + // Fallthrough |
319 | + } else { |
320 | return false; |
321 | - /* no break */ |
322 | + } |
323 | + FALLS_THROUGH; |
324 | case 1: |
325 | map.get_trn(area_, &area_); |
326 | break; |
327 | @@ -53,6 +55,7 @@ |
328 | default: |
329 | NEVER_HERE(); |
330 | } |
331 | + |
332 | if (--remaining_in_phase_ == 0) { |
333 | remaining_in_phase_ = area_.radius; |
334 | --phase_; |
335 | @@ -66,9 +69,11 @@ |
336 | if (area_.radius) { |
337 | remaining_in_phase_ = area_.radius; |
338 | phase_ = 6; |
339 | - } else |
340 | + // Fallthrough |
341 | + } else { |
342 | return false; |
343 | - /* no break */ |
344 | + } |
345 | + FALLS_THROUGH; |
346 | case 1: |
347 | map.get_trn(area_, &area_); |
348 | break; |
349 | @@ -90,6 +95,7 @@ |
350 | default: |
351 | NEVER_HERE(); |
352 | } |
353 | + |
354 | if (--remaining_in_phase_ == 0) { |
355 | remaining_in_phase_ = area_.radius; |
356 | --phase_; |
357 | |
358 | === added file 'src/logic/player_end_result.h' |
359 | --- src/logic/player_end_result.h 1970-01-01 00:00:00 +0000 |
360 | +++ src/logic/player_end_result.h 2017-06-17 14:22:37 +0000 |
361 | @@ -0,0 +1,27 @@ |
362 | +/* |
363 | + * Copyright (C) 2008-2017 by the Widelands Development Team |
364 | + * |
365 | + * This program is free software; you can redistribute it and/or |
366 | + * modify it under the terms of the GNU General Public License |
367 | + * as published by the Free Software Foundation; either version 2 |
368 | + * of the License, or (at your option) any later version. |
369 | + * |
370 | + * This program is distributed in the hope that it will be useful, |
371 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
372 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
373 | + * GNU General Public License for more details. |
374 | + * |
375 | + * You should have received a copy of the GNU General Public License |
376 | + * along with this program; if not, write to the Free Software |
377 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
378 | + * |
379 | + */ |
380 | + |
381 | +#ifndef WL_LOGIC_PLAYER_END_RESULT_H |
382 | +#define WL_LOGIC_PLAYER_END_RESULT_H |
383 | + |
384 | +namespace Widelands { |
385 | +enum class PlayerEndResult : uint8_t { kLost = 0, kWon = 1, kResigned = 2, kUndefined = 255 }; |
386 | +} |
387 | + |
388 | +#endif // end of include guard: WL_LOGIC_PLAYER_END_RESULT_H |
389 | |
390 | === modified file 'src/logic/playersmanager.h' |
391 | --- src/logic/playersmanager.h 2016-08-04 15:49:05 +0000 |
392 | +++ src/logic/playersmanager.h 2017-06-17 14:22:37 +0000 |
393 | @@ -24,6 +24,7 @@ |
394 | #include <vector> |
395 | |
396 | #include "logic/constants.h" |
397 | +#include "logic/player_end_result.h" |
398 | #include "logic/widelands.h" |
399 | |
400 | namespace Widelands { |
401 | @@ -32,13 +33,6 @@ |
402 | class Player; |
403 | class Player; |
404 | |
405 | -enum class PlayerEndResult : uint8_t { |
406 | - PLAYER_LOST = 0, |
407 | - PLAYER_WON = 1, |
408 | - PLAYER_RESIGNED = 2, |
409 | - UNDEFINED = 255 |
410 | -}; |
411 | - |
412 | /** |
413 | * Hold data once a player left the game, or on game ends. |
414 | * Allowed values for the info string, as key=value pairs separated |
415 | |
416 | === modified file 'src/logic/single_player_game_controller.h' |
417 | --- src/logic/single_player_game_controller.h 2016-08-04 15:49:05 +0000 |
418 | +++ src/logic/single_player_game_controller.h 2017-06-17 14:22:37 +0000 |
419 | @@ -22,6 +22,7 @@ |
420 | |
421 | #include "ai/computer_player.h" |
422 | #include "logic/game_controller.h" |
423 | +#include "logic/player_end_result.h" |
424 | |
425 | class SinglePlayerGameController : public GameController { |
426 | public: |
427 | |
428 | === modified file 'src/network/netclient.cc' |
429 | --- src/network/netclient.cc 2016-08-04 15:49:05 +0000 |
430 | +++ src/network/netclient.cc 2017-06-17 14:22:37 +0000 |
431 | @@ -476,8 +476,7 @@ |
432 | |
433 | // This might happen, if a users connects after the game starts. |
434 | if (number == d->settings.users.size()) { |
435 | - UserSettings newuser; |
436 | - d->settings.users.push_back(newuser); |
437 | + d->settings.users.push_back(*new UserSettings()); |
438 | } |
439 | |
440 | d->settings.users.at(number).name = packet.string(); |
441 | |
442 | === modified file 'src/network/netclient.h' |
443 | --- src/network/netclient.h 2016-08-04 15:49:05 +0000 |
444 | +++ src/network/netclient.h 2017-06-17 14:22:37 +0000 |
445 | @@ -23,6 +23,7 @@ |
446 | #include "chat/chat.h" |
447 | #include "logic/game_controller.h" |
448 | #include "logic/game_settings.h" |
449 | +#include "logic/player_end_result.h" |
450 | #include "network/network.h" |
451 | |
452 | struct NetClientImpl; |
453 | |
454 | === modified file 'src/network/nethost.cc' |
455 | --- src/network/nethost.cc 2016-09-22 17:40:14 +0000 |
456 | +++ src/network/nethost.cc 2017-06-17 14:22:37 +0000 |
457 | @@ -143,7 +143,7 @@ |
458 | newstate = PlayerSettings::stateClosed; |
459 | break; |
460 | } // else fall through |
461 | - /* no break */ |
462 | + FALLS_THROUGH; |
463 | case PlayerSettings::stateComputer: { |
464 | const ComputerPlayer::ImplementationVector& impls = ComputerPlayer::get_implementations(); |
465 | ComputerPlayer::ImplementationVector::const_iterator it = impls.begin(); |
466 | @@ -1605,14 +1605,14 @@ |
467 | for (uint32_t i = 0; i < d->settings.users.size(); ++i) |
468 | if (d->settings.users[i].position == UserSettings::not_connected()) { |
469 | client.usernum = i; |
470 | - d->settings.users[i].result = Widelands::PlayerEndResult::UNDEFINED; |
471 | + d->settings.users[i].result = Widelands::PlayerEndResult::kUndefined; |
472 | d->settings.users[i].ready = true; |
473 | break; |
474 | } |
475 | if (client.usernum == -1) { |
476 | client.usernum = d->settings.users.size(); |
477 | UserSettings newuser; |
478 | - newuser.result = Widelands::PlayerEndResult::UNDEFINED; |
479 | + newuser.result = Widelands::PlayerEndResult::kUndefined; |
480 | newuser.ready = true; |
481 | d->settings.users.push_back(newuser); |
482 | } |
483 | @@ -2404,7 +2404,7 @@ |
484 | if (user.position == p_nr - 1) { |
485 | user.result = result; |
486 | user.win_condition_string = info; |
487 | - if (result == Widelands::PlayerEndResult::PLAYER_LOST) { |
488 | + if (result == Widelands::PlayerEndResult::kLost) { |
489 | send_system_message_code("PLAYER_DEFEATED", user.name); |
490 | } |
491 | } |
492 | |
493 | === modified file 'src/network/nethost.h' |
494 | --- src/network/nethost.h 2016-08-04 15:49:05 +0000 |
495 | +++ src/network/nethost.h 2017-06-17 14:22:37 +0000 |
496 | @@ -22,6 +22,7 @@ |
497 | |
498 | #include "logic/game_controller.h" |
499 | #include "logic/game_settings.h" |
500 | +#include "logic/player_end_result.h" |
501 | #include "logic/widelands.h" |
502 | #include "network/network.h" |
503 | |
504 | |
505 | === modified file 'src/scripting/CMakeLists.txt' |
506 | --- src/scripting/CMakeLists.txt 2016-01-18 19:35:25 +0000 |
507 | +++ src/scripting/CMakeLists.txt 2017-06-17 14:22:37 +0000 |
508 | @@ -110,6 +110,7 @@ |
509 | logic |
510 | logic_campaign_visibility |
511 | logic_game_controller |
512 | + logic_game_settings |
513 | logic_widelands_geometry |
514 | map_io |
515 | scripting_base |
516 | |
517 | === modified file 'src/scripting/lua_game.cc' |
518 | --- src/scripting/lua_game.cc 2016-08-07 20:39:44 +0000 |
519 | +++ src/scripting/lua_game.cc 2017-06-17 14:22:37 +0000 |
520 | @@ -33,6 +33,7 @@ |
521 | #include "logic/objective.h" |
522 | #include "logic/path.h" |
523 | #include "logic/player.h" |
524 | +#include "logic/player_end_result.h" |
525 | #include "logic/playersmanager.h" |
526 | #include "scripting/globals.h" |
527 | #include "scripting/lua_interface.h" |
528 | |
529 | === modified file 'src/ui_basic/editbox.cc' |
530 | --- src/ui_basic/editbox.cc 2016-08-07 08:18:51 +0000 |
531 | +++ src/ui_basic/editbox.cc 2017-06-17 14:22:37 +0000 |
532 | @@ -219,15 +219,16 @@ |
533 | if (code.mod & KMOD_NUM) { |
534 | break; |
535 | } |
536 | - /* no break */ |
537 | + FALLS_THROUGH; |
538 | case SDLK_DELETE: |
539 | if (m_->caret < m_->text.size()) { |
540 | while ((m_->text[++m_->caret] & 0xc0) == 0x80) { |
541 | }; |
542 | - // now handle it like Backspace |
543 | - } else |
544 | + // Now fallthrough to handle it like Backspace |
545 | + } else { |
546 | return true; |
547 | - /* no break */ |
548 | + } |
549 | + FALLS_THROUGH; |
550 | case SDLK_BACKSPACE: |
551 | if (m_->caret > 0) { |
552 | while ((m_->text[--m_->caret] & 0xc0) == 0x80) |
553 | @@ -242,7 +243,7 @@ |
554 | if (code.mod & KMOD_NUM) { |
555 | break; |
556 | } |
557 | - /* no break */ |
558 | + FALLS_THROUGH; |
559 | case SDLK_LEFT: |
560 | if (m_->caret > 0) { |
561 | while ((m_->text[--m_->caret] & 0xc0) == 0x80) { |
562 | @@ -260,7 +261,7 @@ |
563 | if (code.mod & KMOD_NUM) { |
564 | break; |
565 | } |
566 | - /* no break */ |
567 | + FALLS_THROUGH; |
568 | case SDLK_RIGHT: |
569 | if (m_->caret < m_->text.size()) { |
570 | while ((m_->text[++m_->caret] & 0xc0) == 0x80) { |
571 | @@ -280,7 +281,7 @@ |
572 | if (code.mod & KMOD_NUM) { |
573 | break; |
574 | } |
575 | - /* no break */ |
576 | + FALLS_THROUGH; |
577 | case SDLK_HOME: |
578 | if (m_->caret != 0) { |
579 | m_->caret = 0; |
580 | @@ -293,7 +294,7 @@ |
581 | if (code.mod & KMOD_NUM) { |
582 | break; |
583 | } |
584 | - /* no break */ |
585 | + FALLS_THROUGH; |
586 | case SDLK_END: |
587 | if (m_->caret != m_->text.size()) { |
588 | m_->caret = m_->text.size(); |
589 | @@ -305,7 +306,7 @@ |
590 | if (code.mod & KMOD_NUM) { |
591 | break; |
592 | } |
593 | - /* no break */ |
594 | + FALLS_THROUGH; |
595 | case SDLK_UP: |
596 | // Load entry from history if active and text is not empty |
597 | if (history_active_) { |
598 | @@ -323,7 +324,7 @@ |
599 | if (code.mod & KMOD_NUM) { |
600 | break; |
601 | } |
602 | - /* no break */ |
603 | + FALLS_THROUGH; |
604 | case SDLK_DOWN: |
605 | // Load entry from history if active and text is not equivalent to the current one |
606 | if (history_active_) { |
607 | |
608 | === modified file 'src/ui_basic/listselect.cc' |
609 | --- src/ui_basic/listselect.cc 2016-08-04 15:49:05 +0000 |
610 | +++ src/ui_basic/listselect.cc 2017-06-17 14:22:37 +0000 |
611 | @@ -454,9 +454,10 @@ |
612 | uint32_t selected_idx; |
613 | switch (code.sym) { |
614 | case SDLK_KP_2: |
615 | - if (code.mod & KMOD_NUM) |
616 | + if (code.mod & KMOD_NUM) { |
617 | break; |
618 | - /* no break */ |
619 | + } |
620 | + FALLS_THROUGH; |
621 | case SDLK_DOWN: |
622 | selected_idx = selection_index() + 1; |
623 | if (selected_idx < size()) |
624 | @@ -468,9 +469,10 @@ |
625 | } |
626 | return true; |
627 | case SDLK_KP_8: |
628 | - if (code.mod & KMOD_NUM) |
629 | + if (code.mod & KMOD_NUM) { |
630 | break; |
631 | - /* no break */ |
632 | + } |
633 | + FALLS_THROUGH; |
634 | case SDLK_UP: |
635 | selected_idx = selection_index(); |
636 | if (selected_idx > 0) |
637 | |
638 | === modified file 'src/ui_basic/multilineeditbox.cc' |
639 | --- src/ui_basic/multilineeditbox.cc 2016-08-07 10:10:18 +0000 |
640 | +++ src/ui_basic/multilineeditbox.cc 2017-06-17 14:22:37 +0000 |
641 | @@ -235,9 +235,10 @@ |
642 | // Let the panel handle the tab key |
643 | return get_parent()->handle_key(true, code); |
644 | case SDLK_KP_PERIOD: |
645 | - if (code.mod & KMOD_NUM) |
646 | + if (code.mod & KMOD_NUM) { |
647 | break; |
648 | - /* no break */ |
649 | + } |
650 | + FALLS_THROUGH; |
651 | case SDLK_DELETE: |
652 | if (d_->cursor_pos < d_->text.size()) { |
653 | d_->erase_bytes(d_->cursor_pos, d_->next_char(d_->cursor_pos)); |
654 | @@ -256,7 +257,7 @@ |
655 | if (code.mod & KMOD_NUM) { |
656 | break; |
657 | } |
658 | - /* no break */ |
659 | + FALLS_THROUGH; |
660 | case SDLK_LEFT: { |
661 | if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) { |
662 | uint32_t newpos = d_->prev_char(d_->cursor_pos); |
663 | @@ -279,7 +280,7 @@ |
664 | if (code.mod & KMOD_NUM) { |
665 | break; |
666 | } |
667 | - /* no break */ |
668 | + FALLS_THROUGH; |
669 | case SDLK_RIGHT: |
670 | if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) { |
671 | uint32_t newpos = d_->next_char(d_->cursor_pos); |
672 | @@ -297,7 +298,7 @@ |
673 | if (code.mod & KMOD_NUM) { |
674 | break; |
675 | } |
676 | - /* no break */ |
677 | + FALLS_THROUGH; |
678 | case SDLK_DOWN: |
679 | if (d_->cursor_pos < d_->text.size()) { |
680 | d_->refresh_ww(); |
681 | @@ -326,7 +327,7 @@ |
682 | if (code.mod & KMOD_NUM) { |
683 | break; |
684 | } |
685 | - /* no break */ |
686 | + FALLS_THROUGH; |
687 | case SDLK_UP: |
688 | if (d_->cursor_pos > 0) { |
689 | d_->refresh_ww(); |
690 | @@ -353,7 +354,7 @@ |
691 | if (code.mod & KMOD_NUM) { |
692 | break; |
693 | } |
694 | - /* no break */ |
695 | + FALLS_THROUGH; |
696 | case SDLK_HOME: |
697 | if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) { |
698 | d_->set_cursor_pos(0); |
699 | @@ -371,7 +372,7 @@ |
700 | if (code.mod & KMOD_NUM) { |
701 | break; |
702 | } |
703 | - /* no break */ |
704 | + FALLS_THROUGH; |
705 | case SDLK_END: |
706 | if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) { |
707 | d_->set_cursor_pos(d_->text.size()); |
708 | |
709 | === modified file 'src/ui_fsmenu/loadgame.cc' |
710 | --- src/ui_fsmenu/loadgame.cc 2016-09-25 12:27:22 +0000 |
711 | +++ src/ui_fsmenu/loadgame.cc 2017-06-17 14:22:37 +0000 |
712 | @@ -631,9 +631,10 @@ |
713 | |
714 | switch (code.sym) { |
715 | case SDLK_KP_PERIOD: |
716 | - if (code.mod & KMOD_NUM) |
717 | + if (code.mod & KMOD_NUM) { |
718 | break; |
719 | - /* no break */ |
720 | + } |
721 | + FALLS_THROUGH; |
722 | case SDLK_DELETE: |
723 | clicked_delete(); |
724 | return true; |
725 | |
726 | === modified file 'src/wui/game_summary.cc' |
727 | --- src/wui/game_summary.cc 2016-08-04 15:49:05 +0000 |
728 | +++ src/wui/game_summary.cc 2017-06-17 14:22:37 +0000 |
729 | @@ -26,6 +26,7 @@ |
730 | #include "graphic/graphic.h" |
731 | #include "logic/game.h" |
732 | #include "logic/player.h" |
733 | +#include "logic/player_end_result.h" |
734 | #include "logic/playersmanager.h" |
735 | #include "ui_basic/box.h" |
736 | #include "ui_basic/button.h" |
737 | @@ -147,7 +148,7 @@ |
738 | Widelands::PlayerEndStatus pes = players_status.at(i); |
739 | if (ipl && pes.player == ipl->player_number()) { |
740 | local_in_game = true; |
741 | - local_won = pes.result == Widelands::PlayerEndResult::PLAYER_WON; |
742 | + local_won = pes.result == Widelands::PlayerEndResult::kWon; |
743 | current_player_position = i; |
744 | } |
745 | Widelands::Player* p = game_.get_player(pes.player); |
746 | @@ -163,11 +164,11 @@ |
747 | // Status |
748 | std::string stat_str; |
749 | switch (pes.result) { |
750 | - case Widelands::PlayerEndResult::PLAYER_LOST: |
751 | + case Widelands::PlayerEndResult::kLost: |
752 | /** TRANSLATORS: This is shown in the game summary for the players who have lost. */ |
753 | stat_str = _("Lost"); |
754 | break; |
755 | - case Widelands::PlayerEndResult::PLAYER_WON: |
756 | + case Widelands::PlayerEndResult::kWon: |
757 | /** TRANSLATORS: This is shown in the game summary for the players who have won. */ |
758 | stat_str = _("Won"); |
759 | if (!single_won) { |
760 | @@ -176,11 +177,11 @@ |
761 | teawon_ = p->team_number(); |
762 | } |
763 | break; |
764 | - case Widelands::PlayerEndResult::PLAYER_RESIGNED: |
765 | + case Widelands::PlayerEndResult::kResigned: |
766 | /** TRANSLATORS: This is shown in the game summary for the players who have resigned. */ |
767 | stat_str = _("Resigned"); |
768 | break; |
769 | - case Widelands::PlayerEndResult::UNDEFINED: |
770 | + case Widelands::PlayerEndResult::kUndefined: |
771 | /** TRANSLATORS: This is shown in the game summary when we don't know */ |
772 | /** TRANSLATORS: if the player has lost or won. */ |
773 | stat_str = pgettext("player_won", "Unknown"); |
774 | |
775 | === modified file 'src/wui/interactive_base.cc' |
776 | --- src/wui/interactive_base.cc 2016-09-25 16:45:37 +0000 |
777 | +++ src/wui/interactive_base.cc 2017-06-17 14:22:37 +0000 |
778 | @@ -774,9 +774,10 @@ |
779 | if (down) { |
780 | switch (code.sym) { |
781 | case SDLK_KP_9: |
782 | - if (code.mod & KMOD_NUM) |
783 | + if (code.mod & KMOD_NUM) { |
784 | break; |
785 | - /* no break */ |
786 | + } |
787 | + FALLS_THROUGH; |
788 | case SDLK_PAGEUP: |
789 | if (upcast(Game, game, &egbase_)) { |
790 | if (GameController* const ctrl = game->game_controller()) { |
791 | @@ -794,9 +795,10 @@ |
792 | return true; |
793 | |
794 | case SDLK_KP_3: |
795 | - if (code.mod & KMOD_NUM) |
796 | + if (code.mod & KMOD_NUM) { |
797 | break; |
798 | - /* no break */ |
799 | + } |
800 | + FALLS_THROUGH; |
801 | case SDLK_PAGEDOWN: |
802 | if (upcast(Widelands::Game, game, &egbase_)) { |
803 | if (GameController* const ctrl = game->game_controller()) { |
804 | |
805 | === modified file 'src/wui/interactive_player.cc' |
806 | --- src/wui/interactive_player.cc 2016-08-04 15:49:05 +0000 |
807 | +++ src/wui/interactive_player.cc 2017-06-17 14:22:37 +0000 |
808 | @@ -320,7 +320,7 @@ |
809 | case SDLK_KP_7: |
810 | if (code.mod & KMOD_NUM) |
811 | break; |
812 | - /* no break */ |
813 | + FALLS_THROUGH; |
814 | case SDLK_HOME: |
815 | move_view_to(game().map().get_starting_pos(player_number_)); |
816 | return true; |