widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #00827
[Merge] lp:~ab-tools/widelands/msvs2010-compilewarnings into lp:widelands
Andreas Breitschopp has proposed merging lp:~ab-tools/widelands/msvs2010-compilewarnings into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~ab-tools/widelands/msvs2010-compilewarnings/+merge/109787
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.
--
https://code.launchpad.net/~ab-tools/widelands/msvs2010-compilewarnings/+merge/109787
Your team Widelands Developers is requested to review the proposed merge of lp:~ab-tools/widelands/msvs2010-compilewarnings into lp:widelands.
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2012-05-25 20:06:20 +0000
+++ CMakeLists.txt 2012-06-12 09:18:28 +0000
@@ -254,7 +254,7 @@
find_library(INTL_LIBRARY NAMES intl libintl)
- set (MSVC_DISABLE_WARNINGS "/wd4290 /wd4800 /wo4373 /wd4355")
+ set (MSVC_DISABLE_WARNINGS "/wd4290 /wd4800 /wd4373 /wd4355")
# CMAKE only defines "-g", but we need -DDEBUG also, and we need -DNOPARACHUTE (for SDL) in Debug
set (CMAKE_CXX_FLAGS_DEBUG " -DDEBUG -DNOPARACHUTE /MTd /Zi /D_DEBUG ${MSVC_DISABLE_WARNINGS}" CACHE STRING "Set by widelands CMakeLists.txt" FORCE)
=== modified file 'src/ai/ai_hints.cc'
--- src/ai/ai_hints.cc 2012-02-15 21:25:34 +0000
+++ src/ai/ai_hints.cc 2012-06-12 09:18:28 +0000
@@ -44,8 +44,8 @@
{
if (section) {
if (char const * const s = section->get_string("renews_map_resource"))
- renews_map_resource = strdup(s);
+ renews_map_resource = _strdup(s);
if (char const * const s = section->get_string("mines"))
- mines = strdup(s);
+ mines = _strdup(s);
}
}
=== modified file 'src/ai/defaultai.cc'
--- src/ai/defaultai.cc 2012-04-26 15:51:44 +0000
+++ src/ai/defaultai.cc 2012-06-12 09:18:28 +0000
@@ -2347,7 +2347,7 @@
// Attack the selected target.
game().send_player_enemyflagaction
- (target->base_flag(), pn, attackers, retreat);
+ (target->base_flag(), static_cast<Widelands::Player_Number>(pn), attackers, retreat);
// Do not attack again too soon - returning soldiers must get healed first.
next_attack_consideration_due = (gametime % 51 + 10) * 1000 + gametime;
=== modified file 'src/editor/editorinteractive.cc'
--- src/editor/editorinteractive.cc 2012-05-06 16:28:43 +0000
+++ src/editor/editorinteractive.cc 2012-06-12 09:18:28 +0000
@@ -219,7 +219,7 @@
// Run the editor initialization script, if any
try {
egbase().lua().run_script("map", "editor_init");
- } catch (LuaScriptNotExistingError & e) {
+ } catch (LuaScriptNotExistingError &) {
// do nothing.
}
egbase().map().overlay_manager().show_buildhelp(true);
=== modified file 'src/editor/ui_menus/editor_main_menu_random_map.cc'
--- src/editor/ui_menus/editor_main_menu_random_map.cc 2012-04-27 17:07:48 +0000
+++ src/editor/ui_menus/editor_main_menu_random_map.cc 2012-06-12 09:18:28 +0000
@@ -523,8 +523,8 @@
if (MAP_DIMENSIONS[ix] == mapInfo.w)
m_w = ix;
- m_landval = mapInfo.landRatio * 100.0 + 0.49;
- m_waterval = mapInfo.waterRatio * 100.0 + 0.49;
+ m_landval = static_cast<int32_t>(mapInfo.landRatio * 100.0 + 0.49);
+ m_waterval = static_cast<int32_t>(mapInfo.waterRatio * 100.0 + 0.49);
m_res_amount = mapInfo.resource_amount;
m_res->set_title(m_res_amounts[m_res_amount].c_str());
=== modified file 'src/graphic/animation.cc'
--- src/graphic/animation.cc 2012-02-15 21:25:34 +0000
+++ src/graphic/animation.cc 2012-06-12 09:18:28 +0000
@@ -131,7 +131,7 @@
while (Section::Value * const v = s.get_next_val("sfx")) {
char * parameters = v->get_string(), * endp;
unsigned long long int const value = strtoull(parameters, &endp, 0);
- uint32_t const frame_number = value;
+ uint32_t const frame_number = static_cast<uint32_t>(value);
try {
if (endp == parameters or frame_number != value)
throw wexception
=== modified file 'src/graphic/graphic.cc'
--- src/graphic/graphic.cc 2012-03-09 16:57:20 +0000
+++ src/graphic/graphic.cc 2012-06-12 09:18:28 +0000
@@ -553,8 +553,8 @@
else // average
ratio = (ratio_x + ratio_y) / 2;
- uint32_t fullwidth(src->get_w() * ratio);
- uint32_t fullheight(src->get_h() * ratio);
+ uint32_t fullwidth(static_cast<uint32_t>(src->get_w() * ratio));
+ uint32_t fullheight(static_cast<uint32_t>(src->get_h() * ratio));
if (fullwidth <= w) {
srcrect.x = 0;
@@ -1000,9 +1000,9 @@
if (halve_alpha)
color.a >>= 1;
- color.r = color.r * factor > 255 ? 255 : color.r * factor;
- color.g = color.g * factor > 255 ? 255 : color.g * factor;
- color.b = color.b * factor > 255 ? 255 : color.b * factor;
+ color.r = (color.r * factor) > 255 ? 255 : static_cast<Uint8>(color.r * factor);
+ color.g = (color.g * factor) > 255 ? 255 : static_cast<Uint8>(color.g * factor);
+ color.b = (color.b * factor) > 255 ? 255 : static_cast<Uint8>(color.b * factor);
destpix.set_pixel(x, y, color.map(destfmt));
}
=== modified file 'src/graphic/render/gameview.cc'
--- src/graphic/render/gameview.cc 2012-06-08 22:33:16 +0000
+++ src/graphic/render/gameview.cc 2012-06-12 09:18:28 +0000
@@ -65,7 +65,7 @@
static_cast<Sint16>
(((static_cast<Sint16>(result) + 128) >> 1)
*
- (1.0 + (time_ago < 45000 ? expf(-8.46126929e-5 * time_ago) : 0)))
+ (1.0f + (time_ago < 45000 ? expf(-8.46126929e-5f * time_ago) : 0)))
-
128;
}
=== modified file 'src/graphic/render/gl_picture_texture.cc'
--- src/graphic/render/gl_picture_texture.cc 2012-02-15 21:25:34 +0000
+++ src/graphic/render/gl_picture_texture.cc 2012-06-12 09:18:28 +0000
@@ -80,8 +80,8 @@
} else {
pixels_format = GL_RGBA;
// Read four bytes per pixel but ignore the alpha value
- glPixelTransferi(GL_ALPHA_SCALE, 0.0f);
- glPixelTransferi(GL_ALPHA_BIAS, 1.0f);
+ glPixelTransferi(GL_ALPHA_SCALE, 0);
+ glPixelTransferi(GL_ALPHA_BIAS, 1);
}
} else if
(fmt.Bmask == 0x000000ff and fmt.Gmask == 0x0000ff00 and
@@ -92,8 +92,8 @@
} else {
pixels_format = GL_BGRA;
// Read four bytes per pixel but ignore the alpha value
- glPixelTransferi(GL_ALPHA_SCALE, 0.0f);
- glPixelTransferi(GL_ALPHA_BIAS, 1.0f);
+ glPixelTransferi(GL_ALPHA_SCALE, 0);
+ glPixelTransferi(GL_ALPHA_BIAS, 1);
}
} else
throw wexception("OpenGL: Unknown pixel format");
=== modified file 'src/graphic/render/gl_surface_screen.cc'
--- src/graphic/render/gl_surface_screen.cc 2012-02-15 21:25:34 +0000
+++ src/graphic/render/gl_surface_screen.cc 2012-06-12 09:18:28 +0000
@@ -141,10 +141,10 @@
glBegin(GL_LINE_LOOP); {
glColor3ub(clr.r(), clr.g(), clr.b());
- glVertex2f(rc.x + 0.5f, rc.y + 0.5f);
- glVertex2f(rc.x + rc.w - 0.5f, rc.y + 0.5f);
- glVertex2f(rc.x + rc.w - 0.5f, rc.y + rc.h - 0.5f);
- glVertex2f(rc.x + 0.5f, rc.y + rc.h - 0.5f);
+ glVertex2f(static_cast<float>(rc.x + 0.5f), static_cast<float>(rc.y + 0.5f));
+ glVertex2f(static_cast<float>(rc.x + rc.w - 0.5f), static_cast<float>(rc.y + 0.5f));
+ glVertex2f(static_cast<float>(rc.x + rc.w - 0.5f), static_cast<float>(rc.y + rc.h - 0.5f));
+ glVertex2f(static_cast<float>(rc.x + 0.5f), static_cast<float>(rc.y + rc.h - 0.5f));
} glEnd();
glEnable(GL_TEXTURE_2D);
}
@@ -165,10 +165,10 @@
glBegin(GL_QUADS); {
glColor4ub(clr.r, clr.g, clr.b, clr.a);
- glVertex2f(rc.x, rc.y);
- glVertex2f(rc.x + rc.w, rc.y);
- glVertex2f(rc.x + rc.w, rc.y + rc.h);
- glVertex2f(rc.x, rc.y + rc.h);
+ glVertex2f(static_cast<float>(rc.x), static_cast<float>(rc.y));
+ glVertex2f(static_cast<float>(rc.x + rc.w), static_cast<float>(rc.y));
+ glVertex2f(static_cast<float>(rc.x + rc.w), static_cast<float>(rc.y + rc.h));
+ glVertex2f(static_cast<float>(rc.x), static_cast<float>(rc.y + rc.h));
} glEnd();
glEnable(GL_TEXTURE_2D);
}
@@ -213,13 +213,13 @@
// (this is the source color) over the region
glBegin(GL_QUADS); {
glColor3f
- ((fabsf(factor) / 256.0f),
- (fabsf(factor) / 256.0f),
- (fabsf(factor) / 256.0f));
- glVertex2f(rc.x, rc.y);
- glVertex2f(rc.x + rc.w, rc.y);
- glVertex2f(rc.x + rc.w, rc.y + rc.h);
- glVertex2f(rc.x, rc.y + rc.h);
+ ((fabsf(static_cast<float>(factor)) / 256.0f),
+ (fabsf(static_cast<float>(factor)) / 256.0f),
+ (fabsf(static_cast<float>(factor)) / 256.0f));
+ glVertex2f(static_cast<float>(rc.x), static_cast<float>(rc.y));
+ glVertex2f(static_cast<float>(rc.x + rc.w), static_cast<float>(rc.y));
+ glVertex2f(static_cast<float>(rc.x + rc.w), static_cast<float>(rc.y + rc.h));
+ glVertex2f(static_cast<float>(rc.x), static_cast<float>(rc.y + rc.h));
} glEnd();
if (factor < 0)
@@ -289,19 +289,19 @@
glBegin(GL_QUADS); {
// set color white, otherwise textures get mixed with color
- glColor3f(1.0, 1.0, 1.0);
+ glColor3f(1.0f, 1.0f, 1.0f);
// top-left
glTexCoord2i(srcrc.x, srcrc.y);
glVertex2i (dst.x, dst.y);
// top-right
glTexCoord2i(srcrc.x + srcrc.w, srcrc.y);
- glVertex2f (dst.x + srcrc.w, dst.y);
+ glVertex2f (static_cast<float>(dst.x + srcrc.w), static_cast<float>(dst.y));
// bottom-right
glTexCoord2i(srcrc.x + srcrc.w, srcrc.y + srcrc.h);
- glVertex2f (dst.x + srcrc.w, dst.y + srcrc.h);
+ glVertex2f (static_cast<float>(dst.x + srcrc.w), static_cast<float>(dst.y + srcrc.h));
// bottom-left
- glTexCoord2i(srcrc.x, srcrc.y + srcrc.h);
- glVertex2f (dst.x, dst.y + srcrc.h);
+ glTexCoord2i(srcrc.x, srcrc.y + srcrc.h);
+ glVertex2f (static_cast<float>(dst.x), static_cast<float>(dst.y + srcrc.h));
} glEnd();
glLoadIdentity();
=== modified file 'src/graphic/render/render_sdl.cc'
--- src/graphic/render/render_sdl.cc 2012-02-15 21:25:34 +0000
+++ src/graphic/render/render_sdl.cc 2012-06-12 09:18:28 +0000
@@ -155,7 +155,11 @@
r = ~r >> 24;
*reinterpret_cast<Uint32 *>(pix) =
- SDL_MapRGB(m_surface->format, r, g, b);
+ SDL_MapRGB
+ (m_surface->format,
+ static_cast<Uint8>(r),
+ static_cast<Uint8>(g),
+ static_cast<Uint8>(b));
}
} else if (m_surface->format->BytesPerPixel == 2) {
for (int32_t y = rc.y; y < bl.y; ++y)
@@ -180,7 +184,11 @@
r = ~r >> 24;
*reinterpret_cast<Uint16 *>(pix) =
- SDL_MapRGB(m_surface->format, r, g, b);
+ SDL_MapRGB
+ (m_surface->format,
+ static_cast<Uint8>(r),
+ static_cast<Uint8>(g),
+ static_cast<Uint8>(b));
}
}
unlock(IPixelAccess::Unlock_Update);
=== modified file 'src/graphic/render/terrain_opengl.h'
--- src/graphic/render/terrain_opengl.h 2012-02-21 13:51:08 +0000
+++ src/graphic/render/terrain_opengl.h 2012-06-12 09:18:28 +0000
@@ -150,40 +150,67 @@
glBegin(GL_TRIANGLES); {
{
- GLfloat const brightness = (150.0 + p1.b) / 150.0;
+ GLfloat const brightness = (150.0f + p1.b) / 150.0f;
glColor3f(brightness, brightness, brightness);
}
glMultiTexCoord2iARB(GL_TEXTURE0_ARB, t1.tx, t1.ty);
- glMultiTexCoord2fARB(GL_TEXTURE1_ARB, t1.tx / TEXTURE_WIDTH, t1.ty / TEXTURE_WIDTH);
+ glMultiTexCoord2fARB
+ (GL_TEXTURE1_ARB,
+ static_cast<float>(t1.tx / TEXTURE_WIDTH),
+ static_cast<float>(t1.ty / TEXTURE_WIDTH));
glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 0, 0);
- glMultiTexCoord2fARB(GL_TEXTURE3_ARB, t1.tx / TEXTURE_WIDTH, t1.ty / TEXTURE_WIDTH);
+ glMultiTexCoord2fARB
+ (GL_TEXTURE3_ARB,
+ static_cast<float>(t1.tx / TEXTURE_WIDTH),
+ static_cast<float>(t1.ty / TEXTURE_WIDTH));
glMultiTexCoord2fARB(GL_TEXTURE4_ARB, 1, 0);
- glMultiTexCoord2fARB(GL_TEXTURE5_ARB, t1.tx / TEXTURE_WIDTH, t1.ty / TEXTURE_WIDTH);
- glVertex2f(t1.x, t1.y);
+ glMultiTexCoord2fARB
+ (GL_TEXTURE5_ARB,
+ static_cast<float>(t1.tx / TEXTURE_WIDTH),
+ static_cast<float>(t1.ty / TEXTURE_WIDTH));
+ glVertex2f(static_cast<float>(t1.x), static_cast<float>(t1.y));
{
- GLfloat const brightness = (150.0 + p2.b) / 150.0;
+ GLfloat const brightness = (150.0f + p2.b) / 150.0f;
glColor3f(brightness, brightness, brightness);
}
glMultiTexCoord2iARB(GL_TEXTURE0_ARB, t2.tx, t2.ty);
- glMultiTexCoord2fARB(GL_TEXTURE1_ARB, t2.tx / TEXTURE_WIDTH, t2.ty / TEXTURE_WIDTH);
+ glMultiTexCoord2fARB
+ (GL_TEXTURE1_ARB,
+ static_cast<float>(t2.tx / TEXTURE_WIDTH),
+ static_cast<float>(t2.ty / TEXTURE_WIDTH));
glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 0.5, 1);
- glMultiTexCoord2fARB(GL_TEXTURE3_ARB, t2.tx / TEXTURE_WIDTH, t2.ty / TEXTURE_WIDTH);
+ glMultiTexCoord2fARB
+ (GL_TEXTURE3_ARB,
+ static_cast<float>(t2.tx / TEXTURE_WIDTH),
+ static_cast<float>(t2.ty / TEXTURE_WIDTH));
glMultiTexCoord2fARB(GL_TEXTURE4_ARB, 0, 0);
- glMultiTexCoord2fARB(GL_TEXTURE5_ARB, t2.tx / TEXTURE_WIDTH, t2.ty / TEXTURE_WIDTH);
- glVertex2f(t2.x, t2.y);
+ glMultiTexCoord2fARB
+ (GL_TEXTURE5_ARB,
+ static_cast<float>(t2.tx / TEXTURE_WIDTH),
+ static_cast<float>(t2.ty / TEXTURE_WIDTH));
+ glVertex2f(static_cast<float>(t2.x), static_cast<float>(t2.y));
{
- GLfloat const brightness = (150.0 + p3.b) / 150.0;
+ GLfloat const brightness = (150.0f + p3.b) / 150.0f;
glColor3f(brightness, brightness, brightness);
}
glMultiTexCoord2iARB(GL_TEXTURE0_ARB, t3.tx, t3.ty);
- glMultiTexCoord2fARB(GL_TEXTURE1_ARB, t3.tx / TEXTURE_WIDTH, t3.ty / TEXTURE_WIDTH);
+ glMultiTexCoord2fARB
+ (GL_TEXTURE1_ARB,
+ static_cast<float>(t3.tx / TEXTURE_WIDTH),
+ static_cast<float>(t3.ty / TEXTURE_WIDTH));
glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 1, 0);
- glMultiTexCoord2fARB(GL_TEXTURE3_ARB, t3.tx / TEXTURE_WIDTH, t3.ty / TEXTURE_WIDTH);
+ glMultiTexCoord2fARB
+ (GL_TEXTURE3_ARB,
+ static_cast<float>(t3.tx / TEXTURE_WIDTH),
+ static_cast<float>(t3.ty / TEXTURE_WIDTH));
glMultiTexCoord2fARB(GL_TEXTURE4_ARB, 0.5, 1);
- glMultiTexCoord2fARB(GL_TEXTURE5_ARB, t3.tx / TEXTURE_WIDTH, t3.ty / TEXTURE_WIDTH);
- glVertex2f(t3.x, t3.y);
+ glMultiTexCoord2fARB
+ (GL_TEXTURE5_ARB,
+ static_cast<float>(t3.tx / TEXTURE_WIDTH),
+ static_cast<float>(t3.ty / TEXTURE_WIDTH));
+ glVertex2f(static_cast<float>(t3.x), static_cast<float>(t3.y));
} glEnd();
// Cleanup OpenGL
@@ -211,54 +238,54 @@
glBindTexture(GL_TEXTURE_2D, texture.getTexture());
glBegin(GL_TRIANGLES); {
{
- GLfloat const brightness = (150.0 + p1.b) / 150.0;
+ GLfloat const brightness = (150.0f + p1.b) / 150.0f;
glColor3f(brightness, brightness, brightness);
}
glTexCoord2i(t1.tx, t1.ty);
- glVertex2f(t1.x, t1.y);
+ glVertex2f(static_cast<float>(t1.x), static_cast<float>(t1.y));
{
- GLfloat const brightness = (150.0 + p2.b) / 150.0;
+ GLfloat const brightness = (150.0f + p2.b) / 150.0f;
glColor3f(brightness, brightness, brightness);
}
glTexCoord2i(t2.tx, t2.ty);
- glVertex2f(t2.x, t2.y);
+ glVertex2f(static_cast<float>(t2.x), static_cast<float>(t2.y));
{
- GLfloat const brightness = (150.0 + p3.b) / 150.0;
+ GLfloat const brightness = (150.0f + p3.b) / 150.0f;
glColor3f(brightness, brightness, brightness);
}
glTexCoord2i(t3.tx, t3.ty);
- glVertex2f(t3.x, t3.y);
+ glVertex2f(static_cast<float>(t3.x), static_cast<float>(t3.y));
} glEnd();
}
}
-#define horiz_road_opengl(tex, start, end) \
- glBindTexture( GL_TEXTURE_2D, tex); \
- glBegin(GL_QUADS); { \
- glTexCoord2i(0, 0); \
- glVertex2f(subwin.x + start.x, subwin.y + start.y - 2); \
- glTexCoord2i(TEXTURE_WIDTH, 0); \
- glVertex2f(subwin.x + end.x, subwin.y + end.y - 2); \
- glTexCoord2i(TEXTURE_WIDTH, 4); \
- glVertex2f(subwin.x + end.x, subwin.y + end.y + 2); \
- glTexCoord2i(0, 4); \
- glVertex2f(subwin.x + start.x, subwin.y + start.y + 2); \
- } glEnd(); \
+#define horiz_road_opengl(tex, start, end) \
+ glBindTexture(GL_TEXTURE_2D, tex); \
+ glBegin(GL_QUADS); { \
+ glTexCoord2i(0, 0); \
+ glVertex2f(static_cast<float>(subwin.x + start.x), static_cast<float>(subwin.y + start.y - 2)); \
+ glTexCoord2i(TEXTURE_WIDTH, 0); \
+ glVertex2f(static_cast<float>(subwin.x + end.x), static_cast<float>(subwin.y + end.y - 2)); \
+ glTexCoord2i(TEXTURE_WIDTH, 4); \
+ glVertex2f(static_cast<float>(subwin.x + end.x), static_cast<float>(subwin.y + end.y + 2)); \
+ glTexCoord2i(0, 4); \
+ glVertex2f(static_cast<float>(subwin.x + start.x), static_cast<float>(subwin.y + start.y + 2)); \
+ } glEnd(); \
-#define vert_road_opengl(tex, start, end) \
- glBindTexture( GL_TEXTURE_2D, tex); \
- glBegin(GL_QUADS); { \
- glTexCoord2i(0, 0); \
- glVertex2f(subwin.x + start.x - 3, subwin.y + start.y); \
- glTexCoord2i(6, 0); \
- glVertex2f(subwin.x + start.x + 3, subwin.y + start.y); \
- glTexCoord2i(TEXTURE_WIDTH, TEXTURE_HEIGHT); \
- glVertex2f(subwin.x + end.x + 3, subwin.y + end.y); \
- glTexCoord2i(TEXTURE_WIDTH - 6, TEXTURE_HEIGHT); \
- glVertex2f(subwin.x + end.x - 3, subwin.y + end.y); \
- } glEnd(); \
+#define vert_road_opengl(tex, start, end) \
+ glBindTexture( GL_TEXTURE_2D, tex); \
+ glBegin(GL_QUADS); { \
+ glTexCoord2i(0, 0); \
+ glVertex2f(static_cast<float>(subwin.x + start.x - 3), static_cast<float>(subwin.y + start.y)); \
+ glTexCoord2i(6, 0); \
+ glVertex2f(static_cast<float>(subwin.x + start.x + 3), static_cast<float>(subwin.y + start.y)); \
+ glTexCoord2i(TEXTURE_WIDTH, TEXTURE_HEIGHT); \
+ glVertex2f(static_cast<float>(subwin.x + end.x + 3), static_cast<float>(subwin.y + end.y)); \
+ glTexCoord2i(TEXTURE_WIDTH - 6, TEXTURE_HEIGHT); \
+ glVertex2f(static_cast<float>(subwin.x + end.x - 3), static_cast<float>(subwin.y + end.y)); \
+ } glEnd(); \
void draw_roads_opengl
(Rect & subwin,
=== modified file 'src/graphic/render/terrain_sdl.cc'
--- src/graphic/render/terrain_sdl.cc 2012-02-15 21:25:34 +0000
+++ src/graphic/render/terrain_sdl.cc 2012-06-12 09:18:28 +0000
@@ -27,7 +27,7 @@
{
float det;
- det = u1 * v2 - u2 * v1; // determinant of (u v)
+ det = static_cast<float>(u1 * v2 - u2 * v1); // determinant of (u v)
lambda = v2 / det; // by Cramer's rule
mu = -u2 / det;
=== modified file 'src/graphic/rendertarget.cc'
--- src/graphic/rendertarget.cc 2012-03-15 21:41:48 +0000
+++ src/graphic/rendertarget.cc 2012-06-12 09:18:28 +0000
@@ -345,7 +345,7 @@
gfx->get_frame
(0);
- PictureID dark_frame = g_gr->create_changed_luminosity_pic(frame, 1.22, true);
+ PictureID dark_frame = g_gr->create_changed_luminosity_pic(frame, 1.22f, true);
dst -= Point(frame->get_w() / 2, frame->get_h() / 2);
=== modified file 'src/graphic/texture.cc'
--- src/graphic/texture.cc 2012-02-16 01:09:34 +0000
+++ src/graphic/texture.cc 2012-06-12 09:18:28 +0000
@@ -74,7 +74,7 @@
SDL_Surface * surf;
- m_texture_picture = strdup(fname);
+ m_texture_picture = _strdup(fname);
FileRead fr;
=== modified file 'src/i18n.cc'
--- src/i18n.cc 2012-04-06 19:26:17 +0000
+++ src/i18n.cc 2012-06-12 09:18:28 +0000
@@ -183,7 +183,7 @@
locale = lang;
#endif
#ifdef _WIN32
- putenv(const_cast<char *>((std::string("LANG=") + lang).c_str()));
+ _putenv(const_cast<char *>((std::string("LANG=") + lang).c_str()));
locale = lang;
#endif
=== modified file 'src/io/filesystem/disk_filesystem.cc'
--- src/io/filesystem/disk_filesystem.cc 2012-05-08 12:35:24 +0000
+++ src/io/filesystem/disk_filesystem.cc 2012-06-12 09:18:28 +0000
@@ -347,7 +347,7 @@
("a file with the name \"%s\" already exists", dirname.c_str());
if
- (mkdir
+ (_mkdir
#ifdef WIN32
(fspath.c_str())
#else
=== modified file 'src/io/filesystem/filesystem.cc'
--- src/io/filesystem/filesystem.cc 2012-06-08 12:50:14 +0000
+++ src/io/filesystem/filesystem.cc 2012-06-12 09:18:28 +0000
@@ -145,7 +145,7 @@
*/
std::string FileSystem::getWorkingDirectory() const {
char cwd[PATH_MAX + 1];
- char * const result = getcwd(cwd, PATH_MAX);
+ char * const result = _getcwd(cwd, PATH_MAX);
if (! result)
throw File_error("FileSystem::getWorkingDirectory()", "widelands", "can not run getcwd");
=== modified file 'src/journal.h'
--- src/journal.h 2012-02-15 21:25:34 +0000
+++ src/journal.h 2012-06-12 09:18:28 +0000
@@ -92,7 +92,7 @@
* Returns the position in the playback file
* \return byte offset into the playback file, used with file reading
*/
- int32_t get_playback_offset() {return m_playbackstream.tellg();}
+ int32_t get_playback_offset() {return static_cast<int32_t>(m_playbackstream.tellg());}
void write(int8_t);
void write(uint8_t);
=== modified file 'src/logic/cmd_luascript.cc'
--- src/logic/cmd_luascript.cc 2012-02-15 21:25:34 +0000
+++ src/logic/cmd_luascript.cc 2012-06-12 09:18:28 +0000
@@ -30,7 +30,7 @@
log("Trying to run: %s, %s: ", m_ns.c_str(), m_script.c_str());
try {
game.lua().run_script(m_ns, m_script);
- } catch (LuaScriptNotExistingError & e) {
+ } catch (LuaScriptNotExistingError &) {
// The script has not been found.
log("not found.\n");
return;
=== modified file 'src/logic/game.cc'
--- src/logic/game.cc 2012-06-06 19:32:13 +0000
+++ src/logic/game.cc 2012-06-12 09:18:28 +0000
@@ -110,7 +110,7 @@
if (m_dump) {
try {
m_dump->Data(data, size);
- } catch (_wexception const & e) {
+ } catch (_wexception const &) {
log
("Writing to syncstream file %s failed. Stop synctream dump.\n",
m_dumpfname.c_str());
=== modified file 'src/logic/immovable.cc'
--- src/logic/immovable.cc 2012-06-08 22:33:16 +0000
+++ src/logic/immovable.cc 2012-06-12 09:18:28 +0000
@@ -857,7 +857,7 @@
if (not reached_end) {
char * endp;
unsigned long long int const value = strtoull(parameters, &endp, 0);
- priority = value;
+ priority = static_cast<uint8_t>(value);
if (*endp or priority != value)
throw game_data_error
(_("expected %s but found \"%s\""), _("priority"), parameters);
@@ -901,7 +901,7 @@
("expected probability in range [1, 254] but found "
"\"%s\""),
params[i].c_str());
- probability = value;
+ probability = static_cast<uint8_t>(value);
} else {
std::vector<std::string> segments = split_string(params[i], ":");
@@ -1024,7 +1024,7 @@
throw game_data_error
(_("expected %s but found \"%s\""),
_("probability in range [1, 254]"), parameters);
- probability = value;
+ probability = static_cast<uint8_t>(value);
} else
probability = 0;
} catch (_wexception const & e) {
@@ -1080,7 +1080,7 @@
("expected probability in range [1, 254] but found "
"\"%s\""),
p);
- probability = value;
+ probability = static_cast<uint8_t>(value);
// fallthrough
}
case '\0':
=== modified file 'src/logic/military_data.cc'
--- src/logic/military_data.cc 2012-02-15 21:25:34 +0000
+++ src/logic/military_data.cc 2012-06-12 09:18:28 +0000
@@ -52,12 +52,12 @@
container_iterate(std::vector<std::string>, list, i)
remove_spaces(*i.current);
char * endp;
- m_min_retreat = strtol(list[0].c_str(), &endp, 0);
+ m_min_retreat = static_cast<uint8_t>(strtol(list[0].c_str(), &endp, 0));
if (*endp or m_min_retreat > 100)
throw game_data_error
(_("expected %s but found \"%s\""),
_("positive integer <= 100"), list[0].c_str());
- m_max_retreat = strtol(list[1].c_str(), &endp, 0);
+ m_max_retreat = static_cast<uint8_t>(strtol(list[1].c_str(), &endp, 0));
if (*endp or m_max_retreat > 100 or m_max_retreat < m_min_retreat)
throw game_data_error
(_("expected positive integer >= %u <= 100 but found \"%s\""),
=== modified file 'src/logic/production_program.cc'
--- src/logic/production_program.cc 2012-06-08 22:33:16 +0000
+++ src/logic/production_program.cc 2012-06-12 09:18:28 +0000
@@ -108,7 +108,7 @@
++parameters;
char * endp;
unsigned long long int const value = strtoull(parameters, &endp, 0);
- count = value;
+ count = static_cast<uint8_t>(value);
if ((*endp and *endp != ' ') or value < 1 or count != value)
throw game_data_error
(_("expected %s but found \"%s\""), _("count"), parameters);
@@ -639,7 +639,7 @@
if (*parameters) {
char * endp;
long long int const value = strtoll(parameters, &endp, 0);
- m_duration = value;
+ m_duration = static_cast<Widelands::Duration>(value);
if (*endp or value <= 0 or m_duration != value)
throw game_data_error
(_("expected %s but found \"%s\""),
@@ -712,7 +712,7 @@
if (not reached_end) { // The next parameter is the duration.
char * endp;
long long int const value = strtoll(parameters, &endp, 0);
- m_duration = value;
+ m_duration = static_cast<Widelands::Duration>(value);
if (*endp or value <= 0 or m_duration != value)
throw game_data_error
(_("expected %s but found \"%s\""),
@@ -866,7 +866,7 @@
char * endp;
unsigned long long int const value =
strtoull(parameters, &endp, 0);
- item.second = value;
+ item.second = static_cast<uint8_t>(value);
if
((*endp and *endp != ' ')
or
@@ -961,7 +961,7 @@
char * endp;
unsigned long long int const value =
strtoull(parameters, &endp, 0);
- item.second = value;
+ item.second = static_cast<uint8_t>(value);
if
((*endp and *endp != ' ')
or
@@ -1043,7 +1043,7 @@
{
char * endp;
unsigned long long int const value = strtoull(parameters, &endp, 0);
- m_distance = value;
+ m_distance = static_cast<uint8_t>(value);
if (*endp != ' ' or m_distance != value)
throw game_data_error
(_("expected %s but found \"%s\""), _("distance"), parameters);
@@ -1053,7 +1053,7 @@
{
char * endp;
unsigned long long int const value = strtoull(parameters, &endp, 0);
- m_max = value;
+ m_max = static_cast<uint8_t>(value);
if (*endp != ' ' or value < 1 or 100 < value)
throw game_data_error
(_("expected %s but found \"%s\""),
@@ -1064,7 +1064,7 @@
{
char * endp;
unsigned long long int const value = strtoull(parameters, &endp, 0);
- m_chance = value;
+ m_chance = static_cast<uint8_t>(value);
if (*endp or value < 1 or 100 < value)
throw game_data_error
(_("expected %s but found \"%s\""),
@@ -1241,7 +1241,7 @@
char * endp;
unsigned long long int const value = strtoull(parameters, &endp, 0);
- level = value;
+ level = static_cast<uint8_t>(value);
if (*endp or level != value)
throw game_data_error
(_("expected %s but found \"%s\""), _("level"), parameters);
@@ -1313,7 +1313,7 @@
{
char * endp;
unsigned long long int const value = strtoull(parameters, &endp, 0);
- level = value;
+ level = static_cast<uint8_t>(value);
if (*endp != ' ' or level != value)
throw game_data_error
(_("expected %s but found \"%s\""), _("level"), parameters);
@@ -1323,7 +1323,7 @@
{
char * endp;
unsigned long long int const value = strtoull(parameters, &endp, 0);
- target_level = value;
+ target_level = static_cast<uint8_t>(value);
if (*endp or target_level != value or target_level <= level)
throw game_data_error
(_("expected level > %u but found \"%s\""), level, parameters);
@@ -1401,7 +1401,7 @@
if (not reached_end) {
char * endp;
unsigned long long int const value = strtoull(parameters, &endp, 0);
- priority = value;
+ priority = static_cast<uint8_t>(value);
if (*endp or priority != value)
throw game_data_error
(_("expected %s but found \"%s\""), _("priority"), parameters);
=== modified file 'src/logic/soldier.cc'
--- src/logic/soldier.cc 2012-06-06 19:32:13 +0000
+++ src/logic/soldier.cc 2012-06-12 09:18:28 +0000
@@ -607,10 +607,10 @@
// Draw level pictures
{
- dst.blit(pt + Point(-atw, -(hph + ath)), attackpic);
- dst.blit(pt + Point(0, -(evh + deh)), defensepic);
- dst.blit(pt + Point(-hpw, -hph), hppic);
- dst.blit(pt + Point(0, -evh), evadepic);
+ dst.blit(pt + Point(-static_cast<int32_t>(atw), -static_cast<int32_t>(hph + ath)), attackpic);
+ dst.blit(pt + Point(0, -static_cast<int32_t>(evh + deh)), defensepic);
+ dst.blit(pt + Point(-static_cast<int32_t>(hpw), -static_cast<int32_t>(hph)), hppic);
+ dst.blit(pt + Point(0, -static_cast<int32_t>(evh)), evadepic);
}
}
=== modified file 'src/logic/soldier.h'
--- src/logic/soldier.h 2012-02-15 21:25:34 +0000
+++ src/logic/soldier.h 2012-06-12 09:18:28 +0000
@@ -198,6 +198,7 @@
void init_auto_task(Game &);
Point calc_drawpos(Editor_Game_Base const &, Point) const;
+
/// Draw this soldier
virtual void draw
(const Editor_Game_Base &, RenderTarget &, const Point) const;
=== modified file 'src/logic/world.cc'
--- src/logic/world.cc 2012-06-09 22:12:30 +0000
+++ src/logic/world.cc 2012-06-12 09:18:28 +0000
@@ -907,7 +907,7 @@
(fnametmpl, sizeof(fnametmpl),
"%s/pics/%s_??.png", directory, m_name.c_str());
- m_picnametempl = strdup(fnametmpl);
+ m_picnametempl = _strdup(fnametmpl);
}
Terrain_Descr::~Terrain_Descr()
=== modified file 'src/map_generator.cc'
--- src/map_generator.cc 2012-02-15 21:25:34 +0000
+++ src/map_generator.cc 2012-06-12 09:18:28 +0000
@@ -207,15 +207,17 @@
double const land_fac = m_mapInfo.landRatio;
uint8_t res_h =
- elevation < water_fac ? water_h :
+ elevation < water_fac ? static_cast<uint8_t>(water_h) :
elevation < water_fac + land_fac ?
- water_h + 1 +
- ((elevation - water_fac) / land_fac) * (mount_h - water_h)
+ static_cast<uint8_t>
+ (water_h + 1 +
+ ((elevation - water_fac) / land_fac) * (mount_h - water_h))
:
- mount_h +
- ((elevation - water_fac - land_fac) / (1 - water_fac - land_fac))
- *
- (summit_h - mount_h);
+ static_cast<uint8_t>
+ (mount_h +
+ ((elevation - water_fac - land_fac) / (1 - water_fac - land_fac))
+ *
+ (summit_h - mount_h));
// Handle Map Border in island mode
if (m_mapInfo.islandMode) {
@@ -374,12 +376,12 @@
for (uint32_t x = 0; x < w; ++x)
for (uint32_t y = 0; y < h; ++y) {
- values[x + y * w] =
- ((static_cast<double>(values[x + y * w] - min))
- /
- static_cast<double>(max - min))
- *
- MAX_ELEVATION;
+ values[x + y * w] = static_cast<uint32_t>
+ (((static_cast<double>(values[x + y * w] - min))
+ /
+ static_cast<double>(max - min))
+ *
+ MAX_ELEVATION);
++histo[values[x + y * w] >> 22];
}
@@ -399,10 +401,10 @@
// This is done to have reliable water/land ratio later on.
for (uint32_t x = 0; x < w; ++x)
for (uint32_t y = 0; y < h; ++y)
- values[x + y * w] =
- minVals[values[x + y * w] >> 22]
- *
- static_cast<double>(MAX_ELEVATION);
+ values[x + y * w] = static_cast<uint32_t>
+ (minVals[values[x + y * w] >> 22]
+ *
+ static_cast<double>(MAX_ELEVATION));
return values;
} catch (...) {
delete[] values;
@@ -1111,11 +1113,11 @@
// Convert height
nums [8] = (mapInfo.h - 64) / 16;
// Convert water percent
- nums [9] = (mapInfo.waterRatio + 0.025) * 20.0;
+ nums [9] = static_cast<int32_t>((mapInfo.waterRatio + 0.025) * 20.0);
// Convert land percent
- nums[10] = (mapInfo.landRatio + 0.025) * 20.0;
+ nums[10] = static_cast<int32_t>((mapInfo.landRatio + 0.025) * 20.0);
// Convert wasteland percent
- nums[11] = (mapInfo.wastelandRatio + 0.025) * 20.0;
+ nums[11] = static_cast<int32_t>((mapInfo.wastelandRatio + 0.025) * 20.0);
// Set number of islands
nums[12] = mapInfo.numPlayers;
=== modified file 'src/map_io/widelands_map_resources_data_packet.cc'
--- src/map_io/widelands_map_resources_data_packet.cc 2012-02-15 21:25:34 +0000
+++ src/map_io/widelands_map_resources_data_packet.cc 2012-06-12 09:18:28 +0000
@@ -55,7 +55,7 @@
// construct ids and map
std::map<uint8_t, uint8_t> smap;
for (uint8_t i = 0; i < nr_res; ++i) {
- uint8_t const id = fr.Unsigned16();
+ uint8_t const id = static_cast<uint8_t>(fr.Unsigned16());
char const * const buffer = fr.CString();
int32_t const res = world.get_resource(buffer);
if (res == -1)
=== modified file 'src/network/internet_gaming.cc'
--- src/network/internet_gaming.cc 2012-05-27 11:54:05 +0000
+++ src/network/internet_gaming.cc 2012-06-12 09:18:28 +0000
@@ -152,7 +152,7 @@
s.send(m_sock);
// Now let's see, whether the metaserver is answering
- uint32_t const secs = time(0);
+ uint32_t const secs = static_cast<uint32_t>(time(0));
m_state = CONNECTING;
while (INTERNET_GAMING_TIMEOUT > time(0) - secs) {
handle_metaserver_communication();
@@ -194,7 +194,7 @@
s.send(m_sock);
// Now let's see, whether the metaserver is answering
- uint32_t const secs = time(0);
+ uint32_t const secs = static_cast<uint32_t>(time(0));
m_state = CONNECTING;
while (INTERNET_GAMING_TIMEOUT > time(0) - secs) {
handle_metaserver_communication();
@@ -421,7 +421,7 @@
else if (cmd == IGPCMD_TIME) {
// Client received the server time
- time_offset = boost::lexical_cast<int>(packet.String()) - time(0);
+ time_offset = boost::lexical_cast<int>(packet.String()) - static_cast<int32_t>(time(0));
dedicatedlog("InternetGaming: Server time offset is %i seconds.\n", time_offset);
std::string temp = (boost::format(_("Server time offset is %i seconds.")) % time_offset).str();
formatAndAddChat("", "", true, temp);
@@ -579,7 +579,7 @@
// From now on we wait for a reply from the metaserver
waitcmd = IGPCMD_GAME_CONNECT;
- waittimeout = time(0) + INTERNET_GAMING_TIMEOUT;
+ waittimeout = static_cast<int32_t>(time(0)) + INTERNET_GAMING_TIMEOUT;
}
@@ -599,7 +599,7 @@
// From now on we wait for a reply from the metaserver
waitcmd = IGPCMD_GAME_OPEN;
- waittimeout = time(0) + INTERNET_GAMING_TIMEOUT;
+ waittimeout = static_cast<int32_t>(time(0)) + INTERNET_GAMING_TIMEOUT;
}
@@ -616,7 +616,7 @@
// From now on we wait for a reply from the metaserver
waitcmd = IGPCMD_GAME_START;
- waittimeout = time(0) + INTERNET_GAMING_TIMEOUT;
+ waittimeout = static_cast<int32_t>(time(0)) + INTERNET_GAMING_TIMEOUT;
}
=== modified file 'src/network/nethost.cc'
--- src/network/nethost.cc 2012-06-08 22:33:16 +0000
+++ src/network/nethost.cc 2012-06-12 09:18:28 +0000
@@ -1313,7 +1313,7 @@
info.path = name;
info.players = static_cast<uint8_t>(s.get_safe_int("nr_players"));
d->settings.saved_games.push_back(info);
- } catch (_wexception const & e) {}
+ } catch (_wexception const &) {}
}
}
@@ -2002,13 +2002,13 @@
if (effective_name.empty())
effective_name = _("Player");
- if (haveUserName(effective_name, client.usernum)) {
+ if (haveUserName(effective_name, static_cast<uint8_t>(client.usernum))) {
uint32_t i = 2;
do {
char buf[32];
snprintf(buf, sizeof(buf), "%u", i++);
effective_name = playername + buf;
- } while (haveUserName(effective_name, client.usernum));
+ } while (haveUserName(effective_name, static_cast<uint8_t>(client.usernum)));
}
d->settings.users.at(client.usernum).name = effective_name;
@@ -2573,7 +2573,7 @@
uint8_t nr_players = s.get_safe_int("nr_players");
d->hp.setMap(gpdp.get_mapname(), path, nr_players, true);
- } catch (_wexception const & e) {}
+ } catch (_wexception const &) {}
}
} else {
if (g_fs->FileExists(path)) {
=== modified file 'src/profile/profile.cc'
--- src/profile/profile.cc 2012-02-15 21:25:34 +0000
+++ src/profile/profile.cc 2012-06-12 09:18:28 +0000
@@ -57,11 +57,11 @@
Profile g_options(Profile::err_log);
Section::Value::Value(const char * const nname, const char * const nval) :
- m_used(false), m_name(strdup(nname)), m_value(strdup(nval))
+ m_used(false), m_name(_strdup(nname)), m_value(_strdup(nval))
{}
Section::Value::Value(Section::Value const & o) :
-m_used(o.m_used), m_name(strdup(o.m_name)), m_value(strdup(o.m_value)) {}
+m_used(o.m_used), m_name(_strdup(o.m_name)), m_value(_strdup(o.m_value)) {}
Section::Value::~Value()
{
@@ -75,8 +75,8 @@
free(m_name);
free(m_value);
m_used = o.m_used;
- m_name = strdup(o.m_name);
- m_value = strdup(o.m_value);
+ m_name = _strdup(o.m_name);
+ m_value = _strdup(o.m_value);
}
return *this;
}
@@ -111,7 +111,7 @@
long long int i = strtoll(m_value, &endp, 0);
if (*endp or i < 0)
throw wexception("%s: '%s' is not natural", get_name(), m_value);
- return i;
+ return static_cast<uint32_t>(i);
}
@@ -121,7 +121,7 @@
long long int i = strtoll(m_value, &endp, 0);
if (*endp or i < 1)
throw wexception("%s: '%s' is not positive", get_name(), m_value);
- return i;
+ return static_cast<uint32_t>(i);
}
@@ -169,13 +169,16 @@
("%s: \"%s\" is not a Coords on a map with size (%u, %u)",
get_name(), m_value, extent.w, extent.h);
- return Widelands::Coords(x, y);
+ return
+ Widelands::Coords
+ (static_cast<Widelands::X_Coordinate>(x),
+ static_cast<Widelands::Y_Coordinate>(y));
}
void Section::Value::set_string(char const * const value)
{
free(m_value);
- m_value = strdup(value);
+ m_value = _strdup(value);
}
@@ -192,12 +195,12 @@
}
Section::Section(Profile * const prof, const char * const name) :
-m_profile(prof), m_used(false), m_section_name(strdup(name)) {}
+m_profile(prof), m_used(false), m_section_name(_strdup(name)) {}
Section::Section(const Section & o) :
m_profile (o.m_profile),
m_used (o.m_used),
- m_section_name(strdup(o.m_section_name)),
+ m_section_name(_strdup(o.m_section_name)),
m_values (o.m_values)
{
assert(this != &o);
@@ -211,7 +214,7 @@
m_profile = o.m_profile;
m_used = o.m_used;
- m_section_name = strdup(o.m_section_name);
+ m_section_name = _strdup(o.m_section_name);
m_values = o.m_values;
}
@@ -971,7 +974,7 @@
}
}
}
- catch (FileNotFound_error const & e) {
+ catch (FileNotFound_error const &) {
//It's no problem if the config file does not exist. (It'll get
//written on exit anyway)
log("There's no configuration file, using default values.\n");
=== modified file 'src/scripting/lua_map.cc'
--- src/scripting/lua_map.cc 2012-06-08 22:33:16 +0000
+++ src/scripting/lua_map.cc 2012-06-12 09:18:28 +0000
@@ -904,7 +904,7 @@
objname, from_where.c_str());
m = &egbase.create_immovable(c->coords(), imm_idx, &tribe);
- } catch (game_data_error & gd) {
+ } catch (game_data_error &) {
return
report_error
(L, "Problem loading tribe <%s>. Maybe not existent?",
=== modified file 'src/sound/sound_handler.cc'
--- src/sound/sound_handler.cc 2012-02-15 21:25:34 +0000
+++ src/sound/sound_handler.cc 2012-06-12 09:18:28 +0000
@@ -359,7 +359,7 @@
//probability that this fx gets played; initially set according to priority
// float division! not integer
- probability = (priority % PRIO_ALLOW_MULTIPLE) / 128.0;
+ probability = (priority % PRIO_ALLOW_MULTIPLE) / 128.0f;
//TODO: what to do with fx that happen offscreen?
//TODO: reduce volume? reduce priority? other?
=== modified file 'src/text_parser.cc'
--- src/text_parser.cc 2012-02-15 21:25:34 +0000
+++ src/text_parser.cc 2012-06-12 09:18:28 +0000
@@ -299,7 +299,11 @@
long int const red = strtol(r.c_str(), &ptr, 0);
long int const green = strtol(g.c_str(), &ptr, 0);
long int const blue = strtol(b.c_str(), &ptr, 0);
- element.set_font_color(RGBColor(red, green, blue));
+ element.set_font_color
+ (RGBColor
+ (static_cast<Uint8>(red),
+ static_cast<Uint8>(green),
+ static_cast<Uint8>(blue)));
} else if (key == "font-weight")
element.set_font_weight(val);
else if (key == "font-style")
=== modified file 'src/ui_basic/checkbox.cc'
--- src/ui_basic/checkbox.cc 2012-05-04 15:27:30 +0000
+++ src/ui_basic/checkbox.cc 2012-06-12 09:18:28 +0000
@@ -141,8 +141,9 @@
void Statebox::handle_mousein(bool const inside) {
bool oldhl = m_flags & Is_Highlighted;
set_flags(Is_Highlighted, inside and m_flags & Is_Enabled);
+ bool newhl = m_flags & Is_Highlighted;
- if (oldhl != m_flags & Is_Highlighted)
+ if (oldhl != newhl)
update();
}
=== modified file 'src/ui_basic/editbox.cc'
--- src/ui_basic/editbox.cc 2012-02-15 21:25:34 +0000
+++ src/ui_basic/editbox.cc 2012-06-12 09:18:28 +0000
@@ -396,7 +396,7 @@
{
if (m->text.size() < m->maxLength) {
if (code.unicode < 0x80) // 1 byte char
- m->text.insert(m->text.begin() + m->caret++, 1, code.unicode);
+ m->text.insert(m->text.begin() + m->caret++, 1, static_cast<char>(code.unicode));
else if (code.unicode < 0x800) { // 2 byte char
m->text.insert
(m->text.begin() + m->caret++, (((code.unicode & 0x7c0) >> 6) | 0xc0));
=== modified file 'src/ui_basic/multilinetextarea.cc'
--- src/ui_basic/multilinetextarea.cc 2012-06-08 22:33:16 +0000
+++ src/ui_basic/multilinetextarea.cc 2012-06-12 09:18:28 +0000
@@ -193,7 +193,7 @@
anchor = get_eff_w();
break;
}
- m->ww.draw(dst, Point(anchor, -m_scrollbar.get_scrollpos()), m_align);
+ m->ww.draw(dst, Point(anchor, -static_cast<int32_t>(m_scrollbar.get_scrollpos())), m_align);
}
}
=== modified file 'src/ui_basic/panel.cc'
--- src/ui_basic/panel.cc 2012-06-08 22:33:16 +0000
+++ src/ui_basic/panel.cc 2012-06-12 09:18:28 +0000
@@ -59,7 +59,7 @@
_border_snap_distance(0), _panel_snap_distance(0),
_desired_w(nw), _desired_h(nh),
_running(false),
- _tooltip(tooltip_text.size() ? strdup(tooltip_text.c_str()) : 0)
+ _tooltip(tooltip_text.size() ? _strdup(tooltip_text.c_str()) : 0)
{
assert(nparent != this);
if (_parent) {
@@ -1122,7 +1122,7 @@
assert(not text or *text);
if (_tooltip != text) {
free(_tooltip);
- _tooltip = text ? strdup(text) : 0;
+ _tooltip = text ? _strdup(text) : 0;
}
}
=== modified file 'src/ui_basic/panel.h'
--- src/ui_basic/panel.h 2012-02-21 19:36:34 +0000
+++ src/ui_basic/panel.h 2012-06-12 09:18:28 +0000
@@ -120,7 +120,7 @@
Point to_parent(const Point &) const;
virtual bool is_snap_target() const {return false;}
- uint16_t get_border_snap_distance() const {return _border_snap_distance;}
+ uint8_t get_border_snap_distance() const {return _border_snap_distance;}
void set_border_snap_distance(uint8_t const value) {
_border_snap_distance = value;
}
=== modified file 'src/ui_basic/progressbar.cc'
--- src/ui_basic/progressbar.cc 2012-02-15 21:25:34 +0000
+++ src/ui_basic/progressbar.cc 2012-06-12 09:18:28 +0000
@@ -75,7 +75,7 @@
assert(0 < get_h());
assert(m_total);
const float fraction =
- m_state < m_total ? static_cast<float>(m_state) / m_total : 1.0;
+ m_state < m_total ? static_cast<float>(m_state / m_total) : 1.0f;
assert(0 <= fraction);
assert (fraction <= 1);
=== modified file 'src/ui_basic/scrollbar.cc'
--- src/ui_basic/scrollbar.cc 2012-02-15 21:25:34 +0000
+++ src/ui_basic/scrollbar.cc 2012-06-12 09:18:28 +0000
@@ -234,8 +234,8 @@
int32_t pos;
switch (area) {
- case Minus: diff = -m_singlestepsize; break;
- case MinusPage: diff = -m_pagesize; break;
+ case Minus: diff = -static_cast<int32_t>(m_singlestepsize); break;
+ case MinusPage: diff = -static_cast<int32_t>(m_pagesize); break;
case Plus: diff = m_singlestepsize; break;
case PlusPage: diff = m_pagesize; break;
default:
=== modified file 'src/ui_fsmenu/internet_lobby.cc'
--- src/ui_fsmenu/internet_lobby.cc 2012-02-15 21:25:34 +0000
+++ src/ui_fsmenu/internet_lobby.cc 2012-06-12 09:18:28 +0000
@@ -369,7 +369,7 @@
if (opengames.has_selection()) {
InternetGaming::ref().join_game(opengames.get_selected().name);
- uint32_t const secs = time(0);
+ uint32_t const secs = static_cast<int32_t>(time(0));
while (InternetGaming::ref().ip().size() < 1) {
InternetGaming::ref().handle_metaserver_communication();
// give some time for the answer + for a relogin, if a problem occurs.
=== modified file 'src/ui_fsmenu/loadgame.cc'
--- src/ui_fsmenu/loadgame.cc 2012-03-07 09:39:47 +0000
+++ src/ui_fsmenu/loadgame.cc 2012-06-12 09:18:28 +0000
@@ -237,7 +237,7 @@
gl.preload_game(gpdp);
m_list.add(FileSystem::FS_FilenameWoExt(name).c_str(), name);
- } catch (_wexception const & e) {
+ } catch (_wexception const &) {
// we simply skip illegal entries
}
}
=== modified file 'src/utf8.h'
--- src/utf8.h 2012-02-15 21:25:34 +0000
+++ src/utf8.h 2012-06-12 09:18:28 +0000
@@ -42,7 +42,7 @@
unsigned char buf[4];
if (unicode < 0x80) {
- buf[0] = unicode;
+ buf[0] = static_cast<unsigned char>(unicode);
buf[1] = 0;
} else if (unicode < 0x800) {
buf[0] = ((unicode & 0x7c0) >> 6) | 0xc0;
=== modified file 'src/wlapplication.cc'
--- src/wlapplication.cc 2012-05-27 07:29:33 +0000
+++ src/wlapplication.cc 2012-06-12 09:18:28 +0000
@@ -998,7 +998,7 @@
for (int i = videomode.size() - 1; result == -1 && i >= 0; --i) {
strcpy(videodrvused + 16, videomode[i].c_str());
videodrvused[16 + videomode[i].size()] = '\0';
- putenv(videodrvused);
+ _putenv(videodrvused);
log
("Graphics: Trying Video driver: %i %s %s\n",
i, videomode[i].c_str(), videodrvused);
@@ -1932,7 +1932,7 @@
position.state == PlayerSettings::stateComputer))
{
setPlayer(number, player);
- setPlayer(settings().playernum, position);
+ setPlayer(static_cast<uint8_t>(settings().playernum), position);
s.playernum = number;
}
}
=== modified file 'src/wui/chatoverlay.cc'
--- src/wui/chatoverlay.cc 2012-06-08 22:33:16 +0000
+++ src/wui/chatoverlay.cc 2012-06-12 09:18:28 +0000
@@ -95,7 +95,7 @@
*/
void ChatOverlay::Impl::recompute()
{
- int32_t const now = time(0);
+ int32_t const now = static_cast<int32_t>(time(0));
havemessages = false;
=== modified file 'src/wui/differential_plot_area.cc'
--- src/wui/differential_plot_area.cc 2011-12-06 09:50:16 +0000
+++ src/wui/differential_plot_area.cc 2012-06-12 09:18:28 +0000
@@ -30,19 +30,23 @@
{}
void DifferentialPlot_Area::draw(RenderTarget & dst) {
- float const xline_length = get_inner_w() - space_at_right - spacing;
- float const yline_length = get_inner_h() - space_at_bottom - spacing;
+ float const xline_length = static_cast<float>
+ (get_inner_w() - space_at_right - spacing);
+ float const yline_length = static_cast<float>
+ (get_inner_h() - space_at_bottom - spacing);
+
//yoffset of the zero line
- float const yoffset = spacing + ((get_inner_h() - space_at_bottom) - spacing) / 2;
+ float const yoffset = static_cast<float>
+ (spacing + ((get_inner_h() - space_at_bottom) - spacing) / 2);
uint32_t time_in_ms_ = draw_diagram(dst, xline_length, yline_length);
//draw zero line
dst.draw_line
(get_inner_w() - space_at_right,
- yoffset,
- get_inner_w() - space_at_right - xline_length,
- yoffset,
+ static_cast<int32_t>(yoffset),
+ get_inner_w() - space_at_right - static_cast<int32_t>(xline_length),
+ static_cast<int32_t>(yoffset),
ZERO_LINE_COLOR, 2);
// How many do we take together when relative ploting
@@ -137,7 +141,9 @@
//highest_scale represent the space between zero line and top.
//-> half of the whole differential plot area
- draw_plot_line(dst, dataset, yline_length, highest_scale * 2, sub, color, yoffset);
+ draw_plot_line
+ (dst, dataset, yline_length, highest_scale * 2,
+ sub, color, static_cast<int32_t>(yoffset));
}
}
=== modified file 'src/wui/general_statistics_menu.h'
--- src/wui/general_statistics_menu.h 2012-02-15 21:25:34 +0000
+++ src/wui/general_statistics_menu.h 2012-06-12 09:18:28 +0000
@@ -41,7 +41,7 @@
Registry() :
UI::UniqueWindow::Registry(),
selected_information(0),
- selected_players(true, MAX_PLAYERS),
+ selected_players(true, static_cast<bool>(MAX_PLAYERS)),
time(WUIPlot_Area::TIME_GAME)
{}
=== modified file 'src/wui/interactive_base.cc'
--- src/wui/interactive_base.cc 2012-03-07 09:26:02 +0000
+++ src/wui/interactive_base.cc 2012-06-12 09:18:28 +0000
@@ -332,11 +332,11 @@
if (keyboard_free() && Panel::allow_user_input()) {
if (get_key_state(SDLK_UP) || (get_key_state(SDLK_KP8) && (SDL_GetModState() ^ KMOD_NUM)))
- set_rel_viewpoint(Point(0, -scrollval), false);
+ set_rel_viewpoint(Point(0, -static_cast<int32_t>(scrollval)), false);
if (get_key_state(SDLK_DOWN) || (get_key_state(SDLK_KP2) && (SDL_GetModState() ^ KMOD_NUM)))
set_rel_viewpoint(Point(0, scrollval), false);
if (get_key_state(SDLK_LEFT) || (get_key_state(SDLK_KP4) && (SDL_GetModState() ^ KMOD_NUM)))
- set_rel_viewpoint(Point(-scrollval, 0), false);
+ set_rel_viewpoint(Point(-static_cast<int32_t>(scrollval), 0), false);
if (get_key_state(SDLK_RIGHT) || (get_key_state(SDLK_KP6) && (SDL_GetModState() ^ KMOD_NUM)))
set_rel_viewpoint(Point (scrollval, 0), false);
}
@@ -461,7 +461,7 @@
assert (c.y < egbase().map().get_height());
const Map & map = egbase().map();
- uint32_t const x = (c.x + (c.y & 1) * 0.5) * TRIANGLE_WIDTH;
+ uint32_t const x = static_cast<uint32_t>((c.x + (c.y & 1) * 0.5) * TRIANGLE_WIDTH);
uint32_t const y = c.y * TRIANGLE_HEIGHT - map[c].get_height() * HEIGHT_FACTOR;
if (m->minimap.window)
m->mm->set_view_pos(x, y);
=== modified file 'src/wui/mapviewpixelfunctions.cc'
--- src/wui/mapviewpixelfunctions.cc 2012-02-15 21:25:34 +0000
+++ src/wui/mapviewpixelfunctions.cc 2012-06-12 09:18:28 +0000
@@ -115,12 +115,12 @@
{
const uint32_t map_end_screen_x = get_map_end_screen_x(map);
if (dx > map_end_screen_x / 2)
- dx = -(dx - map_end_screen_x);
+ dx = -static_cast<int32_t>(dx - map_end_screen_x);
}
{
const uint32_t map_end_screen_y = get_map_end_screen_y(map);
if (dy > map_end_screen_y / 2)
- dy = -(dy - map_end_screen_y);
+ dy = -static_cast<int32_t>(dy - map_end_screen_y);
}
return dx + dy;
}
=== modified file 'src/wui/multiplayersetupgroup.cc'
--- src/wui/multiplayersetupgroup.cc 2012-06-08 22:33:16 +0000
+++ src/wui/multiplayersetupgroup.cc 2012-06-12 09:18:28 +0000
@@ -78,7 +78,7 @@
/// Switch human players and spectator
void toggle_type() {
UserSettings us = s->settings().users.at(m_id);
- int16_t p = us.position;
+ uint8_t p = us.position;
if (p == UserSettings::none())
p = -1;
=== modified file 'src/wui/plot_area.cc'
--- src/wui/plot_area.cc 2012-06-08 22:33:16 +0000
+++ src/wui/plot_area.cc 2012-06-12 09:18:28 +0000
@@ -86,13 +86,13 @@
// or a multiple of 20h
// or a multiple of 4 days
if (time_in_ms_ > 8 * days) {
- time_in_ms_ += - (time_in_ms_ % (4 * days)) + 4 * days;
+ time_in_ms_ += -static_cast<int32_t>(time_in_ms_ % (4 * days)) + 4 * days;
} else if (time_in_ms_ > 40 * hours) {
- time_in_ms_ += - (time_in_ms_ % (20 * hours)) + 20 * hours;
+ time_in_ms_ += -static_cast<int32_t>(time_in_ms_ % (20 * hours)) + 20 * hours;
} else if (time_in_ms_ > 4 * hours) {
- time_in_ms_ += - (time_in_ms_ % (2 * hours)) + 2 * hours;
+ time_in_ms_ += -static_cast<int32_t>(time_in_ms_ % (2 * hours)) + 2 * hours;
} else {
- time_in_ms_ += - (time_in_ms_ % (15 * minutes)) + 15 * minutes;
+ time_in_ms_ += -static_cast<int32_t>(time_in_ms_ % (15 * minutes)) + 15 * minutes;
}
return time_in_ms_;
} else {
@@ -164,8 +164,8 @@
uint32_t time_in_ms_;
- float const xline_length = get_inner_w() - space_at_right - spacing;
- float const yline_length = get_inner_h() - space_at_bottom - spacing;
+ float const xline_length = static_cast<float>(get_inner_w() - space_at_right - spacing);
+ float const yline_length = static_cast<float>(get_inner_h() - space_at_bottom - spacing);
time_in_ms_ = draw_diagram(dst, xline_length, yline_length);
@@ -281,7 +281,7 @@
uint32_t const highest_scale, float const sub, RGBColor const color, int32_t const yoffset)
{
- float posx = get_inner_w() - space_at_right;
+ float posx = static_cast<float>(get_inner_w() - space_at_right);
int32_t lx = get_inner_w() - space_at_right;
int32_t ly = yoffset;
@@ -380,7 +380,7 @@
xtickstyle.fg = RGBColor(255, 0, 0);
float sub = xline_length / how_many_ticks;
- float posx = get_inner_w() - space_at_right;
+ float posx = static_cast<float>(get_inner_w() - space_at_right);
for (uint32_t i = 0; i <= how_many_ticks; ++i) {
dst.draw_line
=== modified file 'src/wui/waresqueuedisplay.cc'
--- src/wui/waresqueuedisplay.cc 2012-04-20 19:42:28 +0000
+++ src/wui/waresqueuedisplay.cc 2012-06-12 09:18:28 +0000
@@ -62,7 +62,7 @@
m_icon = ware.icon();
m_icon_grey = g_gr->create_grayed_out_pic(m_icon);
- m_icon_grey = g_gr->create_changed_luminosity_pic(m_icon_grey, 0.65);
+ m_icon_grey = g_gr->create_changed_luminosity_pic(m_icon_grey, 0.65f);
uint32_t pw, ph;
g_gr->get_picture_size(m_max_fill_indicator, pw, ph);
=== modified file 'src/wui/watchwindow.cc'
--- src/wui/watchwindow.cc 2012-05-06 16:28:43 +0000
+++ src/wui/watchwindow.cc 2012-06-12 09:18:28 +0000
@@ -174,7 +174,7 @@
//Calc point on map from coords
Point WatchWindow::calc_coords(Widelands::Coords const coords) {
// Initial positioning
- int32_t vx = (coords.x + (coords.y & 1) * 0.5) * TRIANGLE_WIDTH;
+ int32_t vx = static_cast<int32_t>(coords.x + (coords.y & 1) * 0.5) * TRIANGLE_WIDTH;
int32_t vy = (coords.y) * TRIANGLE_HEIGHT;
Widelands::Map & map = game().map();
uint8_t height = map[coords].get_height() * HEIGHT_FACTOR;
Follow ups