offscreen.patch by Klaus Denker: correct some calculations
[supertux.git] / src / game_session.cpp
index c2aaebd..5caed2e 100644 (file)
@@ -122,8 +122,7 @@ 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)
-    level->stats.declare_invalid();
+  if (!fromBeginning && (reset_sector != "")) level->stats.declare_invalid();
 
   if (fromBeginning) reset_sector="";
   if(reset_sector != "") {
@@ -273,7 +272,12 @@ void
 GameSession::on_escape_press()
 {
   if(currentsector->player->is_dying() || end_sequence != NO_ENDSEQUENCE)
+  {
+    // Let the timers run out, we fast-forward them to force past a sequence
+    endsequence_timer.start(FLT_EPSILON); 
+    currentsector->player->dying_timer.start(FLT_EPSILON);
     return;   // don't let the player open the menu, when he is dying
+  }
 
   if(level->on_menukey_script != "") {
     std::istringstream in(level->on_menukey_script);
@@ -484,9 +488,14 @@ GameSession::update(float elapsed_time)
 
   // Update the world state and all objects in the world
   if(!game_pause) {
-    currentsector->update(elapsed_time * speed_factor);
-    play_time += elapsed_time;
-    currentsector->update(elapsed_time);
+    // Update the world
+    if (end_sequence == ENDSEQUENCE_RUNNING) {
+      currentsector->update(elapsed_time/2);
+    } else if(end_sequence == NO_ENDSEQUENCE) {
+      play_time += elapsed_time; //TODO: make sure we don't count cutscene time
+      level->stats.time = play_time;
+      currentsector->update(elapsed_time);
+    }
   }
 
   // update sounds
@@ -585,7 +594,6 @@ GameSession::start_sequence(const std::string& sequencename)
     if(end_sequence)
       return;
 
-    speed_factor = 0.5;
     end_sequence = ENDSEQUENCE_RUNNING;
     endsequence_timer.start(7.3);
     last_x_pos = -1;