From: Matthias Braun Date: Tue, 23 Jan 2007 12:33:50 +0000 (+0000) Subject: - fix a bunch of msvc warnings (mostly assigning double constants to float variables) X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=c307442e4bf1352cf1807b171b5ab175ba063b31;p=supertux.git - fix a bunch of msvc warnings (mostly assigning double constants to float variables) SVN-Revision: 4661 --- diff --git a/src/badguy/badguy.cpp b/src/badguy/badguy.cpp index 56fe165b5..e7bc8e63e 100644 --- a/src/badguy/badguy.cpp +++ b/src/badguy/badguy.cpp @@ -87,7 +87,7 @@ BadGuy::draw(DrawingContext& context) if (draw_dead_script_hint) { Vector ppos = Vector(systemRandom.randf(bbox.p1.x+8, bbox.p2.x-8), bbox.p2.y); Vector pspeed = Vector(0, -100); - Sector::current()->add_object(new Particles(ppos, 44, 46, pspeed, Vector(0,0), 1, Color(.6, .2, .2), 3, .1, LAYER_OBJECTS+1)); + Sector::current()->add_object(new Particles(ppos, 44, 46, pspeed, Vector(0,0), 1, Color(.6f, .2f, .2f), 3, .1f, LAYER_OBJECTS+1)); } } } diff --git a/src/badguy/darttrap.cpp b/src/badguy/darttrap.cpp index 9bb2eaa3a..e1f4751df 100644 --- a/src/badguy/darttrap.cpp +++ b/src/badguy/darttrap.cpp @@ -56,7 +56,7 @@ DartTrap::activate() sprite->set_action(dir == LEFT ? "idle-left" : "idle-right"); set_group(COLGROUP_DISABLED); - if (initial_delay == 0) initial_delay = 0.1; + if (initial_delay == 0) initial_delay = 0.1f; fire_timer.start(initial_delay); } diff --git a/src/badguy/flame.cpp b/src/badguy/flame.cpp index 85e470cf9..7f8d3562e 100644 --- a/src/badguy/flame.cpp +++ b/src/badguy/flame.cpp @@ -51,7 +51,7 @@ Flame::write(lisp::Writer& writer) void Flame::active_update(float elapsed_time) { - angle = fmodf(angle + elapsed_time * speed, 2*M_PI); + angle = fmodf(angle + elapsed_time * speed, (float) (2*M_PI)); Vector newpos(start_position.x + cos(angle) * radius, start_position.y + sin(angle) * radius); movement = newpos - get_pos(); diff --git a/src/badguy/flyingsnowball.cpp b/src/badguy/flyingsnowball.cpp index fd684304f..a0abf233a 100644 --- a/src/badguy/flyingsnowball.cpp +++ b/src/badguy/flyingsnowball.cpp @@ -25,13 +25,13 @@ #include "random_generator.hpp" #include "object/sprite_particle.hpp" -static const float FLYTIME = 1.0; -static const float FLYSPEED = -100.0; +static const float FLYTIME = 1.0f; +static const float FLYSPEED = -100.0f; namespace { - const float PUFF_PROBABILITY = 0.1; /**< chanche of puffs being spawned in the current cycle */ - const float PUFF_INTERVAL_MIN = 0.1; /**< spawn new puff of smoke at most that often */ - const float PUFF_INTERVAL_MAX = 1.1; /**< spawn new puff of smoke at least that often */ + const float PUFF_PROBABILITY = 0.1f; /**< chanche of puffs being spawned in the current cycle */ + const float PUFF_INTERVAL_MIN = 0.1f; /**< spawn new puff of smoke at most that often */ + const float PUFF_INTERVAL_MAX = 1.1f; /**< spawn new puff of smoke at least that often */ } FlyingSnowBall::FlyingSnowBall(const lisp::Lisp& reader) diff --git a/src/badguy/kugelblitz.cpp b/src/badguy/kugelblitz.cpp index c6242e6ad..cbfdd9986 100644 --- a/src/badguy/kugelblitz.cpp +++ b/src/badguy/kugelblitz.cpp @@ -163,7 +163,7 @@ Kugelblitz::explode() { if (!dying) { sprite->set_action("pop"); - lifetime.start(0.2); + lifetime.start(0.2f); dying = true; } else remove_me(); diff --git a/src/badguy/mole.cpp b/src/badguy/mole.cpp index d3e4e4687..73c187741 100644 --- a/src/badguy/mole.cpp +++ b/src/badguy/mole.cpp @@ -27,8 +27,8 @@ #include "log.hpp" #include "level.hpp" -static const float IDLE_TIME = 0.2; /**< time to wait before and after throwing */ -static const float THROW_TIME = 4.6; /**< time to spend throwing */ +static const float IDLE_TIME = 0.2f; /**< time to wait before and after throwing */ +static const float THROW_TIME = 4.6f; /**< time to spend throwing */ static const float THROW_INTERVAL = 1; /**< time between two thrown rocks */ static const float THROW_VELOCITY = 400; /**< initial velocity of thrown rocks */ diff --git a/src/badguy/mriceblock.cpp b/src/badguy/mriceblock.cpp index 697fed9d7..f616abb5a 100644 --- a/src/badguy/mriceblock.cpp +++ b/src/badguy/mriceblock.cpp @@ -232,7 +232,7 @@ MrIceBlock::set_state(IceState state) physic.set_velocity_x(dir == LEFT ? -KICKSPEED : KICKSPEED); sprite->set_action(dir == LEFT ? "flat-left" : "flat-right"); // we should slide above 1 block holes now... - bbox.set_size(34, 31.8); + bbox.set_size(34, 31.8f); break; case ICESTATE_GRABBED: flat_timer.stop(); diff --git a/src/badguy/mrrocket.cpp b/src/badguy/mrrocket.cpp index 3f6cc3b7a..410cc835f 100644 --- a/src/badguy/mrrocket.cpp +++ b/src/badguy/mrrocket.cpp @@ -82,7 +82,7 @@ MrRocket::collision_solid(const CollisionHit& hit) } else if(hit.left || hit.right) { sprite->set_action(dir == LEFT ? "collision-left" : "collision-right"); physic.set_velocity_x(0); - collision_timer.start(0.2, true); + collision_timer.start(0.2f, true); } } diff --git a/src/badguy/skullyhop.cpp b/src/badguy/skullyhop.cpp index 8bf61d7da..2b086eae4 100644 --- a/src/badguy/skullyhop.cpp +++ b/src/badguy/skullyhop.cpp @@ -25,8 +25,8 @@ namespace { const float VERTICAL_SPEED = -450; /**< y-speed when jumping */ const float HORIZONTAL_SPEED = 220; /**< x-speed when jumping */ - const float MIN_RECOVER_TIME = 0.1; /**< minimum time to stand still before starting a (new) jump */ - const float MAX_RECOVER_TIME = 1.0; /**< maximum time to stand still before starting a (new) jump */ + const float MIN_RECOVER_TIME = 0.1f; /**< minimum time to stand still before starting a (new) jump */ + const float MAX_RECOVER_TIME = 1.0f; /**< maximum time to stand still before starting a (new) jump */ static const std::string HOP_SOUND = "sounds/hop.ogg"; } diff --git a/src/badguy/snail.cpp b/src/badguy/snail.cpp index 1f21922af..a2695334d 100644 --- a/src/badguy/snail.cpp +++ b/src/badguy/snail.cpp @@ -96,7 +96,7 @@ Snail::be_kicked() physic.set_velocity_y(0); // start a timer to delay addition of upward movement until we are (hopefully) out from under the player - kicked_delay_timer.start(0.05); + kicked_delay_timer.start(0.05f); } bool diff --git a/src/badguy/spidermite.cpp b/src/badguy/spidermite.cpp index ee9eac956..96a90a0ee 100644 --- a/src/badguy/spidermite.cpp +++ b/src/badguy/spidermite.cpp @@ -22,8 +22,8 @@ #include "spidermite.hpp" -static const float FLYTIME = 1.2; -static const float FLYSPEED = -100.0; +static const float FLYTIME = 1.2f; +static const float FLYSPEED = -100.0f; SpiderMite::SpiderMite(const lisp::Lisp& reader) : BadGuy(reader, "images/creatures/spidermite/spidermite.sprite") diff --git a/src/badguy/stalactite.cpp b/src/badguy/stalactite.cpp index 60857fb3f..6117e2dd1 100644 --- a/src/badguy/stalactite.cpp +++ b/src/badguy/stalactite.cpp @@ -23,7 +23,7 @@ #include "random_generator.hpp" static const int SHAKE_RANGE_X = 40; -static const float SHAKE_TIME = .8; +static const float SHAKE_TIME = .8f; static const float SQUISH_TIME = 2; static const float SHAKE_RANGE_Y = 400; diff --git a/src/badguy/yeti.cpp b/src/badguy/yeti.cpp index f358b798f..76f0faa69 100644 --- a/src/badguy/yeti.cpp +++ b/src/badguy/yeti.cpp @@ -234,7 +234,7 @@ void Yeti::drop_stalactite() { // make a stalactite falling down and shake camera a bit - Sector::current()->camera->shake(.1, 0, 10); + Sector::current()->camera->shake(.1f, 0, 10); YetiStalactite* nearest = 0; float dist = FLT_MAX; diff --git a/src/badguy/yeti_stalactite.cpp b/src/badguy/yeti_stalactite.cpp index 7febf4e91..de27da329 100644 --- a/src/badguy/yeti_stalactite.cpp +++ b/src/badguy/yeti_stalactite.cpp @@ -19,7 +19,7 @@ #include "yeti_stalactite.hpp" -static const float SHAKE_TIME = .8; +static const float SHAKE_TIME = .8f; YetiStalactite::YetiStalactite(const lisp::Lisp& lisp) : Stalactite(lisp) diff --git a/src/binreloc/binreloc.c b/src/binreloc/binreloc.c index d3912d5ae..17df59e9d 100644 --- a/src/binreloc/binreloc.c +++ b/src/binreloc/binreloc.c @@ -14,7 +14,7 @@ #define __BINRELOC_C__ // [Christoph] use config.h, which defines ENABLE_BINRELOC -#include "config.h" +#include #ifdef ENABLE_BINRELOC #include diff --git a/src/binreloc/binreloc.h b/src/binreloc/binreloc.h index 4177b1b1b..592d99826 100644 --- a/src/binreloc/binreloc.h +++ b/src/binreloc/binreloc.h @@ -13,9 +13,6 @@ #ifndef __BINRELOC_H__ #define __BINRELOC_H__ -// [Christoph] use config.h, which defines ENABLE_BINRELOC -#include "config.h" - #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ diff --git a/src/collision.cpp b/src/collision.cpp index e9c25fb38..f96fdea53 100644 --- a/src/collision.cpp +++ b/src/collision.cpp @@ -57,7 +57,7 @@ namespace { c /= nval; } - static const float DELTA = .0001; + static const float DELTA = .0001f; } bool rectangle_aatriangle(Constraints* constraints, const Rect& rect, @@ -128,7 +128,7 @@ bool rectangle_aatriangle(Constraints* constraints, const Rect& rect, std::cout << "Norm: " << normal << " Depth: " << depth << "\n"; #endif - Vector outvec = normal * (depth + 0.2); + Vector outvec = normal * (depth + 0.2f); const float RDELTA = 3; if(p1.x < area.p1.x - RDELTA || p1.x > area.p2.x + RDELTA diff --git a/src/game_session.cpp b/src/game_session.cpp index 69a1265ed..c1ae83c18 100644 --- a/src/game_session.cpp +++ b/src/game_session.cpp @@ -408,7 +408,7 @@ GameSession::draw_pause(DrawingContext& context) { context.draw_filled_rect( Vector(0,0), Vector(SCREEN_WIDTH, SCREEN_HEIGHT), - Color(.2, .2, .2, .5), LAYER_FOREGROUND1); + Color(.2f, .2f, .2f, .5f), LAYER_FOREGROUND1); } void @@ -586,7 +586,7 @@ GameSession::start_sequence(const std::string& sequencename) end_sequence->start(); sound_manager->play_music("music/leveldone.ogg", false); - currentsector->player->invincible_timer.start(7.3); + currentsector->player->invincible_timer.start(7.3f); // Stop all clocks. for(std::vector::iterator i = currentsector->gameobjects.begin(); diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index 1fb5ae67f..e2ec179c3 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -40,9 +40,9 @@ #include "timer.hpp" #include "control/joystickkeyboardcontroller.hpp" -static const float MENU_REPEAT_INITIAL = 0.4; -static const float MENU_REPEAT_RATE = 0.2; -static const float FLICK_CURSOR_TIME = 0.5; +static const float MENU_REPEAT_INITIAL = 0.4f; +static const float MENU_REPEAT_RATE = 0.2f; +static const float FLICK_CURSOR_TIME = 0.5f; extern SDL_Surface* screen; @@ -81,7 +81,7 @@ bool confirm_dialog(Surface *background, std::string text) } if(background == NULL) - context.draw_gradient(Color(0.8, 0.95, 0.85), Color(0.8, 0.8, 0.8), + context.draw_gradient(Color(0.8f, 0.95f, 0.85f), Color(0.8f, 0.8f, 0.8f), LAYER_BACKGROUND0); else context.draw_surface(background, Vector(0,0), LAYER_BACKGROUND0); diff --git a/src/lisp/lexer.cpp b/src/lisp/lexer.cpp index 9b4220b08..7352c8212 100644 --- a/src/lisp/lexer.cpp +++ b/src/lisp/lexer.cpp @@ -40,7 +40,7 @@ Lexer::Lexer(std::istream& newstream) c = 0; bufend = 0; nextChar(); - } catch(EOFException& e) { + } catch(EOFException& ) { } } diff --git a/src/lisp/lisp.hpp b/src/lisp/lisp.hpp index c01170fc2..2f1464155 100644 --- a/src/lisp/lisp.hpp +++ b/src/lisp/lisp.hpp @@ -89,7 +89,7 @@ public: { if(type != TYPE_REAL) { if(type == TYPE_INTEGER) { - val = v.integer; + val = (float) v.integer; return true; } return false; diff --git a/src/main.cpp b/src/main.cpp index a8aab0649..801bf45fc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -176,6 +175,10 @@ static void init_physfs(const char* argv0) } #endif +#ifdef _WIN32 + PHYSFS_addToSearchPath(".\\data", 1); +#endif + if(!sourcedir) { #if defined(APPDATADIR) || defined(ENABLE_BINRELOC) std::string datadir; diff --git a/src/object/ambient_sound.cpp b/src/object/ambient_sound.cpp index 43ffbdeda..5d3a7929d 100644 --- a/src/object/ambient_sound.cpp +++ b/src/object/ambient_sound.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include "ambient_sound.hpp" #include "object_factory.hpp" @@ -75,7 +76,7 @@ AmbientSound::AmbientSound(const lisp::Lisp& lisp) // set default silence_distance if (distance_factor == 0) - silence_distance = 10e99; + silence_distance = std::numeric_limits::max(); else silence_distance = 1/distance_factor; @@ -101,7 +102,7 @@ AmbientSound::AmbientSound(Vector pos, float factor, float bias, float vol, std: // set default silence_distance if (distance_factor == 0) - silence_distance = 10e99; + silence_distance = std::numeric_limits::max(); else silence_distance = 1/distance_factor; @@ -134,7 +135,7 @@ AmbientSound::start_playing() sound_source->set_gain(0); sound_source->set_looping(true); - currentvolume=targetvolume=1e-20; + currentvolume=targetvolume=1e-20f; sound_source->play(); } catch(std::exception& e) { log_warning << "Couldn't play '" << sample << "': " << e.what() << "" << std::endl; @@ -175,7 +176,7 @@ AmbientSound::update(float deltat) // rise/fall half life? currentvolume*=pow(rise,deltat*10); - currentvolume += 1e-6; // volume is at least 1e-6 (0 would never rise) + currentvolume += 1e-6f; // volume is at least 1e-6 (0 would never rise) if (sound_source != 0) { diff --git a/src/object/block.cpp b/src/object/block.cpp index 0f999ae69..4b4a83e07 100644 --- a/src/object/block.cpp +++ b/src/object/block.cpp @@ -44,14 +44,14 @@ #include "lisp/list_iterator.hpp" #include "object_factory.hpp" -static const float BOUNCY_BRICK_MAX_OFFSET=8; -static const float BOUNCY_BRICK_SPEED=90; -static const float EPSILON = .0001; +static const float BOUNCY_BRICK_MAX_OFFSET = 8; +static const float BOUNCY_BRICK_SPEED = 90; +static const float EPSILON = .0001f; Block::Block(Sprite* newsprite) : sprite(newsprite), bouncing(false), breaking(false), bounce_dir(0), bounce_offset(0) { - bbox.set_size(32, 32.1); + bbox.set_size(32, 32.1f); set_group(COLGROUP_STATIC); sound_manager->preload("sounds/upgrade.wav"); sound_manager->preload("sounds/brick.wav"); diff --git a/src/object/camera.cpp b/src/object/camera.cpp index 62bfbc833..e14353ccb 100644 --- a/src/object/camera.cpp +++ b/src/object/camera.cpp @@ -172,7 +172,7 @@ Camera::scroll_to(const Vector& goal, float scrolltime) mode = SCROLLTO; } -static const float EPSILON = .00001; +static const float EPSILON = .00001f; static const float max_speed_y = 140; void diff --git a/src/object/endsequence.cpp b/src/object/endsequence.cpp index dac0b8f5c..4f17cf9f1 100644 --- a/src/object/endsequence.cpp +++ b/src/object/endsequence.cpp @@ -105,7 +105,7 @@ void EndSequence::starting() { last_x_pos = -1; - endsequence_timer.start(7.3); + endsequence_timer.start(7.3f); } void diff --git a/src/object/fireworks.cpp b/src/object/fireworks.cpp index d218c061b..d3037ea6f 100644 --- a/src/object/fireworks.cpp +++ b/src/object/fireworks.cpp @@ -31,7 +31,7 @@ Fireworks::Fireworks() { - timer.start(.2); + timer.start(.2f); sound_manager->preload("sounds/fireworks.wav"); } @@ -55,7 +55,7 @@ Fireworks::update(float ) (void) red; (void) green; sector->add_object(new Particles(pos, 0, 360, Vector(140, 140), - Vector(0, 0), 45, Color(red, green, 0), 3, 1.3, + Vector(0, 0), 45, Color(red, green, 0), 3, 1.3f, LAYER_FOREGROUND1+1)); sound_manager->play("sounds/fireworks.wav"); timer.start(systemRandom.randf(1.0, 1.5)); diff --git a/src/object/gameobjs.cpp b/src/object/gameobjs.cpp index bcbbdd503..2da97746f 100644 --- a/src/object/gameobjs.cpp +++ b/src/object/gameobjs.cpp @@ -40,7 +40,7 @@ BouncyCoin::BouncyCoin(const Vector& pos) : position(pos) { - timer.start(.3); + timer.start(.3f); sprite = sprite_manager->create("images/objects/coin/coin.sprite"); sprite->set_action("still"); } @@ -71,7 +71,7 @@ BrokenBrick::BrokenBrick(Sprite* nsprite, const Vector& pos, const Vector& nmovement) : sprite(new Sprite(*nsprite)), position(pos), movement(nmovement) { - timer.start(.2); + timer.start(.2f); } BrokenBrick::~BrokenBrick() @@ -101,14 +101,14 @@ BrokenBrick::draw(DrawingContext& context) FloatingText::FloatingText(const Vector& pos, const std::string& text_) : position(pos), text(text_) { - timer.start(.1); + timer.start(.1f); position.x -= text.size() * 8; } FloatingText::FloatingText(const Vector& pos, int score) : position(pos) { - timer.start(.1); + timer.start(.1f); // turn int into a string char str[10]; @@ -152,7 +152,7 @@ Sprite *img_smoke_cloud = 0; SmokeCloud::SmokeCloud(const Vector& pos) : position(pos) { - timer.start(.3); + timer.start(.3f); sprite = sprite_manager->create("images/objects/particles/stomp.sprite"); } diff --git a/src/object/magicblock.cpp b/src/object/magicblock.cpp index 31fcf5ef1..1c7e3cc95 100644 --- a/src/object/magicblock.cpp +++ b/src/object/magicblock.cpp @@ -34,11 +34,11 @@ #include "main.hpp" namespace { - const float MIN_INTENSITY = 0.8; - const float ALPHA_SOLID = 0.7; - const float ALPHA_NONSOLID = 0.3; - const float MIN_SOLIDTIME = 1.0; - const float SWITCH_DELAY = 0.1; /**< seconds to wait for stable conditions until switching solidity */ + const float MIN_INTENSITY = 0.8f; + const float ALPHA_SOLID = 0.7f; + const float ALPHA_NONSOLID = 0.3f; + const float MIN_SOLIDTIME = 1.0f; + const float SWITCH_DELAY = 0.1f; /**< seconds to wait for stable conditions until switching solidity */ } MagicBlock::MagicBlock(const lisp::Lisp& lisp) diff --git a/src/object/particlesystem.cpp b/src/object/particlesystem.cpp index a63afa0e5..4db97d3de 100644 --- a/src/object/particlesystem.cpp +++ b/src/object/particlesystem.cpp @@ -141,7 +141,7 @@ void SnowParticleSystem::update(float elapsed_time) anchor_delta = (particle->anchorx - particle->pos.x); particle->wobble += (4 * anchor_delta * 0.05) + systemRandom.randf(-0.5, 0.5); - particle->wobble *= 0.99; + particle->wobble *= 0.99f; particle->anchorx += particle->drift_speed * elapsed_time; } } diff --git a/src/object/player.cpp b/src/object/player.cpp index 12e750f86..41aed424b 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -51,22 +51,22 @@ #include "object/sprite_particle.hpp" static const int TILES_FOR_BUTTJUMP = 3; -static const float SHOOTING_TIME = .150; +static const float SHOOTING_TIME = .150f; /// time before idle animation starts -static const float IDLE_TIME = 2.5; +static const float IDLE_TIME = 2.5f; static const float WALK_ACCELERATION_X = 300; static const float RUN_ACCELERATION_X = 400; static const float SKID_XM = 200; -static const float SKID_TIME = .3; +static const float SKID_TIME = .3f; static const float MAX_WALK_XM = 230; static const float MAX_RUN_XM = 320; static const float WALK_SPEED = 100; -static const float KICK_TIME = .3; -static const float CHEER_TIME = 1; +static const float KICK_TIME = .3f; +static const float CHEER_TIME = 1.0f; -static const float UNDUCK_HURT_TIME = 0.25; /**< if Tux cannot unduck for this long, he will get hurt */ +static const float UNDUCK_HURT_TIME = 0.25f; /**< if Tux cannot unduck for this long, he will get hurt */ // growing animation Surface* growingtux_left[GROWING_FRAMES]; @@ -141,9 +141,9 @@ void Player::init() { if(is_big()) - set_size(31.8, 62.8); + set_size(31.8f, 62.8f); else - set_size(31.8, 30.8); + set_size(31.8f, 30.8f); dir = RIGHT; old_dir = dir; @@ -258,7 +258,7 @@ Player::update(float elapsed_time) if(fabsf(physic.get_velocity_x()) > MAX_WALK_XM) { set_width(34); } else { - set_width(31.8); + set_width(31.8f); } // on downward slopes, adjust vertical velocity so tux walks smoothly down @@ -442,7 +442,7 @@ Player::handle_horizontal_input() new Particles( Vector(dir == RIGHT ? get_bbox().p2.x : get_bbox().p1.x, get_bbox().p2.y), dir == RIGHT ? 270+20 : 90-40, dir == RIGHT ? 270+40 : 90-20, - Vector(280, -260), Vector(0, 300), 3, Color(.4, .4, .4), 3, .8, + Vector(280, -260), Vector(0, 300), 3, Color(.4f, .4f, .4f), 3, .8f, LAYER_OBJECTS+1)); ax *= 2.5; @@ -481,7 +481,7 @@ Player::do_duck() { if (!on_ground()) return; - if (adjust_height(31.8)) { + if (adjust_height(31.8f)) { duck = true; unduck_hurt_timer.stop(); } else { @@ -498,7 +498,7 @@ Player::do_standup() { if (backflipping) return; - if (adjust_height(63.8)) { + if (adjust_height(63.8f)) { duck = false; unduck_hurt_timer.stop(); } else { @@ -527,7 +527,7 @@ Player::do_backflip() { backflipping = true; do_jump(-580); sound_manager->play("sounds/flip.wav"); - backflip_timer.start(0.15); + backflip_timer.start(0.15f); } void @@ -777,7 +777,7 @@ bool Player::set_bonus(BonusType type, bool animate) { if(player_status->bonus == NO_BONUS) { - if (!adjust_height(62.8)) { + if (!adjust_height(62.8f)) { printf("can't adjust\n"); return false; } @@ -1006,7 +1006,7 @@ Player::collision_solid(const CollisionHit& hit) floor_normal = hit.slope_normal; } else if(hit.top) { if(physic.get_velocity_y() < 0) - physic.set_velocity_y(.2); + physic.set_velocity_y(.2f); } if(hit.left || hit.right) { @@ -1089,13 +1089,13 @@ Player::kill(bool completely) } else if(player_status->bonus == GROWUP_BONUS) { //growing_timer.start(GROWING_TIME); safe_timer.start(TUX_SAFE_TIME /* + GROWING_TIME */); - adjust_height(30.8); + adjust_height(30.8f); duck = false; set_bonus(NO_BONUS, true); } else if(player_status->bonus == NO_BONUS) { growing_timer.stop(); safe_timer.start(TUX_SAFE_TIME); - adjust_height(30.8); + adjust_height(30.8f); duck = false; } } else { @@ -1129,9 +1129,9 @@ Player::move(const Vector& vector) // TODO: do we need the following? Seems irrelevant to moving the player if(is_big()) - set_size(31.8, 63.8); + set_size(31.8f, 63.8f); else - set_size(31.8, 31.8); + set_size(31.8f, 31.8f); duck = false; last_ground_y = vector.y; diff --git a/src/object/player.hpp b/src/object/player.hpp index ce94e29e0..8e1264879 100644 --- a/src/object/player.hpp +++ b/src/object/player.hpp @@ -41,10 +41,10 @@ class BadGuy; class Portable; /* Times: */ -static const float TUX_SAFE_TIME = 1.8; -static const float TUX_INVINCIBLE_TIME = 10.0; -static const float TUX_INVINCIBLE_TIME_WARNING = 2.0; -static const float GROWING_TIME = 0.35; +static const float TUX_SAFE_TIME = 1.8f; +static const float TUX_INVINCIBLE_TIME = 10.0f; +static const float TUX_INVINCIBLE_TIME_WARNING = 2.0f; +static const float GROWING_TIME = 0.35f; static const int GROWING_FRAMES = 7; class Camera; diff --git a/src/object/rainsplash.cpp b/src/object/rainsplash.cpp index 913baea08..c69f817a0 100644 --- a/src/object/rainsplash.cpp +++ b/src/object/rainsplash.cpp @@ -16,6 +16,7 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#include #include "rainsplash.hpp" #include "sector.hpp" diff --git a/src/object/scripted_object.cpp b/src/object/scripted_object.cpp index b3c1158b1..eadcc4345 100644 --- a/src/object/scripted_object.cpp +++ b/src/object/scripted_object.cpp @@ -193,7 +193,7 @@ ScriptedObject::collision_solid(const CollisionHit& hit) if(physic.get_velocity_y() > 0) physic.set_velocity_y(0); } else if(hit.top) { - physic.set_velocity_y(.1); + physic.set_velocity_y(.1f); } if(hit.left || hit.right) { diff --git a/src/object/skull_tile.cpp b/src/object/skull_tile.cpp index 26b86bd56..025b5e8ae 100644 --- a/src/object/skull_tile.cpp +++ b/src/object/skull_tile.cpp @@ -28,8 +28,8 @@ #include "sprite/sprite.hpp" #include "random_generator.hpp" -static const float CRACKTIME = 0.3; -static const float FALLTIME = 0.8; +static const float CRACKTIME = 0.3f; +static const float FALLTIME = 0.8f; SkullTile::SkullTile(const lisp::Lisp& lisp) : MovingSprite(lisp, "images/objects/skull_tile/skull_tile.sprite", LAYER_TILES, COLGROUP_STATIC), hit(false), falling(false) diff --git a/src/object/sprite_particle.cpp b/src/object/sprite_particle.cpp index 18d7b888e..e914c0ce2 100644 --- a/src/object/sprite_particle.cpp +++ b/src/object/sprite_particle.cpp @@ -17,6 +17,7 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#include #include #include "sprite_particle.hpp" diff --git a/src/object/text_object.cpp b/src/object/text_object.cpp index d7f8bed18..305193762 100644 --- a/src/object/text_object.cpp +++ b/src/object/text_object.cpp @@ -125,7 +125,7 @@ TextObject::draw(DrawingContext& context) } context.draw_filled_rect(Vector(125, 50), Vector(550, 120), - Color(0.6, 0.7, 0.8, 0.5), LAYER_GUI-50); + Color(0.6f, 0.7f, 0.8f, 0.5f), LAYER_GUI-50); if (centered) { context.draw_center_text(font, text, Vector(0, 50+35), LAYER_GUI-40); } diff --git a/src/object/thunderstorm.cpp b/src/object/thunderstorm.cpp index b5d1627e8..656bd0a14 100644 --- a/src/object/thunderstorm.cpp +++ b/src/object/thunderstorm.cpp @@ -37,8 +37,8 @@ #include "log.hpp" namespace { - const float LIGHTNING_DELAY = 2.0; - const float FLASH_DISPLAY_TIME = 0.1; + const float LIGHTNING_DELAY = 2.0f; + const float FLASH_DISPLAY_TIME = 0.1f; } Thunderstorm::Thunderstorm(const lisp::Lisp& reader) diff --git a/src/object/tilemap.cpp b/src/object/tilemap.cpp index c923d5dea..d7b770a71 100644 --- a/src/object/tilemap.cpp +++ b/src/object/tilemap.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include "tilemap.hpp" #include "video/drawing_context.hpp" diff --git a/src/object/wind.cpp b/src/object/wind.cpp index 5a392c26f..638ab6956 100644 --- a/src/object/wind.cpp +++ b/src/object/wind.cpp @@ -64,7 +64,7 @@ Wind::update(float elapsed_time) // emit a particle Vector ppos = Vector(systemRandom.randf(bbox.p1.x+8, bbox.p2.x-8), systemRandom.randf(bbox.p1.y+8, bbox.p2.y-8)); Vector pspeed = Vector(speed.x, speed.y); - Sector::current()->add_object(new Particles(ppos, 44, 46, pspeed, Vector(0,0), 1, Color(.4, .4, .4), 3, .1, LAYER_BACKGROUNDTILES+1)); + Sector::current()->add_object(new Particles(ppos, 44, 46, pspeed, Vector(0,0), 1, Color(.4f, .4f, .4f), 3, .1f, LAYER_BACKGROUNDTILES+1)); } } diff --git a/src/random_generator.cpp b/src/random_generator.cpp index 0fd8dc5ac..e48b45719 100644 --- a/src/random_generator.cpp +++ b/src/random_generator.cpp @@ -33,10 +33,11 @@ // Transliterated into C++ Allen King 060417, from sources on // http://www.jbox.dk/sanos/source/lib/random.c.html - +#include #include +#include #include "random_generator.hpp" #include "scripting/squirrel_util.hpp" diff --git a/src/scripting/camera.cpp b/src/scripting/camera.cpp index 814284b8a..c0b338e72 100644 --- a/src/scripting/camera.cpp +++ b/src/scripting/camera.cpp @@ -25,7 +25,7 @@ #include "scripting/camera.hpp" #include "math/vector.hpp" -#define NOIMPL log_fatal << __PRETTY_FUNCTION__ << " not implemented." +#define NOIMPL log_fatal << __FUNCTION__ << " not implemented." namespace Scripting { @@ -37,15 +37,14 @@ namespace Scripting { } void - Camera::shake(float , float , float ) + Camera::shake(float speed, float x, float y) { - NOIMPL; + camera->shake(speed, x, y); } void Camera::set_pos(float , float ) { - NOIMPL; } void diff --git a/src/sector.cpp b/src/sector.cpp index c70d6068d..063a10a9c 100644 --- a/src/sector.cpp +++ b/src/sector.cpp @@ -423,7 +423,7 @@ Sector::fix_old_tiles() // torch if (tile->getID() == 1517) { float pseudo_rnd = (float)((int)pos.x % 10) / 10; - add_object(new PulsingLight(center, 1.0 + pseudo_rnd, 0.9, 1.0, Color(1.0, 1.0, 0.6, 1.0))); + add_object(new PulsingLight(center, 1.0f + pseudo_rnd, 0.9f, 1.0f, Color(1.0f, 1.0f, 0.6f, 1.0f))); } // lava or lavaflow if ((tile->getID() == 173) || (tile->getID() == 1700) || (tile->getID() == 1705) || (tile->getID() == 1706)) { @@ -432,7 +432,7 @@ Sector::fix_old_tiles() && (tm->get_tile(x, y-1)->getID() != tm->get_tile(x,y)->getID())) || ((x % 3 == 0) && (y % 3 == 0))) { float pseudo_rnd = (float)((int)pos.x % 10) / 10; - add_object(new PulsingLight(center, 1.0 + pseudo_rnd, 0.8, 1.0, Color(1.0, 0.3, 0.0, 1.0))); + add_object(new PulsingLight(center, 1.0f + pseudo_rnd, 0.8f, 1.0f, Color(1.0f, 0.3f, 0.0f, 1.0f))); } } @@ -838,7 +838,7 @@ Sector::draw(DrawingContext& context) } if(show_collrects) { - Color col(0.2, 0.2, 0.2, 0.7); + Color col(0.2f, 0.2f, 0.2f, 0.7f); for(MovingObjects::iterator i = moving_objects.begin(); i != moving_objects.end(); ++i) { MovingObject* object = *i; @@ -922,7 +922,7 @@ void check_collisions(collision::Constraints* constraints, } } -static const float DELTA = .001; +static const float DELTA = .001f; void Sector::collision_tilemap(collision::Constraints* constraints, diff --git a/src/sprite/sprite.hpp b/src/sprite/sprite.hpp index f37c47364..b85b62ed4 100644 --- a/src/sprite/sprite.hpp +++ b/src/sprite/sprite.hpp @@ -110,7 +110,7 @@ public: /** Set current frame */ void set_frame(int frame) { - this->frame = (frame % get_frames()); + this->frame = (float) (frame % get_frames()); } Surface* get_frame(unsigned int frame) { diff --git a/src/statistics.cpp b/src/statistics.cpp index a5a8990d6..0086eeec0 100644 --- a/src/statistics.cpp +++ b/src/statistics.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include "video/drawing_context.hpp" #include "gettext.hpp" #include "lisp/lisp.hpp" diff --git a/src/tinygettext/findlocale.cpp b/src/tinygettext/findlocale.cpp index e7deb55b2..d0a391166 100644 --- a/src/tinygettext/findlocale.cpp +++ b/src/tinygettext/findlocale.cpp @@ -26,6 +26,7 @@ use or other dealings in this Software without prior written authorization from the Author. */ +#include #include #include diff --git a/src/tinygettext/tinygettext.cpp b/src/tinygettext/tinygettext.cpp index a05d2488d..bcab14d5c 100644 --- a/src/tinygettext/tinygettext.cpp +++ b/src/tinygettext/tinygettext.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include diff --git a/src/title.cpp b/src/title.cpp index 3877c007d..569ebfd13 100644 --- a/src/title.cpp +++ b/src/title.cpp @@ -154,7 +154,8 @@ TitleScreen::get_level_name(const std::string& filename) level->get("name", name); return name; } catch(std::exception& e) { - log_warning << "Problem getting name of '" << filename << "'." << std::endl; + log_warning << "Problem getting name of '" << filename << "': " + << e.what() << std::endl; return ""; } } @@ -325,7 +326,7 @@ TitleScreen::draw(DrawingContext& context) void TitleScreen::update(float elapsed_time) { - main_loop->set_speed(0.6); + main_loop->set_speed(0.6f); Sector* sector = titlesession->get_current_sector(); sector->update(elapsed_time); @@ -414,7 +415,7 @@ TitleScreen::get_slotinfo(int slot) throw std::runtime_error("file is not a supertux-savegame."); savegame->get("title", title); - } catch(std::exception& e) { + } catch(std::exception& ) { std::ostringstream slottitle; slottitle << _("Slot") << " " << slot << " - " << _("Free"); return slottitle.str(); diff --git a/src/video/font.cpp b/src/video/font.cpp index c61ee431e..07e560626 100644 --- a/src/video/font.cpp +++ b/src/video/font.cpp @@ -249,7 +249,7 @@ Font::draw_chars(Surface* pchars, const std::string& text, const Vector& pos, c = 0; i++; } - ssize_t font_index; + int font_index; // a non-printable character? if(c == '\n') { @@ -272,7 +272,7 @@ Font::draw_chars(Surface* pchars, const std::string& text, const Vector& pos, } } - if(font_index < 0 || font_index >= (ssize_t) char_count) { + if(font_index < 0 || font_index >= (int) char_count) { log_debug << "Unsupported utf-8 character found" << std::endl; font_index = 0; } diff --git a/src/world.cpp b/src/world.cpp index 3f50e543c..9301adcfa 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -147,7 +147,7 @@ World::run() sq_release(global_vm, &world_thread); world_thread = create_thread(global_vm); compile_and_run(object_to_vm(world_thread), in, filename); - } catch(std::exception& e) { + } catch(std::exception& ) { // fallback: try to load worldmap worldmap.stwm using namespace WorldMapNS; main_loop->push_screen(new WorldMap(basedir + "worldmap.stwm")); diff --git a/src/worldmap/tux.cpp b/src/worldmap/tux.cpp index 2e89f0480..b135933f9 100644 --- a/src/worldmap/tux.cpp +++ b/src/worldmap/tux.cpp @@ -35,7 +35,7 @@ namespace WorldMapNS { static const float TUXSPEED = 200; -static const float map_message_TIME = 2.8; +static const float map_message_TIME = 2.8f; Tux::Tux(WorldMap* worldmap_) : worldmap(worldmap_) diff --git a/src/worldmap/worldmap.cpp b/src/worldmap/worldmap.cpp index da6927550..5b4595905 100644 --- a/src/worldmap/worldmap.cpp +++ b/src/worldmap/worldmap.cpp @@ -965,7 +965,7 @@ WorldMap::save_state() // push world into worlds table sq_createslot(vm, -3); - } catch(std::exception& e) { + } catch(std::exception& ) { sq_settop(vm, oldtop); }