[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r4030 - in trunk/pingus: . src/actions src/colliders src/co
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r4030 - in trunk/pingus: . src/actions src/colliders src/components src/display src/editor src/input src/math src/particles src/pingus src/screen src/sound src/util src/worldmap src/worldobjs |
Date: |
Thu, 5 Nov 2009 16:57:54 +0100 |
Author: grumbel
Date: 2009-11-05 16:57:44 +0100 (Thu, 05 Nov 2009)
New Revision: 4030
Modified:
trunk/pingus/TODO
trunk/pingus/src/actions/basher.cpp
trunk/pingus/src/actions/boarder.cpp
trunk/pingus/src/actions/bomber.cpp
trunk/pingus/src/actions/bridger.cpp
trunk/pingus/src/actions/climber.cpp
trunk/pingus/src/actions/digger.cpp
trunk/pingus/src/actions/miner.cpp
trunk/pingus/src/actions/slider.cpp
trunk/pingus/src/actions/walker.cpp
trunk/pingus/src/colliders/pingu_collider.cpp
trunk/pingus/src/components/playfield.cpp
trunk/pingus/src/components/playfield.hpp
trunk/pingus/src/components/smallmap.cpp
trunk/pingus/src/display/drawing_context.cpp
trunk/pingus/src/display/opengl_framebuffer.cpp
trunk/pingus/src/display/sdl_framebuffer.cpp
trunk/pingus/src/editor/level_objs.cpp
trunk/pingus/src/editor/minimap.cpp
trunk/pingus/src/editor/object_properties.cpp
trunk/pingus/src/editor/object_selector.cpp
trunk/pingus/src/editor/object_selector_list.cpp
trunk/pingus/src/editor/panel.cpp
trunk/pingus/src/editor/viewport.cpp
trunk/pingus/src/input/evdev_device.cpp
trunk/pingus/src/input/evdev_device.hpp
trunk/pingus/src/input/sdl_driver.cpp
trunk/pingus/src/input/usbmouse_driver.cpp
trunk/pingus/src/math/math.cpp
trunk/pingus/src/particles/rain_particle_holder.cpp
trunk/pingus/src/pingus/blitter.cpp
trunk/pingus/src/pingus/font.cpp
trunk/pingus/src/pingus/font_test_screen.cpp
trunk/pingus/src/pingus/layer_manager.hpp
trunk/pingus/src/pingus/pingu.cpp
trunk/pingus/src/pingus/pingu_action.cpp
trunk/pingus/src/pingus/pingus_menu.cpp
trunk/pingus/src/pingus/story_screen.cpp
trunk/pingus/src/screen/screen_manager.cpp
trunk/pingus/src/sound/sound_real.cpp
trunk/pingus/src/util/sexpr_file_reader.cpp
trunk/pingus/src/util/sexpr_file_writer.cpp
trunk/pingus/src/util/utf8.cpp
trunk/pingus/src/worldmap/level_dot.cpp
trunk/pingus/src/worldmap/sprite_drawable.cpp
trunk/pingus/src/worldobjs/conveyor_belt.cpp
trunk/pingus/src/worldobjs/ice_block.cpp
trunk/pingus/src/worldobjs/liquid.cpp
trunk/pingus/src/worldobjs/rain_generator.cpp
trunk/pingus/src/worldobjs/snow_generator.cpp
trunk/pingus/src/worldobjs/starfield_background_stars.cpp
trunk/pingus/src/worldobjs/surface_background.cpp
trunk/pingus/src/worldobjs/switch_door.cpp
trunk/pingus/src/worldobjs/woodthing.cpp
Log:
Finished -Wconversion cleanup
Modified: trunk/pingus/TODO
===================================================================
--- trunk/pingus/TODO 2009-11-05 02:45:14 UTC (rev 4029)
+++ trunk/pingus/TODO 2009-11-05 15:57:44 UTC (rev 4030)
@@ -35,7 +35,11 @@
* Editor ObjectSelector is broken, graphics are not clipped (dirty
rectangle renderers fault)
+* add check for OpenGL
+* banish Vector3f from the source code, along with float
+
+
OLPC Issues
===========
Modified: trunk/pingus/src/actions/basher.cpp
===================================================================
--- trunk/pingus/src/actions/basher.cpp 2009-11-05 02:45:14 UTC (rev 4029)
+++ trunk/pingus/src/actions/basher.cpp 2009-11-05 15:57:44 UTC (rev 4030)
@@ -94,8 +94,8 @@
if (basher_c % 2 == 0)
bash();
}
- else if (sprite[pingu->direction].get_current_frame() // FIXME: Game
logic must be separate from Sprite
- / float(sprite[pingu->direction].get_frame_count()) > 0.6f)
+ else if
(static_cast<float>(sprite[pingu->direction].get_current_frame()) // FIXME:
Game logic must be separate from Sprite
+ /
static_cast<float>(sprite[pingu->direction].get_frame_count()) > 0.6f)
{ // FIXME: EVIL! Engine must not relay on graphic
pingu->set_action(Actions::WALKER);
}
@@ -107,8 +107,8 @@
Basher::bash()
{
WorldObj::get_world()->remove(bash_radius,
- static_cast<int>(pingu->get_x () -
(bash_radius_width / 2)),
- static_cast<int>(pingu->get_y () -
bash_radius_width + 1));
+ static_cast<int>(pingu->get_x() -
static_cast<float>(bash_radius_width / 2)),
+ static_cast<int>(pingu->get_y() -
static_cast<float>(bash_radius_width + 1)));
}
void
@@ -133,8 +133,8 @@
{
// Note that Pingu::set_pos() is the 'reverse' of the y co-ords of
// rel_getpixel()
- pingu->set_pos(pingu->get_x() + static_cast<int>(pingu->direction),
- pingu->get_y() - y_inc);
+ pingu->set_pos(pingu->get_x() + static_cast<float>(pingu->direction),
+ pingu->get_y() - static_cast<float>(y_inc));
}
}
Modified: trunk/pingus/src/actions/boarder.cpp
===================================================================
--- trunk/pingus/src/actions/boarder.cpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/actions/boarder.cpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -48,7 +48,7 @@
// Incremental update so that we don't skip pixels
Vector3f new_pos = pingu->get_pos();
- new_pos.x = new_pos.x + pingu->direction * speed;
+ new_pos.x = new_pos.x + static_cast<float>(pingu->direction) * speed;
while (new_pos.x != pingu->get_pos().x)
{
Vector3f old_pos = pingu->get_pos();
@@ -61,8 +61,8 @@
pingu->set_pos(old_pos); // + (pingu->direction * 10);
////pingu->pos.y = 10;
- pingu->apply_force (Vector3f(float(speed * pingu->direction * 0.5),
- -float(speed * abs(pingu->direction) * 0.5)));
+ pingu->apply_force(Vector3f(float(speed *
static_cast<float>(pingu->direction) * 0.5f),
+ -float(speed *
static_cast<float>(abs(pingu->direction)) * 0.5f)));
pingu->set_action(Actions::WALKER);
return;
}
@@ -70,7 +70,7 @@
}
else
{
- pingu->apply_force (Vector3f(speed * pingu->direction, 0));
+ pingu->apply_force (Vector3f(speed * static_cast<float>(pingu->direction),
0));
pingu->set_action(Actions::WALKER);
}
}
Modified: trunk/pingus/src/actions/bomber.cpp
===================================================================
--- trunk/pingus/src/actions/bomber.cpp 2009-11-05 02:45:14 UTC (rev 4029)
+++ trunk/pingus/src/actions/bomber.cpp 2009-11-05 15:57:44 UTC (rev 4030)
@@ -108,8 +108,8 @@
{
colmap_exploded = true;
WorldObj::get_world()->remove(bomber_radius,
- static_cast<int>(pingu->get_x () -
(bomber_radius.get_width()/2)),
- static_cast<int>(pingu->get_y () - 16 -
(bomber_radius.get_width()/2)));
+
static_cast<int>(static_cast<int>(pingu->get_x()) -
(bomber_radius.get_width()/2)),
+
static_cast<int>(static_cast<int>(pingu->get_y()) - 16 -
(bomber_radius.get_width()/2)));
}
// The pingu explode
Modified: trunk/pingus/src/actions/bridger.cpp
===================================================================
--- trunk/pingus/src/actions/bridger.cpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/actions/bridger.cpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -70,13 +70,13 @@
switch (mode)
{
case B_BUILDING:
- gc.color().draw(build_sprite[pingu->direction],
Vector3f(pingu->get_pos().x - (x_offset * pingu->direction),
-
pingu->get_pos().y + y_offset));
+ gc.color().draw(build_sprite[pingu->direction],
Vector3f(pingu->get_pos().x - static_cast<float>(x_offset * pingu->direction),
+
pingu->get_pos().y + static_cast<float>(y_offset)));
break;
case B_WALKING:
- gc.color().draw(walk_sprite[pingu->direction],
Vector3f(pingu->get_pos().x - (x_offset * pingu->direction),
-
pingu->get_pos().y + y_offset));
+ gc.color().draw(walk_sprite[pingu->direction],
Vector3f(pingu->get_pos().x - static_cast<float>(x_offset * pingu->direction),
+
pingu->get_pos().y + static_cast<float>(y_offset)));
break;
}
}
@@ -202,14 +202,14 @@
if (pingu->direction.is_right())
{
WorldObj::get_world()->put(brick_r,
- static_cast<int>(pingu->get_pos().x + 10 -
brick_r.get_width()),
+ static_cast<int>(pingu->get_pos().x + 10.0f -
static_cast<float>(brick_r.get_width())),
static_cast<int>(pingu->get_pos().y),
Groundtype::GP_BRIDGE);
}
else
{
WorldObj::get_world()->put(brick_l,
- static_cast<int>(pingu->get_pos().x - 10),
+ static_cast<int>(pingu->get_pos().x - 10.0f),
static_cast<int>(pingu->get_pos().y),
Groundtype::GP_BRIDGE);
}
@@ -218,7 +218,7 @@
void
Bridger::walk_one_step_up()
{
- pingu->set_pos(pingu->get_pos().x + (4 * pingu->direction),
+ pingu->set_pos(pingu->get_pos().x + (4.0f *
static_cast<float>(pingu->direction)),
pingu->get_pos().y - 2);
}
Modified: trunk/pingus/src/actions/climber.cpp
===================================================================
--- trunk/pingus/src/actions/climber.cpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/actions/climber.cpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -57,8 +57,8 @@
if (!head_collision_on_walk(pingu->direction, 1))
{
// Get ready to walk
- pingu->set_pos(pingu->get_x() + pingu->direction,
- pingu->get_y() - 1);
+ pingu->set_pos(pingu->get_x() + static_cast<float>(pingu->direction),
+ pingu->get_y() - 1.0f);
}
else
{
Modified: trunk/pingus/src/actions/digger.cpp
===================================================================
--- trunk/pingus/src/actions/digger.cpp 2009-11-05 02:45:14 UTC (rev 4029)
+++ trunk/pingus/src/actions/digger.cpp 2009-11-05 15:57:44 UTC (rev 4030)
@@ -82,8 +82,8 @@
Digger::dig ()
{
WorldObj::get_world()->remove(digger_radius,
- static_cast<int>(pingu->get_pos().x -
(digger_radius.get_width() / 2)),
- static_cast<int>(pingu->get_pos().y -
digger_radius.get_height() + 2));
+ static_cast<int>(pingu->get_pos().x -
static_cast<float>(digger_radius.get_width() / 2)),
+ static_cast<int>(pingu->get_pos().y -
static_cast<float>(digger_radius.get_height()) + 2.0f));
pingu->set_pos(pingu->get_pos().x, pingu->get_pos().y + 1.0f);
}
Modified: trunk/pingus/src/actions/miner.cpp
===================================================================
--- trunk/pingus/src/actions/miner.cpp 2009-11-05 02:45:14 UTC (rev 4029)
+++ trunk/pingus/src/actions/miner.cpp 2009-11-05 15:57:44 UTC (rev 4030)
@@ -48,18 +48,19 @@
if (!(slow_count % 3))
{
WorldObj::get_world()->remove(miner_radius,
- static_cast<int>(pingu->get_x() -
(miner_radius.get_width() / 2) + pingu->direction),
- static_cast<int>(pingu->get_y() -
miner_radius.get_width() + 1));
+ static_cast<int>(pingu->get_x() -
static_cast<float>((miner_radius.get_width() / 2) + pingu->direction)),
+ static_cast<int>(pingu->get_y() -
static_cast<float>(miner_radius.get_width() + 1)));
}
- pingu->set_pos(pingu->get_x() + pingu->direction, pingu->get_y() + 1);
+ pingu->set_pos(pingu->get_x() + static_cast<float>(pingu->direction),
+ pingu->get_y() + 1.0f);
}
if (rel_getpixel(0, -1) == Groundtype::GP_NOTHING)
{
WorldObj::get_world()->remove(miner_radius,
- static_cast<int>(pingu->get_x() -
(miner_radius.get_width() / 2) + pingu->direction),
- static_cast<int>(pingu->get_y() -
miner_radius.get_width() + 3) );
+ static_cast<int>(pingu->get_x() -
static_cast<float>((miner_radius.get_width() / 2) + pingu->direction)),
+ static_cast<int>(pingu->get_y() -
static_cast<float>(miner_radius.get_width() + 3) ));
pingu->set_action(Actions::WALKER);
}
else if (rel_getpixel(0, -1) == Groundtype::GP_SOLID
@@ -69,8 +70,8 @@
Sound::PingusSound::play_sound("chink");
WorldObj::get_world()->remove(miner_radius,
- static_cast<int>(pingu->get_x() -
(miner_radius.get_width() / 2) + pingu->direction),
- static_cast<int>(pingu->get_y() -
miner_radius.get_width() + 1) );
+ static_cast<int>(pingu->get_x() -
static_cast<float>((miner_radius.get_width() / 2) + pingu->direction)),
+
static_cast<int>(pingu->get_y() - static_cast<float>(miner_radius.get_width() +
1) ));
pingu->set_action(Actions::WALKER);
// Stop Pingu walking further into the solid.
Modified: trunk/pingus/src/actions/slider.cpp
===================================================================
--- trunk/pingus/src/actions/slider.cpp 2009-11-05 02:45:14 UTC (rev 4029)
+++ trunk/pingus/src/actions/slider.cpp 2009-11-05 15:57:44 UTC (rev 4030)
@@ -39,7 +39,7 @@
for (int i = 0; i < speed && rel_getpixel(1, 0) == Groundtype::GP_NOTHING;
++i)
{
- pingu->set_x(pingu->get_x() + pingu->direction);
+ pingu->set_x(pingu->get_x() + static_cast<float>(pingu->direction));
if (rel_getpixel(0, -1) == Groundtype::GP_NOTHING)
{
Modified: trunk/pingus/src/actions/walker.cpp
===================================================================
--- trunk/pingus/src/actions/walker.cpp 2009-11-05 02:45:14 UTC (rev 4029)
+++ trunk/pingus/src/actions/walker.cpp 2009-11-05 15:57:44 UTC (rev 4030)
@@ -63,9 +63,10 @@
*/
- if (rel_getpixel(1, 0) == Groundtype::GP_OUTOFSCREEN) {
- pingu->set_x(pingu->get_x() + pingu->direction);
- return;
+ if (rel_getpixel(1, 0) == Groundtype::GP_OUTOFSCREEN)
+ {
+ pingu->set_x(pingu->get_x() + static_cast<float>(pingu->direction));
+ return;
}
if (rel_getpixel(0, -1) == Groundtype::GP_WATER)
@@ -93,7 +94,7 @@
if (found_ground)
{
- pingu->set_y(pingu->get_y() - i);
+ pingu->set_y(pingu->get_y() - static_cast<float>(i));
}
else
{
@@ -109,8 +110,8 @@
{
// simple, stupid, but working bridge code
// FIXME: We don't check if we 'drift' into a solid ground block
- pingu->set_pos(pingu->get_x() + pingu->direction,
- pingu->get_y() - 1); // pingus 'float' through bridges
+ pingu->set_pos(pingu->get_x() + static_cast<float>(pingu->direction),
+ pingu->get_y() - 1.0f); // pingus 'float' through bridges
}
else
{
@@ -144,8 +145,8 @@
if (found_next_step)
{
// pos.y has a reversed co-system to rel_getpixel()?
- pingu->set_pos(pingu->get_x() + pingu->direction,
- pingu->get_y() - possible_y_step);
+ pingu->set_pos(pingu->get_x() + static_cast<float>(pingu->direction),
+ pingu->get_y() - static_cast<float>(possible_y_step));
}
else
{
@@ -165,7 +166,7 @@
else
{
// We take the step, so that we are in the air
- pingu->set_x(pingu->get_x() + pingu->direction);
+ pingu->set_x(pingu->get_x() +
static_cast<float>(pingu->direction));
// We reached a cliff
pingu->set_action(Actions::FALLER);
return;
Modified: trunk/pingus/src/colliders/pingu_collider.cpp
===================================================================
--- trunk/pingus/src/colliders/pingu_collider.cpp 2009-11-05 02:45:14 UTC
(rev 4029)
+++ trunk/pingus/src/colliders/pingu_collider.cpp 2009-11-05 15:57:44 UTC
(rev 4030)
@@ -30,7 +30,7 @@
}
bool PinguCollider::operator() (World* const world, Vector3f current_pos,
- const Vector3f& step_vector) const
+ const Vector3f& step_vector) const
{
Vector3f new_pos = current_pos + step_vector;
int pixel;
@@ -43,7 +43,7 @@
// If the Pingu is going to move sideways to the next pixel...
if (static_cast<int>(new_pos.x) != static_cast<int>(current_pos.x))
{
- float top_of_pingu = new_pos.y - height;
+ float top_of_pingu = new_pos.y - static_cast<float>(height);
for (; new_pos.y >= top_of_pingu; --new_pos.y)
{
@@ -63,7 +63,7 @@
// If the Pingu is not falling...
else if (!falling)
{
- pixel = getpixel(world, Vector3f(new_pos.x, new_pos.y - height));
+ pixel = getpixel(world, Vector3f(new_pos.x, new_pos.y -
static_cast<float>(height)));
// If the top of the Pingu has hit something except a bridge...
if (pixel != Groundtype::GP_NOTHING && pixel != Groundtype::GP_BRIDGE)
Modified: trunk/pingus/src/components/playfield.cpp
===================================================================
--- trunk/pingus/src/components/playfield.cpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/components/playfield.cpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -137,8 +137,8 @@
}
else
{
- state.set_pos(Vector2i(static_cast<int>(state.get_pos().x -
(scroll_center.x - mouse_pos.x) * 0.2f),
- static_cast<int>(state.get_pos().y -
(scroll_center.y - mouse_pos.y) * 0.2f)));
+ state.set_pos(Vector2i(state.get_pos().x -
static_cast<int>(static_cast<float>(scroll_center.x - mouse_pos.x) * 0.2f),
+ state.get_pos().y -
static_cast<int>(static_cast<float>(scroll_center.y - mouse_pos.y) * 0.2f)));
}
}
@@ -216,36 +216,36 @@
mouse_pos.y = y;
if (maintainer_mode)
- { // Some fun stuff that lets you draw directly on the level
- Uint8 *keystate = SDL_GetKeyState(NULL);
- if (keystate[SDLK_r])
- {
- CollisionMask mask("other/bash_radius_gfx");
- Vector2f p = state.screen2world(mouse_pos);
- server->get_world()->remove(mask,
- int(p.x - mask.get_width()/2),
- int(p.y - mask.get_height()/2));
- }
- else if (keystate[SDLK_g])
- {
- CollisionMask mask("other/bash_radius_gfx");
- Vector2f p = state.screen2world(mouse_pos);
- server->get_world()->put(mask,
- int(p.x - mask.get_width()/2),
- int(p.y - mask.get_height()/2),
- Groundtype::GP_GROUND);
- }
- else if (keystate[SDLK_b])
- {
- CollisionMask mask("other/bash_radius_gfx");
- Vector2f p = state.screen2world(mouse_pos);
- server->get_world()->put(mask,
- int(p.x - mask.get_width()/2),
- int(p.y - mask.get_height()/2),
- Groundtype::GP_BRIDGE);
- }
+ { // Some fun stuff that lets you draw directly on the level
+ Uint8 *keystate = SDL_GetKeyState(NULL);
+ if (keystate[SDLK_r])
+ {
+ CollisionMask mask("other/bash_radius_gfx");
+ Vector2i p = state.screen2world(mouse_pos);
+ server->get_world()->remove(mask,
+ p.x - mask.get_width()/2,
+ p.y - mask.get_height()/2);
}
+ else if (keystate[SDLK_g])
+ {
+ CollisionMask mask("other/bash_radius_gfx");
+ Vector2i p = state.screen2world(mouse_pos);
+ server->get_world()->put(mask,
+ p.x - mask.get_width()/2,
+ p.y - mask.get_height()/2,
+ Groundtype::GP_GROUND);
+ }
+ else if (keystate[SDLK_b])
+ {
+ CollisionMask mask("other/bash_radius_gfx");
+ Vector2i p = state.screen2world(mouse_pos);
+ server->get_world()->put(mask,
+ p.x - mask.get_width()/2,
+ p.y - mask.get_height()/2,
+ Groundtype::GP_BRIDGE);
}
+ }
+}
Vector2i
Playfield::get_pos() const
Modified: trunk/pingus/src/components/playfield.hpp
===================================================================
--- trunk/pingus/src/components/playfield.hpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/components/playfield.hpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -78,6 +78,7 @@
void disable_scroll_mode();
void update_layout();
+
private:
Playfield (const Playfield&);
Playfield& operator= (const Playfield&);
Modified: trunk/pingus/src/components/smallmap.cpp
===================================================================
--- trunk/pingus/src/components/smallmap.cpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/components/smallmap.cpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -62,28 +62,28 @@
Rect view_rect;
if (world->get_width() > gc.get_width())
- {
- int rwidth = int(gc.get_width() * rect.get_width() /
world->get_width());
- view_rect.left = rect.left + (of.x * rect.get_width() /
world->get_width()) - rwidth/2;
- view_rect.right = view_rect.left + rwidth;
- }
+ {
+ int rwidth = int(gc.get_width() * rect.get_width() / world->get_width());
+ view_rect.left = rect.left + (of.x * rect.get_width() /
world->get_width()) - rwidth/2;
+ view_rect.right = view_rect.left + rwidth;
+ }
else
- {
- view_rect.left = rect.left;
- view_rect.right = rect.left + rect.get_width();
- }
+ {
+ view_rect.left = rect.left;
+ view_rect.right = rect.left + rect.get_width();
+ }
if (world->get_height() > gc.get_height())
- {
- int rheight = int(gc.get_height() * rect.get_height() /
world->get_height());
- view_rect.top = rect.top + (of.y * rect.get_height() /
world->get_height()) - rheight/2;
- view_rect.bottom = view_rect.top + rheight;
- }
+ {
+ int rheight = int(gc.get_height() * rect.get_height() /
world->get_height());
+ view_rect.top = rect.top + (of.y * rect.get_height() /
world->get_height()) - rheight/2;
+ view_rect.bottom = view_rect.top + rheight;
+ }
else
- {
- view_rect.top = rect.top;
- view_rect.bottom = rect.top + rect.get_height();
- }
+ {
+ view_rect.top = rect.top;
+ view_rect.bottom = rect.top + rect.get_height();
+ }
gc.draw(image->get_surface(), Vector2i(rect.left, rect.top));
gc.draw_rect(view_rect, Color(0, 255, 0));
@@ -93,12 +93,14 @@
// Draw Pingus
PinguHolder* pingus = world->get_pingus();
for(PinguIter i = pingus->begin(); i != pingus->end(); ++i)
- {
- int x = static_cast<int>(rect.left + ((*i)->get_x() * rect.get_width()
/ world->get_width()));
- int y = static_cast<int>(rect.top + ((*i)->get_y() * rect.get_height() /
world->get_height()));
+ {
+ int x = static_cast<int>(static_cast<float>(rect.left) + ((*i)->get_x() *
static_cast<float>(rect.get_width())
+ /
static_cast<float>(world->get_width())));
+ int y = static_cast<int>(static_cast<float>(rect.top) + ((*i)->get_y() *
static_cast<float>(rect.get_height())
+ /
static_cast<float>(world->get_height())));
- gc.draw_line(Vector2i(x, y), Vector2i(x, y-2), Color(255, 255, 0));
- }
+ gc.draw_line(Vector2i(x, y), Vector2i(x, y-2), Color(255, 255, 0));
+ }
gc_ptr = 0;
}
@@ -113,8 +115,8 @@
SmallMap::draw_sprite(Sprite sprite, Vector3f pos)
{
World* world = server->get_world();
- float x = rect.left + (pos.x * rect.get_width() / world->get_width());
- float y = rect.top + (pos.y * rect.get_height() / world->get_height());
+ float x = static_cast<float>(rect.left) + (pos.x *
static_cast<float>(rect.get_width()) / static_cast<float>(world->get_width()));
+ float y = static_cast<float>(rect.top) + (pos.y *
static_cast<float>(rect.get_height()) /
static_cast<float>(world->get_height()));
gc_ptr->draw(sprite, Vector3f(x, y));
}
Modified: trunk/pingus/src/display/drawing_context.cpp
===================================================================
--- trunk/pingus/src/display/drawing_context.cpp 2009-11-05 02:45:14 UTC
(rev 4029)
+++ trunk/pingus/src/display/drawing_context.cpp 2009-11-05 15:57:44 UTC
(rev 4030)
@@ -255,8 +255,8 @@
void
DrawingContext::draw(const Sprite& sprite, const Vector3f& pos)
{
- draw(new SpriteDrawingRequest(sprite,
Vector2i(static_cast<int>(translate_stack.back().x + pos.x),
-
static_cast<int>(translate_stack.back().y + pos.y)),
+ draw(new SpriteDrawingRequest(sprite, Vector2i(translate_stack.back().x +
static_cast<int>(pos.x),
+ translate_stack.back().y +
static_cast<int>(pos.y)),
pos.z));
}
Modified: trunk/pingus/src/display/opengl_framebuffer.cpp
===================================================================
--- trunk/pingus/src/display/opengl_framebuffer.cpp 2009-11-05 02:45:14 UTC
(rev 4029)
+++ trunk/pingus/src/display/opengl_framebuffer.cpp 2009-11-05 15:57:44 UTC
(rev 4030)
@@ -150,11 +150,19 @@
glVertexPointer(2, GL_INT, 0, vertices);
float uvs[] = {
- float(srcrect.left)/texture->get_texture_size().width,
float(srcrect.top)/texture->get_texture_size().height,
- float(srcrect.right)/texture->get_texture_size().width,
float(srcrect.top)/texture->get_texture_size().height,
- float(srcrect.right)/texture->get_texture_size().width,
float(srcrect.bottom)/texture->get_texture_size().height,
- float(srcrect.left)/texture->get_texture_size().width,
float(srcrect.bottom)/texture->get_texture_size().height
+ static_cast<float>(srcrect.left) /
static_cast<float>(texture->get_texture_size().width),
+ static_cast<float>(srcrect.top) /
static_cast<float>(texture->get_texture_size().height),
+
+ static_cast<float>(srcrect.right) /
static_cast<float>(texture->get_texture_size().width),
+ static_cast<float>(srcrect.top) /
static_cast<float>(texture->get_texture_size().height),
+
+ static_cast<float>(srcrect.right) /
static_cast<float>(texture->get_texture_size().width),
+ static_cast<float>(srcrect.bottom) /
static_cast<float>(texture->get_texture_size().height),
+
+ static_cast<float>(srcrect.left) /
static_cast<float>(texture->get_texture_size().width),
+ static_cast<float>(srcrect.bottom) /
static_cast<float>(texture->get_texture_size().height)
};
+
glTexCoordPointer(2, GL_FLOAT, 0, uvs);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
Modified: trunk/pingus/src/display/sdl_framebuffer.cpp
===================================================================
--- trunk/pingus/src/display/sdl_framebuffer.cpp 2009-11-05 02:45:14 UTC
(rev 4029)
+++ trunk/pingus/src/display/sdl_framebuffer.cpp 2009-11-05 15:57:44 UTC
(rev 4030)
@@ -32,10 +32,10 @@
if (c.a < 255) {
Uint16 *p;
unsigned long dp;
- unsigned char alpha;
+ uint8_t alpha;
// Loses precision for speed
- alpha = (255 - c.a) >> 3;
+ alpha = static_cast<uint8_t>((255 - c.a) >> 3);
p = &((Uint16 *)screen->pixels)[x + y * screen->w];
color = (((color << 16) | color) & 0x07E0F81F);
@@ -44,7 +44,7 @@
dp = ((((dp - color) * alpha) >> 5) + color) & 0x07E0F81F;
*p = (Uint16)((dp >> 16) | dp);
} else {
- ((Uint16 *)screen->pixels)[x + y * screen->w] = color;
+ static_cast<Uint16*>(screen->pixels)[x + y * screen->w] =
static_cast<Uint16>(color);
}
}
@@ -59,7 +59,7 @@
unsigned long dp2;
unsigned char alpha;
- alpha = 255 - c.a;
+ alpha = static_cast<unsigned char>(255 - c.a);
p = &((Uint32*)screen->pixels)[x + y * screen->w];
@@ -122,9 +122,9 @@
rect.x = Math::max(r1->x, r2->x);
rect.y = Math::max(r1->y, r2->y);
int endx = Math::min(r1->x + r1->w, r2->x + r2->w);
- rect.w = Math::max(endx - rect.x, 0);
+ rect.w = static_cast<Uint16>(Math::max(static_cast<int>(endx - rect.x), 0));
int endy = Math::min(r1->y + r1->h, r2->y + r2->h);
- rect.h = Math::max(endy - rect.y, 0);
+ rect.h = static_cast<Uint16>(Math::max(static_cast<int>(endy - rect.y), 0));
return rect;
}
@@ -189,10 +189,10 @@
dstrect.h = 0;
SDL_Rect sdlsrcrect;
- sdlsrcrect.x = srcrect.left;
- sdlsrcrect.y = srcrect.top;
- sdlsrcrect.w = srcrect.get_width();
- sdlsrcrect.h = srcrect.get_height();
+ sdlsrcrect.x = static_cast<Sint16>(srcrect.left);
+ sdlsrcrect.y = static_cast<Sint16>(srcrect.top);
+ sdlsrcrect.w = static_cast<Uint16>(srcrect.get_width());
+ sdlsrcrect.h = static_cast<Uint16>(srcrect.get_height());
SDL_BlitSurface(src, &sdlsrcrect, screen, &dstrect);
}
@@ -351,10 +351,10 @@
{
SDL_Rect srcrect;
- srcrect.x = rect.left;
- srcrect.y = rect.top;
- srcrect.w = rect.get_width();
- srcrect.h = rect.get_height();
+ srcrect.x = static_cast<Sint16>(rect.left);
+ srcrect.y = static_cast<Sint16>(rect.top);
+ srcrect.w = static_cast<Uint16>(rect.get_width());
+ srcrect.h = static_cast<Uint16>(rect.get_height());
SDL_FillRect(screen, &srcrect, SDL_MapRGB(screen->format, color.r,
color.g, color.b));
}
@@ -406,10 +406,10 @@
for(std::vector<Rect>::const_iterator i = rects.begin(); i != rects.end();
++i)
{
SDL_Rect sdl_rect;
- sdl_rect.x = i->left;
- sdl_rect.y = i->top;
- sdl_rect.w = i->get_width();
- sdl_rect.h = i->get_height();
+ sdl_rect.x = static_cast<Sint16>(i->left);
+ sdl_rect.y = static_cast<Sint16>(i->top);
+ sdl_rect.w = static_cast<Uint16>(i->get_width());
+ sdl_rect.h = static_cast<Uint16>(i->get_height());
sdl_rects.push_back(sdl_rect);
}
@@ -443,10 +443,10 @@
SDLFramebuffer::push_cliprect(const Rect& rect)
{
SDL_Rect sdl_rect;
- sdl_rect.x = rect.left;
- sdl_rect.y = rect.top;
- sdl_rect.w = rect.get_width();
- sdl_rect.h = rect.get_height();
+ sdl_rect.x = static_cast<Sint16>(rect.left);
+ sdl_rect.y = static_cast<Sint16>(rect.top);
+ sdl_rect.w = static_cast<Uint16>(rect.get_width());
+ sdl_rect.h = static_cast<Uint16>(rect.get_height());
if (!cliprect_stack.empty())
{
Modified: trunk/pingus/src/editor/level_objs.cpp
===================================================================
--- trunk/pingus/src/editor/level_objs.cpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/editor/level_objs.cpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -137,7 +137,7 @@
{
if (attribs & HAS_REPEAT)
{
- for(int x = int(pos.x); x < pos.x + sprite.get_width()*repeat; x +=
sprite.get_width())
+ for(int x = static_cast<int>(pos.x); x < static_cast<int>(pos.x) +
sprite.get_width() * repeat; x += sprite.get_width())
{
gc.draw(sprite, Vector3f(static_cast<float>(x), pos.y, pos.z));
}
@@ -373,8 +373,8 @@
LevelObj::duplicate(const Vector2i& offset) const
{
LevelObj* obj = new LevelObj(*this);
- obj->pos.x += offset.x;
- obj->pos.y += offset.y;
+ obj->pos.x += static_cast<float>(offset.x);
+ obj->pos.y += static_cast<float>(offset.y);
return obj;
}
Modified: trunk/pingus/src/editor/minimap.cpp
===================================================================
--- trunk/pingus/src/editor/minimap.cpp 2009-11-05 02:45:14 UTC (rev 4029)
+++ trunk/pingus/src/editor/minimap.cpp 2009-11-05 15:57:44 UTC (rev 4030)
@@ -75,9 +75,9 @@
else // hotspot, background, etc.
color = Color(255,0,0);
- Color bg_color(int(color.r * 0.75f),
- int(color.g * 0.75f),
- int(color.b * 0.75f));
+ Color bg_color(static_cast<uint8_t>(3 * color.r / 4),
+ static_cast<uint8_t>(3 * color.g / 4),
+ static_cast<uint8_t>(3 * color.b / 4));
dc.draw_fillrect(r, bg_color, (*i)->get_pos().z);
dc.draw_rect(r, color, (*i)->get_pos().z);
@@ -86,11 +86,11 @@
Vector2f viewport_pos = editor->get_viewport()->get_scroll_pos();
Rect viewport_rect = editor->get_viewport()->get_rect();
- viewport_pos.x -= viewport_rect.get_width()/2;
- viewport_pos.y -= viewport_rect.get_height()/2;
+ viewport_pos.x -= static_cast<float>(viewport_rect.get_width()) / 2;
+ viewport_pos.y -= static_cast<float>(viewport_rect.get_height()) / 2;
- Rect view(Vector2i(int(viewport_pos.x * minimap_rect.get_width() /
levelsize.width),
- int(viewport_pos.y * minimap_rect.get_height() /
levelsize.height)),
+ Rect view(Vector2i(static_cast<int>(viewport_pos.x *
static_cast<float>(minimap_rect.get_width()) /
static_cast<float>(levelsize.width)),
+ static_cast<int>(viewport_pos.y *
static_cast<float>(minimap_rect.get_height()) /
static_cast<float>(levelsize.height))),
Size(viewport_rect.get_width() * minimap_rect.get_width() /
levelsize.width,
viewport_rect.get_height() * minimap_rect.get_height() /
levelsize.height));
dc.draw_fillrect(view, Color(255, 255, 0, 150), 1000000.0f);
Modified: trunk/pingus/src/editor/object_properties.cpp
===================================================================
--- trunk/pingus/src/editor/object_properties.cpp 2009-11-05 02:45:14 UTC
(rev 4029)
+++ trunk/pingus/src/editor/object_properties.cpp 2009-11-05 15:57:44 UTC
(rev 4030)
@@ -567,7 +567,7 @@
for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
{
Color color = (*i)->get_color();
- color.r = StringUtil::to<int>(str);
+ color.r = static_cast<char>(StringUtil::to<int>(str));
(*i)->set_color(color);
}
}
@@ -578,7 +578,7 @@
for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
{
Color color = (*i)->get_color();
- color.g = StringUtil::to<int>(str);
+ color.g = static_cast<uint8_t>(StringUtil::to<int>(str));
(*i)->set_color(color);
}
}
@@ -589,7 +589,7 @@
for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
{
Color color = (*i)->get_color();
- color.b = StringUtil::to<int>(str);
+ color.b = static_cast<uint8_t>(StringUtil::to<int>(str));
(*i)->set_color(color);
}
}
@@ -600,7 +600,7 @@
for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
{
Color color = (*i)->get_color();
- color.a = StringUtil::to<int>(str);
+ color.a = static_cast<uint8_t>(StringUtil::to<int>(str));
(*i)->set_color(color);
}
}
Modified: trunk/pingus/src/editor/object_selector.cpp
===================================================================
--- trunk/pingus/src/editor/object_selector.cpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/editor/object_selector.cpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -236,7 +236,7 @@
if (mouse_over)
{
- int t_w = Fonts::verdana11.get_width(tooltip);
+ int t_w = static_cast<int>(Fonts::verdana11.get_width(tooltip));
Rect t_r(rect.left + 17 - t_w/2 - 4, rect.top + 38 - 2,
rect.left + 17 + t_w/2 + 4, rect.top + 38 +
Fonts::verdana11.get_height() + 4);
gc.draw_fillrect(t_r, Color(255, 255, 200), 1000.0f);
Modified: trunk/pingus/src/editor/object_selector_list.cpp
===================================================================
--- trunk/pingus/src/editor/object_selector_list.cpp 2009-11-05 02:45:14 UTC
(rev 4029)
+++ trunk/pingus/src/editor/object_selector_list.cpp 2009-11-05 15:57:44 UTC
(rev 4030)
@@ -189,7 +189,7 @@
if (!set->get_objects().empty())
{
int obj_x = Math::clamp(0, mouse_pos.x / 48, width - 1);
- int obj_y = Math::clamp(0, int(mouse_pos.y - offset) / 48, height-1);
+ int obj_y = Math::clamp(0, (mouse_pos.y - static_cast<int>(offset)) /
48, height-1);
current_object = Math::clamp(-1, (obj_y * 5) + obj_x,
int(set->get_objects().size()-1));
}
@@ -197,8 +197,8 @@
if (mode == SCROLLING)
{
- offset = old_offset + (y - drag_start.y);
- offset = Math::clamp(Math::min(rect.get_height() - (height * 48.0f),
0.0f), offset, 0.0f);
+ offset = old_offset + static_cast<float>(y - drag_start.y);
+ offset = Math::clamp(Math::min(static_cast<float>(rect.get_height()) -
(static_cast<float>(height) * 48.0f), 0.0f), offset, 0.0f);
}
}
Modified: trunk/pingus/src/editor/panel.cpp
===================================================================
--- trunk/pingus/src/editor/panel.cpp 2009-11-05 02:45:14 UTC (rev 4029)
+++ trunk/pingus/src/editor/panel.cpp 2009-11-05 15:57:44 UTC (rev 4030)
@@ -91,7 +91,7 @@
if (mouse_over)
{
- int t_w = Fonts::verdana11.get_width(tooltip);
+ int t_w = static_cast<int>(Fonts::verdana11.get_width(tooltip));
Rect t_r(pos.x + 17 - t_w/2 - 4, pos.y + 38 - 2,
pos.x + 17 + t_w/2 + 4, pos.y + 38 +
Fonts::verdana11.get_height() + 4);
gc.draw_fillrect(t_r, Color(255, 255, 200), 1000.0f);
Modified: trunk/pingus/src/editor/viewport.cpp
===================================================================
--- trunk/pingus/src/editor/viewport.cpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/editor/viewport.cpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -351,8 +351,8 @@
{
if (current_action == SCROLLING)
{
- state.set_pos(Vector2i(static_cast<int>(state.get_pos().x +
(mouse_screen_pos.x - drag_screen_pos.x) * 5 * delta),
- static_cast<int>(state.get_pos().y +
(mouse_screen_pos.y - drag_screen_pos.y) * 5 * delta)));
+
state.set_pos(Vector2i(static_cast<int>(static_cast<float>(state.get_pos().x +
(mouse_screen_pos.x - drag_screen_pos.x)) * 5.0f * delta),
+
static_cast<int>(static_cast<float>(state.get_pos().y + (mouse_screen_pos.y -
drag_screen_pos.y)) * 5.0f * delta)));
}
// Autoscroll if necessary
@@ -511,7 +511,9 @@
for (unsigned i = 0; i < selected_objs.size(); i++)
{
Vector3f p = selected_objs[i]->get_pos();
- selected_objs[i]->set_pos(Vector3f(p.x + offset.x, p.y + offset.y, p.z));
+ selected_objs[i]->set_pos(Vector3f(p.x + static_cast<float>(offset.x),
+ p.y + static_cast<float>(offset.y),
+ p.z));
}
}
Modified: trunk/pingus/src/input/evdev_device.cpp
===================================================================
--- trunk/pingus/src/input/evdev_device.cpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/input/evdev_device.cpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -151,9 +151,9 @@
i != relatives[idx].bindings.end(); ++i)
{
if (relatives[idx].binding_axis == 0)
- (*i)->set_delta(Vector2f(-ev.value * 0.125f, 0)); // FIXME: make
scaling and inversion configurable
+ (*i)->set_delta(Vector2f(static_cast<float>(-ev.value) * 0.125f,
0.0f)); // FIXME: make scaling and inversion configurable
else if (relatives[idx].binding_axis == 1)
- (*i)->set_delta(Vector2f(0, -ev.value * 0.125f));
+ (*i)->set_delta(Vector2f(0, static_cast<float>(-ev.value) * 0.125f));
}
}
Modified: trunk/pingus/src/input/evdev_device.hpp
===================================================================
--- trunk/pingus/src/input/evdev_device.hpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/input/evdev_device.hpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -38,7 +38,7 @@
int pos;
inline float get_posf() const {
- return float(pos - min)/(max - min) * 2.0f - 1.0f;
+ return static_cast<float>(pos - min) / static_cast<float>(max - min) *
2.0f - 1.0f;
}
};
Modified: trunk/pingus/src/input/sdl_driver.cpp
===================================================================
--- trunk/pingus/src/input/sdl_driver.cpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/input/sdl_driver.cpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -287,7 +287,7 @@
{
if (event.jaxis.which == i->device &&
event.jaxis.axis == i->axis)
- i->binding->set_state(event.jaxis.value / 32767.0f);
+ i->binding->set_state(static_cast<float>(event.jaxis.value) /
32767.0f);
}
break;
Modified: trunk/pingus/src/input/usbmouse_driver.cpp
===================================================================
--- trunk/pingus/src/input/usbmouse_driver.cpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/input/usbmouse_driver.cpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -127,7 +127,7 @@
(*i)->set_pos(mouse_pos);
for(std::vector<Scroller*>::iterator i =
scroller_bindings.begin(); i != scroller_bindings.end(); ++i)
- (*i)->set_delta(Vector2f(-delta_x, delta_y)); // FIXME:
Inversion should be configurable
+ (*i)->set_delta(Vector2f(static_cast<float>(-delta_x),
static_cast<float>(delta_y))); // FIXME: Inversion should be configurable
}
// Scrollwheel move
Modified: trunk/pingus/src/math/math.cpp
===================================================================
--- trunk/pingus/src/math/math.cpp 2009-11-05 02:45:14 UTC (rev 4029)
+++ trunk/pingus/src/math/math.cpp 2009-11-05 15:57:44 UTC (rev 4030)
@@ -36,7 +36,7 @@
float sqrt(float a)
{
- return ::sqrt(a);
+ return ::sqrtf(a);
}
float mod(float x, float y)
@@ -51,7 +51,7 @@
float atan2(float x, float y)
{
- return ::atan2(x, y);
+ return ::atan2f(x, y);
}
static char num2hex[] = "0123456789abcdef";
@@ -72,9 +72,9 @@
static char hex2int(char c)
{
if (c >= '0' && c <= '9')
- return c - '0';
+ return static_cast<char>(c - '0');
else if (c >= 'a' && c <= 'f')
- return c - 'a' + 0xa;
+ return static_cast<char>(c - 'a' + 0xa);
else
return 0;
}
@@ -87,7 +87,7 @@
for(size_t i = 0; i < sizeof(float); ++i)
{
char& v = reinterpret_cast<char*>(&value)[i];
- v = (hex2int(str[2*i+0]) << 4) | hex2int(str[2*i+1]);
+ v = static_cast<char>((hex2int(str[2*i+0]) << 4) | hex2int(str[2*i+1]));
}
return value;
Modified: trunk/pingus/src/particles/rain_particle_holder.cpp
===================================================================
--- trunk/pingus/src/particles/rain_particle_holder.cpp 2009-11-05 02:45:14 UTC
(rev 4029)
+++ trunk/pingus/src/particles/rain_particle_holder.cpp 2009-11-05 15:57:44 UTC
(rev 4030)
@@ -74,8 +74,8 @@
continue;
}
- it->splash_frame += 10 * game_speed / 1000.0f;
- (it->splash_counter == 3) ? it->alive = false :
++it->splash_counter;
+ it->splash_frame += 10.0f * static_cast<float>(game_speed) / 1000.0f;
+ (it->splash_counter == 3) ? it->alive = false : ++it->splash_counter;
}
else
{
@@ -119,10 +119,10 @@
else
if (it->use_rain2_surf)
gc.color().draw(rain2_surf, Vector2i(static_cast<int>(it->pos.x),
- static_cast<int>(it->pos.y -
rain1_surf.get_height())));
+ static_cast<int>(it->pos.y -
static_cast<float>(rain1_surf.get_height()))));
else
gc.color().draw(rain1_surf, Vector2i(static_cast<int>(it->pos.x),
- static_cast<int>(it->pos.y -
rain1_surf.get_height())));
+ static_cast<int>(it->pos.y -
static_cast<float>(rain1_surf.get_height()))));
}
}
Modified: trunk/pingus/src/pingus/blitter.cpp
===================================================================
--- trunk/pingus/src/pingus/blitter.cpp 2009-11-05 02:45:14 UTC (rev 4029)
+++ trunk/pingus/src/pingus/blitter.cpp 2009-11-05 15:57:44 UTC (rev 4030)
@@ -82,7 +82,7 @@
unsigned char *p1, *p2, *p3, *p4;
new_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
surface->format->BitsPerPixel,
- surface->format->Rmask, surface->format->Gmask, surface->format->Bmask,
surface->format->Amask);
+ surface->format->Rmask,
surface->format->Gmask, surface->format->Bmask, surface->format->Amask);
SDL_LockSurface(surface);
SDL_LockSurface(new_surface);
@@ -93,13 +93,13 @@
for (i = 0; i < height; ++i) {
x = i * new_pitch;
- fy = (float)i * surface->h / height;
+ fy = static_cast<float>(i) * static_cast<float>(surface->h) /
static_cast<float>(height);
iy = (int)fy;
- fy -= iy;
+ fy -= static_cast<float>(iy);
for (j = 0; j < width; ++j) {
- fx = (float)j * surface->w / width;
+ fx = static_cast<float>(j) * static_cast<float>(surface->w) /
static_cast<float>(width);
ix = (int)fx;
- fx -= ix;
+ fx -= static_cast<float>(ix);
fz = (fx + fy) / 2;
p1 = &pixels[iy * surface->pitch + ix * bpp];
@@ -111,22 +111,22 @@
&pixels[(iy + 1) * surface->pitch + (ix + 1) * bpp] : p1;
new_pixels[x + 0] = static_cast<unsigned char>(
- (p1[0] * (1 - fy) + p2[0] * fy +
- p1[0] * (1 - fx) + p3[0] * fx +
- p1[0] * (1 - fz) + p4[0] * fz) / 3.0 + .5);
+ (static_cast<float>(p1[0]) * (1 - fy) + static_cast<float>(p2[0]) *
fy +
+ static_cast<float>(p1[0]) * (1 - fx) + static_cast<float>(p3[0]) *
fx +
+ static_cast<float>(p1[0]) * (1 - fz) + static_cast<float>(p4[0]) *
fz) / 3.0 + .5);
new_pixels[x + 1] = static_cast<unsigned char>(
- (p1[1] * (1 - fy) + p2[1] * fy +
- p1[1] * (1 - fx) + p3[1] * fx +
- p1[1] * (1 - fz) + p4[1] * fz) / 3.0 + .5);
+ (static_cast<float>(p1[1]) * (1 - fy) + static_cast<float>(p2[1]) *
fy +
+ static_cast<float>(p1[1]) * (1 - fx) + static_cast<float>(p3[1]) *
fx +
+ static_cast<float>(p1[1]) * (1 - fz) + static_cast<float>(p4[1]) *
fz) / 3.0 + .5);
new_pixels[x + 2] = static_cast<unsigned char>(
- (p1[2] * (1 - fy) + p2[2] * fy +
- p1[2] * (1 - fx) + p3[2] * fx +
- p1[2] * (1 - fz) + p4[2] * fz) / 3.0 + .5);
+ (static_cast<float>(p1[2]) * (1 - fy) + static_cast<float>(p2[2]) *
fy +
+ static_cast<float>(p1[2]) * (1 - fx) + static_cast<float>(p3[2]) *
fx +
+ static_cast<float>(p1[2]) * (1 - fz) + static_cast<float>(p4[2]) *
fz) / 3.0 + .5);
if (bpp == 4) {
new_pixels[x + 3] = static_cast<unsigned char>(
- (p1[3] * (1 - fy) + p2[3] * fy +
- p1[3] * (1 - fx) + p3[3] * fx +
- p1[3] * (1 - fz) + p4[3] * fz) / 3.0 + .5);
+ (static_cast<float>(p1[3]) * (1 - fy) + static_cast<float>(p2[3])
* fy +
+ static_cast<float>(p1[3]) * (1 - fx) + static_cast<float>(p3[3])
* fx +
+ static_cast<float>(p1[3]) * (1 - fz) + static_cast<float>(p4[3])
* fz) / 3.0 + .5);
}
x += bpp;
}
Modified: trunk/pingus/src/pingus/font.cpp
===================================================================
--- trunk/pingus/src/pingus/font.cpp 2009-11-05 02:45:14 UTC (rev 4029)
+++ trunk/pingus/src/pingus/font.cpp 2009-11-05 15:57:44 UTC (rev 4030)
@@ -46,7 +46,7 @@
vertical_spacing(),
size(desc.size)
{
- vertical_spacing = size * desc.vertical_spacing;
+ vertical_spacing = static_cast<float>(size) * desc.vertical_spacing;
glyphs.resize(65536, 0); // 16bit ought to be enough for everybody
@@ -123,7 +123,7 @@
const GlyphDescription& glyph = *glyphs[unicode];
fb.draw_surface(framebuffer_surfaces[glyph.image],
glyph.rect, Vector2i(static_cast<int>(dstx),
static_cast<int>(dsty)) + glyph.offset);
- dstx += glyph.advance + char_spacing;
+ dstx += static_cast<float>(glyph.advance) + char_spacing;
}
else
{
@@ -140,7 +140,7 @@
float get_width(uint32_t unicode) const
{
if (unicode < glyphs.size() && glyphs[unicode])
- return glyphs[unicode]->advance;
+ return static_cast<float>(glyphs[unicode]->advance);
else
return 0;
}
Modified: trunk/pingus/src/pingus/font_test_screen.cpp
===================================================================
--- trunk/pingus/src/pingus/font_test_screen.cpp 2009-11-05 02:45:14 UTC
(rev 4029)
+++ trunk/pingus/src/pingus/font_test_screen.cpp 2009-11-05 15:57:44 UTC
(rev 4030)
@@ -81,8 +81,8 @@
y+font.get_height()),
Color(0,0,255));
gc.draw_rect(Rect(x, y,
- x+font.get_width(char(i)),
- y+font.get_height()),
+ x + static_cast<int>(font.get_width(char(i))),
+ y + font.get_height()),
Color(255,0,255));
gc.print_left(font, Vector2i(x, y),
std::string(1, char(i)));
Modified: trunk/pingus/src/pingus/layer_manager.hpp
===================================================================
--- trunk/pingus/src/pingus/layer_manager.hpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/pingus/layer_manager.hpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -59,7 +59,7 @@
void draw (DrawingContext& gc)
{
gc.draw(sur, Vector3f(x_pos + x_offset, y_pos + y_offset));
- gc.draw(sur, Vector3f(x_pos + x_offset - gc.get_width(), y_pos +
y_offset));
+ gc.draw(sur, Vector3f(x_pos + x_offset -
static_cast<float>(gc.get_width()), y_pos + y_offset));
}
void update (float delta)
Modified: trunk/pingus/src/pingus/pingu.cpp
===================================================================
--- trunk/pingus/src/pingus/pingu.cpp 2009-11-05 02:45:14 UTC (rev 4029)
+++ trunk/pingus/src/pingus/pingu.cpp 2009-11-05 15:57:44 UTC (rev 4030)
@@ -318,16 +318,17 @@
// Returns the distance between the Pingu and a given coordinate
float
-Pingu::dist (int x, int y)
+Pingu::dist(int x, int y)
{
Vector3f p = get_center_pos ();
- return Math::sqrt(((p.x - x) * (p.x - x) + (p.y - y) * (p.y - y)));
+ return Math::sqrt(((p.x - static_cast<float>(x)) * (p.x -
static_cast<float>(x)) +
+ (p.y - static_cast<float>(y)) * (p.y -
static_cast<float>(y))));
}
// Let the pingu do his job (i.e. walk his way)
void
-Pingu::update ()
+Pingu::update()
{
if (status == PS_DEAD)
return;
@@ -378,10 +379,10 @@
}
int
-Pingu::rel_getpixel (int x, int y)
+Pingu::rel_getpixel(int x, int y)
{
- return WorldObj::get_world()->get_colmap()->getpixel(static_cast<int>(pos_x
+ (x * direction)),
- static_cast<int>(pos_y
- y));
+ return WorldObj::get_world()->get_colmap()->getpixel(static_cast<int>(pos_x
+ static_cast<float>(x * direction)),
+ static_cast<int>(pos_y
- static_cast<float>(y)));
}
void
Modified: trunk/pingus/src/pingus/pingu_action.cpp
===================================================================
--- trunk/pingus/src/pingus/pingu_action.cpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/pingus/pingu_action.cpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -48,8 +48,8 @@
PinguAction::rel_getpixel (int x, int y)
{
// FIXME: Inline me
- return
WorldObj::get_world()->get_colmap()->getpixel(static_cast<int>(pingu->get_x() +
(x * pingu->direction)),
-
static_cast<int>(pingu->get_y() - y));
+ return
WorldObj::get_world()->get_colmap()->getpixel(static_cast<int>(pingu->get_x() +
static_cast<float>((x * pingu->direction))),
+
static_cast<int>(pingu->get_y() - static_cast<float>(y)));
}
ActionType
@@ -215,8 +215,8 @@
else
{
// Move the Pingu left
- pingu->set_x(pingu->get_x() + pingu->direction);
- force_counter.x -= pingu->direction;
+ pingu->set_x(pingu->get_x() +
static_cast<float>(pingu->direction));
+ force_counter.x -= static_cast<float>(pingu->direction);
}
}
Modified: trunk/pingus/src/pingus/pingus_menu.cpp
===================================================================
--- trunk/pingus/src/pingus/pingus_menu.cpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/pingus/pingus_menu.cpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -236,10 +236,10 @@
layer5 = layer5.scale(302 * w / default_screen_width, 104 * h /
default_screen_height);
background->add_layer(Sprite(layer1), 0, 0, 12, 0);
- background->add_layer(Sprite(layer2), 0, 150 * (float)h /
default_screen_height, 25, 0);
- background->add_layer(Sprite(layer3), 0, 200 * (float)h /
default_screen_height, 50, 0);
- background->add_layer(Sprite(layer4), 0, 429 * (float)h /
default_screen_height, 100, 0);
- background->add_layer(Sprite(layer5), 0, 500 * (float)h /
default_screen_height, 200, 0);
+ background->add_layer(Sprite(layer2), 0, 150 * static_cast<float>(h) /
static_cast<float>(default_screen_height), 25, 0);
+ background->add_layer(Sprite(layer3), 0, 200 * static_cast<float>(h) /
static_cast<float>(default_screen_height), 50, 0);
+ background->add_layer(Sprite(layer4), 0, 429 * static_cast<float>(h) /
static_cast<float>(default_screen_height), 100, 0);
+ background->add_layer(Sprite(layer5), 0, 500 * static_cast<float>(h) /
static_cast<float>(default_screen_height), 200, 0);
}
else
{
Modified: trunk/pingus/src/pingus/story_screen.cpp
===================================================================
--- trunk/pingus/src/pingus/story_screen.cpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/pingus/story_screen.cpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -119,10 +119,10 @@
bool is_at(int x, int y)
{
return
- x > x_pos - Fonts::chalk_small.get_width(_("skip")) &&
+ x > x_pos - static_cast<int>(Fonts::chalk_small.get_width(_("skip"))) &&
x < x_pos &&
y > y_pos &&
- y < y_pos + Fonts::chalk_small.get_height();
+ y < y_pos + static_cast<int>(Fonts::chalk_small.get_height());
}
void on_pointer_enter()
Modified: trunk/pingus/src/screen/screen_manager.cpp
===================================================================
--- trunk/pingus/src/screen/screen_manager.cpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/screen/screen_manager.cpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -356,8 +356,8 @@
Framebuffer& fb = Display::get_framebuffer();
while (progress <= 1.0f)
{
- int border_x = int((Display::get_width()/2) * (1.0f - progress));
- int border_y = int((Display::get_height()/2) * (1.0f - progress));
+ int border_x =
static_cast<int>(static_cast<float>(Display::get_width()/2) * (1.0f -
progress));
+ int border_y =
static_cast<int>(static_cast<float>(Display::get_height()/2) * (1.0f -
progress));
old_screen->draw(*display_gc);
display_gc->render(fb, Rect(Vector2i(0,0), Size(Display::get_width(),
@@ -377,7 +377,7 @@
fb.flip();
display_gc->clear();
- progress = (SDL_GetTicks() - last_ticks)/1000.0f;
+ progress = static_cast<float>(SDL_GetTicks() - last_ticks)/1000.0f;
}
}
Modified: trunk/pingus/src/sound/sound_real.cpp
===================================================================
--- trunk/pingus/src/sound/sound_real.cpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/sound/sound_real.cpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -74,8 +74,8 @@
Mix_Volume(channel, (int)(volume * MIX_MAX_VOLUME));
if (panning != 0.0f)
{
- Uint8 left = (panning < 0.0f) ? 255 : (Uint8)((panning - 1.0f) *
-255);
- Uint8 right = (panning > 0.0f) ? 255 : (Uint8)((panning + 1.0f) *
255);
+ Uint8 left = static_cast<Uint8>((panning < 0.0f) ? 255 :
(Uint8)((panning - 1.0f) * -255));
+ Uint8 right = static_cast<Uint8>((panning > 0.0f) ? 255 :
(Uint8)((panning + 1.0f) * 255));
Mix_SetPanning(channel, left, right);
}
}
Modified: trunk/pingus/src/util/sexpr_file_reader.cpp
===================================================================
--- trunk/pingus/src/util/sexpr_file_reader.cpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/util/sexpr_file_reader.cpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -176,16 +176,16 @@
}
return false;
}
-
+
bool read_color (const char* name, Color& v) const
{
boost::shared_ptr<lisp::Lisp> sub = get_subsection(name);
if (sub && sub->get_list_size() == 5)
{
- v = Color(int(sub->get_list_elem(1)->get_float() * 255),
- int(sub->get_list_elem(2)->get_float() * 255),
- int(sub->get_list_elem(3)->get_float() * 255),
- int(sub->get_list_elem(4)->get_float() * 255));
+ v = Color(static_cast<char>(sub->get_list_elem(1)->get_float() * 255),
+ static_cast<char>(sub->get_list_elem(2)->get_float() * 255),
+ static_cast<char>(sub->get_list_elem(3)->get_float() * 255),
+ static_cast<char>(sub->get_list_elem(4)->get_float() * 255));
return true;
}
return false;
Modified: trunk/pingus/src/util/sexpr_file_writer.cpp
===================================================================
--- trunk/pingus/src/util/sexpr_file_writer.cpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/util/sexpr_file_writer.cpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -64,10 +64,10 @@
SExprFileWriter::write_color(const char* name, const Color& color)
{
(*out) << "\n" << indent() << "(" << name << " "
- << color.r/255.0f << " "
- << color.g/255.0f << " "
- << color.b/255.0f << " "
- << color.a/255.0f << ")";
+ << static_cast<float>(color.r)/255.0f << " "
+ << static_cast<float>(color.g)/255.0f << " "
+ << static_cast<float>(color.b)/255.0f << " "
+ << static_cast<float>(color.a)/255.0f << ")";
}
void
Modified: trunk/pingus/src/util/utf8.cpp
===================================================================
--- trunk/pingus/src/util/utf8.cpp 2009-11-05 02:45:14 UTC (rev 4029)
+++ trunk/pingus/src/util/utf8.cpp 2009-11-05 15:57:44 UTC (rev 4030)
@@ -128,7 +128,7 @@
uint32_t
UTF8::decode_utf8(const std::string& text, size_t& p)
{
- uint32_t c1 = static_cast<uint32_t>(text[p+0]);
+ unsigned char c1 = static_cast<unsigned char>(text[p+0]);
if (has_multibyte_mark(c1))
{
@@ -145,7 +145,7 @@
{
// 110x.xxxx: 2 byte sequence
if(p+1 >= text.size()) throw std::range_error("Malformed utf-8
sequence");
- uint32_t c2 = static_cast<uint32_t>(text[p+1]);
+ unsigned char c2 = static_cast<unsigned char>(text[p+1]);
if (!has_multibyte_mark(c2)) throw std::runtime_error("Malformed utf-8
sequence");
p+=2;
@@ -155,8 +155,8 @@
{
// 1110.xxxx: 3 byte sequence
if(p+2 >= text.size()) throw std::range_error("Malformed utf-8
sequence");
- uint32_t c2 = static_cast<uint32_t>(text[p+1]);
- uint32_t c3 = static_cast<uint32_t>(text[p+2]);
+ unsigned char c2 = static_cast<unsigned char>(text[p+1]);
+ unsigned char c3 = static_cast<unsigned char>(text[p+2]);
if (!has_multibyte_mark(c2)) throw std::runtime_error("Malformed utf-8
sequence");
if (!has_multibyte_mark(c3)) throw std::runtime_error("Malformed utf-8
sequence");
p+=3;
@@ -167,9 +167,9 @@
{
// 1111.0xxx: 4 byte sequence
if(p+3 >= text.size()) throw std::range_error("Malformed utf-8
sequence");
- uint32_t c2 = static_cast<uint32_t>(text[p+1]);
- uint32_t c3 = static_cast<uint32_t>(text[p+2]);
- uint32_t c4 = static_cast<uint32_t>(text[p+4]);
+ unsigned char c2 = static_cast<unsigned char>(text[p+1]);
+ unsigned char c3 = static_cast<unsigned char>(text[p+2]);
+ unsigned char c4 = static_cast<unsigned char>(text[p+4]);
if (!has_multibyte_mark(c2)) throw std::runtime_error("Malformed utf-8
sequence");
if (!has_multibyte_mark(c3)) throw std::runtime_error("Malformed utf-8
sequence");
if (!has_multibyte_mark(c4)) throw std::runtime_error("Malformed utf-8
sequence");
Modified: trunk/pingus/src/worldmap/level_dot.cpp
===================================================================
--- trunk/pingus/src/worldmap/level_dot.cpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/worldmap/level_dot.cpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -57,8 +57,8 @@
Vector2i mpos
=
gc.screen_to_world(Vector2i(Input::Controller::current()->get_pointer(Input::STANDARD_POINTER)->get_pos()));
- float x = mpos.x - pos.x;
- float y = mpos.y - pos.y;
+ float x = static_cast<float>(mpos.x) - pos.x;
+ float y = static_cast<float>(mpos.y) - pos.y;
bool highlight = false;
Modified: trunk/pingus/src/worldmap/sprite_drawable.cpp
===================================================================
--- trunk/pingus/src/worldmap/sprite_drawable.cpp 2009-11-05 02:45:14 UTC
(rev 4029)
+++ trunk/pingus/src/worldmap/sprite_drawable.cpp 2009-11-05 15:57:44 UTC
(rev 4030)
@@ -57,9 +57,8 @@
{
Vector3f pingus_pos = Worldmap::current()->get_pingus()->get_pos();
// Pingu is not over the surface
- if (!(pingus_pos.x > pos.x && pingus_pos.x < pos.x + surface.get_width()
- &&
- pingus_pos.y > pos.y && pingus_pos.y < pos.y +
surface.get_height()))
+ if (!(pingus_pos.x > pos.x && pingus_pos.x < pos.x +
static_cast<float>(surface.get_width()) &&
+ pingus_pos.y > pos.y && pingus_pos.y < pos.y +
static_cast<float>(surface.get_height())))
{
gc.draw(surface, pos);
}
@@ -67,14 +66,14 @@
{ // FIXME: Hack for the 0.6.0 release/tutorial world remove later
gc.draw(surface, pos);
}
- }
+ }
else
{
gc.draw(surface, pos);
}
+ }
}
-}
- } // namespace WorldmapNS
+} // namespace WorldmapNS
/* EOF */
Modified: trunk/pingus/src/worldobjs/conveyor_belt.cpp
===================================================================
--- trunk/pingus/src/worldobjs/conveyor_belt.cpp 2009-11-05 02:45:14 UTC
(rev 4029)
+++ trunk/pingus/src/worldobjs/conveyor_belt.cpp 2009-11-05 15:57:44 UTC
(rev 4030)
@@ -44,11 +44,11 @@
gc.color().draw(left_sur, pos);
for (int i=0; i < width; ++i)
gc.color().draw(middle_sur,
- Vector3f(static_cast<float>(pos.x + left_sur.get_width() +
i * middle_sur.get_width()),
+ Vector3f(static_cast<float>(pos.x +
static_cast<float>(left_sur.get_width() + i * middle_sur.get_width())),
static_cast<float>(pos.y)));
gc.color().draw(right_sur,
- Vector3f(static_cast<float>(pos.x + left_sur.get_width() +
width * middle_sur.get_width()),
+ Vector3f(static_cast<float>(pos.x +
static_cast<float>(left_sur.get_width() + width * middle_sur.get_width())),
static_cast<float>(pos.y)));
}
@@ -75,7 +75,7 @@
for (PinguIter pingu = holder->begin(); pingu != holder->end(); ++pingu)
{
if ( (*pingu)->get_pos().x > pos.x
- && (*pingu)->get_pos().x < pos.x + 15 * (width + 2)
+ && (*pingu)->get_pos().x < pos.x + 15 * static_cast<float>(width +
2)
&& (*pingu)->get_pos().y > pos.y - 2
&& (*pingu)->get_pos().y < pos.y + 10)
{
Modified: trunk/pingus/src/worldobjs/ice_block.cpp
===================================================================
--- trunk/pingus/src/worldobjs/ice_block.cpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/worldobjs/ice_block.cpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -68,8 +68,8 @@
for (PinguIter pingu = holder->begin(); pingu != holder->end(); ++pingu)
{
- if ( (*pingu)->get_x() > pos.x && (*pingu)->get_x() < pos.x +
block_sur.get_width()
- && (*pingu)->get_y() > pos.y - 4 && (*pingu)->get_y() < pos.y +
block_sur.get_height())
+ if ((*pingu)->get_x() > pos.x && (*pingu)->get_x() < pos.x +
static_cast<float>(block_sur.get_width()) &&
+ (*pingu)->get_y() > pos.y - 4 && (*pingu)->get_y() < pos.y +
static_cast<float>(block_sur.get_height()))
{
last_contact = world->get_time();
}
Modified: trunk/pingus/src/worldobjs/liquid.cpp
===================================================================
--- trunk/pingus/src/worldobjs/liquid.cpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/worldobjs/liquid.cpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -62,7 +62,7 @@
for(int i=0; i < width; ++i)
world->get_colmap()->put(mask,
- static_cast<int>(pos.x + i),
+ static_cast<int>(pos.x + static_cast<float>(i)),
static_cast<int>(pos.y),
Groundtype::GP_WATER);
}
@@ -71,7 +71,7 @@
Liquid::draw (SceneContext& gc)
{
for(int x = static_cast<int>(pos.x);
- x < pos.x + width;
+ x < static_cast<int>(pos.x) + width;
x += sur.get_width())
{
gc.color().draw(sur, Vector3f((float)x, pos.y));
Modified: trunk/pingus/src/worldobjs/rain_generator.cpp
===================================================================
--- trunk/pingus/src/worldobjs/rain_generator.cpp 2009-11-05 02:45:14 UTC
(rev 4029)
+++ trunk/pingus/src/worldobjs/rain_generator.cpp 2009-11-05 15:57:44 UTC
(rev 4030)
@@ -45,7 +45,7 @@
waiter_count = 1.0f;
}
- gc.color().fill_screen(Color(255, 255, 255,
static_cast<int>(thunder_count*255)));
+ gc.color().fill_screen(Color(255, 255, 255,
static_cast<uint8_t>(thunder_count*255)));
}
}
Modified: trunk/pingus/src/worldobjs/snow_generator.cpp
===================================================================
--- trunk/pingus/src/worldobjs/snow_generator.cpp 2009-11-05 02:45:14 UTC
(rev 4029)
+++ trunk/pingus/src/worldobjs/snow_generator.cpp 2009-11-05 15:57:44 UTC
(rev 4030)
@@ -45,7 +45,7 @@
world->get_snow_particle_holder()->add_particle(rand() %
world->get_width(), -tile_size, true);
}
- if ((intensity - (int)intensity) > Math::frand())
+ if ((intensity - static_cast<float>(static_cast<int>(intensity))) >
Math::frand())
{
if (rand() % 3 != 0)
world->get_snow_particle_holder()->add_particle(rand() %
world->get_width(), -tile_size, false);
Modified: trunk/pingus/src/worldobjs/starfield_background_stars.cpp
===================================================================
--- trunk/pingus/src/worldobjs/starfield_background_stars.cpp 2009-11-05
02:45:14 UTC (rev 4029)
+++ trunk/pingus/src/worldobjs/starfield_background_stars.cpp 2009-11-05
15:57:44 UTC (rev 4030)
@@ -45,7 +45,7 @@
x_pos = float(rand() % WorldObj::get_world()->get_width());
y_pos = float(rand() % WorldObj::get_world()->get_height());
- x_add = rand() % 5 + 1.0f;
+ x_add = static_cast<float>(rand() % 5) + 1.0f;
y_add = 0.0f;
}
Modified: trunk/pingus/src/worldobjs/surface_background.cpp
===================================================================
--- trunk/pingus/src/worldobjs/surface_background.cpp 2009-11-05 02:45:14 UTC
(rev 4029)
+++ trunk/pingus/src/worldobjs/surface_background.cpp 2009-11-05 15:57:44 UTC
(rev 4030)
@@ -72,8 +72,8 @@
{
if (keep_aspect)
{
- float aspect = surface.get_height()/float(surface.get_width());
- surface = surface.scale(world->get_width(),
int(world->get_width()*aspect));
+ float aspect = static_cast<float>(surface.get_height()) /
static_cast<float>(surface.get_width());
+ surface = surface.scale(world->get_width(),
static_cast<int>(static_cast<float>(world->get_width()) * aspect));
}
else
{
@@ -84,8 +84,8 @@
{
if (keep_aspect)
{
- float aspect = float(surface.get_width())/surface.get_height();
- surface = surface.scale(int(world->get_height() * aspect),
world->get_height());
+ float aspect = static_cast<float>(surface.get_width()) /
static_cast<float>(surface.get_height());
+ surface =
surface.scale(static_cast<int>(static_cast<float>(world->get_height()) *
aspect), world->get_height());
}
else
{
@@ -113,9 +113,9 @@
scroll_ox += scroll_x;
if (scroll_ox > bg_sprite.get_width())
- scroll_ox -= bg_sprite.get_width();
+ scroll_ox -= static_cast<float>(bg_sprite.get_width());
else if (-scroll_ox > bg_sprite.get_width())
- scroll_ox += bg_sprite.get_width();
+ scroll_ox += static_cast<float>(bg_sprite.get_width());
}
if (scroll_y)
@@ -123,9 +123,9 @@
scroll_oy += scroll_y;
if (scroll_oy > bg_sprite.get_height())
- scroll_oy -= bg_sprite.get_height();
+ scroll_oy -= static_cast<float>(bg_sprite.get_height());
else if (-scroll_oy > bg_sprite.get_height())
- scroll_oy += bg_sprite.get_height();
+ scroll_oy += static_cast<float>(bg_sprite.get_height());
}
}
@@ -140,8 +140,8 @@
offset.x -= gc.color().get_rect().left;
offset.y -= gc.color().get_rect().top;
- int start_x = static_cast<int>((offset.x * para_x) + scroll_ox);
- int start_y = static_cast<int>((offset.y * para_y) + scroll_oy);
+ int start_x = static_cast<int>((static_cast<float>(offset.x) * para_x) +
scroll_ox);
+ int start_y = static_cast<int>((static_cast<float>(offset.y) * para_y) +
scroll_oy);
if (start_x > 0)
start_x = (start_x % bg_sprite.get_width()) - bg_sprite.get_width();
Modified: trunk/pingus/src/worldobjs/switch_door.cpp
===================================================================
--- trunk/pingus/src/worldobjs/switch_door.cpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/worldobjs/switch_door.cpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -44,7 +44,7 @@
subreader.read_vector("position", door_pos);
subreader.read_int("height", door_height);
- current_door_height = door_height;
+ current_door_height = door_height;
}
void
@@ -70,7 +70,7 @@
gc.color().draw (door_box, door_pos);
for (int i=0; i < current_door_height; ++i)
gc.color().draw(door_tile, Vector3f(door_pos.x,
- door_pos.y + i * door_tile.get_height() +
door_box.get_height()));
+ door_pos.y + static_cast<float>(i *
door_tile.get_height() + door_box.get_height())));
gc.color().draw(switch_sur, switch_pos);
}
@@ -78,46 +78,46 @@
void
SwitchDoor::update ()
{
- if (current_door_height > 0)
- {
- if (!is_opening)
- {
- // Check if a pingu is passing the switch
- PinguHolder* holder = world->get_pingus();
+ if (current_door_height > 0)
+ {
+ if (!is_opening)
+ {
+ // Check if a pingu is passing the switch
+ PinguHolder* holder = world->get_pingus();
- for (PinguIter pingu = holder->begin (); pingu !=
holder->end (); ++pingu)
- {
- if ( (*pingu)->get_pos().x > switch_pos.x
- && (*pingu)->get_pos().x < switch_pos.x
+ switch_sur.get_width()
- && (*pingu)->get_pos().y > switch_pos.y
- && (*pingu)->get_pos().y < switch_pos.y
+ switch_sur.get_height())
- {
- is_opening = true;
- }
- }
- }
- else
- {
- // Open the door
- --current_door_height;
+ for (PinguIter pingu = holder->begin (); pingu != holder->end ();
++pingu)
+ {
+ if ((*pingu)->get_pos().x > switch_pos.x &&
+ (*pingu)->get_pos().x < switch_pos.x +
static_cast<float>(switch_sur.get_width()) &&
+ (*pingu)->get_pos().y > switch_pos.y &&
+ (*pingu)->get_pos().y < switch_pos.y +
static_cast<float>(switch_sur.get_height()))
+ {
+ is_opening = true;
+ }
+ }
+ }
+ else
+ {
+ // Open the door
+ --current_door_height;
- // If the door is opend enough, so that a pingus fits
under
- // it, we remove the door from the colmap
- if (current_door_height + 10 < door_height)
- {
- world->get_colmap()->put(door_box_cmap,
- static_cast<int>(door_pos.x),
- static_cast<int>(door_pos.y),
- Groundtype::GP_NOTHING);
- for (int i=0; i < door_height; ++i)
- world->get_colmap()->put(door_tile_cmap,
- static_cast<int>(door_pos.x),
- static_cast<int>(door_pos.y) + i *
door_tile.get_height()
- + door_box.get_height(),
- Groundtype::GP_NOTHING);
- }
- }
- }
+ // If the door is opend enough, so that a pingus fits under
+ // it, we remove the door from the colmap
+ if (current_door_height + 10 < door_height)
+ {
+ world->get_colmap()->put(door_box_cmap,
+ static_cast<int>(door_pos.x),
+ static_cast<int>(door_pos.y),
+ Groundtype::GP_NOTHING);
+ for (int i=0; i < door_height; ++i)
+ world->get_colmap()->put(door_tile_cmap,
+ static_cast<int>(door_pos.x),
+ static_cast<int>(door_pos.y) + i *
door_tile.get_height()
+ + door_box.get_height(),
+ Groundtype::GP_NOTHING);
+ }
+ }
+ }
}
} // namespace WorldObjs
Modified: trunk/pingus/src/worldobjs/woodthing.cpp
===================================================================
--- trunk/pingus/src/worldobjs/woodthing.cpp 2009-11-05 02:45:14 UTC (rev
4029)
+++ trunk/pingus/src/worldobjs/woodthing.cpp 2009-11-05 15:57:44 UTC (rev
4030)
@@ -44,8 +44,8 @@
if (rand() % 5 == 0)
{
world->get_smoke_particle_holder()->
- add_particle(pos.x - surface.get_width () / 2 - 24,
- pos.y - surface.get_height() + 32 - 147,
+ add_particle(pos.x - static_cast<float>(surface.get_width()) / 2.0f -
24.0f,
+ pos.y - static_cast<float>(surface.get_height()) + 32.0f
- 147.0f,
float(Math::frand() + 1) * -0.6f, float(Math::frand() +
1) * -0.6f);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r4030 - in trunk/pingus: . src/actions src/colliders src/components src/display src/editor src/input src/math src/particles src/pingus src/screen src/sound src/util src/worldmap src/worldobjs,
grumbel at BerliOS <=