[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Adonthell-devel] [PATCH] Fixed strict compiler warnings
From: |
Chris Frey |
Subject: |
[Adonthell-devel] [PATCH] Fixed strict compiler warnings |
Date: |
Sat, 4 Oct 2008 18:07:06 -0400 |
User-agent: |
Mutt/1.4.1i |
Fixed the following compiler warnings in various places in the code:
- uninitialized variables
- unused variables
- comparison of signed and unsigned values / expressions
- using a float where an integer was expected
- order of constructor initializers did not match class declaration
---
src/python/callback.h | 4 ++--
src/world/chunk.cc | 4 +---
src/world/mapview.cc | 4 ++--
src/world/moving.cc | 12 ++++++------
src/world/render_info.h | 2 +-
src/world/triangle3.cc | 18 +++++++++++++++---
src/world/vector3.h | 2 +-
test/worldtest.cc | 4 ++--
8 files changed, 30 insertions(+), 20 deletions(-)
diff --git a/src/python/callback.h b/src/python/callback.h
index c474e95..f1437ee 100644
--- a/src/python/callback.h
+++ b/src/python/callback.h
@@ -84,7 +84,7 @@ namespace python
private:
RT run()
{
- RT retvalue;
+ RT retvalue = RT();
PyObject * pyres;
// We can directly call our function
@@ -200,7 +200,7 @@ namespace python
private:
RT run(P1 arg1)
{
- RT retvalue;
+ RT retvalue = RT();
PyObject * pyarg1;
PyObject * pyres;
diff --git a/src/world/chunk.cc b/src/world/chunk.cc
index c022923..03c7042 100644
--- a/src/world/chunk.cc
+++ b/src/world/chunk.cc
@@ -244,9 +244,7 @@ void chunk::objects_in_view (const s_int32 & min_x, const
s_int32 & max_x, const
c->objects_in_view (min_x, max_x, min_yz, max_yz, result);
}
}
-
- u_int32 num = result.size();
-
+
// process contained map objects
std::list<chunk_info>::const_iterator i;
for (i = Objects.begin (); i != Objects.end(); i++)
diff --git a/src/world/mapview.cc b/src/world/mapview.cc
index 3fb1006..94f0e64 100644
--- a/src/world/mapview.cc
+++ b/src/world/mapview.cc
@@ -122,7 +122,7 @@ void mapview::center_on (const s_int32 & x, const s_int32 &
y)
// don't go past edge of map
if (Sx < 0) Sx = 0;
- else if (Sx + length() > ml) Sx = ml - length();
+ else if (Sx + length() > (s_int32) ml) Sx = ml - length();
}
// calculate start and offset of view (y-axis)
@@ -138,7 +138,7 @@ void mapview::center_on (const s_int32 & x, const s_int32 &
y)
// don't go past edge of map
if (Sy < 0) Sy = 0;
- else if (Sy + height() > mh) Sy = mh - height();
+ else if (Sy + height() > (s_int32) mh) Sy = mh - height();
}
}
diff --git a/src/world/moving.cc b/src/world/moving.cc
index d4153e5..1219b1c 100644
--- a/src/world/moving.cc
+++ b/src/world/moving.cc
@@ -113,14 +113,14 @@ bool moving::collide_with_objects (collision
*collisionData)
{
// bbox around character and projected movement
const vector3<s_int32> min (
- x() + (Velocity.x() < 0 ? floor (Velocity.x()) : 0),
- y() - placeable::width()/2 + (Velocity.y() < 0 ? floor (Velocity.y())
: 0),
- z() + (Velocity.z() < 0 ? floor (Velocity.z()) : 0));
+ x() + (Velocity.x() < 0 ? static_cast<s_int32>(floor (Velocity.x())) :
0),
+ y() - placeable::width()/2 + (Velocity.y() < 0 ?
static_cast<s_int32>(floor (Velocity.y())) : 0),
+ z() + (Velocity.z() < 0 ? static_cast<s_int32>( floor (Velocity.z())
): 0));
const vector3<s_int32> max (
- min.x() + placeable::length() + (Velocity.x () > 0 ? ceil
(Velocity.x()) : 0),
- min.y() + placeable::width() + (Velocity.y () > 0 ? ceil
(Velocity.y()) : 0),
- min.z() + placeable::height() + (Velocity.z () > 0 ? ceil
(Velocity.z()) : 0));
+ min.x() + placeable::length() + (Velocity.x () > 0 ?
static_cast<s_int32>(ceil (Velocity.x())) : 0),
+ min.y() + placeable::width() + (Velocity.y () > 0 ?
static_cast<s_int32>(ceil (Velocity.y())) : 0),
+ min.z() + placeable::height() + (Velocity.z () > 0 ?
static_cast<s_int32>(ceil (Velocity.z())) : 0));
#if DEBUG_COLLISION
printf (" area [%i, %i, %i] - [%i, %i, %i]\n", min.x(), min.y(),
min.z(), max.x(), max.y(), max.z());
diff --git a/src/world/render_info.h b/src/world/render_info.h
index 9108939..d260463 100644
--- a/src/world/render_info.h
+++ b/src/world/render_info.h
@@ -16,7 +16,7 @@ class render_info
{
public:
render_info (const placeable_shape *shape, const gfx::sprite * sprite,
const vector3<s_int32> & pos)
- : Shape (shape), Sprite (sprite), Pos (pos)
+ : Pos (pos), Shape (shape), Sprite (sprite)
{
Pos.set (Pos.x() + Shape->x(), Pos.y() + Shape->y(), Pos.z() +
Shape->z());
}
diff --git a/src/world/triangle3.cc b/src/world/triangle3.cc
index d4a9921..765ed0a 100644
--- a/src/world/triangle3.cc
+++ b/src/world/triangle3.cc
@@ -86,9 +86,21 @@ void triangle3<float>::draw (const u_int16 & x, const
u_int16 & y, gfx::surface
if (!target) target = gfx::screen::get_surface();
u_int32 color = target->map_color (0, 255, 255);
- target->draw_line (x + A.x(), y + A.y() - A.z(), x + B.x(), y + B.y() -
B.z(), color);
- target->draw_line (x + B.x(), y + B.y() - B.z(), x + C.x(), y + C.y() -
C.z(), color);
- target->draw_line (x + C.x(), y + C.y() - C.z(), x + A.x(), y + A.y() -
A.z(), color);
+ target->draw_line (x + static_cast<u_int16>(A.x()),
+ y + static_cast<u_int16>(A.y()) - static_cast<u_int16>(A.z()),
+ x + static_cast<u_int16>(B.x()),
+ y + static_cast<u_int16>(B.y()) - static_cast<u_int16>(B.z()),
+ color);
+ target->draw_line (x + static_cast<u_int16>(B.x()),
+ y + static_cast<u_int16>(B.y()) - static_cast<u_int16>(B.z()),
+ x + static_cast<u_int16>(C.x()),
+ y + static_cast<u_int16>(C.y()) - static_cast<u_int16>(C.z()),
+ color);
+ target->draw_line (x + static_cast<u_int16>(C.x()),
+ y + static_cast<u_int16>(C.y()) - static_cast<u_int16>(C.z()),
+ x + static_cast<u_int16>(A.x()),
+ y + static_cast<u_int16>(A.y()) - static_cast<u_int16>(A.z()),
+ color);
}
} // namespace world
diff --git a/src/world/vector3.h b/src/world/vector3.h
index 946c826..a52634f 100644
--- a/src/world/vector3.h
+++ b/src/world/vector3.h
@@ -119,7 +119,7 @@ public:
void set_length (const T & length)
{
float l = length / this->length ();
- set (X * l, Y * l, Z * l);
+ set (static_cast<T>(X * l), static_cast<T>(Y * l), static_cast<T>(Z *
l));
}
/**
diff --git a/test/worldtest.cc b/test/worldtest.cc
index d5a49a5..75da832 100644
--- a/test/worldtest.cc
+++ b/test/worldtest.cc
@@ -319,8 +319,8 @@ public:
for (float i = 0; i < 16; i += 1.5)
for (float j = 2; j < 12; j += 1.5)
{
- u_int16 x = 40 * i;
- u_int16 y = 40 * j;
+ u_int16 x = (u_int16) (40 * i);
+ u_int16 y = (u_int16) (40 * j);
world::coordinates mc (x, y, 0);
world.put_entity (1, mc);
--
1.6.0.2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Adonthell-devel] [PATCH] Fixed strict compiler warnings,
Chris Frey <=