Merge lp:~ab-tools/widelands/msvs2010-compilewarnings into lp:widelands

Proposed by Andreas Breitschopp on 2012-06-12
Status: Rejected
Rejected by: SirVer on 2013-07-15
Proposed branch: lp:~ab-tools/widelands/msvs2010-compilewarnings
Merge into: lp:widelands
Diff against target: 1463 lines (+254/-202)
55 files modified
CMakeLists.txt (+1/-1)
src/ai/ai_hints.cc (+2/-2)
src/ai/defaultai.cc (+1/-1)
src/editor/editorinteractive.cc (+1/-1)
src/editor/ui_menus/editor_main_menu_random_map.cc (+2/-2)
src/graphic/animation.cc (+1/-1)
src/graphic/graphic.cc (+5/-5)
src/graphic/render/gameview.cc (+1/-1)
src/graphic/render/gl_picture_texture.cc (+4/-4)
src/graphic/render/gl_surface_screen.cc (+20/-20)
src/graphic/render/render_sdl.cc (+10/-2)
src/graphic/render/terrain_opengl.h (+72/-45)
src/graphic/render/terrain_sdl.cc (+1/-1)
src/graphic/rendertarget.cc (+1/-1)
src/graphic/texture.cc (+1/-1)
src/i18n.cc (+1/-1)
src/io/filesystem/disk_filesystem.cc (+1/-1)
src/io/filesystem/filesystem.cc (+1/-1)
src/journal.h (+1/-1)
src/logic/cmd_luascript.cc (+1/-1)
src/logic/game.cc (+1/-1)
src/logic/immovable.cc (+4/-4)
src/logic/military_data.cc (+2/-2)
src/logic/production_program.cc (+12/-12)
src/logic/soldier.cc (+4/-4)
src/logic/soldier.h (+1/-0)
src/logic/world.cc (+1/-1)
src/map_generator.cc (+22/-20)
src/map_io/widelands_map_resources_data_packet.cc (+1/-1)
src/network/internet_gaming.cc (+6/-6)
src/network/nethost.cc (+4/-4)
src/profile/profile.cc (+15/-12)
src/scripting/lua_map.cc (+1/-1)
src/sound/sound_handler.cc (+1/-1)
src/text_parser.cc (+5/-1)
src/ui_basic/checkbox.cc (+2/-1)
src/ui_basic/editbox.cc (+1/-1)
src/ui_basic/multilinetextarea.cc (+1/-1)
src/ui_basic/panel.cc (+2/-2)
src/ui_basic/panel.h (+1/-1)
src/ui_basic/progressbar.cc (+1/-1)
src/ui_basic/scrollbar.cc (+2/-2)
src/ui_fsmenu/internet_lobby.cc (+1/-1)
src/ui_fsmenu/loadgame.cc (+1/-1)
src/utf8.h (+1/-1)
src/wlapplication.cc (+2/-2)
src/wui/chatoverlay.cc (+1/-1)
src/wui/differential_plot_area.cc (+13/-7)
src/wui/general_statistics_menu.h (+1/-1)
src/wui/interactive_base.cc (+3/-3)
src/wui/mapviewpixelfunctions.cc (+2/-2)
src/wui/multiplayersetupgroup.cc (+1/-1)
src/wui/plot_area.cc (+8/-8)
src/wui/waresqueuedisplay.cc (+1/-1)
src/wui/watchwindow.cc (+1/-1)
To merge this branch: bzr merge lp:~ab-tools/widelands/msvs2010-compilewarnings
Reviewer Review Type Date Requested Status
SirVer 2012-06-12 Needs Fixing on 2012-06-12
Review via email: mp+109787@code.launchpad.net

Description of the change

After fixing the MSVS 2010 compiler errors in my last merge request, I've now looked at the compiler warnings.

Beside very few places where I think that the type of a variable was really chosen inappropriately, in most of the cases I just made a typecasting explicit to fix the compiler warning.

Of course, explicit typecasting makes the source code cleaner, but not really shorter or easier to read. Therefore I don't know if all developers wants this to be fixed although in my opinion explicit typecasting would really be much cleaner. What you think about that?

Anyway, it would be important that an experienced developer takes a look at my changes (to be sure I didn't make a mistake somewhere) and also tries to compile it on Linux. I've only tested it on Windows where it compiled and ran without any problems.

To post a comment you must log in.
Peter Waller (peter.waller) wrote :

You make a casts to float for a lot of gl...f() (e.g. glVertex2f(static_cast<float>(integer))) functions, when you could instead use the gl...i (integer) functions and not require the cast.

Andreas Breitschopp (ab-tools) wrote :

Hello Peter,

first thanks for your comment!

Yes, I thought the same and tried to use the "gl...i" functions instead, but as a result the OpenGL rendering did not work anymore correctly (the whole menu turned black after doing this change and trying to switch to OpenGL rendering mode).

I have to admit that I'm not familiar with the whole rendering staff, so I don't know why that's the case (maybe calculation precision issues when using the integer functions?), but it was what I experienced when running Widelands on Windows.

Maybe someone else can explain why that's the case or you can also test it on Linux if it works for you if you use the integer functions instead.

SirVer (sirver) wrote :

I get a some compiler errors concerning _strdup. It is not defined on my system.

I am not too fond with the arbitrary type casting all around. The proper fix would be to track down where the wrong types are used and fixing this throughout the code. If a type is necessary it should only be done exactly once. I feel uneasy just casting around to shut up the compiler like that.

review: Needs Fixing
Jari Hautio (jarih) wrote :

_strdup is vs2010 way of saying that it's not strictly ansi c standard function. In similar cases I have silenced the compiler by a compiler specific define in top level CMakeLists.txt.

Andreas Breitschopp (ab-tools) wrote :

That's OK, then I'll revert the "underscore" function name changes and add a Compile directive to the CMake file.

Regarding the typecasting, I'll check if there are possibilities to use better fitting variable types to reduce typecasting.

Hans Joachim Desserud (hjd) wrote :

Hi, thanks for taking your time working on eliminating warnings and improving code quality.

Since this merge request was filed, a lot of things have changed in the code, including plenty of warnings reported by GCC and Clang have been addressed. Effectively, this means that applying these changes might trigger conflicts and that some of the warnings might already have been addressed.

Don't get me wrong though, since every compiler is implemented differently, they likely report different amounts and types of warnings. So while fixing warnings in GCC/Clang may also have improved the situation in VS, we would still like any warnings only found in VS to be fixed. I would be really happy if WL could compile warning-free in the various compilers we use.

Could you please take a look at how the current trunk looks in Visual Studio and or see what happens if you attempt to merge latest trunk into this branch. I fear you are going to run into conflicts when attempting the latter though.

Andreas Breitschopp (ab-tools) wrote :

First thanks for your reply, Hans!

I retested now to compile the very latest BZR version (without any changes) under Windows, but there is no chance right now due to a lot of new compile errors (not warnings).

The most errors are referring to a "Syntax error: '('" in these two lines:
- "panel.h": line 250: void do_draw(RenderTarget &) __attribute__((hot));
- "button.h": line 72: void draw(RenderTarget &)__attribute__((hot));

Any ideas on that?

Best regards
Andreas

Hans Joachim Desserud (hjd) wrote :

Sorry, I only know basic c++, so I'm not the right person to answer that. :P

This obviously needs to be sorted out before we can proceed with the warnings though. Could you file a bug report on this and tag it 'regression'?

Andreas Breitschopp (ab-tools) wrote :

Same for me as I'm more on the C# (.NET) side normally. ;-)

Therefore I've created a bug report now as you suggested:
https://bugs.launchpad.net/widelands/+bug/1142781

Hans Joachim Desserud (hjd) wrote :

Sorry for not following up on this before now, but now that bug 1142781 is fixed, what is the current status on warnings in VS?

Andreas Breitschopp (ab-tools) wrote :

To be honest I didn't test it again for quite a long time and there were a lot of changes in the code since then.

But I'll give it a try again. I think I should find some time for a new compilation test on Windows this weekend and post some feedback afterwards.

Andreas Breitschopp (ab-tools) wrote :

I've done a new compiling test on Windows (using Visual Studio 2010). Compilation worked, but again with a lot of warnings.

These two warnings were thrown already by CMake:
http://www.ab-tools.com/temp/Widelands-CMakeWarnings.txt
These probably can be fixed easily by adding an if clause around the lines "set (PARAMETER_COMPILERFLAG_EXTRAWARNINGS*" and "set (PARAMETER_COMPILERFLAG_GCCWARNINGS*" in the "CMakeList.txt" file.

And here is the list of warnings by the Visual Studio compiler:
http://www.ab-tools.com/temp/Widelands-CompilerWarnings.txt
As you can see many of these warnings are the same and can be fixed in one go (e. g. the "warning C4086: Pragma-Parameter"). But as I'm not the most experienced C++ developer (im coming from the C# side ;-) ), I need some help here to make the right changes.

So if you have any suggestions, please just let me know and I'm happy to test it here.

SirVer (sirver) wrote :

There are a lot, so this list is hard to access. Let's take this in small steps then.

I tried fixing the error in c:\widelands\widelands\src\logic\immovable.h:163 in r6618. And i tried to fix the pragma warning in field.h in r6619. Could you redo the list?

Hans Joachim Desserud (hjd) wrote :

Regarding the CMake warnings, check CMakeList.txt lines 206 and 213. They are in if clauses already. If the compiler supports the additional warnings, they are appended to the options used, otherwise the warnings you saw are printed. This was done both to explain why the additional warnings aren't used and to avoid silently using less without being told why. I guess I could somehow improve the warnings to make this a bit clearer, at least mention Visual Studio as an alternative in the GCC-only warning.

Andreas Breitschopp (ab-tools) wrote :

Yes, that really helped already!

Now there are only 100 warnings instead of almost 750 left:
http://www.ab-tools.com/temp/Widelands-CompilerWarnings2.txt

Andreas Breitschopp (ab-tools) wrote :

Too happy too soon: for whatever reason Visual Studio did not show all warnings...

Now I have the full list - 442 left and I updated the list here again:
http://www.ab-tools.com/temp/Widelands-CompilerWarnings2.txt

Anyway, better already than the 742 in the first compilation today. ;-)

SirVer (sirver) wrote :

Okay, there are still a bunch of dups in this one - most of them will need manual intervention to get fixed properly.

If you are still willing to fix them, I can review them. But I would much appreciate if we could take them in smaller merge requests - this one is too much to chew on right now for me, and I am not sure how many merge conflicts this branch already has. Is this somehow possible for you without much work?

Andreas Breitschopp (ab-tools) wrote :

Yes, this merge request has not much to do with the current warnings anymore as it is very old already.

As I wrote to Hans few days ago I am very happy to help with doing compilation tests here on Windows, but I won't be able to provide many fixes myself for most of these issues as I do have too less C++ experience (as a C# developer).

But I could open a bug report for these warnings if you prefer to go on their instead of in this merge request (which is no longer really useful).

Anyway, I at least have a patch for the 40 warnings regarding not referenced variables:
http://www.ab-tools.com/temp/Widelands-NotReferencedVariables.patch
You're welcome to commit that directly.

After that the compiler warnings are reduced to only 402: ;-)
http://www.ab-tools.com/temp/Widelands-CompilerWarnings3.txt

SirVer (sirver) wrote :

Okay, I applied the patch. I think we should talk about the rest of the warnings in a bug report. First aim should be to make the warning options similar to what we use for the gnu tools (for example we do not care about signed vs unsigned comparison there). Some of the warnings look more serious and are worth investigating for sure, i.e. the unary minus on unsigned values and the overwritten warnings.

Mind opening a bug report for this? We can take it step by step. In the meantime, I set this one to rejected as it is no longer a real merge request. Sounds good?

Andreas Breitschopp (ab-tools) wrote :

That's OK, and I also reported the bug here:
https://bugs.launchpad.net/widelands/+bug/1202101

In the current BZR version compilation on Windows is even not possible at all as there are also compile errors now.

Unmerged revisions

6405. By Andreas Breitschopp on 2012-06-11

Fixing more MSVS 2010 compiler warnings.

6404. By Andreas Breitschopp on 2012-06-11

Fixing CodeCheck issues.

6403. By Andreas Breitschopp on 2012-06-11

Fixing compiler warnings of MSVS 2010.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2012-05-25 20:06:20 +0000
3+++ CMakeLists.txt 2012-06-12 09:18:28 +0000
4@@ -254,7 +254,7 @@
5
6 find_library(INTL_LIBRARY NAMES intl libintl)
7
8- set (MSVC_DISABLE_WARNINGS "/wd4290 /wd4800 /wo4373 /wd4355")
9+ set (MSVC_DISABLE_WARNINGS "/wd4290 /wd4800 /wd4373 /wd4355")
10 # CMAKE only defines "-g", but we need -DDEBUG also, and we need -DNOPARACHUTE (for SDL) in Debug
11 set (CMAKE_CXX_FLAGS_DEBUG " -DDEBUG -DNOPARACHUTE /MTd /Zi /D_DEBUG ${MSVC_DISABLE_WARNINGS}" CACHE STRING "Set by widelands CMakeLists.txt" FORCE)
12
13
14=== modified file 'src/ai/ai_hints.cc'
15--- src/ai/ai_hints.cc 2012-02-15 21:25:34 +0000
16+++ src/ai/ai_hints.cc 2012-06-12 09:18:28 +0000
17@@ -44,8 +44,8 @@
18 {
19 if (section) {
20 if (char const * const s = section->get_string("renews_map_resource"))
21- renews_map_resource = strdup(s);
22+ renews_map_resource = _strdup(s);
23 if (char const * const s = section->get_string("mines"))
24- mines = strdup(s);
25+ mines = _strdup(s);
26 }
27 }
28
29=== modified file 'src/ai/defaultai.cc'
30--- src/ai/defaultai.cc 2012-04-26 15:51:44 +0000
31+++ src/ai/defaultai.cc 2012-06-12 09:18:28 +0000
32@@ -2347,7 +2347,7 @@
33
34 // Attack the selected target.
35 game().send_player_enemyflagaction
36- (target->base_flag(), pn, attackers, retreat);
37+ (target->base_flag(), static_cast<Widelands::Player_Number>(pn), attackers, retreat);
38
39 // Do not attack again too soon - returning soldiers must get healed first.
40 next_attack_consideration_due = (gametime % 51 + 10) * 1000 + gametime;
41
42=== modified file 'src/editor/editorinteractive.cc'
43--- src/editor/editorinteractive.cc 2012-05-06 16:28:43 +0000
44+++ src/editor/editorinteractive.cc 2012-06-12 09:18:28 +0000
45@@ -219,7 +219,7 @@
46 // Run the editor initialization script, if any
47 try {
48 egbase().lua().run_script("map", "editor_init");
49- } catch (LuaScriptNotExistingError & e) {
50+ } catch (LuaScriptNotExistingError &) {
51 // do nothing.
52 }
53 egbase().map().overlay_manager().show_buildhelp(true);
54
55=== modified file 'src/editor/ui_menus/editor_main_menu_random_map.cc'
56--- src/editor/ui_menus/editor_main_menu_random_map.cc 2012-04-27 17:07:48 +0000
57+++ src/editor/ui_menus/editor_main_menu_random_map.cc 2012-06-12 09:18:28 +0000
58@@ -523,8 +523,8 @@
59 if (MAP_DIMENSIONS[ix] == mapInfo.w)
60 m_w = ix;
61
62- m_landval = mapInfo.landRatio * 100.0 + 0.49;
63- m_waterval = mapInfo.waterRatio * 100.0 + 0.49;
64+ m_landval = static_cast<int32_t>(mapInfo.landRatio * 100.0 + 0.49);
65+ m_waterval = static_cast<int32_t>(mapInfo.waterRatio * 100.0 + 0.49);
66 m_res_amount = mapInfo.resource_amount;
67
68 m_res->set_title(m_res_amounts[m_res_amount].c_str());
69
70=== modified file 'src/graphic/animation.cc'
71--- src/graphic/animation.cc 2012-02-15 21:25:34 +0000
72+++ src/graphic/animation.cc 2012-06-12 09:18:28 +0000
73@@ -131,7 +131,7 @@
74 while (Section::Value * const v = s.get_next_val("sfx")) {
75 char * parameters = v->get_string(), * endp;
76 unsigned long long int const value = strtoull(parameters, &endp, 0);
77- uint32_t const frame_number = value;
78+ uint32_t const frame_number = static_cast<uint32_t>(value);
79 try {
80 if (endp == parameters or frame_number != value)
81 throw wexception
82
83=== modified file 'src/graphic/graphic.cc'
84--- src/graphic/graphic.cc 2012-03-09 16:57:20 +0000
85+++ src/graphic/graphic.cc 2012-06-12 09:18:28 +0000
86@@ -553,8 +553,8 @@
87 else // average
88 ratio = (ratio_x + ratio_y) / 2;
89
90- uint32_t fullwidth(src->get_w() * ratio);
91- uint32_t fullheight(src->get_h() * ratio);
92+ uint32_t fullwidth(static_cast<uint32_t>(src->get_w() * ratio));
93+ uint32_t fullheight(static_cast<uint32_t>(src->get_h() * ratio));
94
95 if (fullwidth <= w) {
96 srcrect.x = 0;
97@@ -1000,9 +1000,9 @@
98 if (halve_alpha)
99 color.a >>= 1;
100
101- color.r = color.r * factor > 255 ? 255 : color.r * factor;
102- color.g = color.g * factor > 255 ? 255 : color.g * factor;
103- color.b = color.b * factor > 255 ? 255 : color.b * factor;
104+ color.r = (color.r * factor) > 255 ? 255 : static_cast<Uint8>(color.r * factor);
105+ color.g = (color.g * factor) > 255 ? 255 : static_cast<Uint8>(color.g * factor);
106+ color.b = (color.b * factor) > 255 ? 255 : static_cast<Uint8>(color.b * factor);
107
108 destpix.set_pixel(x, y, color.map(destfmt));
109 }
110
111=== modified file 'src/graphic/render/gameview.cc'
112--- src/graphic/render/gameview.cc 2012-06-08 22:33:16 +0000
113+++ src/graphic/render/gameview.cc 2012-06-12 09:18:28 +0000
114@@ -65,7 +65,7 @@
115 static_cast<Sint16>
116 (((static_cast<Sint16>(result) + 128) >> 1)
117 *
118- (1.0 + (time_ago < 45000 ? expf(-8.46126929e-5 * time_ago) : 0)))
119+ (1.0f + (time_ago < 45000 ? expf(-8.46126929e-5f * time_ago) : 0)))
120 -
121 128;
122 }
123
124=== modified file 'src/graphic/render/gl_picture_texture.cc'
125--- src/graphic/render/gl_picture_texture.cc 2012-02-15 21:25:34 +0000
126+++ src/graphic/render/gl_picture_texture.cc 2012-06-12 09:18:28 +0000
127@@ -80,8 +80,8 @@
128 } else {
129 pixels_format = GL_RGBA;
130 // Read four bytes per pixel but ignore the alpha value
131- glPixelTransferi(GL_ALPHA_SCALE, 0.0f);
132- glPixelTransferi(GL_ALPHA_BIAS, 1.0f);
133+ glPixelTransferi(GL_ALPHA_SCALE, 0);
134+ glPixelTransferi(GL_ALPHA_BIAS, 1);
135 }
136 } else if
137 (fmt.Bmask == 0x000000ff and fmt.Gmask == 0x0000ff00 and
138@@ -92,8 +92,8 @@
139 } else {
140 pixels_format = GL_BGRA;
141 // Read four bytes per pixel but ignore the alpha value
142- glPixelTransferi(GL_ALPHA_SCALE, 0.0f);
143- glPixelTransferi(GL_ALPHA_BIAS, 1.0f);
144+ glPixelTransferi(GL_ALPHA_SCALE, 0);
145+ glPixelTransferi(GL_ALPHA_BIAS, 1);
146 }
147 } else
148 throw wexception("OpenGL: Unknown pixel format");
149
150=== modified file 'src/graphic/render/gl_surface_screen.cc'
151--- src/graphic/render/gl_surface_screen.cc 2012-02-15 21:25:34 +0000
152+++ src/graphic/render/gl_surface_screen.cc 2012-06-12 09:18:28 +0000
153@@ -141,10 +141,10 @@
154
155 glBegin(GL_LINE_LOOP); {
156 glColor3ub(clr.r(), clr.g(), clr.b());
157- glVertex2f(rc.x + 0.5f, rc.y + 0.5f);
158- glVertex2f(rc.x + rc.w - 0.5f, rc.y + 0.5f);
159- glVertex2f(rc.x + rc.w - 0.5f, rc.y + rc.h - 0.5f);
160- glVertex2f(rc.x + 0.5f, rc.y + rc.h - 0.5f);
161+ glVertex2f(static_cast<float>(rc.x + 0.5f), static_cast<float>(rc.y + 0.5f));
162+ glVertex2f(static_cast<float>(rc.x + rc.w - 0.5f), static_cast<float>(rc.y + 0.5f));
163+ glVertex2f(static_cast<float>(rc.x + rc.w - 0.5f), static_cast<float>(rc.y + rc.h - 0.5f));
164+ glVertex2f(static_cast<float>(rc.x + 0.5f), static_cast<float>(rc.y + rc.h - 0.5f));
165 } glEnd();
166 glEnable(GL_TEXTURE_2D);
167 }
168@@ -165,10 +165,10 @@
169
170 glBegin(GL_QUADS); {
171 glColor4ub(clr.r, clr.g, clr.b, clr.a);
172- glVertex2f(rc.x, rc.y);
173- glVertex2f(rc.x + rc.w, rc.y);
174- glVertex2f(rc.x + rc.w, rc.y + rc.h);
175- glVertex2f(rc.x, rc.y + rc.h);
176+ glVertex2f(static_cast<float>(rc.x), static_cast<float>(rc.y));
177+ glVertex2f(static_cast<float>(rc.x + rc.w), static_cast<float>(rc.y));
178+ glVertex2f(static_cast<float>(rc.x + rc.w), static_cast<float>(rc.y + rc.h));
179+ glVertex2f(static_cast<float>(rc.x), static_cast<float>(rc.y + rc.h));
180 } glEnd();
181 glEnable(GL_TEXTURE_2D);
182 }
183@@ -213,13 +213,13 @@
184 // (this is the source color) over the region
185 glBegin(GL_QUADS); {
186 glColor3f
187- ((fabsf(factor) / 256.0f),
188- (fabsf(factor) / 256.0f),
189- (fabsf(factor) / 256.0f));
190- glVertex2f(rc.x, rc.y);
191- glVertex2f(rc.x + rc.w, rc.y);
192- glVertex2f(rc.x + rc.w, rc.y + rc.h);
193- glVertex2f(rc.x, rc.y + rc.h);
194+ ((fabsf(static_cast<float>(factor)) / 256.0f),
195+ (fabsf(static_cast<float>(factor)) / 256.0f),
196+ (fabsf(static_cast<float>(factor)) / 256.0f));
197+ glVertex2f(static_cast<float>(rc.x), static_cast<float>(rc.y));
198+ glVertex2f(static_cast<float>(rc.x + rc.w), static_cast<float>(rc.y));
199+ glVertex2f(static_cast<float>(rc.x + rc.w), static_cast<float>(rc.y + rc.h));
200+ glVertex2f(static_cast<float>(rc.x), static_cast<float>(rc.y + rc.h));
201 } glEnd();
202
203 if (factor < 0)
204@@ -289,19 +289,19 @@
205
206 glBegin(GL_QUADS); {
207 // set color white, otherwise textures get mixed with color
208- glColor3f(1.0, 1.0, 1.0);
209+ glColor3f(1.0f, 1.0f, 1.0f);
210 // top-left
211 glTexCoord2i(srcrc.x, srcrc.y);
212 glVertex2i (dst.x, dst.y);
213 // top-right
214 glTexCoord2i(srcrc.x + srcrc.w, srcrc.y);
215- glVertex2f (dst.x + srcrc.w, dst.y);
216+ glVertex2f (static_cast<float>(dst.x + srcrc.w), static_cast<float>(dst.y));
217 // bottom-right
218 glTexCoord2i(srcrc.x + srcrc.w, srcrc.y + srcrc.h);
219- glVertex2f (dst.x + srcrc.w, dst.y + srcrc.h);
220+ glVertex2f (static_cast<float>(dst.x + srcrc.w), static_cast<float>(dst.y + srcrc.h));
221 // bottom-left
222- glTexCoord2i(srcrc.x, srcrc.y + srcrc.h);
223- glVertex2f (dst.x, dst.y + srcrc.h);
224+ glTexCoord2i(srcrc.x, srcrc.y + srcrc.h);
225+ glVertex2f (static_cast<float>(dst.x), static_cast<float>(dst.y + srcrc.h));
226 } glEnd();
227
228 glLoadIdentity();
229
230=== modified file 'src/graphic/render/render_sdl.cc'
231--- src/graphic/render/render_sdl.cc 2012-02-15 21:25:34 +0000
232+++ src/graphic/render/render_sdl.cc 2012-06-12 09:18:28 +0000
233@@ -155,7 +155,11 @@
234 r = ~r >> 24;
235
236 *reinterpret_cast<Uint32 *>(pix) =
237- SDL_MapRGB(m_surface->format, r, g, b);
238+ SDL_MapRGB
239+ (m_surface->format,
240+ static_cast<Uint8>(r),
241+ static_cast<Uint8>(g),
242+ static_cast<Uint8>(b));
243 }
244 } else if (m_surface->format->BytesPerPixel == 2) {
245 for (int32_t y = rc.y; y < bl.y; ++y)
246@@ -180,7 +184,11 @@
247 r = ~r >> 24;
248
249 *reinterpret_cast<Uint16 *>(pix) =
250- SDL_MapRGB(m_surface->format, r, g, b);
251+ SDL_MapRGB
252+ (m_surface->format,
253+ static_cast<Uint8>(r),
254+ static_cast<Uint8>(g),
255+ static_cast<Uint8>(b));
256 }
257 }
258 unlock(IPixelAccess::Unlock_Update);
259
260=== modified file 'src/graphic/render/terrain_opengl.h'
261--- src/graphic/render/terrain_opengl.h 2012-02-21 13:51:08 +0000
262+++ src/graphic/render/terrain_opengl.h 2012-06-12 09:18:28 +0000
263@@ -150,40 +150,67 @@
264
265 glBegin(GL_TRIANGLES); {
266 {
267- GLfloat const brightness = (150.0 + p1.b) / 150.0;
268+ GLfloat const brightness = (150.0f + p1.b) / 150.0f;
269 glColor3f(brightness, brightness, brightness);
270 }
271 glMultiTexCoord2iARB(GL_TEXTURE0_ARB, t1.tx, t1.ty);
272- glMultiTexCoord2fARB(GL_TEXTURE1_ARB, t1.tx / TEXTURE_WIDTH, t1.ty / TEXTURE_WIDTH);
273+ glMultiTexCoord2fARB
274+ (GL_TEXTURE1_ARB,
275+ static_cast<float>(t1.tx / TEXTURE_WIDTH),
276+ static_cast<float>(t1.ty / TEXTURE_WIDTH));
277 glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 0, 0);
278- glMultiTexCoord2fARB(GL_TEXTURE3_ARB, t1.tx / TEXTURE_WIDTH, t1.ty / TEXTURE_WIDTH);
279+ glMultiTexCoord2fARB
280+ (GL_TEXTURE3_ARB,
281+ static_cast<float>(t1.tx / TEXTURE_WIDTH),
282+ static_cast<float>(t1.ty / TEXTURE_WIDTH));
283 glMultiTexCoord2fARB(GL_TEXTURE4_ARB, 1, 0);
284- glMultiTexCoord2fARB(GL_TEXTURE5_ARB, t1.tx / TEXTURE_WIDTH, t1.ty / TEXTURE_WIDTH);
285- glVertex2f(t1.x, t1.y);
286+ glMultiTexCoord2fARB
287+ (GL_TEXTURE5_ARB,
288+ static_cast<float>(t1.tx / TEXTURE_WIDTH),
289+ static_cast<float>(t1.ty / TEXTURE_WIDTH));
290+ glVertex2f(static_cast<float>(t1.x), static_cast<float>(t1.y));
291
292 {
293- GLfloat const brightness = (150.0 + p2.b) / 150.0;
294+ GLfloat const brightness = (150.0f + p2.b) / 150.0f;
295 glColor3f(brightness, brightness, brightness);
296 }
297 glMultiTexCoord2iARB(GL_TEXTURE0_ARB, t2.tx, t2.ty);
298- glMultiTexCoord2fARB(GL_TEXTURE1_ARB, t2.tx / TEXTURE_WIDTH, t2.ty / TEXTURE_WIDTH);
299+ glMultiTexCoord2fARB
300+ (GL_TEXTURE1_ARB,
301+ static_cast<float>(t2.tx / TEXTURE_WIDTH),
302+ static_cast<float>(t2.ty / TEXTURE_WIDTH));
303 glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 0.5, 1);
304- glMultiTexCoord2fARB(GL_TEXTURE3_ARB, t2.tx / TEXTURE_WIDTH, t2.ty / TEXTURE_WIDTH);
305+ glMultiTexCoord2fARB
306+ (GL_TEXTURE3_ARB,
307+ static_cast<float>(t2.tx / TEXTURE_WIDTH),
308+ static_cast<float>(t2.ty / TEXTURE_WIDTH));
309 glMultiTexCoord2fARB(GL_TEXTURE4_ARB, 0, 0);
310- glMultiTexCoord2fARB(GL_TEXTURE5_ARB, t2.tx / TEXTURE_WIDTH, t2.ty / TEXTURE_WIDTH);
311- glVertex2f(t2.x, t2.y);
312+ glMultiTexCoord2fARB
313+ (GL_TEXTURE5_ARB,
314+ static_cast<float>(t2.tx / TEXTURE_WIDTH),
315+ static_cast<float>(t2.ty / TEXTURE_WIDTH));
316+ glVertex2f(static_cast<float>(t2.x), static_cast<float>(t2.y));
317
318 {
319- GLfloat const brightness = (150.0 + p3.b) / 150.0;
320+ GLfloat const brightness = (150.0f + p3.b) / 150.0f;
321 glColor3f(brightness, brightness, brightness);
322 }
323 glMultiTexCoord2iARB(GL_TEXTURE0_ARB, t3.tx, t3.ty);
324- glMultiTexCoord2fARB(GL_TEXTURE1_ARB, t3.tx / TEXTURE_WIDTH, t3.ty / TEXTURE_WIDTH);
325+ glMultiTexCoord2fARB
326+ (GL_TEXTURE1_ARB,
327+ static_cast<float>(t3.tx / TEXTURE_WIDTH),
328+ static_cast<float>(t3.ty / TEXTURE_WIDTH));
329 glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 1, 0);
330- glMultiTexCoord2fARB(GL_TEXTURE3_ARB, t3.tx / TEXTURE_WIDTH, t3.ty / TEXTURE_WIDTH);
331+ glMultiTexCoord2fARB
332+ (GL_TEXTURE3_ARB,
333+ static_cast<float>(t3.tx / TEXTURE_WIDTH),
334+ static_cast<float>(t3.ty / TEXTURE_WIDTH));
335 glMultiTexCoord2fARB(GL_TEXTURE4_ARB, 0.5, 1);
336- glMultiTexCoord2fARB(GL_TEXTURE5_ARB, t3.tx / TEXTURE_WIDTH, t3.ty / TEXTURE_WIDTH);
337- glVertex2f(t3.x, t3.y);
338+ glMultiTexCoord2fARB
339+ (GL_TEXTURE5_ARB,
340+ static_cast<float>(t3.tx / TEXTURE_WIDTH),
341+ static_cast<float>(t3.ty / TEXTURE_WIDTH));
342+ glVertex2f(static_cast<float>(t3.x), static_cast<float>(t3.y));
343 } glEnd();
344
345 // Cleanup OpenGL
346@@ -211,54 +238,54 @@
347 glBindTexture(GL_TEXTURE_2D, texture.getTexture());
348 glBegin(GL_TRIANGLES); {
349 {
350- GLfloat const brightness = (150.0 + p1.b) / 150.0;
351+ GLfloat const brightness = (150.0f + p1.b) / 150.0f;
352 glColor3f(brightness, brightness, brightness);
353 }
354 glTexCoord2i(t1.tx, t1.ty);
355- glVertex2f(t1.x, t1.y);
356+ glVertex2f(static_cast<float>(t1.x), static_cast<float>(t1.y));
357
358 {
359- GLfloat const brightness = (150.0 + p2.b) / 150.0;
360+ GLfloat const brightness = (150.0f + p2.b) / 150.0f;
361 glColor3f(brightness, brightness, brightness);
362 }
363 glTexCoord2i(t2.tx, t2.ty);
364- glVertex2f(t2.x, t2.y);
365+ glVertex2f(static_cast<float>(t2.x), static_cast<float>(t2.y));
366
367 {
368- GLfloat const brightness = (150.0 + p3.b) / 150.0;
369+ GLfloat const brightness = (150.0f + p3.b) / 150.0f;
370 glColor3f(brightness, brightness, brightness);
371 }
372 glTexCoord2i(t3.tx, t3.ty);
373- glVertex2f(t3.x, t3.y);
374+ glVertex2f(static_cast<float>(t3.x), static_cast<float>(t3.y));
375 } glEnd();
376 }
377 }
378
379-#define horiz_road_opengl(tex, start, end) \
380- glBindTexture( GL_TEXTURE_2D, tex); \
381- glBegin(GL_QUADS); { \
382- glTexCoord2i(0, 0); \
383- glVertex2f(subwin.x + start.x, subwin.y + start.y - 2); \
384- glTexCoord2i(TEXTURE_WIDTH, 0); \
385- glVertex2f(subwin.x + end.x, subwin.y + end.y - 2); \
386- glTexCoord2i(TEXTURE_WIDTH, 4); \
387- glVertex2f(subwin.x + end.x, subwin.y + end.y + 2); \
388- glTexCoord2i(0, 4); \
389- glVertex2f(subwin.x + start.x, subwin.y + start.y + 2); \
390- } glEnd(); \
391+#define horiz_road_opengl(tex, start, end) \
392+ glBindTexture(GL_TEXTURE_2D, tex); \
393+ glBegin(GL_QUADS); { \
394+ glTexCoord2i(0, 0); \
395+ glVertex2f(static_cast<float>(subwin.x + start.x), static_cast<float>(subwin.y + start.y - 2)); \
396+ glTexCoord2i(TEXTURE_WIDTH, 0); \
397+ glVertex2f(static_cast<float>(subwin.x + end.x), static_cast<float>(subwin.y + end.y - 2)); \
398+ glTexCoord2i(TEXTURE_WIDTH, 4); \
399+ glVertex2f(static_cast<float>(subwin.x + end.x), static_cast<float>(subwin.y + end.y + 2)); \
400+ glTexCoord2i(0, 4); \
401+ glVertex2f(static_cast<float>(subwin.x + start.x), static_cast<float>(subwin.y + start.y + 2)); \
402+ } glEnd(); \
403
404-#define vert_road_opengl(tex, start, end) \
405- glBindTexture( GL_TEXTURE_2D, tex); \
406- glBegin(GL_QUADS); { \
407- glTexCoord2i(0, 0); \
408- glVertex2f(subwin.x + start.x - 3, subwin.y + start.y); \
409- glTexCoord2i(6, 0); \
410- glVertex2f(subwin.x + start.x + 3, subwin.y + start.y); \
411- glTexCoord2i(TEXTURE_WIDTH, TEXTURE_HEIGHT); \
412- glVertex2f(subwin.x + end.x + 3, subwin.y + end.y); \
413- glTexCoord2i(TEXTURE_WIDTH - 6, TEXTURE_HEIGHT); \
414- glVertex2f(subwin.x + end.x - 3, subwin.y + end.y); \
415- } glEnd(); \
416+#define vert_road_opengl(tex, start, end) \
417+ glBindTexture( GL_TEXTURE_2D, tex); \
418+ glBegin(GL_QUADS); { \
419+ glTexCoord2i(0, 0); \
420+ glVertex2f(static_cast<float>(subwin.x + start.x - 3), static_cast<float>(subwin.y + start.y)); \
421+ glTexCoord2i(6, 0); \
422+ glVertex2f(static_cast<float>(subwin.x + start.x + 3), static_cast<float>(subwin.y + start.y)); \
423+ glTexCoord2i(TEXTURE_WIDTH, TEXTURE_HEIGHT); \
424+ glVertex2f(static_cast<float>(subwin.x + end.x + 3), static_cast<float>(subwin.y + end.y)); \
425+ glTexCoord2i(TEXTURE_WIDTH - 6, TEXTURE_HEIGHT); \
426+ glVertex2f(static_cast<float>(subwin.x + end.x - 3), static_cast<float>(subwin.y + end.y)); \
427+ } glEnd(); \
428
429 void draw_roads_opengl
430 (Rect & subwin,
431
432=== modified file 'src/graphic/render/terrain_sdl.cc'
433--- src/graphic/render/terrain_sdl.cc 2012-02-15 21:25:34 +0000
434+++ src/graphic/render/terrain_sdl.cc 2012-06-12 09:18:28 +0000
435@@ -27,7 +27,7 @@
436 {
437 float det;
438
439- det = u1 * v2 - u2 * v1; // determinant of (u v)
440+ det = static_cast<float>(u1 * v2 - u2 * v1); // determinant of (u v)
441
442 lambda = v2 / det; // by Cramer's rule
443 mu = -u2 / det;
444
445=== modified file 'src/graphic/rendertarget.cc'
446--- src/graphic/rendertarget.cc 2012-03-15 21:41:48 +0000
447+++ src/graphic/rendertarget.cc 2012-06-12 09:18:28 +0000
448@@ -345,7 +345,7 @@
449 gfx->get_frame
450 (0);
451
452- PictureID dark_frame = g_gr->create_changed_luminosity_pic(frame, 1.22, true);
453+ PictureID dark_frame = g_gr->create_changed_luminosity_pic(frame, 1.22f, true);
454
455 dst -= Point(frame->get_w() / 2, frame->get_h() / 2);
456
457
458=== modified file 'src/graphic/texture.cc'
459--- src/graphic/texture.cc 2012-02-16 01:09:34 +0000
460+++ src/graphic/texture.cc 2012-06-12 09:18:28 +0000
461@@ -74,7 +74,7 @@
462
463 SDL_Surface * surf;
464
465- m_texture_picture = strdup(fname);
466+ m_texture_picture = _strdup(fname);
467
468 FileRead fr;
469
470
471=== modified file 'src/i18n.cc'
472--- src/i18n.cc 2012-04-06 19:26:17 +0000
473+++ src/i18n.cc 2012-06-12 09:18:28 +0000
474@@ -183,7 +183,7 @@
475 locale = lang;
476 #endif
477 #ifdef _WIN32
478- putenv(const_cast<char *>((std::string("LANG=") + lang).c_str()));
479+ _putenv(const_cast<char *>((std::string("LANG=") + lang).c_str()));
480 locale = lang;
481 #endif
482
483
484=== modified file 'src/io/filesystem/disk_filesystem.cc'
485--- src/io/filesystem/disk_filesystem.cc 2012-05-08 12:35:24 +0000
486+++ src/io/filesystem/disk_filesystem.cc 2012-06-12 09:18:28 +0000
487@@ -347,7 +347,7 @@
488 ("a file with the name \"%s\" already exists", dirname.c_str());
489
490 if
491- (mkdir
492+ (_mkdir
493 #ifdef WIN32
494 (fspath.c_str())
495 #else
496
497=== modified file 'src/io/filesystem/filesystem.cc'
498--- src/io/filesystem/filesystem.cc 2012-06-08 12:50:14 +0000
499+++ src/io/filesystem/filesystem.cc 2012-06-12 09:18:28 +0000
500@@ -145,7 +145,7 @@
501 */
502 std::string FileSystem::getWorkingDirectory() const {
503 char cwd[PATH_MAX + 1];
504- char * const result = getcwd(cwd, PATH_MAX);
505+ char * const result = _getcwd(cwd, PATH_MAX);
506 if (! result)
507 throw File_error("FileSystem::getWorkingDirectory()", "widelands", "can not run getcwd");
508
509
510=== modified file 'src/journal.h'
511--- src/journal.h 2012-02-15 21:25:34 +0000
512+++ src/journal.h 2012-06-12 09:18:28 +0000
513@@ -92,7 +92,7 @@
514 * Returns the position in the playback file
515 * \return byte offset into the playback file, used with file reading
516 */
517- int32_t get_playback_offset() {return m_playbackstream.tellg();}
518+ int32_t get_playback_offset() {return static_cast<int32_t>(m_playbackstream.tellg());}
519
520 void write(int8_t);
521 void write(uint8_t);
522
523=== modified file 'src/logic/cmd_luascript.cc'
524--- src/logic/cmd_luascript.cc 2012-02-15 21:25:34 +0000
525+++ src/logic/cmd_luascript.cc 2012-06-12 09:18:28 +0000
526@@ -30,7 +30,7 @@
527 log("Trying to run: %s, %s: ", m_ns.c_str(), m_script.c_str());
528 try {
529 game.lua().run_script(m_ns, m_script);
530- } catch (LuaScriptNotExistingError & e) {
531+ } catch (LuaScriptNotExistingError &) {
532 // The script has not been found.
533 log("not found.\n");
534 return;
535
536=== modified file 'src/logic/game.cc'
537--- src/logic/game.cc 2012-06-06 19:32:13 +0000
538+++ src/logic/game.cc 2012-06-12 09:18:28 +0000
539@@ -110,7 +110,7 @@
540 if (m_dump) {
541 try {
542 m_dump->Data(data, size);
543- } catch (_wexception const & e) {
544+ } catch (_wexception const &) {
545 log
546 ("Writing to syncstream file %s failed. Stop synctream dump.\n",
547 m_dumpfname.c_str());
548
549=== modified file 'src/logic/immovable.cc'
550--- src/logic/immovable.cc 2012-06-08 22:33:16 +0000
551+++ src/logic/immovable.cc 2012-06-12 09:18:28 +0000
552@@ -857,7 +857,7 @@
553 if (not reached_end) {
554 char * endp;
555 unsigned long long int const value = strtoull(parameters, &endp, 0);
556- priority = value;
557+ priority = static_cast<uint8_t>(value);
558 if (*endp or priority != value)
559 throw game_data_error
560 (_("expected %s but found \"%s\""), _("priority"), parameters);
561@@ -901,7 +901,7 @@
562 ("expected probability in range [1, 254] but found "
563 "\"%s\""),
564 params[i].c_str());
565- probability = value;
566+ probability = static_cast<uint8_t>(value);
567 } else {
568 std::vector<std::string> segments = split_string(params[i], ":");
569
570@@ -1024,7 +1024,7 @@
571 throw game_data_error
572 (_("expected %s but found \"%s\""),
573 _("probability in range [1, 254]"), parameters);
574- probability = value;
575+ probability = static_cast<uint8_t>(value);
576 } else
577 probability = 0;
578 } catch (_wexception const & e) {
579@@ -1080,7 +1080,7 @@
580 ("expected probability in range [1, 254] but found "
581 "\"%s\""),
582 p);
583- probability = value;
584+ probability = static_cast<uint8_t>(value);
585 // fallthrough
586 }
587 case '\0':
588
589=== modified file 'src/logic/military_data.cc'
590--- src/logic/military_data.cc 2012-02-15 21:25:34 +0000
591+++ src/logic/military_data.cc 2012-06-12 09:18:28 +0000
592@@ -52,12 +52,12 @@
593 container_iterate(std::vector<std::string>, list, i)
594 remove_spaces(*i.current);
595 char * endp;
596- m_min_retreat = strtol(list[0].c_str(), &endp, 0);
597+ m_min_retreat = static_cast<uint8_t>(strtol(list[0].c_str(), &endp, 0));
598 if (*endp or m_min_retreat > 100)
599 throw game_data_error
600 (_("expected %s but found \"%s\""),
601 _("positive integer <= 100"), list[0].c_str());
602- m_max_retreat = strtol(list[1].c_str(), &endp, 0);
603+ m_max_retreat = static_cast<uint8_t>(strtol(list[1].c_str(), &endp, 0));
604 if (*endp or m_max_retreat > 100 or m_max_retreat < m_min_retreat)
605 throw game_data_error
606 (_("expected positive integer >= %u <= 100 but found \"%s\""),
607
608=== modified file 'src/logic/production_program.cc'
609--- src/logic/production_program.cc 2012-06-08 22:33:16 +0000
610+++ src/logic/production_program.cc 2012-06-12 09:18:28 +0000
611@@ -108,7 +108,7 @@
612 ++parameters;
613 char * endp;
614 unsigned long long int const value = strtoull(parameters, &endp, 0);
615- count = value;
616+ count = static_cast<uint8_t>(value);
617 if ((*endp and *endp != ' ') or value < 1 or count != value)
618 throw game_data_error
619 (_("expected %s but found \"%s\""), _("count"), parameters);
620@@ -639,7 +639,7 @@
621 if (*parameters) {
622 char * endp;
623 long long int const value = strtoll(parameters, &endp, 0);
624- m_duration = value;
625+ m_duration = static_cast<Widelands::Duration>(value);
626 if (*endp or value <= 0 or m_duration != value)
627 throw game_data_error
628 (_("expected %s but found \"%s\""),
629@@ -712,7 +712,7 @@
630 if (not reached_end) { // The next parameter is the duration.
631 char * endp;
632 long long int const value = strtoll(parameters, &endp, 0);
633- m_duration = value;
634+ m_duration = static_cast<Widelands::Duration>(value);
635 if (*endp or value <= 0 or m_duration != value)
636 throw game_data_error
637 (_("expected %s but found \"%s\""),
638@@ -866,7 +866,7 @@
639 char * endp;
640 unsigned long long int const value =
641 strtoull(parameters, &endp, 0);
642- item.second = value;
643+ item.second = static_cast<uint8_t>(value);
644 if
645 ((*endp and *endp != ' ')
646 or
647@@ -961,7 +961,7 @@
648 char * endp;
649 unsigned long long int const value =
650 strtoull(parameters, &endp, 0);
651- item.second = value;
652+ item.second = static_cast<uint8_t>(value);
653 if
654 ((*endp and *endp != ' ')
655 or
656@@ -1043,7 +1043,7 @@
657 {
658 char * endp;
659 unsigned long long int const value = strtoull(parameters, &endp, 0);
660- m_distance = value;
661+ m_distance = static_cast<uint8_t>(value);
662 if (*endp != ' ' or m_distance != value)
663 throw game_data_error
664 (_("expected %s but found \"%s\""), _("distance"), parameters);
665@@ -1053,7 +1053,7 @@
666 {
667 char * endp;
668 unsigned long long int const value = strtoull(parameters, &endp, 0);
669- m_max = value;
670+ m_max = static_cast<uint8_t>(value);
671 if (*endp != ' ' or value < 1 or 100 < value)
672 throw game_data_error
673 (_("expected %s but found \"%s\""),
674@@ -1064,7 +1064,7 @@
675 {
676 char * endp;
677 unsigned long long int const value = strtoull(parameters, &endp, 0);
678- m_chance = value;
679+ m_chance = static_cast<uint8_t>(value);
680 if (*endp or value < 1 or 100 < value)
681 throw game_data_error
682 (_("expected %s but found \"%s\""),
683@@ -1241,7 +1241,7 @@
684
685 char * endp;
686 unsigned long long int const value = strtoull(parameters, &endp, 0);
687- level = value;
688+ level = static_cast<uint8_t>(value);
689 if (*endp or level != value)
690 throw game_data_error
691 (_("expected %s but found \"%s\""), _("level"), parameters);
692@@ -1313,7 +1313,7 @@
693 {
694 char * endp;
695 unsigned long long int const value = strtoull(parameters, &endp, 0);
696- level = value;
697+ level = static_cast<uint8_t>(value);
698 if (*endp != ' ' or level != value)
699 throw game_data_error
700 (_("expected %s but found \"%s\""), _("level"), parameters);
701@@ -1323,7 +1323,7 @@
702 {
703 char * endp;
704 unsigned long long int const value = strtoull(parameters, &endp, 0);
705- target_level = value;
706+ target_level = static_cast<uint8_t>(value);
707 if (*endp or target_level != value or target_level <= level)
708 throw game_data_error
709 (_("expected level > %u but found \"%s\""), level, parameters);
710@@ -1401,7 +1401,7 @@
711 if (not reached_end) {
712 char * endp;
713 unsigned long long int const value = strtoull(parameters, &endp, 0);
714- priority = value;
715+ priority = static_cast<uint8_t>(value);
716 if (*endp or priority != value)
717 throw game_data_error
718 (_("expected %s but found \"%s\""), _("priority"), parameters);
719
720=== modified file 'src/logic/soldier.cc'
721--- src/logic/soldier.cc 2012-06-06 19:32:13 +0000
722+++ src/logic/soldier.cc 2012-06-12 09:18:28 +0000
723@@ -607,10 +607,10 @@
724
725 // Draw level pictures
726 {
727- dst.blit(pt + Point(-atw, -(hph + ath)), attackpic);
728- dst.blit(pt + Point(0, -(evh + deh)), defensepic);
729- dst.blit(pt + Point(-hpw, -hph), hppic);
730- dst.blit(pt + Point(0, -evh), evadepic);
731+ dst.blit(pt + Point(-static_cast<int32_t>(atw), -static_cast<int32_t>(hph + ath)), attackpic);
732+ dst.blit(pt + Point(0, -static_cast<int32_t>(evh + deh)), defensepic);
733+ dst.blit(pt + Point(-static_cast<int32_t>(hpw), -static_cast<int32_t>(hph)), hppic);
734+ dst.blit(pt + Point(0, -static_cast<int32_t>(evh)), evadepic);
735 }
736 }
737
738
739=== modified file 'src/logic/soldier.h'
740--- src/logic/soldier.h 2012-02-15 21:25:34 +0000
741+++ src/logic/soldier.h 2012-06-12 09:18:28 +0000
742@@ -198,6 +198,7 @@
743 void init_auto_task(Game &);
744
745 Point calc_drawpos(Editor_Game_Base const &, Point) const;
746+
747 /// Draw this soldier
748 virtual void draw
749 (const Editor_Game_Base &, RenderTarget &, const Point) const;
750
751=== modified file 'src/logic/world.cc'
752--- src/logic/world.cc 2012-06-09 22:12:30 +0000
753+++ src/logic/world.cc 2012-06-12 09:18:28 +0000
754@@ -907,7 +907,7 @@
755 (fnametmpl, sizeof(fnametmpl),
756 "%s/pics/%s_??.png", directory, m_name.c_str());
757
758- m_picnametempl = strdup(fnametmpl);
759+ m_picnametempl = _strdup(fnametmpl);
760 }
761
762 Terrain_Descr::~Terrain_Descr()
763
764=== modified file 'src/map_generator.cc'
765--- src/map_generator.cc 2012-02-15 21:25:34 +0000
766+++ src/map_generator.cc 2012-06-12 09:18:28 +0000
767@@ -207,15 +207,17 @@
768 double const land_fac = m_mapInfo.landRatio;
769
770 uint8_t res_h =
771- elevation < water_fac ? water_h :
772+ elevation < water_fac ? static_cast<uint8_t>(water_h) :
773 elevation < water_fac + land_fac ?
774- water_h + 1 +
775- ((elevation - water_fac) / land_fac) * (mount_h - water_h)
776+ static_cast<uint8_t>
777+ (water_h + 1 +
778+ ((elevation - water_fac) / land_fac) * (mount_h - water_h))
779 :
780- mount_h +
781- ((elevation - water_fac - land_fac) / (1 - water_fac - land_fac))
782- *
783- (summit_h - mount_h);
784+ static_cast<uint8_t>
785+ (mount_h +
786+ ((elevation - water_fac - land_fac) / (1 - water_fac - land_fac))
787+ *
788+ (summit_h - mount_h));
789
790 // Handle Map Border in island mode
791 if (m_mapInfo.islandMode) {
792@@ -374,12 +376,12 @@
793
794 for (uint32_t x = 0; x < w; ++x)
795 for (uint32_t y = 0; y < h; ++y) {
796- values[x + y * w] =
797- ((static_cast<double>(values[x + y * w] - min))
798- /
799- static_cast<double>(max - min))
800- *
801- MAX_ELEVATION;
802+ values[x + y * w] = static_cast<uint32_t>
803+ (((static_cast<double>(values[x + y * w] - min))
804+ /
805+ static_cast<double>(max - min))
806+ *
807+ MAX_ELEVATION);
808 ++histo[values[x + y * w] >> 22];
809 }
810
811@@ -399,10 +401,10 @@
812 // This is done to have reliable water/land ratio later on.
813 for (uint32_t x = 0; x < w; ++x)
814 for (uint32_t y = 0; y < h; ++y)
815- values[x + y * w] =
816- minVals[values[x + y * w] >> 22]
817- *
818- static_cast<double>(MAX_ELEVATION);
819+ values[x + y * w] = static_cast<uint32_t>
820+ (minVals[values[x + y * w] >> 22]
821+ *
822+ static_cast<double>(MAX_ELEVATION));
823 return values;
824 } catch (...) {
825 delete[] values;
826@@ -1111,11 +1113,11 @@
827 // Convert height
828 nums [8] = (mapInfo.h - 64) / 16;
829 // Convert water percent
830- nums [9] = (mapInfo.waterRatio + 0.025) * 20.0;
831+ nums [9] = static_cast<int32_t>((mapInfo.waterRatio + 0.025) * 20.0);
832 // Convert land percent
833- nums[10] = (mapInfo.landRatio + 0.025) * 20.0;
834+ nums[10] = static_cast<int32_t>((mapInfo.landRatio + 0.025) * 20.0);
835 // Convert wasteland percent
836- nums[11] = (mapInfo.wastelandRatio + 0.025) * 20.0;
837+ nums[11] = static_cast<int32_t>((mapInfo.wastelandRatio + 0.025) * 20.0);
838
839 // Set number of islands
840 nums[12] = mapInfo.numPlayers;
841
842=== modified file 'src/map_io/widelands_map_resources_data_packet.cc'
843--- src/map_io/widelands_map_resources_data_packet.cc 2012-02-15 21:25:34 +0000
844+++ src/map_io/widelands_map_resources_data_packet.cc 2012-06-12 09:18:28 +0000
845@@ -55,7 +55,7 @@
846 // construct ids and map
847 std::map<uint8_t, uint8_t> smap;
848 for (uint8_t i = 0; i < nr_res; ++i) {
849- uint8_t const id = fr.Unsigned16();
850+ uint8_t const id = static_cast<uint8_t>(fr.Unsigned16());
851 char const * const buffer = fr.CString();
852 int32_t const res = world.get_resource(buffer);
853 if (res == -1)
854
855=== modified file 'src/network/internet_gaming.cc'
856--- src/network/internet_gaming.cc 2012-05-27 11:54:05 +0000
857+++ src/network/internet_gaming.cc 2012-06-12 09:18:28 +0000
858@@ -152,7 +152,7 @@
859 s.send(m_sock);
860
861 // Now let's see, whether the metaserver is answering
862- uint32_t const secs = time(0);
863+ uint32_t const secs = static_cast<uint32_t>(time(0));
864 m_state = CONNECTING;
865 while (INTERNET_GAMING_TIMEOUT > time(0) - secs) {
866 handle_metaserver_communication();
867@@ -194,7 +194,7 @@
868 s.send(m_sock);
869
870 // Now let's see, whether the metaserver is answering
871- uint32_t const secs = time(0);
872+ uint32_t const secs = static_cast<uint32_t>(time(0));
873 m_state = CONNECTING;
874 while (INTERNET_GAMING_TIMEOUT > time(0) - secs) {
875 handle_metaserver_communication();
876@@ -421,7 +421,7 @@
877
878 else if (cmd == IGPCMD_TIME) {
879 // Client received the server time
880- time_offset = boost::lexical_cast<int>(packet.String()) - time(0);
881+ time_offset = boost::lexical_cast<int>(packet.String()) - static_cast<int32_t>(time(0));
882 dedicatedlog("InternetGaming: Server time offset is %i seconds.\n", time_offset);
883 std::string temp = (boost::format(_("Server time offset is %i seconds.")) % time_offset).str();
884 formatAndAddChat("", "", true, temp);
885@@ -579,7 +579,7 @@
886
887 // From now on we wait for a reply from the metaserver
888 waitcmd = IGPCMD_GAME_CONNECT;
889- waittimeout = time(0) + INTERNET_GAMING_TIMEOUT;
890+ waittimeout = static_cast<int32_t>(time(0)) + INTERNET_GAMING_TIMEOUT;
891 }
892
893
894@@ -599,7 +599,7 @@
895
896 // From now on we wait for a reply from the metaserver
897 waitcmd = IGPCMD_GAME_OPEN;
898- waittimeout = time(0) + INTERNET_GAMING_TIMEOUT;
899+ waittimeout = static_cast<int32_t>(time(0)) + INTERNET_GAMING_TIMEOUT;
900 }
901
902
903@@ -616,7 +616,7 @@
904
905 // From now on we wait for a reply from the metaserver
906 waitcmd = IGPCMD_GAME_START;
907- waittimeout = time(0) + INTERNET_GAMING_TIMEOUT;
908+ waittimeout = static_cast<int32_t>(time(0)) + INTERNET_GAMING_TIMEOUT;
909 }
910
911
912
913=== modified file 'src/network/nethost.cc'
914--- src/network/nethost.cc 2012-06-08 22:33:16 +0000
915+++ src/network/nethost.cc 2012-06-12 09:18:28 +0000
916@@ -1313,7 +1313,7 @@
917 info.path = name;
918 info.players = static_cast<uint8_t>(s.get_safe_int("nr_players"));
919 d->settings.saved_games.push_back(info);
920- } catch (_wexception const & e) {}
921+ } catch (_wexception const &) {}
922 }
923 }
924
925@@ -2002,13 +2002,13 @@
926 if (effective_name.empty())
927 effective_name = _("Player");
928
929- if (haveUserName(effective_name, client.usernum)) {
930+ if (haveUserName(effective_name, static_cast<uint8_t>(client.usernum))) {
931 uint32_t i = 2;
932 do {
933 char buf[32];
934 snprintf(buf, sizeof(buf), "%u", i++);
935 effective_name = playername + buf;
936- } while (haveUserName(effective_name, client.usernum));
937+ } while (haveUserName(effective_name, static_cast<uint8_t>(client.usernum)));
938 }
939
940 d->settings.users.at(client.usernum).name = effective_name;
941@@ -2573,7 +2573,7 @@
942 uint8_t nr_players = s.get_safe_int("nr_players");
943
944 d->hp.setMap(gpdp.get_mapname(), path, nr_players, true);
945- } catch (_wexception const & e) {}
946+ } catch (_wexception const &) {}
947 }
948 } else {
949 if (g_fs->FileExists(path)) {
950
951=== modified file 'src/profile/profile.cc'
952--- src/profile/profile.cc 2012-02-15 21:25:34 +0000
953+++ src/profile/profile.cc 2012-06-12 09:18:28 +0000
954@@ -57,11 +57,11 @@
955 Profile g_options(Profile::err_log);
956
957 Section::Value::Value(const char * const nname, const char * const nval) :
958- m_used(false), m_name(strdup(nname)), m_value(strdup(nval))
959+ m_used(false), m_name(_strdup(nname)), m_value(_strdup(nval))
960 {}
961
962 Section::Value::Value(Section::Value const & o) :
963-m_used(o.m_used), m_name(strdup(o.m_name)), m_value(strdup(o.m_value)) {}
964+m_used(o.m_used), m_name(_strdup(o.m_name)), m_value(_strdup(o.m_value)) {}
965
966 Section::Value::~Value()
967 {
968@@ -75,8 +75,8 @@
969 free(m_name);
970 free(m_value);
971 m_used = o.m_used;
972- m_name = strdup(o.m_name);
973- m_value = strdup(o.m_value);
974+ m_name = _strdup(o.m_name);
975+ m_value = _strdup(o.m_value);
976 }
977 return *this;
978 }
979@@ -111,7 +111,7 @@
980 long long int i = strtoll(m_value, &endp, 0);
981 if (*endp or i < 0)
982 throw wexception("%s: '%s' is not natural", get_name(), m_value);
983- return i;
984+ return static_cast<uint32_t>(i);
985 }
986
987
988@@ -121,7 +121,7 @@
989 long long int i = strtoll(m_value, &endp, 0);
990 if (*endp or i < 1)
991 throw wexception("%s: '%s' is not positive", get_name(), m_value);
992- return i;
993+ return static_cast<uint32_t>(i);
994 }
995
996
997@@ -169,13 +169,16 @@
998 ("%s: \"%s\" is not a Coords on a map with size (%u, %u)",
999 get_name(), m_value, extent.w, extent.h);
1000
1001- return Widelands::Coords(x, y);
1002+ return
1003+ Widelands::Coords
1004+ (static_cast<Widelands::X_Coordinate>(x),
1005+ static_cast<Widelands::Y_Coordinate>(y));
1006 }
1007
1008 void Section::Value::set_string(char const * const value)
1009 {
1010 free(m_value);
1011- m_value = strdup(value);
1012+ m_value = _strdup(value);
1013 }
1014
1015
1016@@ -192,12 +195,12 @@
1017 }
1018
1019 Section::Section(Profile * const prof, const char * const name) :
1020-m_profile(prof), m_used(false), m_section_name(strdup(name)) {}
1021+m_profile(prof), m_used(false), m_section_name(_strdup(name)) {}
1022
1023 Section::Section(const Section & o) :
1024 m_profile (o.m_profile),
1025 m_used (o.m_used),
1026- m_section_name(strdup(o.m_section_name)),
1027+ m_section_name(_strdup(o.m_section_name)),
1028 m_values (o.m_values)
1029 {
1030 assert(this != &o);
1031@@ -211,7 +214,7 @@
1032
1033 m_profile = o.m_profile;
1034 m_used = o.m_used;
1035- m_section_name = strdup(o.m_section_name);
1036+ m_section_name = _strdup(o.m_section_name);
1037 m_values = o.m_values;
1038 }
1039
1040@@ -971,7 +974,7 @@
1041 }
1042 }
1043 }
1044- catch (FileNotFound_error const & e) {
1045+ catch (FileNotFound_error const &) {
1046 //It's no problem if the config file does not exist. (It'll get
1047 //written on exit anyway)
1048 log("There's no configuration file, using default values.\n");
1049
1050=== modified file 'src/scripting/lua_map.cc'
1051--- src/scripting/lua_map.cc 2012-06-08 22:33:16 +0000
1052+++ src/scripting/lua_map.cc 2012-06-12 09:18:28 +0000
1053@@ -904,7 +904,7 @@
1054 objname, from_where.c_str());
1055
1056 m = &egbase.create_immovable(c->coords(), imm_idx, &tribe);
1057- } catch (game_data_error & gd) {
1058+ } catch (game_data_error &) {
1059 return
1060 report_error
1061 (L, "Problem loading tribe <%s>. Maybe not existent?",
1062
1063=== modified file 'src/sound/sound_handler.cc'
1064--- src/sound/sound_handler.cc 2012-02-15 21:25:34 +0000
1065+++ src/sound/sound_handler.cc 2012-06-12 09:18:28 +0000
1066@@ -359,7 +359,7 @@
1067 //probability that this fx gets played; initially set according to priority
1068
1069 // float division! not integer
1070- probability = (priority % PRIO_ALLOW_MULTIPLE) / 128.0;
1071+ probability = (priority % PRIO_ALLOW_MULTIPLE) / 128.0f;
1072
1073 //TODO: what to do with fx that happen offscreen?
1074 //TODO: reduce volume? reduce priority? other?
1075
1076=== modified file 'src/text_parser.cc'
1077--- src/text_parser.cc 2012-02-15 21:25:34 +0000
1078+++ src/text_parser.cc 2012-06-12 09:18:28 +0000
1079@@ -299,7 +299,11 @@
1080 long int const red = strtol(r.c_str(), &ptr, 0);
1081 long int const green = strtol(g.c_str(), &ptr, 0);
1082 long int const blue = strtol(b.c_str(), &ptr, 0);
1083- element.set_font_color(RGBColor(red, green, blue));
1084+ element.set_font_color
1085+ (RGBColor
1086+ (static_cast<Uint8>(red),
1087+ static_cast<Uint8>(green),
1088+ static_cast<Uint8>(blue)));
1089 } else if (key == "font-weight")
1090 element.set_font_weight(val);
1091 else if (key == "font-style")
1092
1093=== modified file 'src/ui_basic/checkbox.cc'
1094--- src/ui_basic/checkbox.cc 2012-05-04 15:27:30 +0000
1095+++ src/ui_basic/checkbox.cc 2012-06-12 09:18:28 +0000
1096@@ -141,8 +141,9 @@
1097 void Statebox::handle_mousein(bool const inside) {
1098 bool oldhl = m_flags & Is_Highlighted;
1099 set_flags(Is_Highlighted, inside and m_flags & Is_Enabled);
1100+ bool newhl = m_flags & Is_Highlighted;
1101
1102- if (oldhl != m_flags & Is_Highlighted)
1103+ if (oldhl != newhl)
1104 update();
1105 }
1106
1107
1108=== modified file 'src/ui_basic/editbox.cc'
1109--- src/ui_basic/editbox.cc 2012-02-15 21:25:34 +0000
1110+++ src/ui_basic/editbox.cc 2012-06-12 09:18:28 +0000
1111@@ -396,7 +396,7 @@
1112 {
1113 if (m->text.size() < m->maxLength) {
1114 if (code.unicode < 0x80) // 1 byte char
1115- m->text.insert(m->text.begin() + m->caret++, 1, code.unicode);
1116+ m->text.insert(m->text.begin() + m->caret++, 1, static_cast<char>(code.unicode));
1117 else if (code.unicode < 0x800) { // 2 byte char
1118 m->text.insert
1119 (m->text.begin() + m->caret++, (((code.unicode & 0x7c0) >> 6) | 0xc0));
1120
1121=== modified file 'src/ui_basic/multilinetextarea.cc'
1122--- src/ui_basic/multilinetextarea.cc 2012-06-08 22:33:16 +0000
1123+++ src/ui_basic/multilinetextarea.cc 2012-06-12 09:18:28 +0000
1124@@ -193,7 +193,7 @@
1125 anchor = get_eff_w();
1126 break;
1127 }
1128- m->ww.draw(dst, Point(anchor, -m_scrollbar.get_scrollpos()), m_align);
1129+ m->ww.draw(dst, Point(anchor, -static_cast<int32_t>(m_scrollbar.get_scrollpos())), m_align);
1130 }
1131 }
1132
1133
1134=== modified file 'src/ui_basic/panel.cc'
1135--- src/ui_basic/panel.cc 2012-06-08 22:33:16 +0000
1136+++ src/ui_basic/panel.cc 2012-06-12 09:18:28 +0000
1137@@ -59,7 +59,7 @@
1138 _border_snap_distance(0), _panel_snap_distance(0),
1139 _desired_w(nw), _desired_h(nh),
1140 _running(false),
1141- _tooltip(tooltip_text.size() ? strdup(tooltip_text.c_str()) : 0)
1142+ _tooltip(tooltip_text.size() ? _strdup(tooltip_text.c_str()) : 0)
1143 {
1144 assert(nparent != this);
1145 if (_parent) {
1146@@ -1122,7 +1122,7 @@
1147 assert(not text or *text);
1148 if (_tooltip != text) {
1149 free(_tooltip);
1150- _tooltip = text ? strdup(text) : 0;
1151+ _tooltip = text ? _strdup(text) : 0;
1152 }
1153 }
1154
1155
1156=== modified file 'src/ui_basic/panel.h'
1157--- src/ui_basic/panel.h 2012-02-21 19:36:34 +0000
1158+++ src/ui_basic/panel.h 2012-06-12 09:18:28 +0000
1159@@ -120,7 +120,7 @@
1160 Point to_parent(const Point &) const;
1161
1162 virtual bool is_snap_target() const {return false;}
1163- uint16_t get_border_snap_distance() const {return _border_snap_distance;}
1164+ uint8_t get_border_snap_distance() const {return _border_snap_distance;}
1165 void set_border_snap_distance(uint8_t const value) {
1166 _border_snap_distance = value;
1167 }
1168
1169=== modified file 'src/ui_basic/progressbar.cc'
1170--- src/ui_basic/progressbar.cc 2012-02-15 21:25:34 +0000
1171+++ src/ui_basic/progressbar.cc 2012-06-12 09:18:28 +0000
1172@@ -75,7 +75,7 @@
1173 assert(0 < get_h());
1174 assert(m_total);
1175 const float fraction =
1176- m_state < m_total ? static_cast<float>(m_state) / m_total : 1.0;
1177+ m_state < m_total ? static_cast<float>(m_state / m_total) : 1.0f;
1178 assert(0 <= fraction);
1179 assert (fraction <= 1);
1180
1181
1182=== modified file 'src/ui_basic/scrollbar.cc'
1183--- src/ui_basic/scrollbar.cc 2012-02-15 21:25:34 +0000
1184+++ src/ui_basic/scrollbar.cc 2012-06-12 09:18:28 +0000
1185@@ -234,8 +234,8 @@
1186 int32_t pos;
1187
1188 switch (area) {
1189- case Minus: diff = -m_singlestepsize; break;
1190- case MinusPage: diff = -m_pagesize; break;
1191+ case Minus: diff = -static_cast<int32_t>(m_singlestepsize); break;
1192+ case MinusPage: diff = -static_cast<int32_t>(m_pagesize); break;
1193 case Plus: diff = m_singlestepsize; break;
1194 case PlusPage: diff = m_pagesize; break;
1195 default:
1196
1197=== modified file 'src/ui_fsmenu/internet_lobby.cc'
1198--- src/ui_fsmenu/internet_lobby.cc 2012-02-15 21:25:34 +0000
1199+++ src/ui_fsmenu/internet_lobby.cc 2012-06-12 09:18:28 +0000
1200@@ -369,7 +369,7 @@
1201 if (opengames.has_selection()) {
1202 InternetGaming::ref().join_game(opengames.get_selected().name);
1203
1204- uint32_t const secs = time(0);
1205+ uint32_t const secs = static_cast<int32_t>(time(0));
1206 while (InternetGaming::ref().ip().size() < 1) {
1207 InternetGaming::ref().handle_metaserver_communication();
1208 // give some time for the answer + for a relogin, if a problem occurs.
1209
1210=== modified file 'src/ui_fsmenu/loadgame.cc'
1211--- src/ui_fsmenu/loadgame.cc 2012-03-07 09:39:47 +0000
1212+++ src/ui_fsmenu/loadgame.cc 2012-06-12 09:18:28 +0000
1213@@ -237,7 +237,7 @@
1214 gl.preload_game(gpdp);
1215
1216 m_list.add(FileSystem::FS_FilenameWoExt(name).c_str(), name);
1217- } catch (_wexception const & e) {
1218+ } catch (_wexception const &) {
1219 // we simply skip illegal entries
1220 }
1221 }
1222
1223=== modified file 'src/utf8.h'
1224--- src/utf8.h 2012-02-15 21:25:34 +0000
1225+++ src/utf8.h 2012-06-12 09:18:28 +0000
1226@@ -42,7 +42,7 @@
1227 unsigned char buf[4];
1228
1229 if (unicode < 0x80) {
1230- buf[0] = unicode;
1231+ buf[0] = static_cast<unsigned char>(unicode);
1232 buf[1] = 0;
1233 } else if (unicode < 0x800) {
1234 buf[0] = ((unicode & 0x7c0) >> 6) | 0xc0;
1235
1236=== modified file 'src/wlapplication.cc'
1237--- src/wlapplication.cc 2012-05-27 07:29:33 +0000
1238+++ src/wlapplication.cc 2012-06-12 09:18:28 +0000
1239@@ -998,7 +998,7 @@
1240 for (int i = videomode.size() - 1; result == -1 && i >= 0; --i) {
1241 strcpy(videodrvused + 16, videomode[i].c_str());
1242 videodrvused[16 + videomode[i].size()] = '\0';
1243- putenv(videodrvused);
1244+ _putenv(videodrvused);
1245 log
1246 ("Graphics: Trying Video driver: %i %s %s\n",
1247 i, videomode[i].c_str(), videodrvused);
1248@@ -1932,7 +1932,7 @@
1249 position.state == PlayerSettings::stateComputer))
1250 {
1251 setPlayer(number, player);
1252- setPlayer(settings().playernum, position);
1253+ setPlayer(static_cast<uint8_t>(settings().playernum), position);
1254 s.playernum = number;
1255 }
1256 }
1257
1258=== modified file 'src/wui/chatoverlay.cc'
1259--- src/wui/chatoverlay.cc 2012-06-08 22:33:16 +0000
1260+++ src/wui/chatoverlay.cc 2012-06-12 09:18:28 +0000
1261@@ -95,7 +95,7 @@
1262 */
1263 void ChatOverlay::Impl::recompute()
1264 {
1265- int32_t const now = time(0);
1266+ int32_t const now = static_cast<int32_t>(time(0));
1267
1268 havemessages = false;
1269
1270
1271=== modified file 'src/wui/differential_plot_area.cc'
1272--- src/wui/differential_plot_area.cc 2011-12-06 09:50:16 +0000
1273+++ src/wui/differential_plot_area.cc 2012-06-12 09:18:28 +0000
1274@@ -30,19 +30,23 @@
1275 {}
1276
1277 void DifferentialPlot_Area::draw(RenderTarget & dst) {
1278- float const xline_length = get_inner_w() - space_at_right - spacing;
1279- float const yline_length = get_inner_h() - space_at_bottom - spacing;
1280+ float const xline_length = static_cast<float>
1281+ (get_inner_w() - space_at_right - spacing);
1282+ float const yline_length = static_cast<float>
1283+ (get_inner_h() - space_at_bottom - spacing);
1284+
1285 //yoffset of the zero line
1286- float const yoffset = spacing + ((get_inner_h() - space_at_bottom) - spacing) / 2;
1287+ float const yoffset = static_cast<float>
1288+ (spacing + ((get_inner_h() - space_at_bottom) - spacing) / 2);
1289
1290 uint32_t time_in_ms_ = draw_diagram(dst, xline_length, yline_length);
1291
1292 //draw zero line
1293 dst.draw_line
1294 (get_inner_w() - space_at_right,
1295- yoffset,
1296- get_inner_w() - space_at_right - xline_length,
1297- yoffset,
1298+ static_cast<int32_t>(yoffset),
1299+ get_inner_w() - space_at_right - static_cast<int32_t>(xline_length),
1300+ static_cast<int32_t>(yoffset),
1301 ZERO_LINE_COLOR, 2);
1302
1303 // How many do we take together when relative ploting
1304@@ -137,7 +141,9 @@
1305
1306 //highest_scale represent the space between zero line and top.
1307 //-> half of the whole differential plot area
1308- draw_plot_line(dst, dataset, yline_length, highest_scale * 2, sub, color, yoffset);
1309+ draw_plot_line
1310+ (dst, dataset, yline_length, highest_scale * 2,
1311+ sub, color, static_cast<int32_t>(yoffset));
1312 }
1313 }
1314
1315
1316=== modified file 'src/wui/general_statistics_menu.h'
1317--- src/wui/general_statistics_menu.h 2012-02-15 21:25:34 +0000
1318+++ src/wui/general_statistics_menu.h 2012-06-12 09:18:28 +0000
1319@@ -41,7 +41,7 @@
1320 Registry() :
1321 UI::UniqueWindow::Registry(),
1322 selected_information(0),
1323- selected_players(true, MAX_PLAYERS),
1324+ selected_players(true, static_cast<bool>(MAX_PLAYERS)),
1325 time(WUIPlot_Area::TIME_GAME)
1326 {}
1327
1328
1329=== modified file 'src/wui/interactive_base.cc'
1330--- src/wui/interactive_base.cc 2012-03-07 09:26:02 +0000
1331+++ src/wui/interactive_base.cc 2012-06-12 09:18:28 +0000
1332@@ -332,11 +332,11 @@
1333
1334 if (keyboard_free() && Panel::allow_user_input()) {
1335 if (get_key_state(SDLK_UP) || (get_key_state(SDLK_KP8) && (SDL_GetModState() ^ KMOD_NUM)))
1336- set_rel_viewpoint(Point(0, -scrollval), false);
1337+ set_rel_viewpoint(Point(0, -static_cast<int32_t>(scrollval)), false);
1338 if (get_key_state(SDLK_DOWN) || (get_key_state(SDLK_KP2) && (SDL_GetModState() ^ KMOD_NUM)))
1339 set_rel_viewpoint(Point(0, scrollval), false);
1340 if (get_key_state(SDLK_LEFT) || (get_key_state(SDLK_KP4) && (SDL_GetModState() ^ KMOD_NUM)))
1341- set_rel_viewpoint(Point(-scrollval, 0), false);
1342+ set_rel_viewpoint(Point(-static_cast<int32_t>(scrollval), 0), false);
1343 if (get_key_state(SDLK_RIGHT) || (get_key_state(SDLK_KP6) && (SDL_GetModState() ^ KMOD_NUM)))
1344 set_rel_viewpoint(Point (scrollval, 0), false);
1345 }
1346@@ -461,7 +461,7 @@
1347 assert (c.y < egbase().map().get_height());
1348
1349 const Map & map = egbase().map();
1350- uint32_t const x = (c.x + (c.y & 1) * 0.5) * TRIANGLE_WIDTH;
1351+ uint32_t const x = static_cast<uint32_t>((c.x + (c.y & 1) * 0.5) * TRIANGLE_WIDTH);
1352 uint32_t const y = c.y * TRIANGLE_HEIGHT - map[c].get_height() * HEIGHT_FACTOR;
1353 if (m->minimap.window)
1354 m->mm->set_view_pos(x, y);
1355
1356=== modified file 'src/wui/mapviewpixelfunctions.cc'
1357--- src/wui/mapviewpixelfunctions.cc 2012-02-15 21:25:34 +0000
1358+++ src/wui/mapviewpixelfunctions.cc 2012-06-12 09:18:28 +0000
1359@@ -115,12 +115,12 @@
1360 {
1361 const uint32_t map_end_screen_x = get_map_end_screen_x(map);
1362 if (dx > map_end_screen_x / 2)
1363- dx = -(dx - map_end_screen_x);
1364+ dx = -static_cast<int32_t>(dx - map_end_screen_x);
1365 }
1366 {
1367 const uint32_t map_end_screen_y = get_map_end_screen_y(map);
1368 if (dy > map_end_screen_y / 2)
1369- dy = -(dy - map_end_screen_y);
1370+ dy = -static_cast<int32_t>(dy - map_end_screen_y);
1371 }
1372 return dx + dy;
1373 }
1374
1375=== modified file 'src/wui/multiplayersetupgroup.cc'
1376--- src/wui/multiplayersetupgroup.cc 2012-06-08 22:33:16 +0000
1377+++ src/wui/multiplayersetupgroup.cc 2012-06-12 09:18:28 +0000
1378@@ -78,7 +78,7 @@
1379 /// Switch human players and spectator
1380 void toggle_type() {
1381 UserSettings us = s->settings().users.at(m_id);
1382- int16_t p = us.position;
1383+ uint8_t p = us.position;
1384 if (p == UserSettings::none())
1385 p = -1;
1386
1387
1388=== modified file 'src/wui/plot_area.cc'
1389--- src/wui/plot_area.cc 2012-06-08 22:33:16 +0000
1390+++ src/wui/plot_area.cc 2012-06-12 09:18:28 +0000
1391@@ -86,13 +86,13 @@
1392 // or a multiple of 20h
1393 // or a multiple of 4 days
1394 if (time_in_ms_ > 8 * days) {
1395- time_in_ms_ += - (time_in_ms_ % (4 * days)) + 4 * days;
1396+ time_in_ms_ += -static_cast<int32_t>(time_in_ms_ % (4 * days)) + 4 * days;
1397 } else if (time_in_ms_ > 40 * hours) {
1398- time_in_ms_ += - (time_in_ms_ % (20 * hours)) + 20 * hours;
1399+ time_in_ms_ += -static_cast<int32_t>(time_in_ms_ % (20 * hours)) + 20 * hours;
1400 } else if (time_in_ms_ > 4 * hours) {
1401- time_in_ms_ += - (time_in_ms_ % (2 * hours)) + 2 * hours;
1402+ time_in_ms_ += -static_cast<int32_t>(time_in_ms_ % (2 * hours)) + 2 * hours;
1403 } else {
1404- time_in_ms_ += - (time_in_ms_ % (15 * minutes)) + 15 * minutes;
1405+ time_in_ms_ += -static_cast<int32_t>(time_in_ms_ % (15 * minutes)) + 15 * minutes;
1406 }
1407 return time_in_ms_;
1408 } else {
1409@@ -164,8 +164,8 @@
1410
1411 uint32_t time_in_ms_;
1412
1413- float const xline_length = get_inner_w() - space_at_right - spacing;
1414- float const yline_length = get_inner_h() - space_at_bottom - spacing;
1415+ float const xline_length = static_cast<float>(get_inner_w() - space_at_right - spacing);
1416+ float const yline_length = static_cast<float>(get_inner_h() - space_at_bottom - spacing);
1417
1418
1419 time_in_ms_ = draw_diagram(dst, xline_length, yline_length);
1420@@ -281,7 +281,7 @@
1421 uint32_t const highest_scale, float const sub, RGBColor const color, int32_t const yoffset)
1422 {
1423
1424- float posx = get_inner_w() - space_at_right;
1425+ float posx = static_cast<float>(get_inner_w() - space_at_right);
1426
1427 int32_t lx = get_inner_w() - space_at_right;
1428 int32_t ly = yoffset;
1429@@ -380,7 +380,7 @@
1430 xtickstyle.fg = RGBColor(255, 0, 0);
1431
1432 float sub = xline_length / how_many_ticks;
1433- float posx = get_inner_w() - space_at_right;
1434+ float posx = static_cast<float>(get_inner_w() - space_at_right);
1435
1436 for (uint32_t i = 0; i <= how_many_ticks; ++i) {
1437 dst.draw_line
1438
1439=== modified file 'src/wui/waresqueuedisplay.cc'
1440--- src/wui/waresqueuedisplay.cc 2012-04-20 19:42:28 +0000
1441+++ src/wui/waresqueuedisplay.cc 2012-06-12 09:18:28 +0000
1442@@ -62,7 +62,7 @@
1443
1444 m_icon = ware.icon();
1445 m_icon_grey = g_gr->create_grayed_out_pic(m_icon);
1446- m_icon_grey = g_gr->create_changed_luminosity_pic(m_icon_grey, 0.65);
1447+ m_icon_grey = g_gr->create_changed_luminosity_pic(m_icon_grey, 0.65f);
1448
1449 uint32_t pw, ph;
1450 g_gr->get_picture_size(m_max_fill_indicator, pw, ph);
1451
1452=== modified file 'src/wui/watchwindow.cc'
1453--- src/wui/watchwindow.cc 2012-05-06 16:28:43 +0000
1454+++ src/wui/watchwindow.cc 2012-06-12 09:18:28 +0000
1455@@ -174,7 +174,7 @@
1456 //Calc point on map from coords
1457 Point WatchWindow::calc_coords(Widelands::Coords const coords) {
1458 // Initial positioning
1459- int32_t vx = (coords.x + (coords.y & 1) * 0.5) * TRIANGLE_WIDTH;
1460+ int32_t vx = static_cast<int32_t>(coords.x + (coords.y & 1) * 0.5) * TRIANGLE_WIDTH;
1461 int32_t vy = (coords.y) * TRIANGLE_HEIGHT;
1462 Widelands::Map & map = game().map();
1463 uint8_t height = map[coords].get_height() * HEIGHT_FACTOR;