From: Tim Goya Date: Tue, 30 Jan 2007 04:48:05 +0000 (+0000) Subject: Really, Really fix issue 0000141. Maybe broke the coin toss animation. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=b1f32292605db3100b5097e4cb09276a0ccf0c63;p=supertux.git Really, Really fix issue 0000141. Maybe broke the coin toss animation. SVN-Revision: 4738 --- diff --git a/src/game_session.cpp b/src/game_session.cpp index 84c1793cb..852d8f0ea 100644 --- a/src/game_session.cpp +++ b/src/game_session.cpp @@ -99,7 +99,7 @@ GameSession::GameSession(const std::string& levelfile_, Statistics* statistics) statistics_backdrop.reset(new Surface("images/engine/menu/score-backdrop.png")); - restart_level(true); + restart_level(); game_menu.reset(new Menu()); game_menu->add_label(_("Pause")); @@ -111,7 +111,7 @@ GameSession::GameSession(const std::string& levelfile_, Statistics* statistics) } void -GameSession::restart_level(bool fromBeginning) +GameSession::restart_level() { game_pause = false; end_sequence = 0; @@ -126,9 +126,8 @@ GameSession::restart_level(bool fromBeginning) level->stats.total_badguys = level->get_total_badguys(); level->stats.total_secrets = level->get_total_count(); level->stats.reset(); - if (!fromBeginning && (reset_sector != "")) level->stats.declare_invalid(); + if(reset_sector != "")level->stats.declare_invalid(); - if (fromBeginning) reset_sector=""; if(reset_sector != "") { currentsector = level->get_sector(reset_sector); if(!currentsector) { @@ -138,7 +137,6 @@ GameSession::restart_level(bool fromBeginning) } currentsector->activate(reset_pos); } else { - player_status->coins += 25; currentsector = level->get_sector("main"); if(!currentsector) throw std::runtime_error("Couldn't find main sector"); @@ -383,17 +381,8 @@ GameSession::check_end_conditions() /* End of level? */ if(end_sequence && end_sequence->is_done()) { finish(true); - return; } else if (!end_sequence && tux->is_dead()) { - if (player_status->coins < 0) { - // No more coins: restart level from beginning - restart_level(true); - } else { - // Still has coins: restart level from last reset point - restart_level(false); - } - - return; + restart_level(); } } diff --git a/src/game_session.hpp b/src/game_session.hpp index 4e76139bd..4143286c3 100644 --- a/src/game_session.hpp +++ b/src/game_session.hpp @@ -85,7 +85,7 @@ public: * resources for the current level/world */ std::string get_working_directory(); - void restart_level(bool fromBeginning = true); + void restart_level(); void toggle_pause(); diff --git a/src/object/player.cpp b/src/object/player.cpp index bec11024a..cf0958155 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -1099,17 +1099,24 @@ Player::kill(bool completely) duck = false; } } else { - for (int i = 0; (i < 5) && (i < player_status->coins); i++) + if (player_status->coins >= 25 && !GameSession::current()->get_reset_point_sectorname().empty()) { - // the numbers: starting x, starting y, velocity y - Sector::current()->add_object(new FallingCoin(get_pos() + - Vector(systemRandom.rand(5), systemRandom.rand(-32,18)), - systemRandom.rand(-100,100))); + for (int i = 0; i < 5; i++) + { + // the numbers: starting x, starting y, velocity y + Sector::current()->add_object(new FallingCoin(get_pos() + + Vector(systemRandom.rand(5), systemRandom.rand(-32,18)), + systemRandom.rand(-100,100))); + } + player_status->coins -= 25; + } + else + { + GameSession::current()->set_reset_point("", Vector()); } physic.enable_gravity(true); physic.set_acceleration(0, 0); physic.set_velocity(0, -700); - player_status->coins -= 25; set_bonus(NO_BONUS, true); dying = true; dying_timer.start(3.0);