Really, Really fix issue 0000141. Maybe broke the coin toss animation.
authorTim Goya <tuxdev103@gmail.com>
Tue, 30 Jan 2007 04:48:05 +0000 (04:48 +0000)
committerTim Goya <tuxdev103@gmail.com>
Tue, 30 Jan 2007 04:48:05 +0000 (04:48 +0000)
SVN-Revision: 4738

src/game_session.cpp
src/game_session.hpp
src/object/player.cpp

index 84c1793..852d8f0 100644 (file)
@@ -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<SecretAreaTrigger>();
   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();
   }
 }
 
index 4e76139..4143286 100644 (file)
@@ -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();
 
index bec1102..cf09581 100644 (file)
@@ -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);